mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-01-04 20:37:36 +01:00
Minor code improvements
This commit is contained in:
parent
271173dca2
commit
236a5cd645
@ -34,6 +34,7 @@ interface IBitNodeModifiedStatsProps {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function BitNodeModifiedStats(props: IBitNodeModifiedStatsProps): React.ReactElement {
|
function BitNodeModifiedStats(props: IBitNodeModifiedStatsProps): React.ReactElement {
|
||||||
|
// If player doesn't have SF5 or if the property isn't affected by BitNode mults
|
||||||
if (props.mult === 1 || SourceFileFlags[5] === 0)
|
if (props.mult === 1 || SourceFileFlags[5] === 0)
|
||||||
return <Typography color={props.color}>{numeralWrapper.formatPercentage(props.base)}</Typography>;
|
return <Typography color={props.color}>{numeralWrapper.formatPercentage(props.base)}</Typography>;
|
||||||
|
|
||||||
@ -55,33 +56,28 @@ type MultiplierListItemData = [
|
|||||||
|
|
||||||
interface IMultiplierListProps {
|
interface IMultiplierListProps {
|
||||||
rows: MultiplierListItemData[];
|
rows: MultiplierListItemData[];
|
||||||
noMargin?: boolean;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
function MultiplierList({ rows, noMargin = false }: IMultiplierListProps): React.ReactElement {
|
function MultiplierList(props: IMultiplierListProps): React.ReactElement {
|
||||||
const listItems = rows
|
const listItems = props.rows
|
||||||
.map((data) => {
|
.map((data) => {
|
||||||
const mult = data[0],
|
const [multiplier, currentValue, augmentedValue, bitNodeMultiplier, color] = data;
|
||||||
value = data[1],
|
|
||||||
improved = data[2],
|
|
||||||
bnMult = data[3],
|
|
||||||
color = data[4];
|
|
||||||
|
|
||||||
if (improved) {
|
if (!isNaN(augmentedValue)) {
|
||||||
return (
|
return (
|
||||||
<ListItem key={mult} disableGutters sx={{ py: 0 }}>
|
<ListItem key={multiplier} disableGutters sx={{ py: 0 }}>
|
||||||
<ListItemText
|
<ListItemText
|
||||||
sx={{ my: 0.1 }}
|
sx={{ my: 0.1 }}
|
||||||
primary={
|
primary={
|
||||||
<Typography color={color}>
|
<Typography color={color}>
|
||||||
<b>{mult}</b>
|
<b>{multiplier}</b>
|
||||||
</Typography>
|
</Typography>
|
||||||
}
|
}
|
||||||
secondary={
|
secondary={
|
||||||
<span style={{ display: "flex", alignItems: "center", flexWrap: "wrap" }}>
|
<span style={{ display: "flex", alignItems: "center", flexWrap: "wrap" }}>
|
||||||
<BitNodeModifiedStats base={value} mult={bnMult} color={color} />
|
<BitNodeModifiedStats base={currentValue} mult={bitNodeMultiplier} 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={improved} mult={bnMult} color={Settings.theme.success} />
|
<BitNodeModifiedStats base={augmentedValue} mult={bitNodeMultiplier} color={Settings.theme.success} />
|
||||||
</span>
|
</span>
|
||||||
}
|
}
|
||||||
disableTypography
|
disableTypography
|
||||||
@ -93,19 +89,14 @@ function MultiplierList({ rows, noMargin = false }: IMultiplierListProps): React
|
|||||||
})
|
})
|
||||||
.filter((i) => i !== undefined);
|
.filter((i) => i !== undefined);
|
||||||
|
|
||||||
if (listItems.length > 0) {
|
return listItems.length > 0 ? <List disablePadding>{listItems}</List> : <></>;
|
||||||
return (
|
|
||||||
<List disablePadding sx={{ mb: noMargin ? 0 : 2 }}>
|
|
||||||
{listItems}
|
|
||||||
</List>
|
|
||||||
);
|
|
||||||
}
|
|
||||||
return <></>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
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 Chance ", Player.hacking_chance_mult, Player.hacking_chance_mult * mults.hacking_chance_mult, 1],
|
||||||
|
Loading…
Reference in New Issue
Block a user