Fixed issue with Hacknet Node multipliers. Added total production cost display for Active Scripts

This commit is contained in:
Daniel Xie 2017-05-30 19:00:24 -05:00
parent 84c0fe892a
commit f4c90a1612
5 changed files with 40 additions and 9 deletions

@ -145,7 +145,8 @@ background-color: #555;
overflow-y: scroll;
}
#active-scripts-text {
#active-scripts-text,
#active-scripts-total-prod {
width: 70%;
margin: 6px;
padding: 4px;

@ -166,6 +166,7 @@
<div id="active-scripts-container">
<p id="active-scripts-text"> This page displays a list of all scripts that are currently running across every machine. It also gives
information about their production </p>
<p id="active-scripts-total-prod"> Total online production rate: </p>
<ul class="active-scripts-list" id="active-scripts-list" style="list-style: none;">
</ul>
</div>

@ -77,9 +77,8 @@ HacknetNode.prototype.purchaseLevelUpgrade = function(levels=1) {
if (cost > Player.money) {return false;}
Player.loseMoney(cost);
if (this.level + levels >= CONSTANTS.HacknetNodeMaxLevel) {
this.level = CONSTANTS.HacknetNodeMaxLevel;
this.updateMoneyGainRate();
return true;
var diff = Math.max(0, CONSTANTS.HacknetNodeMaxLevel - this.level);
return this.purchaseLevelUpgrade(diff);
}
this.level += levels;
this.updateMoneyGainRate();
@ -373,7 +372,8 @@ updateHacknetNodeDomElement = function(nodeObj) {
//Max
multiplier = getMaxNumberLevelUpgrades(nodeObj);
} else {
multiplier = hacknetNodePurchaseMultiplier;
var levelsToMax = CONSTANTS.HacknetNodeMaxLevel - nodeObj.level;
multiplier = Math.min(levelsToMax, hacknetNodePurchaseMultiplier);
}
var upgradeLevelCost = nodeObj.calculateLevelUpgradeCost(multiplier);

@ -57,6 +57,7 @@ function runScriptsLoop() {
if (errorTextArray.length != 4) {
console.log("ERROR: Something wrong with Error text in evaluator...");
console.log("Error text: " + errorText);
return;
}
var serverIp = errorTextArray[1];
var scriptName = errorTextArray[2];
@ -78,6 +79,7 @@ function runScriptsLoop() {
if (errorTextArray.length != 4) {
console.log("ERROR: Something wrong with Error text in evaluator...");
console.log("Error text: " + errorText);
return;
}
var serverIp = errorTextArray[1];
var scriptName = errorTextArray[2];
@ -87,7 +89,28 @@ function runScriptsLoop() {
}
w.running = false;
w.env.stopFlag = true;
}
} else if (isScriptErrorMessage(w)) {
var errorTextArray = errorText.split("|");
if (errorTextArray.length != 4) {
console.log("ERROR: Something wrong with Error text in evaluator...");
console.log("Error text: " + errorText);
return;
}
var serverIp = errorTextArray[1];
var scriptName = errorTextArray[2];
var errorMsg = errorTextArray[3];
dialogBoxCreate("Script runtime error: ", "Server Ip: " + serverIp, "Script name: " + scriptName, errorMsg);
//Find the corresponding workerscript and set its flags to kill it
for (var i = 0; i < workerScripts.length; ++i) {
if (workerScripts[i].serverIp == serverIp && workerScripts[i].name == scriptName) {
workerScripts[i].running = false;
workerScripts[i].env.stopFlag = true;
return;
}
}
}
});
}
}

@ -363,9 +363,12 @@ var Engine = {
//Update the ActiveScriptsItems array
updateActiveScriptsItems: function() {
var total = 0;
for (var i = 0; i < workerScripts.length; ++i) {
Engine.updateActiveScriptsItemContent(i, workerScripts[i]);
total += Engine.updateActiveScriptsItemContent(i, workerScripts[i]);
}
document.getElementById("active-scripts-total-prod").innerHTML =
"Total online production rate: $" + formatNumber(total, 2) + " / second";
},
//Updates the content of the given item in the Active Scripts list
@ -382,8 +385,8 @@ var Engine = {
item.removeChild(item.firstChild);
}
//Add the updated text back
Engine.createActiveScriptsText(workerscript, item);
//Add the updated text back. Returns the total online production rate
return Engine.createActiveScriptsText(workerscript, item);
},
createActiveScriptsText: function(workerscript, item) {
@ -421,6 +424,9 @@ var Engine = {
offlineMpsText + "<br>" + offlineEpsText + "<br>";
item.appendChild(itemText);
//Return total online production rate
return onlineMps;
},
displayFactionsInfo: function() {