2017-08-30 19:44:29 +02:00
|
|
|
import {formatNumber,
|
2018-06-22 23:30:24 +02:00
|
|
|
convertTimeMsToTimeElapsedString,
|
2018-09-16 10:55:54 +02:00
|
|
|
replaceAt} from "../utils/StringHelperFunctions";
|
2017-08-30 19:44:29 +02:00
|
|
|
import {loxBoxCreate, logBoxUpdateText,
|
2018-09-16 10:55:54 +02:00
|
|
|
logBoxOpened} from "../utils/LogBox";
|
|
|
|
import {updateActiveScriptsItems} from "./ActiveScriptsUI";
|
2019-01-15 14:11:14 +01:00
|
|
|
import { Augmentations } from "./Augmentation/Augmentations";
|
|
|
|
import { installAugmentations,
|
|
|
|
initAugmentations,
|
|
|
|
displayAugmentationsContent,
|
|
|
|
PlayerOwnedAugmentation } from "./Augmentation/AugmentationHelpers";
|
|
|
|
import { AugmentationNames } from "./Augmentation/data/AugmentationNames";
|
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
import {BitNodes, initBitNodes,
|
2019-01-15 14:11:14 +01:00
|
|
|
initBitNodeMultipliers} from "./BitNode/BitNode";
|
2018-09-16 10:55:54 +02:00
|
|
|
import {Bladeburner} from "./Bladeburner";
|
2019-03-14 05:56:48 +01:00
|
|
|
import { CharacterOverviewComponent } from "./ui/React/CharacterOverview";
|
2018-09-16 10:55:54 +02:00
|
|
|
import {cinematicTextFlag} from "./CinematicText";
|
2018-10-27 21:26:22 +02:00
|
|
|
import {generateRandomContract} from "./CodingContractGenerator";
|
2018-11-16 02:28:23 +01:00
|
|
|
import {CompanyPositions} from "./Company/CompanyPositions";
|
|
|
|
import {initCompanies} from "./Company/Companies";
|
2018-12-09 14:36:18 +01:00
|
|
|
import { Corporation } from "./Corporation/Corporation";
|
2018-09-16 10:55:54 +02:00
|
|
|
import {CONSTANTS} from "./Constants";
|
2018-10-23 20:55:42 +02:00
|
|
|
import {createDevMenu, closeDevMenu} from "./DevMenu";
|
2018-12-07 11:54:26 +01:00
|
|
|
import { Factions, initFactions } from "./Faction/Factions";
|
|
|
|
import { displayFactionContent, joinFaction,
|
|
|
|
processPassiveFactionRepGain,
|
|
|
|
inviteToFaction } from "./Faction/FactionHelpers";
|
2019-03-05 02:40:28 +01:00
|
|
|
import { FconfSettings } from "./Fconf/FconfSettings";
|
2018-07-21 06:22:04 +02:00
|
|
|
import {displayLocationContent,
|
2018-09-16 10:55:54 +02:00
|
|
|
initLocationButtons} from "./Location";
|
|
|
|
import {Locations} from "./Locations";
|
2017-08-30 19:44:29 +02:00
|
|
|
import {displayHacknetNodesContent, processAllHacknetNodeEarnings,
|
2018-09-16 10:55:54 +02:00
|
|
|
updateHacknetNodesContent} from "./HacknetNode";
|
|
|
|
import {iTutorialStart} from "./InteractiveTutorial";
|
|
|
|
import {initLiterature} from "./Literature";
|
2019-03-05 02:40:28 +01:00
|
|
|
import { checkForMessagesToSend, initMessages } from "./Message/MessageHelpers";
|
2018-09-16 10:55:54 +02:00
|
|
|
import {inMission, currMission} from "./Missions";
|
2017-09-01 16:12:40 +02:00
|
|
|
import {initSingularitySFFlags,
|
2018-09-16 10:55:54 +02:00
|
|
|
hasSingularitySF, hasCorporationSF} from "./NetscriptFunctions";
|
2017-08-30 19:44:29 +02:00
|
|
|
import {updateOnlineScriptTimes,
|
2018-09-16 10:55:54 +02:00
|
|
|
runScriptsLoop} from "./NetscriptWorker";
|
|
|
|
import {Player} from "./Player";
|
2017-08-30 19:44:29 +02:00
|
|
|
import {prestigeAugmentation,
|
2018-09-16 10:55:54 +02:00
|
|
|
prestigeSourceFile} from "./Prestige";
|
2018-12-25 11:14:18 +01:00
|
|
|
import { Programs } from "./Programs/Programs";
|
|
|
|
import { displayCreateProgramContent,
|
|
|
|
getNumAvailableCreateProgram,
|
|
|
|
initCreateProgramButtons } from "./Programs/ProgramHelpers";
|
2018-09-16 10:55:54 +02:00
|
|
|
import {redPillFlag, hackWorldDaemon} from "./RedPill";
|
|
|
|
import {saveObject, loadGame} from "./SaveObject";
|
2019-01-27 23:08:45 +01:00
|
|
|
import { getCurrentEditor,
|
|
|
|
loadAllRunningScripts,
|
|
|
|
scriptEditorInit,
|
2019-03-05 02:40:28 +01:00
|
|
|
updateScriptEditorContent } from "./Script/ScriptHelpers";
|
2019-03-13 23:17:30 +01:00
|
|
|
import { AllServers,
|
|
|
|
initForeignServers } from "./Server/AllServers";
|
2019-03-13 23:19:29 +01:00
|
|
|
|
2019-03-05 02:40:28 +01:00
|
|
|
import { Server } from "./Server/Server";
|
2019-01-27 23:08:45 +01:00
|
|
|
import {Settings} from "./Settings/Settings";
|
2019-01-17 20:10:35 +01:00
|
|
|
import { initSourceFiles, SourceFiles } from "./SourceFile";
|
|
|
|
import { updateSourceFileFlags } from "./SourceFile/SourceFileFlags";
|
2019-03-05 02:40:28 +01:00
|
|
|
import {SpecialServerIps, initSpecialServerIps} from "./Server/SpecialServerIps";
|
2017-08-30 19:44:29 +02:00
|
|
|
import {StockMarket, StockSymbols,
|
|
|
|
SymbolToStockMap, initStockSymbols,
|
|
|
|
initSymbolToStockMap, stockMarketCycle,
|
2018-10-30 22:02:16 +01:00
|
|
|
processStockPrices,
|
2019-01-09 01:42:39 +01:00
|
|
|
displayStockMarketContent} from "./StockMarket/StockMarket";
|
2018-09-16 10:55:54 +02:00
|
|
|
import {Terminal, postNetburnerText} from "./Terminal";
|
2019-01-18 18:57:21 +01:00
|
|
|
|
2019-01-20 23:57:38 +01:00
|
|
|
import { Sleeve } from "./PersonObjects/Sleeve/Sleeve";
|
|
|
|
import { clearSleevesPage,
|
|
|
|
createSleevesPage,
|
|
|
|
updateSleevesPage } from "./PersonObjects/Sleeve/SleeveUI";
|
2019-01-18 18:57:21 +01:00
|
|
|
import { clearResleevesPage,
|
|
|
|
createResleevesPage } from "./PersonObjects/Resleeving/ResleevingUI";
|
|
|
|
|
|
|
|
import { createStatusText } from "./ui/createStatusText";
|
2019-02-22 03:26:28 +01:00
|
|
|
import { displayCharacterInfo } from "./ui/displayCharacterInfo";
|
2018-09-16 10:55:54 +02:00
|
|
|
import {Page, routing} from "./ui/navigationTracking";
|
2019-01-18 18:57:21 +01:00
|
|
|
import {numeralWrapper} from "./ui/numeralFormat";
|
|
|
|
import {setSettingsLabels} from "./ui/setSettingsLabels";
|
|
|
|
import { initializeMainMenuHeaders } from "./ui/MainMenu/Headers";
|
|
|
|
import { initializeMainMenuLinks,
|
|
|
|
MainMenuLinks } from "./ui/MainMenu/Links";
|
|
|
|
|
|
|
|
|
|
|
|
import { dialogBoxCreate} from "../utils/DialogBox";
|
|
|
|
import { gameOptionsBoxClose,
|
|
|
|
gameOptionsBoxOpen } from "../utils/GameOptions";
|
|
|
|
import { getRandomInt } from "../utils/helpers/getRandomInt";
|
|
|
|
import { removeChildrenFromElement } from "../utils/uiHelpers/removeChildrenFromElement";
|
|
|
|
import { clearEventListeners } from "../utils/uiHelpers/clearEventListeners";
|
|
|
|
import { createElement } from "../utils/uiHelpers/createElement";
|
|
|
|
import { exceptionAlert } from "../utils/helpers/exceptionAlert";
|
|
|
|
import { removeLoadingScreen } from "../utils/uiHelpers/removeLoadingScreen";
|
|
|
|
import {KEY} from "../utils/helpers/keyCodes";
|
|
|
|
|
2019-03-14 05:56:48 +01:00
|
|
|
import React from "react";
|
|
|
|
import ReactDOM from "react-dom";
|
2017-08-30 19:44:29 +02:00
|
|
|
|
2018-07-11 17:19:36 +02:00
|
|
|
// These should really be imported with the module that is presenting that UI, but because they very much depend on the
|
|
|
|
// cascade order, we'll pull them all in here.
|
2018-09-25 19:18:06 +02:00
|
|
|
import 'normalize.css';
|
2018-07-13 22:13:49 +02:00
|
|
|
import "../css/styles.scss";
|
2018-12-22 11:27:04 +01:00
|
|
|
import "../css/tooltips.scss";
|
2018-09-25 19:18:06 +02:00
|
|
|
import "../css/buttons.scss";
|
|
|
|
import "../css/mainmenu.scss";
|
2018-11-01 19:18:32 +01:00
|
|
|
import "../css/characteroverview.scss";
|
2018-07-13 22:13:49 +02:00
|
|
|
import "../css/terminal.scss";
|
2019-01-27 23:08:45 +01:00
|
|
|
import "../css/scripteditor.scss";
|
2018-07-13 22:13:49 +02:00
|
|
|
import "../css/menupages.scss";
|
2019-01-18 19:04:04 +01:00
|
|
|
import "../css/redpill.scss";
|
2019-01-09 11:06:49 +01:00
|
|
|
import "../css/stockmarket.scss";
|
2018-07-13 22:13:49 +02:00
|
|
|
import "../css/workinprogress.scss";
|
|
|
|
import "../css/popupboxes.scss";
|
2018-12-31 01:11:48 +01:00
|
|
|
import "../css/gameoptions.scss";
|
2018-07-13 22:13:49 +02:00
|
|
|
import "../css/interactivetutorial.scss";
|
|
|
|
import "../css/loader.scss";
|
|
|
|
import "../css/missions.scss";
|
|
|
|
import "../css/companymanagement.scss";
|
|
|
|
import "../css/bladeburner.scss";
|
2018-10-23 20:55:42 +02:00
|
|
|
import "../css/gang.scss";
|
2019-01-20 23:57:38 +01:00
|
|
|
import "../css/sleeves.scss";
|
|
|
|
import "../css/resleeving.scss";
|
2018-12-16 00:31:21 +01:00
|
|
|
import "../css/treant.css";
|
2019-03-22 04:15:28 +01:00
|
|
|
import "../css/grid.min.css";
|
|
|
|
import "../css/dev-menu.css";
|
2018-07-11 17:19:36 +02:00
|
|
|
|
2018-12-31 01:11:48 +01:00
|
|
|
|
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) {
|
2018-05-06 22:27:47 +02:00
|
|
|
if (Settings.DisableHotkeys === true) {return;}
|
2019-01-27 23:08:45 +01:00
|
|
|
|
|
|
|
// These hotkeys should be disabled if the player is writing scripts
|
|
|
|
try {
|
|
|
|
if (getCurrentEditor().isFocused()) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
} catch(e) {}
|
|
|
|
|
2018-05-02 19:38:11 +02:00
|
|
|
if (!Player.isWorking && !redPillFlag && !inMission && !cinematicTextFlag) {
|
2017-07-22 00:54:55 +02:00
|
|
|
if (e.keyCode == 84 && e.altKey) {
|
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadTerminalContent();
|
2018-05-06 22:27:47 +02:00
|
|
|
} else if (e.keyCode === KEY.C && e.altKey) {
|
2017-07-22 00:54:55 +02:00
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadCharacterContent();
|
2018-05-06 22:27:47 +02:00
|
|
|
} else if (e.keyCode === KEY.E && e.altKey) {
|
2017-07-22 00:54:55 +02:00
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadScriptEditorContent();
|
2018-05-06 22:27:47 +02:00
|
|
|
} else if (e.keyCode === KEY.S && e.altKey) {
|
2017-07-22 00:54:55 +02:00
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadActiveScriptsContent();
|
2018-05-06 22:27:47 +02:00
|
|
|
} else if (e.keyCode === KEY.H && e.altKey) {
|
2017-07-22 00:54:55 +02:00
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadHacknetNodesContent();
|
2018-05-06 22:27:47 +02:00
|
|
|
} else if (e.keyCode === KEY.W && e.altKey) {
|
2017-07-22 00:54:55 +02:00
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadWorldContent();
|
2018-05-06 22:27:47 +02:00
|
|
|
} else if (e.keyCode === KEY.J && e.altKey) {
|
2017-07-22 00:54:55 +02:00
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadJobContent();
|
2018-05-06 22:27:47 +02:00
|
|
|
} else if (e.keyCode === KEY.R && e.altKey) {
|
2017-07-22 00:54:55 +02:00
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadTravelContent();
|
2018-05-06 22:27:47 +02:00
|
|
|
} else if (e.keyCode === KEY.P && e.altKey) {
|
2017-07-22 00:54:55 +02:00
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadCreateProgramContent();
|
2018-05-06 22:27:47 +02:00
|
|
|
} else if (e.keyCode === KEY.F && e.altKey) {
|
2018-03-12 20:39:04 +01:00
|
|
|
//Overriden by Fconf
|
2018-07-20 03:51:18 +02:00
|
|
|
if (routing.isOn(Page.Terminal) && FconfSettings.ENABLE_BASH_HOTKEYS) {
|
2018-03-12 20:39:04 +01:00
|
|
|
return;
|
|
|
|
}
|
2017-07-22 00:54:55 +02:00
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadFactionsContent();
|
2018-05-06 22:27:47 +02:00
|
|
|
} else if (e.keyCode === KEY.A && e.altKey) {
|
2017-07-22 00:54:55 +02:00
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadAugmentationsContent();
|
2018-05-06 22:27:47 +02:00
|
|
|
} else if (e.keyCode === KEY.U && e.altKey) {
|
2017-07-22 00:54:55 +02:00
|
|
|
e.preventDefault();
|
|
|
|
Engine.loadTutorialContent();
|
2017-07-25 03:06:40 +02:00
|
|
|
}
|
2017-07-22 00:54:55 +02:00
|
|
|
}
|
|
|
|
|
2018-05-06 22:27:47 +02:00
|
|
|
if (e.keyCode === KEY.O && e.altKey) {
|
2017-07-22 00:54:55 +02:00
|
|
|
e.preventDefault();
|
|
|
|
gameOptionsBoxOpen();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
2018-09-06 18:07:59 +02:00
|
|
|
const 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
|
|
|
saveMainMenuButton: null,
|
|
|
|
deleteMainMenuButton: 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,
|
2018-05-02 19:38:11 +02:00
|
|
|
cinematicTextContent: null,
|
2017-09-21 23:27:31 +02:00
|
|
|
missionContent: 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,
|
2016-10-17 10:24:39 +02: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();
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.terminalContent.style.display = "block";
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.Terminal);
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Terminal.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();
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.characterContent.style.display = "block";
|
2019-02-22 03:26:28 +01:00
|
|
|
Engine.updateCharacterInfo();
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.CharacterInfo);
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Stats.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();
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.scriptEditorContent.style.display = "block";
|
2019-01-27 23:08:45 +01:00
|
|
|
try {
|
|
|
|
getCurrentEditor().openScript(filename, code);
|
|
|
|
} catch(e) {
|
|
|
|
exceptionAlert(e);
|
2017-01-31 04:41:42 +01:00
|
|
|
}
|
2019-01-27 23:08:45 +01:00
|
|
|
|
2017-08-30 19:44:29 +02:00
|
|
|
updateScriptEditorContent();
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.ScriptEditor);
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.ScriptEditor.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();
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.activeScriptsContent.style.display = "block";
|
2017-09-26 04:44:33 +02:00
|
|
|
updateActiveScriptsItems();
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.ActiveScripts);
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.ActiveScripts.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();
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.hacknetNodesContent.style.display = "block";
|
2017-04-27 22:02:58 +02:00
|
|
|
displayHacknetNodesContent();
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.HacknetNodes);
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.HacknetNodes.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();
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.worldContent.style.display = "block";
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.displayWorldInfo();
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.World);
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.City.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();
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.createProgramContent.style.display = "block";
|
2017-02-28 22:20:37 +01:00
|
|
|
displayCreateProgramContent();
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.CreateProgram);
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.CreateProgram.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();
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.factionsContent.style.display = "block";
|
2017-02-20 23:45:36 +01:00
|
|
|
Engine.displayFactionsInfo();
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.Factions);
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Factions.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();
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.factionContent.style.display = "block";
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.Faction);
|
2017-01-28 04:10:16 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
loadAugmentationsContent: function() {
|
|
|
|
Engine.hideAllContent();
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.augmentationsContent.style.display = "block";
|
2019-01-03 09:39:32 +01:00
|
|
|
displayAugmentationsContent(Engine.Display.augmentationsContent);
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.Augmentations);
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Augmentations.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();
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.tutorialContent.style.display = "block";
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.Tutorial);
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Tutorial.classList.add("active");
|
2017-01-31 04:41:42 +01:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2018-06-11 19:41:02 +02:00
|
|
|
loadDevMenuContent: function() {
|
|
|
|
Engine.hideAllContent();
|
2018-10-23 20:55:42 +02:00
|
|
|
createDevMenu();
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.DevMenu);
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.DevMenu.classList.add("active");
|
2018-06-11 19:41:02 +02:00
|
|
|
},
|
|
|
|
|
2017-01-31 04:41:42 +01:00
|
|
|
loadLocationContent: function() {
|
|
|
|
Engine.hideAllContent();
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.locationContent.style.display = "block";
|
2018-11-18 01:23:48 +01:00
|
|
|
try {
|
|
|
|
displayLocationContent();
|
|
|
|
} catch(e) {
|
|
|
|
exceptionAlert(e);
|
|
|
|
console.error(e);
|
|
|
|
}
|
|
|
|
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.Location);
|
2017-01-31 04:41:42 +01:00
|
|
|
},
|
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");
|
2017-11-09 02:55:21 +01:00
|
|
|
//mainMenu.style.visibility = "hidden";
|
2017-02-08 01:27:11 +01:00
|
|
|
mainMenu.style.visibility = "hidden";
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.workInProgressContent.style.display = "block";
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(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";
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.redPillContent.style.display = "block";
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.RedPill);
|
2017-07-05 06:02:19 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2018-05-02 19:38:11 +02:00
|
|
|
loadCinematicTextContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
var mainMenu = document.getElementById("mainmenu-container");
|
|
|
|
mainMenu.style.visibility = "hidden";
|
|
|
|
Engine.Display.cinematicTextContent.style.display = "block";
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.CinematicText);
|
2018-05-02 19:38:11 +02:00
|
|
|
},
|
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
loadInfiltrationContent: function() {
|
|
|
|
Engine.hideAllContent();
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.infiltrationContent.style.display = "block";
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.Infiltration);
|
2017-07-03 21:42:11 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
loadStockMarketContent: function() {
|
|
|
|
Engine.hideAllContent();
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.stockMarketContent.style.display = "block";
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.StockMarket);
|
2017-10-25 21:47:47 +02:00
|
|
|
displayStockMarketContent();
|
2017-07-03 21:42:11 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-08-13 07:01:33 +02:00
|
|
|
loadGangContent: function() {
|
|
|
|
Engine.hideAllContent();
|
2017-08-30 19:44:29 +02:00
|
|
|
if (document.getElementById("gang-container") || Player.inGang()) {
|
2018-10-23 20:55:42 +02:00
|
|
|
Player.gang.displayGangContent(Player);
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.Gang);
|
2017-08-13 07:01:33 +02:00
|
|
|
} else {
|
|
|
|
Engine.loadTerminalContent();
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.Terminal);
|
2017-08-13 07:01:33 +02:00
|
|
|
}
|
2017-09-21 23:27:31 +02:00
|
|
|
},
|
2017-08-13 07:01:33 +02:00
|
|
|
|
2017-09-21 23:27:31 +02:00
|
|
|
loadMissionContent: function() {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
document.getElementById("mainmenu-container").style.visibility = "hidden";
|
|
|
|
document.getElementById("character-overview-wrapper").style.visibility = "hidden";
|
2017-11-09 03:53:40 +01:00
|
|
|
Engine.Display.missionContent.style.display = "block";
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.Mission);
|
2017-08-13 07:01:33 +02:00
|
|
|
},
|
|
|
|
|
2017-12-02 04:50:08 +01:00
|
|
|
loadCorporationContent: function() {
|
|
|
|
if (Player.corporation instanceof Corporation) {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
document.getElementById("character-overview-wrapper").style.visibility = "hidden";
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.Corporation);
|
2019-03-13 23:17:30 +01:00
|
|
|
Player.corporation.createUI();
|
2017-12-02 04:50:08 +01:00
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2018-05-02 19:38:11 +02:00
|
|
|
loadBladeburnerContent: function() {
|
|
|
|
if (Player.bladeburner instanceof Bladeburner) {
|
|
|
|
try {
|
|
|
|
Engine.hideAllContent();
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(Page.Bladeburner);
|
2018-05-02 19:38:11 +02:00
|
|
|
Player.bladeburner.createContent();
|
|
|
|
} catch(e) {
|
|
|
|
exceptionAlert(e);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2019-01-17 16:40:43 +01:00
|
|
|
loadSleevesContent: function() {
|
2019-01-18 18:57:21 +01:00
|
|
|
// This is for Duplicate Sleeves page, not Re-sleeving @ Vita Life
|
2019-01-20 23:57:38 +01:00
|
|
|
try {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
routing.navigateTo(Page.Sleeves);
|
|
|
|
createSleevesPage(Player);
|
|
|
|
} catch(e) {
|
|
|
|
exceptionAlert(e);
|
|
|
|
}
|
2019-01-18 18:57:21 +01:00
|
|
|
},
|
2019-01-17 16:40:43 +01:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
loadResleevingContent: function() {
|
|
|
|
try {
|
|
|
|
Engine.hideAllContent();
|
|
|
|
routing.navigateTo(Page.Resleeves);
|
|
|
|
createResleevesPage(Player);
|
|
|
|
} catch(e) {
|
|
|
|
exceptionAlert(e);
|
|
|
|
}
|
2019-01-17 16:40:43 +01:00
|
|
|
},
|
|
|
|
|
2017-07-25 03:06:40 +02:00
|
|
|
//Helper function that hides all content
|
2016-10-17 10:24:39 +02:00
|
|
|
hideAllContent: function() {
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.terminalContent.style.display = "none";
|
|
|
|
Engine.Display.characterContent.style.display = "none";
|
|
|
|
Engine.Display.scriptEditorContent.style.display = "none";
|
|
|
|
Engine.Display.activeScriptsContent.style.display = "none";
|
|
|
|
Engine.Display.hacknetNodesContent.style.display = "none";
|
|
|
|
Engine.Display.worldContent.style.display = "none";
|
|
|
|
Engine.Display.createProgramContent.style.display = "none";
|
|
|
|
Engine.Display.factionsContent.style.display = "none";
|
|
|
|
Engine.Display.factionContent.style.display = "none";
|
|
|
|
Engine.Display.factionAugmentationsContent.style.display = "none";
|
|
|
|
Engine.Display.augmentationsContent.style.display = "none";
|
|
|
|
Engine.Display.tutorialContent.style.display = "none";
|
|
|
|
Engine.Display.locationContent.style.display = "none";
|
|
|
|
Engine.Display.workInProgressContent.style.display = "none";
|
|
|
|
Engine.Display.redPillContent.style.display = "none";
|
2018-05-02 19:38:11 +02:00
|
|
|
Engine.Display.cinematicTextContent.style.display = "none";
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.infiltrationContent.style.display = "none";
|
|
|
|
Engine.Display.stockMarketContent.style.display = "none";
|
|
|
|
Engine.Display.missionContent.style.display = "none";
|
|
|
|
if (document.getElementById("gang-container")) {
|
|
|
|
document.getElementById("gang-container").style.display = "none";
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2018-10-23 20:55:42 +02:00
|
|
|
if (Player.inGang()) {
|
|
|
|
Player.gang.clearUI();
|
|
|
|
}
|
2017-12-02 04:50:08 +01:00
|
|
|
if (Player.corporation instanceof Corporation) {
|
|
|
|
Player.corporation.clearUI();
|
|
|
|
}
|
|
|
|
|
2018-05-02 19:38:11 +02:00
|
|
|
if (Player.bladeburner instanceof Bladeburner) {
|
|
|
|
Player.bladeburner.clearContent();
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:57:38 +01:00
|
|
|
clearResleevesPage();
|
|
|
|
clearSleevesPage();
|
|
|
|
|
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
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Terminal.classList.remove("active");
|
|
|
|
MainMenuLinks.ScriptEditor.classList.remove("active");
|
|
|
|
MainMenuLinks.ActiveScripts.classList.remove("active");
|
|
|
|
MainMenuLinks.CreateProgram.classList.remove("active");
|
|
|
|
MainMenuLinks.Stats.classList.remove("active");
|
|
|
|
MainMenuLinks.Factions.classList.remove("active");
|
|
|
|
MainMenuLinks.Augmentations.classList.remove("active");
|
|
|
|
MainMenuLinks.HacknetNodes.classList.remove("active");
|
2019-01-30 07:02:27 +01:00
|
|
|
MainMenuLinks.Sleeves.classList.remove("active");
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.City.classList.remove("active");
|
|
|
|
MainMenuLinks.Travel.classList.remove("active");
|
|
|
|
MainMenuLinks.Job.classList.remove("active");
|
|
|
|
MainMenuLinks.StockMarket.classList.remove("active");
|
|
|
|
MainMenuLinks.Bladeburner.classList.remove("active");
|
|
|
|
MainMenuLinks.Corporation.classList.remove("active");
|
|
|
|
MainMenuLinks.Gang.classList.remove("active");
|
|
|
|
MainMenuLinks.Tutorial.classList.remove("active");
|
|
|
|
MainMenuLinks.Options.classList.remove("active");
|
|
|
|
MainMenuLinks.DevMenu.classList.remove("active");
|
2018-10-23 20:55:42 +02:00
|
|
|
|
|
|
|
// Close dev menu
|
|
|
|
closeDevMenu();
|
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() {
|
2019-03-14 05:56:48 +01:00
|
|
|
ReactDOM.render(<CharacterOverviewComponent />, document.getElementById('character-overview-text'));
|
2018-08-29 17:12:33 +02:00
|
|
|
|
2018-07-25 06:56:52 +02:00
|
|
|
const save = document.getElementById("character-overview-save-button");
|
|
|
|
const flashClass = "flashing-button";
|
2018-08-29 17:12:33 +02:00
|
|
|
if(!Settings.AutosaveInterval) {
|
2018-07-25 06:56:52 +02:00
|
|
|
save.classList.add(flashClass);
|
|
|
|
} else {
|
|
|
|
save.classList.remove(flashClass);
|
|
|
|
}
|
2017-05-20 09:33:33 +02:00
|
|
|
},
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2016-10-17 10:24:39 +02:00
|
|
|
/* Display character info */
|
2019-02-22 03:26:28 +01:00
|
|
|
updateCharacterInfo: function() {
|
|
|
|
displayCharacterInfo(Engine.Display.characterInfo, Player);
|
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) {
|
|
|
|
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";
|
2017-12-02 04:50:08 +01:00
|
|
|
|
2018-01-20 05:47:57 +01:00
|
|
|
//City hall only in BitNode-3/with Source-File 3
|
2018-03-03 22:05:33 +01:00
|
|
|
if ((Player.bitNodeN === 3 || hasCorporationSF) && Player.bitNodeN !== 8) {
|
2017-12-02 04:50:08 +01:00
|
|
|
document.getElementById("sector12-cityhall-li").style.display = "block";
|
|
|
|
} else {
|
|
|
|
document.getElementById("sector12-cityhall-li").style.display = "none";
|
|
|
|
}
|
2017-01-31 04:41:42 +01:00
|
|
|
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
|
|
|
|
2018-03-27 02:46:21 +02:00
|
|
|
//Generic Locations (common to every city):
|
|
|
|
// World Stock Exchange
|
|
|
|
// Corporation (if applicable)
|
2018-06-03 03:37:56 +02:00
|
|
|
// Bladeburner HQ (if applicable);
|
2017-12-02 04:50:08 +01:00
|
|
|
var genericLocationsList = document.getElementById("generic-locations-list");
|
|
|
|
genericLocationsList.style.display = "inline";
|
2018-03-27 02:46:21 +02:00
|
|
|
removeChildrenFromElement(genericLocationsList);
|
|
|
|
var li = createElement("li");
|
|
|
|
li.appendChild(createElement("a", {
|
|
|
|
innerText:"World Stock Exchange", class:"a-link-button",
|
|
|
|
clickListener:()=>{
|
|
|
|
Player.location = Locations.WorldStockExchange;
|
|
|
|
Engine.loadStockMarketContent();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
genericLocationsList.appendChild(li);
|
|
|
|
|
2017-12-02 04:50:08 +01:00
|
|
|
if (Player.corporation instanceof Corporation && document.getElementById("location-corporation-button") == null) {
|
2018-03-27 02:46:21 +02:00
|
|
|
var li = createElement("li");
|
2017-12-02 04:50:08 +01:00
|
|
|
li.appendChild(createElement("a", {
|
|
|
|
innerText:Player.corporation.name, id:"location-corporation-button",
|
|
|
|
class:"a-link-button",
|
|
|
|
clickListener:()=>{
|
|
|
|
Engine.loadCorporationContent();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
genericLocationsList.appendChild(li);
|
|
|
|
}
|
2018-06-03 03:37:56 +02:00
|
|
|
|
|
|
|
if (Player.bladeburner instanceof Bladeburner) {
|
|
|
|
var li = createElement("li");
|
|
|
|
li.appendChild(createElement("a", {
|
|
|
|
innerText:"Bladeburner Headquarters", class:"a-link-button",
|
|
|
|
clickListener:()=>{
|
|
|
|
Engine.loadBladeburnerContent();
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
genericLocationsList.appendChild(li);
|
|
|
|
}
|
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() {
|
2018-03-27 02:46:21 +02:00
|
|
|
removeChildrenFromElement(Engine.Display.factionsContent);
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2018-03-27 02:46:21 +02:00
|
|
|
//Factions
|
|
|
|
Engine.Display.factionsContent.appendChild(createElement("h1", {
|
|
|
|
innerText:"Factions"
|
|
|
|
}));
|
|
|
|
Engine.Display.factionsContent.appendChild(createElement("p", {
|
|
|
|
innerText:"Lists all factions you have joined"
|
|
|
|
}));
|
|
|
|
var factionsList = createElement("ul");
|
|
|
|
Engine.Display.factionsContent.appendChild(createElement("br"));
|
|
|
|
|
|
|
|
//Add a button 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
|
|
|
|
2018-03-27 02:46:21 +02:00
|
|
|
factionsList.appendChild(createElement("a", {
|
|
|
|
class:"a-link-button", innerText:factionName, padding:"4px", margin:"4px",
|
|
|
|
display:"inline-block",
|
|
|
|
clickListener:()=>{
|
|
|
|
Engine.loadFactionContent();
|
|
|
|
displayFactionContent(factionName);
|
|
|
|
return false;
|
|
|
|
}
|
|
|
|
}));
|
|
|
|
factionsList.appendChild(createElement("br"));
|
2017-05-04 21:29:50 +02:00
|
|
|
}()); //Immediate invocation
|
2017-02-20 23:45:36 +01:00
|
|
|
}
|
2018-03-27 02:46:21 +02:00
|
|
|
Engine.Display.factionsContent.appendChild(factionsList);
|
|
|
|
Engine.Display.factionsContent.appendChild(createElement("br"));
|
2017-07-27 04:56:14 +02:00
|
|
|
|
2018-03-27 02:46:21 +02:00
|
|
|
//Invited Factions
|
|
|
|
Engine.Display.factionsContent.appendChild(createElement("h1", {
|
|
|
|
innerText:"Outstanding Faction Invitations"
|
|
|
|
}));
|
|
|
|
Engine.Display.factionsContent.appendChild(createElement("p", {
|
|
|
|
width:"70%",
|
|
|
|
innerText:"Lists factions you have been invited to, as well as " +
|
|
|
|
"factions you have previously rejected. You can accept " +
|
|
|
|
"these faction invitations at any time."
|
|
|
|
}));
|
|
|
|
var invitationsList = createElement("ul");
|
2017-07-27 04:56:14 +02:00
|
|
|
|
2018-03-27 02:46:21 +02:00
|
|
|
//Add a button to accept for each faction you have invitiations for
|
2017-07-27 04:56:14 +02:00
|
|
|
for (var i = 0; i < Player.factionInvitations.length; ++i) {
|
|
|
|
(function () {
|
|
|
|
var factionName = Player.factionInvitations[i];
|
|
|
|
|
2018-03-27 02:46:21 +02:00
|
|
|
var item = createElement("li", {padding:"6px", margin:"6px"});
|
|
|
|
item.appendChild(createElement("p", {
|
|
|
|
innerText:factionName, display:"inline", margin:"4px", padding:"4px"
|
|
|
|
}));
|
|
|
|
item.appendChild(createElement("a", {
|
|
|
|
innerText:"Accept Faction Invitation",
|
|
|
|
class:"a-link-button", display:"inline", margin:"4px", padding:"4px",
|
2019-02-22 20:43:59 +01:00
|
|
|
clickListener: (e) => {
|
|
|
|
if (!e.isTrusted) { return false; }
|
2018-03-27 02:46:21 +02:00
|
|
|
joinFaction(Factions[factionName]);
|
|
|
|
for (var i = 0; i < Player.factionInvitations.length; ++i) {
|
2018-05-27 07:48:10 +02:00
|
|
|
if (Player.factionInvitations[i] == factionName || Factions[Player.factionInvitations[i]].isBanned) {
|
2018-03-27 02:46:21 +02:00
|
|
|
Player.factionInvitations.splice(i, 1);
|
2018-05-27 07:48:10 +02:00
|
|
|
i--;
|
2018-03-27 02:46:21 +02:00
|
|
|
}
|
2017-07-27 04:56:14 +02:00
|
|
|
}
|
2018-03-27 02:46:21 +02:00
|
|
|
Engine.displayFactionsInfo();
|
|
|
|
return false;
|
2017-07-27 04:56:14 +02:00
|
|
|
}
|
2018-03-27 02:46:21 +02:00
|
|
|
}));
|
2017-07-27 04:56:14 +02:00
|
|
|
|
|
|
|
invitationsList.appendChild(item);
|
|
|
|
}());
|
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2018-03-27 02:46:21 +02:00
|
|
|
Engine.Display.factionsContent.appendChild(invitationsList);
|
2017-02-20 23:45:36 +01:00
|
|
|
},
|
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
|
|
|
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;}
|
2018-06-22 21:38:25 +02:00
|
|
|
if (Player.playtimeSinceLastBitnode == null) {Player.playtimeSinceLastBitnode = 0;}
|
2017-05-15 16:15:59 +02:00
|
|
|
Player.totalPlaytime += time;
|
2017-06-17 19:47:04 +02:00
|
|
|
Player.playtimeSinceLastAug += time;
|
2018-06-22 21:38:25 +02:00
|
|
|
Player.playtimeSinceLastBitnode += time;
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
//Start Manual hack
|
2018-08-30 19:00:38 +02:00
|
|
|
if (Terminal.actionStarted === true) {
|
|
|
|
Engine._totalActionTime = Terminal.actionTime;
|
|
|
|
Engine._actionTimeLeft = Terminal.actionTime;
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine._actionInProgress = true;
|
|
|
|
Engine._actionProgressBarCount = 1;
|
|
|
|
Engine._actionProgressStr = "[ ]";
|
|
|
|
Engine._actionTimeStr = "Time left: ";
|
2018-08-30 19:00:38 +02:00
|
|
|
Terminal.actionStarted = false;
|
2017-01-31 04:41:42 +01:00
|
|
|
}
|
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
|
|
|
|
2018-10-30 22:02:16 +01:00
|
|
|
// Update stock prices
|
|
|
|
if (Player.hasWseAccount) {
|
|
|
|
processStockPrices(numCycles);
|
|
|
|
}
|
|
|
|
|
2017-08-13 07:01:33 +02:00
|
|
|
//Gang, if applicable
|
|
|
|
if (Player.bitNodeN == 2 && Player.inGang()) {
|
2018-10-23 20:55:42 +02:00
|
|
|
Player.gang.process(numCycles, Player);
|
2017-08-13 07:01:33 +02:00
|
|
|
}
|
|
|
|
|
2017-09-27 17:13:42 +02:00
|
|
|
//Mission
|
2017-09-25 14:50:19 +02:00
|
|
|
if (inMission && currMission) {
|
|
|
|
currMission.process(numCycles);
|
|
|
|
}
|
|
|
|
|
2017-12-02 04:50:08 +01:00
|
|
|
//Corporation
|
|
|
|
if (Player.corporation instanceof Corporation) {
|
2018-03-12 20:39:04 +01:00
|
|
|
//Stores cycles in a "buffer". Processed separately using Engine Counters
|
|
|
|
//This is to avoid constant DOM redraws when Corporation is catching up
|
|
|
|
Player.corporation.storeCycles(numCycles);
|
2017-12-02 04:50:08 +01:00
|
|
|
}
|
|
|
|
|
2018-05-02 19:38:11 +02:00
|
|
|
if (Player.bladeburner instanceof Bladeburner) {
|
|
|
|
Player.bladeburner.storeCycles(numCycles);
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:57:38 +01:00
|
|
|
// Sleeves
|
|
|
|
for (let i = 0; i < Player.sleeves.length; ++i) {
|
|
|
|
if (Player.sleeves[i] instanceof Sleeve) {
|
|
|
|
const expForOtherSleeves = Player.sleeves[i].process(Player, numCycles);
|
|
|
|
|
|
|
|
// This sleeve earns experience for other sleeves
|
|
|
|
if (expForOtherSleeves == null) { continue; }
|
|
|
|
for (let j = 0; j < Player.sleeves.length; ++j) {
|
|
|
|
if (j === i) { continue; }
|
2019-01-22 05:39:52 +01:00
|
|
|
Player.sleeves[j].gainExperience(Player, expForOtherSleeves, numCycles, true);
|
2019-01-20 23:57:38 +01: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
|
2018-05-10 19:14:45 +02:00
|
|
|
updateDisplays: 3,
|
2017-08-18 19:20:51 +02:00
|
|
|
updateDisplaysMed: 9,
|
2017-08-13 07:01:33 +02:00
|
|
|
updateDisplaysLong: 15,
|
2018-05-11 23:30:55 +02:00
|
|
|
updateActiveScriptsDisplay: 5,
|
2017-05-05 18:52:48 +02:00
|
|
|
createProgramNotifications: 10, //Checks whether any programs can be created and notifies
|
2017-07-27 04:56:14 +02:00
|
|
|
checkFactionInvitations: 100, //Check whether you qualify for any faction invitations
|
2017-05-04 07:05:48 +02:00
|
|
|
passiveFactionGrowth: 600,
|
2017-07-22 00:54:55 +02:00
|
|
|
messages: 150,
|
2017-07-25 03:06:40 +02:00
|
|
|
sCr: 1500,
|
2018-05-02 19:38:11 +02:00
|
|
|
mechanicProcess: 5, //Processes certain mechanics (Corporation, Bladeburner)
|
2018-09-16 10:55:54 +02:00
|
|
|
contractGeneration: 3000 //Generate Coding Contracts
|
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) {
|
2018-01-20 05:47:57 +01:00
|
|
|
if (Settings.AutosaveInterval == null) {
|
|
|
|
Settings.AutosaveInterval = 60;
|
|
|
|
}
|
|
|
|
if (Settings.AutosaveInterval === 0) {
|
|
|
|
Engine.Counters.autoSaveCounter = Infinity;
|
|
|
|
} else {
|
|
|
|
Engine.Counters.autoSaveCounter = Settings.AutosaveInterval * 5;
|
2019-02-09 03:46:30 +01:00
|
|
|
saveObject.saveGame(indexedDb);
|
2018-01-20 05:47:57 +01:00
|
|
|
}
|
2016-12-02 22:57:20 +01:00
|
|
|
}
|
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
|
|
|
|
2018-05-11 23:30:55 +02:00
|
|
|
if (Engine.Counters.updateActiveScriptsDisplay <= 0) {
|
|
|
|
//Always update, but make the interval longer if the page isn't active
|
|
|
|
updateActiveScriptsItems();
|
2018-07-20 03:51:18 +02:00
|
|
|
if (routing.isOn(Page.ActiveScripts)) {
|
2018-05-11 23:30:55 +02:00
|
|
|
Engine.Counters.updateActiveScriptsDisplay = 5;
|
|
|
|
} else {
|
2018-07-03 05:35:12 +02:00
|
|
|
Engine.Counters.updateActiveScriptsDisplay = 10;
|
2018-05-10 19:14:45 +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();
|
2019-02-22 03:26:28 +01:00
|
|
|
if (routing.isOn(Page.HacknetNodes)) {
|
2017-04-27 22:02:58 +02:00
|
|
|
updateHacknetNodesContent();
|
2018-07-20 03:51:18 +02:00
|
|
|
} else if (routing.isOn(Page.CreateProgram)) {
|
2017-05-12 20:12:32 +02:00
|
|
|
displayCreateProgramContent();
|
2019-01-20 23:57:38 +01:00
|
|
|
} else if (routing.isOn(Page.Sleeves)) {
|
|
|
|
updateSleevesPage();
|
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-08-18 19:20:51 +02:00
|
|
|
if (Engine.Counters.updateDisplaysMed <= 0) {
|
2019-03-13 23:17:30 +01:00
|
|
|
if (routing.isOn(Page.CharacterInfo)) {
|
2019-02-22 03:26:28 +01:00
|
|
|
Engine.updateCharacterInfo();
|
2017-08-18 19:20:51 +02:00
|
|
|
}
|
2018-05-10 19:14:45 +02:00
|
|
|
Engine.Counters.updateDisplaysMed = 9;
|
2017-08-18 19:20:51 +02:00
|
|
|
}
|
|
|
|
|
2017-08-13 07:01:33 +02:00
|
|
|
if (Engine.Counters.updateDisplaysLong <= 0) {
|
2018-10-23 20:55:42 +02:00
|
|
|
if (routing.isOn(Page.Gang) && Player.inGang()) {
|
|
|
|
Player.gang.updateGangContent();
|
2018-07-20 03:51:18 +02:00
|
|
|
} else if (routing.isOn(Page.ScriptEditor)) {
|
2018-01-27 07:52:39 +01:00
|
|
|
updateScriptEditorContent();
|
2017-08-13 07:01:33 +02:00
|
|
|
}
|
|
|
|
Engine.Counters.updateDisplaysLong = 15;
|
|
|
|
}
|
|
|
|
|
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) {
|
2017-09-01 22:35:14 +02:00
|
|
|
if (Player.firstFacInvRecvd === false) {
|
|
|
|
Player.firstFacInvRecvd = true;
|
|
|
|
document.getElementById("factions-tab").style.display = "list-item";
|
2017-09-03 19:44:20 +02:00
|
|
|
document.getElementById("character-menu-header").click();
|
|
|
|
document.getElementById("character-menu-header").click();
|
2017-09-01 22:35:14 +02:00
|
|
|
}
|
|
|
|
|
2017-02-16 19:52:11 +01:00
|
|
|
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-09-19 20:38:03 +02:00
|
|
|
if (Augmentations[AugmentationNames.TheRedPill].owned) {
|
2017-09-27 17:13:42 +02:00
|
|
|
Engine.Counters.messages = 4500; //15 minutes for Red pill message
|
2017-09-19 20:38:03 +02:00
|
|
|
} else {
|
|
|
|
Engine.Counters.messages = 150;
|
|
|
|
}
|
2017-06-02 06:15:45 +02:00
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-13 18:54:29 +02:00
|
|
|
if (Engine.Counters.sCr <= 0) {
|
|
|
|
if (Player.hasWseAccount) {
|
2017-07-22 00:54:55 +02:00
|
|
|
stockMarketCycle();
|
2017-07-13 18:54:29 +02:00
|
|
|
}
|
|
|
|
Engine.Counters.sCr = 1500;
|
|
|
|
}
|
2018-03-12 20:39:04 +01:00
|
|
|
|
2018-05-02 19:38:11 +02:00
|
|
|
if (Engine.Counters.mechanicProcess <= 0) {
|
2018-03-12 20:39:04 +01:00
|
|
|
if (Player.corporation instanceof Corporation) {
|
|
|
|
Player.corporation.process();
|
|
|
|
}
|
2018-05-02 19:38:11 +02:00
|
|
|
if (Player.bladeburner instanceof Bladeburner) {
|
|
|
|
try {
|
|
|
|
Player.bladeburner.process();
|
|
|
|
} catch(e) {
|
|
|
|
exceptionAlert("Exception caught in Bladeburner.process(): " + e);
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
Engine.Counters.mechanicProcess = 5;
|
2018-03-12 20:39:04 +01:00
|
|
|
}
|
2018-09-16 10:55:54 +02:00
|
|
|
|
|
|
|
if (Engine.Counters.contractGeneration <= 0) {
|
2018-09-24 06:27:31 +02:00
|
|
|
// X% chance of a contract being generated
|
2018-09-26 07:00:28 +02:00
|
|
|
if (Math.random() <= 0.25) {
|
2018-10-27 21:26:22 +02:00
|
|
|
generateRandomContract();
|
2018-09-16 10:55:54 +02:00
|
|
|
}
|
|
|
|
Engine.Counters.contractGeneration = 3000;
|
|
|
|
}
|
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) {
|
2018-06-22 23:30:24 +02:00
|
|
|
Engine._actionProgressStr = replaceAt(Engine._actionProgressStr, Engine._actionProgressBarCount, "|");
|
2017-01-31 04:41:42 +01:00
|
|
|
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-09-01 20:49:21 +02:00
|
|
|
//Used when initializing a game
|
|
|
|
//elems should be an array of all DOM elements under the header
|
|
|
|
closeMainMenuHeader: function(elems) {
|
|
|
|
for (var i = 0; i < elems.length; ++i) {
|
|
|
|
elems[i].style.maxHeight = null;
|
|
|
|
elems[i].style.opacity = 0;
|
|
|
|
elems[i].style.pointerEvents = "none";
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
//Used when initializing the game
|
|
|
|
//elems should be an array of all DOM elements under the header
|
|
|
|
openMainMenuHeader: function(elems) {
|
|
|
|
for (var i = 0; i < elems.length; ++i) {
|
|
|
|
elems[i].style.maxHeight = elems[i].scrollHeight + "px";
|
|
|
|
elems[i].style.display = "block";
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
|
|
|
//Used in game when clicking on a main menu header (NOT FOR INITIALIZATION)
|
|
|
|
//open is a boolean specifying whether its being opened or closed
|
|
|
|
//elems is an array of DOM elements for main menu tabs (li)
|
|
|
|
//links is an array of DOM elements for main menu links (a)
|
|
|
|
toggleMainMenuHeader: function(open, elems, links) {
|
|
|
|
for (var i = 0; i < elems.length; ++i) {
|
|
|
|
if (open) {
|
|
|
|
elems[i].style.opacity = 1;
|
|
|
|
elems[i].style.maxHeight = elems[i].scrollHeight + "px";
|
|
|
|
} else {
|
|
|
|
elems[i].style.opacity = 0;
|
|
|
|
elems[i].style.maxHeight = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
for (var i = 0; i < links.length; ++i) {
|
|
|
|
if (open) {
|
|
|
|
links[i].style.opacity = 1;
|
|
|
|
links[i].style.maxHeight = links[i].scrollHeight + "px";
|
|
|
|
links[i].style.pointerEvents = "auto";
|
|
|
|
} else {
|
|
|
|
links[i].style.opacity = 0;
|
|
|
|
links[i].style.maxHeight = null;
|
|
|
|
links[i].style.pointerEvents = "none";
|
|
|
|
}
|
|
|
|
}
|
|
|
|
},
|
|
|
|
|
2017-10-12 04:00:22 +02:00
|
|
|
load: function(saveString) {
|
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");
|
2018-11-01 19:18:32 +01:00
|
|
|
var stockmarket = document.getElementById("stock-market-tab");
|
2018-07-13 04:22:28 +02:00
|
|
|
var bladeburner = document.getElementById("bladeburner-tab");
|
|
|
|
var corp = document.getElementById("corporation-tab");
|
|
|
|
var gang = document.getElementById("gang-tab");
|
2017-07-22 00:54:55 +02:00
|
|
|
var tutorial = document.getElementById("tutorial-tab");
|
|
|
|
var options = document.getElementById("options-tab");
|
2018-06-11 19:41:02 +02:00
|
|
|
var dev = document.getElementById("dev-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-10-12 04:00:22 +02:00
|
|
|
if (loadGame(saveString)) {
|
2017-05-05 23:27:35 +02:00
|
|
|
console.log("Loaded game from save");
|
2017-08-30 19:44:29 +02:00
|
|
|
initBitNodes();
|
2019-02-14 03:08:18 +01:00
|
|
|
initBitNodeMultipliers(Player);
|
2017-08-30 19:44:29 +02:00
|
|
|
initSourceFiles();
|
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.init(); //Initialize buttons, work, etc.
|
2017-06-28 22:53:12 +02:00
|
|
|
initAugmentations(); //Also calls Player.reapplyAllAugmentations()
|
2017-08-13 07:01:33 +02:00
|
|
|
Player.reapplyAllSourceFiles();
|
2017-07-03 21:42:11 +02:00
|
|
|
initStockSymbols();
|
|
|
|
if (Player.hasWseAccount) {
|
|
|
|
initSymbolToStockMap();
|
|
|
|
}
|
2017-08-18 19:20:51 +02:00
|
|
|
initLiterature();
|
2017-08-30 19:44:29 +02:00
|
|
|
initSingularitySFFlags();
|
2019-01-17 20:10:35 +01:00
|
|
|
updateSourceFileFlags(Player);
|
2017-10-04 03:50:13 +02:00
|
|
|
|
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
|
|
|
|
2018-11-04 23:39:30 +01:00
|
|
|
// Stock Market offline progress
|
|
|
|
if (Player.hasWseAccount) {
|
|
|
|
processStockPrices(numCyclesOffline);
|
|
|
|
}
|
|
|
|
|
2018-12-22 11:27:04 +01:00
|
|
|
// Gang progress for BitNode 2
|
2017-09-05 03:03:29 +02:00
|
|
|
if (Player.bitNodeN != null && Player.bitNodeN === 2 && Player.inGang()) {
|
2018-10-23 20:55:42 +02:00
|
|
|
Player.gang.process(numCyclesOffline, Player);
|
2017-08-13 07:01:33 +02:00
|
|
|
}
|
|
|
|
|
2018-12-22 11:27:04 +01:00
|
|
|
// Corporation offline progress
|
|
|
|
if (Player.corporation instanceof Corporation) {
|
|
|
|
Player.corporation.storeCycles(numCyclesOffline);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Bladeburner offline progress
|
2018-05-02 19:38:11 +02:00
|
|
|
if (Player.bladeburner instanceof Bladeburner) {
|
|
|
|
Player.bladeburner.storeCycles(numCyclesOffline);
|
|
|
|
}
|
|
|
|
|
2019-01-20 23:57:38 +01:00
|
|
|
// Sleeves offline progress
|
|
|
|
for (let i = 0; i < Player.sleeves.length; ++i) {
|
|
|
|
if (Player.sleeves[i] instanceof Sleeve) {
|
|
|
|
const expForOtherSleeves = Player.sleeves[i].process(Player, numCyclesOffline);
|
|
|
|
|
|
|
|
// This sleeve earns experience for other sleeves
|
|
|
|
if (expForOtherSleeves == null) { continue; }
|
|
|
|
for (let j = 0; j < Player.sleeves.length; ++j) {
|
|
|
|
if (j === i) { continue; }
|
2019-01-22 05:39:52 +01:00
|
|
|
Player.sleeves[j].gainExperience(Player, expForOtherSleeves, numCyclesOffline, true);
|
2019-01-20 23:57:38 +01: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;}
|
2018-06-22 21:38:25 +02:00
|
|
|
if (Player.playtimeSinceLastBitnode == null) {Player.playtimeSinceLastBitnode = 0;}
|
2017-05-15 18:54:23 +02:00
|
|
|
Player.totalPlaytime += time;
|
2017-06-17 19:47:04 +02:00
|
|
|
Player.playtimeSinceLastAug += time;
|
2018-06-22 21:38:25 +02:00
|
|
|
Player.playtimeSinceLastBitnode += 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
|
2018-07-16 20:16:15 +02:00
|
|
|
removeLoadingScreen();
|
2019-02-12 10:14:38 +01:00
|
|
|
const timeOfflineString = convertTimeMsToTimeElapsedString(time);
|
|
|
|
dialogBoxCreate(`Offline for ${timeOfflineString}. While you were offline, your scripts ` +
|
|
|
|
"generated <span class='money-gold'>" +
|
|
|
|
numeralWrapper.formatMoney(offlineProductionFromScripts) + "</span> and your Hacknet Nodes generated <span class='money-gold'>" +
|
|
|
|
numeralWrapper.formatMoney(offlineProductionFromHacknetNodes) + "</span>");
|
2017-07-22 00:54:55 +02:00
|
|
|
//Close main menu accordions for loaded game
|
2017-09-01 22:35:14 +02:00
|
|
|
var visibleMenuTabs = [terminal, createScript, activeScripts, stats,
|
2018-06-11 19:41:02 +02:00
|
|
|
hacknetnodes, city, tutorial, options, dev];
|
2017-09-01 22:35:14 +02:00
|
|
|
if (Player.firstFacInvRecvd) {visibleMenuTabs.push(factions);}
|
|
|
|
else {factions.style.display = "none";}
|
|
|
|
if (Player.firstAugPurchased) {visibleMenuTabs.push(augmentations);}
|
|
|
|
else {augmentations.style.display = "none";}
|
2019-01-15 04:34:04 +01:00
|
|
|
if (Player.companyName !== "") {visibleMenuTabs.push(job);}
|
2017-09-01 22:35:14 +02:00
|
|
|
else {job.style.display = "none";}
|
|
|
|
if (Player.firstTimeTraveled) {visibleMenuTabs.push(travel);}
|
|
|
|
else {travel.style.display = "none";}
|
|
|
|
if (Player.firstProgramAvailable) {visibleMenuTabs.push(createProgram);}
|
|
|
|
else {createProgram.style.display = "none";}
|
2018-11-01 19:18:32 +01:00
|
|
|
if (Player.hasWseAccount) {visibleMenuTabs.push(stockmarket);}
|
|
|
|
else {stockmarket.style.display = "none";}
|
2018-07-13 04:22:28 +02:00
|
|
|
if(Player.bladeburner instanceof Bladeburner) {visibleMenuTabs.push(bladeburner);}
|
|
|
|
else {bladeburner.style.display = "none";}
|
|
|
|
if(Player.corporation instanceof Corporation) {visibleMenuTabs.push(corp);}
|
|
|
|
else {corp.style.display = "none";}
|
|
|
|
if(Player.inGang()) {visibleMenuTabs.push(gang);}
|
|
|
|
else {gang.style.display = "none";}
|
2017-09-01 22:35:14 +02:00
|
|
|
|
2017-09-13 16:22:22 +02:00
|
|
|
Engine.closeMainMenuHeader(visibleMenuTabs);
|
2017-05-05 23:27:35 +02:00
|
|
|
} else {
|
|
|
|
//No save found, start new game
|
|
|
|
console.log("Initializing new game");
|
2017-08-30 19:44:29 +02:00
|
|
|
initBitNodes();
|
2019-02-14 03:08:18 +01:00
|
|
|
initBitNodeMultipliers(Player);
|
2017-08-30 19:44:29 +02:00
|
|
|
initSourceFiles();
|
|
|
|
initSpecialServerIps();
|
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();
|
2019-03-05 02:40:28 +01:00
|
|
|
initForeignServers(Player.getHomeComputer());
|
2017-05-05 23:27:35 +02:00
|
|
|
initCompanies();
|
|
|
|
initFactions();
|
|
|
|
initAugmentations();
|
2017-06-20 22:36:48 +02:00
|
|
|
initMessages();
|
2017-07-03 21:42:11 +02:00
|
|
|
initStockSymbols();
|
2017-08-18 19:20:51 +02:00
|
|
|
initLiterature();
|
2017-08-30 19:44:29 +02:00
|
|
|
initSingularitySFFlags();
|
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");
|
2017-09-01 22:35:14 +02:00
|
|
|
|
|
|
|
//Hide tabs that wont be revealed until later
|
|
|
|
factions.style.display = "none";
|
|
|
|
augmentations.style.display = "none";
|
|
|
|
job.style.display = "none";
|
2018-11-01 19:18:32 +01:00
|
|
|
stockmarket.style.display = "none";
|
2017-09-01 22:35:14 +02:00
|
|
|
travel.style.display = "none";
|
|
|
|
createProgram.style.display = "none";
|
2018-07-13 04:22:28 +02:00
|
|
|
bladeburner.style.display = "none";
|
|
|
|
corp.style.display = "none";
|
|
|
|
gang.style.display = "none";
|
2018-08-07 03:15:31 +02:00
|
|
|
dev.style.display = "none";
|
2017-09-01 22:35:14 +02:00
|
|
|
|
2017-09-01 20:49:21 +02:00
|
|
|
Engine.openMainMenuHeader(
|
2017-09-01 22:35:14 +02:00
|
|
|
[terminal, createScript, activeScripts, stats,
|
|
|
|
hacknetnodes, city,
|
2018-08-07 03:15:31 +02:00
|
|
|
tutorial, options]
|
2017-09-01 20:49:21 +02:00
|
|
|
);
|
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();
|
2018-07-16 20:16:15 +02:00
|
|
|
removeLoadingScreen();
|
2017-05-05 23:27:35 +02:00
|
|
|
}
|
2017-07-25 16:39:56 +02:00
|
|
|
//Initialize labels on game settings
|
|
|
|
setSettingsLabels();
|
2018-03-03 22:05:33 +01:00
|
|
|
scriptEditorInit();
|
2017-09-13 16:22:22 +02:00
|
|
|
Terminal.resetTerminalInput();
|
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");
|
2018-07-20 03:51:18 +02:00
|
|
|
routing.navigateTo(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");
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.characterContent.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.scriptEditorContent = document.getElementById("script-editor-container");
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.scriptEditorContent.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.activeScriptsContent = document.getElementById("active-scripts-container");
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.activeScriptsContent.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.hacknetNodesContent = document.getElementById("hacknet-nodes-container");
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.hacknetNodesContent.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.worldContent = document.getElementById("world-container");
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.worldContent.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.createProgramContent = document.getElementById("create-program-container");
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.createProgramContent.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.factionsContent = document.getElementById("factions-container");
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.factionsContent.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.factionContent = document.getElementById("faction-container");
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.factionContent.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.factionAugmentationsContent = document.getElementById("faction-augmentations-container");
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.factionAugmentationsContent.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.augmentationsContent = document.getElementById("augmentations-container");
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.augmentationsContent.style.display = "none";
|
|
|
|
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
Engine.Display.tutorialContent = document.getElementById("tutorial-container");
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.tutorialContent.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-06-28 22:53:12 +02:00
|
|
|
Engine.Display.infiltrationContent = document.getElementById("infiltration-container");
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.infiltrationContent.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-07-03 21:42:11 +02:00
|
|
|
Engine.Display.stockMarketContent = document.getElementById("stock-market-container");
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.stockMarketContent.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-09-21 23:27:31 +02:00
|
|
|
Engine.Display.missionContent = document.getElementById("mission-container");
|
2017-11-09 02:55:21 +01:00
|
|
|
Engine.Display.missionContent.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
//Character info
|
2018-01-20 05:47:57 +01:00
|
|
|
Engine.Display.characterInfo = document.getElementById("character-content");
|
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");
|
2017-11-09 02:55:21 +01:00
|
|
|
//Engine.Display.locationContent.style.visibility = "hidden";
|
|
|
|
Engine.Display.locationContent.style.display = "none";
|
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");
|
2017-11-09 02:55:21 +01:00
|
|
|
//Engine.Display.workInProgressContent.style.visibility = "hidden";
|
|
|
|
Engine.Display.workInProgressContent.style.display = "none";
|
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-11-09 02:55:21 +01:00
|
|
|
Engine.Display.redPillContent.style.display = "none";
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2018-05-02 19:38:11 +02:00
|
|
|
//Cinematic Text
|
|
|
|
Engine.Display.cinematicTextContent = document.getElementById("cinematic-text-container");
|
|
|
|
Engine.Display.cinematicTextContent.style.display = "none";
|
|
|
|
|
2017-05-05 23:27:35 +02:00
|
|
|
//Init Location buttons
|
|
|
|
initLocationButtons();
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
// Initialize references to main menu links
|
|
|
|
if (!initializeMainMenuLinks()) {
|
|
|
|
const errorMsg = "Failed to initialize Main Menu Links. Please try refreshing the page. " +
|
|
|
|
"If that doesn't work, report the issue to the developer";
|
|
|
|
exceptionAlert(new Error(errorMsg));
|
2019-01-30 07:02:27 +01:00
|
|
|
console.error(errorMsg);
|
2019-01-18 18:57:21 +01:00
|
|
|
return;
|
|
|
|
}
|
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-08-30 19:44:29 +02:00
|
|
|
//Import game link
|
|
|
|
document.getElementById("import-game-link").onclick = function() {
|
|
|
|
saveObject.importGame();
|
|
|
|
};
|
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
// Initialize Main Menu Headers (this must be done after initializing the links)
|
|
|
|
if (!initializeMainMenuHeaders(Player, process.env.NODE_ENV === "development")) {
|
|
|
|
const errorMsg = "Failed to initialize Main Menu Headers. Please try refreshing the page. " +
|
|
|
|
"If that doesn't work, report the issue to the developer";
|
|
|
|
exceptionAlert(new Error(errorMsg));
|
2019-01-30 07:02:27 +01:00
|
|
|
console.error(errorMsg);
|
2019-01-18 18:57:21 +01:00
|
|
|
return;
|
2017-07-22 00:54:55 +02:00
|
|
|
}
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Terminal.addEventListener("click", function() {
|
2016-10-17 10:24:39 +02:00
|
|
|
Engine.loadTerminalContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.ScriptEditor.addEventListener("click", function() {
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.loadScriptEditorContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.ActiveScripts.addEventListener("click", function() {
|
2017-01-31 04:41:42 +01:00
|
|
|
Engine.loadActiveScriptsContent();
|
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.CreateProgram.addEventListener("click", function() {
|
|
|
|
Engine.loadCreateProgramContent();
|
2017-04-27 22:02:58 +02:00
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Stats.addEventListener("click", function() {
|
|
|
|
Engine.loadCharacterContent();
|
2017-01-31 04:41:42 +01:00
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Factions.addEventListener("click", function() {
|
|
|
|
Engine.loadFactionsContent();
|
2017-07-22 00:54:55 +02:00
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Augmentations.addEventListener("click", function() {
|
|
|
|
Engine.loadAugmentationsContent();
|
2017-07-22 00:54:55 +02:00
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.HacknetNodes.addEventListener("click", function() {
|
|
|
|
Engine.loadHacknetNodesContent();
|
2018-11-01 19:18:32 +01:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2019-01-20 23:57:38 +01:00
|
|
|
MainMenuLinks.Sleeves.addEventListener("click", function() {
|
|
|
|
Engine.loadSleevesContent();
|
2019-01-30 07:02:27 +01:00
|
|
|
MainMenuLinks.Sleeves.classList.add("active");
|
2019-01-20 23:57:38 +01:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.City.addEventListener("click", function() {
|
|
|
|
Engine.loadWorldContent();
|
2017-01-31 04:41:42 +01:00
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Travel.addEventListener("click", function() {
|
|
|
|
Engine.loadTravelContent();
|
|
|
|
MainMenuLinks.Travel.classList.add("active");
|
2017-01-31 04:41:42 +01:00
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Job.addEventListener("click", function() {
|
|
|
|
Engine.loadJobContent();
|
|
|
|
MainMenuLinks.Job.classList.add("active");
|
2017-01-31 04:41:42 +01:00
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.StockMarket.addEventListener("click", function() {
|
|
|
|
Engine.loadStockMarketContent();
|
|
|
|
MainMenuLinks.StockMarket.classList.add("active");
|
2017-01-31 04:41:42 +01:00
|
|
|
return false;
|
|
|
|
});
|
2017-07-25 03:06:40 +02:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Bladeburner.addEventListener("click", function() {
|
2018-07-13 04:22:28 +02:00
|
|
|
Engine.loadBladeburnerContent();
|
|
|
|
return false;
|
|
|
|
});
|
2019-01-18 18:57:21 +01:00
|
|
|
|
|
|
|
MainMenuLinks.Corporation.addEventListener("click", function() {
|
2018-07-13 04:22:28 +02:00
|
|
|
Engine.loadCorporationContent();
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Corporation.classList.add("active");
|
2018-07-13 04:22:28 +02:00
|
|
|
return false;
|
|
|
|
});
|
2019-01-18 18:57:21 +01:00
|
|
|
|
|
|
|
MainMenuLinks.Gang.addEventListener("click", function() {
|
2018-07-13 04:22:28 +02:00
|
|
|
Engine.loadGangContent();
|
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.Tutorial.addEventListener("click", function() {
|
|
|
|
Engine.loadTutorialContent();
|
|
|
|
return false;
|
|
|
|
});
|
2018-07-13 04:22:28 +02:00
|
|
|
|
2019-01-18 18:57:21 +01:00
|
|
|
MainMenuLinks.DevMenu.addEventListener("click", function() {
|
|
|
|
if (process.env.NODE_ENV === "development") {
|
2018-08-07 03:15:31 +02:00
|
|
|
Engine.loadDevMenuContent();
|
|
|
|
}
|
2018-06-11 19:41:02 +02:00
|
|
|
return false;
|
|
|
|
});
|
|
|
|
|
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-10-12 04:00:22 +02:00
|
|
|
saveObject.saveGame(indexedDb);
|
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-10-12 04:00:22 +02:00
|
|
|
saveObject.deleteGame(indexedDb);
|
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-10-12 04:00:22 +02:00
|
|
|
saveObject.saveGame(indexedDb);
|
2017-05-25 16:50:58 +02:00
|
|
|
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];
|
2017-08-30 19:44:29 +02:00
|
|
|
Player.finishFactionWork(true);
|
2017-05-15 17:28:59 +02:00
|
|
|
} else if (Player.workType == CONSTANTS.WorkTypeCreateProgram) {
|
2017-08-30 19:44:29 +02:00
|
|
|
Player.finishCreateProgramWork(true);
|
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
|
|
|
|
2018-12-31 01:11:48 +01:00
|
|
|
// Copy Save Data to Clipboard
|
|
|
|
document.getElementById("copy-save-to-clipboard-link").addEventListener("click", function() {
|
|
|
|
const saveString = saveObject.getSaveString();
|
|
|
|
if (!navigator.clipboard) {
|
|
|
|
// Async Clipboard API not supported, so we'll use this using the
|
|
|
|
// textarea and document.execCommand('copy') trick
|
|
|
|
const textArea = document.createElement("textarea");
|
|
|
|
textArea.value = saveString;
|
|
|
|
textArea.setAttribute("readonly", '');
|
|
|
|
textArea.style.position = 'absolute';
|
|
|
|
textArea.left = '-9999px';
|
|
|
|
document.body.appendChild(textArea);
|
|
|
|
textArea.focus();
|
|
|
|
textArea.select();
|
|
|
|
try {
|
|
|
|
const successful = document.execCommand("copy");
|
|
|
|
if (successful) {
|
|
|
|
createStatusText("Copied save to clipboard");
|
|
|
|
} else {
|
|
|
|
createStatusText("Failed to copy save");
|
|
|
|
}
|
|
|
|
} catch(e) {
|
|
|
|
console.error("Unable to copy save data to clipboard using document.execCommand('copy')");
|
|
|
|
createStatusText("Failed to copy save");
|
|
|
|
}
|
|
|
|
document.body.removeChild(textArea);
|
|
|
|
} else {
|
|
|
|
// Use the Async Clipboard API
|
|
|
|
navigator.clipboard.writeText(saveString).then(function() {
|
|
|
|
createStatusText("Copied save to clipboard");
|
|
|
|
}, function(e) {
|
|
|
|
console.error("Unable to copy save data to clipboard using Async API");
|
|
|
|
createStatusText("Failed to copy save");
|
|
|
|
})
|
|
|
|
}
|
|
|
|
});
|
|
|
|
|
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
|
|
|
};
|
|
|
|
|
2017-10-12 04:00:22 +02:00
|
|
|
var indexedDb, indexedDbRequest;
|
2016-10-17 10:24:39 +02:00
|
|
|
window.onload = function() {
|
2017-10-12 04:00:22 +02:00
|
|
|
if (!window.indexedDB) {
|
|
|
|
return Engine.load(null); //Will try to load from localstorage
|
|
|
|
}
|
|
|
|
|
|
|
|
//DB is called bitburnerSave
|
|
|
|
//Object store is called savestring
|
|
|
|
//key for the Object store is called save
|
|
|
|
indexedDbRequest = window.indexedDB.open("bitburnerSave", 1);
|
|
|
|
|
|
|
|
indexedDbRequest.onerror = function(e) {
|
2017-10-15 03:55:41 +02:00
|
|
|
console.log("Error opening indexedDB: ");
|
|
|
|
console.log(e);
|
2017-10-12 04:00:22 +02:00
|
|
|
return Engine.load(null); //Try to load from localstorage
|
|
|
|
};
|
|
|
|
|
|
|
|
indexedDbRequest.onsuccess = function(e) {
|
|
|
|
console.log("Opening bitburnerSave database successful!");
|
|
|
|
indexedDb = e.target.result;
|
|
|
|
var transaction = indexedDb.transaction(["savestring"]);
|
|
|
|
var objectStore = transaction.objectStore("savestring");
|
|
|
|
var request = objectStore.get("save");
|
|
|
|
request.onerror = function(e) {
|
|
|
|
console.log("Error in Database request to get savestring: " + e);
|
|
|
|
return Engine.load(null); //Try to load from localstorage
|
|
|
|
}
|
|
|
|
|
|
|
|
request.onsuccess = function(e) {
|
|
|
|
Engine.load(request.result); //Is this right?
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
indexedDbRequest.onupgradeneeded = function(e) {
|
2017-10-15 03:55:41 +02:00
|
|
|
var db = e.target.result;
|
2017-10-12 04:00:22 +02:00
|
|
|
var objectStore = db.createObjectStore("savestring");
|
|
|
|
}
|
2016-10-17 10:24:39 +02:00
|
|
|
};
|
2017-08-30 19:44:29 +02:00
|
|
|
|
|
|
|
export {Engine};
|