Merge pull request #8 from danielyxie/dev

v0.5
This commit is contained in:
danielyxie 2017-05-14 21:47:54 -05:00 committed by GitHub
commit f7e42ca910
6 changed files with 61 additions and 20 deletions

@ -47,4 +47,24 @@ 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/
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"
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

@ -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
@ -138,7 +138,7 @@ CONSTANTS = {
"run [script/program] Execute a program or a script<br>" +
"scan See 'netstat' command<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)" +
"tail [script] Display script logs (logs contain details about active scripts)<br>" +
"telnet [ip/hostname] See 'connect' command<br>" +
"top Display all running scripts and their RAM usage<br>",
@ -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. <br>" +
"manually through terminal is faster than hacking from a script. <br><br>" +
"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. <br>" +
"hacking attempt is unsuccessful, you will still gain experience points. <br><br>" +
"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 " +
@ -232,11 +232,13 @@ CONSTANTS = {
"<u><h1> Functions </h1></u><br>" +
"You can NOT define you own functions in Netscript (yet), but there are several built in functions that " +
"you may use: <br><br> " +
"<i>hack(hostname/ip)</i><br>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. <br>Examples: hack('foodnstuff'); or hack('148.192.0.12');<br><br>" +
"<i>hack(hostname/ip)</i><br>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. <br>Examples: hack('foodnstuff'); or hack('148.192.0.12');<br><br>" +
"<i>sleep(n)</i><br>Suspends the script for n milliseconds. <br>Example: sleep(5000);<br><br>" +
"<i>grow(hostname/ip)</i><br>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. <br> Example: grow('foodnstuff');<br><br>" +
"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. <br> Example: grow('foodnstuff');<br><br>" +
"<i>print(x)</i> <br> Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command )<br><br>" +
"<i>nuke(hostname/ip)</i><br>Run NUKE.exe on the target server. NUKE.exe must exist on your home computer. <br> Example: nuke('foodnstuff'); <br><br>" +
"<i>brutessh(hostname/ip)</i><br>Run BruteSSH.exe on the target server. BruteSSH.exe must exist on your home computer <br> Example: brutessh('foodnstuff');<br><br>" +
@ -260,7 +262,8 @@ CONSTANTS = {
"as long as <i>[cond]</i> is met. The <i>[post]</i> 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: <br><br>" +
"<i>for (i = 0; i < 10; i = i+1) { <br>&nbsp;&nbsp;&nbsp;&nbsp;hack('foodnstuff');<br>}; </i><br><br><br>",
"<i>for (i = 0; i < 10; i = i+1) { <br>&nbsp;&nbsp;&nbsp;&nbsp;hack('foodnstuff');<br>}; </i><br><br>" +
"<u><h1> If statements </h1></u>",
TutorialTravelingText:"There are six major cities in the world that you are able to travel to: <br><br> " +
" Aevum<br>" +

@ -197,7 +197,7 @@ function iTutorialEvaluateStep() {
"}<br><br> " +
"For anyone with basic programming experience, this code should be straightforward. " +
"This script will continuously hack the 'foodnstuff' server. <br><br>" +
"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;

@ -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);

@ -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;

@ -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");