grow() no longer reports Infinite growth when money is at 0

This commit is contained in:
danielyxie 2018-09-27 21:09:02 -05:00
parent 561cdb1652
commit 11c60a87c2
2 changed files with 2 additions and 1 deletions

@ -514,6 +514,7 @@ let CONSTANTS = {
* It is now possible to use freely use angled bracket (<, >) and create DOM elements using tprint() * It is now possible to use freely use angled bracket (<, >) and create DOM elements using tprint()
* The game's theme colors can now be set through the Terminal configuration (.fconf). * The game's theme colors can now be set through the Terminal configuration (.fconf).
* You can now switch to the old left-hand main menu bar through the Terminal configuration (.fconf) * You can now switch to the old left-hand main menu bar through the Terminal configuration (.fconf)
* grow() percentage is no longer reported as Infinity when a server's money is grown from 0 to X
` `
} }

@ -421,7 +421,7 @@ function NetscriptFunctions(workerScript) {
} }
return netscriptDelay(growTime * 1000, workerScript).then(function() { return netscriptDelay(growTime * 1000, workerScript).then(function() {
if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
const moneyBefore = server.moneyAvailable; const moneyBefore = server.moneyAvailable <= 0 ? 1 : 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; const moneyAfter = server.moneyAvailable;