From 31ef48f4a86742efd2e4f306d989780ab30d36e5 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Sun, 14 May 2017 21:21:22 -0500 Subject: [PATCH 1/4] Small UI improvements based on private beta feedback --- README.md | 16 +++++++++++++++- src/Constants.js | 10 ++++++---- src/InteractiveTutorial.js | 5 +++-- src/Script.js | 8 -------- src/engine.js | 10 ++++++++++ 5 files changed, 34 insertions(+), 15 deletions(-) diff --git a/README.md b/README.md index e79ee7f2c..dcaffb0c2 100644 --- a/README.md +++ b/README.md @@ -47,4 +47,18 @@ Tasks TODO: Account for Max possible int when gaining exp (it will overflow) OPTIMIZATION - https://gamealchemist.wordpress.com/2013/05/01/lets-get-those-javascript-arrays-to-work-fast/ \ No newline at end of file + https://gamealchemist.wordpress.com/2013/05/01/lets-get-those-javascript-arrays-to-work-fast/ + + + +Private beta feedback + 2 things right off the bat, I'd suggest putting a "Back" button in the tutorial + window, and you could highlight or otherwise point out which tab the tutorial is + suggesting I click on next + Maybe have a different colour for each tab, and then in the tutorial window it + can have the name of the tab with that colour + + 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" \ No newline at end of file diff --git a/src/Constants.js b/src/Constants.js index 637ed2bc7..64e3f384c 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -138,7 +138,7 @@ CONSTANTS = { "run [script/program] Execute a program or a script
" + "scan See 'netstat' command
" + "sudov Shows whether or not you have root access on this computer
" + - "tail [script] Display script logs (logs contain details about active scripts)" + + "tail [script] Display script logs (logs contain details about active scripts)
" + "telnet [ip/hostname] See 'connect' command
" + "top Display all running scripts and their RAM usage
", @@ -179,10 +179,10 @@ CONSTANTS = { "a script, you attempt to hack the server. This action takes time. The more advanced a server's " + "security is, the more time it will take. Your hacking skill level also affects the hacking time, " + "with a higher hacking skill leading to shorter hacking times. Also, running the hack command " + - "manually through terminal is faster than hacking from a script.
" + + "manually through terminal is faster than hacking from a script.

" + "Your attempt to hack a server will not always succeed. The chance you have to successfully hack a " + "server is also determined by the server's security and your hacking skill level. Even if your " + - "hacking attempt is unsuccessful, you will still gain experience points.
" + + "hacking attempt is unsuccessful, you will still gain experience points.

" + "When you successfully hack a server. You steal a certain percentage of that server's total money. This " + "percentage is determined by the server's security and your hacking skill level. The amount of money " + "on a server is not limitless. So, if you constantly hack a server and deplete its money, then you will " + @@ -260,7 +260,9 @@ CONSTANTS = { "as long as [cond] is met. The [post] expression will evaluate at the end of every iteration " + "of the for loop. The following example shows code that will do the same thing as the while loop example above, " + "except using a for loop instead:

" + - "for (i = 0; i < 10; i = i+1) {
    hack('foodnstuff');
};



", + "for (i = 0; i < 10; i = i+1) {
    hack('foodnstuff');
};


" + + "

If statements

" + + "", TutorialTravelingText:"There are six major cities in the world that you are able to travel to:

" + " Aevum
" + diff --git a/src/InteractiveTutorial.js b/src/InteractiveTutorial.js index 60dbe8ee9..f79599b9e 100644 --- a/src/InteractiveTutorial.js +++ b/src/InteractiveTutorial.js @@ -197,7 +197,7 @@ function iTutorialEvaluateStep() { "}

" + "For anyone with basic programming experience, this code should be straightforward. " + "This script will continuously hack the 'foodnstuff' server.

" + - "To save and close the script editor, press the button in the top left, or press ctrl + b."); + "To save and close the script editor, press the button in the top right, or press ctrl + b."); //next step triggered in saveAndCloseScriptEditor() (Script.js) break; case iTutorialSteps.TerminalFree: @@ -208,7 +208,7 @@ function iTutorialEvaluateStep() { //next step triggered by terminal commmand break; case iTutorialSteps.TerminalRunScript: - iTutorialSetText("We have 2GB of free RAM on this machine, which is enough to run our " + + iTutorialSetText("We have 4GB of free RAM on this machine, which is enough to run our " + "script. Let's run our script using 'run foodnstuff.script'."); //next step triggered by terminal commmand break; @@ -318,6 +318,7 @@ function iTutorialEvaluateStep() { "Hope you enjoy the game!"); var next = clearEventListeners("interactive-tutorial-next"); next.style.display = "inline-block"; + next.innerHTML = "Finish Tutorial"; next.addEventListener("click", function() { iTutorialNextStep(); return false; diff --git a/src/Script.js b/src/Script.js index ec0b28b35..d9429618a 100644 --- a/src/Script.js +++ b/src/Script.js @@ -10,14 +10,6 @@ function scriptEditorSaveCloseInit() { saveAndCloseScriptEditor(); return false; }); - - var netscriptDocButton = document.getElementById("script-editor-netscript-doc-button"); - netscriptDocButton.addEventListener("click", function() { - Engine.loadTutorialContent(); - Engine.displayTutorialContent(); - Engine.displayTutorialPage(CONSTANTS.TutorialNetscriptText); - return false; - }); }; document.addEventListener("DOMContentLoaded", scriptEditorSaveCloseInit, false); diff --git a/src/engine.js b/src/engine.js index f88d21cab..57d580bce 100644 --- a/src/engine.js +++ b/src/engine.js @@ -941,6 +941,16 @@ var Engine = { return false; }); + + //Script Editor Netscript documentation button + var netscriptDocButton = document.getElementById("script-editor-netscript-doc-button"); + netscriptDocButton.addEventListener("click", function() { + Engine.loadTutorialContent(); + Engine.displayTutorialContent(); + Engine.displayTutorialPage(CONSTANTS.TutorialNetscriptText); + return false; + }); + //Create Program buttons var portHackALink = document.getElementById("create-program-nuke"); var bruteSshALink = document.getElementById("create-program-brutessh"); From 6bbf28411fdfe40756ec25517eeeae8dd327acf6 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Sun, 14 May 2017 21:36:58 -0500 Subject: [PATCH 2/4] Added slightly more information to Tutorial docuemntation --- README.md | 4 +++- src/Constants.js | 11 ++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index dcaffb0c2..82786b04d 100644 --- a/README.md +++ b/README.md @@ -61,4 +61,6 @@ 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" \ No newline at end of file + For the last thing of the tutorial, I would just have a button like "Finish Tutorial" rather than "Next" + + Command to see a script's RAM cost \ No newline at end of file diff --git a/src/Constants.js b/src/Constants.js index 64e3f384c..95f103afc 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -232,11 +232,13 @@ CONSTANTS = { "

Functions


" + "You can NOT define you own functions in Netscript (yet), but there are several built in functions that " + "you may use:

" + - "hack(hostname/ip)
Core function that is used to hack servers to steal money and gain hacking experience. The argument passed in must be a string with " + - "either the IP or hostname of the server you want to hack.
Examples: hack('foodnstuff'); or hack('148.192.0.12');

" + + "hack(hostname/ip)
Core function that is used to try and hack servers to steal money and gain hacking experience. The argument passed in must be a string with " + + "either the IP or hostname of the server you want to hack. Attempting to hack a server takes time. This time is dependent on your hacking skill and the server's " + + "security level.
Examples: hack('foodnstuff'); or hack('148.192.0.12');

" + "sleep(n)
Suspends the script for n milliseconds.
Example: sleep(5000);

" + "grow(hostname/ip)
Use your hacking skills to increase the amount of money available on a server. The argument passed in " + - "must be a string with either the IP or hostname of the target server.
Example: grow('foodnstuff');

" + + "must be a string with either the IP or hostname of the target server. The grow() command takes a flat 2 minutes to execute " + + "and grants 1 hacking exp when complete.
Example: grow('foodnstuff');

" + "print(x)
Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command )

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

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

" + @@ -261,8 +263,7 @@ CONSTANTS = { "of the for loop. The following example shows code that will do the same thing as the while loop example above, " + "except using a for loop instead:

" + "for (i = 0; i < 10; i = i+1) {
    hack('foodnstuff');
};


" + - "

If statements

" + - "", + "

If statements

", TutorialTravelingText:"There are six major cities in the world that you are able to travel to:

" + " Aevum
" + From 0019494ad23ef70d1d0c5623b791cf8f46037575 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Sun, 14 May 2017 21:46:52 -0500 Subject: [PATCH 3/4] Added mem command --- README.md | 6 +++++- src/Terminal.js | 17 ++++++++++++++++- 2 files changed, 21 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 82786b04d..da382d30e 100644 --- a/README.md +++ b/README.md @@ -63,4 +63,8 @@ Private beta feedback For the last thing of the tutorial, I would just have a button like "Finish Tutorial" rather than "Next" - Command to see a script's RAM cost \ No newline at end of file + Command to see a script's RAM cost + + Netscript commands: + I just got two from the top of my head: a function to get the current cash on the server, and a function to know how much a hack would take + Like, if I want to grow each time I take 5000$ from the server, that would be practical \ No newline at end of file diff --git a/src/Terminal.js b/src/Terminal.js index 86110badd..656d40fb6 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -205,7 +205,8 @@ function determineAllPossibilitiesForTabCompletion(input) { } if (input.startsWith("kill ") || input.startsWith("nano ") || - input.startsWith("tail ") || input.startsWith("rm ")) { + input.startsWith("tail ") || input.startsWith("rm ") || + input.startsWith("mem ")) { //All Scripts for (var i = 0; i < currServ.scripts.length; ++i) { allPos.push(currServ.scripts[i].filename); @@ -598,6 +599,20 @@ var Terminal = { case "ls": Terminal.executeListCommand(commandArray); break; + case "mem": + if (commandArray.length != 2) { + post("Incorrect usage of mem command. usage: mem [scriptname]"); return; + } + var scriptName = commandArray[1]; + var currServ = Player.getCurrentServer(); + for (var i = 0; i < currServ.scripts.length; ++i) { + if (scriptName == currServ.scripts[i].filename) { + post("This script requires " + formatNumber(currServ.scripts[i].ramUsage, 2) + "GB of RAM to run"); + return; + } + } + post("ERR: No such script exists!"); + break; case "nano": if (commandArray.length != 2) { post("Incorrect usage of nano command. Usage: nano [scriptname]"); return; From 85225ae3ba6395afb09c2f552d5aab26bafdd045 Mon Sep 17 00:00:00 2001 From: Daniel Xie Date: Sun, 14 May 2017 21:47:09 -0500 Subject: [PATCH 4/4] Updated to v0.5 --- src/Constants.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Constants.js b/src/Constants.js index 95f103afc..3f3ccb2c9 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -1,5 +1,5 @@ CONSTANTS = { - Version: "0.4", + Version: "0.5", //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