mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-26 09:33:49 +01:00
Merge pull request #2785 from davidpa9708/improve-server-grow-low-money
Use min `server.moneyAvailable` of 1$ when growing server money
This commit is contained in:
commit
0a0b7db06f
@ -612,12 +612,12 @@ export function NetscriptFunctions(workerScript: WorkerScript): NS {
|
|||||||
)} (t=${numeralWrapper.formatThreads(threads)}).`,
|
)} (t=${numeralWrapper.formatThreads(threads)}).`,
|
||||||
);
|
);
|
||||||
return netscriptDelay(growTime * 1000, workerScript).then(function () {
|
return netscriptDelay(growTime * 1000, workerScript).then(function () {
|
||||||
const moneyBefore = server.moneyAvailable <= 0 ? 1 : server.moneyAvailable;
|
const moneyBefore = server.moneyAvailable;
|
||||||
processSingleServerGrowth(server, threads, Player, host.cpuCores);
|
const growth = processSingleServerGrowth(server, threads, Player, host.cpuCores);
|
||||||
const moneyAfter = server.moneyAvailable;
|
const moneyAfter = server.moneyAvailable;
|
||||||
workerScript.scriptRef.recordGrow(server.hostname, threads);
|
workerScript.scriptRef.recordGrow(server.hostname, threads);
|
||||||
const expGain = calculateHackingExpGain(server, Player) * threads;
|
const expGain = calculateHackingExpGain(server, Player) * threads;
|
||||||
const logGrowPercent = moneyAfter / moneyBefore - 1;
|
const logGrowPercent = growth;
|
||||||
workerScript.log(
|
workerScript.log(
|
||||||
"grow",
|
"grow",
|
||||||
() =>
|
() =>
|
||||||
|
@ -74,8 +74,8 @@ export function processSingleServerGrowth(server: Server, threads: number, p: IP
|
|||||||
serverGrowth = 1;
|
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;
|
const oldMoneyAvailable = server.moneyAvailable;
|
||||||
server.moneyAvailable += 1 * threads; // It can be grown even if it has no money
|
|
||||||
server.moneyAvailable *= serverGrowth;
|
server.moneyAvailable *= serverGrowth;
|
||||||
|
|
||||||
// in case of data corruption
|
// in case of data corruption
|
||||||
|
Loading…
Reference in New Issue
Block a user