From 73c07841a313a7c995854b22da013c3ea8b6fb88 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Tue, 23 May 2017 12:36:35 -0500 Subject: [PATCH] Added scan-analyze. Faction rep from donating affected by faction rep multiplier --- src/Constants.js | 1 + src/Faction.js | 4 ++-- src/NetscriptParser.js | 1 + src/NetscriptWorker.js | 2 +- src/SaveObject.js | 2 +- src/Terminal.js | 30 ++++++++++++++++++++++-------- 6 files changed, 28 insertions(+), 12 deletions(-) diff --git a/src/Constants.js b/src/Constants.js index 71c405803..6e3545357 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -147,6 +147,7 @@ CONSTANTS = { "rm Delete a script/program from the machine. (WARNING: Permanent)
" + "run [script/program] Execute a program or a script
" + "scan Displays all available network connections
" + + "scan-analyze Displays hacking-related information for all available network connections
" + "sudov Shows whether or not you have root access on this computer
" + "tail [script] Display script logs (logs contain details about active scripts)
" + "top Display all running scripts and their RAM usage
", diff --git a/src/Faction.js b/src/Faction.js index d1095a143..1cb954c8c 100644 --- a/src/Faction.js +++ b/src/Faction.js @@ -6,7 +6,7 @@ function factionInit() { if (isPositiveNumber(val)) { var numMoneyDonate = Number(val); document.getElementById("faction-donate-rep-gain").innerHTML = - "This donation will result in " + formatNumber(numMoneyDonate/1000, 3) + " reputation gain"; + "This donation will result in " + formatNumber(numMoneyDonate/1000 * Player.faction_rep_mult, 3) + " reputation gain"; } else { document.getElementById("faction-donate-rep-gain").innerHTML = "This donation will result in 0 reputation gain"; @@ -585,7 +585,7 @@ displayFactionContent = function(factionName) { return; } Player.loseMoney(numMoneyDonate); - var repGain = numMoneyDonate / 1000; + var repGain = numMoneyDonate / 1000 * Player.faction_rep_mult; faction.playerReputation += repGain; dialogBoxCreate("You just donated $" + formatNumber(numMoneyDonate, 2) + " to " + faction.name + " to gain " + formatNumber(repGain, 3) + " reputation"); diff --git a/src/NetscriptParser.js b/src/NetscriptParser.js index 95f4fad71..f3987b7f8 100644 --- a/src/NetscriptParser.js +++ b/src/NetscriptParser.js @@ -219,6 +219,7 @@ function Parser(input) { var tok = input.next(); if (tok.type == "var" || tok.type == "num" || tok.type == "str") + console.log("encountered var in parse_atom"); return tok; unexpected(); }); diff --git a/src/NetscriptWorker.js b/src/NetscriptWorker.js index 1076ced86..4f57bb201 100644 --- a/src/NetscriptWorker.js +++ b/src/NetscriptWorker.js @@ -31,7 +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); + console.log(ast); } catch (e) { dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":", e, "", ""); workerScripts[i].env.stopFlag = true; diff --git a/src/SaveObject.js b/src/SaveObject.js index 2a5f50580..b22dfecb5 100644 --- a/src/SaveObject.js +++ b/src/SaveObject.js @@ -43,7 +43,7 @@ loadGame = function(saveObj) { Factions = JSON.parse(saveObj.FactionsSave, Reviver); SpecialServerIps = JSON.parse(saveObj.SpecialServerIpsSave, Reviver); Augmentations = JSON.parse(saveObj.AugmentationsSave, Reviver); - if (saveObj.hasOwnProperty(AliasesSave)) { + if (saveObj.hasOwnProperty("AliasesSave")) { try { Aliases = JSON.parse(saveObj.AliasesSave, Reviver); } catch(e) { diff --git a/src/Terminal.js b/src/Terminal.js index 16a777c66..a72f806d3 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -675,9 +675,6 @@ var Terminal = { } Engine.loadScriptEditorContent(scriptname, ""); break; - case "scan": - Terminal.executeScanCommand(commandArray); - break; case "ps": if (commandArray.length != 1) { post("Incorrect usage of ps command. Usage: ps"); return; @@ -732,12 +729,11 @@ var Terminal = { } } break; + case "scan": + Terminal.executeScanCommand(commandArray); + break; case "scan-analyze": - if (commandArray.length != 1) { - post("Incorrect number of arguments. Usage: scan-analyze"); - } else { - Terminal.executeScanAnalyzeCommand(); - } + Terminal.executeScanAnalyzeCommand(commandArray); break; case "scp": //TODO @@ -842,6 +838,24 @@ var Terminal = { } }, + executeScanAnalyzeCommand: function(commandArray) { + if (commandArray.length != 1) { + post("Incorrect usage of scan-analyze command. usage: scan-analyze"); return; + } + var currServ = Player.getCurrentServer(); + for (var i = 0; i < currServ.serversOnNetwork.length; ++i) { + var serv = currServ.getServerOnNetwork(i); + if (serv == null) {continue;} + post("" + serv.hostname + ""); + var c = "N"; + if (serv.hasAdminRights) {c = "Y";} + post("----Root Access: " + c); + post("----Required hacking skill: " + serv.requiredHackingSkill); + post("----Number open ports required to NUKE: " + serv.numOpenPortsRequired); + post(" "); + } + }, + executeFreeCommand: function(commandArray) { if (commandArray.length != 1) { post("Incorrect usage of free command. Usage: free"); return;