MISC: Avoid reinventing core bonus calculation and fix formatting issue (#2387)

This commit is contained in:
imcute_aaaa
2025-11-20 07:18:54 +09:00
committed by GitHub
parent 4d230c3121
commit bb50272e54
2 changed files with 3 additions and 1 deletions

View File

@@ -34,6 +34,7 @@ export class Port {
this.promise = null;
}
}
export function portHandle(n: PortNumber): NetscriptPort {
return {
write: (value: unknown) => writePort(n, value),

View File

@@ -2,6 +2,7 @@ import { currentNodeMults } from "../../BitNode/BitNodeMultipliers";
import { Person as IPerson, Server as IServer } from "@nsdefs";
import { ServerConstants } from "../data/Constants";
import { isValidNumber } from "../../utils/helpers/isValidNumber";
import { getCoreBonus } from "../ServerHelpers";
// Returns the log of the growth rate. When passing 1 for threads, this gives a useful constant.
export function calculateServerGrowthLog(server: IServer, threads: number, p: IPerson, cores = 1): number {
@@ -21,7 +22,7 @@ export function calculateServerGrowthLog(server: IServer, threads: number, p: IP
const serverGrowthPercentageAdjusted = serverGrowthPercentage * currentNodeMults.ServerGrowthRate;
//Apply serverGrowth for the calculated number of growth cycles
const coreBonus = 1 + (cores - 1) * (1 / 16);
const coreBonus = getCoreBonus(cores);
// It is critical that numServerGrowthCycles (aka threads) is multiplied last,
// so that it rounds the same way as numCycleForGrowthCorrected.
return adjGrowthLog * serverGrowthPercentageAdjusted * p.mults.hacking_grow * coreBonus * numServerGrowthCycles;