From c3a3994658c227568ea5283a8a4e39ab924e0fd1 Mon Sep 17 00:00:00 2001 From: phyzical Date: Fri, 15 Apr 2022 01:19:51 +0800 Subject: [PATCH 1/8] rename augmentation to static augmentation --- src/Augmentation/AugmentationHelpers.tsx | 21 ++++++++++--------- ...ugmentations.ts => StaticAugmentations.ts} | 2 +- src/Augmentation/ui/AugmentationsRoot.tsx | 6 ++++-- .../ui/InstalledAugmentations.tsx | 4 ++-- src/Augmentation/ui/PlayerMultipliers.tsx | 4 ++-- .../ui/PurchasedAugmentations.tsx | 4 ++-- src/Faction/FactionHelpers.tsx | 6 +++--- src/Faction/ui/AugmentationsPage.tsx | 20 +++++++++--------- src/Faction/ui/PurchaseableAugmentation.tsx | 6 +++--- src/NetscriptFunctions/Grafting.ts | 14 ++++++------- src/NetscriptFunctions/Singularity.ts | 4 ++-- src/NetscriptFunctions/Sleeve.ts | 4 ++-- src/PersonObjects/Grafting/GraftingHelpers.ts | 4 ++-- .../Grafting/ui/GraftingRoot.tsx | 21 +++++++++++-------- .../Player/PlayerObjectGeneralMethods.tsx | 3 +-- src/PersonObjects/Sleeve/SleeveHelpers.ts | 8 +++---- .../Sleeve/ui/SleeveAugmentationsModal.tsx | 4 ++-- src/Prestige.ts | 8 +++---- 18 files changed, 74 insertions(+), 69 deletions(-) rename src/Augmentation/{Augmentations.ts => StaticAugmentations.ts} (57%) diff --git a/src/Augmentation/AugmentationHelpers.tsx b/src/Augmentation/AugmentationHelpers.tsx index 18fda54f9..a302347e5 100644 --- a/src/Augmentation/AugmentationHelpers.tsx +++ b/src/Augmentation/AugmentationHelpers.tsx @@ -1,5 +1,5 @@ import { Augmentation } from "./Augmentation"; -import { Augmentations } from "./Augmentations"; +import { StaticAugmentations } from "./StaticAugmentations"; import { PlayerOwnedAugmentation, IPlayerOwnedAugmentation } from "./PlayerOwnedAugmentation"; import { AugmentationNames } from "./data/AugmentationNames"; @@ -23,7 +23,7 @@ import { import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers"; import { Router } from "../ui/GameRoot"; -export function AddToAugmentations(aug: Augmentation): void { +export function AddToStaticAugmentations(aug: Augmentation): void { const name = aug.name; Augmentations[name] = aug; } @@ -44,6 +44,7 @@ export function getNextNeuroFluxLevel(): number { } } return currLevel + 1; + StaticAugmentations[name] = aug; } function createAugmentations(): void { @@ -67,7 +68,7 @@ function resetFactionAugmentations(): void { function initAugmentations(): void { resetFactionAugmentations(); - clearObject(Augmentations); + clearObject(StaticAugmentations); createAugmentations(); updateAugmentationCosts(); Player.reapplyAllAugmentations(); @@ -127,17 +128,17 @@ function resetAugmentation(aug: Augmentation): void { aug.addToFactions(aug.factions); const name = aug.name; if (augmentationExists(name)) { - delete Augmentations[name]; + delete StaticAugmentations[name]; } - AddToAugmentations(aug); + AddToStaticAugmentations(aug); } function applyAugmentation(aug: IPlayerOwnedAugmentation, reapply = false): void { - const augObj = Augmentations[aug.name]; + const staticAugmentation = StaticAugmentations[aug.name]; // Apply multipliers - for (const mult of Object.keys(augObj.mults)) { - const v = Player.getMult(mult) * augObj.mults[mult]; + for (const mult of Object.keys(staticAugmentation.mults)) { + const v = Player.getMult(mult) * staticAugmentation.mults[mult]; Player.setMult(mult, v); } @@ -183,7 +184,7 @@ function installAugmentations(force?: boolean): boolean { } for (let i = 0; i < Player.queuedAugmentations.length; ++i) { const ownedAug = Player.queuedAugmentations[i]; - const aug = Augmentations[ownedAug.name]; + const aug = StaticAugmentations[ownedAug.name]; if (aug == null) { console.error(`Invalid augmentation: ${ownedAug.name}`); continue; @@ -213,7 +214,7 @@ function installAugmentations(force?: boolean): boolean { } function augmentationExists(name: string): boolean { - return Augmentations.hasOwnProperty(name); + return StaticAugmentations.hasOwnProperty(name); } export function isRepeatableAug(aug: Augmentation): boolean { diff --git a/src/Augmentation/Augmentations.ts b/src/Augmentation/StaticAugmentations.ts similarity index 57% rename from src/Augmentation/Augmentations.ts rename to src/Augmentation/StaticAugmentations.ts index ed2eab639..768e52770 100644 --- a/src/Augmentation/Augmentations.ts +++ b/src/Augmentation/StaticAugmentations.ts @@ -1,4 +1,4 @@ import { Augmentation } from "./Augmentation"; import { IMap } from "../types"; -export const Augmentations: IMap = {}; +export const StaticAugmentations: IMap = {}; diff --git a/src/Augmentation/ui/AugmentationsRoot.tsx b/src/Augmentation/ui/AugmentationsRoot.tsx index fcb5bd861..edb38230d 100644 --- a/src/Augmentation/ui/AugmentationsRoot.tsx +++ b/src/Augmentation/ui/AugmentationsRoot.tsx @@ -22,7 +22,7 @@ import { Settings } from "../../Settings/Settings"; import { ConfirmationModal } from "../../ui/React/ConfirmationModal"; import { IPlayer } from "../../PersonObjects/IPlayer"; import { AugmentationNames } from "../data/AugmentationNames"; -import { Augmentations } from "../Augmentations"; +import { StaticAugmentations } from "../StaticAugmentations"; import { CONSTANTS } from "../../Constants"; import { formatNumber } from "../../utils/StringHelperFunctions"; import { Info } from "@mui/icons-material"; @@ -39,7 +39,9 @@ const NeuroFluxDisplay = ({ player }: NFGDisplayProps): React.ReactElement => { NeuroFlux Governor - Level {level} - {Augmentations[AugmentationNames.NeuroFluxGovernor].stats} + + {StaticAugmentations[AugmentationNames.NeuroFluxGovernor].stats} + ) : ( <> diff --git a/src/Augmentation/ui/InstalledAugmentations.tsx b/src/Augmentation/ui/InstalledAugmentations.tsx index d200ebfa6..1ec34391f 100644 --- a/src/Augmentation/ui/InstalledAugmentations.tsx +++ b/src/Augmentation/ui/InstalledAugmentations.tsx @@ -13,7 +13,7 @@ import React, { useState } from "react"; import { OwnedAugmentationsOrderSetting } from "../../Settings/SettingEnums"; import { Settings } from "../../Settings/Settings"; import { use } from "../../ui/Context"; -import { Augmentations } from "../Augmentations"; +import { StaticAugmentations } from "../StaticAugmentations"; import { AugmentationNames } from "../data/AugmentationNames"; export function InstalledAugmentations(): React.ReactElement { @@ -77,7 +77,7 @@ export function InstalledAugmentations(): React.ReactElement { {(() => { - const aug = Augmentations[selectedAug.name]; + const aug = StaticAugmentations[selectedAug.name]; const info = typeof aug.info === "string" ? {aug.info} : aug.info; const tooltip = ( diff --git a/src/Augmentation/ui/PlayerMultipliers.tsx b/src/Augmentation/ui/PlayerMultipliers.tsx index 5b69c8a36..0b1288bef 100644 --- a/src/Augmentation/ui/PlayerMultipliers.tsx +++ b/src/Augmentation/ui/PlayerMultipliers.tsx @@ -8,7 +8,7 @@ import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers"; import { Player } from "../../Player"; import { Settings } from "../../Settings/Settings"; import { numeralWrapper } from "../../ui/numeralFormat"; -import { Augmentations } from "../Augmentations"; +import { StaticAugmentations } from "../StaticAugmentations"; interface IAugmentedStats { [index: string]: number; @@ -17,7 +17,7 @@ interface IAugmentedStats { function calculateAugmentedStats(): IAugmentedStats { const augP: IAugmentedStats = {}; for (const aug of Player.queuedAugmentations) { - const augObj = Augmentations[aug.name]; + const augObj = StaticAugmentations[aug.name]; for (const mult of Object.keys(augObj.mults)) { const v = augP[mult] ? augP[mult] : 1; augP[mult] = v * augObj.mults[mult]; diff --git a/src/Augmentation/ui/PurchasedAugmentations.tsx b/src/Augmentation/ui/PurchasedAugmentations.tsx index f3982f035..d86c9d4f6 100644 --- a/src/Augmentation/ui/PurchasedAugmentations.tsx +++ b/src/Augmentation/ui/PurchasedAugmentations.tsx @@ -5,7 +5,7 @@ import { List, ListItemText, Paper, Tooltip, Typography } from "@mui/material"; import * as React from "react"; import { Player } from "../../Player"; -import { Augmentations } from "../Augmentations"; +import { StaticAugmentations } from "../StaticAugmentations"; import { AugmentationNames } from "../data/AugmentationNames"; export function PurchasedAugmentations(): React.ReactElement { @@ -23,7 +23,7 @@ export function PurchasedAugmentations(): React.ReactElement { let displayName = ownedAug.name; if (ownedAug.name === AugmentationNames.NeuroFluxGovernor && i !== nfgIndex) continue; - const aug = Augmentations[ownedAug.name]; + const aug = StaticAugmentations[ownedAug.name]; let level = null; if (ownedAug.name === AugmentationNames.NeuroFluxGovernor) { diff --git a/src/Faction/FactionHelpers.tsx b/src/Faction/FactionHelpers.tsx index 84519d5af..43b8d80b6 100644 --- a/src/Faction/FactionHelpers.tsx +++ b/src/Faction/FactionHelpers.tsx @@ -1,4 +1,4 @@ -import { Augmentations } from "../Augmentation/Augmentations"; +import { StaticAugmentations } from "../Augmentation/StaticAugmentations"; import { Augmentation } from "../Augmentation/Augmentation"; import { PlayerOwnedAugmentation } from "../Augmentation/PlayerOwnedAugmentation"; import { AugmentationNames } from "../Augmentation/data/AugmentationNames"; @@ -57,7 +57,7 @@ export function hasAugmentationPrereqs(aug: Augmentation): boolean { let hasPrereqs = true; if (aug.prereqs && aug.prereqs.length > 0) { for (let i = 0; i < aug.prereqs.length; ++i) { - const prereqAug = Augmentations[aug.prereqs[i]]; + const prereqAug = StaticAugmentations[aug.prereqs[i]]; if (prereqAug == null) { console.error(`Invalid prereq Augmentation ${aug.prereqs[i]}`); continue; @@ -162,7 +162,7 @@ export function processPassiveFactionRepGain(numCycles: number): void { export const getFactionAugmentationsFiltered = (player: IPlayer, faction: Faction): string[] => { // If player has a gang with this faction, return (almost) all augmentations if (player.hasGangWith(faction.name)) { - let augs = Object.values(Augmentations); + let augs = Object.values(StaticAugmentations); // Remove special augs augs = augs.filter((a) => !a.isSpecial); diff --git a/src/Faction/ui/AugmentationsPage.tsx b/src/Faction/ui/AugmentationsPage.tsx index 6e220240e..ea6b90e4c 100644 --- a/src/Faction/ui/AugmentationsPage.tsx +++ b/src/Faction/ui/AugmentationsPage.tsx @@ -5,7 +5,7 @@ import React, { useState } from "react"; import { PurchaseableAugmentation } from "./PurchaseableAugmentation"; -import { Augmentations } from "../../Augmentation/Augmentations"; +import { StaticAugmentations } from "../../Augmentation/StaticAugmentations"; import { AugmentationNames } from "../../Augmentation/data/AugmentationNames"; import { Faction } from "../Faction"; import { PurchaseAugmentationsOrderSetting } from "../../Settings/SettingEnums"; @@ -63,8 +63,8 @@ export function AugmentationsPage(props: IProps): React.ReactElement { function getAugsSortedByCost(): string[] { const augs = getAugs(); augs.sort((augName1, augName2) => { - const aug1 = Augmentations[augName1], - aug2 = Augmentations[augName2]; + const aug1 = StaticAugmentations[augName1], + aug2 = StaticAugmentations[augName2]; if (aug1 == null || aug2 == null) { throw new Error("Invalid Augmentation Names"); } @@ -78,16 +78,16 @@ export function AugmentationsPage(props: IProps): React.ReactElement { function getAugsSortedByPurchasable(): string[] { const augs = getAugs(); function canBuy(augName: string): boolean { - const aug = Augmentations[augName]; const repCost = aug.baseRepRequirement; + const aug = StaticAugmentations[augName]; const hasReq = props.faction.playerReputation >= repCost; const hasRep = hasAugmentationPrereqs(aug); const hasCost = aug.baseCost !== 0 && player.money > aug.baseCost; return hasCost && hasReq && hasRep; } const buy = augs.filter(canBuy).sort((augName1, augName2) => { - const aug1 = Augmentations[augName1], - aug2 = Augmentations[augName2]; + const aug1 = StaticAugmentations[augName1], + aug2 = StaticAugmentations[augName2]; if (aug1 == null || aug2 == null) { throw new Error("Invalid Augmentation Names"); } @@ -97,8 +97,8 @@ export function AugmentationsPage(props: IProps): React.ReactElement { const cantBuy = augs .filter((aug) => !canBuy(aug)) .sort((augName1, augName2) => { - const aug1 = Augmentations[augName1], - aug2 = Augmentations[augName2]; + const aug1 = StaticAugmentations[augName1], + aug2 = StaticAugmentations[augName2]; if (aug1 == null || aug2 == null) { throw new Error("Invalid Augmentation Names"); } @@ -111,8 +111,8 @@ export function AugmentationsPage(props: IProps): React.ReactElement { function getAugsSortedByReputation(): string[] { const augs = getAugs(); augs.sort((augName1, augName2) => { - const aug1 = Augmentations[augName1], - aug2 = Augmentations[augName2]; + const aug1 = StaticAugmentations[augName1], + aug2 = StaticAugmentations[augName2]; if (aug1 == null || aug2 == null) { throw new Error("Invalid Augmentation Names"); } diff --git a/src/Faction/ui/PurchaseableAugmentation.tsx b/src/Faction/ui/PurchaseableAugmentation.tsx index feebb29e0..9446faf5e 100644 --- a/src/Faction/ui/PurchaseableAugmentation.tsx +++ b/src/Faction/ui/PurchaseableAugmentation.tsx @@ -7,7 +7,7 @@ import React, { useState } from "react"; import { hasAugmentationPrereqs, purchaseAugmentation } from "../FactionHelpers"; import { PurchaseAugmentationModal } from "./PurchaseAugmentationModal"; -import { Augmentations } from "../../Augmentation/Augmentations"; +import { StaticAugmentations } from "../../Augmentation/StaticAugmentations"; import { AugmentationNames } from "../../Augmentation/data/AugmentationNames"; import { Faction } from "../Faction"; import { IPlayer } from "../../PersonObjects/IPlayer"; @@ -35,7 +35,7 @@ interface IReqProps { } function Requirements(props: IReqProps): React.ReactElement { - const aug = Augmentations[props.augName]; + const aug = StaticAugmentations[props.augName]; if (!props.hasReq) { return ( @@ -75,7 +75,7 @@ interface IProps { export function PurchaseableAugmentation(props: IProps): React.ReactElement { const [open, setOpen] = useState(false); - const aug = Augmentations[props.augName]; + const aug = StaticAugmentations[props.augName]; if (aug == null) throw new Error(`aug ${props.augName} does not exists`); if (aug == null) { diff --git a/src/NetscriptFunctions/Grafting.ts b/src/NetscriptFunctions/Grafting.ts index 577336570..bfaf8bc70 100644 --- a/src/NetscriptFunctions/Grafting.ts +++ b/src/NetscriptFunctions/Grafting.ts @@ -1,4 +1,4 @@ -import { Augmentations } from "../Augmentation/Augmentations"; +import { StaticAugmentations } from "../Augmentation/StaticAugmentations"; import { hasAugmentationPrereqs } from "../Faction/FactionHelpers"; import { CityName } from "../Locations/data/CityNames"; import { getRamCost } from "../Netscript/RamCostGenerator"; @@ -28,10 +28,10 @@ export function NetscriptGrafting(player: IPlayer, workerScript: WorkerScript, h updateRam("getAugmentationGraftPrice"); const augName = helper.string("getAugmentationGraftPrice", "augName", _augName); checkGraftingAPIAccess("getAugmentationGraftPrice"); - if (!getGraftingAvailableAugs(player).includes(augName) || !Augmentations.hasOwnProperty(augName)) { + if (!getGraftingAvailableAugs(player).includes(augName) || !StaticAugmentations.hasOwnProperty(augName)) { throw helper.makeRuntimeErrorMsg("grafting.getAugmentationGraftPrice", `Invalid aug: ${augName}`); } - const craftableAug = new GraftableAugmentation(Augmentations[augName]); + const craftableAug = new GraftableAugmentation(StaticAugmentations[augName]); return craftableAug.cost; }, @@ -39,10 +39,10 @@ export function NetscriptGrafting(player: IPlayer, workerScript: WorkerScript, h updateRam("getAugmentationGraftTime"); const augName = helper.string("getAugmentationGraftTime", "augName", _augName); checkGraftingAPIAccess("getAugmentationGraftTime"); - if (!getGraftingAvailableAugs(player).includes(augName) || !Augmentations.hasOwnProperty(augName)) { + if (!getGraftingAvailableAugs(player).includes(augName) || !StaticAugmentations.hasOwnProperty(augName)) { throw helper.makeRuntimeErrorMsg("grafting.getAugmentationGraftTime", `Invalid aug: ${augName}`); } - const craftableAug = new GraftableAugmentation(Augmentations[augName]); + const craftableAug = new GraftableAugmentation(StaticAugmentations[augName]); return craftableAug.time; }, @@ -64,7 +64,7 @@ export function NetscriptGrafting(player: IPlayer, workerScript: WorkerScript, h "You must be in New Tokyo to begin grafting an Augmentation.", ); } - if (!getGraftingAvailableAugs(player).includes(augName) || !Augmentations.hasOwnProperty(augName)) { + if (!getGraftingAvailableAugs(player).includes(augName) || !StaticAugmentations.hasOwnProperty(augName)) { workerScript.log("grafting.graftAugmentation", () => `Invalid aug: ${augName}`); return false; } @@ -75,7 +75,7 @@ export function NetscriptGrafting(player: IPlayer, workerScript: WorkerScript, h workerScript.log("graftAugmentation", () => txt); } - const craftableAug = new GraftableAugmentation(Augmentations[augName]); + const craftableAug = new GraftableAugmentation(StaticAugmentations[augName]); if (player.money < craftableAug.cost) { workerScript.log("grafting.graftAugmentation", () => `You don't have enough money to craft ${augName}`); return false; diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index 0124e1e90..9921b0ce6 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -3,7 +3,7 @@ import { IPlayer } from "../PersonObjects/IPlayer"; import { purchaseAugmentation, joinFaction, getFactionAugmentationsFiltered } from "../Faction/FactionHelpers"; import { startWorkerScript } from "../NetscriptWorker"; import { Augmentation } from "../Augmentation/Augmentation"; -import { Augmentations } from "../Augmentation/Augmentations"; +import { StaticAugmentations } from "../Augmentation/StaticAugmentations"; import { augmentationExists, installAugmentations } from "../Augmentation/AugmentationHelpers"; import { AugmentationNames } from "../Augmentation/data/AugmentationNames"; import { killWorkerScript } from "../Netscript/killWorkerScript"; @@ -56,7 +56,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript throw _ctx.helper.makeRuntimeErrorMsg(`Invalid augmentation: '${name}'`); } - return Augmentations[name]; + return StaticAugmentations[name]; }; const getFaction = function (_ctx: NetscriptContext, name: string): Faction { diff --git a/src/NetscriptFunctions/Sleeve.ts b/src/NetscriptFunctions/Sleeve.ts index 6b7751001..d3aafceb6 100644 --- a/src/NetscriptFunctions/Sleeve.ts +++ b/src/NetscriptFunctions/Sleeve.ts @@ -5,7 +5,7 @@ import { FactionWorkType } from "../Faction/FactionWorkTypeEnum"; import { SleeveTaskType } from "../PersonObjects/Sleeve/SleeveTaskTypesEnum"; import { WorkerScript } from "../Netscript/WorkerScript"; import { findSleevePurchasableAugs } from "../PersonObjects/Sleeve/SleeveHelpers"; -import { Augmentations } from "../Augmentation/Augmentations"; +import { StaticAugmentations } from "../Augmentation/StaticAugmentations"; import { CityName } from "../Locations/data/CityNames"; import { findCrime } from "../Crime/CrimeHelpers"; @@ -298,7 +298,7 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel throw helper.makeRuntimeErrorMsg("sleeve.purchaseSleeveAug", `Sleeve shock too high: Sleeve ${sleeveNumber}`); } - const aug = Augmentations[augName]; + const aug = StaticAugmentations[augName]; if (!aug) { throw helper.makeRuntimeErrorMsg("sleeve.purchaseSleeveAug", `Invalid aug: ${augName}`); } diff --git a/src/PersonObjects/Grafting/GraftingHelpers.ts b/src/PersonObjects/Grafting/GraftingHelpers.ts index 35d4d7946..549f5babd 100644 --- a/src/PersonObjects/Grafting/GraftingHelpers.ts +++ b/src/PersonObjects/Grafting/GraftingHelpers.ts @@ -1,11 +1,11 @@ -import { Augmentations } from "../../Augmentation/Augmentations"; +import { StaticAugmentations } from "../../Augmentation/StaticAugmentations"; import { AugmentationNames } from "../../Augmentation/data/AugmentationNames"; import { IPlayer } from "../IPlayer"; export const getGraftingAvailableAugs = (player: IPlayer): string[] => { const augs: string[] = []; - for (const [augName, aug] of Object.entries(Augmentations)) { + for (const [augName, aug] of Object.entries(StaticAugmentations)) { if (augName === AugmentationNames.NeuroFluxGovernor || augName === AugmentationNames.TheRedPill || aug.isSpecial) continue; augs.push(augName); diff --git a/src/PersonObjects/Grafting/ui/GraftingRoot.tsx b/src/PersonObjects/Grafting/ui/GraftingRoot.tsx index 34e3a1a61..f6c90ae56 100644 --- a/src/PersonObjects/Grafting/ui/GraftingRoot.tsx +++ b/src/PersonObjects/Grafting/ui/GraftingRoot.tsx @@ -2,7 +2,7 @@ import { Construction, CheckBox, CheckBoxOutlineBlank } from "@mui/icons-materia import { Box, Button, Container, List, ListItemButton, Paper, Typography } from "@mui/material"; import React, { useState } from "react"; import { Augmentation } from "../../../Augmentation/Augmentation"; -import { Augmentations } from "../../../Augmentation/Augmentations"; +import { StaticAugmentations } from "../../../Augmentation/StaticAugmentations"; import { AugmentationNames } from "../../../Augmentation/data/AugmentationNames"; import { CONSTANTS } from "../../../Constants"; import { hasAugmentationPrereqs } from "../../../Faction/FactionHelpers"; @@ -54,7 +54,7 @@ export const GraftingRoot = (): React.ReactElement => { const player = use.Player(); const router = use.Router(); - for (const aug of Object.values(Augmentations)) { + for (const aug of Object.values(StaticAugmentations)) { const name = aug.name; const graftableAug = new GraftableAugmentation(aug); GraftableAugmentations[name] = graftableAug; @@ -62,7 +62,7 @@ export const GraftingRoot = (): React.ReactElement => { const [selectedAug, setSelectedAug] = useState(getGraftingAvailableAugs(player)[0]); const [graftOpen, setGraftOpen] = useState(false); - + const selectedAugmentation = StaticAugmentations[selectedAug]; return ( @@ -136,22 +136,25 @@ export const GraftingRoot = (): React.ReactElement => { )} {/* Use formula so the displayed creation time is accurate to player bonus */} - {Augmentations[selectedAug].prereqs.length > 0 && ( - + {selectedAugmentation.prereqs.length > 0 && ( + )}
{(() => { - const aug = Augmentations[selectedAug]; - - const info = typeof aug.info === "string" ? {aug.info} : aug.info; + const info = + typeof selectedAugmentation.info === "string" ? ( + {selectedAugmentation.info} + ) : ( + selectedAugmentation.info + ); const tooltip = ( <> {info}

- {aug.stats} + {selectedAugmentation.stats} ); return tooltip; diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx index a45df0b32..da4270681 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx @@ -1,6 +1,5 @@ import { IPlayer } from "../IPlayer"; import { PlayerObject } from "./PlayerObject"; -import { Augmentations } from "../../Augmentation/Augmentations"; import { applyAugmentation } from "../../Augmentation/AugmentationHelpers"; import { PlayerOwnedAugmentation } from "../../Augmentation/PlayerOwnedAugmentation"; import { AugmentationNames } from "../../Augmentation/data/AugmentationNames"; @@ -1374,7 +1373,7 @@ export function craftAugmentationWork(this: IPlayer, numCycles: number): boolean export function finishGraftAugmentationWork(this: IPlayer, cancelled: boolean): string { const augName = this.graftAugmentationName; if (cancelled === false) { - applyAugmentation(Augmentations[augName]); + applyAugmentation({ name: augName, level: 1 }); if (!this.hasAugmentation(AugmentationNames.CongruityImplant)) { this.entropy += 1; diff --git a/src/PersonObjects/Sleeve/SleeveHelpers.ts b/src/PersonObjects/Sleeve/SleeveHelpers.ts index 76bde04e8..402547632 100644 --- a/src/PersonObjects/Sleeve/SleeveHelpers.ts +++ b/src/PersonObjects/Sleeve/SleeveHelpers.ts @@ -4,7 +4,7 @@ import { Sleeve } from "./Sleeve"; import { IPlayer } from "../IPlayer"; import { Augmentation } from "../../Augmentation/Augmentation"; -import { Augmentations } from "../../Augmentation/Augmentations"; +import { StaticAugmentations } from "../../Augmentation/StaticAugmentations"; import { AugmentationNames } from "../../Augmentation/data/AugmentationNames"; import { Faction } from "../../Faction/Faction"; import { Factions } from "../../Faction/Factions"; @@ -68,8 +68,8 @@ export function findSleevePurchasableAugs(sleeve: Sleeve, p: IPlayer): Augmentat if (p.inGang()) { const fac = p.getGangFaction(); - for (const augName of Object.keys(Augmentations)) { - const aug = Augmentations[augName]; + for (const augName of Object.keys(StaticAugmentations)) { + const aug = StaticAugmentations[augName]; if (!isAvailableForSleeve(aug)) { continue; } @@ -93,7 +93,7 @@ export function findSleevePurchasableAugs(sleeve: Sleeve, p: IPlayer): Augmentat } for (const augName of fac.augmentations) { - const aug: Augmentation = Augmentations[augName]; + const aug: Augmentation = StaticAugmentations[augName]; if (!isAvailableForSleeve(aug)) { continue; } diff --git a/src/PersonObjects/Sleeve/ui/SleeveAugmentationsModal.tsx b/src/PersonObjects/Sleeve/ui/SleeveAugmentationsModal.tsx index e17118e8c..c3db83ec3 100644 --- a/src/PersonObjects/Sleeve/ui/SleeveAugmentationsModal.tsx +++ b/src/PersonObjects/Sleeve/ui/SleeveAugmentationsModal.tsx @@ -1,7 +1,7 @@ import React, { useState, useEffect } from "react"; import { Sleeve } from "../Sleeve"; import { findSleevePurchasableAugs } from "../SleeveHelpers"; -import { Augmentations } from "../../../Augmentation/Augmentations"; +import { StaticAugmentations } from "../../../Augmentation/StaticAugmentations"; import { Augmentation } from "../../../Augmentation/Augmentation"; import { Money } from "../../../ui/React/Money"; import { Modal } from "../../../ui/React/Modal"; @@ -93,7 +93,7 @@ export function SleeveAugmentationsModal(props: IProps): React.ReactElement { Owned Augmentations: {ownedAugNames.map((augName) => { - const aug = Augmentations[augName]; + const aug = StaticAugmentations[augName]; const info = typeof aug.info === "string" ? {aug.info} : aug.info; const tooltip = ( <> diff --git a/src/Prestige.ts b/src/Prestige.ts index fec16b409..a643018af 100755 --- a/src/Prestige.ts +++ b/src/Prestige.ts @@ -1,6 +1,6 @@ import { FactionNames } from "./Faction/data/FactionNames"; import { CityName } from "./Locations/data/CityNames"; -import { Augmentations } from "./Augmentation/Augmentations"; +import { StaticAugmentations } from "./Augmentation/StaticAugmentations"; import { augmentationExists, initAugmentations } from "./Augmentation/AugmentationHelpers"; import { AugmentationNames } from "./Augmentation/data/AugmentationNames"; import { initBitNodeMultipliers } from "./BitNode/BitNode"; @@ -225,9 +225,9 @@ export function prestigeSourceFile(flume: boolean): void { } // Delete all Augmentations - for (const name of Object.keys(Augmentations)) { - if (Augmentations.hasOwnProperty(name)) { - delete Augmentations[name]; + for (const name of Object.keys(StaticAugmentations)) { + if (StaticAugmentations.hasOwnProperty(name)) { + delete StaticAugmentations[name]; } } From db97125d22a36589e49e1ed019bcee8953251c3a Mon Sep 17 00:00:00 2001 From: phyzical Date: Fri, 15 Apr 2022 01:39:38 +0800 Subject: [PATCH 2/8] remove level, base cost and rep requirment from base augmentation obj * added in place calculations for cost and level of augmentations given player context * removed redundant logic for dynamically calculating cost,rep and level against the augmentation object * replaced references to startingCost to baseCost as it is now always whatever it started at --- src/Augmentation/Augmentation.tsx | 82 +++++++++++++++---- src/Augmentation/AugmentationHelpers.tsx | 79 +----------------- src/Faction/FactionHelpers.tsx | 14 ++-- src/Faction/ui/AugmentationsPage.tsx | 13 +-- src/Faction/ui/PurchaseAugmentationModal.tsx | 2 +- src/Faction/ui/PurchaseableAugmentation.tsx | 12 +-- src/NetscriptFunctions/Singularity.ts | 10 +-- src/NetscriptFunctions/Sleeve.ts | 2 +- .../Grafting/GraftableAugmentation.ts | 2 +- src/PersonObjects/Sleeve/Sleeve.ts | 4 +- src/PersonObjects/Sleeve/SleeveHelpers.ts | 4 +- .../Sleeve/ui/SleeveAugmentationsModal.tsx | 4 +- 12 files changed, 102 insertions(+), 126 deletions(-) diff --git a/src/Augmentation/Augmentation.tsx b/src/Augmentation/Augmentation.tsx index eead67a98..247c535a3 100644 --- a/src/Augmentation/Augmentation.tsx +++ b/src/Augmentation/Augmentation.tsx @@ -9,6 +9,18 @@ import { Money } from "../ui/React/Money"; import { Generic_fromJSON, Generic_toJSON, Reviver } from "../utils/JSONReviver"; import { FactionNames } from "../Faction/data/FactionNames"; +import { IPlayer } from "../PersonObjects/IPlayer"; +import { AugmentationNames } from "./data/AugmentationNames"; +import { CONSTANTS } from "../Constants"; +import { StaticAugmentations } from "./StaticAugmentations"; +import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers"; +import { getBaseAugmentationPriceMultiplier, getGenericAugmentationPriceMultiplier } from "./AugmentationHelpers"; +import { initInfiltratorsAugmentations } from "./data/AugmentationCreator"; + +export interface AugmentationCosts { + moneyCost: number; + repCost: number; +} export interface IConstructorParams { info: string | JSX.Element; @@ -410,10 +422,10 @@ function generateStatsDescription(mults: IMap, programs?: string[], star } export class Augmentation { - // How much money this costs to buy + // How much money this costs to buy before multipliers baseCost = 0; - // How much faction reputation is required to unlock this + // How much faction reputation is required to unlock this before multipliers baseRepRequirement = 0; // Description of what this Aug is and what it does @@ -425,9 +437,6 @@ export class Augmentation { // Any Augmentation not immediately available in BitNode-1 is special (e.g. Bladeburner augs) isSpecial = false; - // Augmentation level - for repeatable Augs like NeuroFlux Governor - level = 0; - // Name of Augmentation name = ""; @@ -438,12 +447,6 @@ export class Augmentation { // The Player/Person classes mults: IMap = {}; - // Initial cost. Doesn't change when you purchase multiple Augmentation - startingCost = 0; - - // Initial rep requirement. Doesn't change when you purchase multiple Augmentation - startingRepRequirement = 0; - // Factions that offer this aug. factions: string[] = []; @@ -462,16 +465,12 @@ export class Augmentation { this.baseRepRequirement = params.repCost; this.baseCost = params.moneyCost; - this.startingCost = this.baseCost; - this.startingRepRequirement = this.baseRepRequirement; this.factions = params.factions; if (params.isSpecial) { this.isSpecial = true; } - this.level = 0; - // Set multipliers if (params.hacking_mult) { this.mults.hacking_mult = params.hacking_mult; @@ -600,6 +599,59 @@ export class Augmentation { } } + getCost(player: IPlayer): AugmentationCosts { + const augmentationReference = StaticAugmentations[this.name]; + let moneyCost = augmentationReference.baseCost; + let repCost = augmentationReference.baseRepRequirement; + + if (augmentationReference.name === AugmentationNames.NeuroFluxGovernor) { + let nextLevel = this.getLevel(player); + --nextLevel; + const multiplier = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, nextLevel); + repCost = augmentationReference.baseRepRequirement * multiplier * BitNodeMultipliers.AugmentationRepCost; + moneyCost = augmentationReference.baseCost * multiplier * BitNodeMultipliers.AugmentationMoneyCost; + + for (let i = 0; i < player.queuedAugmentations.length; ++i) { + augmentationReference.baseCost *= getBaseAugmentationPriceMultiplier(); + } + } else if (augmentationReference.factions.includes(FactionNames.Infiltrators)) { + const infiltratorAugmentationNames = initInfiltratorsAugmentations().map((augmentation) => augmentation.name); + const infiltratorMultiplier = + infiltratorAugmentationNames.filter((augmentationName) => player.hasAugmentation(augmentationName)).length + 1; + moneyCost = Math.pow(augmentationReference.baseCost * 1000, infiltratorMultiplier); + if (infiltratorAugmentationNames.find((augmentationName) => augmentationName === augmentationReference.name)) { + repCost = augmentationReference.baseRepRequirement * infiltratorMultiplier; + } + } else { + moneyCost = + augmentationReference.baseCost * + getGenericAugmentationPriceMultiplier() * + BitNodeMultipliers.AugmentationMoneyCost; + } + return { moneyCost, repCost }; + } + + getLevel(player: IPlayer): number { + // Get current Neuroflux level based on Player's augmentations + if (this.name === AugmentationNames.NeuroFluxGovernor) { + let currLevel = 0; + for (let i = 0; i < player.augmentations.length; ++i) { + if (player.augmentations[i].name === AugmentationNames.NeuroFluxGovernor) { + currLevel = player.augmentations[i].level; + } + } + + // Account for purchased but uninstalled Augmentations + for (let i = 0; i < player.queuedAugmentations.length; ++i) { + if (player.queuedAugmentations[i].name == AugmentationNames.NeuroFluxGovernor) { + ++currLevel; + } + } + return currLevel + 1; + } + return 0; + } + // Adds this Augmentation to all Factions addToAllFactions(): void { for (const fac of Object.keys(Factions)) { diff --git a/src/Augmentation/AugmentationHelpers.tsx b/src/Augmentation/AugmentationHelpers.tsx index a302347e5..ba96f378e 100644 --- a/src/Augmentation/AugmentationHelpers.tsx +++ b/src/Augmentation/AugmentationHelpers.tsx @@ -20,30 +20,10 @@ import { initNeuroFluxGovernor, initUnstableCircadianModulator, } from "./data/AugmentationCreator"; -import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers"; import { Router } from "../ui/GameRoot"; export function AddToStaticAugmentations(aug: Augmentation): void { const name = aug.name; - Augmentations[name] = aug; -} - -export function getNextNeuroFluxLevel(): number { - // Get current Neuroflux level based on Player's augmentations - let currLevel = 0; - for (let i = 0; i < Player.augmentations.length; ++i) { - if (Player.augmentations[i].name === AugmentationNames.NeuroFluxGovernor) { - currLevel = Player.augmentations[i].level; - } - } - - // Account for purchased but uninstalled Augmentations - for (let i = 0; i < Player.queuedAugmentations.length; ++i) { - if (Player.queuedAugmentations[i].name == AugmentationNames.NeuroFluxGovernor) { - ++currLevel; - } - } - return currLevel + 1; StaticAugmentations[name] = aug; } @@ -70,59 +50,16 @@ function initAugmentations(): void { resetFactionAugmentations(); clearObject(StaticAugmentations); createAugmentations(); - updateAugmentationCosts(); Player.reapplyAllAugmentations(); } -function getBaseAugmentationPriceMultiplier(): number { +export function getBaseAugmentationPriceMultiplier(): number { return CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][Player.sourceFileLvl(11)]; } export function getGenericAugmentationPriceMultiplier(): number { return Math.pow(getBaseAugmentationPriceMultiplier(), Player.queuedAugmentations.length); } -function updateNeuroFluxGovernorCosts(neuroFluxGovernorAugmentation: Augmentation): void { - let nextLevel = getNextNeuroFluxLevel(); - --nextLevel; - const multiplier = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, nextLevel); - neuroFluxGovernorAugmentation.baseRepRequirement = - neuroFluxGovernorAugmentation.startingRepRequirement * multiplier * BitNodeMultipliers.AugmentationRepCost; - neuroFluxGovernorAugmentation.baseCost = - neuroFluxGovernorAugmentation.startingCost * multiplier * BitNodeMultipliers.AugmentationMoneyCost; - - for (let i = 0; i < Player.queuedAugmentations.length; ++i) { - neuroFluxGovernorAugmentation.baseCost *= getBaseAugmentationPriceMultiplier(); - } -} - -function updateInfiltratorCosts(infiltratorAugmentation: Augmentation): void { - const infiltratorAugmentationNames = initInfiltratorsAugmentations().map((augmentation) => augmentation.name); - const infiltratorMultiplier = - infiltratorAugmentationNames.filter((augmentationName) => Player.hasAugmentation(augmentationName)).length + 1; - infiltratorAugmentation.baseCost = Math.pow(infiltratorAugmentation.startingCost * 1000, infiltratorMultiplier); - if (infiltratorAugmentationNames.find((augmentationName) => augmentationName === infiltratorAugmentation.name)) { - infiltratorAugmentation.baseRepRequirement = infiltratorAugmentation.startingRepRequirement * infiltratorMultiplier; - } -} - -export function updateAugmentationCosts(): void { - for (const name of Object.keys(Augmentations)) { - if (Augmentations.hasOwnProperty(name)) { - const augmentationToUpdate = Augmentations[name]; - if (augmentationToUpdate.name === AugmentationNames.NeuroFluxGovernor) { - updateNeuroFluxGovernorCosts(augmentationToUpdate); - } else if (augmentationToUpdate.factions.includes(FactionNames.Infiltrators)) { - updateInfiltratorCosts(augmentationToUpdate); - } else { - augmentationToUpdate.baseCost = - augmentationToUpdate.startingCost * - getGenericAugmentationPriceMultiplier() * - BitNodeMultipliers.AugmentationMoneyCost; - } - } - } -} - //Resets an Augmentation during (re-initizliation) function resetAugmentation(aug: Augmentation): void { aug.addToFactions(aug.factions); @@ -142,20 +79,6 @@ function applyAugmentation(aug: IPlayerOwnedAugmentation, reapply = false): void Player.setMult(mult, v); } - // Special logic for NeuroFlux Governor - if (aug.name === AugmentationNames.NeuroFluxGovernor) { - if (!reapply) { - Augmentations[aug.name].level = aug.level; - for (let i = 0; i < Player.augmentations.length; ++i) { - if (Player.augmentations[i].name == AugmentationNames.NeuroFluxGovernor) { - Player.augmentations[i].level = aug.level; - return; - // break; - } - } - } - } - // Special logic for Congruity Implant if (aug.name === AugmentationNames.CongruityImplant && !reapply) { Player.entropy = 0; diff --git a/src/Faction/FactionHelpers.tsx b/src/Faction/FactionHelpers.tsx index 43b8d80b6..ba13ac477 100644 --- a/src/Faction/FactionHelpers.tsx +++ b/src/Faction/FactionHelpers.tsx @@ -18,7 +18,6 @@ import { import { dialogBoxCreate } from "../ui/React/DialogBox"; import { InvitationEvent } from "./ui/InvitationModal"; import { FactionNames } from "./data/FactionNames"; -import { updateAugmentationCosts, getNextNeuroFluxLevel } from "../Augmentation/AugmentationHelpers"; import { SFC32RNG } from "../Casino/RNG"; export function inviteToFaction(faction: Faction): void { @@ -82,6 +81,7 @@ export function hasAugmentationPrereqs(aug: Augmentation): boolean { export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = false): string { const hasPrereqs = hasAugmentationPrereqs(aug); + const augCosts = aug.getCost(Player); if (!hasPrereqs) { const txt = `You must first purchase or install ${aug.prereqs.join(",")} before you can purchase this one.`; if (sing) { @@ -89,28 +89,26 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal } else { dialogBoxCreate(txt); } - } else if (aug.baseCost !== 0 && Player.money < aug.baseCost) { + } else if (augCosts.moneyCost !== 0 && Player.money < augCosts.moneyCost) { const txt = "You don't have enough money to purchase " + aug.name; if (sing) { return txt; } dialogBoxCreate(txt); - } else if (fac.playerReputation < aug.baseRepRequirement) { + } else if (fac.playerReputation < augCosts.repCost) { const txt = "You don't have enough faction reputation to purchase " + aug.name; if (sing) { return txt; } dialogBoxCreate(txt); - } else if (aug.baseCost === 0 || Player.money >= aug.baseCost) { + } else if (augCosts.moneyCost === 0 || Player.money >= augCosts.moneyCost) { const queuedAugmentation = new PlayerOwnedAugmentation(aug.name); if (aug.name == AugmentationNames.NeuroFluxGovernor) { - queuedAugmentation.level = getNextNeuroFluxLevel(); + queuedAugmentation.level = aug.getLevel(Player); } Player.queuedAugmentations.push(queuedAugmentation); - Player.loseMoney(aug.baseCost, "augmentations"); - - updateAugmentationCosts(); + Player.loseMoney(augCosts.moneyCost, "augmentations"); if (sing) { return "You purchased " + aug.name; diff --git a/src/Faction/ui/AugmentationsPage.tsx b/src/Faction/ui/AugmentationsPage.tsx index ea6b90e4c..79dad99dc 100644 --- a/src/Faction/ui/AugmentationsPage.tsx +++ b/src/Faction/ui/AugmentationsPage.tsx @@ -69,7 +69,7 @@ export function AugmentationsPage(props: IProps): React.ReactElement { throw new Error("Invalid Augmentation Names"); } - return aug1.baseCost - aug2.baseCost; + return aug1.getCost(player).moneyCost - aug2.getCost(player).moneyCost; }); return augs; @@ -78,11 +78,12 @@ export function AugmentationsPage(props: IProps): React.ReactElement { function getAugsSortedByPurchasable(): string[] { const augs = getAugs(); function canBuy(augName: string): boolean { - const repCost = aug.baseRepRequirement; const aug = StaticAugmentations[augName]; + const augCosts = aug.getCost(player) + const repCost = augCosts.repCost; const hasReq = props.faction.playerReputation >= repCost; const hasRep = hasAugmentationPrereqs(aug); - const hasCost = aug.baseCost !== 0 && player.money > aug.baseCost; + const hasCost = augCosts.moneyCost !== 0 && player.money > augCosts.moneyCost; return hasCost && hasReq && hasRep; } const buy = augs.filter(canBuy).sort((augName1, augName2) => { @@ -92,7 +93,7 @@ export function AugmentationsPage(props: IProps): React.ReactElement { throw new Error("Invalid Augmentation Names"); } - return aug1.baseCost - aug2.baseCost; + return aug1.getCost(player).moneyCost - aug2.getCost(player).moneyCost; }); const cantBuy = augs .filter((aug) => !canBuy(aug)) @@ -102,7 +103,7 @@ export function AugmentationsPage(props: IProps): React.ReactElement { if (aug1 == null || aug2 == null) { throw new Error("Invalid Augmentation Names"); } - return aug1.baseRepRequirement - aug2.baseRepRequirement; + return aug1.getCost(player).repCost - aug2.getCost(player).repCost; }); return buy.concat(cantBuy); @@ -116,7 +117,7 @@ export function AugmentationsPage(props: IProps): React.ReactElement { if (aug1 == null || aug2 == null) { throw new Error("Invalid Augmentation Names"); } - return aug1.baseRepRequirement - aug2.baseRepRequirement; + return aug1.getCost(player).repCost - aug2.getCost(player).repCost; }); return augs; diff --git a/src/Faction/ui/PurchaseAugmentationModal.tsx b/src/Faction/ui/PurchaseAugmentationModal.tsx index 658978aaf..22e01c4b4 100644 --- a/src/Faction/ui/PurchaseAugmentationModal.tsx +++ b/src/Faction/ui/PurchaseAugmentationModal.tsx @@ -42,7 +42,7 @@ export function PurchaseAugmentationModal(props: IProps): React.ReactElement {

Would you like to purchase the {props.aug.name} Augmentation for  - ? + ?

diff --git a/src/Faction/ui/PurchaseableAugmentation.tsx b/src/Faction/ui/PurchaseableAugmentation.tsx index 9446faf5e..3d4ec6728 100644 --- a/src/Faction/ui/PurchaseableAugmentation.tsx +++ b/src/Faction/ui/PurchaseableAugmentation.tsx @@ -22,7 +22,7 @@ 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"; +import { use } from "../../ui/Context"; interface IReqProps { augName: string; @@ -74,6 +74,7 @@ interface IProps { } export function PurchaseableAugmentation(props: IProps): React.ReactElement { + const player = use.Player(); const [open, setOpen] = useState(false); const aug = StaticAugmentations[props.augName]; if (aug == null) throw new Error(`aug ${props.augName} does not exists`); @@ -85,11 +86,12 @@ export function PurchaseableAugmentation(props: IProps): React.ReactElement { return <>; } - const moneyCost = aug.baseCost; - const repCost = aug.baseRepRequirement; + const repCosts = aug.getCost(player); + const moneyCost = repCosts.moneyCost; + const repCost = repCosts.repCost; const hasReq = hasAugmentationPrereqs(aug); const hasRep = props.faction.playerReputation >= repCost; - const hasCost = aug.baseCost === 0 || props.p.money > aug.baseCost; + const hasCost = moneyCost === 0 || props.p.money > moneyCost; // Determine UI properties const color: "error" | "primary" = !hasReq || !hasRep || !hasCost ? "error" : "primary"; @@ -97,7 +99,7 @@ export function PurchaseableAugmentation(props: IProps): React.ReactElement { // Determine button txt let btnTxt = aug.name; if (aug.name === AugmentationNames.NeuroFluxGovernor) { - btnTxt += ` - Level ${getNextNeuroFluxLevel()}`; + btnTxt += ` - Level ${aug.getLevel(player)}`; } let tooltip = <>; diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index 9921b0ce6..5d9fa48bb 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -1,3 +1,4 @@ +import { AugmentationCosts } from "./../Augmentation/Augmentation"; import { WorkerScript } from "../Netscript/WorkerScript"; import { IPlayer } from "../PersonObjects/IPlayer"; import { purchaseAugmentation, joinFaction, getFactionAugmentationsFiltered } from "../Faction/FactionHelpers"; @@ -122,7 +123,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript _ctx.helper.checkSingularityAccess(); const augName = _ctx.helper.string("augName", _augName); const aug = getAugmentation(_ctx, augName); - return [aug.baseRepRequirement, aug.baseCost]; + return [aug.getCost(player).moneyCost, aug.getCost(player).repCost]; }, getAugmentationPrereq: (_ctx: NetscriptContext) => function (_augName: unknown): string[] { @@ -136,14 +137,14 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript _ctx.helper.checkSingularityAccess(); const augName = _ctx.helper.string("augName", _augName); const aug = getAugmentation(_ctx, augName); - return aug.baseCost; + return aug.getCost(player).moneyCost; }, getAugmentationRepReq: (_ctx: NetscriptContext) => function (_augName: unknown): number { _ctx.helper.checkSingularityAccess(); const augName = _ctx.helper.string("augName", _augName); const aug = getAugmentation(_ctx, augName); - return aug.baseRepRequirement; + return aug.getCost(player).repCost; }, getAugmentationStats: (_ctx: NetscriptContext) => function (_augName: unknown): AugmentationStats { @@ -186,7 +187,7 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript } } - if (fac.playerReputation < aug.baseRepRequirement) { + if (fac.playerReputation < aug.getCost(player).repCost) { workerScript.log("purchaseAugmentation", () => `You do not have enough reputation with '${fac.name}'.`); return false; } @@ -1128,7 +1129,6 @@ export function NetscriptSingularity(player: IPlayer, workerScript: WorkerScript workerScript.log("workForFaction", () => `Invalid work type: '${type}`); return false; } - return true; }, getFactionRep: (_ctx: NetscriptContext) => function (_facName: unknown): number { diff --git a/src/NetscriptFunctions/Sleeve.ts b/src/NetscriptFunctions/Sleeve.ts index d3aafceb6..d2aa0b452 100644 --- a/src/NetscriptFunctions/Sleeve.ts +++ b/src/NetscriptFunctions/Sleeve.ts @@ -281,7 +281,7 @@ export function NetscriptSleeve(player: IPlayer, workerScript: WorkerScript, hel const aug = purchasableAugs[i]; augs.push({ name: aug.name, - cost: aug.startingCost, + cost: aug.baseCost, }); } diff --git a/src/PersonObjects/Grafting/GraftableAugmentation.ts b/src/PersonObjects/Grafting/GraftableAugmentation.ts index dbace889d..6875bbfc4 100644 --- a/src/PersonObjects/Grafting/GraftableAugmentation.ts +++ b/src/PersonObjects/Grafting/GraftableAugmentation.ts @@ -18,7 +18,7 @@ export class GraftableAugmentation { } get cost(): number { - return this.augmentation.startingCost * CONSTANTS.AugmentationGraftingCostMult; + return this.augmentation.baseCost * CONSTANTS.AugmentationGraftingCostMult; } get time(): number { diff --git a/src/PersonObjects/Sleeve/Sleeve.ts b/src/PersonObjects/Sleeve/Sleeve.ts index 74295b062..144e79357 100644 --- a/src/PersonObjects/Sleeve/Sleeve.ts +++ b/src/PersonObjects/Sleeve/Sleeve.ts @@ -678,7 +678,7 @@ export class Sleeve extends Person { } tryBuyAugmentation(p: IPlayer, aug: Augmentation): boolean { - if (!p.canAfford(aug.startingCost)) { + if (!p.canAfford(aug.baseCost)) { return false; } @@ -687,7 +687,7 @@ export class Sleeve extends Person { return false; } - p.loseMoney(aug.startingCost, "sleeves"); + p.loseMoney(aug.baseCost, "sleeves"); this.installAugmentation(aug); return true; } diff --git a/src/PersonObjects/Sleeve/SleeveHelpers.ts b/src/PersonObjects/Sleeve/SleeveHelpers.ts index 402547632..a53470573 100644 --- a/src/PersonObjects/Sleeve/SleeveHelpers.ts +++ b/src/PersonObjects/Sleeve/SleeveHelpers.ts @@ -74,7 +74,7 @@ export function findSleevePurchasableAugs(sleeve: Sleeve, p: IPlayer): Augmentat continue; } - if (fac.playerReputation > aug.baseRepRequirement) { + if (fac.playerReputation > aug.getCost(p).repCost) { availableAugs.push(aug); } } @@ -98,7 +98,7 @@ export function findSleevePurchasableAugs(sleeve: Sleeve, p: IPlayer): Augmentat continue; } - if (fac.playerReputation > aug.baseRepRequirement) { + if (fac.playerReputation > aug.getCost(p).repCost) { availableAugs.push(aug); } } diff --git a/src/PersonObjects/Sleeve/ui/SleeveAugmentationsModal.tsx b/src/PersonObjects/Sleeve/ui/SleeveAugmentationsModal.tsx index c3db83ec3..34446f202 100644 --- a/src/PersonObjects/Sleeve/ui/SleeveAugmentationsModal.tsx +++ b/src/PersonObjects/Sleeve/ui/SleeveAugmentationsModal.tsx @@ -66,7 +66,7 @@ export function SleeveAugmentationsModal(props: IProps): React.ReactElement { return ( - @@ -78,7 +78,7 @@ export function SleeveAugmentationsModal(props: IProps): React.ReactElement { - + ); From 0bff9be8a76f1685a8ca26d4c903e021db066fb5 Mon Sep 17 00:00:00 2001 From: phyzical Date: Fri, 15 Apr 2022 11:14:16 +0800 Subject: [PATCH 3/8] missed one reference to making baseCost static --- src/Augmentation/Augmentation.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Augmentation/Augmentation.tsx b/src/Augmentation/Augmentation.tsx index 247c535a3..ebbbe84a8 100644 --- a/src/Augmentation/Augmentation.tsx +++ b/src/Augmentation/Augmentation.tsx @@ -612,7 +612,7 @@ export class Augmentation { moneyCost = augmentationReference.baseCost * multiplier * BitNodeMultipliers.AugmentationMoneyCost; for (let i = 0; i < player.queuedAugmentations.length; ++i) { - augmentationReference.baseCost *= getBaseAugmentationPriceMultiplier(); + moneyCost *= getBaseAugmentationPriceMultiplier(); } } else if (augmentationReference.factions.includes(FactionNames.Infiltrators)) { const infiltratorAugmentationNames = initInfiltratorsAugmentations().map((augmentation) => augmentation.name); From ec8437cadd6b97210477cbd497790b42046ed969 Mon Sep 17 00:00:00 2001 From: phyzical Date: Fri, 15 Apr 2022 11:17:27 +0800 Subject: [PATCH 4/8] freeze the cost to stop sneeky sneekers --- src/Augmentation/Augmentation.tsx | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/Augmentation/Augmentation.tsx b/src/Augmentation/Augmentation.tsx index ebbbe84a8..effe67b29 100644 --- a/src/Augmentation/Augmentation.tsx +++ b/src/Augmentation/Augmentation.tsx @@ -464,7 +464,9 @@ export class Augmentation { this.prereqs = params.prereqs ? params.prereqs : []; this.baseRepRequirement = params.repCost; + Object.freeze(this.baseRepRequirement); this.baseCost = params.moneyCost; + Object.freeze(this.baseCost); this.factions = params.factions; if (params.isSpecial) { From 1478e7a5b12e55fedf2ee3c1f3a0ebdcfc879810 Mon Sep 17 00:00:00 2001 From: phyzical Date: Fri, 15 Apr 2022 11:17:49 +0800 Subject: [PATCH 5/8] lint --- src/Faction/ui/AugmentationsPage.tsx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Faction/ui/AugmentationsPage.tsx b/src/Faction/ui/AugmentationsPage.tsx index 79dad99dc..65aa04898 100644 --- a/src/Faction/ui/AugmentationsPage.tsx +++ b/src/Faction/ui/AugmentationsPage.tsx @@ -79,7 +79,7 @@ export function AugmentationsPage(props: IProps): React.ReactElement { const augs = getAugs(); function canBuy(augName: string): boolean { const aug = StaticAugmentations[augName]; - const augCosts = aug.getCost(player) + const augCosts = aug.getCost(player); const repCost = augCosts.repCost; const hasReq = props.faction.playerReputation >= repCost; const hasRep = hasAugmentationPrereqs(aug); From 00bb38703614e11cd7edd98ead0ca7cc27d52055 Mon Sep 17 00:00:00 2001 From: phyzical Date: Sat, 23 Apr 2022 10:34:41 +0800 Subject: [PATCH 6/8] few regressions from hydros changes --- src/Augmentation/Augmentation.tsx | 6 +++--- src/NetscriptFunctions/Singularity.ts | 1 - 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/Augmentation/Augmentation.tsx b/src/Augmentation/Augmentation.tsx index c6ceb0a4c..4cc617586 100644 --- a/src/Augmentation/Augmentation.tsx +++ b/src/Augmentation/Augmentation.tsx @@ -15,7 +15,7 @@ import { CONSTANTS } from "../Constants"; import { StaticAugmentations } from "./StaticAugmentations"; import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers"; import { getBaseAugmentationPriceMultiplier, getGenericAugmentationPriceMultiplier } from "./AugmentationHelpers"; -import { initInfiltratorsAugmentations } from "./data/AugmentationCreator"; +import { initSoAAugmentations } from "./data/AugmentationCreator"; export interface AugmentationCosts { moneyCost: number; @@ -616,8 +616,8 @@ export class Augmentation { for (let i = 0; i < player.queuedAugmentations.length; ++i) { moneyCost *= getBaseAugmentationPriceMultiplier(); } - } else if (augmentationReference.factions.includes(FactionNames.Infiltrators)) { - const infiltratorAugmentationNames = initInfiltratorsAugmentations().map((augmentation) => augmentation.name); + } else if (augmentationReference.factions.includes(FactionNames.ShadowsOfAnarchy)) { + const infiltratorAugmentationNames = initSoAAugmentations().map((augmentation) => augmentation.name); const infiltratorMultiplier = infiltratorAugmentationNames.filter((augmentationName) => player.hasAugmentation(augmentationName)).length + 1; moneyCost = Math.pow(augmentationReference.baseCost * 1000, infiltratorMultiplier); diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index 124510921..fdd022f35 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -1,4 +1,3 @@ -import { AugmentationCosts } from "./../Augmentation/Augmentation"; import { WorkerScript } from "../Netscript/WorkerScript"; import { IPlayer } from "../PersonObjects/IPlayer"; import { purchaseAugmentation, joinFaction, getFactionAugmentationsFiltered } from "../Faction/FactionHelpers"; From 15dca70afdeae945cec7e64de5cf061a3bfc7cb1 Mon Sep 17 00:00:00 2001 From: phyzical Date: Sat, 23 Apr 2022 10:47:19 +0800 Subject: [PATCH 7/8] one more conflict with hydros changes to SOA --- src/Augmentation/Augmentation.tsx | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Augmentation/Augmentation.tsx b/src/Augmentation/Augmentation.tsx index 4cc617586..acc2f4f48 100644 --- a/src/Augmentation/Augmentation.tsx +++ b/src/Augmentation/Augmentation.tsx @@ -617,12 +617,14 @@ export class Augmentation { moneyCost *= getBaseAugmentationPriceMultiplier(); } } else if (augmentationReference.factions.includes(FactionNames.ShadowsOfAnarchy)) { - const infiltratorAugmentationNames = initSoAAugmentations().map((augmentation) => augmentation.name); - const infiltratorMultiplier = - infiltratorAugmentationNames.filter((augmentationName) => player.hasAugmentation(augmentationName)).length + 1; - moneyCost = Math.pow(augmentationReference.baseCost * 1000, infiltratorMultiplier); - if (infiltratorAugmentationNames.find((augmentationName) => augmentationName === augmentationReference.name)) { - repCost = augmentationReference.baseRepRequirement * infiltratorMultiplier; + const soaAugmentationNames = initSoAAugmentations().map((augmentation) => augmentation.name); + const soaMultiplier = Math.pow( + CONSTANTS.SoACostMult, + soaAugmentationNames.filter((augmentationName) => player.hasAugmentation(augmentationName)).length, + ); + moneyCost = augmentationReference.baseCost * soaMultiplier; + if (soaAugmentationNames.find((augmentationName) => augmentationName === augmentationReference.name)) { + repCost = augmentationReference.baseRepRequirement * soaMultiplier; } } else { moneyCost = From 033154a32dd0d8730af23e09292c3d8b4a01c5d3 Mon Sep 17 00:00:00 2001 From: phyzical Date: Thu, 28 Apr 2022 18:02:50 +0800 Subject: [PATCH 8/8] linting --- src/Faction/ui/FactionRoot.tsx | 5 +---- src/index.tsx | 1 - 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/src/Faction/ui/FactionRoot.tsx b/src/Faction/ui/FactionRoot.tsx index 4410e5bdb..bcb37a563 100644 --- a/src/Faction/ui/FactionRoot.tsx +++ b/src/Faction/ui/FactionRoot.tsx @@ -16,12 +16,10 @@ import { BitNodeMultipliers } from "../../BitNode/BitNodeMultipliers"; import { Faction } from "../Faction"; import { use } from "../../ui/Context"; -import { CreateGangModal } from "./CreateGangModal"; -import { Box, Paper, Typography, Button, Tooltip } from "@mui/material"; +import { Typography, Button } from "@mui/material"; import { CovenantPurchasesRoot } from "../../PersonObjects/Sleeve/ui/CovenantPurchasesRoot"; import { FactionNames } from "../data/FactionNames"; -import { GangConstants } from "../../Gang/data/Constants"; import { GangButton } from "./GangButton"; type IProps = { @@ -30,7 +28,6 @@ type IProps = { }; // Info text for all options on the UI -const gangInfo = "Create and manage a gang for this Faction. Gangs will earn you money and faction reputation"; const hackingContractsInfo = "Complete hacking contracts for your faction. " + "Your effectiveness, which determines how much " + diff --git a/src/index.tsx b/src/index.tsx index 38aba9a58..db30c785c 100644 --- a/src/index.tsx +++ b/src/index.tsx @@ -4,7 +4,6 @@ import ReactDOM from "react-dom"; import { TTheme as Theme, ThemeEvents, refreshTheme } from "./Themes/ui/Theme"; import { LoadingScreen } from "./ui/LoadingScreen"; import { initElectron } from "./Electron"; -import { AlertEvents } from "./ui/React/AlertManager"; initElectron(); globalThis["React"] = React; globalThis["ReactDOM"] = ReactDOM;