Stanek performance boost + bonus time rework (#410)

This commit is contained in:
Snarling 2023-03-07 14:45:22 -05:00 committed by GitHub
parent 701f063642
commit 51bf0d1904
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 15 additions and 6 deletions

@ -7,7 +7,6 @@ import { Factions } from "../Faction/Factions";
import { CalculateEffect } from "./formulas/effect"; import { CalculateEffect } from "./formulas/effect";
import { StaneksGiftEvents } from "./StaneksGiftEvents"; import { StaneksGiftEvents } from "./StaneksGiftEvents";
import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver"; import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver";
import { CONSTANTS } from "../Constants";
import { StanekConstants } from "./data/Constants"; import { StanekConstants } from "./data/Constants";
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers"; import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
import { Player } from "@player"; import { Player } from "@player";
@ -16,6 +15,8 @@ import { defaultMultipliers, mergeMultipliers, Multipliers, scaleMultipliers } f
import { StaticAugmentations } from "../Augmentation/StaticAugmentations"; import { StaticAugmentations } from "../Augmentation/StaticAugmentations";
export class StaneksGift extends BaseGift { export class StaneksGift extends BaseGift {
isBonusCharging = false;
justCharged = false;
storedCycles = 0; storedCycles = 0;
constructor() { constructor() {
super(); super();
@ -42,18 +43,24 @@ export class StaneksGift extends BaseGift {
const cotmg = Factions[FactionNames.ChurchOfTheMachineGod]; const cotmg = Factions[FactionNames.ChurchOfTheMachineGod];
cotmg.playerReputation += (Player.mults.faction_rep * (Math.pow(threads, 0.95) * (cotmg.favor + 100))) / 1000; cotmg.playerReputation += (Player.mults.faction_rep * (Math.pow(threads, 0.95) * (cotmg.favor + 100))) / 1000;
this.justCharged = true;
} }
inBonus(): boolean { inBonus(): boolean {
return (this.storedCycles * CONSTANTS.MilliPerCycle) / 1000 > 1; return this.storedCycles >= 5;
} }
process(numCycles = 1): void { process(numCycles = 1): void {
if (!Player.hasAugmentation(AugmentationNames.StaneksGift1)) return; if (!Player.hasAugmentation(AugmentationNames.StaneksGift1)) return;
this.storedCycles += numCycles; this.storedCycles += numCycles;
this.storedCycles -= 10; const usedCycles = this.isBonusCharging ? 5 : 1;
this.storedCycles = Math.max(0, this.storedCycles); this.isBonusCharging = false;
this.storedCycles = Math.max(0, this.storedCycles - usedCycles);
// Only update multipliers (slow) if there was charging done since last process tick.
if (this.justCharged) {
this.updateMults(); this.updateMults();
this.justCharged = false;
}
StaneksGiftEvents.emit(); StaneksGiftEvents.emit();
} }

@ -44,7 +44,9 @@ export function NetscriptStanek(): InternalAPI<IStanek> {
); );
} }
//Charge the fragment //Charge the fragment
const time = staneksGift.inBonus() ? 200 : 1000; const inBonus = staneksGift.inBonus();
const time = inBonus ? 200 : 1000;
if (inBonus) staneksGift.isBonusCharging = true;
return helpers.netscriptDelay(ctx, time).then(function () { return helpers.netscriptDelay(ctx, time).then(function () {
staneksGift.charge(fragment, ctx.workerScript.scriptRef.threads); staneksGift.charge(fragment, ctx.workerScript.scriptRef.threads);
helpers.log(ctx, () => `Charged fragment with ${ctx.workerScript.scriptRef.threads} threads.`); helpers.log(ctx, () => `Charged fragment with ${ctx.workerScript.scriptRef.threads} threads.`);