diff --git a/README.md b/README.md index 9c3317aaa..ba370f007 100644 --- a/README.md +++ b/README.md @@ -57,9 +57,7 @@ Private beta feedback Also not really a big deal, but I'm at 110% zoom on chrome and the tutorial window covers some of the text - - For the last thing of the tutorial, I would just have a button like "Finish Tutorial" rather than "Next" - + I'd put a little popup or something when you click save, so you know Netscript commands: diff --git a/index.html b/index.html index f045e7fbb..ee64dfb49 100644 --- a/index.html +++ b/index.html @@ -112,6 +112,10 @@
  • Delete Game
  • + +
  • + Delete Active Scripts +
  • diff --git a/src/Augmentations.js b/src/Augmentations.js index 930a85daf..3ca5c1d03 100644 --- a/src/Augmentations.js +++ b/src/Augmentations.js @@ -760,7 +760,7 @@ initAugmentations = function() { AddToAugmentations(HacknetNodeNICUpload); var HacknetNodeKernelDNI = new Augmentation(AugmentationNames.HacknetNodeKernelDNI); - HacknetNodeKernelDNI.setRequirements(4000, 90000000); + HacknetNodeKernelDNI.setRequirements(4000, 12000000); HacknetNodeKernelDNI.setInfo("Installs a Direct-Neural Interface jack into the arm that is capable of connecting to a " + "Hacknet Node. This lets the user access and manipulate the Node's kernel using the mind's " + "electrochemical signals.

    " + diff --git a/src/Constants.js b/src/Constants.js index 44eb55917..317838987 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -34,17 +34,20 @@ CONSTANTS = { CodeInstructionRunTime: 1500, //RAM Costs for differenc commands - ScriptWhileRamCost: 0.4, - ScriptForRamCost: 0.4, - ScriptIfRamCost: 0.1, - ScriptHackRamCost: 0.25, - ScriptGrowRamCost: 0.25, - ScriptNukeRamCost: 0.05, - ScriptBrutesshRamCost: 0.05, - ScriptFtpcrackRamCost: 0.05, - ScriptRelaysmtpRamCost: 0.05, - ScriptHttpwormRamCost: 0.05, - ScriptSqlinjectRamCost: 0.05, + ScriptWhileRamCost: 0.4, + ScriptForRamCost: 0.4, + ScriptIfRamCost: 0.1, + ScriptHackRamCost: 0.25, + ScriptGrowRamCost: 0.25, + ScriptNukeRamCost: 0.05, + ScriptBrutesshRamCost: 0.05, + ScriptFtpcrackRamCost: 0.05, + ScriptRelaysmtpRamCost: 0.05, + ScriptHttpwormRamCost: 0.05, + ScriptSqlinjectRamCost: 0.05, + ScriptRunRamCost: 0.5, + ScriptGetHackingLevelRamCost: 0.1, + ScriptGetServerMoneyRamCost: 0.1, //Server growth rate ServerGrowthRate: 1.00075, diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js index 876e7dee5..ee18b1ee8 100644 --- a/src/NetscriptEvaluator.js +++ b/src/NetscriptEvaluator.js @@ -638,6 +638,7 @@ function evaluate(exp, workerScript) { reject(e); }); } else if (exp.func.value == "run") { + console.log("run() called"); if (exp.args.length != 1) { reject("|"+workerScript.serverIp+"|"+workerScript.name+"|run() call has incorrect number of arguments. Takes 1 argument"); } @@ -660,10 +661,12 @@ function evaluate(exp, workerScript) { reject(e); }); } else if (exp.func.value == "getHackingLevel") { + console.log("getHackingLevel called"); if (exp.args.length != 0) { reject("|"+workerScript.serverIp+"|"+workerScript.name+"|getHackingLevel() call has incorrect number of arguments. Takes 0 arguments"); } setTimeout(function() { + console.log("About to resolve getHackingLevel"); resolve(Player.hacking_skill); }, CONSTANTS.CodeInstructionRunTime); } else if (exp.func.value == "getServerMoneyAvailable") { @@ -687,6 +690,7 @@ function evaluate(exp, workerScript) { } }, CONSTANTS.CodeInstructionRunTime); }); + reject("|" + workerScript.serverIp + "|" + workerScript.name + "|Unrecognized function call"); break; default: diff --git a/src/NetscriptParser.js b/src/NetscriptParser.js index 09b366d31..95f4fad71 100644 --- a/src/NetscriptParser.js +++ b/src/NetscriptParser.js @@ -109,16 +109,13 @@ function Parser(input) { * else: {"type": "var", "value": "foo"} */ function parse_if() { - console.log("Parsing if token"); checkKeywordAndSkip("if"); //Conditional var cond = parse_expression(); - console.log("cond: " + cond); //Body var then = parse_expression(); - console.log("then: " + then); var ret = { type: "if", cond: [], diff --git a/src/NetscriptWorker.js b/src/NetscriptWorker.js index 6667d2608..4f57bb201 100644 --- a/src/NetscriptWorker.js +++ b/src/NetscriptWorker.js @@ -31,6 +31,7 @@ function runScriptsLoop() { if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) { try { var ast = Parser(Tokenizer(InputStream(workerScripts[i].code))); + console.log(ast); } catch (e) { dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":", e, "", ""); workerScripts[i].env.stopFlag = true; diff --git a/src/Player.js b/src/Player.js index 68256bf60..cbcda55ef 100644 --- a/src/Player.js +++ b/src/Player.js @@ -168,6 +168,7 @@ function PlayerObject() { //Used to store the last update time. this.lastUpdate = new Date().getTime(); + this.totalPlaytime = 0; }; PlayerObject.prototype.init = function() { diff --git a/src/Script.js b/src/Script.js index d9429618a..e86913312 100644 --- a/src/Script.js +++ b/src/Script.js @@ -96,11 +96,6 @@ function Script() { this.logs = []; //Script logging. Array of strings, with each element being a log entry /* Properties to calculate offline progress. Only applies for infinitely looping scripts */ - - //Number of instructions ("lines") in the code. Any call ending in a ; - //is considered one instruction. Used to calculate ramUsage - this.numInstructions = 0; - //Stats to display on the Scripts menu, and used to determine offline progress this.offlineRunningTime = 0.01; //Seconds this.offlineMoneyMade = 0; @@ -125,8 +120,7 @@ Script.prototype.saveScript = function() { //Server this.server = Player.currentServer; - //Calculate/update number of instructions, ram usage, execution time, etc. - this.updateNumInstructions(); + //Calculate/update ram usage, execution time, etc. this.updateRamUsage(); //Clear the stats when the script is updated @@ -147,12 +141,7 @@ Script.prototype.reset = function() { this.onlineRunningTime = 0.01; //Seconds this.onlineMoneyMade = 0; this.onlineExpGained = 0; -} - -//Calculates the number of instructions, which is just determined by number of semicolons -Script.prototype.updateNumInstructions = function() { - var numSemicolons = this.code.split(";").length - 1; - this.numInstructions = numSemicolons; + this.logs = []; } //Updates how much RAM the script uses when it is running. @@ -172,6 +161,9 @@ Script.prototype.updateRamUsage = function() { var relaysmtpCount = numOccurrences(codeCopy, "relaysmtp("); var httpwormCount = numOccurrences(codeCopy, "httpworm("); var sqlinjectCount = numOccurrences(codeCopy, "sqlinject("); + var runCount = numOccurrences(codeCopy, "run("); + var getHackingLevelCount = numOccurrences(codeCopy, "getHackingLevel("); + var getServerMoneyAvailableCount = numOccurrences(codeCopy, "getServerMoneyAvailable("); this.ramUsage = baseRam + ((whileCount * CONSTANTS.ScriptWhileRamCost) + @@ -184,7 +176,10 @@ Script.prototype.updateRamUsage = function() { (ftpcrackCount * CONSTANTS.ScriptFtpcrackRamCost) + (relaysmtpCount * CONSTANTS.ScriptRelaysmtpRamCost) + (httpwormCount * CONSTANTS.ScriptHttpwormRamCost) + - (sqlinjectCount * CONSTANTS.ScriptSqlinjectRamCost)); + (sqlinjectCount * CONSTANTS.ScriptSqlinjectRamCost) + + (runCount * CONSTANTS.ScriptRunRamCost) + + (getHackingLevelCount * CONSTANTS.ScriptGetHackingLevelRamCost) + + (getServerMoneyAvailableCount * CONSTANTS.ScriptGetServerMoneyRamCost)); console.log("ram usage: " + this.ramUsage); } @@ -304,7 +299,6 @@ function AllServersToMoneyMap() { } AllServersToMoneyMap.prototype.printConsole = function() { - console.log("Printing AllServersToMoneyMap"); for (var ip in this) { if (this.hasOwnProperty(ip)) { var serv = AllServers[ip]; @@ -312,7 +306,6 @@ AllServersToMoneyMap.prototype.printConsole = function() { console.log("Warning null server encountered with ip: " + ip); continue; } - console.log(ip + "(" + serv.hostname + "): " + this[ip]); } } } \ No newline at end of file diff --git a/src/engine.js b/src/engine.js index 57d580bce..5d7a4b400 100644 --- a/src/engine.js +++ b/src/engine.js @@ -273,7 +273,8 @@ var Engine = { 'Crime money multiplier: ' + formatNumber(Player.crime_money_mult * 100, 2) + '%


    ' + 'Misc

    ' + 'Servers owned: ' + Player.purchasedServers.length + '
    ' + - 'Hacknet Nodes owned: ' + Player.hacknetNodes.length + '

    ').replace( / /g, " " ); + 'Hacknet Nodes owned: ' + Player.hacknetNodes.length + '
    ' + + 'Time played: ' + convertTimeMsToTimeElapsedString(Player.totalPlaytime) + '


    ').replace( / /g, " " ); }, @@ -524,6 +525,11 @@ var Engine = { }, updateGame: function(numCycles = 1) { + //Update total playtime + var time = numCycles * Engine._idleSpeed; + if (Player.totalPlaytime == null) {Player.totalPlaytime = 0;} + Player.totalPlaytime += time; + //Start Manual hack if (Player.startAction == true) { Engine._totalActionTime = Player.actionTime; @@ -1001,6 +1007,12 @@ var Engine = { }); Engine.loadWorkInProgressContent(); } + + //DEBUG + document.getElementById("debug-delete-scripts-link").addEventListener("click", function() { + Player.getHomeComputer().runningScripts = []; + return false; + }); }, start: function() { diff --git a/utils/StringHelperFunctions.js b/utils/StringHelperFunctions.js index b518b5a0f..d030e5d3e 100644 --- a/utils/StringHelperFunctions.js +++ b/utils/StringHelperFunctions.js @@ -32,6 +32,9 @@ function convertTimeMsToTimeElapsedString(time) { //Convert ms to seconds, since we only have second-level precision time = Math.floor(time / 1000); + var days = Math.floor(time / 86400); + time %= 86400; + var hours = Math.floor(time / 3600); time %= 3600; @@ -40,7 +43,12 @@ function convertTimeMsToTimeElapsedString(time) { var seconds = time; - return hours + " hours " + minutes + " minutes " + seconds + " seconds"; + var res = ""; + if (days) {res += days + " days";} + if (hours) {res += hours + " hours ";} + if (minutes) {res += minutes + " minutes ";} + if (seconds) {res += seconds + " seconds ";} + return res; } //Finds the longest common starting substring in a set of strings