mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2025-03-07 11:04:36 +01:00
Operators now have RAM cost
This commit is contained in:
@ -48,6 +48,7 @@ CONSTANTS = {
|
||||
ScriptRunRamCost: 0.75,
|
||||
ScriptGetHackingLevelRamCost: 0.1,
|
||||
ScriptGetServerMoneyRamCost: 0.1,
|
||||
ScriptOperatorRamCost: 0.01,
|
||||
|
||||
//Server growth rate
|
||||
ServerGrowthRate: 1.00075,
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
}
|
||||
|
Reference in New Issue
Block a user