mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-04 06:37:49 +02:00
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:
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { GetServer, createUniqueRandomIp, ipExists } from "./AllServers";
|
||||
import { Server, IConstructorParams } from "./Server";
|
||||
import { BaseServer } from "./BaseServer";
|
||||
import { calculateServerGrowth, calculateServerGrowthLog } from "./formulas/grow";
|
||||
|
||||
import { currentNodeMults } from "../BitNode/BitNodeMultipliers";
|
||||
import { ServerConstants } from "./data/Constants";
|
||||
import { Player } from "@player";
|
||||
import { CompletedProgramName, LiteratureName } from "@enums";
|
||||
@@ -258,3 +258,8 @@ export function getCoreBonus(cores = 1): number {
|
||||
const coreBonus = 1 + (cores - 1) / 16;
|
||||
return coreBonus;
|
||||
}
|
||||
|
||||
export function getWeakenEffect(threads: number, cores: number): number {
|
||||
const coreBonus = getCoreBonus(cores);
|
||||
return ServerConstants.ServerWeakenAmount * threads * coreBonus * currentNodeMults.ServerWeakenRate;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user