From 34a86fc32cb03ac38c6651ad296466c5334b6cb3 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Fri, 16 Jun 2017 10:57:03 -0400 Subject: [PATCH 01/15] Implement top Implementation of the "top" command. Uses the column formatting from scan, which breaks with long names. --- src/Terminal.js | 34 ++++++++++++++++++++++++++++++++-- 1 file changed, 32 insertions(+), 2 deletions(-) diff --git a/src/Terminal.js b/src/Terminal.js index af5fb4aad..a5cd28229 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -954,8 +954,38 @@ var Terminal = { } break; case "top": - //TODO List each's script RAM usage - post("Not yet implemented"); + if(commandArray.length != 1) { + post("Incorrect usage of top command. Usage: top"); return; + } + + post("Script RAM Usage Threads"); + var currRunningScripts = Player.getCurrentServer().runningScripts; + for(i = 0; i < currRunningScripts.length; i++) { + //Check if script is on current server + for(j = 0; j < Player.getCurrentServer().scripts.length; j++) { + if(currRunningScripts[i] === Player.getCurrentServer().scripts[j].filename) { + var script = Player.getCurrentServer().scripts[j]; + + //Add script name + var entry = script.filename; + + //Calculate padding and add RAM usage + var numSpaces = 26 - entry.length; + var spaces = Array(numSpaces+1).join(" "); + entry += spaces; + var ramUsage = (script.ramUsage * script.threads * Math.pow(1.02, script.threads - 1)).toFixed(3); + entry += ramUsage + "GB"; + + //Calculate padding and add thread count + numSpaces = 26 - (ramUsage.length + 2); + spaces = Array(numSpaces+1).join(" "); + entry += spaces; + entry += script.threads; + + post(entry); + } + } + } break; default: post("Command not found"); From 96be33344fb0f22add0d4e595de389f8efdbf720 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Fri, 16 Jun 2017 13:23:42 -0400 Subject: [PATCH 02/15] Update "top" command Updated the entry construction to use `.join()` and added/updated comments. --- src/Terminal.js | 37 ++++++++++++++++++------------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/Terminal.js b/src/Terminal.js index a5cd28229..0020b829c 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -957,32 +957,31 @@ var Terminal = { if(commandArray.length != 1) { post("Incorrect usage of top command. Usage: top"); return; } - + post("Script RAM Usage Threads"); + var currRunningScripts = Player.getCurrentServer().runningScripts; - for(i = 0; i < currRunningScripts.length; i++) { - //Check if script is on current server - for(j = 0; j < Player.getCurrentServer().scripts.length; j++) { - if(currRunningScripts[i] === Player.getCurrentServer().scripts[j].filename) { + //Iterate through active scripts on current server + for(var i = 0; i < currRunningScripts.length; i++) { + //Iterate through scripts on current server + for(var j = 0; j < Player.getCurrentServer().scripts.length; j++) { + if(currRunningScripts[i] === Player.getCurrentServer().scripts[j].filename) { //If the script is active var script = Player.getCurrentServer().scripts[j]; - //Add script name - var entry = script.filename; + //Calculate name padding + var numSpacesScript = 26 - script.filename.length; // 26 is the width of each column + var spacesScript = Array(numSpacesScript+1).join(" "); - //Calculate padding and add RAM usage - var numSpaces = 26 - entry.length; - var spaces = Array(numSpaces+1).join(" "); - entry += spaces; - var ramUsage = (script.ramUsage * script.threads * Math.pow(1.02, script.threads - 1)).toFixed(3); - entry += ramUsage + "GB"; + //Calculate and transform RAM usage + var ramUsage = script.ramUsage * script.threads * Math.pow(1.02, script.threads - 1); + ramUsage = ramUsage.toFixed(3) + "GB"; //Rounds RAM to three decimal places - //Calculate padding and add thread count - numSpaces = 26 - (ramUsage.length + 2); - spaces = Array(numSpaces+1).join(" "); - entry += spaces; - entry += script.threads; + //Calculate RAM padding + var numSpacesRAM = 26 - ramUsage.length; + var spacesRAM = Array(numSpacesRAM+1).join(" "); - post(entry); + var entry = [script.filename, spacesScript, ramUsage, spacesRAM, script.threads]; + post(entry.join("")); } } } From 92b100f3ce4aaf88f5bb26fbb405db57ed7b2414 Mon Sep 17 00:00:00 2001 From: Kyle B Date: Fri, 16 Jun 2017 14:17:40 -0400 Subject: [PATCH 03/15] Update "top" command- columns and loops Switched the RAM and thread columns so that the RAM usage does not need to be rounded. Updated structure to remove nested loops. --- src/Terminal.js | 48 +++++++++++++++++++++++------------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/Terminal.js b/src/Terminal.js index 0020b829c..229c548f5 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -954,37 +954,35 @@ var Terminal = { } break; case "top": - if(commandArray.length != 1) { - post("Incorrect usage of top command. Usage: top"); return; - } + if(commandArray.length != 1) { + post("Incorrect usage of top command. Usage: top"); return; + } - post("Script RAM Usage Threads"); + post("Script Threads RAM Usage"); - var currRunningScripts = Player.getCurrentServer().runningScripts; - //Iterate through active scripts on current server - for(var i = 0; i < currRunningScripts.length; i++) { - //Iterate through scripts on current server - for(var j = 0; j < Player.getCurrentServer().scripts.length; j++) { - if(currRunningScripts[i] === Player.getCurrentServer().scripts[j].filename) { //If the script is active - var script = Player.getCurrentServer().scripts[j]; + var currRunningScripts = Player.getCurrentServer().runningScripts; + var currScripts = Player.getCurrentServer().scripts; + //Iterate through scripts on current server + for(var i = 0; i < currScripts.length; i++) { + if(currRunningScripts.includes(currScripts[i].filename)) { //If the script is running + var script = currScripts[i]; - //Calculate name padding - var numSpacesScript = 26 - script.filename.length; // 26 is the width of each column - var spacesScript = Array(numSpacesScript+1).join(" "); + //Calculate name padding + var numSpacesScript = 26 - script.filename.length; //26 -> width of name column + var spacesScript = Array(numSpacesScript+1).join(" "); - //Calculate and transform RAM usage - var ramUsage = script.ramUsage * script.threads * Math.pow(1.02, script.threads - 1); - ramUsage = ramUsage.toFixed(3) + "GB"; //Rounds RAM to three decimal places + //Calculate thread padding + var numSpacesThread = 16 - (script.threads + "").length; //16 -> width of thread column + var spacesThread = Array(numSpacesThread+1).join(" "); - //Calculate RAM padding - var numSpacesRAM = 26 - ramUsage.length; - var spacesRAM = Array(numSpacesRAM+1).join(" "); + //Calculate and transform RAM usage + var ramUsage = script.ramUsage * script.threads * Math.pow(1.02, script.threads - 1); + ramUsage = ramUsage + "GB"; - var entry = [script.filename, spacesScript, ramUsage, spacesRAM, script.threads]; - post(entry.join("")); - } - } - } + var entry = [script.filename, spacesScript, script.threads, spacesThread, ramUsage]; + post(entry.join("")); + } + } break; default: post("Command not found"); From bc282daf088714cc95161b59642f15c4deef1fad Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Wed, 28 Jun 2017 14:21:04 -0500 Subject: [PATCH 04/15] Bug fix with marking augmentations as owned in Player.augmentations --- src/Faction.js | 6 ++++++ src/SaveObject.js | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/Faction.js b/src/Faction.js index 4037335ad..e7a1e5bb2 100644 --- a/src/Faction.js +++ b/src/Faction.js @@ -982,6 +982,12 @@ displayFactionAugmentations = function(factionName) { owned = true; } } + for (var j = 0; j < Player.augmentations.length; ++j) { + if (Player.augmentations[j].name == aug.name) { + owned = true; + } + } + var item = document.createElement("li"); var span = document.createElement("span"); var aDiv = document.createElement("div"); diff --git a/src/SaveObject.js b/src/SaveObject.js index 6d4e5aaf1..f37638585 100644 --- a/src/SaveObject.js +++ b/src/SaveObject.js @@ -168,7 +168,7 @@ loadImportedGame = function(saveObj, saveString) { } } if (CONSTANTS.Version == "0.23.0") { - Augmentations = JSON.parse(saveObj.AugmentationsSave, Reviver); + tempAugmentations = JSON.parse(saveObj.AugmentationsSave, Reviver); } createNewUpdateText(); } From d63f17fa8d701ccd96e8bd931eb761f33037b724 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Wed, 28 Jun 2017 15:53:12 -0500 Subject: [PATCH 05/15] initAugmentations() now called applyAugmentations() at the end --- css/menupages.css | 10 ++++++---- index.html | 20 ++++++++++---------- src/Augmentations.js | 2 ++ src/Constants.js | 3 +++ src/Player.js | 8 ++++++++ src/engine.js | 9 +++++---- 6 files changed, 34 insertions(+), 18 deletions(-) diff --git a/css/menupages.css b/css/menupages.css index 756dca2de..34d6162a6 100644 --- a/css/menupages.css +++ b/css/menupages.css @@ -508,12 +508,8 @@ div.faction-clear { /* Location */ #location-container { - color: var(--my-font-color); position: fixed; padding: 6px; - height: 100%; - margin-left: 10%; - width: 99%; } #location-slums-description { @@ -533,3 +529,9 @@ div.faction-clear { #location-job-reputation, #location-company-favor { display: inline; } + +/* Infiltration */ +#infiltration-container { + position: fixed; + padding: 6px; +} diff --git a/index.html b/index.html index f9cd95be5..92a07748d 100644 --- a/index.html +++ b/index.html @@ -683,16 +683,16 @@

- - - - - - - - - - + + + + + + + + + +
diff --git a/src/Augmentations.js b/src/Augmentations.js index c6b811983..517201949 100644 --- a/src/Augmentations.js +++ b/src/Augmentations.js @@ -1379,6 +1379,8 @@ initAugmentations = function() { Augmentations[name].baseCost *= mult; } } + + Player.reapplyAllAugmentations(); } applyAugmentation = function(aug, reapply=false) { diff --git a/src/Constants.js b/src/Constants.js index 1ca6a45c9..43024237d 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -91,6 +91,9 @@ CONSTANTS = { //How much a TOR router costs TorRouterCost: 200000, + //Infiltration constants + InfiltrationBribeBaseAmount: 100000, //Amount per clearance level + MillisecondsPer20Hours: 72000000, GameCyclesPer20Hours: 72000000 / 200, diff --git a/src/Player.js b/src/Player.js index 70a1a77e9..a2bbd4bfc 100644 --- a/src/Player.js +++ b/src/Player.js @@ -1204,6 +1204,14 @@ PlayerObject.prototype.finishCrime = function(cancelled) { Engine.loadLocationContent(); } +PlayerObject.prototype.takeDamage = function() { + +} + +PlayerObject.prototype.hospitalize = function() { + +} + /* Functions for saving and loading the Player data */ PlayerObject.prototype.toJSON = function() { return Generic_toJSON("PlayerObject", this); diff --git a/src/engine.js b/src/engine.js index b9160ec53..e6f51e3d5 100644 --- a/src/engine.js +++ b/src/engine.js @@ -54,6 +54,7 @@ var Engine = { factionAugmentationsContent: null, augmentationsContent: null, tutorialContent: null, + infiltrationContent: null, locationContent: null, workInProgressContent: null, @@ -682,7 +683,7 @@ var Engine = { Engine.setDisplayElements(); //Sets variables for important DOM elements Engine.init(); //Initialize buttons, work, etc. CompanyPositions.init(); - initAugmentations(); + initAugmentations(); //Also calls Player.reapplyAllAugmentations() //Calculate the number of cycles have elapsed while offline Engine._lastUpdate = new Date().getTime(); @@ -721,9 +722,6 @@ var Engine = { Player.totalPlaytime += time; Player.playtimeSinceLastAug += time; - //Re-apply augmentations - Player.reapplyAllAugmentations(); - Player.lastUpdate = Engine._lastUpdate; Engine.start(); //Run main game loop and Scripts loop dialogBoxCreate("While you were offline, your scripts generated $" + @@ -787,6 +785,9 @@ var Engine = { Engine.Display.tutorialContent = document.getElementById("tutorial-container"); Engine.Display.tutorialContent.style.visibility = "hidden"; + Engine.Display.infiltrationContent = document.getElementById("infiltration-container"); + Engine.Display.infiltrationContent.style.visibility = "hidden"; + //Character info Engine.Display.characterInfo = document.getElementById("character-info"); From f18b8d58faa6508a5b99ba5240e61d6176ebefa5 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Thu, 29 Jun 2017 09:16:32 -0500 Subject: [PATCH 06/15] scan() now takes in 1 argument representing the server to scan --- src/Constants.js | 7 ++++++- src/NetscriptEvaluator.js | 33 ++++++++++++++++++++------------- 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/Constants.js b/src/Constants.js index 43024237d..31e70c4f4 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -1,5 +1,5 @@ CONSTANTS = { - Version: "0.23.0", + Version: "0.23.1", //Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience //and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then @@ -94,6 +94,9 @@ CONSTANTS = { //Infiltration constants InfiltrationBribeBaseAmount: 100000, //Amount per clearance level + + HospitalCostPerHp: 25000, + MillisecondsPer20Hours: 72000000, GameCyclesPer20Hours: 72000000 / 200, @@ -857,6 +860,8 @@ CONSTANTS = { "-You can now see what an Augmentation does and its price even while its locked

", LatestUpdate: + "v0.23.1
" + + "-scan() Netscript function now takes a single argument representing the server from which to scan.

" + "v0.23.0
" + "-You can now purchase multiple Augmentations in a run. When you purchase an Augmentation you will lose money equal to the price " + "and then the cost of purchasing another Augmentation during this run will be increased by 75%. You do not gain the benefits " + diff --git a/src/NetscriptEvaluator.js b/src/NetscriptEvaluator.js index a939af495..c72917736 100644 --- a/src/NetscriptEvaluator.js +++ b/src/NetscriptEvaluator.js @@ -204,20 +204,27 @@ function evaluate(exp, workerScript) { }); } else if (exp.func.value == "scan") { - if (exp.args.length != 0) { - return reject(makeRuntimeRejectMsg(workerScript, "scan() call has incorrect number of arguments. Takes 0 arguments")); + if (exp.args.length != 1) { + return reject(makeRuntimeRejectMsg(workerScript, "scan() call has incorrect number of arguments. Takes 1 argument")); } - var currServ = getServer(workerScript.serverIp); - if (currServ == null) { - return reject(makeRuntimeRejectMsg(workerScript, "Could not find server ip for this script. This is a bug please contact game developer")); - } - var res = []; - for (var i = 0; i < currServ.serversOnNetwork.length; ++i) { - var thisServ = getServer(currServ.serversOnNetwork[i]); - if (thisServ == null) {continue;} - res.push({type:"str", value: thisServ.hostname}); - } - resolve(res); + + var ipPromise = evaluate(exp.args[0], workerScript); + ipPromise.then(function(ip) { + var server = getServer(ip); + if (server == null) { + workerScript.scriptRef.log("scan() failed. Invalid IP or hostname passed in: " + ip); + return reject(makeRuntimeRejectMsg(workerScript, "Invalid IP or hostname passed into scan() command"));; + } + var res = []; + for (var i = 0; i < server.serversOnNetwork.length; ++i) { + var thisServ = getServer(server.serversOnNetwork[i]); + if (thisServ == null) {continue;} + res.push({type:"str", value: thisServ.hostname}); + } + resolve(res); + }, function(e) { + reject(e); + }); } else if (exp.func.value == "nuke") { var p = netscriptRunProgram(exp, workerScript, Programs.NukeProgram); p.then(function(res) { From c0fc4e381d13ccd73f25443a82b742d06a0a12be Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Thu, 29 Jun 2017 09:17:47 -0500 Subject: [PATCH 07/15] Updated documentation for new scan() command --- src/Constants.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/Constants.js b/src/Constants.js index 31e70c4f4..4279903d1 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -424,8 +424,8 @@ CONSTANTS = { "print(x)
Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command ).
" + "WARNING: Do NOT call print() on an array. The script will crash. You can, however, call print on single elements of an array. For example, if " + "the variable 'a' is an array, then do NOT call print(a), but it is okay to call print(a[0]).

" + - "scan()
Returns an array containing the hostnames of all servers that are one node away from the current server. The " + - "current server is the server on which the script that calls this function is running. The hostnames are strings.

" + + "scan(hostname/ip)
Returns an array containing the hostnames of all servers that are one node away from the specified server. " + + "The argument must be a string containing the IP or hostname of the target server. The hostnames in the returned array are strings.

" + "nuke(hostname/ip)
Run NUKE.exe on the target server. NUKE.exe must exist on your home computer. Does NOT work while offline
Example: nuke('foodnstuff');

" + "brutessh(hostname/ip)
Run BruteSSH.exe on the target server. BruteSSH.exe must exist on your home computer. Does NOT work while offline
Example: brutessh('foodnstuff');

" + "ftpcrack(hostname/ip)
Run FTPCrack.exe on the target server. FTPCrack.exe must exist on your home computer. Does NOT work while offline
Example: ftpcrack('foodnstuff');

" + From 6bfe6a549d8adfcd27da9d83c90f11e2cc1b10b7 Mon Sep 17 00:00:00 2001 From: MrNuggelz Date: Fri, 30 Jun 2017 18:44:03 +0200 Subject: [PATCH 08/15] made alias names posix compilant and added global aliases --- src/Alias.js | 50 +++++++++++++++++++++++++++++++++++++++++------ src/SaveObject.js | 26 ++++++++++++++++++++++++ src/Terminal.js | 21 +++++++++++--------- 3 files changed, 82 insertions(+), 15 deletions(-) diff --git a/src/Alias.js b/src/Alias.js index 071b50bef..da6be05b6 100644 --- a/src/Alias.js +++ b/src/Alias.js @@ -1,5 +1,6 @@ /* Alias.js */ Aliases = {}; +GlobalAliases = {}; //Print all aliases to terminal function printAliases() { @@ -8,21 +9,40 @@ function printAliases() { post("alias " + name + "=" + Aliases[name]); } } + for (var name in GlobalAliases) { + if (GlobalAliases.hasOwnProperty(name)) { + post("global alias " + name + "=" + GlobalAliases[name]); + } + } } //True if successful, false otherwise -function parseAliasDeclaration(dec) { - var re = /([^=]+)="(.+)"/; +function parseAliasDeclaration(dec,global=false) { + var re = /^([_|\w|!|%|,|@]+)="(.+)"$/; var matches = dec.match(re); if (matches == null || matches.length != 3) {return false;} - addAlias(matches[1], matches[2]); + if (global){ + addGlobalAlias(matches[1],matches[2]); + } else { + addAlias(matches[1], matches[2]); + } return true; } function addAlias(name, value) { + if (name in GlobalAliases){ + delete GlobalAliases[name]; + } Aliases[name] = value; } +function addGlobalAlias(name, value) { + if (name in Aliases){ + delete Aliases[name]; + } + GlobalAliases[name] = value; +} + function getAlias(name) { if (Aliases.hasOwnProperty(name)) { return Aliases[name]; @@ -30,6 +50,13 @@ function getAlias(name) { return null; } +function getGlobalAlias(name) { + if (GlobalAliases.hasOwnProperty(name)) { + return GlobalAliases[name]; + } + return null; +} + function removeAlias(name) { if (Aliases.hasOwnProperty(name)) { delete Aliases[name]; @@ -42,10 +69,21 @@ function removeAlias(name) { //Aliases only applied to "whole words", one level deep function substituteAliases(origCommand) { var commandArray = origCommand.split(" "); - for (var i = 0; i < commandArray.length; ++i) { - var alias = getAlias(commandArray[i]); + if (commandArray.length>0){ + var alias = getAlias(commandArray[0]); if (alias != null) { - commandArray[i] = alias; + commandArray[0] = alias; + } else { + var alias = getGlobalAlias(commandArray[0]); + if (alias != null) { + commandArray[0] = alias; + } + } + for (var i = 0; i < commandArray.length; ++i) { + var alias = getGlobalAlias(commandArray[i]); + if (alias != null) { + commandArray[i] = alias; + } } } return commandArray.join(" "); diff --git a/src/SaveObject.js b/src/SaveObject.js index 0e38841bb..4f81c1897 100644 --- a/src/SaveObject.js +++ b/src/SaveObject.js @@ -11,6 +11,7 @@ function BitburnerSaveObject() { this.SpecialServerIpsSave = ""; this.AugmentationsSave = ""; this.AliasesSave = ""; + this.GlobalAliasesSave = ""; this.MessagesSave = ""; this.VersionSave = ""; } @@ -37,6 +38,7 @@ BitburnerSaveObject.prototype.saveGame = function() { this.SpecialServerIpsSave = JSON.stringify(SpecialServerIps); this.AugmentationsSave = JSON.stringify(Augmentations); this.AliasesSave = JSON.stringify(Aliases); + this.GlobalAliasesSave = JSON.stringify(GlobalAliases); this.MessagesSave = JSON.stringify(Messages); this.VersionSave = JSON.stringify(CONSTANTS.Version); @@ -70,6 +72,15 @@ loadGame = function(saveObj) { } else { Aliases = {}; } + if (saveObj.hasOwnProperty("GlobalAliasesSave")) { + try { + GlobalAliases = JSON.parse(saveObj.GlobalAliasesSave, Reviver); + } catch(e) { + GlobalAliases = {}; + } + } else { + GlobalAliases = {}; + } if (saveObj.hasOwnProperty("MessagesSave")) { try { Messages = JSON.parse(saveObj.MessagesSave, Reviver); @@ -118,6 +129,7 @@ loadImportedGame = function(saveObj, saveString) { var tempSpecialServerIps = null; var tempAugmentations = null; var tempAliases = null; + var tempGlobalAliases = null; var tempMessages = null; try { saveString = decodeURIComponent(escape(atob(saveString))); @@ -139,6 +151,15 @@ loadImportedGame = function(saveObj, saveString) { } else { tempAliases = {}; } + if (tempSaveObj.hasOwnProperty("GlobalAliases")) { + try { + tempGlobalAliases = JSON.parse(tempSaveObj.AliasesSave, Reviver); + } catch(e) { + tempGlobalAliases = {}; + } + } else { + tempGlobalAliases = {}; + } if (tempSaveObj.hasOwnProperty("MessagesSave")) { try { tempMessages = JSON.parse(tempSaveObj.MessagesSave, Reviver); @@ -191,6 +212,10 @@ loadImportedGame = function(saveObj, saveString) { Aliases = tempAliases; } + if (tempGlobalAliases) { + GlobalAliases = tempGlobalAliases; + } + if (tempMessages) { Messages = tempMessages; } @@ -263,6 +288,7 @@ BitburnerSaveObject.prototype.exportGame = function() { this.SpecialServerIpsSave = JSON.stringify(SpecialServerIps); this.AugmentationsSave = JSON.stringify(Augmentations); this.AliasesSave = JSON.stringify(Aliases); + this.GlobalAliasesSave = JSON.stringify(GlobalAliasesSave); this.MessagesSave = JSON.stringify(Messages); this.VersionSave = JSON.stringify(CONSTANTS.Version); diff --git a/src/Terminal.js b/src/Terminal.js index 0e7a45c6d..f8fae4ae6 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -243,7 +243,7 @@ function determineAllPossibilitiesForTabCompletion(input, index=0) { return ["alias", "analyze", "cat", "check", "clear", "cls", "connect", "free", "hack", "help", "home", "hostname", "ifconfig", "kill", "killall", "ls", "mem", "nano", "ps", "rm", "run", "scan", "scan-analyze", - "scp", "sudov", "tail", "theme", "top"].concat(Object.keys(Aliases)); + "scp", "sudov", "tail", "theme", "top"].concat(Object.keys(Aliases)).concat(Object.keys(GlobalAliases)); } if (input.startsWith ("buy ")) { @@ -581,15 +581,18 @@ var Terminal = { case "alias": if (commandArray.length == 1) { printAliases(); - } else if (commandArray.length == 2) { - if (parseAliasDeclaration(commandArray[1])) { - - } else { - post('Incorrect usage of alias command. Usage: alias [aliasname="value"]'); return; - } - } else { - post('Incorrect usage of alias command. Usage: alias [aliasname="value"]'); return; + return; } + if (commandArray.length == 2 ) { + var args = commandArray[1].split(" "); + if (args.length == 1 && parseAliasDeclaration(args[0])){ + return; + } + if (args.length == 2 && args[0] == "-g" && parseAliasDeclaration(args[1],true)){ + return; + } + } + post('Incorrect usage of alias command. Usage: alias [aliasname="value"]'); break; case "analyze": if (commandArray.length != 1) { From 36e3a3b5d200972a75f3bb88911112703ac70f57 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Mon, 3 Jul 2017 14:42:11 -0500 Subject: [PATCH 09/15] StockMarket and Infiltration implementations --- css/menupages.css | 86 +++- css/popupboxes.css | 206 ++------- css/styles.css | 8 +- index.html | 116 ++++- src/Augmentations.js | 2 +- src/Company.js | 27 +- src/CompanyJobApplication.js | 2 +- src/Constants.js | 124 ++++-- src/Infiltration.js | 796 +++++++++++++++++++++++++++++++++++ src/InteractiveTutorial.js | 2 +- src/Location.js | 179 +++++++- src/NetscriptEvaluator.js | 24 +- src/Player.js | 31 +- src/Prestige.js | 6 + src/SaveObject.js | 25 ++ src/Server.js | 4 +- src/StockMarket.js | 546 ++++++++++++++++++++++++ src/engine.js | 68 ++- utils/InfiltrationBox.js | 90 ++++ 19 files changed, 2037 insertions(+), 305 deletions(-) create mode 100644 src/Infiltration.js create mode 100644 src/StockMarket.js create mode 100644 utils/InfiltrationBox.js diff --git a/css/menupages.css b/css/menupages.css index 34d6162a6..9ed069200 100644 --- a/css/menupages.css +++ b/css/menupages.css @@ -75,7 +75,7 @@ } #script-editor-filename { -background-color: #555; + background-color: #555; display: inline-block; float: center; resize: none; @@ -274,15 +274,9 @@ background-color: #555; padding: 10px; } - -#hacknet-nodes-container li{ - padding: 6px; - margin: 6px; - width: 70%; -} - #hacknet-nodes-text, -#hacknet-nodes-money { +#hacknet-nodes-money, +#hacknet-nodes-container li { width: 70%; margin: 10px; padding: 10px; @@ -344,10 +338,7 @@ background-color: #555; padding-top: 10px; } -#create-program-page-text { - width: 70%; -} - +#create-program-page-text, #create-program-list { width: 70%; } @@ -510,6 +501,12 @@ div.faction-clear { #location-container { position: fixed; padding: 6px; + overflow-x: hidden; +} + +#location-container a { + display:inline-block; + width: 30%; } #location-slums-description { @@ -535,3 +532,66 @@ div.faction-clear { position: fixed; padding: 6px; } +#infiltration-left-panel, +#infiltration-right-panel { + display:inline-block; + border: 1px solid white; + width: 35%; + height: 75%; + top: 10px; + overflow-y: auto; + overflow-x: auto; +} + +#infiltration-faction-select { + color:white; +} + +#infiltration-left-panel p, +#infiltration-right-panel p { + margin: 4px; +} + +#infiltration-buttons .a-link-button { + display:inline; + width: 25%; +} + +/* Stock market */ +#stock-market-container { + position: fixed; + padding: 6px; +} + +#stock-market-container p { + padding: 10px; + margin: 10px; + width: 70%; +} + +#stock-market-container a { + margin: 10px; +} + +.stock-market-qty-input { + border: 1px solid white; + color: var(--my-font-color); + padding: 4px; + margin: 4px; +} + +.stock-market-buy-sell-button { + color: #aaa; + font-size: 16px; + font-weight: bold; + padding: 2px; + margin: 6px; + border: 1px solid white; +} + +.stock-market-buy-sell-button:hover, +.stock-market-buy-sell-button:focus { + color: var(--my-font-color); + text-decoration: none; + cursor: pointer; +} \ No newline at end of file diff --git a/css/popupboxes.css b/css/popupboxes.css index 4c338addd..c204464a0 100644 --- a/css/popupboxes.css +++ b/css/popupboxes.css @@ -5,14 +5,38 @@ z-index: 1; /* Sit on top */ left: 0; top: 0; - width: 100%; /* Full width */ - height: 100%; /* Full height */ + width: 100%; + height: 100%; overflow: auto; /* Enable scroll if needed */ - /*background-color: black; /* Fallback color */ - /*background-color: rgba(0,0,0,0.4); /* Black w/ opacity */ background-color: rbga(var(--my-background-color), 0.4); } +.popup-box-content { + background-color: var(--my-background-color); + margin: 15% auto; + padding: 12px; + border: 5px solid var(--my-highlight-color); + width: 70%; + color: var(--my-font-color); +} + +.popup-box-button { + color: #aaa; + float: right; + font-size: 16px; + font-weight: bold; + padding: 2px; + margin: 6px; + border: 1px solid white; +} + +.popup-box-button:hover, +.popup-box-button:focus { + color: var(--my-font-color); + text-decoration: none; + cursor: pointer; +} + .dialog-box-container, #log-box-container { display: block; @@ -69,207 +93,45 @@ transition: opacity 400ms ease-in; } -#purchase-server-box-content { - background-color: var(--my-background-color); - margin: 15% auto; /* 15% from the top and centered */ - padding: 12px; - border: 5px solid var(--my-highlight-color);; - width: 80%; /* Could be more or less, depending on screen size */ - color: var(--my-font-color); -} - #purchase-server-box-input { color: white; } -#purchase-server-box-confirm, -#purchase-server-box-cancel { - color: #aaa; - float: right; - font-size: 16px; - font-weight: bold; - padding: 2px; - margin: 6px; - border: 1px solid white; -} - -#purchase-server-box-confirm:hover, -#purchase-server-box-confirm:focus { - color: var(--my-font-color); - text-decoration: none; - cursor: pointer; -} - -#purchase-server-box-cancel:hover, -#purchase-server-box-cancel:focus { - color: var(--my-font-color); - text-decoration: none; - cursor: pointer; -} - /* Purchase RAM for Home computer pop-up box */ #purchase-ram-for-home-box-container { transition: opacity 400ms ease-in; } -#purchase-ram-for-home-box-content { - background-color: var(--my-background-color); - margin: 15% auto; /* 15% from the top and centered */ - padding: 12px; - border: 5px solid var(--my-highlight-color); - width: 50%; /* Could be more or less, depending on screen size */ - color: var(--my-font-color); -} - -#purchase-ram-for-home-box-confirm, -#purchase-ram-for-home-box-cancel { - color: #aaa; - float: right; - font-size: 16px; - font-weight: bold; - padding: 2px; - margin: 6px; - border: 1px solid white; -} - -#purchase-ram-for-home-box-confirm:hover, -#purchase-ram-for-home-box-confirm:focus { - color: var(--my-font-color); - text-decoration: none; - cursor: pointer; -} - -#purchase-ram-for-home-box-cancel:hover, -#purchase-ram-for-home-box-cancel:focus { - color: var(--my-font-color); - text-decoration: none; - cursor: pointer; -} - /* Purchase Invitation Box */ #purchase-augmentation-box-container { transition: opacity 400ms ease-in; } -#purchase-augmentation-box-content { - background-color: var(--my-background-color); - margin: 15% auto; /* 15% from the top and centered */ - padding: 8px; - border: 5px solid var(--my-highlight-color);; - width: 80%; /* Could be more or less, depending on screen size */ - color: var(--my-font-color); -} - -#purchase-augmentation-box-confirm, -#purchase-augmentation-box-cancel { - color: #aaa; - float: right; - font-size: 16px; - font-weight: bold; - padding: 4px; - margin: 6px; - border: 1px solid white; -} - -#purchase-augmentation-box-confirm:hover, -#purchase-augmentation-box-confirm:focus { - color: var(--my-font-color); - text-decoration: none; - cursor: pointer; -} - -#purchase-augmentation-box-cancel:hover, -#purchase-augmentation-box-cancel:focus { - color: var(--my-font-color); - text-decoration: none; - cursor: pointer; -} - /* Faction invitation box */ #faction-invitation-box-container { transition: opacity 400ms ease-in; } - -#faction-invitation-box-content { - background-color: var(--my-background-color); - margin: 15% auto; /* 15% from the top and centered */ - padding: 10px; - border: 5px solid var(--my-highlight-color);; - width: 80%; /* Could be more or less, depending on screen size */ - color: var(--my-font-color); -} - #faction-invitation-box-warning { margin: 4px; padding: 4px; } -#faction-invitation-box-yes, -#faction-invitation-box-no { - color: #aaa; - font-size: 20px; - font-weight: bold; - padding: 2px; - margin: 6px; - border: 1px solid white; -} - -#faction-invitation-box-yes:hover, -#faction-invitation-box-yes:focus { - color: white; - text-decoration: none; - cursor: pointer; -} - -#faction-invitation-box-no:hover, -#faction-invitation-box-no:focus { - color: white; - text-decoration: none; - cursor: pointer; -} - - /* Travel Pop-up Box */ #travel-box-container { transition: opacity 400ms ease-in; } -#travel-box-content { - background-color: var(--my-background-color); - margin: 15% auto; /* 15% from the top and centered */ - padding: 10px; - border: 5px solid var(--my-highlight-color);; - width: 50%; /* Could be more or less, depending on screen size */ - color: var(--my-font-color); -} #travel-box-text { margin: 8px; } -#travel-box-confirm, -#travel-box-cancel { - color: #aaa; - float: right; - font-size: 16px; - font-weight: bold; - padding: 2px; - margin: 6px; - border: 1px solid white; -} - -#travel-box-confirm:hover, -#travel-box-confirm:focus { - color: white; - text-decoration: none; - cursor: pointer; -} - -#travel-box-cancel:hover, -#travel-box-cancel:focus { - color: white; - text-decoration: none; - cursor: pointer; +/* Infiltration-box */ +#infiltration-box-sell, +#infiltration-box-faction { + display: block; + padding: 8px; + margin: 8px; } /* Game Options */ diff --git a/css/styles.css b/css/styles.css index f3b8d08d2..47419edb1 100644 --- a/css/styles.css +++ b/css/styles.css @@ -32,7 +32,7 @@ h2 { } ul { - padding: 6px; + padding: 2px; list-style-type: none; } @@ -252,7 +252,7 @@ tr:focus { position: absolute; /* Stay in place */ right: 0; top: 0; - height: 185px; /* Full height */ + height: 195px; /* Full height */ /*margin: 50% auto;*/ padding: 5px; border: 2px solid var(--my-highlight-color); @@ -264,7 +264,7 @@ tr:focus { #character-overview-text { padding: 4px; - margin: 10px; + margin: 8px; color: white; background-color: #444; } @@ -272,7 +272,7 @@ tr:focus { #character-overview-save-button, #character-overview-options-button { color: #aaa; - font-size: 16px; + font-size: 14px; font-weight: bold; -webkit-border-radius: 12px; -moz-border-radius: 12px; diff --git a/index.html b/index.html index 92a07748d..c73b58f79 100644 --- a/index.html +++ b/index.html @@ -26,6 +26,7 @@ + @@ -61,6 +62,8 @@ + + @@ -115,7 +118,7 @@
  • - Augmentations + Augmentations
  • @@ -212,6 +215,9 @@
  • Travel Agency
  • +
  • + Hospital +
  • Summit University
  • @@ -260,6 +266,9 @@
  • Travel Agency
  • +
  • + Hospital +
  • KuaiGong International
  • @@ -275,6 +284,9 @@
  • Travel Agency
  • +
  • + Hospital +
  • Rothman University
  • @@ -329,6 +341,9 @@
  • Travel Agency
  • +
  • + Hospital +
  • DefComm
  • @@ -350,6 +365,9 @@
  • Travel Agency
  • +
  • + Hospital +
  • Storm Technologies
  • @@ -368,6 +386,9 @@
  • Travel Agency
  • +
  • + Hospital +
  • ZB Insitute of Technology
  • @@ -399,6 +420,12 @@ The Slums + +
    @@ -559,7 +586,8 @@ Scripts on every computer but your home computer
    Purchased servers
    Hacknet Nodes
    - Faction/Company reputation

    + Faction/Company reputation
    + Stocks

    Purchasing an Augmentation lets you start over with the perks and benefits granted by all of the Augmentations you have ever purchased. Also, you will keep any scripts and RAM upgrades on your home computer (but you will lose all programs besides NUKE.exe). @@ -583,7 +611,7 @@ Scripts Netscript Programming Language Traveling - Jobs + Companies and Infiltration Factions Augmentations @@ -649,6 +677,17 @@ Purchase TOR Router - $100,000 Purchase additional RAM for Home computer + + Infiltrate Company + + Infiltrate this company's facility to try and steal their classified secrets! + Warning: You may end up hospitalized if you are unsuccessful! + + + + + Get Treatment for Wounds +

    From here, you can travel to any other city! A ticket costs $200,000. @@ -699,6 +738,35 @@

    + +
    +

    + Welcome to the World Stock Exchange (WSE)!

    + + To begin trading, you must first purchase an account. WSE accounts will persist + after you 'reset' by installing Augmentations. +

    + Buy WSE Account +

    + You can also purchase access to the World Stock Exchange's TIX API! TIX, short for + Trade Information eXchange, is the communications protocol supported by the WSE. +

    + Gaining access to the TIX API lets you write code to build automated trading + systems. In other words, you can create your own algorithmic trading strategies! +

    + If you purchase access to the TIX API, you will retain that access even after + you 'reset' by installing Augmentations. +

    + + Buy Trade Information eXchange (TEX) API Access - COMING SOON + +

    + +
      +
    +
    + +
    @@ -710,55 +778,67 @@