Added arrays to Netscript. Fixed bug with Hacknet Nodes

This commit is contained in:
Daniel Xie
2017-06-10 17:44:33 -05:00
parent 6582026557
commit 60207b8e04
5 changed files with 63 additions and 9 deletions
+2 -2
View File
@@ -74,12 +74,12 @@ HacknetNode.prototype.calculateLevelUpgradeCost = function(levels=1) {
HacknetNode.prototype.purchaseLevelUpgrade = function(levels=1) {
var cost = this.calculateLevelUpgradeCost(levels);
if (isNaN(cost)) {return false;}
if (cost > Player.money) {return false;}
Player.loseMoney(cost);
if (this.level + levels > CONSTANTS.HacknetNodeMaxLevel) {
var diff = Math.max(0, CONSTANTS.HacknetNodeMaxLevel - this.level);
return this.purchaseLevelUpgrade(diff);
}
if (cost > Player.money) {return false;}
Player.loseMoney(cost);
this.level += levels;
this.updateMoneyGainRate();
return true;