From 3df3e04f9c9dd94653077dd8b34790ca009321dd Mon Sep 17 00:00:00 2001 From: nickofolas Date: Tue, 22 Mar 2022 17:53:57 -0500 Subject: [PATCH] Formulas --- src/Constants.ts | 6 ++++-- .../Grafting/CraftableAugmentation.ts | 9 +++++++-- src/PersonObjects/Grafting/ui/GraftingRoot.tsx | 6 +++++- .../Player/PlayerObjectGeneralMethods.tsx | 9 ++++++--- src/ui/React/CharacterOverview.tsx | 4 ++-- src/ui/WorkInProgressRoot.tsx | 17 +++++++++++------ 6 files changed, 35 insertions(+), 16 deletions(-) diff --git a/src/Constants.ts b/src/Constants.ts index e6f97865a..1a93ec942 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -41,6 +41,7 @@ export const CONSTANTS: { IntelligenceInfiltrationWeight: number; IntelligenceCrimeBaseExpGain: number; IntelligenceProgramBaseExpGain: number; + IntelligenceCraftBaseExpGain: number; IntelligenceTerminalHackBaseExpGain: number; IntelligenceSingFnBaseExpGain: number; IntelligenceClassBaseExpGain: number; @@ -110,7 +111,7 @@ export const CONSTANTS: { CodingContractBaseCompanyRepGain: number; CodingContractBaseMoneyGain: number; AugmentationCraftingCostMult: number; - AugmentationCraftingTimeMult: number; + AugmentationCraftingTimeBase: number; EntropyEffect: number; TotalNumBitNodes: number; LatestUpdate: string; @@ -184,6 +185,7 @@ export const CONSTANTS: { IntelligenceInfiltrationWeight: 0.1, // Weight for how much int affects infiltration success rates IntelligenceCrimeBaseExpGain: 0.05, IntelligenceProgramBaseExpGain: 0.1, // Program required hack level divided by this to determine int exp gain + IntelligenceCraftBaseExpGain: 0.05, IntelligenceTerminalHackBaseExpGain: 200, // Hacking exp divided by this to determine int exp gain IntelligenceSingFnBaseExpGain: 1.5, IntelligenceClassBaseExpGain: 0.01, @@ -277,7 +279,7 @@ export const CONSTANTS: { // Augmentation crafting multipliers // TODO: Get these right AugmentationCraftingCostMult: 1.2, - AugmentationCraftingTimeMult: 0.01, + AugmentationCraftingTimeBase: 3600000, EntropyEffect: 0.99, diff --git a/src/PersonObjects/Grafting/CraftableAugmentation.ts b/src/PersonObjects/Grafting/CraftableAugmentation.ts index 5f7785c16..0d365ebd7 100644 --- a/src/PersonObjects/Grafting/CraftableAugmentation.ts +++ b/src/PersonObjects/Grafting/CraftableAugmentation.ts @@ -1,3 +1,5 @@ +import { sum } from "lodash"; + import { Augmentation } from "../../Augmentation/Augmentation"; import { CONSTANTS } from "../../Constants"; @@ -20,7 +22,10 @@ export class CraftableAugmentation { } get time(): number { - // CONSTANTS.AugmentationCraftingTimeMult - return 15000; + // Time = 1 hour * log_2(sum(aug multipliers) || 1) + 30 minutes + const antiLog = Math.max(sum(Object.values(this.augmentation.mults)), 1); + + const mult = Math.log2(antiLog); + return CONSTANTS.AugmentationCraftingTimeBase * mult + CONSTANTS.MillisecondsPerHalfHour; } } diff --git a/src/PersonObjects/Grafting/ui/GraftingRoot.tsx b/src/PersonObjects/Grafting/ui/GraftingRoot.tsx index 055ed5d6e..eefde9c2f 100644 --- a/src/PersonObjects/Grafting/ui/GraftingRoot.tsx +++ b/src/PersonObjects/Grafting/ui/GraftingRoot.tsx @@ -108,7 +108,11 @@ export const GraftingRoot = (): React.ReactElement => { } /> - Time to Craft: {convertTimeMsToTimeElapsedString(CraftableAugmentations[selectedAug].time)} + Time to Craft:{" "} + {convertTimeMsToTimeElapsedString( + CraftableAugmentations[selectedAug].time / (1 + (player.getIntelligenceBonus(3) - 1) / 3), + )} + {/* Use formula so the displayed creation time is accurate to player bonus */} {(() => { diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx index 60384f82a..2a862085e 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx @@ -1354,8 +1354,7 @@ export function craftAugmentationWork(this: IPlayer, numCycles: number): boolean focusBonus = this.focus ? 1 : CONSTANTS.BaseFocusBonus; } - // TODO: formula logic here (focus bonus and stuff) - let skillMult = 1; + let skillMult = 1 + (this.getIntelligenceBonus(3) - 1) / 3; skillMult *= focusBonus; this.timeWorked += CONSTANTS._idleSpeed * numCycles; @@ -1380,7 +1379,11 @@ export function finishCraftAugmentationWork(this: IPlayer, cancelled: boolean): dialogBoxCreate(`You cancelled the crafting of ${augName}.
Your money was not returned to you.`) } - // TODO: intelligence EXP stuff here later + // Intelligence gain + if (!cancelled) { + this.gainIntelligenceExp((CONSTANTS.IntelligenceCraftBaseExpGain * this.timeWorked) / 10000); + } + this.isWorking = false; this.resetWorkStatus(); return `Crafting of ${augName} has ended.` diff --git a/src/ui/React/CharacterOverview.tsx b/src/ui/React/CharacterOverview.tsx index 34e7b81eb..5b08dbebe 100644 --- a/src/ui/React/CharacterOverview.tsx +++ b/src/ui/React/CharacterOverview.tsx @@ -199,8 +199,8 @@ function Work(): React.ReactElement { header = <>Crafting an Augmentation; innerText = ( <> - {convertTimeMsToTimeElapsedString(player.timeNeededToCompleteWork - player.timeWorkedCraftAugmentation)} - {" "}remaining + {((player.timeWorkedCraftAugmentation / player.timeNeededToCompleteWork) * 100).toFixed(2)}% + {" "}done ); } diff --git a/src/ui/WorkInProgressRoot.tsx b/src/ui/WorkInProgressRoot.tsx index fe9978bb1..72a91efa1 100644 --- a/src/ui/WorkInProgressRoot.tsx +++ b/src/ui/WorkInProgressRoot.tsx @@ -41,8 +41,8 @@ export function WorkInProgressRoot(): React.ReactElement { return ( <> - You have not joined {player.currentWorkFactionName || "(Faction not found)"} yet or cannot work at this time, - please try again if you think this should have worked + You have not joined {player.currentWorkFactionName || "(Faction not found)"} yet or cannot work at this + time, please try again if you think this should have worked @@ -497,10 +497,15 @@ export function WorkInProgressRoot(): React.ReactElement { You are currently working on crafting {player.craftAugmentationName}. -

+
+
You have been working for {convertTimeMsToTimeElapsedString(player.timeWorked)} -

- The augmentation will be done in {convertTimeMsToTimeElapsedString(player.timeNeededToCompleteWork - player.timeWorkedCraftAugmentation)}.
+
+
+ The augmentation is{" "} + {((player.timeWorkedCraftAugmentation / player.timeNeededToCompleteWork) * 100).toFixed(2)}% done being + crafted. +
If you cancel, your work will not be saved, and the money you spent will not be returned.
@@ -511,7 +516,7 @@ export function WorkInProgressRoot(): React.ReactElement { - ) + ); } if (!player.workType) router.toTerminal();