From 7220cab4378a29a6f4607f86191f9c80a92da2e5 Mon Sep 17 00:00:00 2001 From: nickofolas Date: Fri, 11 Mar 2022 13:04:17 -0600 Subject: [PATCH] More robust augs left calculations - Should fix all issues with incorrect amount remaining --- src/Faction/ui/FactionsRoot.tsx | 50 +++++++++++++++++++++++++-------- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/src/Faction/ui/FactionsRoot.tsx b/src/Faction/ui/FactionsRoot.tsx index cec5ce15a..d923c9071 100644 --- a/src/Faction/ui/FactionsRoot.tsx +++ b/src/Faction/ui/FactionsRoot.tsx @@ -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 { + 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 { Table, TableCell } from "../../ui/React/Table"; import { IRouter } from "../../ui/Router"; + import { Faction } from "../Faction"; import { joinFaction } from "../FactionHelpers"; import { Factions } from "../Factions"; @@ -51,6 +58,29 @@ export function FactionsRoot(props: IProps): React.ReactElement { 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 + ) continue; + if (!Augmentations[augName].isSpecial) { + augs.push(augName) + } + } + } else { + augs = faction.augmentations.slice(); + } + + return augs.filter( + (augmentation: string) => !player.hasAugmentation(augmentation) + ).length; + } + return ( Factions @@ -82,11 +112,7 @@ export function FactionsRoot(props: IProps): React.ReactElement {