MISC: refactor weaken effect calculation (#1076)

so far we calculate the effect of weaken in three +1 places
ns.weaken
ns.weakenAnalyze
terminal weaken

and server.weaken where the bn mult is applied

i extracted the logic into a new netscript helper function getWeakenEffect
this gives us one place if we want to change the formula

a side effect i added the server.cpuCores to the terminal weaken to future proof it if the npc server core pr (#963) is merged
This commit is contained in:
Caldwell
2024-02-17 02:18:16 +01:00
committed by GitHub
parent 93b9a10e41
commit 8c8af38a3a
5 changed files with 21 additions and 17 deletions
+1 -1
View File
@@ -141,7 +141,7 @@ export class Server extends BaseServer {
/** Lowers the server's security level (difficulty) by the specified amount) */
weaken(amt: number): void {
this.hackDifficulty -= amt * currentNodeMults.ServerWeakenRate;
this.hackDifficulty -= amt;
this.capDifficulty();
}