From 4e73e489edb37f330bda4b091f3a1677db05f4e0 Mon Sep 17 00:00:00 2001 From: phyzical Date: Tue, 22 Mar 2022 23:02:15 +0800 Subject: [PATCH] more refactors --- src/Achievements/Achievements.ts | 1 + src/Augmentation/AugmentationCreator.tsx | 32 +++++++++++----------- src/Augmentation/AugmentationHelpers.tsx | 26 +++++++++--------- src/Augmentation/data/AugmentationNames.ts | 6 ++-- src/Faction/FactionHelpers.tsx | 13 --------- src/Faction/ui/AugmentationsPage.tsx | 10 +++---- 6 files changed, 37 insertions(+), 51 deletions(-) diff --git a/src/Achievements/Achievements.ts b/src/Achievements/Achievements.ts index 7059f2ec3..c815dd1d1 100644 --- a/src/Achievements/Achievements.ts +++ b/src/Achievements/Achievements.ts @@ -776,6 +776,7 @@ export const achievements: IMap = { // { ID: FactionNames.Bladeburners.toUpperCase(), Condition: () => Player.factions.includes(FactionNames.Bladeburners) }, // { ID: "DEEPSCANV1.EXE", Condition: () => Player.getHomeComputer().programs.includes(Programs.DeepscanV1.name) }, // { ID: "DEEPSCANV2.EXE", Condition: () => Player.getHomeComputer().programs.includes(Programs.DeepscanV2.name) }, +// { ID: "INFILTRATORS", Condition: () => Player.factions.includes(FactionNames.Infiltators) }, // { // ID: "SERVERPROFILER.EXE", // Condition: () => Player.getHomeComputer().programs.includes(Programs.ServerProfiler.name), diff --git a/src/Augmentation/AugmentationCreator.tsx b/src/Augmentation/AugmentationCreator.tsx index 0ff725f41..82116653b 100644 --- a/src/Augmentation/AugmentationCreator.tsx +++ b/src/Augmentation/AugmentationCreator.tsx @@ -97,8 +97,8 @@ function getRandomBonus(): any { export const infiltratorsAugmentations = [ new Augmentation({ name: AugmentationNames.BagOfSand, - repCost: 100, - moneyCost: 1e9, + repCost: 1e2, + moneyCost: 1e6, info: "You watched a bittube video about sword fighting, " + "it suggested the best way to win a sword fight was to play dirty " + @@ -110,8 +110,8 @@ export const infiltratorsAugmentations = [ }), new Augmentation({ name: AugmentationNames.IntellisenseModule, - repCost: 100, - moneyCost: 1e9, + repCost: 1e2, + moneyCost: 1e6, info: "A brain implant with AI power that focuses in auto linting and intellisense, which " + "provides the ability to perform code completion better than any existing " + @@ -121,8 +121,8 @@ export const infiltratorsAugmentations = [ }), new Augmentation({ name: AugmentationNames.ReverseDictionary, - repCost: 100, - moneyCost: 1e9, + repCost: 1e2, + moneyCost: 1e6, info: "An ancient dictionary with a thick layer of dust it looks like a different language, " + "as you examine it further you realise that its actually just a normal dictionary but the words are " + @@ -132,8 +132,8 @@ export const infiltratorsAugmentations = [ }), new Augmentation({ name: AugmentationNames.AmuletOfPersuasian, - repCost: 100, - moneyCost: 1e9, + repCost: 1e2, + moneyCost: 1e6, info: "A fancy looking amulet that looks like something an Egyptian goddess would wear, " + "you hear faint whispers that are trying to convince you to do things you wouldn't normally do, " + @@ -143,8 +143,8 @@ export const infiltratorsAugmentations = [ }), new Augmentation({ name: AugmentationNames.LameSharkRepository, - repCost: 100, - moneyCost: 1e9, + repCost: 1e2, + moneyCost: 1e6, info: "You stumble across an old opensource repository for a weird defunct version of LameShark, " + "upon studying the source code it seems to just have a bunch of arrow key cheat codes. ", @@ -153,8 +153,8 @@ export const infiltratorsAugmentations = [ }), new Augmentation({ name: AugmentationNames.CyberDecoder, - repCost: 100, - moneyCost: 1e9, + repCost: 1e2, + moneyCost: 1e6, info: "A cool looking do hickey that oddly resembles Keanu Reeves face, " + "it has a usb cable that looks like it plugs into something.", @@ -163,8 +163,8 @@ export const infiltratorsAugmentations = [ }), new Augmentation({ name: AugmentationNames.MineDetector, - repCost: 100, - moneyCost: 1e9, + repCost: 1e2, + moneyCost: 1e6, info: "You stumble across an old mine detector at an army surplus store, " + "on the side is inscribed 'X(' i wonder what happened to the original owner, " + @@ -179,8 +179,8 @@ export const infiltratorsAugmentations = [ }), new Augmentation({ name: AugmentationNames.WireCuttingManual, - repCost: 100, - moneyCost: 1e9, + repCost: 1e2, + moneyCost: 1e6, info: "You found an old wire cutting for dummies book in the local library, " + "how hard can it be to cut wires, right?", diff --git a/src/Augmentation/AugmentationHelpers.tsx b/src/Augmentation/AugmentationHelpers.tsx index ced5ec39a..f8377bbd2 100644 --- a/src/Augmentation/AugmentationHelpers.tsx +++ b/src/Augmentation/AugmentationHelpers.tsx @@ -55,10 +55,14 @@ function initAugmentations(): void { Player.reapplyAllAugmentations(); } +function getBaseAugmentationPriceMultiplier(): number { + return CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]]; +} +export function getGenericAugmentationPriceMultiplier(): number { + return Math.pow(getBaseAugmentationPriceMultiplier(), Player.queuedAugmentations.length); +} + export function updateAugmentationCosts(): void { - const purchasedOrQueuedInfiltratorAugmentationCount = infiltratorsAugmentations.filter((augmentation) => - Player.hasAugmentation(augmentation.name), - ).length; for (const name of Object.keys(Augmentations)) { if (Augmentations.hasOwnProperty(name)) { const augmentationToUpdate = Augmentations[name]; @@ -70,19 +74,15 @@ export function updateAugmentationCosts(): void { augmentationToUpdate.baseCost *= multiplier * BitNodeMultipliers.AugmentationMoneyCost; for (let i = 0; i < Player.queuedAugmentations.length - 1; ++i) { - augmentationToUpdate.baseCost *= CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]]; + augmentationToUpdate.baseCost *= getBaseAugmentationPriceMultiplier(); } } else if (augmentationToUpdate.factions.includes(FactionNames.Infiltrators)) { - augmentationToUpdate.baseCost = Math.pow( - augmentationToUpdate.baseCost, - purchasedOrQueuedInfiltratorAugmentationCount, - ); - augmentationToUpdate.baseRepRequirement *= purchasedOrQueuedInfiltratorAugmentationCount; + const infiltratorMultiplier = + infiltratorsAugmentations.filter((augmentation) => Player.hasAugmentation(augmentation.name)).length + 1; + augmentationToUpdate.baseCost = Math.pow(augmentationToUpdate.baseCost * 1000, infiltratorMultiplier); + augmentationToUpdate.baseRepRequirement *= infiltratorMultiplier; } else { - augmentationToUpdate.baseCost *= Math.pow( - CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]], - Player.queuedAugmentations.length, - ); + augmentationToUpdate.baseCost *= getGenericAugmentationPriceMultiplier(); } } } diff --git a/src/Augmentation/data/AugmentationNames.ts b/src/Augmentation/data/AugmentationNames.ts index 0ad2be9e5..87049c37c 100644 --- a/src/Augmentation/data/AugmentationNames.ts +++ b/src/Augmentation/data/AugmentationNames.ts @@ -239,9 +239,9 @@ export const AugmentationNames: { ReverseDictionary: "Reverse Dictionary", AmuletOfPersuasian: "Amulet of Persuasian", LameSharkRepository: "Lame Shark Repository", - CyberDecoder: "CyberDecoder", - MineDetector: "MineDetector", - WireCuttingManual: "WireCuttingManual", + CyberDecoder: "Cyber Decoder", + MineDetector: "Mine Detector", + WireCuttingManual: "Wire Cutting Manual", //Wasteland Augs //PepBoy: "P.E.P-Boy", Plasma Energy Projection System diff --git a/src/Faction/FactionHelpers.tsx b/src/Faction/FactionHelpers.tsx index d71f5f5c7..e4bad6b8f 100644 --- a/src/Faction/FactionHelpers.tsx +++ b/src/Faction/FactionHelpers.tsx @@ -111,19 +111,6 @@ export function purchaseAugmentation(aug: Augmentation, fac: Faction, sing = fal Player.loseMoney(aug.baseCost * factionInfo.augmentationPriceMult, "augmentations"); - // If you just purchased Neuroflux Governor, recalculate the cost - if (aug.name == AugmentationNames.NeuroFluxGovernor) { - let nextLevel = getNextNeuroFluxLevel(); - --nextLevel; - const mult = Math.pow(CONSTANTS.NeuroFluxGovernorLevelMult, nextLevel); - aug.baseRepRequirement = 500 * mult * BitNodeMultipliers.AugmentationRepCost; - aug.baseCost = 750e3 * mult * BitNodeMultipliers.AugmentationMoneyCost; - - for (let i = 0; i < Player.queuedAugmentations.length - 1; ++i) { - aug.baseCost *= CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][SourceFileFlags[11]]; - } - } - updateAugmentationCosts(); if (sing) { diff --git a/src/Faction/ui/AugmentationsPage.tsx b/src/Faction/ui/AugmentationsPage.tsx index 1d519b124..9e8e79c09 100644 --- a/src/Faction/ui/AugmentationsPage.tsx +++ b/src/Faction/ui/AugmentationsPage.tsx @@ -23,7 +23,7 @@ import Typography from "@mui/material/Typography"; import Tooltip from "@mui/material/Tooltip"; import TableBody from "@mui/material/TableBody"; import Table from "@mui/material/Table"; -import { CONSTANTS } from "../../Constants"; +import { getGenericAugmentationPriceMultiplier } from "../../Augmentation/AugmentationHelpers"; type IProps = { faction: Faction; @@ -180,10 +180,6 @@ export function AugmentationsPage(props: IProps): React.ReactElement { ); } - const mult = Math.pow( - CONSTANTS.MultipleAugMultiplier * [1, 0.96, 0.94, 0.93][player.sourceFileLvl(11)], - player.queuedAugmentations.length, - ); return ( <> @@ -204,7 +200,9 @@ export function AugmentationsPage(props: IProps): React.ReactElement { } > - Price multiplier: x {numeralWrapper.formatMultiplier(mult)} + + Price multiplier: x {numeralWrapper.formatMultiplier(getGenericAugmentationPriceMultiplier())} +