mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-30 03:23:48 +01:00
Refactor PlayerMultipliers.tsx
This commit is contained in:
parent
81912d7876
commit
ef29baf563
@ -45,13 +45,13 @@ function BitNodeModifiedStats(props: IBitNodeModifiedStatsProps): React.ReactEle
|
|||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
type MultiplierListItemData = [
|
interface MultiplierListItemData {
|
||||||
multiplier: string,
|
mult: string;
|
||||||
currentValue: number,
|
current: number;
|
||||||
augmentedValue: number,
|
augmented: number;
|
||||||
bitNodeMultiplier: number,
|
bnMult?: number;
|
||||||
color: string,
|
color?: string;
|
||||||
];
|
}
|
||||||
|
|
||||||
interface IMultiplierListProps {
|
interface IMultiplierListProps {
|
||||||
rows: MultiplierListItemData[];
|
rows: MultiplierListItemData[];
|
||||||
@ -60,23 +60,23 @@ interface IMultiplierListProps {
|
|||||||
function MultiplierList(props: IMultiplierListProps): React.ReactElement {
|
function MultiplierList(props: IMultiplierListProps): React.ReactElement {
|
||||||
const listItems = props.rows
|
const listItems = props.rows
|
||||||
.map((data) => {
|
.map((data) => {
|
||||||
const [multiplier, currentValue, augmentedValue, bitNodeMultiplier, color] = data;
|
const { mult, current, augmented, bnMult = 1, color = Settings.theme.primary } = data;
|
||||||
|
|
||||||
if (!isNaN(augmentedValue)) {
|
if (!isNaN(augmented)) {
|
||||||
return (
|
return (
|
||||||
<ListItem key={multiplier} disableGutters sx={{ py: 0 }}>
|
<ListItem key={mult} disableGutters sx={{ py: 0 }}>
|
||||||
<ListItemText
|
<ListItemText
|
||||||
sx={{ my: 0.1 }}
|
sx={{ my: 0.1 }}
|
||||||
primary={
|
primary={
|
||||||
<Typography color={color}>
|
<Typography color={color}>
|
||||||
<b>{multiplier}</b>
|
<b>{mult}</b>
|
||||||
</Typography>
|
</Typography>
|
||||||
}
|
}
|
||||||
secondary={
|
secondary={
|
||||||
<span style={{ display: "flex", alignItems: "center", flexWrap: "wrap" }}>
|
<span style={{ display: "flex", alignItems: "center", flexWrap: "wrap" }}>
|
||||||
<BitNodeModifiedStats base={currentValue} mult={bitNodeMultiplier} color={color} />
|
<BitNodeModifiedStats base={current} mult={bnMult} color={color} />
|
||||||
<DoubleArrow fontSize="small" color="success" sx={{ mb: 0.5, mx: 1 }} />
|
<DoubleArrow fontSize="small" color="success" sx={{ mb: 0.5, mx: 1 }} />
|
||||||
<BitNodeModifiedStats base={augmentedValue} mult={bitNodeMultiplier} color={Settings.theme.success} />
|
<BitNodeModifiedStats base={augmented} mult={bnMult} color={Settings.theme.success} />
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
disableTypography
|
disableTypography
|
||||||
@ -94,177 +94,204 @@ function MultiplierList(props: IMultiplierListProps): React.ReactElement {
|
|||||||
export function PlayerMultipliers(): React.ReactElement {
|
export function PlayerMultipliers(): React.ReactElement {
|
||||||
const mults = calculateAugmentedStats();
|
const mults = calculateAugmentedStats();
|
||||||
|
|
||||||
// Column data is a bit janky, so it's set up here to allow for
|
|
||||||
// easier logic in setting up the layout
|
|
||||||
const leftColData: MultiplierListItemData[] = [
|
const leftColData: MultiplierListItemData[] = [
|
||||||
...[
|
...[
|
||||||
["Hacking Chance ", Player.hacking_chance_mult, Player.hacking_chance_mult * mults.hacking_chance_mult, 1],
|
{
|
||||||
["Hacking Speed ", Player.hacking_speed_mult, Player.hacking_speed_mult * mults.hacking_speed_mult, 1],
|
mult: "Hacking Chance",
|
||||||
["Hacking Money ", Player.hacking_money_mult, Player.hacking_money_mult * mults.hacking_money_mult, 1],
|
current: Player.hacking_chance_mult,
|
||||||
["Hacking Growth ", Player.hacking_grow_mult, Player.hacking_grow_mult * mults.hacking_grow_mult, 1],
|
augmented: Player.hacking_chance_mult * mults.hacking_chance_mult,
|
||||||
[
|
},
|
||||||
"Hacking Level ",
|
{
|
||||||
Player.hacking_mult,
|
mult: "Hacking Speed",
|
||||||
Player.hacking_mult * mults.hacking_mult,
|
current: Player.hacking_speed_mult,
|
||||||
BitNodeMultipliers.HackingLevelMultiplier,
|
augmented: Player.hacking_speed_mult * mults.hacking_speed_mult,
|
||||||
],
|
},
|
||||||
[
|
{
|
||||||
"Hacking Experience ",
|
mult: "Hacking Money",
|
||||||
Player.hacking_exp_mult,
|
current: Player.hacking_money_mult,
|
||||||
Player.hacking_exp_mult * mults.hacking_exp_mult,
|
augmented: Player.hacking_money_mult * mults.hacking_money_mult,
|
||||||
BitNodeMultipliers.HackExpGain,
|
},
|
||||||
],
|
{
|
||||||
].map((data): MultiplierListItemData => (data as any).concat([Settings.theme.hack])),
|
mult: "Hacking Growth",
|
||||||
|
current: Player.hacking_grow_mult,
|
||||||
|
augmented: Player.hacking_grow_mult * mults.hacking_grow_mult,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
mult: "Hacking Level",
|
||||||
|
current: Player.hacking_mult,
|
||||||
|
augmented: Player.hacking_mult * mults.hacking_mult,
|
||||||
|
bnMult: BitNodeMultipliers.HackingLevelMultiplier,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
mult: "Hacking Experience",
|
||||||
|
current: Player.hacking_exp_mult,
|
||||||
|
augmented: Player.hacking_exp_mult * mults.hacking_exp_mult,
|
||||||
|
bnMult: BitNodeMultipliers.HackExpGain,
|
||||||
|
},
|
||||||
|
].map((data: MultiplierListItemData) =>
|
||||||
|
Object.defineProperty(data, "color", {
|
||||||
|
value: Settings.theme.hack,
|
||||||
|
}),
|
||||||
|
),
|
||||||
...[
|
...[
|
||||||
[
|
{
|
||||||
"Strength Level ",
|
mult: "Strength Level",
|
||||||
Player.strength_mult,
|
current: Player.strength_mult,
|
||||||
Player.strength_mult * mults.strength_mult,
|
augmented: Player.strength_mult * mults.strength_mult,
|
||||||
BitNodeMultipliers.StrengthLevelMultiplier,
|
bnMult: BitNodeMultipliers.StrengthLevelMultiplier,
|
||||||
],
|
},
|
||||||
["Strength Experience ", Player.strength_exp_mult, Player.strength_exp_mult * mults.strength_exp_mult, 1],
|
{
|
||||||
[
|
mult: "Strength Experience",
|
||||||
"Defense Level ",
|
current: Player.strength_exp_mult,
|
||||||
Player.defense_mult,
|
augmented: Player.strength_exp_mult * mults.strength_exp_mult,
|
||||||
Player.defense_mult * mults.defense_mult,
|
},
|
||||||
BitNodeMultipliers.DefenseLevelMultiplier,
|
{
|
||||||
],
|
mult: "Defense Level",
|
||||||
["Defense Experience ", Player.defense_exp_mult, Player.defense_exp_mult * mults.defense_exp_mult, 1],
|
current: Player.defense_mult,
|
||||||
[
|
augmented: Player.defense_mult * mults.defense_mult,
|
||||||
"Dexterity Level ",
|
bnMult: BitNodeMultipliers.DefenseLevelMultiplier,
|
||||||
Player.dexterity_mult,
|
},
|
||||||
Player.dexterity_mult * mults.dexterity_mult,
|
{
|
||||||
BitNodeMultipliers.DexterityLevelMultiplier,
|
mult: "Defense Experience",
|
||||||
],
|
current: Player.defense_exp_mult,
|
||||||
["Dexterity Experience ", Player.dexterity_exp_mult, Player.dexterity_exp_mult * mults.dexterity_exp_mult, 1],
|
augmented: Player.defense_exp_mult * mults.defense_exp_mult,
|
||||||
[
|
},
|
||||||
"Agility Level ",
|
{
|
||||||
Player.agility_mult,
|
mult: "Dexterity Level",
|
||||||
Player.agility_mult * mults.agility_mult,
|
current: Player.dexterity_mult,
|
||||||
BitNodeMultipliers.AgilityLevelMultiplier,
|
augmented: Player.dexterity_mult * mults.dexterity_mult,
|
||||||
],
|
bnMult: BitNodeMultipliers.DexterityLevelMultiplier,
|
||||||
["Agility Experience ", Player.agility_exp_mult, Player.agility_exp_mult * mults.agility_exp_mult, 1],
|
},
|
||||||
].map((data): MultiplierListItemData => (data as any).concat([Settings.theme.combat])),
|
{
|
||||||
[
|
mult: "Dexterity Experience",
|
||||||
"Charisma Level ",
|
current: Player.dexterity_exp_mult,
|
||||||
Player.charisma_mult,
|
augmented: Player.dexterity_exp_mult * mults.dexterity_exp_mult,
|
||||||
Player.charisma_mult * mults.charisma_mult,
|
},
|
||||||
BitNodeMultipliers.CharismaLevelMultiplier,
|
{
|
||||||
Settings.theme.cha,
|
mult: "Agility Level",
|
||||||
],
|
current: Player.agility_mult,
|
||||||
[
|
augmented: Player.agility_mult * mults.agility_mult,
|
||||||
"Charisma Experience ",
|
bnMult: BitNodeMultipliers.AgilityLevelMultiplier,
|
||||||
Player.charisma_exp_mult,
|
},
|
||||||
Player.charisma_exp_mult * mults.charisma_exp_mult,
|
{
|
||||||
1,
|
mult: "Agility Experience",
|
||||||
Settings.theme.cha,
|
current: Player.agility_exp_mult,
|
||||||
],
|
augmented: Player.agility_exp_mult * mults.agility_exp_mult,
|
||||||
|
},
|
||||||
|
].map((data: MultiplierListItemData) =>
|
||||||
|
Object.defineProperty(data, "color", {
|
||||||
|
value: Settings.theme.combat,
|
||||||
|
}),
|
||||||
|
),
|
||||||
|
{
|
||||||
|
mult: "Charisma Level",
|
||||||
|
current: Player.charisma_mult,
|
||||||
|
augmented: Player.charisma_mult * mults.charisma_mult,
|
||||||
|
bnMult: BitNodeMultipliers.CharismaLevelMultiplier,
|
||||||
|
color: Settings.theme.cha,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
mult: "Charisma Experience",
|
||||||
|
current: Player.charisma_exp_mult,
|
||||||
|
augmented: Player.charisma_exp_mult * mults.charisma_exp_mult,
|
||||||
|
color: Settings.theme.cha,
|
||||||
|
},
|
||||||
];
|
];
|
||||||
const rightColData: MultiplierListItemData[] = [
|
const rightColData: MultiplierListItemData[] = [
|
||||||
...[
|
{
|
||||||
[
|
mult: "Hacknet Node production",
|
||||||
"Hacknet Node production ",
|
current: Player.hacknet_node_money_mult,
|
||||||
Player.hacknet_node_money_mult,
|
augmented: Player.hacknet_node_money_mult * mults.hacknet_node_money_mult,
|
||||||
Player.hacknet_node_money_mult * mults.hacknet_node_money_mult,
|
bnMult: BitNodeMultipliers.HacknetNodeMoney,
|
||||||
BitNodeMultipliers.HacknetNodeMoney,
|
},
|
||||||
],
|
{
|
||||||
[
|
mult: "Hacknet Node purchase cost",
|
||||||
"Hacknet Node purchase cost ",
|
current: Player.hacknet_node_purchase_cost_mult,
|
||||||
Player.hacknet_node_purchase_cost_mult,
|
augmented: Player.hacknet_node_purchase_cost_mult * mults.hacknet_node_purchase_cost_mult,
|
||||||
Player.hacknet_node_purchase_cost_mult * mults.hacknet_node_purchase_cost_mult,
|
},
|
||||||
1,
|
{
|
||||||
],
|
mult: "Hacknet Node RAM upgrade cost",
|
||||||
[
|
current: Player.hacknet_node_ram_cost_mult,
|
||||||
"Hacknet Node RAM upgrade cost ",
|
augmented: Player.hacknet_node_ram_cost_mult * mults.hacknet_node_ram_cost_mult,
|
||||||
Player.hacknet_node_ram_cost_mult,
|
},
|
||||||
Player.hacknet_node_ram_cost_mult * mults.hacknet_node_ram_cost_mult,
|
{
|
||||||
1,
|
mult: "Hacknet Node Core purchase cost",
|
||||||
],
|
current: Player.hacknet_node_core_cost_mult,
|
||||||
[
|
augmented: Player.hacknet_node_core_cost_mult * mults.hacknet_node_core_cost_mult,
|
||||||
"Hacknet Node Core purchase cost ",
|
},
|
||||||
Player.hacknet_node_core_cost_mult,
|
{
|
||||||
Player.hacknet_node_core_cost_mult * mults.hacknet_node_core_cost_mult,
|
mult: "Hacknet Node level upgrade cost",
|
||||||
1,
|
current: Player.hacknet_node_level_cost_mult,
|
||||||
],
|
augmented: Player.hacknet_node_level_cost_mult * mults.hacknet_node_level_cost_mult,
|
||||||
[
|
},
|
||||||
"Hacknet Node level upgrade cost ",
|
{
|
||||||
Player.hacknet_node_level_cost_mult,
|
mult: "Company reputation gain",
|
||||||
Player.hacknet_node_level_cost_mult * mults.hacknet_node_level_cost_mult,
|
current: Player.company_rep_mult,
|
||||||
1,
|
augmented: Player.company_rep_mult * mults.company_rep_mult,
|
||||||
],
|
},
|
||||||
["Company reputation gain ", Player.company_rep_mult, Player.company_rep_mult * mults.company_rep_mult, 1],
|
{
|
||||||
[
|
mult: "Faction reputation gain",
|
||||||
"Faction reputation gain ",
|
current: Player.faction_rep_mult,
|
||||||
Player.faction_rep_mult,
|
augmented: Player.faction_rep_mult * mults.faction_rep_mult,
|
||||||
Player.faction_rep_mult * mults.faction_rep_mult,
|
bnMult: BitNodeMultipliers.FactionWorkRepGain,
|
||||||
BitNodeMultipliers.FactionWorkRepGain,
|
},
|
||||||
],
|
{
|
||||||
].map((data): MultiplierListItemData => (data as any).concat([Settings.theme.primary])),
|
mult: "Salary",
|
||||||
[
|
current: Player.work_money_mult,
|
||||||
"Salary ",
|
augmented: Player.work_money_mult * mults.work_money_mult,
|
||||||
Player.work_money_mult,
|
bnMult: BitNodeMultipliers.CompanyWorkMoney,
|
||||||
Player.work_money_mult * mults.work_money_mult,
|
color: Settings.theme.money,
|
||||||
BitNodeMultipliers.CompanyWorkMoney,
|
},
|
||||||
Settings.theme.money,
|
{
|
||||||
],
|
mult: "Crime success",
|
||||||
[
|
current: Player.crime_success_mult,
|
||||||
"Crime success ",
|
augmented: Player.crime_success_mult * mults.crime_success_mult,
|
||||||
Player.crime_success_mult,
|
color: Settings.theme.combat,
|
||||||
Player.crime_success_mult * mults.crime_success_mult,
|
},
|
||||||
1,
|
{
|
||||||
Settings.theme.combat,
|
mult: "Crime money",
|
||||||
],
|
current: Player.crime_money_mult,
|
||||||
[
|
augmented: Player.crime_money_mult * mults.crime_money_mult,
|
||||||
"Crime money ",
|
bnMult: BitNodeMultipliers.CrimeMoney,
|
||||||
Player.crime_money_mult,
|
color: Settings.theme.money,
|
||||||
Player.crime_money_mult * mults.crime_money_mult,
|
},
|
||||||
BitNodeMultipliers.CrimeMoney,
|
|
||||||
Settings.theme.money,
|
|
||||||
],
|
|
||||||
];
|
];
|
||||||
|
|
||||||
if (Player.canAccessBladeburner()) {
|
if (Player.canAccessBladeburner()) {
|
||||||
rightColData.push(
|
rightColData.push(
|
||||||
...[
|
{
|
||||||
[
|
mult: "Bladeburner Success Chance",
|
||||||
"Bladeburner Success Chance",
|
current: Player.bladeburner_success_chance_mult,
|
||||||
Player.bladeburner_success_chance_mult,
|
augmented: Player.bladeburner_success_chance_mult * mults.bladeburner_success_chance_mult,
|
||||||
Player.bladeburner_success_chance_mult * mults.bladeburner_success_chance_mult,
|
},
|
||||||
1,
|
{
|
||||||
],
|
mult: "Bladeburner Max Stamina",
|
||||||
[
|
current: Player.bladeburner_max_stamina_mult,
|
||||||
"Bladeburner Max Stamina",
|
augmented: Player.bladeburner_max_stamina_mult * mults.bladeburner_max_stamina_mult,
|
||||||
Player.bladeburner_max_stamina_mult,
|
},
|
||||||
Player.bladeburner_max_stamina_mult * mults.bladeburner_max_stamina_mult,
|
{
|
||||||
1,
|
mult: "Bladeburner Stamina Gain",
|
||||||
],
|
current: Player.bladeburner_stamina_gain_mult,
|
||||||
[
|
augmented: Player.bladeburner_stamina_gain_mult * mults.bladeburner_stamina_gain_mult,
|
||||||
"Bladeburner Stamina Gain",
|
},
|
||||||
Player.bladeburner_stamina_gain_mult,
|
{
|
||||||
Player.bladeburner_stamina_gain_mult * mults.bladeburner_stamina_gain_mult,
|
mult: "Bladeburner Field Analysis",
|
||||||
1,
|
current: Player.bladeburner_analysis_mult,
|
||||||
],
|
augmented: Player.bladeburner_analysis_mult * mults.bladeburner_analysis_mult,
|
||||||
[
|
},
|
||||||
"Bladeburner Field Analysis",
|
|
||||||
Player.bladeburner_analysis_mult,
|
|
||||||
Player.bladeburner_analysis_mult * mults.bladeburner_analysis_mult,
|
|
||||||
1,
|
|
||||||
],
|
|
||||||
].map((data): MultiplierListItemData => (data as any).concat([Settings.theme.primary])),
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
const hasLeftImprovements = +!!(leftColData.filter((item) => item[2] !== 0).length > 0),
|
|
||||||
hasRightImprovements = +!!(rightColData.filter((item) => item[2] !== 0).length > 0);
|
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Paper
|
<Paper
|
||||||
sx={{
|
sx={{
|
||||||
p: 1,
|
p: 1,
|
||||||
maxHeight: 400,
|
maxHeight: 400,
|
||||||
overflowY: "scroll",
|
overflowY: "scroll",
|
||||||
display: "grid",
|
display: "flex",
|
||||||
gridTemplateColumns: `repeat(${hasLeftImprovements + hasRightImprovements}, 1fr)`,
|
flexDirection: "column",
|
||||||
|
flexWrap: "wrap",
|
||||||
|
gap: 1,
|
||||||
}}
|
}}
|
||||||
>
|
>
|
||||||
<MultiplierList rows={leftColData} />
|
<MultiplierList rows={leftColData} />
|
||||||
|
Loading…
Reference in New Issue
Block a user