From 6de6fa092f34a90ac62fa4c69d9ce697ab7fe52e Mon Sep 17 00:00:00 2001 From: David Perez Alvarez Date: Sun, 23 Jan 2022 16:32:48 -0500 Subject: [PATCH] "improve" server money grow when 0 min `server.moneyAvailable` of 1$ when growing unify displayed growth --- src/NetscriptFunctions.ts | 6 +++--- src/Server/ServerHelpers.ts | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/NetscriptFunctions.ts b/src/NetscriptFunctions.ts index 5d43cd1e9..2cc6f3825 100644 --- a/src/NetscriptFunctions.ts +++ b/src/NetscriptFunctions.ts @@ -612,12 +612,12 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS { )} (t=${numeralWrapper.formatThreads(threads)}).`, ); return netscriptDelay(growTime * 1000, workerScript).then(function () { - const moneyBefore = server.moneyAvailable <= 0 ? 1 : server.moneyAvailable; - processSingleServerGrowth(server, threads, Player, host.cpuCores); + const moneyBefore = server.moneyAvailable; + const growth = processSingleServerGrowth(server, threads, Player, host.cpuCores); const moneyAfter = server.moneyAvailable; workerScript.scriptRef.recordGrow(server.hostname, threads); const expGain = calculateHackingExpGain(server, Player) * threads; - const logGrowPercent = moneyAfter / moneyBefore - 1; + const logGrowPercent = growth; workerScript.log( "grow", () => diff --git a/src/Server/ServerHelpers.ts b/src/Server/ServerHelpers.ts index 7e8459e9d..db3639c74 100644 --- a/src/Server/ServerHelpers.ts +++ b/src/Server/ServerHelpers.ts @@ -74,8 +74,8 @@ export function processSingleServerGrowth(server: Server, threads: number, p: IP serverGrowth = 1; } + server.moneyAvailable = Math.max(server.moneyAvailable, 1); // It can be grown even if it has no money. 1$ min const oldMoneyAvailable = server.moneyAvailable; - server.moneyAvailable += 1 * threads; // It can be grown even if it has no money server.moneyAvailable *= serverGrowth; // in case of data corruption