From 23c862b72710bd38327fa7449dbcacb90629ffd6 Mon Sep 17 00:00:00 2001 From: danielyxie Date: Thu, 27 Sep 2018 21:09:02 -0500 Subject: [PATCH] grow() no longer reports Infinite growth when money is at 0 --- src/Constants.js | 1 + src/NetscriptFunctions.js | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/Constants.js b/src/Constants.js index 547bb046a..88a06b68d 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -514,6 +514,7 @@ let CONSTANTS = { * 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). * 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 ` } diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 1fd6f1465..02015b587 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -421,7 +421,7 @@ function NetscriptFunctions(workerScript) { } return netscriptDelay(growTime * 1000, workerScript).then(function() { 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 var growthPercentage = processSingleServerGrowth(server, 450 * threads); const moneyAfter = server.moneyAvailable;