From 66d311f9d891e5adc5d68f38a4c30e510177050f Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Mon, 29 May 2017 18:12:57 -0500 Subject: [PATCH] Added RAM cost for getHostname() and hasRootAccess(). Applied hacking grow_mult to server growth) git p --- src/Constants.js | 2 ++ src/NetscriptEvaluator.js | 1 - src/Script.js | 4 ++++ src/Server.js | 4 ++-- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Constants.js b/src/Constants.js index ae5a82591..77932c6af 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -49,6 +49,8 @@ CONSTANTS = { ScriptHttpwormRamCost: 0.05, ScriptSqlinjectRamCost: 0.05, ScriptRunRamCost: 0.8, + ScriptHasRootAccessRamCost: 0.05, + ScriptGetHostnameRamCost: 0.1, ScriptGetHackingLevelRamCost: 0.1, ScriptGetServerMoneyRamCost: 0.1, ScriptOperatorRamCost: 0.01, diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js index fdf1ee66a..26a345423 100644 --- a/src/NetscriptEvaluator.js +++ b/src/NetscriptEvaluator.js @@ -169,7 +169,6 @@ function evaluate(exp, workerScript) { var pForLoop = evaluateFor(exp, workerScript); pForLoop.then(function(forLoopRes) { resolve("forLoopDone"); - workerScript.scriptRef.log("Exiting for loop"); }, function(e) { reject(e); }); diff --git a/src/Script.js b/src/Script.js index 89e24057f..147bae1e8 100644 --- a/src/Script.js +++ b/src/Script.js @@ -182,6 +182,8 @@ Script.prototype.updateRamUsage = function() { var httpwormCount = numOccurrences(codeCopy, "httpworm("); var sqlinjectCount = numOccurrences(codeCopy, "sqlinject("); var runCount = numOccurrences(codeCopy, "run("); + var hasRootAccessCount = numOccurrences(codeCopy, "hasRootAccess("); + var getHostnameCount = numOccurrences(codeCopy, "getHostname("); var getHackingLevelCount = numOccurrences(codeCopy, "getHackingLevel("); var getServerMoneyAvailableCount = numOccurrences(codeCopy, "getServerMoneyAvailable("); var numOperators = numNetscriptOperators(codeCopy); @@ -204,6 +206,8 @@ Script.prototype.updateRamUsage = function() { (httpwormCount * CONSTANTS.ScriptHttpwormRamCost) + (sqlinjectCount * CONSTANTS.ScriptSqlinjectRamCost) + (runCount * CONSTANTS.ScriptRunRamCost) + + (hasRootAccessCount * CONSTANTS.ScriptHasRootAccessRamCost) + + (getHostnameCount * CONSTANTS.ScriptGetHostnameRamCost) + (getHackingLevelCount * CONSTANTS.ScriptGetHackingLevelRamCost) + (getServerMoneyAvailableCount * CONSTANTS.ScriptGetServerMoneyRamCost) + (numOperators * CONSTANTS.ScriptOperatorRamCost) + diff --git a/src/Server.js b/src/Server.js index a4ade1bfd..aff18b744 100644 --- a/src/Server.js +++ b/src/Server.js @@ -651,7 +651,7 @@ processServerGrowth = function(numCycles) { var numServerGrowthCyclesAdjusted = numServerGrowthCycles * serverGrowthPercentage; //Apply serverGrowth for the calculated number of growth cycles - var serverGrowth = Math.pow(CONSTANTS.ServerGrowthRate, numServerGrowthCyclesAdjusted); + var serverGrowth = Math.pow(CONSTANTS.ServerGrowthRate, numServerGrowthCyclesAdjusted) * Player.hacking_grow_mult; if (serverGrowth < 1) { console.log("WARN: serverGrowth calculated to be less than 1"); serverGrowth = 1; @@ -674,7 +674,7 @@ processSingleServerGrowth = function(server, numCycles) { var numServerGrowthCyclesAdjusted = numServerGrowthCycles * serverGrowthPercentage; //Apply serverGrowth for the calculated number of growth cycles - var serverGrowth = Math.pow(CONSTANTS.ServerGrowthRate, numServerGrowthCyclesAdjusted); + var serverGrowth = Math.pow(CONSTANTS.ServerGrowthRate, numServerGrowthCyclesAdjusted) * Player.hacking_grow_mult; if (serverGrowth < 1) { console.log("WARN: serverGrowth calculated to be less than 1"); serverGrowth = 1;