Merge pull request #441 from danielyxie/improve-interactive-tutorial

Updated Interactive Tutorial and added a few helpful links to the hac…
This commit is contained in:
danielyxie 2018-08-29 14:11:13 -05:00 committed by GitHub
commit aa18420e0c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 292 additions and 409 deletions

@ -11,11 +11,11 @@
position: absolute; /* Stay in place */ position: absolute; /* Stay in place */
right: 0; right: 0;
top: 0; top: 0;
height: 400px; /* Full height */ height: 450px;
padding: 10px; padding: 10px;
border: 5px solid #fff; border: 5px solid #fff;
width: 20%; width: 23%;
overflow: auto; /* Enable scroll if needed */ overflow:hidden;
background-color: #444; /* Fallback color */ background-color: #444; /* Fallback color */
color: #fff; color: #fff;
@ -29,6 +29,9 @@
margin: 4px; margin: 4px;
color: #fff; color: #fff;
background-color: #444; background-color: #444;
font-size: $defaultFontSize * 0.875;
max-height: 350px;
overflow-y: auto;
} }
#interactive-tutorial-exit, #interactive-tutorial-exit,
@ -38,7 +41,7 @@
@include boxShadow(1px 1px 3px #000); @include boxShadow(1px 1px 3px #000);
color: #aaa; color: #aaa;
font-size: $defaultFontSize * 1.25; font-size: $defaultFontSize * 1.125;
font-weight: bold; font-weight: bold;
background-color: #000; background-color: #000;
@ -50,6 +53,7 @@
} }
} }
/*
#interactive-tutorial-exit { #interactive-tutorial-exit {
float: left; float: left;
} }
@ -58,6 +62,16 @@
margin-right: 20%; margin-right: 20%;
float: right; float: right;
} }
*/
#interactive-tutorial-exit {
position:absolute;
bottom: 0;
left:0;
}
#interactive-tutorial-back {
float: left;
}
#interactive-tutorial-next { #interactive-tutorial-next {
float: right; float: right;

@ -2,7 +2,7 @@ import {BitNodeMultipliers} from "./BitNodeMultipliers";
import {CONSTANTS} from "./Constants"; import {CONSTANTS} from "./Constants";
import {Engine} from "./engine"; import {Engine} from "./engine";
import {iTutorialSteps, iTutorialNextStep, import {iTutorialSteps, iTutorialNextStep,
iTutorialIsRunning, currITutorialStep} from "./InteractiveTutorial"; ITutorial} from "./InteractiveTutorial";
import {Player} from "./Player"; import {Player} from "./Player";
import {dialogBoxCreate} from "../utils/DialogBox"; import {dialogBoxCreate} from "../utils/DialogBox";
import {clearEventListeners} from "../utils/uiHelpers/clearEventListeners"; import {clearEventListeners} from "../utils/uiHelpers/clearEventListeners";
@ -245,8 +245,8 @@ Reviver.constructors.HacknetNode = HacknetNode;
function purchaseHacknet() { function purchaseHacknet() {
/* INTERACTIVE TUTORIAL */ /* INTERACTIVE TUTORIAL */
if (iTutorialIsRunning) { if (ITutorial.isRunning) {
if (currITutorialStep == iTutorialSteps.HacknetNodesIntroduction) { if (ITutorial.currStep === iTutorialSteps.HacknetNodesIntroduction) {
iTutorialNextStep(); iTutorialNextStep();
} else { } else {
return; return;

@ -1,55 +1,77 @@
import {Engine} from "./engine"; import {Engine} from "./engine";
import {Player} from "./Player"; import {Player} from "./Player";
import {dialogBoxCreate} from "../utils/DialogBox"; import {Settings} from "./Settings";
import {Terminal} from "./Terminal";
import {clearEventListeners} from "../utils/uiHelpers/clearEventListeners"; import {clearEventListeners} from "../utils/uiHelpers/clearEventListeners";
import {createElement} from "../utils/uiHelpers/createElement";
import {createPopup} from "../utils/uiHelpers/createPopup";
import {removeElementById} from "../utils/uiHelpers/removeElementById";
/* InteractiveTutorial.js */ //Ordered array of keys to Interactive Tutorial Steps
let iTutorialSteps = { const orderedITutorialSteps = [
Start: "Start", "Start",
GoToCharacterPage: "Click on the Character page menu link", "GoToCharacterPage", //Click on 'Stats' page
CharacterPage: "Introduction to Character page", "CharacterPage", //Introduction to 'Stats' page
CharacterGoToTerminalPage: "Click on the Terminal link", "CharacterGoToTerminalPage", //Go back to Terminal
TerminalIntro: "Introduction to terminal interface", "TerminalIntro", //Introduction to Terminal
TerminalHelp: "Using the help command to display all options in terminal", "TerminalHelp", //Using 'help' Terminal command
TerminalLs: "Use the ls command to show all programs/scripts. Right now we have NUKE.exe", "TerminalLs", //Using 'ls' Terminal command
TerminalScan: "Using the scan command to display all available connections", "TerminalScan", //Using 'scan' Terminal command
TerminalScanAnalyze1: "Use the scan-analyze command to show hacking related information", "TerminalScanAnalyze1", //Using 'scan-analyze' Terminal command
TerminalScanAnalyze2: "Use the scan-analyze command with a depth of 3", "TerminalScanAnalyze2", //Using 'scan-analyze 3' Terminal command
TerminalConnect: "Using the telnet/connect command to connect to another server", "TerminalConnect", //Connecting to foodnstuff
TerminalAnalyze: "Use the analyze command to display details about this server", "TerminalAnalyze", //Analyzing foodnstuff
TerminalNuke: "Use the NUKE Program to gain root access to a server", "TerminalNuke", //NUKE foodnstuff
TerminalManualHack: "Use the hack command to manually hack a server", "TerminalManualHack", //Hack foodnstuff
TerminalHackingMechanics: "Briefly explain hacking mechanics", "TerminalHackingMechanics", //Explanation of hacking mechanics
TerminalCreateScript: "Create a script using nano", "TerminalCreateScript", //Create a script using 'nano'
TerminalTypeScript: "This occurs in the Script Editor page...type the script then save and close", "TerminalTypeScript", //Script Editor page - Type script and then save & close
TerminalFree: "Use the free command to check RAM", "TerminalFree", //Using 'Free' Terminal command
TerminalRunScript: "Use the run command to run a script", "TerminalRunScript", //Running script using 'run' Terminal command
TerminalGoToActiveScriptsPage: "Go to the ActiveScriptsPage", "TerminalGoToActiveScriptsPage",
ActiveScriptsPage: "Introduction to the Active Scripts Page", "ActiveScriptsPage",
ActiveScriptsToTerminal: "Go from Active Scripts Page Back to Terminal", "ActiveScriptsToTerminal",
TerminalTailScript: "Use the tail command to show a script's logs", "TerminalTailScript",
GoToHacknetNodesPage: "Go to the Hacknet Nodes page", "GoToHacknetNodesPage",
HacknetNodesIntroduction: "Introduction to Hacknet Nodesm and have user purchase one", "HacknetNodesIntroduction",
HacknetNodesGoToWorldPage: "Go to the world page", "HacknetNodesGoToWorldPage",
WorldDescription: "Tell the user to explore..theres a lot of different stuff to do out there", "WorldDescription",
TutorialPageInfo: "The tutorial page contains a lot of info on different subjects", "TutorialPageInfo",
End: "End", "End"
]
//Create an 'enum' for the Steps
const iTutorialSteps = {};
for (let i = 0; i < orderedITutorialSteps.length; ++i) {
iTutorialSteps[orderedITutorialSteps[i]] = i;
} }
var currITutorialStep = iTutorialSteps.Start; var ITutorial = {
var iTutorialIsRunning = false; currStep: 0, //iTutorialSteps.Start
isRunning: false,
//Keeps track of whether each step has been done
stepIsDone: {},
}
function iTutorialStart() { function iTutorialStart() {
//Initialize Interactive Tutorial state by settings 'done' for each state to false
ITutorial.stepIsDone = {};
for (let i = 0; i < orderedITutorialSteps.length; ++i) {
ITutorial.stepIsDone[i] = false;
}
Engine.loadTerminalContent();
Terminal.resetTerminalInput();
//Don't autosave during this interactive tutorial //Don't autosave during this interactive tutorial
Engine.Counters.autoSaveCounter = 999000000000; Engine.Counters.autoSaveCounter = Infinity;
console.log("Interactive Tutorial started"); console.log("Interactive Tutorial started");
currITutorialStep = iTutorialSteps.Start; ITutorial.currStep = 0;
iTutorialIsRunning = true; ITutorial.isRunning = true;
document.getElementById("interactive-tutorial-container").style.display = "block"; document.getElementById("interactive-tutorial-container").style.display = "block";
iTutorialEvaluateStep();
//Exit tutorial button //Exit tutorial button
var exitButton = clearEventListeners("interactive-tutorial-exit"); var exitButton = clearEventListeners("interactive-tutorial-exit");
exitButton.addEventListener("click", function() { exitButton.addEventListener("click", function() {
@ -59,142 +81,150 @@ function iTutorialStart() {
//Back button //Back button
var backButton = clearEventListeners("interactive-tutorial-back"); var backButton = clearEventListeners("interactive-tutorial-back");
backButton.style.display = "none";
backButton.addEventListener("click", function() { backButton.addEventListener("click", function() {
iTutorialPrevStep(); iTutorialPrevStep();
return false; return false;
}); });
//Next button
var nextButton = clearEventListeners("interactive-tutorial-next");
nextButton.addEventListener("click", function() {
iTutorialNextStep();
return false;
});
iTutorialEvaluateStep();
} }
function iTutorialEvaluateStep() { function iTutorialEvaluateStep() {
if (!iTutorialIsRunning) {console.log("Interactive Tutorial not running"); return;} if (!ITutorial.isRunning) {console.log("Interactive Tutorial not running"); return;}
switch(currITutorialStep) {
//Disable and clear main menu
var terminalMainMenu = clearEventListeners("terminal-menu-link");
var statsMainMenu = clearEventListeners("stats-menu-link");
var activeScriptsMainMenu = clearEventListeners("active-scripts-menu-link");
var hacknetMainMenu = clearEventListeners("hacknet-nodes-menu-link");
var cityMainMenu = clearEventListeners("city-menu-link");
var tutorialMainMenu = clearEventListeners("tutorial-menu-link");
terminalMainMenu.removeAttribute("class");
statsMainMenu.removeAttribute("class");
activeScriptsMainMenu.removeAttribute("class");
hacknetMainMenu.removeAttribute("class");
cityMainMenu.removeAttribute("class");
tutorialMainMenu.removeAttribute("class");
//Interactive Tutorial Next button
var nextBtn = document.getElementById("interactive-tutorial-next");
switch(ITutorial.currStep) {
case iTutorialSteps.Start: case iTutorialSteps.Start:
Engine.loadTerminalContent(); Engine.loadTerminalContent();
iTutorialSetText("Welcome to Bitburner, a cyberpunk-themed incremental RPG! " + iTutorialSetText("Welcome to Bitburner, a cyberpunk-themed incremental RPG! " +
"The game takes place in a dark, dystopian future...The year is 2077...<br><br>" + "The game takes place in a dark, dystopian future...The year is 2077...<br><br>" +
"This tutorial will show you the basics of the game. " + "This tutorial will show you the basics of the game. " +
"You may skip the tutorial at any time."); "You may skip the tutorial at any time.");
var next = clearEventListeners("interactive-tutorial-next"); nextBtn.style.display = "inline-block";
next.style.display = "inline-block";
next.addEventListener("click", function() {
iTutorialNextStep();
return false;
});
break; break;
case iTutorialSteps.GoToCharacterPage: case iTutorialSteps.GoToCharacterPage:
Engine.loadTerminalContent();
iTutorialSetText("Let's start by heading to the Stats page. Click the 'Stats' tab on " + iTutorialSetText("Let's start by heading to the Stats page. Click the 'Stats' tab on " +
"the main navigation menu (left-hand side of the screen)"); "the main navigation menu (left-hand side of the screen)");
nextBtn.style.display = "none";
//No next button //Flash 'Stats' menu and set its tutorial click handler
var next = clearEventListeners("interactive-tutorial-next"); statsMainMenu.setAttribute("class", "flashing-button");
next.style.display = "none"; statsMainMenu.addEventListener("click", function() {
//Flash Character tab
document.getElementById("stats-menu-link").setAttribute("class", "flashing-button");
//Initialize everything necessary to open the "Character" page
var charaterMainMenuButton = document.getElementById("stats-menu-link");
charaterMainMenuButton.addEventListener("click", function() {
Engine.loadCharacterContent(); Engine.loadCharacterContent();
iTutorialNextStep(); //Opening the character page will go to the next step iTutorialNextStep(); //Opening the character page will go to the next step
clearEventListeners("stats-menu-link");
return false; return false;
}); });
break; break;
case iTutorialSteps.CharacterPage: case iTutorialSteps.CharacterPage:
Engine.loadCharacterContent();
iTutorialSetText("The Stats page shows a lot of important information about your progress, " + iTutorialSetText("The Stats page shows a lot of important information about your progress, " +
"such as your skills, money, and bonuses/multipliers. ") "such as your skills, money, and bonuses/multipliers. ")
var next = clearEventListeners("interactive-tutorial-next"); nextBtn.style.display = "inline-block";
next.style.display = "inline-block";
next.addEventListener("click", function() {
iTutorialNextStep();
return false;
});
break; break;
case iTutorialSteps.CharacterGoToTerminalPage: case iTutorialSteps.CharacterGoToTerminalPage:
Engine.loadCharacterContent();
iTutorialSetText("Let's head to your computer's terminal by clicking the 'Terminal' tab on the " + iTutorialSetText("Let's head to your computer's terminal by clicking the 'Terminal' tab on the " +
"main navigation menu."); "main navigation menu.");
//No next button nextBtn.style.display = "none";
var next = clearEventListeners("interactive-tutorial-next");
next.style.display = "none";
document.getElementById("terminal-menu-link").setAttribute("class", "flashing-button"); //Flash 'Terminal' menu and set its tutorial click handler
terminalMainMenu.setAttribute("class", "flashing-button");
//Initialize everything necessary to open the 'Terminal' Page terminalMainMenu.addEventListener("click", function() {
var terminalMainMenuButton = document.getElementById("terminal-menu-link");
terminalMainMenuButton.addEventListener("click", function() {
Engine.loadTerminalContent(); Engine.loadTerminalContent();
iTutorialNextStep(); iTutorialNextStep();
clearEventListeners("terminal-menu-link");
return false; return false;
}); });
break; break;
case iTutorialSteps.TerminalIntro: case iTutorialSteps.TerminalIntro:
Engine.loadTerminalContent();
iTutorialSetText("The Terminal is used to interface with your home computer as well as " + iTutorialSetText("The Terminal is used to interface with your home computer as well as " +
"all of the other machines around the world."); "all of the other machines around the world.");
var next = clearEventListeners("interactive-tutorial-next"); nextBtn.style.display = "inline-block";
next.style.display = "inline-block";
next.addEventListener("click", function() {
iTutorialNextStep();
return false;
});
break; break;
case iTutorialSteps.TerminalHelp: case iTutorialSteps.TerminalHelp:
Engine.loadTerminalContent();
iTutorialSetText("Let's try it out. Start by entering the 'help' command into the Terminal " + iTutorialSetText("Let's try it out. Start by entering the 'help' command into the Terminal " +
"(Don't forget to press Enter after typing the command)"); "(Don't forget to press Enter after typing the command)");
var next = clearEventListeners("interactive-tutorial-next"); nextBtn.style.display = "none"; //next step triggered by terminal command
next.style.display = "none";
//next step triggered by terminal command
break; break;
case iTutorialSteps.TerminalLs: case iTutorialSteps.TerminalLs:
Engine.loadTerminalContent();
iTutorialSetText("The 'help' command displays a list of all available Terminal commands, how to use them, " + iTutorialSetText("The 'help' command displays a list of all available Terminal commands, how to use them, " +
"and a description of what they do. <br><br>Let's try another command. Enter the 'ls' command"); "and a description of what they do. <br><br>Let's try another command. Enter the 'ls' command");
//next step triggered by terminal command nextBtn.style.display = "none"; //next step triggered by terminal command
break; break;
case iTutorialSteps.TerminalScan: case iTutorialSteps.TerminalScan:
Engine.loadTerminalContent();
iTutorialSetText("'ls' is a basic command that shows all of the contents (programs/scripts) " + iTutorialSetText("'ls' is a basic command that shows all of the contents (programs/scripts) " +
"on the computer. Right now, it shows that you have a program called 'NUKE.exe' on your computer. " + "on the computer. Right now, it shows that you have a program called 'NUKE.exe' on your computer. " +
"We'll get to what this does later. <br><br>Using your home computer's terminal, you can connect " + "We'll get to what this does later. <br><br>Using your home computer's terminal, you can connect " +
"to other machines throughout the world. Let's do that now by first entering " + "to other machines throughout the world. Let's do that now by first entering " +
"the 'scan' command. "); "the 'scan' command.");
//next step triggered by terminal command nextBtn.style.display = "none"; //next step triggered by terminal command
break; break;
case iTutorialSteps.TerminalScanAnalyze1: case iTutorialSteps.TerminalScanAnalyze1:
Engine.loadTerminalContent();
iTutorialSetText("The 'scan' command shows all available network connections. In other words, " + iTutorialSetText("The 'scan' command shows all available network connections. In other words, " +
"it displays a list of all servers that can be connected to from your " + "it displays a list of all servers that can be connected to from your " +
"current machine. A server is identified by either its IP or its hostname. <br><br> " + "current machine. A server is identified by either its IP or its hostname. <br><br> " +
"That's great and all, but there's so many servers. Which one should you go to? " + "That's great and all, but there's so many servers. Which one should you go to? " +
"The 'scan-analyze' command gives some more detailed information about servers on the " + "The 'scan-analyze' command gives some more detailed information about servers on the " +
"network. Try it now"); "network. Try it now");
//next step triggered by terminal command nextBtn.style.display = "none"; //next step triggered by terminal command
break; break;
case iTutorialSteps.TerminalScanAnalyze2: case iTutorialSteps.TerminalScanAnalyze2:
Engine.loadTerminalContent();
iTutorialSetText("You just ran 'scan-analyze' with a depth of one. This command shows more detailed " + iTutorialSetText("You just ran 'scan-analyze' with a depth of one. This command shows more detailed " +
"information about each server that you can connect to (servers that are a distance of " + "information about each server that you can connect to (servers that are a distance of " +
"one node away). <br><br> It is also possible to run 'scan-analyze' with " + "one node away). <br><br> It is also possible to run 'scan-analyze' with " +
"a higher depth. Let's try a depth of two with the following command: 'scan-analyze 2'.") "a higher depth. Let's try a depth of two with the following command: 'scan-analyze 2'.")
//next step triggered by terminal command nextBtn.style.display = "none"; //next step triggered by terminal command
break; break;
case iTutorialSteps.TerminalConnect: case iTutorialSteps.TerminalConnect:
Engine.loadTerminalContent();
iTutorialSetText("Now you can see information about all servers that are up to two nodes away, as well " + iTutorialSetText("Now you can see information about all servers that are up to two nodes away, as well " +
"as figure out how to navigate to those servers through the network. You can only connect to " + "as figure out how to navigate to those servers through the network. You can only connect to " +
"a server that is one node away. To connect to a machine, use the 'connect [ip/hostname]' command. You can type in " + "a server that is one node away. To connect to a machine, use the 'connect [ip/hostname]' command. You can type in " +
"the ip or the hostname, but dont use both.<br><br>" + "the ip or the hostname, but dont use both.<br><br>" +
"From the results of the 'scan-analyze' command, we can see that the 'foodnstuff' server is " + "From the results of the 'scan-analyze' command, we can see that the 'foodnstuff' server is " +
"only one node away. Let's connect so it now using: 'connect foodnstuff'"); "only one node away. Let's connect so it now using: 'connect foodnstuff'");
//next step triggered by terminal command nextBtn.style.display = "none"; //next step triggered by terminal command
break; break;
case iTutorialSteps.TerminalAnalyze: case iTutorialSteps.TerminalAnalyze:
Engine.loadTerminalContent();
iTutorialSetText("You are now connected to another machine! What can you do now? You can hack it!<br><br> In the year 2077, currency has " + iTutorialSetText("You are now connected to another machine! What can you do now? You can hack it!<br><br> In the year 2077, currency has " +
"become digital and decentralized. People and corporations store their money " + "become digital and decentralized. People and corporations store their money " +
"on servers and computers. Using your hacking abilities, you can hack servers " + "on servers and computers. Using your hacking abilities, you can hack servers " +
"to steal money and gain experience. <br><br> " + "to steal money and gain experience. <br><br> " +
"Before you try to hack a server, you should run diagnostics using the 'analyze' command"); "Before you try to hack a server, you should run diagnostics using the 'analyze' command");
//next step triggered by terminal command nextBtn.style.display = "none"; //next step triggered by terminal command
break; break;
case iTutorialSteps.TerminalNuke: case iTutorialSteps.TerminalNuke:
Engine.loadTerminalContent();
iTutorialSetText("When the 'analyze' command finishes running it will show useful information " + iTutorialSetText("When the 'analyze' command finishes running it will show useful information " +
"about hacking the server. <br><br> For this server, the required hacking skill is only 1, " + "about hacking the server. <br><br> For this server, the required hacking skill is only 1, " +
"which means you can hack it right now. However, in order to hack a server " + "which means you can hack it right now. However, in order to hack a server " +
@ -203,14 +233,16 @@ function iTutorialEvaluateStep() {
"open ports.<br><br> The 'analyze' results shows that there do not need to be any open ports " + "open ports.<br><br> The 'analyze' results shows that there do not need to be any open ports " +
"on this machine for the NUKE virus to work, so go ahead and run the virus using the " + "on this machine for the NUKE virus to work, so go ahead and run the virus using the " +
"'run NUKE.exe' command."); "'run NUKE.exe' command.");
//next step triggered by terminal command nextBtn.style.display = "none"; //next step triggered by terminal command
break; break;
case iTutorialSteps.TerminalManualHack: case iTutorialSteps.TerminalManualHack:
Engine.loadTerminalContent();
iTutorialSetText("You now have root access! You can hack the server using the 'hack' command. " + iTutorialSetText("You now have root access! You can hack the server using the 'hack' command. " +
"Try doing that now."); "Try doing that now.");
//next step triggered by terminal command nextBtn.style.display = "none"; //next step triggered by terminal command
break; break;
case iTutorialSteps.TerminalHackingMechanics: case iTutorialSteps.TerminalHackingMechanics:
Engine.loadTerminalContent();
iTutorialSetText("You are now attempting to hack the server. Note that performing a hack takes time and " + iTutorialSetText("You are now attempting to hack the server. Note that performing a hack takes time and " +
"only has a certain percentage chance " + "only has a certain percentage chance " +
"of success. This time and success chance is determined by a variety of factors, including " + "of success. This time and success chance is determined by a variety of factors, including " +
@ -220,25 +252,20 @@ function iTutorialEvaluateStep() {
"the server's security level.<br><br>The amount of money on a server is not limitless. So, if " + "the server's security level.<br><br>The amount of money on a server is not limitless. So, if " +
"you constantly hack a server and deplete its money, then you will encounter " + "you constantly hack a server and deplete its money, then you will encounter " +
"diminishing returns in your hacking."); "diminishing returns in your hacking.");
var next = clearEventListeners("interactive-tutorial-next"); nextBtn.style.display = "inline-block";
next.style.display = "inline-block";
next.addEventListener("click", function() {
iTutorialNextStep();
return false;
});
break; break;
case iTutorialSteps.TerminalCreateScript: case iTutorialSteps.TerminalCreateScript:
Engine.loadTerminalContent();
iTutorialSetText("Hacking is the core mechanic of the game and is necessary for progressing. However, " + iTutorialSetText("Hacking is the core mechanic of the game and is necessary for progressing. However, " +
"you don't want to be hacking manually the entire time. You can automate your hacking " + "you don't want to be hacking manually the entire time. You can automate your hacking " +
"by writing scripts!<br><br>To create a new script or edit an existing one, you can use the 'nano' " + "by writing scripts!<br><br>To create a new script or edit an existing one, you can use the 'nano' " +
"command. Scripts must end with the '.script' extension. Let's make a script now by " + "command. Scripts must end with the '.script' extension. Let's make a script now by " +
"entering 'nano foodnstuff.script' after the hack command finishes running (Sidenote: Pressing ctrl + c" + "entering 'nano foodnstuff.script' after the hack command finishes running (Sidenote: Pressing ctrl + c" +
" will end a command like hack early)"); " will end a command like hack early)");
var next = clearEventListeners("interactive-tutorial-next"); nextBtn.style.display = "none"; //next step triggered by terminal command
next.style.display = "none";
//next step triggered by terminal command
break; break;
case iTutorialSteps.TerminalTypeScript: case iTutorialSteps.TerminalTypeScript:
Engine.loadScriptEditorContent("foodnstuff.script", "");
iTutorialSetText("This is the script editor. You can use it to program your scripts. Scripts are " + iTutorialSetText("This is the script editor. You can use it to program your scripts. Scripts are " +
"written in the Netscript language, a programming language created for " + "written in the Netscript language, a programming language created for " +
"this game. <strong style='background-color:#444;'>There are details about the Netscript language in the documentation, which " + "this game. <strong style='background-color:#444;'>There are details about the Netscript language in the documentation, which " +
@ -251,21 +278,24 @@ function iTutorialEvaluateStep() {
"For anyone with basic programming experience, this code should be straightforward. " + "For anyone with basic programming experience, this code should be straightforward. " +
"This script will continuously hack the 'foodnstuff' server.<br><br>" + "This script will continuously hack the 'foodnstuff' server.<br><br>" +
"To save and close the script editor, press the button in the bottom left, or press ctrl + b."); "To save and close the script editor, press the button in the bottom left, or press ctrl + b.");
//next step triggered in saveAndCloseScriptEditor() (Script.js) nextBtn.style.display = "none"; //next step triggered in saveAndCloseScriptEditor() (Script.js)
break; break;
case iTutorialSteps.TerminalFree: case iTutorialSteps.TerminalFree:
Engine.loadTerminalContent();
iTutorialSetText("Now we'll run the script. Scripts require a certain amount of RAM to run, and can be " + iTutorialSetText("Now we'll run the script. Scripts require a certain amount of RAM to run, and can be " +
"run on any machine which you have root access to. Different servers have different " + "run on any machine which you have root access to. Different servers have different " +
"amounts of RAM. You can also purchase more RAM for your home server.<br><br>To check how much " + "amounts of RAM. You can also purchase more RAM for your home server.<br><br>To check how much " +
"RAM is available on this machine, enter the 'free' command."); "RAM is available on this machine, enter the 'free' command.");
//next step triggered by terminal commmand nextBtn.style.display = "none"; //next step triggered by terminal commmand
break; break;
case iTutorialSteps.TerminalRunScript: case iTutorialSteps.TerminalRunScript:
Engine.loadTerminalContent();
iTutorialSetText("We have 16GB of free RAM on this machine, which is enough to run our " + iTutorialSetText("We have 16GB of free RAM on this machine, which is enough to run our " +
"script. Let's run our script using 'run foodnstuff.script'."); "script. Let's run our script using 'run foodnstuff.script'.");
//next step triggered by terminal commmand nextBtn.style.display = "none"; //next step triggered by terminal commmand
break; break;
case iTutorialSteps.TerminalGoToActiveScriptsPage: case iTutorialSteps.TerminalGoToActiveScriptsPage:
Engine.loadTerminalContent();
iTutorialSetText("Your script is now running! The script might take a few seconds to 'fully start up'. " + iTutorialSetText("Your script is now running! The script might take a few seconds to 'fully start up'. " +
"Your scripts will continuously run in the background and will automatically stop if " + "Your scripts will continuously run in the background and will automatically stop if " +
"the code ever completes (the 'foodnstuff.script' will never complete because it " + "the code ever completes (the 'foodnstuff.script' will never complete because it " +
@ -274,117 +304,114 @@ function iTutorialEvaluateStep() {
"much slower rate. <br><br> " + "much slower rate. <br><br> " +
"Let's check out some statistics for our running scripts by clicking the " + "Let's check out some statistics for our running scripts by clicking the " +
"'Active Scripts' link in the main navigation menu."); "'Active Scripts' link in the main navigation menu.");
document.getElementById("active-scripts-menu-link").setAttribute("class", "flashing-button"); nextBtn.style.display = "none";
var activeScriptsMainMenuButton = document.getElementById("active-scripts-menu-link");
activeScriptsMainMenuButton.addEventListener("click", function() { //Flash 'Active Scripts' menu and set its tutorial click handler
activeScriptsMainMenu.setAttribute("class", "flashing-button");
activeScriptsMainMenu.addEventListener("click", function() {
Engine.loadActiveScriptsContent(); Engine.loadActiveScriptsContent();
iTutorialNextStep(); iTutorialNextStep();
clearEventListeners("active-scripts-menu-link");
return false; return false;
}); });
break; break;
case iTutorialSteps.ActiveScriptsPage: case iTutorialSteps.ActiveScriptsPage:
Engine.loadActiveScriptsContent();
iTutorialSetText("This page displays stats/information about all of your scripts that are " + iTutorialSetText("This page displays stats/information about all of your scripts that are " +
"running across every existing server. You can use this to gauge how well " + "running across every existing server. You can use this to gauge how well " +
"your scripts are doing. Let's go back to the Terminal now using the 'Terminal'" + "your scripts are doing. Let's go back to the Terminal now using the 'Terminal'" +
"link."); "link.");
document.getElementById("terminal-menu-link").setAttribute("class", "flashing-button"); nextBtn.style.display = "none";
//Initialize everything necessary to open the 'Terminal' Page
var terminalMainMenuButton = clearEventListeners("terminal-menu-link"); //Flash 'Terminal' button and set its tutorial click handler
terminalMainMenuButton.addEventListener("click", function() { terminalMainMenu.setAttribute("class", "flashing-button");
terminalMainMenu.addEventListener("click", function() {
Engine.loadTerminalContent(); Engine.loadTerminalContent();
iTutorialNextStep(); iTutorialNextStep();
clearEventListeners("terminal-menu-link");
return false; return false;
}); });
break; break;
case iTutorialSteps.ActiveScriptsToTerminal: case iTutorialSteps.ActiveScriptsToTerminal:
Engine.loadTerminalContent();
iTutorialSetText("One last thing about scripts, each active script contains logs that detail " + iTutorialSetText("One last thing about scripts, each active script contains logs that detail " +
"what it's doing. We can check these logs using the 'tail' command. Do that " + "what it's doing. We can check these logs using the 'tail' command. Do that " +
"now for the script we just ran by typing 'tail foodnstuff.script'"); "now for the script we just ran by typing 'tail foodnstuff.script'");
//next step triggered by terminal command nextBtn.style.display = "none"; //next step triggered by terminal command
break; break;
case iTutorialSteps.TerminalTailScript: case iTutorialSteps.TerminalTailScript:
Engine.loadTerminalContent();
iTutorialSetText("The log for this script won't show much right now (it might show nothing at all) because it " + iTutorialSetText("The log for this script won't show much right now (it might show nothing at all) because it " +
"just started running...but check back again in a few minutes! <br><br>" + "just started running...but check back again in a few minutes! <br><br>" +
"This pretty much covers the basics of hacking. To learn more about writing " + "This pretty much covers the basics of hacking. To learn more about writing " +
"scripts using the Netscript language, select the 'Tutorial' link in the " + "scripts using the Netscript language, select the 'Tutorial' link in the " +
"main navigation menu to look at the documentation. For now, let's move on " + "main navigation menu to look at the documentation. " +
"to something else!"); "<strong style='background-color:#444;'>If you are an experienced JavaScript " +
var next = clearEventListeners("interactive-tutorial-next"); "developer, I would highly suggest you check out the section on " +
next.style.display = "inline-block"; "NetscriptJS/Netscript 2.0.</strong><br><br>For now, let's move on to something else!");
next.addEventListener("click", function() { nextBtn.style.display = "inline-block";
iTutorialNextStep();
return false;
});
break; break;
case iTutorialSteps.GoToHacknetNodesPage: case iTutorialSteps.GoToHacknetNodesPage:
Engine.loadTerminalContent();
iTutorialSetText("Hacking is not the only way to earn money. One other way to passively " + iTutorialSetText("Hacking is not the only way to earn money. One other way to passively " +
"earn money is by purchasing and upgrading Hacknet Nodes. Let's go to " + "earn money is by purchasing and upgrading Hacknet Nodes. Let's go to " +
"the 'Hacknet Nodes' page through the main navigation menu now."); "the 'Hacknet Nodes' page through the main navigation menu now.");
document.getElementById("hacknet-nodes-menu-link").setAttribute("class", "flashing-button"); nextBtn.style.display = "none";
var hacknetNodesButton = clearEventListeners("hacknet-nodes-menu-link");
var next = clearEventListeners("interactive-tutorial-next"); //Flash 'Hacknet' menu and set its tutorial click handler
next.style.display = "none"; hacknetMainMenu.setAttribute("class", "flashing-button");
hacknetNodesButton.addEventListener("click", function() { hacknetMainMenu.addEventListener("click", function() {
Engine.loadHacknetNodesContent(); Engine.loadHacknetNodesContent();
iTutorialNextStep(); iTutorialNextStep();
clearEventListeners("hacknet-nodes-menu-link");
return false; return false;
}); });
break; break;
case iTutorialSteps.HacknetNodesIntroduction: case iTutorialSteps.HacknetNodesIntroduction:
Engine.loadHacknetNodesContent();
iTutorialSetText("From this page you can purchase new Hacknet Nodes and upgrade your " + iTutorialSetText("From this page you can purchase new Hacknet Nodes and upgrade your " +
"existing ones. Let's purchase a new one now."); "existing ones. Let's purchase a new one now.");
//Next step triggered by purchaseHacknet() (HacknetNode.js) nextBtn.style.display = "none"; //Next step triggered by purchaseHacknet() (HacknetNode.js)
break; break;
case iTutorialSteps.HacknetNodesGoToWorldPage: case iTutorialSteps.HacknetNodesGoToWorldPage:
Engine.loadHacknetNodesContent();
iTutorialSetText("You just purchased a Hacknet Node! This Hacknet Node will passively " + iTutorialSetText("You just purchased a Hacknet Node! This Hacknet Node will passively " +
"earn you money over time, both online and offline. When you get enough " + "earn you money over time, both online and offline. When you get enough " +
" money, you can upgrade " + " money, you can upgrade " +
"your newly-purchased Hacknet Node below.<br><br>" + "your newly-purchased Hacknet Node below.<br><br>" +
"Let's go to the 'City' page through the main navigation menu."); "Let's go to the 'City' page through the main navigation menu.");
document.getElementById("city-menu-link").setAttribute("class", "flashing-button"); nextBtn.style.display = "none";
var worldButton = clearEventListeners("city-menu-link");
worldButton.addEventListener("click", function() { //Flash 'City' menu and set its tutorial click handler
cityMainMenu.setAttribute("class", "flashing-button");
cityMainMenu.addEventListener("click", function() {
Engine.loadWorldContent(); Engine.loadWorldContent();
iTutorialNextStep(); iTutorialNextStep();
clearEventListeners("city-menu-link");
return false; return false;
}); });
break; break;
case iTutorialSteps.WorldDescription: case iTutorialSteps.WorldDescription:
Engine.loadWorldContent();
iTutorialSetText("This page lists all of the different locations you can currently " + iTutorialSetText("This page lists all of the different locations you can currently " +
"travel to. Each location has something that you can do. " + "travel to. Each location has something that you can do. " +
"There's a lot of content out in the world, make sure " + "There's a lot of content out in the world, make sure " +
"you explore and discover!<br><br>" + "you explore and discover!<br><br>" +
"Lastly, click on the 'Tutorial' link in the main navigation menu."); "Lastly, click on the 'Tutorial' link in the main navigation menu.");
document.getElementById("tutorial-menu-link").setAttribute("class", "flashing-button"); nextBtn.style.display = "none";
var tutorialButton = clearEventListeners("tutorial-menu-link");
tutorialButton.addEventListener("click", function() { //Flash 'Tutorial' menu and set its tutorial click handler
tutorialMainMenu.setAttribute("class", "flashing-button");
tutorialMainMenu.addEventListener("click", function() {
Engine.loadTutorialContent(); Engine.loadTutorialContent();
iTutorialNextStep(); iTutorialNextStep();
clearEventListeners("tutorial-menu-link");
return false; return false;
}); });
break; break;
case iTutorialSteps.TutorialPageInfo: case iTutorialSteps.TutorialPageInfo:
Engine.loadTutorialContent();
iTutorialSetText("This page contains a lot of different documentation about the game's " + iTutorialSetText("This page contains a lot of different documentation about the game's " +
"content and mechanics. <strong style='background-color:#444;'> I know it's a lot, but I highly suggest you read " + "content and mechanics. <strong style='background-color:#444;'> I know it's a lot, but I highly suggest you read " +
"(or at least skim) through this before you start playing</strong>. That's the end of the tutorial. " + "(or at least skim) through this before you start playing</strong>. That's the end of the tutorial. " +
"Hope you enjoy the game!"); "Hope you enjoy the game!");
var next = clearEventListeners("interactive-tutorial-next"); nextBtn.style.display = "inline-block";
next.style.display = "inline-block"; nextBtn.innerHTML = "Finish Tutorial";
next.innerHTML = "Finish Tutorial";
var backButton = clearEventListeners("interactive-tutorial-back");
backButton.style.display = "none";
next.addEventListener("click", function() {
iTutorialNextStep();
return false;
});
break; break;
case iTutorialSteps.End: case iTutorialSteps.End:
iTutorialEnd(); iTutorialEnd();
@ -392,264 +419,85 @@ function iTutorialEvaluateStep() {
default: default:
throw new Error("Invalid tutorial step"); throw new Error("Invalid tutorial step");
} }
if (ITutorial.stepIsDone[ITutorial.currStep] === true) {
nextBtn.style.display = "inline-block";
}
} }
//Go to the next step and evaluate it //Go to the next step and evaluate it
function iTutorialNextStep() { function iTutorialNextStep() {
switch(currITutorialStep) { //Special behavior for certain steps
case iTutorialSteps.Start: if (ITutorial.currStep === iTutorialSteps.GoToCharacterPage) {
currITutorialStep = iTutorialSteps.GoToCharacterPage;
iTutorialEvaluateStep();
break;
case iTutorialSteps.GoToCharacterPage:
document.getElementById("stats-menu-link").removeAttribute("class"); document.getElementById("stats-menu-link").removeAttribute("class");
currITutorialStep = iTutorialSteps.CharacterPage;
iTutorialEvaluateStep();
break;
case iTutorialSteps.CharacterPage:
currITutorialStep = iTutorialSteps.CharacterGoToTerminalPage;
iTutorialEvaluateStep();
break;
case iTutorialSteps.CharacterGoToTerminalPage:
document.getElementById("terminal-menu-link").removeAttribute("class");
currITutorialStep = iTutorialSteps.TerminalIntro;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalIntro:
currITutorialStep = iTutorialSteps.TerminalHelp;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalHelp:
currITutorialStep = iTutorialSteps.TerminalLs;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalLs:
currITutorialStep = iTutorialSteps.TerminalScan;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalScan:
currITutorialStep = iTutorialSteps.TerminalScanAnalyze1;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalScanAnalyze1:
currITutorialStep = iTutorialSteps.TerminalScanAnalyze2;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalScanAnalyze2:
currITutorialStep = iTutorialSteps.TerminalConnect;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalConnect:
currITutorialStep = iTutorialSteps.TerminalAnalyze;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalAnalyze:
currITutorialStep = iTutorialSteps.TerminalNuke;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalNuke:
currITutorialStep = iTutorialSteps.TerminalManualHack;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalManualHack:
currITutorialStep = iTutorialSteps.TerminalHackingMechanics;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalHackingMechanics:
currITutorialStep = iTutorialSteps.TerminalCreateScript;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalCreateScript:
currITutorialStep = iTutorialSteps.TerminalTypeScript;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalTypeScript:
currITutorialStep = iTutorialSteps.TerminalFree;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalFree:
currITutorialStep = iTutorialSteps.TerminalRunScript;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalRunScript:
currITutorialStep = iTutorialSteps.TerminalGoToActiveScriptsPage;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalGoToActiveScriptsPage:
document.getElementById("active-scripts-menu-link").removeAttribute("class");
currITutorialStep = iTutorialSteps.ActiveScriptsPage;
iTutorialEvaluateStep();
break;
case iTutorialSteps.ActiveScriptsPage:
document.getElementById("terminal-menu-link").removeAttribute("class");
currITutorialStep = iTutorialSteps.ActiveScriptsToTerminal;
iTutorialEvaluateStep();
break;
case iTutorialSteps.ActiveScriptsToTerminal:
currITutorialStep = iTutorialSteps.TerminalTailScript;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalTailScript:
currITutorialStep = iTutorialSteps.GoToHacknetNodesPage;
iTutorialEvaluateStep();
break;
case iTutorialSteps.GoToHacknetNodesPage:
document.getElementById("hacknet-nodes-menu-link").removeAttribute("class");
currITutorialStep = iTutorialSteps.HacknetNodesIntroduction;
iTutorialEvaluateStep();
break;
case iTutorialSteps.HacknetNodesIntroduction:
currITutorialStep = iTutorialSteps.HacknetNodesGoToWorldPage;
iTutorialEvaluateStep();
break;
case iTutorialSteps.HacknetNodesGoToWorldPage:
document.getElementById("city-menu-link").removeAttribute("class");
currITutorialStep = iTutorialSteps.WorldDescription;
iTutorialEvaluateStep();
break;
case iTutorialSteps.WorldDescription:
document.getElementById("tutorial-menu-link").removeAttribute("class");
currITutorialStep = iTutorialSteps.TutorialPageInfo;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TutorialPageInfo:
currITutorialStep = iTutorialSteps.End;
iTutorialEvaluateStep();
break;
case iTutorialSteps.End:
break;
default:
throw new Error("Invalid tutorial step");
} }
if (ITutorial.currStep === iTutorialSteps.CharacterGoToTerminalPage) {
document.getElementById("terminal-menu-link").removeAttribute("class");
}
if (ITutorial.currStep === iTutorialSteps.TerminalGoToActiveScriptsPage) {
document.getElementById("active-scripts-menu-link").removeAttribute("class");
}
if (ITutorial.currStep === iTutorialSteps.ActiveScriptsPage) {
document.getElementById("terminal-menu-link").removeAttribute("class");
}
if (ITutorial.currStep === iTutorialSteps.GoToHacknetNodesPage) {
document.getElementById("hacknet-nodes-menu-link").removeAttribute("class");
}
if (ITutorial.currStep === iTutorialSteps.HacknetNodesGoToWorldPage) {
document.getElementById("city-menu-link").removeAttribute("class");
}
if (ITutorial.currStep === iTutorialSteps.WorldDescription) {
document.getElementById("tutorial-menu-link").removeAttribute("class");
}
ITutorial.stepIsDone[ITutorial.currStep] = true;
if (ITutorial.currStep < iTutorialSteps.End) {
ITutorial.currStep += 1;
}
iTutorialEvaluateStep();
} }
//Go to previous step and evaluate //Go to previous step and evaluate
function iTutorialPrevStep() { function iTutorialPrevStep() {
switch(currITutorialStep) { if (ITutorial.currStep > iTutorialSteps.Start) {
case iTutorialSteps.Start: ITutorial.currStep -= 1;
currITutorialStep = iTutorialSteps.Start;
iTutorialEvaluateStep();
break;
case iTutorialSteps.GoToCharacterPage:
currITutorialStep = iTutorialSteps.Start;
iTutorialEvaluateStep();
break;
case iTutorialSteps.CharacterPage:
currITutorialStep = iTutorialSteps.GoToCharacterPage;
iTutorialEvaluateStep();
break;
case iTutorialSteps.CharacterGoToTerminalPage:
currITutorialStep = iTutorialSteps.CharacterPage;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalIntro:
currITutorialStep = iTutorialSteps.CharacterGoToTerminalPage;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalHelp:
currITutorialStep = iTutorialSteps.TerminalIntro;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalLs:
currITutorialStep = iTutorialSteps.TerminalHelp;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalScan:
currITutorialStep = iTutorialSteps.TerminalLs;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalConnect:
currITutorialStep = iTutorialSteps.TerminalScan;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalAnalyze:
currITutorialStep = iTutorialSteps.TerminalConnect;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalNuke:
currITutorialStep = iTutorialSteps.TerminalAnalyze;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalManualHack:
currITutorialStep = iTutorialSteps.TerminalNuke;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalHackingMechanics:
currITutorialStep = iTutorialSteps.TerminalManualHack;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalCreateScript:
currITutorialStep = iTutorialSteps.TerminalManualHack;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalTypeScript:
currITutorialStep = iTutorialSteps.TerminalCreateScript;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalFree:
currITutorialStep = iTutorialSteps.TerminalTypeScript;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalRunScript:
currITutorialStep = iTutorialSteps.TerminalFree;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalGoToActiveScriptsPage:
currITutorialStep = iTutorialSteps.TerminalRunScript;
iTutorialEvaluateStep();
break;
case iTutorialSteps.ActiveScriptsPage:
currITutorialStep = iTutorialSteps.TerminalGoToActiveScriptsPage;
iTutorialEvaluateStep();
break;
case iTutorialSteps.ActiveScriptsToTerminal:
currITutorialStep = iTutorialSteps.ActiveScriptsPage;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TerminalTailScript:
currITutorialStep = iTutorialSteps.ActiveScriptsToTerminal;
iTutorialEvaluateStep();
break;
case iTutorialSteps.GoToHacknetNodesPage:
currITutorialStep = iTutorialSteps.TerminalTailScript;
iTutorialEvaluateStep();
break;
case iTutorialSteps.HacknetNodesIntroduction:
currITutorialStep = iTutorialSteps.GoToHacknetNodesPage;
iTutorialEvaluateStep();
break;
case iTutorialSteps.HacknetNodesGoToWorldPage:
currITutorialStep = iTutorialSteps.HacknetNodesIntroduction;
iTutorialEvaluateStep();
break;
case iTutorialSteps.WorldDescription:
currITutorialStep = iTutorialSteps.HacknetNodesGoToWorldPage;
iTutorialEvaluateStep();
break;
case iTutorialSteps.TutorialPageInfo:
currITutorialStep = iTutorialSteps.WorldDescription;
iTutorialEvaluateStep();
break;
case iTutorialSteps.End:
break;
default:
throw new Error("Invalid tutorial step");
} }
iTutorialEvaluateStep();
} }
function iTutorialEnd() { function iTutorialEnd() {
//Re-enable auto save //Re-enable auto save
Engine.Counters.autoSaveCounter = 300; if (Settings.AutosaveInterval === 0) {
Engine.Counters.autoSaveCounter = Infinity;
} else {
Engine.Counters.autoSaveCounter = Settings.AutosaveInterval * 5;
}
console.log("Ending interactive tutorial"); console.log("Ending interactive tutorial");
Engine.init(); Engine.init();
currITutorialStep = iTutorialSteps.End; ITutorial.currStep = iTutorialSteps.End;
iTutorialIsRunning = false; ITutorial.isRunning = false;
document.getElementById("interactive-tutorial-container").style.display = "none"; document.getElementById("interactive-tutorial-container").style.display = "none";
dialogBoxCreate("If you are new to the game, the following links may be useful for you!<br><br>" +
"<a class='a-link-button' href='http://bitburner.wikia.com/wiki/Chapt3rs_Guide_to_Getting_Started_with_Bitburner' target='_blank'>Getting Started Guide</a>" + //Create a popup with final introductory stuff
"<a class='a-link-button' href='http://bitburner.wikia.com/wiki/Bitburner_Wiki' target='_blank'>Wiki</a><br><br>" + var popupId = "interactive-tutorial-ending-popup";
"The Beginner's Guide to Hacking was added to your home computer! It contains some tips/pointers for starting out with the game. " + var txt = createElement("p", {
"To read it, go to Terminal and enter<br><br>cat hackers-starting-handbook.lit"); innerHTML:
"If you are new to the game, the following links may be useful for you!<br><br>" +
"<a class='a-link-button' href='http://bitburner.wikia.com/wiki/Chapt3rs_Guide_to_Getting_Started_with_Bitburner' target='_blank'>Getting Started Guide</a>" +
"<a class='a-link-button' href='http://bitburner.wikia.com/wiki/Bitburner_Wiki' target='_blank'>Wiki</a>" +
"<a class='a-link-button' href='https://bitburner.readthedocs.io/en/latest/' target='_blank'>Documentation</a><br><br>" +
"The Beginner's Guide to Hacking was added to your home computer! It contains some tips/pointers for starting out with the game. " +
"To read it, go to Terminal and enter<br><br>cat hackers-starting-handbook.lit"
});
var gotitBtn = createElement("a", {
class:"a-link-button", float:"right", padding:"6px", innerText:"Got it!",
clickListener:()=>{
removeElementById(popupId);
}
});
createPopup(popupId, [txt, gotitBtn]);
Player.getHomeComputer().messages.push("hackers-starting-handbook.lit"); Player.getHomeComputer().messages.push("hackers-starting-handbook.lit");
} }
@ -660,5 +508,4 @@ function iTutorialSetText(txt) {
textBox.parentElement.scrollTop = 0; // this resets scroll position textBox.parentElement.scrollTop = 0; // this resets scroll position
} }
export {iTutorialSteps, iTutorialEnd, iTutorialStart, iTutorialNextStep, currITutorialStep, export {iTutorialSteps, iTutorialEnd, iTutorialStart, iTutorialNextStep, ITutorial};
iTutorialIsRunning};

@ -23,7 +23,11 @@ function initLiterature() {
var title, fn, txt; var title, fn, txt;
title = "The Beginner's Guide to Hacking"; title = "The Beginner's Guide to Hacking";
fn = "hackers-starting-handbook.lit"; fn = "hackers-starting-handbook.lit";
txt = "When starting out, hacking is the most profitable way to earn money and progress. This " + txt = "Some resources:<br><br>" +
"<a class='a-link-button' href='https://bitburner.readthedocs.io/en/latest/netscriptlearntoprogram.html' target='_blank' style='margin:4px'>Learn to Program</a><br><br>" +
"<a class='a-link-button' href='https://bitburner.readthedocs.io/en/latest/netscriptjs.html' target='_blank' style='margin:4px'>For Experienced JavaScript Developers: NetscriptJS</a><br><br>" +
"<a class='a-link-button' href='https://bitburner.readthedocs.io/en/latest/netscript.html' target='_blank' style='margin:4px'>Netscript Documentation</a><br><br>" +
"When starting out, hacking is the most profitable way to earn money and progress. This " +
"is a brief collection of tips/pointers on how to make the most out of your hacking scripts.<br><br>" + "is a brief collection of tips/pointers on how to make the most out of your hacking scripts.<br><br>" +
"-hack() and grow() both work by percentages. hack() steals a certain percentage of the " + "-hack() and grow() both work by percentages. hack() steals a certain percentage of the " +
"money on a server, and grow() increases the amount of money on a server by some percentage (multiplicatively)<br><br>" + "money on a server, and grow() increases the amount of money on a server by some percentage (multiplicatively)<br><br>" +

@ -566,6 +566,8 @@ PlayerObject.prototype.analyze = function() {
PlayerObject.prototype.hasProgram = function(programName) { PlayerObject.prototype.hasProgram = function(programName) {
var home = Player.getHomeComputer(); var home = Player.getHomeComputer();
if (home == null) {return false;}
for (var i = 0; i < home.programs.length; ++i) { for (var i = 0; i < home.programs.length; ++i) {
if (programName.toLowerCase() == home.programs[i].toLowerCase()) {return true;} if (programName.toLowerCase() == home.programs[i].toLowerCase()) {return true;}
} }

@ -21,7 +21,7 @@ import {CONSTANTS} from "./Constants";
import {Engine} from "./engine"; import {Engine} from "./engine";
import {FconfSettings, parseFconfSettings} from "./Fconf"; import {FconfSettings, parseFconfSettings} from "./Fconf";
import {iTutorialSteps, iTutorialNextStep, import {iTutorialSteps, iTutorialNextStep,
iTutorialIsRunning, currITutorialStep} from "./InteractiveTutorial"; ITutorial} from "./InteractiveTutorial";
import {evaluateImport} from "./NetscriptEvaluator"; import {evaluateImport} from "./NetscriptEvaluator";
import {NetscriptFunctions} from "./NetscriptFunctions"; import {NetscriptFunctions} from "./NetscriptFunctions";
import {addWorkerScript, import {addWorkerScript,
@ -281,8 +281,9 @@ function saveAndCloseScriptEditor() {
var filename = document.getElementById("script-editor-filename").value; var filename = document.getElementById("script-editor-filename").value;
var editor = ace.edit('javascript-editor'); var editor = ace.edit('javascript-editor');
var code = editor.getValue(); var code = editor.getValue();
if (iTutorialIsRunning && currITutorialStep == iTutorialSteps.TerminalTypeScript) { if (ITutorial.isRunning && ITutorial.currStep === iTutorialSteps.TerminalTypeScript) {
if (filename != "foodnstuff.script") { //Make sure filename + code properly follow tutorial
if (filename !== "foodnstuff.script") {
dialogBoxCreate("Leave the script name as 'foodnstuff'!"); dialogBoxCreate("Leave the script name as 'foodnstuff'!");
return; return;
} }
@ -291,7 +292,23 @@ function saveAndCloseScriptEditor() {
dialogBoxCreate("Please copy and paste the code from the tutorial!"); dialogBoxCreate("Please copy and paste the code from the tutorial!");
return; return;
} }
iTutorialNextStep();
//Save the script
let s = Player.getCurrentServer();
for (var i = 0; i < s.scripts.length; i++) {
if (filename == s.scripts[i].filename) {
s.scripts[i].saveScript();
Engine.loadTerminalContent();
return iTutorialNextStep();
}
}
//If the current script does NOT exist, create a new one
let script = new Script();
script.saveScript();
s.scripts.push(script);
return iTutorialNextStep();
} }
if (filename == "") { if (filename == "") {

@ -12,8 +12,7 @@ import {FconfSettings, parseFconfSettings,
createFconf} from "./Fconf"; createFconf} from "./Fconf";
import {TerminalHelpText, HelpTexts} from "./HelpText"; import {TerminalHelpText, HelpTexts} from "./HelpText";
import {iTutorialNextStep, iTutorialSteps, import {iTutorialNextStep, iTutorialSteps,
iTutorialIsRunning, ITutorial} from "./InteractiveTutorial";
currITutorialStep} from "./InteractiveTutorial";
import {showLiterature} from "./Literature"; import {showLiterature} from "./Literature";
import {showMessage, Message} from "./Message"; import {showMessage, Message} from "./Message";
import {scriptCalculateHackingTime, import {scriptCalculateHackingTime,
@ -762,11 +761,11 @@ let Terminal = {
if (commandArray.length == 0) {return;} if (commandArray.length == 0) {return;}
/****************** Interactive Tutorial Terminal Commands ******************/ /****************** Interactive Tutorial Terminal Commands ******************/
if (iTutorialIsRunning) { if (ITutorial.isRunning) {
var foodnstuffServ = GetServerByHostname("foodnstuff"); var foodnstuffServ = GetServerByHostname("foodnstuff");
if (foodnstuffServ == null) {throw new Error("Could not get foodnstuff server"); return;} if (foodnstuffServ == null) {throw new Error("Could not get foodnstuff server"); return;}
switch(currITutorialStep) { switch(ITutorial.currStep) {
case iTutorialSteps.TerminalHelp: case iTutorialSteps.TerminalHelp:
if (commandArray[0] == "help") { if (commandArray[0] == "help") {
post(TerminalHelpText); post(TerminalHelpText);
@ -1809,7 +1808,7 @@ let Terminal = {
* @returns {void} * @returns {void}
*/ */
/** /**
* @type {Object.<string, ProgramHandler} * @type {Object.<string, ProgramHandler}
*/ */
const programHandlers = {}; const programHandlers = {};
programHandlers[Programs.NukeProgram.name] = (server) => { programHandlers[Programs.NukeProgram.name] = (server) => {