mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +01:00
Merge pull request #3119 from nickofolas/fix/augmentations-left
Fix `Augmentations Left` with gang factions
This commit is contained in:
commit
8c9e14ac0e
@ -1,14 +1,21 @@
|
|||||||
import Box from "@mui/material/Box";
|
|
||||||
import Button from "@mui/material/Button";
|
|
||||||
import Container from "@mui/material/Container";
|
|
||||||
import Paper from "@mui/material/Paper";
|
|
||||||
import TableBody from "@mui/material/TableBody";
|
|
||||||
import TableRow from "@mui/material/TableRow";
|
|
||||||
import Typography from "@mui/material/Typography";
|
|
||||||
import React, { useEffect, useState } from "react";
|
import React, { useEffect, useState } from "react";
|
||||||
|
|
||||||
|
import {
|
||||||
|
Box,
|
||||||
|
Button,
|
||||||
|
Container,
|
||||||
|
Paper,
|
||||||
|
TableBody,
|
||||||
|
TableRow,
|
||||||
|
Typography
|
||||||
|
} from "@mui/material";
|
||||||
|
|
||||||
|
import { Augmentations } from "../../Augmentation/Augmentations";
|
||||||
|
import { AugmentationNames } from "../../Augmentation/data/AugmentationNames";
|
||||||
import { IPlayer } from "../../PersonObjects/IPlayer";
|
import { IPlayer } from "../../PersonObjects/IPlayer";
|
||||||
import { Table, TableCell } from "../../ui/React/Table";
|
import { Table, TableCell } from "../../ui/React/Table";
|
||||||
import { IRouter } from "../../ui/Router";
|
import { IRouter } from "../../ui/Router";
|
||||||
|
|
||||||
import { Faction } from "../Faction";
|
import { Faction } from "../Faction";
|
||||||
import { joinFaction } from "../FactionHelpers";
|
import { joinFaction } from "../FactionHelpers";
|
||||||
import { Factions } from "../Factions";
|
import { Factions } from "../Factions";
|
||||||
@ -51,6 +58,28 @@ export function FactionsRoot(props: IProps): React.ReactElement {
|
|||||||
setRerender((x) => !x);
|
setRerender((x) => !x);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const getAugsLeft = (faction: Faction, player: IPlayer): number => {
|
||||||
|
const isPlayersGang = player.inGang() && player.getGangName() === faction.name;
|
||||||
|
let augs: string[] = [];
|
||||||
|
|
||||||
|
if (isPlayersGang) {
|
||||||
|
for (const augName of Object.keys(Augmentations)) {
|
||||||
|
if (
|
||||||
|
augName === AugmentationNames.NeuroFluxGovernor ||
|
||||||
|
augName === AugmentationNames.TheRedPill && player.bitNodeN !== 2 ||
|
||||||
|
Augmentations[augName].isSpecial
|
||||||
|
) continue;
|
||||||
|
augs.push(augName)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
augs = faction.augmentations.slice();
|
||||||
|
}
|
||||||
|
|
||||||
|
return augs.filter(
|
||||||
|
(augmentation: string) => !player.hasAugmentation(augmentation)
|
||||||
|
).length;
|
||||||
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Container disableGutters maxWidth="md" sx={{ mx: 0, mb: 10 }}>
|
<Container disableGutters maxWidth="md" sx={{ mx: 0, mb: 10 }}>
|
||||||
<Typography variant="h4">Factions</Typography>
|
<Typography variant="h4">Factions</Typography>
|
||||||
@ -82,11 +111,7 @@ export function FactionsRoot(props: IProps): React.ReactElement {
|
|||||||
<TableCell align="right">
|
<TableCell align="right">
|
||||||
<Box ml={1} mb={1}>
|
<Box ml={1} mb={1}>
|
||||||
<Button sx={{ width: '100%' }} onClick={() => openFactionAugPage(Factions[faction])}>
|
<Button sx={{ width: '100%' }} onClick={() => openFactionAugPage(Factions[faction])}>
|
||||||
Augmentations Left: {Factions[faction]
|
Augmentations Left: {getAugsLeft(Factions[faction], props.player)}
|
||||||
.augmentations
|
|
||||||
.filter((augmentation: string) =>
|
|
||||||
!props.player.hasAugmentation(augmentation))
|
|
||||||
.length}
|
|
||||||
</Button>
|
</Button>
|
||||||
</Box>
|
</Box>
|
||||||
</TableCell>
|
</TableCell>
|
||||||
|
Loading…
Reference in New Issue
Block a user