2017-07-22 00:54:55 +02:00
|
|
|
/* Shortcuts to navigate through the game
|
|
|
|
* Alt-t - Terminal
|
|
|
|
* Alt-c - Character
|
|
|
|
* Alt-e - Script editor
|
|
|
|
* Alt-s - Active scripts
|
|
|
|
* Alt-h - Hacknet Nodes
|
|
|
|
* Alt-w - City
|
|
|
|
* Alt-j - Job
|
|
|
|
* Alt-r - Travel Agency of current city
|
|
|
|
* Alt-p - Create program
|
|
|
|
* Alt-f - Factions
|
|
|
|
* Alt-a - Augmentations
|
|
|
|
* Alt-u - Tutorial
|
|
|
|
* Alt-o - Options
|
|
|
|
*/
|
|
|
|
$(document).keydown(function(e) {
|
|
|
|
if (!Player.isWorking && !redPillFlag) {
|
|
|
|
if (e.keyCode == 84 && e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadTerminalContent();
|
|
|
|
} else if (e.keyCode == 67 && e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadCharacterContent();
|
|
|
|
} else if (e.keyCode == 69 && e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadScriptEditorContent();
|
|
|
|
} else if (e.keyCode == 83 && e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadActiveScriptsContent();
|
|
|
|
} else if (e.keyCode == 72 && e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadHacknetNodesContent();
|
|
|
|
} else if (e.keyCode == 87 && e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadWorldContent();
|
|
|
|
} else if (e.keyCode == 74 && e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadJobContent();
|
|
|
|
} else if (e.keyCode == 82 && e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadTravelContent();
|
|
|
|
} else if (e.keyCode == 80 && e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadCreateProgramContent();
|
|
|
|
} else if (e.keyCode == 70 && e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadFactionsContent();
|
|
|
|
} else if (e.keyCode == 65 && e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadAugmentationsContent();
|
|
|
|
} else if (e.keyCode == 85 && e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadTutorialContent();
|
2017-07-25 03:06:40 +02:00
|
|
|
}
|
2017-07-22 00:54:55 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
if (e.keyCode == 79 && e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
gameOptionsBoxOpen();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2016-10-17 10:24:39 +02:00
|
|
|
var Engine = {
|
2017-06-07 02:04:18 +02:00
|
|
|
version: "",
|
2017-01-31 04:41:42 +01:00
|
|
|
Debug: true,
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-10-17 10:24:39 +02:00
|
|
|
//Clickable objects
|
2017-07-25 03:06:40 +02:00
|
|
|
Clickables: {
|
2016-10-17 10:24:39 +02:00
|
|
|
//Main menu buttons
|
2017-01-31 04:41:42 +01:00
|
|
|
terminalMainMenuButton: null,
|
|
|
|
characterMainMenuButton: null,
|
|
|
|
scriptEditorMainMenuButton: null,
|
|
|
|
activeScriptsMainMenuButton: null,
|
2017-04-27 22:02:58 +02:00
|
|
|
hacknetNodesMainMenuButton: null,
|
2017-01-31 04:41:42 +01:00
|
|
|
worldMainMenuButton: null,
|
2017-07-22 00:54:55 +02:00
|
|
|
travelMainMenuButton: null,
|
|
|
|
jobMainMenuButton: null,
|
2017-01-31 04:41:42 +01:00
|
|
|
createProgramMainMenuButton: null,
|
|
|
|
factionsMainMenuButton: null,
|
|
|
|
augmentationsMainMenuButton: null,
|
|
|
|
tutorialMainMenuButton: null,
|
|
|
|
saveMainMenuButton: null,
|
|
|
|
deleteMainMenuButton: null,
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-03-31 23:47:06 +02:00
|
|
|
//Tutorial buttons
|
|
|
|
tutorialGettingStartedButton: null,
|
|
|
|
tutorialNetworkingButton: null,
|
|
|
|
tutorialHackingButton: null,
|
|
|
|
tutorialScriptsButton: null,
|
2017-05-07 00:19:18 +02:00
|
|
|
tutorialNetscriptButton: null,
|
2017-03-31 23:47:06 +02:00
|
|
|
tutorialTravelingButton: null,
|
2017-07-03 21:42:11 +02:00
|
|
|
tutorialCompaniesButton: null,
|
2017-03-31 23:47:06 +02:00
|
|
|
tutorialFactionsButton: null,
|
|
|
|
tutorialAugmentationsButton: null,
|
|
|
|
tutorialBackButton: null,
|
2016-10-17 10:24:39 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-10-17 10:24:39 +02:00
|
|
|
//Display objects
|
|
|
|
Display: {
|
|
|
|
//Progress bar
|
2017-01-31 04:41:42 +01:00
|
|
|
progress: null,
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-10-17 10:24:39 +02:00
|
|
|
//Display for status text (such as "Saved" or "Loaded")
|
2017-01-31 04:41:42 +01:00
|
|
|
statusText: null,
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
hacking_skill: null,
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-10-17 10:24:39 +02:00
|
|
|
//Main menu content
|
2017-02-28 18:10:35 +01:00
|
|
|
terminalContent: null,
|
|
|
|
characterContent: null,
|
|
|
|
scriptEditorContent: null,
|
|
|
|
activeScriptsContent: null,
|
2017-04-27 22:02:58 +02:00
|
|
|
hacknetNodesContent: null,
|
2017-02-28 18:10:35 +01:00
|
|
|
worldContent: null,
|
|
|
|
createProgramContent: null,
|
|
|
|
factionsContent: null,
|
|
|
|
factionContent: null,
|
|
|
|
factionAugmentationsContent: null,
|
|
|
|
augmentationsContent: null,
|
|
|
|
tutorialContent: null,
|
2017-06-28 22:53:12 +02:00
|
|
|
infiltrationContent: null,
|
2017-07-03 21:42:11 +02:00
|
|
|
stockMarketContent: null,
|
2017-02-28 18:10:35 +01:00
|
|
|
locationContent: null,
|
|
|
|
workInProgressContent: null,
|
2017-07-04 23:18:42 +02:00
|
|
|
redPillContent: null,
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-10-17 10:24:39 +02:00
|
|
|
//Character info
|
2017-02-28 18:10:35 +01:00
|
|
|
characterInfo: null,
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
//Script editor text
|
2017-07-25 03:06:40 +02:00
|
|
|
scriptEditorText: null,
|
2016-10-17 10:24:39 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
//Current page status
|
2017-01-31 04:41:42 +01:00
|
|
|
Page: {
|
|
|
|
Terminal: "Terminal",
|
|
|
|
CharacterInfo: "CharacterInfo",
|
|
|
|
ScriptEditor: "ScriptEditor",
|
|
|
|
ActiveScripts: "ActiveScripts",
|
2017-04-27 22:02:58 +02:00
|
|
|
HacknetNodes: "HacknetNodes",
|
2017-01-31 04:41:42 +01:00
|
|
|
World: "World",
|
|
|
|
CreateProgram: "CreateProgram",
|
|
|
|
Factions: "Factions",
|
2017-01-28 04:10:16 +01:00
|
|
|
Faction: "Faction",
|
2017-01-31 04:41:42 +01:00
|
|
|
Augmentations: "Augmentations",
|
|
|
|
Tutorial: "Tutorial",
|
|
|
|
Location: "Location",
|
2017-02-16 19:52:11 +01:00
|
|
|
workInProgress: "WorkInProgress",
|
2017-07-04 23:18:42 +02:00
|
|
|
RedPill: "RedPill",
|
2017-07-03 21:42:11 +02:00
|
|
|
Infiltration: "Infiltration",
|
|
|
|
StockMarket: "StockMarket",
|
2017-01-31 04:41:42 +01:00
|
|
|
},
|
|
|
|
currentPage: null,
|
2016-11-24 23:30:33 +01:00
|
|
|
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
//Time variables (milliseconds unix epoch time)
|
|
|
|
_lastUpdate: new Date().getTime(),
|
|
|
|
_idleSpeed: 200, //Speed (in ms) at which the main loop is updated
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
|
|
|
|
/* Load content when a main menu button is clicked */
|
2016-10-17 10:24:39 +02:00
|
|
|
loadTerminalContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
Engine.Display.terminalContent.style.visibility = "visible";
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.currentPage = Engine.Page.Terminal;
|
2017-07-22 00:54:55 +02:00
|
|
|
document.getElementById("terminal-menu-link").classList.add("active");
|
2016-10-17 10:24:39 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-10-17 10:24:39 +02:00
|
|
|
loadCharacterContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
Engine.Display.characterContent.style.visibility = "visible";
|
|
|
|
Engine.displayCharacterInfo();
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.currentPage = Engine.Page.CharacterInfo;
|
2017-07-22 00:54:55 +02:00
|
|
|
document.getElementById("stats-menu-link").classList.add("active");
|
2017-01-31 04:41:42 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
loadScriptEditorContent: function(filename = "", code = "") {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
Engine.Display.scriptEditorContent.style.visibility = "visible";
|
2017-06-02 19:18:53 +02:00
|
|
|
if (filename != "") {
|
2017-01-31 04:41:42 +01:00
|
|
|
document.getElementById("script-editor-filename").value = filename;
|
2017-06-02 19:18:53 +02:00
|
|
|
document.getElementById("script-editor-text").value = code;
|
2017-01-31 04:41:42 +01:00
|
|
|
}
|
2017-05-16 05:06:25 +02:00
|
|
|
document.getElementById("script-editor-text").focus();
|
2017-07-13 18:54:29 +02:00
|
|
|
upgradeScriptEditorContent();
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.currentPage = Engine.Page.ScriptEditor;
|
2017-07-22 00:54:55 +02:00
|
|
|
document.getElementById("create-script-menu-link").classList.add("active");
|
2017-01-31 04:41:42 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
loadActiveScriptsContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
Engine.Display.activeScriptsContent.style.visibility = "visible";
|
2017-06-06 23:22:57 +02:00
|
|
|
setActiveScriptsClickHandlers();
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.currentPage = Engine.Page.ActiveScripts;
|
2017-07-22 00:54:55 +02:00
|
|
|
document.getElementById("active-scripts-menu-link").classList.add("active");
|
2017-01-31 04:41:42 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-04-27 22:02:58 +02:00
|
|
|
loadHacknetNodesContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
Engine.Display.hacknetNodesContent.style.visibility = "visible";
|
|
|
|
displayHacknetNodesContent();
|
|
|
|
Engine.currentPage = Engine.Page.HacknetNodes;
|
2017-07-22 00:54:55 +02:00
|
|
|
document.getElementById("hacknet-nodes-menu-link").classList.add("active");
|
2017-04-27 22:02:58 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
loadWorldContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
Engine.Display.worldContent.style.visibility = "visible";
|
|
|
|
Engine.displayWorldInfo();
|
|
|
|
Engine.currentPage = Engine.Page.World;
|
2017-07-22 00:54:55 +02:00
|
|
|
document.getElementById("city-menu-link").classList.add("active");
|
2017-01-31 04:41:42 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
loadCreateProgramContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
Engine.Display.createProgramContent.style.visibility = "visible";
|
2017-02-28 22:20:37 +01:00
|
|
|
displayCreateProgramContent();
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.currentPage = Engine.Page.CreateProgram;
|
2017-07-22 00:54:55 +02:00
|
|
|
document.getElementById("create-program-menu-link").classList.add("active");
|
2017-01-31 04:41:42 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
loadFactionsContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
Engine.Display.factionsContent.style.visibility = "visible";
|
2017-02-20 23:45:36 +01:00
|
|
|
Engine.displayFactionsInfo();
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.currentPage = Engine.Page.Factions;
|
2017-07-22 00:54:55 +02:00
|
|
|
document.getElementById("factions-menu-link").classList.add("active");
|
2016-10-17 10:24:39 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-28 04:10:16 +01:00
|
|
|
loadFactionContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
Engine.Display.factionContent.style.visibility = "visible";
|
|
|
|
Engine.currentPage = Engine.Page.Faction;
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
loadAugmentationsContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
Engine.Display.augmentationsContent.style.visibility = "visible";
|
2017-02-20 23:45:36 +01:00
|
|
|
Engine.displayAugmentationsContent();
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.currentPage = Engine.Page.Augmentations;
|
2017-07-22 00:54:55 +02:00
|
|
|
document.getElementById("augmentations-menu-link").classList.add("active");
|
2017-01-31 04:41:42 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
loadTutorialContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
Engine.Display.tutorialContent.style.visibility = "visible";
|
2017-03-31 23:47:06 +02:00
|
|
|
Engine.displayTutorialContent();
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.currentPage = Engine.Page.Tutorial;
|
2017-07-22 00:54:55 +02:00
|
|
|
document.getElementById("tutorial-menu-link").classList.add("active");
|
2017-01-31 04:41:42 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
loadLocationContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
Engine.Display.locationContent.style.visibility = "visible";
|
2017-01-31 05:43:33 +01:00
|
|
|
displayLocationContent();
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.currentPage = Engine.Page.Location;
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
loadTravelContent: function() {
|
|
|
|
switch(Player.city) {
|
|
|
|
case Locations.Aevum:
|
|
|
|
Player.location = Locations.AevumTravelAgency;
|
|
|
|
break;
|
|
|
|
case Locations.Chongqing:
|
|
|
|
Player.location = Locations.ChongqingTravelAgency;
|
|
|
|
break;
|
|
|
|
case Locations.Sector12:
|
|
|
|
Player.location = Locations.Sector12TravelAgency;
|
|
|
|
break;
|
|
|
|
case Locations.NewTokyo:
|
|
|
|
Player.location = Locations.NewTokyoTravelAgency;
|
|
|
|
break;
|
|
|
|
case Locations.Ishima:
|
|
|
|
Player.location = Locations.IshimaTravelAgency;
|
|
|
|
break;
|
|
|
|
case Locations.Volhaven:
|
|
|
|
Player.location = Locations.VolhavenTravelAgency;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
dialogBoxCreate("ERROR: Invalid city. This is a bug please contact game dev");
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
Engine.loadLocationContent();
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
loadJobContent: function() {
|
|
|
|
if (Player.companyName == "") {
|
2017-07-25 03:06:40 +02:00
|
|
|
dialogBoxCreate("You do not currently have a job! You can visit various companies " +
|
2017-07-22 00:54:55 +02:00
|
|
|
"in the city and try to find a job.");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
Player.location = Player.companyName;
|
|
|
|
Engine.loadLocationContent();
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-02-08 01:27:11 +01:00
|
|
|
loadWorkInProgressContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
var mainMenu = document.getElementById("mainmenu-container");
|
|
|
|
mainMenu.style.visibility = "hidden";
|
|
|
|
Engine.Display.workInProgressContent.style.visibility = "visible";
|
2017-02-16 19:52:11 +01:00
|
|
|
Engine.currentPage = Engine.Page.WorkInProgress;
|
2017-02-08 01:27:11 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-04 23:18:42 +02:00
|
|
|
loadRedPillContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
var mainMenu = document.getElementById("mainmenu-container");
|
|
|
|
mainMenu.style.visibility = "hidden";
|
|
|
|
Engine.Display.redPillContent.style.visibility = "visible";
|
|
|
|
Engine.currentPage = Engine.Page.RedPill;
|
2017-07-05 06:02:19 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
loadInfiltrationContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
Engine.Display.infiltrationContent.style.visibility = "visible";
|
|
|
|
Engine.currentPage = Engine.Page.Infiltration;
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
loadStockMarketContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
Engine.Display.stockMarketContent.style.visibility = "visible";
|
|
|
|
displayStockMarketContent();
|
|
|
|
Engine.currentPage = Engine.Page.StockMarket;
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
//Helper function that hides all content
|
2016-10-17 10:24:39 +02:00
|
|
|
hideAllContent: function() {
|
|
|
|
Engine.Display.terminalContent.style.visibility = "hidden";
|
|
|
|
Engine.Display.characterContent.style.visibility = "hidden";
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.Display.scriptEditorContent.style.visibility = "hidden";
|
|
|
|
Engine.Display.activeScriptsContent.style.visibility = "hidden";
|
2017-04-27 22:02:58 +02:00
|
|
|
Engine.Display.hacknetNodesContent.style.visibility = "hidden";
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.Display.worldContent.style.visibility = "hidden";
|
|
|
|
Engine.Display.createProgramContent.style.visibility = "hidden";
|
|
|
|
Engine.Display.factionsContent.style.visibility = "hidden";
|
2017-01-28 04:10:16 +01:00
|
|
|
Engine.Display.factionContent.style.visibility = "hidden";
|
2017-02-28 18:10:35 +01:00
|
|
|
Engine.Display.factionAugmentationsContent.style.visibility = "hidden";
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.Display.augmentationsContent.style.visibility = "hidden";
|
|
|
|
Engine.Display.tutorialContent.style.visibility = "hidden";
|
|
|
|
Engine.Display.locationContent.style.visibility = "hidden";
|
2017-02-08 01:27:11 +01:00
|
|
|
Engine.Display.workInProgressContent.style.visibility = "hidden";
|
2017-07-04 23:18:42 +02:00
|
|
|
Engine.Display.redPillContent.style.visibility = "hidden";
|
2017-07-03 21:42:11 +02:00
|
|
|
Engine.Display.infiltrationContent.style.visibility = "hidden";
|
|
|
|
Engine.Display.stockMarketContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-28 04:10:16 +01:00
|
|
|
//Location lists
|
|
|
|
Engine.aevumLocationsList.style.display = "none";
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.chongqingLocationsList.style.display = "none";
|
|
|
|
Engine.sector12LocationsList.style.display = "none";
|
|
|
|
Engine.newTokyoLocationsList.style.display = "none";
|
|
|
|
Engine.ishimaLocationsList.style.display = "none";
|
|
|
|
Engine.volhavenLocationsList.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
//Make nav menu tabs inactive
|
|
|
|
document.getElementById("terminal-menu-link").classList.remove("active");
|
|
|
|
document.getElementById("create-script-menu-link").classList.remove("active");
|
|
|
|
document.getElementById("active-scripts-menu-link").classList.remove("active");
|
|
|
|
document.getElementById("create-program-menu-link").classList.remove("active");
|
|
|
|
document.getElementById("stats-menu-link").classList.remove("active");
|
|
|
|
document.getElementById("factions-menu-link").classList.remove("active");
|
|
|
|
document.getElementById("augmentations-menu-link").classList.remove("active");
|
|
|
|
document.getElementById("hacknet-nodes-menu-link").classList.remove("active");
|
|
|
|
document.getElementById("city-menu-link").classList.remove("active");
|
|
|
|
document.getElementById("tutorial-menu-link").classList.remove("active");
|
|
|
|
document.getElementById("options-menu-link").classList.remove("active");
|
2016-10-17 10:24:39 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-20 09:33:33 +02:00
|
|
|
displayCharacterOverviewInfo: function() {
|
2017-07-03 21:42:11 +02:00
|
|
|
if (Player.hp == null) {Player.hp = Player.max_hp;}
|
2017-07-25 03:06:40 +02:00
|
|
|
document.getElementById("character-overview-text").innerHTML =
|
|
|
|
("Hp: " + Player.hp + " / " + Player.max_hp + "<br>" +
|
|
|
|
"Money: $" + formatNumber(Player.money, 2) + "<br>" +
|
|
|
|
"Hack: " + (Player.hacking_skill).toLocaleString() + "<br>" +
|
|
|
|
"Str: " + (Player.strength).toLocaleString() + "<br>" +
|
|
|
|
"Def: " + (Player.defense).toLocaleString() + "<br>" +
|
|
|
|
"Dex: " + (Player.dexterity).toLocaleString() + "<br>" +
|
|
|
|
"Agi: " + (Player.agility).toLocaleString() + "<br>" +
|
2017-05-20 09:33:33 +02:00
|
|
|
"Cha: " + (Player.charisma).toLocaleString()
|
|
|
|
).replace( / /g, " " );
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-10-17 10:24:39 +02:00
|
|
|
/* Display character info */
|
|
|
|
displayCharacterInfo: function() {
|
2017-02-03 23:05:59 +01:00
|
|
|
var companyPosition = "";
|
|
|
|
if (Player.companyPosition != "") {
|
|
|
|
companyPosition = Player.companyPosition.positionName;
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
Engine.Display.characterInfo.innerHTML =
|
|
|
|
('<b>General</b><br><br>' +
|
|
|
|
'Current City: ' + Player.city + '<br><br>' +
|
|
|
|
'Employer: ' + Player.companyName + '<br>' +
|
|
|
|
'Job Title: ' + companyPosition + '<br><br>' +
|
2017-05-04 22:50:17 +02:00
|
|
|
'Money: $' + formatNumber(Player.money, 2)+ '<br><br><br>' +
|
2017-07-25 03:06:40 +02:00
|
|
|
'<b>Stats</b><br><br>' +
|
|
|
|
'Hacking Level: ' + (Player.hacking_skill).toLocaleString() +
|
|
|
|
" (" + formatNumber(Player.hacking_exp, 4) + ' experience)<br>' +
|
|
|
|
'Strength: ' + (Player.strength).toLocaleString() +
|
|
|
|
" (" + formatNumber(Player.strength_exp, 4) + ' experience)<br>' +
|
|
|
|
'Defense: ' + (Player.defense).toLocaleString() +
|
|
|
|
" (" + formatNumber(Player.defense_exp, 4) + ' experience)<br>' +
|
|
|
|
'Dexterity: ' + (Player.dexterity).toLocaleString() +
|
|
|
|
" (" + formatNumber(Player.dexterity_exp, 4) + ' experience)<br>' +
|
|
|
|
'Agility: ' + (Player.agility).toLocaleString() +
|
2017-05-04 22:50:17 +02:00
|
|
|
" (" + formatNumber(Player.agility_exp, 4) + ' experience)<br>' +
|
2017-05-05 03:08:44 +02:00
|
|
|
'Charisma: ' + (Player.charisma).toLocaleString() +
|
2017-05-04 22:50:17 +02:00
|
|
|
" (" + formatNumber(Player.charisma_exp, 4) + ' experience)<br><br><br>' +
|
2017-07-25 03:06:40 +02:00
|
|
|
'<b>Multipliers</b><br><br>' +
|
|
|
|
'Hacking Chance multiplier: ' + formatNumber(Player.hacking_chance_mult * 100, 2) + '%<br>' +
|
|
|
|
'Hacking Speed multiplier: ' + formatNumber(Player.hacking_speed_mult * 100, 2) + '%<br>' +
|
|
|
|
'Hacking Money multiplier: ' + formatNumber(Player.hacking_money_mult * 100, 2) + '%<br>' +
|
|
|
|
'Hacking Growth multiplier: ' + formatNumber(Player.hacking_grow_mult * 100, 2) + '%<br><br>' +
|
2017-05-05 03:08:44 +02:00
|
|
|
'Hacking Level multiplier: ' + formatNumber(Player.hacking_mult * 100, 2) + '%<br>' +
|
2017-07-25 03:06:40 +02:00
|
|
|
'Hacking Experience multiplier: ' + formatNumber(Player.hacking_exp_mult * 100, 2) + '%<br><br>' +
|
|
|
|
'Strength Level multiplier: ' + formatNumber(Player.strength_mult * 100, 2) + '%<br>' +
|
|
|
|
'Strength Experience multiplier: ' + formatNumber(Player.strength_exp_mult * 100, 2) + '%<br><br>' +
|
|
|
|
'Defense Level multiplier: ' + formatNumber(Player.defense_mult * 100, 2) + '%<br>' +
|
|
|
|
'Defense Experience multiplier: ' + formatNumber(Player.defense_exp_mult * 100, 2) + '%<br><br>' +
|
|
|
|
'Dexterity Level multiplier: ' + formatNumber(Player.dexterity_mult * 100, 2) + '%<br>' +
|
|
|
|
'Dexterity Experience multiplier: ' + formatNumber(Player.dexterity_exp_mult * 100, 2) + '%<br><br>' +
|
|
|
|
'Agility Level multiplier: ' + formatNumber(Player.agility_mult * 100, 2) + '%<br>' +
|
|
|
|
'Agility Experience multiplier: ' + formatNumber(Player.agility_exp_mult * 100, 2) + '%<br><br>' +
|
|
|
|
'Charisma Level multiplier: ' + formatNumber(Player.charisma_mult * 100, 2) + '%<br>' +
|
|
|
|
'Charisma Experience multiplier: ' + formatNumber(Player.charisma_exp_mult * 100, 2) + '%<br><br>' +
|
2017-05-05 03:08:44 +02:00
|
|
|
'Hacknet Node production multiplier: ' + formatNumber(Player.hacknet_node_money_mult * 100, 2) + '%<br>' +
|
|
|
|
'Hacknet Node purchase cost multiplier: ' + formatNumber(Player.hacknet_node_purchase_cost_mult * 100, 2) + '%<br>' +
|
2017-05-30 00:37:38 +02:00
|
|
|
'Hacknet Node RAM upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_ram_cost_mult * 100, 2) + '%<br>' +
|
|
|
|
'Hacknet Node Core purchase cost multiplier: ' + formatNumber(Player.hacknet_node_core_cost_mult * 100, 2) + '%<br>' +
|
|
|
|
'Hacknet Node level upgrade cost multiplier: ' + formatNumber(Player.hacknet_node_level_cost_mult * 100, 2) + '%<br><br>' +
|
|
|
|
'Company reputation gain multiplier: ' + formatNumber(Player.company_rep_mult * 100, 2) + '%<br>' +
|
|
|
|
'Faction reputation gain multiplier: ' + formatNumber(Player.faction_rep_mult * 100, 2) + '%<br>' +
|
|
|
|
'Salary multiplier: ' + formatNumber(Player.work_money_mult * 100, 2) + '%<br>' +
|
|
|
|
'Crime success multiplier: ' + formatNumber(Player.crime_success_mult * 100, 2) + '%<br>' +
|
2017-05-12 20:12:32 +02:00
|
|
|
'Crime money multiplier: ' + formatNumber(Player.crime_money_mult * 100, 2) + '%<br><br><br>' +
|
2017-07-25 03:06:40 +02:00
|
|
|
'<b>Misc</b><br><br>' +
|
|
|
|
'Servers owned: ' + Player.purchasedServers.length + '<br>' +
|
2017-05-15 16:15:59 +02:00
|
|
|
'Hacknet Nodes owned: ' + Player.hacknetNodes.length + '<br>' +
|
2017-07-25 03:06:40 +02:00
|
|
|
'Augmentations installed: ' + Player.augmentations.length + '<br>' +
|
2017-06-17 19:47:04 +02:00
|
|
|
'Time played since last Augmentation: ' + convertTimeMsToTimeElapsedString(Player.playtimeSinceLastAug) + '<br>' +
|
2017-05-15 16:15:59 +02:00
|
|
|
'Time played: ' + convertTimeMsToTimeElapsedString(Player.totalPlaytime) + '<br><br><br>').replace( / /g, " " );
|
2016-10-17 10:24:39 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
/* Display locations in the world*/
|
|
|
|
aevumLocationsList: null,
|
|
|
|
chongqingLocationsList: null,
|
2017-07-25 03:06:40 +02:00
|
|
|
sector12LocationsList: null,
|
2017-01-31 04:41:42 +01:00
|
|
|
newTokyoLocationsList: null,
|
|
|
|
ishimaLocationsList: null,
|
|
|
|
volhavenLocationsList: null,
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
displayWorldInfo: function() {
|
|
|
|
Engine.aevumLocationsList.style.display = "none";
|
|
|
|
Engine.chongqingLocationsList.style.display = "none";
|
|
|
|
Engine.sector12LocationsList.style.display = "none";
|
|
|
|
Engine.newTokyoLocationsList.style.display = "none";
|
|
|
|
Engine.ishimaLocationsList.style.display = "none";
|
|
|
|
Engine.volhavenLocationsList.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 21:12:45 +02:00
|
|
|
document.getElementById("world-city-name").innerHTML = Player.city;
|
|
|
|
var cityDesc = document.getElementById("world-city-desc"); //TODO
|
2017-01-31 04:41:42 +01:00
|
|
|
switch(Player.city) {
|
2017-05-06 21:12:45 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
case Locations.Aevum:
|
|
|
|
Engine.aevumLocationsList.style.display = "inline";
|
|
|
|
break;
|
|
|
|
case Locations.Chongqing:
|
|
|
|
Engine.chongqingLocationsList.style.display = "inline";
|
|
|
|
break;
|
|
|
|
case Locations.Sector12:
|
|
|
|
Engine.sector12LocationsList.style.display = "inline";
|
|
|
|
break;
|
|
|
|
case Locations.NewTokyo:
|
|
|
|
Engine.newTokyoLocationsList.style.display = "inline";
|
|
|
|
break;
|
|
|
|
case Locations.Ishima:
|
|
|
|
Engine.ishimaLocationsList.style.display = "inline";
|
|
|
|
break;
|
|
|
|
case Locations.Volhaven:
|
|
|
|
Engine.volhavenLocationsList.style.display = "inline";
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
console.log("Invalid city value in Player object!");
|
|
|
|
break;
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
document.getElementById("generic-locations-list").style.display = "inline";
|
2017-01-31 04:41:42 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-02-20 23:45:36 +01:00
|
|
|
displayFactionsInfo: function() {
|
|
|
|
var factionsList = document.getElementById("factions-list");
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
//Clear the list
|
2017-04-19 07:02:40 +02:00
|
|
|
while (factionsList.firstChild) {
|
|
|
|
factionsList.removeChild(factionsList.firstChild);
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-04-19 07:02:40 +02:00
|
|
|
//Re-add a link for each faction you are a member of
|
2017-02-20 23:45:36 +01:00
|
|
|
for (var i = 0; i < Player.factions.length; ++i) {
|
2017-05-04 21:29:50 +02:00
|
|
|
(function () {
|
|
|
|
var factionName = Player.factions[i];
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-04 21:29:50 +02:00
|
|
|
//Add the faction to the Factions page content
|
|
|
|
var item = document.createElement("li");
|
|
|
|
var aElem = document.createElement("a");
|
|
|
|
aElem.setAttribute("href", "#");
|
|
|
|
aElem.setAttribute("class", "a-link-button");
|
|
|
|
aElem.innerHTML = factionName;
|
|
|
|
aElem.addEventListener("click", function() {
|
|
|
|
Engine.loadFactionContent();
|
|
|
|
displayFactionContent(factionName);
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
item.appendChild(aElem);
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
factionsList.appendChild(item);
|
2017-05-04 21:29:50 +02:00
|
|
|
}()); //Immediate invocation
|
2017-02-20 23:45:36 +01:00
|
|
|
}
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-02-20 23:45:36 +01:00
|
|
|
displayAugmentationsContent: function() {
|
2017-06-26 01:39:17 +02:00
|
|
|
//Purchased/queued augmentations
|
|
|
|
var queuedAugmentationsList = document.getElementById("queued-augmentations-list");
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-26 01:39:17 +02:00
|
|
|
while (queuedAugmentationsList.firstChild) {
|
|
|
|
queuedAugmentationsList.removeChild(queuedAugmentationsList.firstChild);
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-26 01:39:17 +02:00
|
|
|
for (var i = 0; i < Player.queuedAugmentations.length; ++i) {
|
|
|
|
var augName = Player.queuedAugmentations[i].name;
|
|
|
|
var aug = Augmentations[augName];
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-26 01:39:17 +02:00
|
|
|
var item = document.createElement("li");
|
|
|
|
var hElem = document.createElement("h2");
|
|
|
|
var pElem = document.createElement("p");
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-26 01:39:17 +02:00
|
|
|
item.setAttribute("class", "installed-augmentation");
|
|
|
|
hElem.innerHTML = augName;
|
|
|
|
if (augName == AugmentationNames.NeuroFluxGovernor) {
|
|
|
|
hElem.innerHTML += " - Level " + (Player.queuedAugmentations[i].level);
|
|
|
|
}
|
|
|
|
pElem.innerHTML = aug.info;
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-26 01:39:17 +02:00
|
|
|
item.appendChild(hElem);
|
|
|
|
item.appendChild(pElem);
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-26 01:39:17 +02:00
|
|
|
queuedAugmentationsList.appendChild(item);
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-26 01:39:17 +02:00
|
|
|
//Install Augmentations button
|
|
|
|
var installButton = clearEventListeners("install-augmentations-button");
|
|
|
|
installButton.addEventListener("click", function() {
|
|
|
|
installAugmentations();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-26 01:39:17 +02:00
|
|
|
//Installed augmentations
|
2017-02-20 23:45:36 +01:00
|
|
|
var augmentationsList = document.getElementById("augmentations-list");
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 20:13:31 +02:00
|
|
|
while (augmentationsList.firstChild) {
|
|
|
|
augmentationsList.removeChild(augmentationsList.firstChild);
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-02-20 23:45:36 +01:00
|
|
|
for (var i = 0; i < Player.augmentations.length; ++i) {
|
2017-06-24 23:33:44 +02:00
|
|
|
var augName = Player.augmentations[i].name;
|
2017-02-20 23:45:36 +01:00
|
|
|
var aug = Augmentations[augName];
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-02-20 23:45:36 +01:00
|
|
|
var item = document.createElement("li");
|
|
|
|
var hElem = document.createElement("h2");
|
|
|
|
var pElem = document.createElement("p");
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-02-20 23:45:36 +01:00
|
|
|
item.setAttribute("class", "installed-augmentation");
|
|
|
|
hElem.innerHTML = augName;
|
2017-05-07 12:04:54 +02:00
|
|
|
if (augName == AugmentationNames.NeuroFluxGovernor) {
|
2017-06-26 01:39:17 +02:00
|
|
|
hElem.innerHTML += " - Level " + (Player.augmentations[i].level);
|
2017-05-07 12:04:54 +02:00
|
|
|
}
|
2017-02-20 23:45:36 +01:00
|
|
|
pElem.innerHTML = aug.info;
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-02-20 23:45:36 +01:00
|
|
|
item.appendChild(hElem);
|
|
|
|
item.appendChild(pElem);
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-02-20 23:45:36 +01:00
|
|
|
augmentationsList.appendChild(item);
|
|
|
|
}
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-03-31 23:47:06 +02:00
|
|
|
displayTutorialContent: function() {
|
|
|
|
Engine.Clickables.tutorialGettingStartedButton.style.display = "block";
|
|
|
|
Engine.Clickables.tutorialNetworkingButton.style.display = "block";
|
|
|
|
Engine.Clickables.tutorialHackingButton.style.display = "block";
|
|
|
|
Engine.Clickables.tutorialScriptsButton.style.display = "block";
|
2017-05-07 00:19:18 +02:00
|
|
|
Engine.Clickables.tutorialNetscriptButton.style.display = "block";
|
2017-03-31 23:47:06 +02:00
|
|
|
Engine.Clickables.tutorialTravelingButton.style.display = "block";
|
2017-07-03 21:42:11 +02:00
|
|
|
Engine.Clickables.tutorialCompaniesButton.style.display = "block";
|
2017-03-31 23:47:06 +02:00
|
|
|
Engine.Clickables.tutorialFactionsButton.style.display = "block";
|
2017-07-25 03:06:40 +02:00
|
|
|
Engine.Clickables.tutorialAugmentationsButton.style.display = "block";
|
|
|
|
document.getElementById("tutorial-shortcuts-link").style.display = "block";
|
2017-03-31 23:47:06 +02:00
|
|
|
|
2017-04-13 19:33:34 +02:00
|
|
|
Engine.Clickables.tutorialBackButton.style.display = "none";
|
2017-03-31 23:47:06 +02:00
|
|
|
document.getElementById("tutorial-text").style.display = "none";
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-03-31 23:47:06 +02:00
|
|
|
//Displays the text when a section of the Tutorial is opened
|
|
|
|
displayTutorialPage: function(text) {
|
|
|
|
Engine.Clickables.tutorialGettingStartedButton.style.display = "none";
|
|
|
|
Engine.Clickables.tutorialNetworkingButton.style.display = "none";
|
|
|
|
Engine.Clickables.tutorialHackingButton.style.display = "none";
|
|
|
|
Engine.Clickables.tutorialScriptsButton.style.display = "none";
|
2017-05-07 00:19:18 +02:00
|
|
|
Engine.Clickables.tutorialNetscriptButton.style.display = "none";
|
2017-03-31 23:47:06 +02:00
|
|
|
Engine.Clickables.tutorialTravelingButton.style.display = "none";
|
2017-07-03 21:42:11 +02:00
|
|
|
Engine.Clickables.tutorialCompaniesButton.style.display = "none";
|
2017-03-31 23:47:06 +02:00
|
|
|
Engine.Clickables.tutorialFactionsButton.style.display = "none";
|
|
|
|
Engine.Clickables.tutorialAugmentationsButton.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
document.getElementById("tutorial-shortcuts-link").style.display = "none";
|
|
|
|
|
2017-04-13 19:33:34 +02:00
|
|
|
Engine.Clickables.tutorialBackButton.style.display = "inline-block";
|
2017-03-31 23:47:06 +02:00
|
|
|
document.getElementById("tutorial-text").style.display = "block";
|
|
|
|
document.getElementById("tutorial-text").innerHTML = text;
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
/* Main Event Loop */
|
|
|
|
idleTimer: function() {
|
|
|
|
//Get time difference
|
|
|
|
var _thisUpdate = new Date().getTime();
|
|
|
|
var diff = _thisUpdate - Engine._lastUpdate;
|
2016-12-02 22:57:20 +01:00
|
|
|
var offset = diff % Engine._idleSpeed;
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-11-21 07:11:14 +01:00
|
|
|
//Divide this by cycle time to determine how many cycles have elapsed since last update
|
2016-12-01 23:39:13 +01:00
|
|
|
diff = Math.floor(diff / Engine._idleSpeed);
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-11-21 07:11:14 +01:00
|
|
|
if (diff > 0) {
|
|
|
|
//Update the game engine by the calculated number of cycles
|
2016-12-02 22:57:20 +01:00
|
|
|
Engine._lastUpdate = _thisUpdate - offset;
|
2017-01-31 04:41:42 +01:00
|
|
|
Player.lastUpdate = _thisUpdate - offset;
|
2017-05-15 22:12:19 +02:00
|
|
|
Engine.updateGame(diff);
|
2017-07-25 03:06:40 +02:00
|
|
|
}
|
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
window.requestAnimationFrame(Engine.idleTimer);
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-12-15 23:22:42 +01:00
|
|
|
updateGame: function(numCycles = 1) {
|
2017-05-15 16:15:59 +02:00
|
|
|
//Update total playtime
|
|
|
|
var time = numCycles * Engine._idleSpeed;
|
|
|
|
if (Player.totalPlaytime == null) {Player.totalPlaytime = 0;}
|
2017-06-17 19:47:04 +02:00
|
|
|
if (Player.playtimeSinceLastAug == null) {Player.playtimeSinceLastAug = 0;}
|
2017-05-15 16:15:59 +02:00
|
|
|
Player.totalPlaytime += time;
|
2017-06-17 19:47:04 +02:00
|
|
|
Player.playtimeSinceLastAug += time;
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
//Start Manual hack
|
2017-01-31 04:41:42 +01:00
|
|
|
if (Player.startAction == true) {
|
|
|
|
Engine._totalActionTime = Player.actionTime;
|
|
|
|
Engine._actionTimeLeft = Player.actionTime;
|
|
|
|
Engine._actionInProgress = true;
|
|
|
|
Engine._actionProgressBarCount = 1;
|
|
|
|
Engine._actionProgressStr = "[ ]";
|
|
|
|
Engine._actionTimeStr = "Time left: ";
|
|
|
|
Player.startAction = false;
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-04-24 21:10:35 +02:00
|
|
|
//Working
|
2017-02-06 06:01:01 +01:00
|
|
|
if (Player.isWorking) {
|
2017-04-24 21:10:35 +02:00
|
|
|
if (Player.workType == CONSTANTS.WorkTypeFaction) {
|
2017-04-13 22:21:03 +02:00
|
|
|
Player.workForFaction(numCycles);
|
2017-04-24 21:10:35 +02:00
|
|
|
} else if (Player.workType == CONSTANTS.WorkTypeCreateProgram) {
|
2017-04-13 22:21:03 +02:00
|
|
|
Player.createProgramWork(numCycles);
|
2017-04-24 21:10:35 +02:00
|
|
|
} else if (Player.workType == CONSTANTS.WorkTypeStudyClass) {
|
2017-07-25 03:06:40 +02:00
|
|
|
Player.takeClass(numCycles);
|
2017-05-04 07:27:22 +02:00
|
|
|
} else if (Player.workType == CONSTANTS.WorkTypeCrime) {
|
|
|
|
Player.commitCrime(numCycles);
|
2017-05-10 22:21:15 +02:00
|
|
|
} else if (Player.workType == CONSTANTS.WorkTypeCompanyPartTime) {
|
|
|
|
Player.workPartTime(numCycles);
|
2017-04-13 22:21:03 +02:00
|
|
|
} else {
|
|
|
|
Player.work(numCycles);
|
|
|
|
}
|
2017-02-06 06:01:01 +01:00
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
//Counters
|
|
|
|
Engine.decrementAllCounters(numCycles);
|
2017-07-25 03:06:40 +02:00
|
|
|
Engine.checkCounters();
|
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
//Manual hacks
|
|
|
|
if (Engine._actionInProgress == true) {
|
|
|
|
Engine.updateHackProgress(numCycles);
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
//Update the running time of all active scripts
|
|
|
|
updateOnlineScriptTimes(numCycles);
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-04-27 22:02:58 +02:00
|
|
|
//Hacknet Nodes
|
|
|
|
processAllHacknetNodeEarnings(numCycles);
|
2016-12-15 23:22:42 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-12-02 22:57:20 +01:00
|
|
|
//Counters for the main event loop. Represent the number of game cycles are required
|
2017-07-25 03:06:40 +02:00
|
|
|
//for something to happen.
|
2016-12-02 22:57:20 +01:00
|
|
|
Counters: {
|
2017-01-31 04:41:42 +01:00
|
|
|
autoSaveCounter: 300, //Autosave every minute
|
2017-02-16 19:52:11 +01:00
|
|
|
updateSkillLevelsCounter: 10, //Only update skill levels every 2 seconds. Might improve performance
|
2017-05-04 07:27:22 +02:00
|
|
|
updateDisplays: 3, //Update displays such as Active Scripts display and character display
|
2017-05-05 18:52:48 +02:00
|
|
|
createProgramNotifications: 10, //Checks whether any programs can be created and notifies
|
2017-06-11 05:45:06 +02:00
|
|
|
checkFactionInvitations: 100, //Check whether you qualify for any faction invitations every 5 minutes
|
2017-05-04 07:05:48 +02:00
|
|
|
passiveFactionGrowth: 600,
|
2017-07-22 00:54:55 +02:00
|
|
|
messages: 150,
|
2017-07-13 18:54:29 +02:00
|
|
|
stockTick: 30, //Update stock prices
|
2017-07-25 03:06:40 +02:00
|
|
|
sCr: 1500,
|
2017-07-13 18:54:29 +02:00
|
|
|
updateScriptEditorDisplay: 5,
|
2016-12-02 22:57:20 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-12-02 22:57:20 +01:00
|
|
|
decrementAllCounters: function(numCycles = 1) {
|
|
|
|
for (var counter in Engine.Counters) {
|
|
|
|
if (Engine.Counters.hasOwnProperty(counter)) {
|
|
|
|
Engine.Counters[counter] = Engine.Counters[counter] - numCycles;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-12-02 22:57:20 +01:00
|
|
|
//Checks if any counters are 0 and if they are, executes whatever
|
|
|
|
//is necessary and then resets the counter
|
|
|
|
checkCounters: function() {
|
|
|
|
if (Engine.Counters.autoSaveCounter <= 0) {
|
2017-05-05 03:08:44 +02:00
|
|
|
saveObject.saveGame();
|
2016-12-02 22:57:20 +01:00
|
|
|
Engine.Counters.autoSaveCounter = 300;
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
if (Engine.Counters.updateSkillLevelsCounter <= 0) {
|
|
|
|
Player.updateSkillLevels();
|
|
|
|
Engine.Counters.updateSkillLevelsCounter = 10;
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
if (Engine.Counters.updateDisplays <= 0) {
|
2017-05-20 09:33:33 +02:00
|
|
|
Engine.displayCharacterOverviewInfo();
|
2017-01-31 04:41:42 +01:00
|
|
|
if (Engine.currentPage == Engine.Page.ActiveScripts) {
|
2017-06-06 23:22:57 +02:00
|
|
|
updateActiveScriptsItems();
|
2017-01-31 04:41:42 +01:00
|
|
|
} else if (Engine.currentPage == Engine.Page.CharacterInfo) {
|
|
|
|
Engine.displayCharacterInfo();
|
2017-04-27 22:02:58 +02:00
|
|
|
} else if (Engine.currentPage == Engine.Page.HacknetNodes) {
|
|
|
|
updateHacknetNodesContent();
|
2017-05-12 20:12:32 +02:00
|
|
|
} else if (Engine.currentPage == Engine.Page.CreateProgram) {
|
|
|
|
displayCreateProgramContent();
|
2017-04-27 22:02:58 +02:00
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-15 03:19:52 +02:00
|
|
|
if (logBoxOpened) {
|
|
|
|
logBoxUpdateText();
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-04 07:27:22 +02:00
|
|
|
Engine.Counters.updateDisplays = 3;
|
2017-01-31 04:41:42 +01:00
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 18:52:48 +02:00
|
|
|
if (Engine.Counters.createProgramNotifications <= 0) {
|
|
|
|
var num = getNumAvailableCreateProgram();
|
|
|
|
var elem = document.getElementById("create-program-notification");
|
|
|
|
if (num > 0) {
|
|
|
|
elem.innerHTML = num;
|
|
|
|
elem.setAttribute("class", "notification-on");
|
|
|
|
} else {
|
|
|
|
elem.innerHTML = "";
|
|
|
|
elem.setAttribute("class", "notification-off");
|
|
|
|
}
|
|
|
|
Engine.Counters.createProgramNotifications = 10;
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-02-16 19:52:11 +01:00
|
|
|
if (Engine.Counters.checkFactionInvitations <= 0) {
|
|
|
|
var invitedFactions = Player.checkForFactionInvitations();
|
|
|
|
if (invitedFactions.length > 0) {
|
|
|
|
var randFaction = invitedFactions[Math.floor(Math.random() * invitedFactions.length)];
|
|
|
|
inviteToFaction(randFaction);
|
|
|
|
}
|
2017-06-11 05:45:06 +02:00
|
|
|
Engine.Counters.checkFactionInvitations = 100;
|
2017-02-16 19:52:11 +01:00
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-04 07:05:48 +02:00
|
|
|
if (Engine.Counters.passiveFactionGrowth <= 0) {
|
|
|
|
var adjustedCycles = Math.floor((600 - Engine.Counters.passiveFactionGrowth));
|
|
|
|
processPassiveFactionRepGain(adjustedCycles);
|
|
|
|
Engine.Counters.passiveFactionGrowth = 600;
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-02 06:15:45 +02:00
|
|
|
if (Engine.Counters.messages <= 0) {
|
|
|
|
checkForMessagesToSend();
|
2017-07-22 00:54:55 +02:00
|
|
|
Engine.Counters.messages = 150;
|
2017-06-02 06:15:45 +02:00
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
if (Engine.Counters.stockTick <= 0) {
|
|
|
|
if (Player.hasWseAccount) {
|
|
|
|
updateStockPrices();
|
|
|
|
}
|
2017-07-13 18:54:29 +02:00
|
|
|
Engine.Counters.stockTick = 30;
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-13 18:54:29 +02:00
|
|
|
if (Engine.Counters.sCr <= 0) {
|
|
|
|
//Assume 4Sig will always indicate state of market
|
|
|
|
if (Player.hasWseAccount) {
|
2017-07-22 00:54:55 +02:00
|
|
|
stockMarketCycle();
|
2017-07-13 18:54:29 +02:00
|
|
|
}
|
|
|
|
Engine.Counters.sCr = 1500;
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-13 18:54:29 +02:00
|
|
|
if (Engine.Counters.updateScriptEditorDisplay <= 0) {
|
|
|
|
if (Engine.currentPage == Engine.Page.ScriptEditor) {
|
|
|
|
upgradeScriptEditorContent();
|
|
|
|
}
|
|
|
|
Engine.Counters.updateScriptEditorDisplay = 5;
|
2017-07-03 21:42:11 +02:00
|
|
|
}
|
2017-01-31 04:41:42 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
/* Calculates the hack progress for a manual (non-scripted) hack and updates the progress bar/time accordingly */
|
|
|
|
_totalActionTime: 0,
|
|
|
|
_actionTimeLeft: 0,
|
|
|
|
_actionTimeStr: "Time left: ",
|
|
|
|
_actionProgressStr: "[ ]",
|
|
|
|
_actionProgressBarCount: 1,
|
|
|
|
_actionInProgress: false,
|
|
|
|
updateHackProgress: function(numCycles = 1) {
|
|
|
|
var timeElapsedMilli = numCycles * Engine._idleSpeed;
|
|
|
|
Engine._actionTimeLeft -= (timeElapsedMilli/ 1000); //Substract idle speed (ms)
|
2017-04-18 06:32:17 +02:00
|
|
|
Engine._actionTimeLeft = Math.max(Engine._actionTimeLeft, 0);
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
//Calculate percent filled
|
2017-01-31 04:41:42 +01:00
|
|
|
var percent = Math.round((1 - Engine._actionTimeLeft / Engine._totalActionTime) * 100);
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
//Update progress bar
|
2017-01-31 04:41:42 +01:00
|
|
|
while (Engine._actionProgressBarCount * 2 <= percent) {
|
|
|
|
Engine._actionProgressStr = Engine._actionProgressStr.replaceAt(Engine._actionProgressBarCount, "|");
|
|
|
|
Engine._actionProgressBarCount += 1;
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
//Update hack time remaining
|
|
|
|
Engine._actionTimeStr = "Time left: " + Math.max(0, Math.round(Engine._actionTimeLeft)).toString() + "s";
|
|
|
|
document.getElementById("hack-progress").innerHTML = Engine._actionTimeStr;
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
//Dynamically update progress bar
|
|
|
|
document.getElementById("hack-progress-bar").innerHTML = Engine._actionProgressStr.replace( / /g, " " );
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
//Once percent is 100, the hack is completed
|
|
|
|
if (percent >= 100) {
|
|
|
|
Engine._actionInProgress = false;
|
|
|
|
Terminal.finishAction();
|
|
|
|
}
|
2016-11-21 07:11:14 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-15 18:54:23 +02:00
|
|
|
_prevTimeout: null,
|
|
|
|
createStatusText: function(txt) {
|
|
|
|
if (Engine._prevTimeout != null) {
|
|
|
|
clearTimeout(Engine._prevTimeout);
|
|
|
|
Engine._prevTimeout = null;
|
|
|
|
}
|
|
|
|
var statusText = document.getElementById("status-text")
|
2017-05-15 19:23:20 +02:00
|
|
|
statusText.style.display = "inline-block";
|
2017-05-15 18:54:23 +02:00
|
|
|
statusText.setAttribute("class", "status-text");
|
|
|
|
statusText.innerHTML = txt;
|
|
|
|
Engine._prevTimeout = setTimeout(function() {
|
2017-05-15 19:23:20 +02:00
|
|
|
statusText.style.display = "none";
|
2017-05-15 18:54:23 +02:00
|
|
|
statusText.removeAttribute("class");
|
|
|
|
statusText.innerHTML = "";
|
|
|
|
}, 3000);
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
displayLoadingScreen: function() {
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
removeLoadingScreen: function() {
|
|
|
|
var loader = document.getElementById("loader");
|
|
|
|
if (!loader) {return;}
|
|
|
|
while(loader.firstChild) {
|
|
|
|
loader.removeChild(loader.firstChild);
|
|
|
|
}
|
|
|
|
loader.parentNode.removeChild(loader);
|
|
|
|
document.getElementById("entire-game-container").style.visibility = "visible";
|
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
load: function() {
|
2017-07-22 00:54:55 +02:00
|
|
|
//Initialize main menu accordion panels to all start as "open"
|
|
|
|
var terminal = document.getElementById("terminal-tab");
|
|
|
|
var createScript = document.getElementById("create-script-tab");
|
|
|
|
var activeScripts = document.getElementById("active-scripts-tab");
|
|
|
|
var createProgram = document.getElementById("create-program-tab");
|
|
|
|
var stats = document.getElementById("stats-tab");
|
|
|
|
var factions = document.getElementById("factions-tab");
|
|
|
|
var augmentations = document.getElementById("augmentations-tab");
|
|
|
|
var hacknetnodes = document.getElementById("hacknet-nodes-tab");
|
|
|
|
var city = document.getElementById("city-tab");
|
|
|
|
var travel = document.getElementById("travel-tab");
|
|
|
|
var job = document.getElementById("job-tab");
|
|
|
|
var tutorial = document.getElementById("tutorial-tab");
|
|
|
|
var options = document.getElementById("options-tab");
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
//Load game from save or create new game
|
2017-07-25 03:06:40 +02:00
|
|
|
if (loadGame(saveObject)) {
|
2017-05-05 23:27:35 +02:00
|
|
|
console.log("Loaded game from save");
|
|
|
|
Engine.setDisplayElements(); //Sets variables for important DOM elements
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.init(); //Initialize buttons, work, etc.
|
2017-05-05 23:27:35 +02:00
|
|
|
CompanyPositions.init();
|
2017-06-28 22:53:12 +02:00
|
|
|
initAugmentations(); //Also calls Player.reapplyAllAugmentations()
|
2017-07-03 21:42:11 +02:00
|
|
|
initStockSymbols();
|
|
|
|
if (Player.hasWseAccount) {
|
|
|
|
initSymbolToStockMap();
|
|
|
|
}
|
2017-05-05 23:27:35 +02:00
|
|
|
|
|
|
|
//Calculate the number of cycles have elapsed while offline
|
2017-05-15 21:11:40 +02:00
|
|
|
Engine._lastUpdate = new Date().getTime();
|
2017-05-05 23:27:35 +02:00
|
|
|
var lastUpdate = Player.lastUpdate;
|
2017-05-15 21:11:40 +02:00
|
|
|
var numCyclesOffline = Math.floor((Engine._lastUpdate - lastUpdate) / Engine._idleSpeed);
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
/* Process offline progress */
|
2017-05-20 11:27:42 +02:00
|
|
|
var offlineProductionFromScripts = loadAllRunningScripts(); //This also takes care of offline production for those scripts
|
2017-05-05 23:27:35 +02:00
|
|
|
if (Player.isWorking) {
|
2017-05-15 21:30:08 +02:00
|
|
|
console.log("work() called in load() for " + numCyclesOffline * Engine._idleSpeed + " milliseconds");
|
2017-05-05 23:27:35 +02:00
|
|
|
if (Player.workType == CONSTANTS.WorkTypeFaction) {
|
|
|
|
Player.workForFaction(numCyclesOffline);
|
|
|
|
} else if (Player.workType == CONSTANTS.WorkTypeCreateProgram) {
|
|
|
|
Player.createProgramWork(numCyclesOffline);
|
|
|
|
} else if (Player.workType == CONSTANTS.WorkTypeStudyClass) {
|
|
|
|
Player.takeClass(numCyclesOffline);
|
2017-05-10 22:21:15 +02:00
|
|
|
} else if (Player.workType == CONSTANTS.WorkTypeCrime) {
|
|
|
|
Player.commitCrime(numCyclesOffline);
|
|
|
|
} else if (Player.workType == CONSTANTS.WorkTypeCompanyPartTime) {
|
2017-05-12 20:52:02 +02:00
|
|
|
Player.workPartTime(numCyclesOffline);
|
2017-05-05 23:27:35 +02:00
|
|
|
} else {
|
|
|
|
Player.work(numCyclesOffline);
|
|
|
|
}
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
//Hacknet Nodes offline progress
|
2017-05-20 11:27:42 +02:00
|
|
|
var offlineProductionFromHacknetNodes = processAllHacknetNodeEarnings(numCyclesOffline);
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
//Passive faction rep gain offline
|
|
|
|
processPassiveFactionRepGain(numCyclesOffline);
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-15 18:54:23 +02:00
|
|
|
//Update total playtime
|
|
|
|
var time = numCyclesOffline * Engine._idleSpeed;
|
|
|
|
if (Player.totalPlaytime == null) {Player.totalPlaytime = 0;}
|
2017-06-17 19:47:04 +02:00
|
|
|
if (Player.playtimeSinceLastAug == null) {Player.playtimeSinceLastAug = 0;}
|
2017-05-15 18:54:23 +02:00
|
|
|
Player.totalPlaytime += time;
|
2017-06-17 19:47:04 +02:00
|
|
|
Player.playtimeSinceLastAug += time;
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-15 21:30:08 +02:00
|
|
|
Player.lastUpdate = Engine._lastUpdate;
|
2017-05-15 21:11:40 +02:00
|
|
|
Engine.start(); //Run main game loop and Scripts loop
|
2017-07-22 00:54:55 +02:00
|
|
|
Engine.removeLoadingScreen();
|
2017-07-25 03:06:40 +02:00
|
|
|
dialogBoxCreate("While you were offline, your scripts generated $" +
|
|
|
|
formatNumber(offlineProductionFromScripts, 2) + " and your Hacknet Nodes generated $" +
|
2017-05-20 11:27:42 +02:00
|
|
|
formatNumber(offlineProductionFromHacknetNodes, 2));
|
2017-07-22 00:54:55 +02:00
|
|
|
//Close main menu accordions for loaded game
|
|
|
|
terminal.style.maxHeight = null;
|
|
|
|
terminal.style.opacity = 0;
|
|
|
|
terminal.style.pointerEvents = "none";
|
|
|
|
createScript.style.maxHeight = null;
|
|
|
|
createScript.style.opacity = 0;
|
|
|
|
createScript.style.pointerEvents = "none";
|
|
|
|
activeScripts.style.maxHeight = null;
|
|
|
|
activeScripts.style.opacity = 0;
|
|
|
|
activeScripts.style.pointerEvents = "none";
|
|
|
|
createProgram.style.maxHeight = null;
|
|
|
|
createProgram.style.opacity = 0;
|
|
|
|
createProgram.style.pointerEvents = "none";
|
|
|
|
stats.style.maxHeight = null;
|
|
|
|
stats.style.opacity = 0;
|
|
|
|
stats.style.pointerEvents = "none";
|
|
|
|
factions.style.maxHeight = null;
|
|
|
|
factions.style.opacity = 0;
|
|
|
|
factions.style.pointerEvents = "none";
|
|
|
|
augmentations.style.maxHeight = null;
|
|
|
|
augmentations.style.opacity = 0;
|
|
|
|
augmentations.style.pointerEvents = "none";
|
|
|
|
hacknetnodes.style.maxHeight = null;
|
|
|
|
hacknetnodes.style.opacity = 0;
|
|
|
|
hacknetnodes.style.pointerEvents = "none";
|
|
|
|
city.style.maxHeight = null;
|
|
|
|
city.style.opacity = 0;
|
|
|
|
city.style.pointerEvents = "none";
|
|
|
|
travel.style.maxHeight = null;
|
|
|
|
travel.style.opacity = 0;
|
|
|
|
travel.style.pointerEvents = "none";
|
|
|
|
job.style.maxHeight = null;
|
|
|
|
job.style.opacity = 0;
|
|
|
|
job.style.pointerEvents = "none";
|
|
|
|
tutorial.style.maxHeight = null;
|
|
|
|
tutorial.style.opacity = 0;
|
|
|
|
tutorial.style.pointerEvents = "none";
|
|
|
|
options.style.maxHeight = null;
|
|
|
|
options.style.opacity = 0;
|
|
|
|
options.style.pointerEvents = "none";
|
2017-05-05 23:27:35 +02:00
|
|
|
} else {
|
|
|
|
//No save found, start new game
|
|
|
|
console.log("Initializing new game");
|
2017-05-07 12:04:54 +02:00
|
|
|
SpecialServerIps = new SpecialServerIpsMap();
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.setDisplayElements(); //Sets variables for important DOM elements
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.start(); //Run main game loop and Scripts loop
|
2017-05-05 23:27:35 +02:00
|
|
|
Player.init();
|
|
|
|
initForeignServers();
|
|
|
|
initCompanies();
|
|
|
|
initFactions();
|
|
|
|
CompanyPositions.init();
|
|
|
|
initAugmentations();
|
2017-06-20 22:36:48 +02:00
|
|
|
initMessages();
|
2017-07-03 21:42:11 +02:00
|
|
|
initStockSymbols();
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
//Open main menu accordions for new game
|
|
|
|
//Main menu accordions
|
|
|
|
var hackingHdr = document.getElementById("hacking-menu-header");
|
|
|
|
hackingHdr.classList.toggle("opened");
|
|
|
|
var characterHdr = document.getElementById("character-menu-header");
|
|
|
|
characterHdr.classList.toggle("opened");
|
|
|
|
var worldHdr = document.getElementById("world-menu-header");
|
|
|
|
worldHdr.classList.toggle("opened");
|
|
|
|
var helpHdr = document.getElementById("help-menu-header");
|
|
|
|
helpHdr.classList.toggle("opened");
|
|
|
|
terminal.style.maxHeight = terminal.scrollHeight + "px";
|
|
|
|
terminal.style.display = "block";
|
|
|
|
createScript.style.maxHeight = createScript.scrollHeight + "px";
|
|
|
|
createScript.style.display = "block";
|
|
|
|
activeScripts.style.maxHeight = activeScripts.scrollHeight + "px";
|
|
|
|
activeScripts.style.display = "block";
|
|
|
|
createProgram.style.maxHeight = createProgram.scrollHeight + "px";
|
|
|
|
createProgram.style.display = "block";
|
|
|
|
stats.style.maxHeight = stats.scrollHeight + "px";
|
|
|
|
stats.style.display = "block";
|
|
|
|
factions.style.maxHeight = factions.scrollHeight + "px";
|
|
|
|
factions.style.display = "block";
|
|
|
|
augmentations.style.maxHeight = augmentations.scrollHeight + "px";
|
|
|
|
augmentations.style.display = "block";
|
|
|
|
hacknetnodes.style.maxHeight = hacknetnodes.scrollHeight + "px";
|
|
|
|
hacknetnodes.style.display = "block";
|
|
|
|
city.style.maxHeight = city.scrollHeight + "px";
|
|
|
|
city.style.display = "block";
|
|
|
|
travel.style.maxHeight = travel.scrollHeight + "px";
|
|
|
|
travel.style.display = "block";
|
|
|
|
job.style.maxHeight = job.scrollHeight + "px";
|
|
|
|
job.style.display = "block";
|
|
|
|
tutorial.style.maxHeight = tutorial.scrollHeight + "px";
|
|
|
|
tutorial.style.display = "block";
|
|
|
|
options.style.maxHeight = options.scrollHeight + "px";
|
|
|
|
options.style.display = "block";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
//Start interactive tutorial
|
2017-07-22 00:54:55 +02:00
|
|
|
iTutorialStart();
|
|
|
|
Engine.removeLoadingScreen();
|
2017-05-05 23:27:35 +02:00
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
setDisplayElements: function() {
|
2017-07-25 03:06:40 +02:00
|
|
|
//Content elements
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.terminalContent = document.getElementById("terminal-container");
|
|
|
|
Engine.currentPage = Engine.Page.Terminal;
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.characterContent = document.getElementById("character-container");
|
|
|
|
Engine.Display.characterContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.scriptEditorContent = document.getElementById("script-editor-container");
|
|
|
|
Engine.Display.scriptEditorContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.activeScriptsContent = document.getElementById("active-scripts-container");
|
|
|
|
Engine.Display.activeScriptsContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.hacknetNodesContent = document.getElementById("hacknet-nodes-container");
|
|
|
|
Engine.Display.hacknetNodesContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.worldContent = document.getElementById("world-container");
|
|
|
|
Engine.Display.worldContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.createProgramContent = document.getElementById("create-program-container");
|
|
|
|
Engine.Display.createProgramContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.factionsContent = document.getElementById("factions-container");
|
|
|
|
Engine.Display.factionsContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.factionContent = document.getElementById("faction-container");
|
|
|
|
Engine.Display.factionContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.factionAugmentationsContent = document.getElementById("faction-augmentations-container");
|
|
|
|
Engine.Display.factionAugmentationsContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.augmentationsContent = document.getElementById("augmentations-container");
|
|
|
|
Engine.Display.augmentationsContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.tutorialContent = document.getElementById("tutorial-container");
|
|
|
|
Engine.Display.tutorialContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-28 22:53:12 +02:00
|
|
|
Engine.Display.infiltrationContent = document.getElementById("infiltration-container");
|
|
|
|
Engine.Display.infiltrationContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
Engine.Display.stockMarketContent = document.getElementById("stock-market-container");
|
|
|
|
Engine.Display.stockMarketContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
//Character info
|
|
|
|
Engine.Display.characterInfo = document.getElementById("character-info");
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
//Location lists
|
|
|
|
Engine.aevumLocationsList = document.getElementById("aevum-locations-list");
|
|
|
|
Engine.chongqingLocationsList = document.getElementById("chongqing-locations-list");
|
|
|
|
Engine.sector12LocationsList = document.getElementById("sector12-locations-list");
|
|
|
|
Engine.newTokyoLocationsList = document.getElementById("newtokyo-locations-list");
|
|
|
|
Engine.ishimaLocationsList = document.getElementById("ishima-locations-list");
|
|
|
|
Engine.volhavenLocationsList = document.getElementById("volhaven-locations-list");
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
//Location page (page that shows up when you visit a specific location in World)
|
|
|
|
Engine.Display.locationContent = document.getElementById("location-container");
|
|
|
|
Engine.Display.locationContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
//Work In Progress
|
|
|
|
Engine.Display.workInProgressContent = document.getElementById("work-in-progress-container");
|
|
|
|
Engine.Display.workInProgressContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-04 23:18:42 +02:00
|
|
|
//Red Pill / Hack World Daemon
|
|
|
|
Engine.Display.redPillContent = document.getElementById("red-pill-container");
|
2017-07-05 06:02:19 +02:00
|
|
|
Engine.Display.redPillContent.style.visibility = "hidden";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
//Init Location buttons
|
|
|
|
initLocationButtons();
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
//Script editor
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.scriptEditorText = document.getElementById("script-editor-text");
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
//Tutorial buttons
|
|
|
|
Engine.Clickables.tutorialGettingStartedButton = document.getElementById("tutorial-getting-started-link");
|
|
|
|
Engine.Clickables.tutorialGettingStartedButton.addEventListener("click", function() {
|
|
|
|
Engine.displayTutorialPage(CONSTANTS.TutorialGettingStartedText);
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.tutorialNetworkingButton = document.getElementById("tutorial-networking-link");
|
|
|
|
Engine.Clickables.tutorialNetworkingButton.addEventListener("click", function() {
|
|
|
|
Engine.displayTutorialPage(CONSTANTS.TutorialNetworkingText);
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.tutorialHackingButton = document.getElementById("tutorial-hacking-link");
|
|
|
|
Engine.Clickables.tutorialHackingButton.addEventListener("click", function() {
|
|
|
|
Engine.displayTutorialPage(CONSTANTS.TutorialHackingText);
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.tutorialScriptsButton = document.getElementById("tutorial-scripts-link");
|
|
|
|
Engine.Clickables.tutorialScriptsButton.addEventListener("click", function() {
|
|
|
|
Engine.displayTutorialPage(CONSTANTS.TutorialScriptsText);
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-07 00:19:18 +02:00
|
|
|
Engine.Clickables.tutorialNetscriptButton = document.getElementById("tutorial-netscript-link");
|
|
|
|
Engine.Clickables.tutorialNetscriptButton.addEventListener("click", function() {
|
|
|
|
Engine.displayTutorialPage(CONSTANTS.TutorialNetscriptText);
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.tutorialTravelingButton = document.getElementById("tutorial-traveling-link");
|
|
|
|
Engine.Clickables.tutorialTravelingButton.addEventListener("click", function() {
|
|
|
|
Engine.displayTutorialPage(CONSTANTS.TutorialTravelingText);
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
Engine.Clickables.tutorialCompaniesButton = document.getElementById("tutorial-jobs-link");
|
|
|
|
Engine.Clickables.tutorialCompaniesButton.addEventListener("click", function() {
|
|
|
|
Engine.displayTutorialPage(CONSTANTS.TutorialCompaniesText);
|
2017-05-06 08:24:01 +02:00
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.tutorialFactionsButton = document.getElementById("tutorial-factions-link");
|
|
|
|
Engine.Clickables.tutorialFactionsButton.addEventListener("click", function() {
|
|
|
|
Engine.displayTutorialPage(CONSTANTS.TutorialFactionsText);
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.tutorialAugmentationsButton = document.getElementById("tutorial-augmentations-link");
|
|
|
|
Engine.Clickables.tutorialAugmentationsButton.addEventListener("click", function() {
|
|
|
|
Engine.displayTutorialPage(CONSTANTS.TutorialAugmentationsText);
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.tutorialBackButton = document.getElementById("tutorial-back-button");
|
|
|
|
Engine.Clickables.tutorialBackButton.addEventListener("click", function() {
|
|
|
|
Engine.displayTutorialContent();
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 21:12:45 +02:00
|
|
|
//If DarkWeb already purchased, disable the button
|
|
|
|
if (SpecialServerIps.hasOwnProperty("Darkweb Server")) {
|
|
|
|
document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button-inactive");
|
|
|
|
}
|
2017-05-06 08:24:01 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-10-17 10:24:39 +02:00
|
|
|
/* Initialization */
|
2017-01-31 04:41:42 +01:00
|
|
|
init: function() {
|
2017-07-22 00:54:55 +02:00
|
|
|
//Main menu accordions
|
|
|
|
var hackingHdr = document.getElementById("hacking-menu-header");
|
|
|
|
//hackingHdr.classList.toggle("opened");
|
|
|
|
var characterHdr = document.getElementById("character-menu-header");
|
|
|
|
//characterHdr.classList.toggle("opened");
|
|
|
|
var worldHdr = document.getElementById("world-menu-header");
|
|
|
|
//worldHdr.classList.toggle("opened");
|
|
|
|
var helpHdr = document.getElementById("help-menu-header");
|
|
|
|
//helpHdr.classList.toggle("opened");
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
hackingHdr.onclick = function() {
|
|
|
|
var terminal = document.getElementById("terminal-tab");
|
|
|
|
var terminalLink = document.getElementById("terminal-menu-link");
|
|
|
|
var createScript = document.getElementById("create-script-tab");
|
|
|
|
var createScriptLink = document.getElementById("create-script-menu-link");
|
|
|
|
var activeScripts = document.getElementById("active-scripts-tab");
|
|
|
|
var activeScriptsLink = document.getElementById("active-scripts-menu-link");
|
|
|
|
var createProgram = document.getElementById("create-program-tab");
|
|
|
|
var createProgramLink = document.getElementById("create-program-menu-link");
|
|
|
|
var createProgramNot = document.getElementById("create-program-notification");
|
|
|
|
this.classList.toggle("opened");
|
|
|
|
if (terminal.style.maxHeight) {
|
|
|
|
terminal.style.opacity = 0;
|
|
|
|
terminal.style.maxHeight = null;
|
|
|
|
terminalLink.style.opacity = 0;
|
|
|
|
terminalLink.style.maxHeight = null;
|
|
|
|
terminalLink.style.pointerEvents = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
createScript.style.opacity = 0;
|
|
|
|
createScript.style.maxHeight = null;
|
|
|
|
createScriptLink.style.opacity = 0;
|
|
|
|
createScriptLink.style.maxHeight = null;
|
|
|
|
createScriptLink.style.pointerEvents = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
activeScripts.style.opacity = 0;
|
|
|
|
activeScripts.style.maxHeight = null;
|
|
|
|
activeScriptsLink.style.opacity = 0;
|
|
|
|
activeScriptsLink.style.maxHeight = null;
|
|
|
|
activeScriptsLink.style.pointerEvents = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
createProgram.style.opacity = 0;
|
|
|
|
createProgram.style.maxHeight = null;
|
|
|
|
createProgramLink.style.opacity = 0;
|
|
|
|
createProgramLink.style.maxHeight = null;
|
|
|
|
createProgramLink.style.pointerEvents = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
createProgramNot.style.display = "none";
|
|
|
|
} else {
|
|
|
|
terminal.style.maxHeight = terminal.scrollHeight + "px";
|
|
|
|
terminal.style.opacity = 1;
|
|
|
|
terminalLink.style.maxHeight = terminalLink.scrollHeight + "px";
|
|
|
|
terminalLink.style.opacity = 1;
|
|
|
|
terminalLink.style.pointerEvents = "auto";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
createScript.style.maxHeight = createScript.scrollHeight + "px";
|
|
|
|
createScript.style.opacity = 1;
|
|
|
|
createScriptLink.style.maxHeight = createScriptLink.scrollHeight + "px";
|
|
|
|
createScriptLink.style.opacity = 1;
|
|
|
|
createScriptLink.style.pointerEvents = "auto";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
activeScripts.style.maxHeight = activeScripts.scrollHeight + "px";
|
|
|
|
activeScripts.style.opacity = 1;
|
|
|
|
activeScriptsLink.style.maxHeight = activeScriptsLink.scrollHeight + "px";
|
|
|
|
activeScriptsLink.style.opacity = 1;
|
|
|
|
activeScriptsLink.style.pointerEvents = "auto";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
createProgram.style.maxHeight = createProgram.scrollHeight + "px";
|
|
|
|
createProgram.style.opacity = 1;
|
|
|
|
createProgramLink.style.maxHeight = createProgramLink.scrollHeight + "px";
|
|
|
|
createProgramLink.style.opacity = 1;
|
|
|
|
createProgramLink.style.pointerEvents = "auto";
|
|
|
|
createProgramNot.style.display = "block"
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
characterHdr.onclick = function() {
|
|
|
|
var stats = document.getElementById("stats-tab");
|
|
|
|
var statsLink = document.getElementById("stats-menu-link");
|
|
|
|
var factions = document.getElementById("factions-tab");
|
|
|
|
var factionsLink = document.getElementById("factions-menu-link");
|
|
|
|
var augmentations = document.getElementById("augmentations-tab");
|
|
|
|
var augmentationsLink = document.getElementById("augmentations-menu-link");
|
|
|
|
var hacknetnodes = document.getElementById("hacknet-nodes-tab");
|
|
|
|
var hacknetnodesLink = document.getElementById("hacknet-nodes-menu-link");
|
|
|
|
this.classList.toggle("opened");
|
|
|
|
if (stats.style.maxHeight) {
|
|
|
|
stats.style.opacity = 0;
|
|
|
|
stats.style.maxHeight = null;
|
|
|
|
statsLink.style.opacity = 0;
|
|
|
|
statsLink.style.maxHeight = null;
|
|
|
|
statsLink.style.pointerEvents = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
factions.style.opacity = 0;
|
|
|
|
factions.style.maxHeight = null;
|
|
|
|
factionsLink.style.opacity = 0;
|
|
|
|
factionsLink.style.maxHeight = null;
|
|
|
|
factionsLink.style.pointerEvents = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
augmentations.style.opacity = 0;
|
|
|
|
augmentations.style.maxHeight = null;
|
|
|
|
augmentationsLink.style.opacity = 0;
|
|
|
|
augmentationsLink.style.maxHeight = null;
|
|
|
|
augmentationsLink.style.pointerEvents = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
hacknetnodes.style.opacity = 0;
|
|
|
|
hacknetnodes.style.maxHeight = null;
|
|
|
|
hacknetnodesLink.style.opacity = 0;
|
|
|
|
hacknetnodesLink.style.maxHeight = null;
|
|
|
|
hacknetnodesLink.style.pointerEvents = "none";
|
|
|
|
} else {
|
|
|
|
stats.style.maxHeight = stats.scrollHeight + "px";
|
|
|
|
stats.style.opacity = 1;
|
|
|
|
statsLink.style.maxHeight = statsLink.scrollHeight + "px";
|
|
|
|
statsLink.style.opacity = 1;
|
|
|
|
statsLink.style.pointerEvents = "auto";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
factions.style.maxHeight = factions.scrollHeight + "px";
|
|
|
|
factions.style.opacity = 1;
|
|
|
|
factionsLink.style.maxHeight = factionsLink.scrollHeight + "px";
|
|
|
|
factionsLink.style.opacity = 1;
|
|
|
|
factionsLink.style.pointerEvents = "auto";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
augmentations.style.maxHeight = augmentations.scrollHeight + "px";
|
|
|
|
augmentations.style.opacity = 1;
|
|
|
|
augmentationsLink.style.maxHeight = augmentationsLink.scrollHeight + "px";
|
|
|
|
augmentationsLink.style.opacity = 1;
|
|
|
|
augmentationsLink.style.pointerEvents = "auto";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
hacknetnodes.style.maxHeight = hacknetnodes.scrollHeight + "px";
|
|
|
|
hacknetnodes.style.opacity = 1;
|
|
|
|
hacknetnodesLink.style.maxHeight = hacknetnodesLink.scrollHeight + "px";
|
|
|
|
hacknetnodesLink.style.opacity = 1;
|
|
|
|
hacknetnodesLink.style.pointerEvents = "auto";
|
|
|
|
}
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
worldHdr.onclick = function() {
|
|
|
|
var city = document.getElementById("city-tab");
|
|
|
|
var cityLink = document.getElementById("city-menu-link");
|
|
|
|
var travel = document.getElementById("travel-tab");
|
|
|
|
var travelLink = document.getElementById("travel-menu-link");
|
|
|
|
var job = document.getElementById("job-tab");
|
|
|
|
var jobLink = document.getElementById("job-menu-link");
|
|
|
|
this.classList.toggle("opened");
|
|
|
|
if (city.style.maxHeight) {
|
|
|
|
city.style.opacity = 0;
|
|
|
|
city.style.maxHeight = null;
|
|
|
|
cityLink.style.opacity = 0;
|
|
|
|
cityLink.style.maxHeight = null;
|
|
|
|
cityLink.style.pointerEvents = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
travel.style.opacity = 0;
|
|
|
|
travel.style.maxHeight = null;
|
|
|
|
travelLink.style.opacity = 0;
|
|
|
|
travelLink.style.maxHeight = null;
|
|
|
|
travelLink.style.pointerEvents = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
job.style.opacity = 0;
|
|
|
|
job.style.maxHeight = null;
|
|
|
|
jobLink.style.opacity = 0;
|
|
|
|
jobLink.style.maxHeight = null;
|
|
|
|
jobLink.style.pointerEvents = "none";
|
|
|
|
} else {
|
|
|
|
city.style.maxHeight = city.scrollHeight + "px";
|
|
|
|
city.style.opacity = 1;
|
|
|
|
cityLink.style.maxHeight = cityLink.scrollHeight + "px";
|
|
|
|
cityLink.style.opacity = 1;
|
|
|
|
cityLink.style.pointerEvents = "auto";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
travel.style.maxHeight = travel.scrollHeight + "px";
|
|
|
|
travel.style.opacity = 1;
|
|
|
|
travelLink.style.maxHeight = travelLink.scrollHeight + "px";
|
|
|
|
travelLink.style.opacity = 1;
|
|
|
|
travelLink.style.pointerEvents = "auto";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
job.style.maxHeight = job.scrollHeight + "px";
|
|
|
|
job.style.opacity = 1;
|
|
|
|
jobLink.style.maxHeight = jobLink.scrollHeight + "px";
|
|
|
|
jobLink.style.opacity = 1;
|
|
|
|
jobLink.style.pointerEvents = "auto";
|
|
|
|
}
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
helpHdr.onclick = function() {
|
|
|
|
var tutorial = document.getElementById("tutorial-tab");
|
|
|
|
var tutorialLink = document.getElementById("tutorial-menu-link");
|
|
|
|
var options = document.getElementById("options-tab");
|
|
|
|
var optionsLink = document.getElementById("options-menu-link");
|
|
|
|
this.classList.toggle("opened");
|
|
|
|
if (tutorial.style.maxHeight) {
|
|
|
|
tutorial.style.opacity = 0;
|
|
|
|
tutorial.style.maxHeight = null;
|
|
|
|
tutorialLink.style.opacity = 0;
|
|
|
|
tutorialLink.style.maxHeight = null;
|
|
|
|
tutorialLink.style.pointerEvents = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
options.style.opacity = 0;
|
|
|
|
options.style.maxHeight = null;
|
|
|
|
optionsLink.style.opacity = 0;
|
|
|
|
optionsLink.style.maxHeight = null;
|
|
|
|
optionsLink.style.pointerEvents = "none";
|
|
|
|
} else {
|
|
|
|
tutorial.style.maxHeight = tutorial.scrollHeight + "px";
|
|
|
|
tutorial.style.opacity = 1;
|
|
|
|
tutorialLink.style.maxHeight = tutorialLink.scrollHeight + "px";
|
|
|
|
tutorialLink.style.opacity = 1;
|
|
|
|
tutorialLink.style.pointerEvents = "auto";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
options.style.maxHeight = options.scrollHeight + "px";
|
|
|
|
options.style.opacity = 1;
|
|
|
|
optionsLink.style.maxHeight = optionsLink.scrollHeight + "px";
|
|
|
|
optionsLink.style.opacity = 1;
|
|
|
|
optionsLink.style.pointerEvents = "auto";
|
|
|
|
}
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-10-17 10:24:39 +02:00
|
|
|
//Main menu buttons and content
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.terminalMainMenuButton = clearEventListeners("terminal-menu-link");
|
2016-10-17 10:24:39 +02:00
|
|
|
Engine.Clickables.terminalMainMenuButton.addEventListener("click", function() {
|
|
|
|
Engine.loadTerminalContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
Engine.Clickables.characterMainMenuButton = clearEventListeners("stats-menu-link");
|
2016-10-17 10:24:39 +02:00
|
|
|
Engine.Clickables.characterMainMenuButton.addEventListener("click", function() {
|
|
|
|
Engine.loadCharacterContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.scriptEditorMainMenuButton = clearEventListeners("create-script-menu-link");
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.Clickables.scriptEditorMainMenuButton.addEventListener("click", function() {
|
|
|
|
Engine.loadScriptEditorContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.activeScriptsMainMenuButton = clearEventListeners("active-scripts-menu-link");
|
2016-12-19 19:20:19 +01:00
|
|
|
Engine.Clickables.activeScriptsMainMenuButton.addEventListener("click", function() {
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.loadActiveScriptsContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.hacknetNodesMainMenuButton = clearEventListeners("hacknet-nodes-menu-link");
|
2017-04-27 22:02:58 +02:00
|
|
|
Engine.Clickables.hacknetNodesMainMenuButton.addEventListener("click", function() {
|
|
|
|
Engine.loadHacknetNodesContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
Engine.Clickables.worldMainMenuButton = clearEventListeners("city-menu-link");
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.Clickables.worldMainMenuButton.addEventListener("click", function() {
|
|
|
|
Engine.loadWorldContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
Engine.Clickables.travelMainMenuButton = clearEventListeners("travel-menu-link");
|
|
|
|
Engine.Clickables.travelMainMenuButton.addEventListener("click", function() {
|
|
|
|
Engine.loadTravelContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-22 00:54:55 +02:00
|
|
|
Engine.Clickables.jobMainMenuButton = clearEventListeners("job-menu-link");
|
|
|
|
Engine.Clickables.jobMainMenuButton.addEventListener("click", function() {
|
|
|
|
Engine.loadJobContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.createProgramMainMenuButton = clearEventListeners("create-program-menu-link");
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.Clickables.createProgramMainMenuButton.addEventListener("click", function() {
|
|
|
|
Engine.loadCreateProgramContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.factionsMainMenuButton = clearEventListeners("factions-menu-link");
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.Clickables.factionsMainMenuButton.addEventListener("click", function() {
|
|
|
|
Engine.loadFactionsContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.augmentationsMainMenuButton = clearEventListeners("augmentations-menu-link");
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.Clickables.augmentationsMainMenuButton.addEventListener("click", function() {
|
|
|
|
Engine.loadAugmentationsContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
Engine.Clickables.tutorialMainMenuButton = clearEventListeners("tutorial-menu-link");
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.Clickables.tutorialMainMenuButton.addEventListener("click", function() {
|
|
|
|
Engine.loadTutorialContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
//Active scripts list
|
|
|
|
Engine.ActiveScriptsList = document.getElementById("active-scripts-list");
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-08 06:57:40 +02:00
|
|
|
//Save, Delete, Import/Export buttons
|
2016-12-01 23:18:18 +01:00
|
|
|
Engine.Clickables.saveMainMenuButton = document.getElementById("save-game-link");
|
|
|
|
Engine.Clickables.saveMainMenuButton.addEventListener("click", function() {
|
2017-05-05 03:08:44 +02:00
|
|
|
saveObject.saveGame();
|
2017-07-25 03:06:40 +02:00
|
|
|
return false;
|
2016-12-01 23:18:18 +01:00
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-12-01 23:18:18 +01:00
|
|
|
Engine.Clickables.deleteMainMenuButton = document.getElementById("delete-game-link");
|
|
|
|
Engine.Clickables.deleteMainMenuButton.addEventListener("click", function() {
|
2017-05-05 03:08:44 +02:00
|
|
|
saveObject.deleteGame();
|
2016-12-01 23:18:18 +01:00
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-08 06:57:40 +02:00
|
|
|
document.getElementById("export-game-link").addEventListener("click", function() {
|
|
|
|
saveObject.exportGame();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-13 17:58:31 +02:00
|
|
|
//Character Overview buttons
|
|
|
|
document.getElementById("character-overview-save-button").addEventListener("click", function() {
|
2017-05-25 16:50:58 +02:00
|
|
|
saveObject.saveGame();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-13 17:58:31 +02:00
|
|
|
document.getElementById("character-overview-options-button").addEventListener("click", function() {
|
|
|
|
gameOptionsBoxOpen();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 18:52:48 +02:00
|
|
|
//Create Program buttons
|
2017-06-23 16:23:35 +02:00
|
|
|
initCreateProgramButtons();
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-10-17 10:24:39 +02:00
|
|
|
//Message at the top of terminal
|
2017-01-31 04:41:42 +01:00
|
|
|
postNetburnerText();
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-10 22:21:15 +02:00
|
|
|
//Player was working cancel button
|
2017-02-16 19:52:11 +01:00
|
|
|
if (Player.isWorking) {
|
|
|
|
var cancelButton = document.getElementById("work-in-progress-cancel-button");
|
|
|
|
cancelButton.addEventListener("click", function() {
|
2017-04-24 21:10:35 +02:00
|
|
|
if (Player.workType == CONSTANTS.WorkTypeFaction) {
|
2017-04-24 03:43:41 +02:00
|
|
|
var fac = Factions[Player.currentWorkFactionName];
|
|
|
|
Player.finishFactionWork(true, fac);
|
2017-05-15 17:28:59 +02:00
|
|
|
} else if (Player.workType == CONSTANTS.WorkTypeCreateProgram) {
|
2017-04-24 03:43:41 +02:00
|
|
|
Player.finishCreateProgramWork(true, Player.createProgramName);
|
2017-04-24 21:10:35 +02:00
|
|
|
} else if (Player.workType == CONSTANTS.WorkTypeStudyClass) {
|
|
|
|
Player.finishClass();
|
2017-05-10 22:21:15 +02:00
|
|
|
} else if (Player.workType == CONSTANTS.WorkTypeCrime) {
|
|
|
|
Player.finishCrime(true);
|
|
|
|
} else if (Player.workType == CONSTANTS.WorkTypeCompanyPartTime) {
|
|
|
|
Player.finishWorkPartTime();
|
2017-04-24 03:43:41 +02:00
|
|
|
} else {
|
|
|
|
Player.finishWork(true);
|
|
|
|
}
|
2017-02-16 19:52:11 +01:00
|
|
|
});
|
|
|
|
Engine.loadWorkInProgressContent();
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-20 11:27:42 +02:00
|
|
|
//character overview screen
|
|
|
|
document.getElementById("character-overview-container").style.display = "block";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-20 11:27:42 +02:00
|
|
|
//Remove classes from links (they might be set from tutorial)
|
|
|
|
document.getElementById("terminal-menu-link").removeAttribute("class");
|
2017-07-22 00:54:55 +02:00
|
|
|
document.getElementById("stats-menu-link").removeAttribute("class");
|
2017-05-20 11:27:42 +02:00
|
|
|
document.getElementById("create-script-menu-link").removeAttribute("class");
|
|
|
|
document.getElementById("active-scripts-menu-link").removeAttribute("class");
|
|
|
|
document.getElementById("hacknet-nodes-menu-link").removeAttribute("class");
|
2017-07-22 00:54:55 +02:00
|
|
|
document.getElementById("city-menu-link").removeAttribute("class");
|
2017-05-20 11:27:42 +02:00
|
|
|
document.getElementById("tutorial-menu-link").removeAttribute("class");
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-31 17:58:09 +02:00
|
|
|
//DEBUG Delete active Scripts on home
|
2017-05-15 16:15:59 +02:00
|
|
|
document.getElementById("debug-delete-scripts-link").addEventListener("click", function() {
|
2017-05-25 14:18:34 +02:00
|
|
|
console.log("Deleting running scripts on home computer");
|
2017-05-15 16:15:59 +02:00
|
|
|
Player.getHomeComputer().runningScripts = [];
|
2017-05-31 17:58:09 +02:00
|
|
|
dialogBoxCreate("Forcefully deleted all running scripts on home computer. Please save and refresh page");
|
2017-06-08 07:08:53 +02:00
|
|
|
gameOptionsBoxClose();
|
2017-05-31 17:58:09 +02:00
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-31 17:58:09 +02:00
|
|
|
//DEBUG Soft Reset
|
|
|
|
document.getElementById("debug-soft-reset").addEventListener("click", function() {
|
|
|
|
dialogBoxCreate("Soft Reset!");
|
|
|
|
prestigeAugmentation();
|
2017-06-08 07:08:53 +02:00
|
|
|
gameOptionsBoxClose();
|
2017-05-15 16:15:59 +02:00
|
|
|
return false;
|
|
|
|
});
|
2017-05-06 08:24:01 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-06 08:24:01 +02:00
|
|
|
start: function() {
|
2016-10-17 10:24:39 +02:00
|
|
|
//Run main loop
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.idleTimer();
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-02-16 19:52:11 +01:00
|
|
|
//Scripts
|
2017-01-31 04:41:42 +01:00
|
|
|
runScriptsLoop();
|
|
|
|
}
|
2016-10-17 10:24:39 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
window.onload = function() {
|
2017-07-22 00:54:55 +02:00
|
|
|
Engine.displayLoadingScreen();
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.load();
|
2016-10-17 10:24:39 +02:00
|
|
|
};
|