From c92b15958063a8cb8d8fe65dc774df9e2e266408 Mon Sep 17 00:00:00 2001 From: nickofolas Date: Sat, 19 Mar 2022 13:15:31 -0500 Subject: [PATCH] Implement entropy accumulation system --- src/Constants.ts | 5 +- .../Grafting/EntropyAccumulation.ts | 52 ++++++++++++++++++ .../Grafting/ui/GraftingRoot.tsx | 5 +- src/PersonObjects/IPlayer.ts | 3 + src/PersonObjects/Player/PlayerObject.ts | 7 +++ .../Player/PlayerObjectAugmentationMethods.ts | 9 +++ .../Player/PlayerObjectGeneralMethods.tsx | 55 ++++++++++--------- src/Prestige.ts | 3 + src/engine.tsx | 3 + 9 files changed, 113 insertions(+), 29 deletions(-) create mode 100644 src/PersonObjects/Grafting/EntropyAccumulation.ts diff --git a/src/Constants.ts b/src/Constants.ts index 7dd447c7c..e6f97865a 100644 --- a/src/Constants.ts +++ b/src/Constants.ts @@ -111,6 +111,7 @@ export const CONSTANTS: { CodingContractBaseMoneyGain: number; AugmentationCraftingCostMult: number; AugmentationCraftingTimeMult: number; + EntropyEffect: number; TotalNumBitNodes: number; LatestUpdate: string; } = { @@ -276,7 +277,9 @@ export const CONSTANTS: { // Augmentation crafting multipliers // TODO: Get these right AugmentationCraftingCostMult: 1.2, - AugmentationCraftingTimeMult: 1, + AugmentationCraftingTimeMult: 0.01, + + EntropyEffect: 0.99, // BitNode/Source-File related stuff TotalNumBitNodes: 24, diff --git a/src/PersonObjects/Grafting/EntropyAccumulation.ts b/src/PersonObjects/Grafting/EntropyAccumulation.ts new file mode 100644 index 000000000..e894127f7 --- /dev/null +++ b/src/PersonObjects/Grafting/EntropyAccumulation.ts @@ -0,0 +1,52 @@ +import { IMap } from "../../types"; +import { CONSTANTS } from "../../Constants"; + +import { IPlayer } from "../IPlayer"; + +export const applyEntropy = (player: IPlayer, stacks = 1): IMap => { + const multipliers: IMap = { + hacking_chance_mult: player.hacking_chance_mult, + hacking_speed_mult: player.hacking_speed_mult, + hacking_money_mult: player.hacking_money_mult, + hacking_grow_mult: player.hacking_grow_mult, + + hacking_mult: player.hacking_mult, + strength_mult: player.strength_mult, + defense_mult: player.defense_mult, + dexterity_mult: player.dexterity_mult, + agility_mult: player.agility_mult, + charisma_mult: player.charisma_mult, + + hacking_exp_mult: player.hacking_exp_mult, + strength_exp_mult: player.strength_exp_mult, + defense_exp_mult: player.defense_exp_mult, + dexterity_exp_mult: player.dexterity_exp_mult, + agility_exp_mult: player.agility_exp_mult, + charisma_exp_mult: player.charisma_exp_mult, + + company_rep_mult: player.company_rep_mult, + faction_rep_mult: player.faction_rep_mult, + + crime_money_mult: player.crime_money_mult, + crime_success_mult: player.crime_success_mult, + + hacknet_node_money_mult: player.hacknet_node_money_mult, + hacknet_node_purchase_cost_mult: player.hacknet_node_purchase_cost_mult, + hacknet_node_ram_cost_mult: player.hacknet_node_ram_cost_mult, + hacknet_node_core_cost_mult: player.hacknet_node_core_cost_mult, + hacknet_node_level_cost_mult: player.hacknet_node_level_cost_mult, + + work_money_mult: player.work_money_mult, + + bladeburner_max_stamina_mult: player.bladeburner_max_stamina_mult, + bladeburner_stamina_gain_mult: player.bladeburner_stamina_gain_mult, + bladeburner_analysis_mult: player.bladeburner_analysis_mult, + bladeburner_success_chance_mult: player.bladeburner_success_chance_mult, + } + + for (const [mult, val] of Object.entries(multipliers)) { + multipliers[mult] = val * (CONSTANTS.EntropyEffect ** stacks); + } + + return multipliers; +} diff --git a/src/PersonObjects/Grafting/ui/GraftingRoot.tsx b/src/PersonObjects/Grafting/ui/GraftingRoot.tsx index 15e4f4652..91c84e7b7 100644 --- a/src/PersonObjects/Grafting/ui/GraftingRoot.tsx +++ b/src/PersonObjects/Grafting/ui/GraftingRoot.tsx @@ -127,9 +127,10 @@ export const GraftingRoot = (): React.ReactElement => { - name tbd + Entropy Accumulation - probably some info about the cumulative negative effects here + probably some info about the cumulative negative effects here
+ {player.entropyStacks} accumulated entropy
diff --git a/src/PersonObjects/IPlayer.ts b/src/PersonObjects/IPlayer.ts index ed15ce028..41881462a 100644 --- a/src/PersonObjects/IPlayer.ts +++ b/src/PersonObjects/IPlayer.ts @@ -160,6 +160,8 @@ export interface IPlayer { workChaExpGainRate: number; workMoneyLossRate: number; + entropyStacks: number; + // Methods work(numCycles: number): boolean; workPartTime(numCycles: number): boolean; @@ -289,4 +291,5 @@ export interface IPlayer { startCraftAugmentationWork(augmentationName: string, time: number): void; craftAugmentationWork(numCycles: number): boolean; finishCraftAugmentationWork(cancelled: boolean): string; + applyEntropy(stacks?: number): void; } diff --git a/src/PersonObjects/Player/PlayerObject.ts b/src/PersonObjects/Player/PlayerObject.ts index 211131f30..65603c3af 100644 --- a/src/PersonObjects/Player/PlayerObject.ts +++ b/src/PersonObjects/Player/PlayerObject.ts @@ -169,6 +169,8 @@ export class PlayerObject implements IPlayer { workChaExpGainRate: number; workMoneyLossRate: number; + entropyStacks: number; + // Methods work: (numCycles: number) => boolean; workPartTime: (numCycles: number) => boolean; @@ -299,6 +301,7 @@ export class PlayerObject implements IPlayer { startCraftAugmentationWork: (augmentationName: string, time: number) => void; craftAugmentationWork: (numCycles: number) => boolean; finishCraftAugmentationWork: (cancelled: boolean) => string; + applyEntropy: (stacks?: number) => void; constructor() { //Skills and stats @@ -467,6 +470,8 @@ export class PlayerObject implements IPlayer { //bitnode this.bitNodeN = 1; + this.entropyStacks = 0; + //Used to store the last update time. this.lastUpdate = 0; this.lastSave = 0; @@ -619,6 +624,8 @@ export class PlayerObject implements IPlayer { this.canAccessCotMG = generalMethods.canAccessCotMG; this.sourceFileLvl = generalMethods.sourceFileLvl; + + this.applyEntropy = augmentationMethods.applyEntropy; } /** diff --git a/src/PersonObjects/Player/PlayerObjectAugmentationMethods.ts b/src/PersonObjects/Player/PlayerObjectAugmentationMethods.ts index acccb38df..ed68a0251 100644 --- a/src/PersonObjects/Player/PlayerObjectAugmentationMethods.ts +++ b/src/PersonObjects/Player/PlayerObjectAugmentationMethods.ts @@ -5,6 +5,8 @@ import { IPlayer } from "../IPlayer"; import { Augmentation } from "../../Augmentation/Augmentation"; +import { applyEntropy as calculateEntropy } from "../Grafting/EntropyAccumulation"; + export function hasAugmentation(this: IPlayer, aug: string | Augmentation, installed = false): boolean { const augName: string = aug instanceof Augmentation ? aug.name : aug; @@ -24,3 +26,10 @@ export function hasAugmentation(this: IPlayer, aug: string | Augmentation, insta return false; } + +export function applyEntropy(this: IPlayer, stacks = 1): void { + const newMultipliers = calculateEntropy(this, stacks); + for (const [mult, val] of Object.entries(newMultipliers)) { + this.setMult(mult, val); + } +} diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx index 03bb85edb..30d7a4731 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.tsx @@ -180,6 +180,7 @@ export function prestigeAugmentation(this: PlayerObject): void { } export function prestigeSourceFile(this: IPlayer): void { + this.entropyStacks = 0; this.prestigeAugmentation(); this.karma = 0; // Duplicate sleeves are reset to level 1 every Bit Node (but the number of sleeves you have persists) @@ -1373,6 +1374,8 @@ export function finishCraftAugmentationWork(this: IPlayer, cancelled: boolean): dialogBoxCreate(`You've finished crafting ${augName}.
The augmentation has been grafted to your body, but you feel a bit off.`) applyAugmentation(Augmentations[augName]); + this.entropyStacks += 1; + this.applyEntropy(); } else { dialogBoxCreate(`You cancelled the crafting of ${augName}.
Your money was not returned to you.`) } @@ -1561,20 +1564,20 @@ export function finishCrime(this: IPlayer, cancelled: boolean): string { if (ws.disableLogs.ALL == null && ws.disableLogs.commitCrime == null) { ws.scriptRef.log( "SUCCESS: Crime successful! Gained " + - numeralWrapper.formatMoney(this.workMoneyGained) + - ", " + - numeralWrapper.formatExp(this.workHackExpGained) + - " hack exp, " + - numeralWrapper.formatExp(this.workStrExpGained) + - " str exp, " + - numeralWrapper.formatExp(this.workDefExpGained) + - " def exp, " + - numeralWrapper.formatExp(this.workDexExpGained) + - " dex exp, " + - numeralWrapper.formatExp(this.workAgiExpGained) + - " agi exp, " + - numeralWrapper.formatExp(this.workChaExpGained) + - " cha exp.", + numeralWrapper.formatMoney(this.workMoneyGained) + + ", " + + numeralWrapper.formatExp(this.workHackExpGained) + + " hack exp, " + + numeralWrapper.formatExp(this.workStrExpGained) + + " str exp, " + + numeralWrapper.formatExp(this.workDefExpGained) + + " def exp, " + + numeralWrapper.formatExp(this.workDexExpGained) + + " dex exp, " + + numeralWrapper.formatExp(this.workAgiExpGained) + + " agi exp, " + + numeralWrapper.formatExp(this.workChaExpGained) + + " cha exp.", ); } } else { @@ -1613,18 +1616,18 @@ export function finishCrime(this: IPlayer, cancelled: boolean): string { if (ws.disableLogs.ALL == null && ws.disableLogs.commitCrime == null) { ws.scriptRef.log( "FAIL: Crime failed! Gained " + - numeralWrapper.formatExp(this.workHackExpGained) + - " hack exp, " + - numeralWrapper.formatExp(this.workStrExpGained) + - " str exp, " + - numeralWrapper.formatExp(this.workDefExpGained) + - " def exp, " + - numeralWrapper.formatExp(this.workDexExpGained) + - " dex exp, " + - numeralWrapper.formatExp(this.workAgiExpGained) + - " agi exp, " + - numeralWrapper.formatExp(this.workChaExpGained) + - " cha exp.", + numeralWrapper.formatExp(this.workHackExpGained) + + " hack exp, " + + numeralWrapper.formatExp(this.workStrExpGained) + + " str exp, " + + numeralWrapper.formatExp(this.workDefExpGained) + + " def exp, " + + numeralWrapper.formatExp(this.workDexExpGained) + + " dex exp, " + + numeralWrapper.formatExp(this.workAgiExpGained) + + " agi exp, " + + numeralWrapper.formatExp(this.workChaExpGained) + + " cha exp.", ); } } else { diff --git a/src/Prestige.ts b/src/Prestige.ts index ab8641a85..066fb1d59 100755 --- a/src/Prestige.ts +++ b/src/Prestige.ts @@ -108,6 +108,9 @@ export function prestigeAugmentation(): void { // Messages initMessages(); + // Apply entropy from grafting + Player.applyEntropy(Player.entropyStacks); + // Gang const gang = Player.gang; if (Player.inGang() && gang !== null) { diff --git a/src/engine.tsx b/src/engine.tsx index 6464d3309..d2c28aba7 100644 --- a/src/engine.tsx +++ b/src/engine.tsx @@ -259,6 +259,9 @@ const Engine: { initSymbolToStockMap(); } + // Apply penalty for entropy accumulation + Player.applyEntropy(Player.entropyStacks); + // Calculate the number of cycles have elapsed while offline Engine._lastUpdate = new Date().getTime(); const lastUpdate = Player.lastUpdate;