Operators now have RAM cost

This commit is contained in:
Daniel Xie
2017-05-15 10:38:17 -05:00
parent 51c8e7a6c6
commit bb73fe1101
3 changed files with 31 additions and 3 deletions

View File

@ -48,6 +48,7 @@ CONSTANTS = {
ScriptRunRamCost: 0.75,
ScriptGetHackingLevelRamCost: 0.1,
ScriptGetServerMoneyRamCost: 0.1,
ScriptOperatorRamCost: 0.01,
//Server growth rate
ServerGrowthRate: 1.00075,

View File

@ -180,8 +180,12 @@ Script.prototype.updateRamUsage = function() {
(sqlinjectCount * CONSTANTS.ScriptSqlinjectRamCost) +
(runCount * CONSTANTS.ScriptRunRamCost) +
(getHackingLevelCount * CONSTANTS.ScriptGetHackingLevelRamCost) +
(getServerMoneyAvailableCount * CONSTANTS.ScriptGetServerMoneyRamCost));
(getServerMoneyAvailableCount * CONSTANTS.ScriptGetServerMoneyRamCost) +
(numOperators * CONSTANTS.ScriptOperatorRamCost));
console.log("ram usage: " + this.ramUsage);
if (isNaN(this.ramUsage)) {
dialogBoxCreate("ERROR in calculating ram usage. This is a bug, please report to game develoepr");
}
}
Script.prototype.log = function(txt) {

View File

@ -81,7 +81,7 @@ function formatNumber(num, numFractionDigits) {
});
}
//Counters the number of times a substring occurs in a string
//Count the number of times a substring occurs in a string
function numOccurrences(string, subString) {
string += "";
subString += "";
@ -97,4 +97,27 @@ function numOccurrences(string, subString) {
} else break;
}
return n;
}
}
//Counters the number of Netscript operators in a string
function numNetscriptOperators(string) {
var total = 0;
total += numOccurrences(string, "+");
total += numOccurrences(string, "-");
total += numOccurrences(string, "*");
total += numOccurrences(string, "/");
total += numOccurrences(string, "%");
total += numOccurrences(string, "&&");
total += numOccurrences(string, "||");
total += numOccurrences(string, "<");
total += numOccurrences(string, ">");
total += numOccurrences(string, "<=");
total += numOccurrences(string, ">=");
total += numOccurrences(string, "==");
total += numOccurrences(string, "!=");
if (isNaN(total)) {
dialogBoxCreate("ERROR in counting number of operators in script. This is a bug, please report to game developer");
total = 0;
}
return total;
}