diff --git a/src/Augmentation/ui/PurchaseAugmentationModal.tsx b/src/Augmentation/ui/PurchaseAugmentationModal.tsx
index 58c4cf76c..0a6c2e938 100644
--- a/src/Augmentation/ui/PurchaseAugmentationModal.tsx
+++ b/src/Augmentation/ui/PurchaseAugmentationModal.tsx
@@ -13,21 +13,23 @@ import Button from "@mui/material/Button";
interface IProps {
open: boolean;
onClose: () => void;
- faction: Faction;
- aug: Augmentation;
- rerender: () => void;
+ faction?: Faction;
+ aug?: Augmentation;
}
export function PurchaseAugmentationModal(props: IProps): React.ReactElement {
+ if (typeof props.aug === "undefined" || typeof props.faction === "undefined") {
+ return <>>;
+ }
+
const player = use.Player();
function buy(): void {
- if (!isRepeatableAug(props.aug) && player.hasAugmentation(props.aug)) {
+ if (!isRepeatableAug(props.aug as Augmentation) && player.hasAugmentation(props.aug as Augmentation)) {
return;
}
- purchaseAugmentation(props.aug, props.faction);
- props.rerender();
+ purchaseAugmentation(props.aug as Augmentation, props.faction as Faction);
props.onClose();
}
diff --git a/src/Augmentation/ui/PurchaseableAugmentations.tsx b/src/Augmentation/ui/PurchaseableAugmentations.tsx
index d3d9a70a4..fe07b39b2 100644
--- a/src/Augmentation/ui/PurchaseableAugmentations.tsx
+++ b/src/Augmentation/ui/PurchaseableAugmentations.tsx
@@ -131,6 +131,7 @@ interface IPurchaseableAugsProps {
rep?: number;
skipPreReqs?: boolean;
skipExclusiveIndicator?: boolean;
+ faction?: Faction;
}
export const PurchaseableAugmentations = (props: IPurchaseableAugsProps): React.ReactElement => {
@@ -140,192 +141,102 @@ export const PurchaseableAugmentations = (props: IPurchaseableAugsProps): React.
disableGutters
sx={{ mx: 0, display: "grid", gridTemplateColumns: "repeat(1, 1fr)", gap: 1 }}
>
- {props.augNames.map((augName: string) => {
- const aug = Augmentations[augName];
-
- const info = typeof aug.info === "string" ? {aug.info} : aug.info;
- const description = (
- <>
- {info}
-
-
- {aug.stats}
- >
- );
-
- return (
-
-
-
-
-
-
-
-
- {augName}
- {augName === AugmentationNames.NeuroFluxGovernor && ` - Level ${getNextNeuroFluxLevel()}`}
-
- {description}
- >
- }
- >
-
-
-
- {aug.name}
- {aug.name === AugmentationNames.NeuroFluxGovernor && ` - Level ${getNextNeuroFluxLevel()}`}
-
- {aug.factions.length === 1 && !props.skipExclusiveIndicator && (
-
- )}
-
-
- {aug.prereqs.length > 0 && !props.skipPreReqs && }
-
-
-
-
-
- aug.baseCost}
- value={numeralWrapper.formatMoney(aug.baseCost)}
- color={Settings.theme.money}
- />
- {props.rep !== undefined && (
- = aug.baseRepRequirement}
- value={`${numeralWrapper.formatReputation(aug.baseRepRequirement)} reputation`}
- color={Settings.theme.rep}
- />
- )}
-
-
-
- );
- })}
+ {props.augNames.map((augName: string) => (
+
+ ))}
);
};
interface IPurchaseableAugProps {
+ parent: IPurchaseableAugsProps;
augName: string;
- faction: Faction;
- p: IPlayer;
- rerender: () => void;
- owned?: boolean;
}
export function PurchaseableAugmentation(props: IPurchaseableAugProps): 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();
- }
- }
+ const info = typeof aug.info === "string" ? {aug.info} : aug.info;
+ const description = (
+ <>
+ {info}
+
+
+ {aug.stats}
+ >
+ );
return (
-
- {!props.owned && (
-
-
- )}
-
-
- {tooltip}} placement="top">
- {btnTxt}
-
+
+
+
+
+
+ {props.augName}
+ {props.augName === AugmentationNames.NeuroFluxGovernor && ` - Level ${getNextNeuroFluxLevel()}`}
+
+ {description}
+ >
+ }
+ >
+
+
+
+ {aug.name}
+ {aug.name === AugmentationNames.NeuroFluxGovernor && ` - Level ${getNextNeuroFluxLevel()}`}
+
+ {aug.factions.length === 1 && !props.parent.skipExclusiveIndicator && (
+
+ )}
+
+
+ {aug.prereqs.length > 0 && !props.parent.skipPreReqs && }
+
-
- {!props.owned && (
-
- )}
-
+
+
+
+ aug.baseCost}
+ value={numeralWrapper.formatMoney(aug.baseCost)}
+ color={Settings.theme.money}
+ />
+ {props.parent.rep !== undefined && (
+ = aug.baseRepRequirement}
+ value={`${numeralWrapper.formatReputation(aug.baseRepRequirement)} reputation`}
+ color={Settings.theme.rep}
+ />
+ )}
+
+
+
+ setOpen(false)} faction={props.parent.faction} aug={aug} />
+ >
);
}
diff --git a/src/Faction/ui/AugmentationsPage.tsx b/src/Faction/ui/AugmentationsPage.tsx
index 35718b458..25a94a363 100644
--- a/src/Faction/ui/AugmentationsPage.tsx
+++ b/src/Faction/ui/AugmentationsPage.tsx
@@ -14,7 +14,7 @@ import { Reputation } from "../../ui/React/Reputation";
import { Faction } from "../Faction";
import { getFactionAugmentationsFiltered, hasAugmentationPrereqs, purchaseAugmentation } from "../FactionHelpers";
-import {Box, Button, Typography, Tooltip, TableBody, Table} from "@mui/material";
+import { Box, Button, Typography, Tooltip, TableBody, Table } from "@mui/material";
import { getGenericAugmentationPriceMultiplier } from "../../Augmentation/AugmentationHelpers";
import { FactionNames } from "../data/FactionNames";
@@ -217,6 +217,7 @@ export function AugmentationsPage(props: IProps): React.ReactElement {
}
}}
rep={props.faction.playerReputation}
+ faction={props.faction}
/>
{/*