Added scan-analyze. Faction rep from donating affected by faction rep multiplier

This commit is contained in:
Daniel Xie 2017-05-23 12:36:35 -05:00
parent 9b83035187
commit 73c07841a3
6 changed files with 28 additions and 12 deletions

@ -147,6 +147,7 @@ CONSTANTS = {
"rm Delete a script/program from the machine. (WARNING: Permanent)<br>" + "rm Delete a script/program from the machine. (WARNING: Permanent)<br>" +
"run [script/program] Execute a program or a script<br>" + "run [script/program] Execute a program or a script<br>" +
"scan Displays all available network connections<br>" + "scan Displays all available network connections<br>" +
"scan-analyze Displays hacking-related information for all available network connections<br>" +
"sudov Shows whether or not you have root access on this computer<br>" + "sudov Shows whether or not you have root access on this computer<br>" +
"tail [script] Display script logs (logs contain details about active scripts)<br>" + "tail [script] Display script logs (logs contain details about active scripts)<br>" +
"top Display all running scripts and their RAM usage<br>", "top Display all running scripts and their RAM usage<br>",

@ -6,7 +6,7 @@ function factionInit() {
if (isPositiveNumber(val)) { if (isPositiveNumber(val)) {
var numMoneyDonate = Number(val); var numMoneyDonate = Number(val);
document.getElementById("faction-donate-rep-gain").innerHTML = 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 { } else {
document.getElementById("faction-donate-rep-gain").innerHTML = document.getElementById("faction-donate-rep-gain").innerHTML =
"This donation will result in 0 reputation gain"; "This donation will result in 0 reputation gain";
@ -585,7 +585,7 @@ displayFactionContent = function(factionName) {
return; return;
} }
Player.loseMoney(numMoneyDonate); Player.loseMoney(numMoneyDonate);
var repGain = numMoneyDonate / 1000; var repGain = numMoneyDonate / 1000 * Player.faction_rep_mult;
faction.playerReputation += repGain; faction.playerReputation += repGain;
dialogBoxCreate("You just donated $" + formatNumber(numMoneyDonate, 2) + " to " + dialogBoxCreate("You just donated $" + formatNumber(numMoneyDonate, 2) + " to " +
faction.name + " to gain " + formatNumber(repGain, 3) + " reputation"); faction.name + " to gain " + formatNumber(repGain, 3) + " reputation");

@ -219,6 +219,7 @@ function Parser(input) {
var tok = input.next(); var tok = input.next();
if (tok.type == "var" || tok.type == "num" || tok.type == "str") if (tok.type == "var" || tok.type == "num" || tok.type == "str")
console.log("encountered var in parse_atom");
return tok; return tok;
unexpected(); unexpected();
}); });

@ -31,7 +31,7 @@ function runScriptsLoop() {
if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) { if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) {
try { try {
var ast = Parser(Tokenizer(InputStream(workerScripts[i].code))); var ast = Parser(Tokenizer(InputStream(workerScripts[i].code)));
//console.log(ast); console.log(ast);
} catch (e) { } catch (e) {
dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":", e, "", ""); dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ":", e, "", "");
workerScripts[i].env.stopFlag = true; workerScripts[i].env.stopFlag = true;

@ -43,7 +43,7 @@ loadGame = function(saveObj) {
Factions = JSON.parse(saveObj.FactionsSave, Reviver); Factions = JSON.parse(saveObj.FactionsSave, Reviver);
SpecialServerIps = JSON.parse(saveObj.SpecialServerIpsSave, Reviver); SpecialServerIps = JSON.parse(saveObj.SpecialServerIpsSave, Reviver);
Augmentations = JSON.parse(saveObj.AugmentationsSave, Reviver); Augmentations = JSON.parse(saveObj.AugmentationsSave, Reviver);
if (saveObj.hasOwnProperty(AliasesSave)) { if (saveObj.hasOwnProperty("AliasesSave")) {
try { try {
Aliases = JSON.parse(saveObj.AliasesSave, Reviver); Aliases = JSON.parse(saveObj.AliasesSave, Reviver);
} catch(e) { } catch(e) {

@ -675,9 +675,6 @@ var Terminal = {
} }
Engine.loadScriptEditorContent(scriptname, ""); Engine.loadScriptEditorContent(scriptname, "");
break; break;
case "scan":
Terminal.executeScanCommand(commandArray);
break;
case "ps": case "ps":
if (commandArray.length != 1) { if (commandArray.length != 1) {
post("Incorrect usage of ps command. Usage: ps"); return; post("Incorrect usage of ps command. Usage: ps"); return;
@ -732,12 +729,11 @@ var Terminal = {
} }
} }
break; break;
case "scan":
Terminal.executeScanCommand(commandArray);
break;
case "scan-analyze": case "scan-analyze":
if (commandArray.length != 1) { Terminal.executeScanAnalyzeCommand(commandArray);
post("Incorrect number of arguments. Usage: scan-analyze");
} else {
Terminal.executeScanAnalyzeCommand();
}
break; break;
case "scp": case "scp":
//TODO //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("<strong>" + serv.hostname + "</strong>");
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) { executeFreeCommand: function(commandArray) {
if (commandArray.length != 1) { if (commandArray.length != 1) {
post("Incorrect usage of free command. Usage: free"); return; post("Incorrect usage of free command. Usage: free"); return;