mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-22 23:53:48 +01:00
Merge pull request #278 from hydroflame/fix-negative-growth
Fix negative growth
This commit is contained in:
commit
84d239e7f8
@ -308,8 +308,10 @@ function NetscriptFunctions(workerScript) {
|
|||||||
}
|
}
|
||||||
return netscriptDelay(growTime, workerScript).then(function() {
|
return netscriptDelay(growTime, workerScript).then(function() {
|
||||||
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
|
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
|
||||||
|
const moneyBefore = server.moneyAvailable;
|
||||||
server.moneyAvailable += (1 * threads); //It can be grown even if it has no money
|
server.moneyAvailable += (1 * threads); //It can be grown even if it has no money
|
||||||
var growthPercentage = processSingleServerGrowth(server, 450 * threads);
|
var growthPercentage = processSingleServerGrowth(server, 450 * threads);
|
||||||
|
const moneyAfter = server.moneyAvailable;
|
||||||
workerScript.scriptRef.recordGrow(server.ip, threads);
|
workerScript.scriptRef.recordGrow(server.ip, threads);
|
||||||
var expGain = scriptCalculateExpGain(server) * threads;
|
var expGain = scriptCalculateExpGain(server) * threads;
|
||||||
if (growthPercentage == 1) {
|
if (growthPercentage == 1) {
|
||||||
@ -317,7 +319,7 @@ function NetscriptFunctions(workerScript) {
|
|||||||
}
|
}
|
||||||
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
|
if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
|
||||||
workerScript.scriptRef.log("Available money on " + server.hostname + " grown by " +
|
workerScript.scriptRef.log("Available money on " + server.hostname + " grown by " +
|
||||||
formatNumber(growthPercentage*100 - 100, 6) + "%. Gained " +
|
formatNumber((moneyAfter/moneyBefore)*100 - 100, 6) + "%. Gained " +
|
||||||
formatNumber(expGain, 4) + " hacking exp (t=" + threads +")");
|
formatNumber(expGain, 4) + " hacking exp (t=" + threads +")");
|
||||||
}
|
}
|
||||||
workerScript.scriptRef.onlineExpGained += expGain;
|
workerScript.scriptRef.onlineExpGained += expGain;
|
||||||
|
Loading…
Reference in New Issue
Block a user