diff --git a/src/Augmentation/ui/PurchaseableAugmentations.tsx b/src/Augmentation/ui/PurchaseableAugmentations.tsx index 7062858d0..61c0c3b5f 100644 --- a/src/Augmentation/ui/PurchaseableAugmentations.tsx +++ b/src/Augmentation/ui/PurchaseableAugmentations.tsx @@ -4,7 +4,7 @@ */ import React, { useState } from "react"; -import { getNextNeurofluxLevel, hasAugmentationPrereqs, purchaseAugmentation } from "../../Faction/FactionHelpers"; +import { hasAugmentationPrereqs, purchaseAugmentation } from "../../Faction/FactionHelpers"; import { PurchaseAugmentationModal } from "./PurchaseAugmentationModal"; import { Augmentations } from "../Augmentations"; @@ -20,6 +20,7 @@ import { CheckBox, CheckBoxOutlineBlank, Verified, Info, Report, CheckCircle } f import { Augmentation as AugFormat } from "../../ui/React/Augmentation"; import { Paper, Button, Typography, Tooltip, Box, TableRow, Container, List, ListItem } from "@mui/material"; import { TableCell } from "../../ui/React/Table"; +import { getNextNeuroFluxLevel } from "../../Augmentation/AugmentationHelpers"; import { Augmentation } from "../Augmentation"; // interface IReqProps { @@ -233,7 +234,7 @@ export function PurchaseableAugmentation(props: IPurchaseableAugProps): React.Re // Determine button txt let btnTxt = aug.name; if (aug.name === AugmentationNames.NeuroFluxGovernor) { - btnTxt += ` - Level ${getNextNeurofluxLevel()}`; + btnTxt += ` - Level ${getNextNeuroFluxLevel()}`; } let tooltip = <>; diff --git a/src/Faction/ui/PurchaseableAugmentation.tsx b/src/Faction/ui/PurchaseableAugmentation.tsx deleted file mode 100644 index feebb29e0..000000000 --- a/src/Faction/ui/PurchaseableAugmentation.tsx +++ /dev/null @@ -1,170 +0,0 @@ -/** - * React component for displaying a single augmentation for purchase through - * the faction UI - */ -import React, { useState } from "react"; - -import { hasAugmentationPrereqs, purchaseAugmentation } from "../FactionHelpers"; -import { PurchaseAugmentationModal } from "./PurchaseAugmentationModal"; - -import { Augmentations } from "../../Augmentation/Augmentations"; -import { AugmentationNames } from "../../Augmentation/data/AugmentationNames"; -import { Faction } from "../Faction"; -import { IPlayer } from "../../PersonObjects/IPlayer"; -import { Settings } from "../../Settings/Settings"; -import { Money } from "../../ui/React/Money"; -import { Reputation } from "../../ui/React/Reputation"; - -import { Augmentation as AugFormat } from "../../ui/React/Augmentation"; -import Button from "@mui/material/Button"; -import Typography from "@mui/material/Typography"; -import Tooltip from "@mui/material/Tooltip"; -import Box from "@mui/material/Box"; -import { TableCell } from "../../ui/React/Table"; -import TableRow from "@mui/material/TableRow"; -import { getNextNeuroFluxLevel } from "../../Augmentation/AugmentationHelpers"; - -interface IReqProps { - augName: string; - p: IPlayer; - hasReq: boolean; - rep: number; - hasRep: boolean; - cost: number; - hasCost: boolean; -} - -function Requirements(props: IReqProps): React.ReactElement { - const aug = Augmentations[props.augName]; - if (!props.hasReq) { - return ( - - - Requires{" "} - {aug.prereqs.map((aug, i) => ( - - ))} - - - ); - } - - return ( - - - - - - - - - Requires faction reputation - - - - ); -} - -interface IProps { - augName: string; - faction: Faction; - p: IPlayer; - rerender: () => void; - owned?: boolean; -} - -export function PurchaseableAugmentation(props: IProps): React.ReactElement { - const [open, setOpen] = useState(false); - const aug = Augmentations[props.augName]; - if (aug == null) throw new Error(`aug ${props.augName} does not exists`); - - if (aug == null) { - console.error( - `Invalid Augmentation when trying to create PurchaseableAugmentation display element: ${props.augName}`, - ); - return <>; - } - - const moneyCost = aug.baseCost; - const repCost = aug.baseRepRequirement; - const hasReq = hasAugmentationPrereqs(aug); - const hasRep = props.faction.playerReputation >= repCost; - const hasCost = aug.baseCost === 0 || props.p.money > aug.baseCost; - - // Determine UI properties - const color: "error" | "primary" = !hasReq || !hasRep || !hasCost ? "error" : "primary"; - - // Determine button txt - let btnTxt = aug.name; - if (aug.name === AugmentationNames.NeuroFluxGovernor) { - btnTxt += ` - Level ${getNextNeuroFluxLevel()}`; - } - - let tooltip = <>; - if (typeof aug.info === "string") { - tooltip = ( - <> - {aug.info} -
-
- {aug.stats} - - ); - } else - tooltip = ( - <> - {aug.info} -
-
- {aug.stats} - - ); - - function handleClick(): void { - if (color === "error") return; - if (!Settings.SuppressBuyAugmentationConfirmation) { - setOpen(true); - } else { - purchaseAugmentation(aug, props.faction); - props.rerender(); - } - } - - return ( - - {!props.owned && ( - - - setOpen(false)} - aug={aug} - faction={props.faction} - rerender={props.rerender} - /> - - )} - - - {tooltip}} placement="top"> - {btnTxt} - - - - {!props.owned && ( - - )} - - ); -}