weaken message

This commit is contained in:
Olivier Gagnon 2021-12-20 14:13:56 -05:00
parent 4ec021c8f0
commit ddd0eaaf5c
2 changed files with 20 additions and 2 deletions

@ -212,13 +212,18 @@ export class Terminal implements ITerminal {
player.gainHackingExp(expGainedOnSuccess);
player.gainIntelligenceExp(expGainedOnSuccess / CONSTANTS.IntelligenceTerminalHackBaseExpGain);
const oldSec = server.hackDifficulty;
server.fortify(CONSTANTS.ServerFortifyAmount);
const newSec = server.hackDifficulty;
this.print(
`Hack successful! Gained ${numeralWrapper.formatMoney(moneyGained)} and ${numeralWrapper.formatExp(
expGainedOnSuccess,
)} hacking exp`,
);
this.print(
`Security increased from ${numeralWrapper.formatSecurity(oldSec)} to ${numeralWrapper.formatSecurity(newSec)}`,
);
} else {
// Failure
player.gainHackingExp(expGainedOnFailure);
@ -237,13 +242,18 @@ export class Terminal implements ITerminal {
}
if (!(server instanceof Server)) throw new Error("server should be normal server");
const expGain = calculateHackingExpGain(server, player);
const oldSec = server.hackDifficulty;
const growth = processSingleServerGrowth(server, 25, player, server.cpuCores) - 1;
const newSec = server.hackDifficulty;
this.print(
`Available money on '${server.hostname}' grown by ${numeralWrapper.formatPercentage(
growth,
6,
)}. Gained ${numeralWrapper.formatExp(expGain)} hacking exp.`,
);
this.print(
`Security increased from ${numeralWrapper.formatSecurity(oldSec)} to ${numeralWrapper.formatSecurity(newSec)}`,
);
}
finishWeaken(player: IPlayer, cancelled = false): void {
@ -255,10 +265,14 @@ export class Terminal implements ITerminal {
}
if (!(server instanceof Server)) throw new Error("server should be normal server");
const expGain = calculateHackingExpGain(server, player);
const oldSec = server.hackDifficulty;
server.weaken(CONSTANTS.ServerWeakenAmount);
const newSec = server.hackDifficulty;
this.print(
`'${server.hostname}' security level weakened to ${server.hackDifficulty.toFixed(3)} ` +
`and Gained ${numeralWrapper.formatExp(expGain)} hacking exp.`,
`Security decreased from ${numeralWrapper.formatSecurity(oldSec)} to ${numeralWrapper.formatSecurity(
newSec,
)} (min: ${numeralWrapper.formatSecurity(server.minDifficulty)})` +
` and Gained ${numeralWrapper.formatExp(expGain)} hacking exp.`,
);
}

@ -105,6 +105,10 @@ class NumeralFormatter {
return this.format(n, "0,0");
}
formatSecurity(n: number): string {
return n.toFixed(3);
}
formatRAM(n: number): string {
if (n < 1e3) return this.format(n, "0.00") + "GB";
if (n < 1e6) return this.format(n / 1e3, "0.00") + "TB";