Implement entropy accumulation system

This commit is contained in:
nickofolas 2022-03-19 13:15:31 -05:00
parent c33c23700e
commit c92b159580
9 changed files with 113 additions and 29 deletions

@ -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,

@ -0,0 +1,52 @@
import { IMap } from "../../types";
import { CONSTANTS } from "../../Constants";
import { IPlayer } from "../IPlayer";
export const applyEntropy = (player: IPlayer, stacks = 1): IMap<number> => {
const multipliers: IMap<number> = {
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;
}

@ -127,9 +127,10 @@ export const GraftingRoot = (): React.ReactElement => {
</Box>
<Box sx={{ my: 5 }}>
<Typography variant="h5">name tbd</Typography>
<Typography variant="h5">Entropy Accumulation</Typography>
<Typography>
probably some info about the cumulative negative effects here
probably some info about the cumulative negative effects here<br />
{player.entropyStacks} accumulated entropy
</Typography>
</Box>
</Container>

@ -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;
}

@ -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;
}
/**

@ -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);
}
}

@ -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}.<br>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}.<br>Your money was not returned to you.`)
}

@ -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) {

@ -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;