From 2e3254877fc41efd167e04ccf046d55f8280ed01 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Mon, 11 Jun 2018 13:41:02 -0400 Subject: [PATCH] some work on dev menu --- index.html | 19 +++++++++++++++ src/Player.js | 18 ++++++++++++++ src/engine.js | 67 +++++++++++++++++++++++++++++++++++++++++++++------ 3 files changed, 97 insertions(+), 7 deletions(-) diff --git a/index.html b/index.html index 440ac9049..04c17d87b 100644 --- a/index.html +++ b/index.html @@ -88,6 +88,9 @@ + @@ -475,6 +478,22 @@

+ +
+

If you see this menu you can pretty much break the game. It's recommended that you use this menu only to setup a save file appropriate to test a new feature or bug fix.

+ Add $1000t + + +
+ Add Augmentation
+ + + + + + +
+
Return to World diff --git a/src/Player.js b/src/Player.js index 3a2a12695..82c1944cc 100644 --- a/src/Player.js +++ b/src/Player.js @@ -2315,6 +2315,24 @@ PlayerObject.prototype.setBitNodeNumber = function(n) { this.bitNodeN = n; } +PlayerObject.prototype.queueAugmentation = function(name) { + for(const i in this.queuedAugmentations) { + if(this.queuedAugmentations[i].name == name) { + console.log('tried to queue '+name+' twice, this may be a bug'); + return; + } + } + + for(const i in this.augmentations) { + if(this.augmentations[i].name == name) { + console.log('tried to queue '+name+' but we already have that aug'); + return; + } + } + + this.queuedAugmentations.push(new PlayerOwnedAugmentation(name)); +} + /* Functions for saving and loading the Player data */ function loadPlayer(saveString) { Player = JSON.parse(saveString, Reviver); diff --git a/src/engine.js b/src/engine.js index dc721e5a9..a213beea2 100644 --- a/src/engine.js +++ b/src/engine.js @@ -12,7 +12,8 @@ import {loxBoxCreate, logBoxUpdateText, import {updateActiveScriptsItems} from "./ActiveScriptsUI.js"; import {Augmentations, installAugmentations, initAugmentations, AugmentationNames, - displayAugmentationsContent} from "./Augmentations.js"; + displayAugmentationsContent, + PlayerOwnedAugmentation} from "./Augmentations.js"; import {BitNodes, initBitNodes, initBitNodeMultipliers} from "./BitNode.js"; import {Bladeburner} from "./Bladeburner.js"; @@ -145,6 +146,7 @@ let Engine = { factionsMainMenuButton: null, augmentationsMainMenuButton: null, tutorialMainMenuButton: null, + devMainMenuButton: null, saveMainMenuButton: null, deleteMainMenuButton: null, @@ -158,6 +160,11 @@ let Engine = { tutorialFactionsButton: null, tutorialAugmentationsButton: null, tutorialBackButton: null, + + //Dev menu + devMenuGiveMoney: null, + devMenuAugDropdown: null, + devMenuAddAug: null, }, //Display objects @@ -183,6 +190,7 @@ let Engine = { factionAugmentationsContent: null, augmentationsContent: null, tutorialContent: null, + devMenuContent: null, infiltrationContent: null, stockMarketContent: null, locationContent: null, @@ -208,6 +216,7 @@ let Engine = { Faction: "Faction", Augmentations: "Augmentations", Tutorial: "Tutorial", + DevMenu: "Dev Menu", Location: "Location", workInProgress: "WorkInProgress", RedPill: "RedPill", @@ -319,6 +328,14 @@ let Engine = { document.getElementById("tutorial-menu-link").classList.add("active"); }, + loadDevMenuContent: function() { + Engine.hideAllContent(); + Engine.Display.devMenuContent.style.display = "block"; + Engine.displayDevMenuContent(); + Engine.currentPage = Engine.Page.DevMenu; + document.getElementById("dev-menu-link").classList.add("active"); + }, + loadLocationContent: function() { Engine.hideAllContent(); Engine.Display.locationContent.style.display = "block"; @@ -455,6 +472,7 @@ let Engine = { Engine.Display.factionAugmentationsContent.style.display = "none"; Engine.Display.augmentationsContent.style.display = "none"; Engine.Display.tutorialContent.style.display = "none"; + Engine.Display.devMenuContent.style.display = "none"; Engine.Display.locationContent.style.display = "none"; Engine.Display.workInProgressContent.style.display = "none"; Engine.Display.redPillContent.style.display = "none"; @@ -494,6 +512,7 @@ let Engine = { document.getElementById("city-menu-link").classList.remove("active"); document.getElementById("tutorial-menu-link").classList.remove("active"); document.getElementById("options-menu-link").classList.remove("active"); + document.getElementById("dev-menu-link").classList.remove("active"); }, displayCharacterOverviewInfo: function() { @@ -784,6 +803,12 @@ let Engine = { document.getElementById("tutorial-text").style.display = "none"; }, + displayDevMenuContent: function() { + Engine.Clickables.devMenuGiveMoney.style.display = "block"; + Engine.Clickables.devMenuAugDropdown.style.display = "block"; + Engine.Clickables.devMenuAddAug.style.display = "block"; + }, + //Displays the text when a section of the Tutorial is opened displayTutorialPage: function(text) { document.getElementById("tutorial-getting-started-link").style.display = "none"; @@ -1182,6 +1207,7 @@ let Engine = { var job = document.getElementById("job-tab"); var tutorial = document.getElementById("tutorial-tab"); var options = document.getElementById("options-tab"); + var dev = document.getElementById("dev-tab"); //Load game from save or create new game if (loadGame(saveString)) { @@ -1258,7 +1284,7 @@ let Engine = { formatNumber(offlineProductionFromHacknetNodes, 2)); //Close main menu accordions for loaded game var visibleMenuTabs = [terminal, createScript, activeScripts, stats, - hacknetnodes, city, tutorial, options]; + hacknetnodes, city, tutorial, options, dev]; if (Player.firstFacInvRecvd) {visibleMenuTabs.push(factions);} else {factions.style.display = "none";} if (Player.firstAugPurchased) {visibleMenuTabs.push(augmentations);} @@ -1312,7 +1338,7 @@ let Engine = { Engine.openMainMenuHeader( [terminal, createScript, activeScripts, stats, hacknetnodes, city, - tutorial, options] + tutorial, options, dev] ); //Start interactive tutorial @@ -1365,6 +1391,9 @@ let Engine = { Engine.Display.tutorialContent = document.getElementById("tutorial-container"); Engine.Display.tutorialContent.style.display = "none"; + Engine.Display.devMenuContent = document.getElementById("dev-menu-container"); + Engine.Display.devMenuContent.style.display = "none"; + Engine.Display.infiltrationContent = document.getElementById("infiltration-container"); Engine.Display.infiltrationContent.style.display = "none"; @@ -1452,6 +1481,22 @@ let Engine = { Engine.displayTutorialContent(); }); + Engine.Clickables.devMenuGiveMoney = document.getElementById("dev-need-money"); + Engine.Clickables.devMenuGiveMoney.addEventListener("click", function() { + Player.gainMoney(1e15); + }); + + Engine.Clickables.devMenuAugDropdown = document.getElementById("dev-menu-aug-dropdown"); + const augDD = Engine.Clickables.devMenuAugDropdown; + for(const i in AugmentationNames) { + augDD.options[augDD.options.length] = new Option(AugmentationNames[i], AugmentationNames[i]); + } + + Engine.Clickables.devMenuAddAug = document.getElementById("dev-add-aug"); + Engine.Clickables.devMenuAddAug.addEventListener("click", function() { + Player.queueAugmentation(augDD.options[augDD.selectedIndex].value); + }); + //If DarkWeb already purchased, disable the button if (SpecialServerIps.hasOwnProperty("Darkweb Server")) { document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button-inactive"); @@ -1548,16 +1593,18 @@ let Engine = { var tutorialLink = document.getElementById("tutorial-menu-link"); var options = document.getElementById("options-tab"); var optionsLink = document.getElementById("options-menu-link"); + var dev = document.getElementById("dev-tab"); + var devLink = document.getElementById("dev-menu-link"); this.classList.toggle("opened"); if (tutorial.style.maxHeight) { Engine.toggleMainMenuHeader(false, - [tutorial, options], - [tutorialLink, optionsLink] + [tutorial, options, dev], + [tutorialLink, optionsLink, devLink] ); } else { Engine.toggleMainMenuHeader(true, - [tutorial, options], - [tutorialLink, optionsLink] + [tutorial, options, dev], + [tutorialLink, optionsLink, devLink] ); } } @@ -1636,6 +1683,12 @@ let Engine = { return false; }); + Engine.Clickables.devMainMenuButton = clearEventListeners("dev-menu-link"); + Engine.Clickables.devMainMenuButton.addEventListener("click", function() { + Engine.loadDevMenuContent(); + return false; + }); + //Active scripts list Engine.ActiveScriptsList = document.getElementById("active-scripts-list");