Fixed bug with Hacknet nodes

This commit is contained in:
Daniel Xie 2017-05-30 15:34:29 -05:00
parent 6a2343ee58
commit 2569a4819d

@ -78,7 +78,8 @@ HacknetNode.prototype.purchaseLevelUpgrade = function(levels=1) {
Player.loseMoney(cost); Player.loseMoney(cost);
if (this.level + levels >= CONSTANTS.HacknetNodeMaxLevel) { if (this.level + levels >= CONSTANTS.HacknetNodeMaxLevel) {
this.level = CONSTANTS.HacknetNodeMaxLevel; this.level = CONSTANTS.HacknetNodeMaxLevel;
return false; this.updateMoneyGainRate();
return true;
} }
this.level += levels; this.level += levels;
this.updateMoneyGainRate(); this.updateMoneyGainRate();
@ -99,8 +100,8 @@ HacknetNode.prototype.purchaseRamUpgrade = function() {
var cost = this.calculateRamUpgradeCost(); var cost = this.calculateRamUpgradeCost();
if (isNaN(cost)) {return false;} if (isNaN(cost)) {return false;}
if (cost > Player.money) {return false;} if (cost > Player.money) {return false;}
Player.loseMoney(cost);
if (this.ram >= CONSTANTS.HacknetNodeMaxRam) {return false;} if (this.ram >= CONSTANTS.HacknetNodeMaxRam) {return false;}
Player.loseMoney(cost);
this.ram *= 2; //Ram is always doubled this.ram *= 2; //Ram is always doubled
this.updateMoneyGainRate(); this.updateMoneyGainRate();
return true; return true;
@ -116,8 +117,8 @@ HacknetNode.prototype.purchaseCoreUpgrade = function() {
var cost = this.calculateCoreUpgradeCost(); var cost = this.calculateCoreUpgradeCost();
if (isNaN(cost)) {return false;} if (isNaN(cost)) {return false;}
if (cost > Player.money) {return false;} if (cost > Player.money) {return false;}
Player.loseMoney(cost);
if (this.numCores >= CONSTANTS.HacknetNodeMaxCores) {return false;} if (this.numCores >= CONSTANTS.HacknetNodeMaxCores) {return false;}
Player.loseMoney(cost);
++this.numCores; ++this.numCores;
this.updateMoneyGainRate(); this.updateMoneyGainRate();
return true; return true;