From 2e3254877fc41efd167e04ccf046d55f8280ed01 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Mon, 11 Jun 2018 13:41:02 -0400 Subject: [PATCH 1/8] 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"); From bc14a6a147e95805a0683cb19e29a98eab513f6e Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Tue, 12 Jun 2018 15:27:37 -0400 Subject: [PATCH 2/8] work on the dev menu --- css/menupages.css | 15 ++++++++ index.html | 25 +++++++++---- src/Player.js | 8 ++++ src/engine.js | 93 ++++++++++++++++++++++++++++++++++++++++++++++- 4 files changed, 133 insertions(+), 8 deletions(-) diff --git a/css/menupages.css b/css/menupages.css index fe23d4c2b..8a73b0322 100644 --- a/css/menupages.css +++ b/css/menupages.css @@ -486,6 +486,21 @@ width: 50%; } +/* Dev menu */ +#dev-menu-container { + position: fixed; + padding-top: 10px; +} + +#dev-menu-text { + width: 70%; + margin: 10px; +} + +#dev-menu-container a { + width: 50%; +} + /* Location */ #location-container { position: fixed; diff --git a/index.html b/index.html index 04c17d87b..563a25ec8 100644 --- a/index.html +++ b/index.html @@ -480,18 +480,29 @@
-

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.

+

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
+ + Add Augmentation + + Trigger BitFlume + + + Receive invite + + NUKE + ports all servers + minimize all servers security + maximize all servers money + + + Connect + + + Add Program - - - -
diff --git a/src/Player.js b/src/Player.js index 82c1944cc..4ce865dec 100644 --- a/src/Player.js +++ b/src/Player.js @@ -413,6 +413,14 @@ PlayerObject.prototype.getUpgradeHomeRamCost = function() { return cost; } +PlayerObject.prototype.receiveInvite = function(factionName) { + if(this.factionInvitations.includes(factionName) || this.factions.includes(factionName)) { + return; + } + this.firstFacInvRecvd = true; + this.factionInvitations.push(factionName); +} + //Calculates skill level based on experience. The same formula will be used for every skill PlayerObject.prototype.calculateSkill = function(exp) { return Math.max(Math.floor(32 * Math.log(exp + 534.5) - 200), 1); diff --git a/src/engine.js b/src/engine.js index a213beea2..fa18e7596 100644 --- a/src/engine.js +++ b/src/engine.js @@ -45,7 +45,7 @@ import {updateOnlineScriptTimes, import {Player} from "./Player.js"; import {prestigeAugmentation, prestigeSourceFile} from "./Prestige.js"; -import {redPillFlag} from "./RedPill.js"; +import {redPillFlag, hackWorldDaemon} from "./RedPill.js"; import {saveObject, loadGame} from "./SaveObject.js"; import {loadAllRunningScripts, scriptEditorInit, updateScriptEditorContent} from "./Script.js"; @@ -165,6 +165,16 @@ let Engine = { devMenuGiveMoney: null, devMenuAugDropdown: null, devMenuAddAug: null, + devMenuTriggerBitFlume: null, + devMenuFactionDropdown: null, + devMenuAddFaction: null, + devMenuOpen: null, + devMenuMinSecurity: null, + devMenuMaxMoney: null, + devMenuConnectDropdown: null, + devMenuConnect: null, + devMenuProgramsDropdown: null, + devMenuAddProgram: null, }, //Display objects @@ -807,6 +817,16 @@ let Engine = { Engine.Clickables.devMenuGiveMoney.style.display = "block"; Engine.Clickables.devMenuAugDropdown.style.display = "block"; Engine.Clickables.devMenuAddAug.style.display = "block"; + Engine.Clickables.devMenuTriggerBitFlume.style.display = "block"; + Engine.Clickables.devMenuFactionDropdown.style.display = "block"; + Engine.Clickables.devMenuAddFaction.style.display = "block"; + Engine.Clickables.devMenuOpen.style.display = "block"; + Engine.Clickables.devMenuMinSecurity.style.display = "block"; + Engine.Clickables.devMenuMaxMoney.style.display = "block"; + Engine.Clickables.devMenuConnectDropdown = "block"; + Engine.Clickables.devMenuConnect = "block"; + Engine.Clickables.devMenuProgramsDropdown = "block"; + Engine.Clickables.devMenuAddProgram = "block"; }, //Displays the text when a section of the Tutorial is opened @@ -1481,6 +1501,7 @@ let Engine = { Engine.displayTutorialContent(); }); + // dev menu buttons Engine.Clickables.devMenuGiveMoney = document.getElementById("dev-need-money"); Engine.Clickables.devMenuGiveMoney.addEventListener("click", function() { Player.gainMoney(1e15); @@ -1497,6 +1518,76 @@ let Engine = { Player.queueAugmentation(augDD.options[augDD.selectedIndex].value); }); + Engine.Clickables.devMenuTriggerBitFlume = document.getElementById("dev-bit-flume"); + Engine.Clickables.devMenuTriggerBitFlume.addEventListener("click", function() { + hackWorldDaemon(Player.bitNodeN, true); + }); + + Engine.Clickables.devMenuFactionDropdown = document.getElementById("dev-menu-faction-dropdown"); + const facDD = Engine.Clickables.devMenuFactionDropdown; + for(const i in Factions) { + facDD.options[facDD.options.length] = new Option(Factions[i].name, Factions[i].name); + } + + Engine.Clickables.devMenuAddFaction = document.getElementById("dev-add-faction"); + Engine.Clickables.devMenuAddFaction.addEventListener("click", function() { + const factionName = facDD.options[facDD.selectedIndex].value; + Player.receiveInvite(factionName); + }); + + Engine.Clickables.devMenuOpen = document.getElementById("dev-open-all"); + Engine.Clickables.devMenuOpen.addEventListener("click", function() { + for(const i in AllServers) { + AllServers[i].hasAdminRights = true; + AllServers[i].sshPortOpen = true; + AllServers[i].ftpPortOpen = true; + AllServers[i].smtpPortOpen = true; + AllServers[i].httpPortOpen = true; + AllServers[i].sqlPortOpen = true; + AllServers[i].openPortCount = 5; + } + }); + + Engine.Clickables.devMenuMinSecurity = document.getElementById("dev-min-security"); + Engine.Clickables.devMenuMinSecurity.addEventListener("click", function() { + for(const i in AllServers) { + AllServers[i].hackDifficulty = AllServers[i].minDifficulty; + } + }); + + Engine.Clickables.devMenuMaxMoney = document.getElementById("dev-max-money"); + Engine.Clickables.devMenuMaxMoney.addEventListener("click", function() { + for(const i in AllServers) { + AllServers[i].moneyAvailable = AllServers[i].moneyMax; + } + }); + + Engine.Clickables.devMenuConnectDropdown = document.getElementById("dev-menu-connect-dropdown"); + const connectDD = Engine.Clickables.devMenuConnectDropdown; + for(const i in AllServers) { + connectDD.options[connectDD.options.length] = new Option(AllServers[i].hostname, AllServers[i].hostname); + } + + Engine.Clickables.devMenuConnect = document.getElementById("dev-connect"); + Engine.Clickables.devMenuConnect.addEventListener("click", function() { + const host = connectDD.options[connectDD.selectedIndex].value; + Terminal.connectToServer(host); + }); + + Engine.Clickables.devMenuProgramsDropdown = document.getElementById("dev-menu-add-program-dropdown"); + const programsDD = Engine.Clickables.devMenuProgramsDropdown; + for(const i in Programs) { + programsDD.options[programsDD.options.length] = new Option(Programs[i], Programs[i]); + } + + Engine.Clickables.devMenuAddProgram = document.getElementById("dev-add-program"); + Engine.Clickables.devMenuAddProgram.addEventListener("click", function() { + const program = programsDD.options[programsDD.selectedIndex].value;; + if(!Player.hasProgram(program)) { + Player.getHomeComputer().programs.push(program); + } + }); + //If DarkWeb already purchased, disable the button if (SpecialServerIps.hasOwnProperty("Darkweb Server")) { document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button-inactive"); From c2f2829e752cb9c59b98936ddda6fcab09bdd9ac Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Tue, 12 Jun 2018 16:06:05 -0400 Subject: [PATCH 3/8] added stats related dev options --- index.html | 24 +++++++++--- src/Player.js | 18 +++++++++ src/engine.js | 100 ++++++++++++++++++++++++++++++++++++++++++++++++-- 3 files changed, 133 insertions(+), 9 deletions(-) diff --git a/index.html b/index.html index 563a25ec8..6a689bc03 100644 --- a/index.html +++ b/index.html @@ -492,17 +492,31 @@ Receive invite - NUKE + ports all servers - minimize all servers security - maximize all servers money - Connect Add Program - + NUKE + ports all servers + minimize all servers security + maximize all servers money + + + add hacking exp + + add strength exp + + add defense exp + + add dexterity exp + + add agility exp + + add charisma exp + + add intelligence exp + unlock intelligence
diff --git a/src/Player.js b/src/Player.js index 4ce865dec..6e780dbf4 100644 --- a/src/Player.js +++ b/src/Player.js @@ -587,6 +587,9 @@ PlayerObject.prototype.gainHackingExp = function(exp) { console.log("ERR: NaN passed into Player.gainHackingExp()"); return; } this.hacking_exp += exp; + if(this.hacking_exp < 0) { + this.hacking_exp = 0; + } } PlayerObject.prototype.gainStrengthExp = function(exp) { @@ -594,6 +597,9 @@ PlayerObject.prototype.gainStrengthExp = function(exp) { console.log("ERR: NaN passed into Player.gainStrengthExp()"); return; } this.strength_exp += exp; + if(this.strength_exp < 0) { + this.strength_exp = 0; + } } PlayerObject.prototype.gainDefenseExp = function(exp) { @@ -601,6 +607,9 @@ PlayerObject.prototype.gainDefenseExp = function(exp) { console.log("ERR: NaN passed into player.gainDefenseExp()"); return; } this.defense_exp += exp; + if(this.defense_exp < 0) { + this.defense_exp = 0; + } } PlayerObject.prototype.gainDexterityExp = function(exp) { @@ -608,6 +617,9 @@ PlayerObject.prototype.gainDexterityExp = function(exp) { console.log("ERR: NaN passed into Player.gainDexterityExp()"); return; } this.dexterity_exp += exp; + if(this.dexterity_exp < 0) { + this.dexterity_exp = 0; + } } PlayerObject.prototype.gainAgilityExp = function(exp) { @@ -615,6 +627,9 @@ PlayerObject.prototype.gainAgilityExp = function(exp) { console.log("ERR: NaN passed into Player.gainAgilityExp()"); return; } this.agility_exp += exp; + if(this.agility_exp < 0) { + this.agility_exp = 0; + } } PlayerObject.prototype.gainCharismaExp = function(exp) { @@ -622,6 +637,9 @@ PlayerObject.prototype.gainCharismaExp = function(exp) { console.log("ERR: NaN passed into Player.gainCharismaExp()"); return; } this.charisma_exp += exp; + if(this.charisma_exp < 0) { + this.charisma_exp = 0; + } } PlayerObject.prototype.gainIntelligenceExp = function(exp) { diff --git a/src/engine.js b/src/engine.js index fa18e7596..9c56825ca 100644 --- a/src/engine.js +++ b/src/engine.js @@ -175,6 +175,21 @@ let Engine = { devMenuConnect: null, devMenuProgramsDropdown: null, devMenuAddProgram: null, + devMenuHackingExp: null, + devMenuAddHacking: null, + devMenuStrengthExp: null, + devMenuAddStrength: null, + devMenuDefenseExp: null, + devMenuAddDefense: null, + devMenuDexterityExp: null, + devMenuAddDexterity: null, + devMenuAgilityExp: null, + devMenuAddAgility: null, + devMenuCharismaExp: null, + devMenuAddCharisma: null, + devMenuIntelligenceExp: null, + devMenuAddIntelligence: null, + devMenuUnlockIntelligence: null, }, //Display objects @@ -823,10 +838,26 @@ let Engine = { Engine.Clickables.devMenuOpen.style.display = "block"; Engine.Clickables.devMenuMinSecurity.style.display = "block"; Engine.Clickables.devMenuMaxMoney.style.display = "block"; - Engine.Clickables.devMenuConnectDropdown = "block"; - Engine.Clickables.devMenuConnect = "block"; - Engine.Clickables.devMenuProgramsDropdown = "block"; - Engine.Clickables.devMenuAddProgram = "block"; + Engine.Clickables.devMenuConnectDropdown.style.display = "block"; + Engine.Clickables.devMenuConnect.style.display = "block"; + Engine.Clickables.devMenuProgramsDropdown.style.display = "block"; + Engine.Clickables.devMenuAddProgram.style.display = "block"; + + Engine.Clickables.devMenuHackingExp.style.display = "block"; + Engine.Clickables.devMenuAddHacking.style.display = "block"; + Engine.Clickables.devMenuStrengthExp.style.display = "block"; + Engine.Clickables.devMenuAddStrength.style.display = "block"; + Engine.Clickables.devMenuDefenseExp.style.display = "block"; + Engine.Clickables.devMenuAddDefense.style.display = "block"; + Engine.Clickables.devMenuDexterityExp.style.display = "block"; + Engine.Clickables.devMenuAddDexterity.style.display = "block"; + Engine.Clickables.devMenuAgilityExp.style.display = "block"; + Engine.Clickables.devMenuAddAgility.style.display = "block"; + Engine.Clickables.devMenuCharismaExp.style.display = "block"; + Engine.Clickables.devMenuAddCharisma.style.display = "block"; + Engine.Clickables.devMenuIntelligenceExp.style.display = "block"; + Engine.Clickables.devMenuAddIntelligence.style.display = "block"; + Engine.Clickables.devMenuUnlockIntelligence.style.display = "block"; }, //Displays the text when a section of the Tutorial is opened @@ -1588,6 +1619,67 @@ let Engine = { } }); + Engine.Clickables.devMenuHackingExp = document.getElementById("dev-hacking-exp"); + Engine.Clickables.devMenuAddHacking = document.getElementById("dev-add-hacking"); + Engine.Clickables.devMenuAddHacking.addEventListener("click", function() { + const exp = parseInt(Engine.Clickables.devMenuHackingExp.value); + Player.gainHackingExp(exp); + Player.updateSkillLevels(); + }); + + Engine.Clickables.devMenuStrengthExp = document.getElementById("dev-strength-exp"); + Engine.Clickables.devMenuAddStrength = document.getElementById("dev-add-strength"); + Engine.Clickables.devMenuAddStrength.addEventListener("click", function() { + const exp = parseInt(Engine.Clickables.devMenuStrengthExp.value); + Player.gainStrengthExp(exp); + Player.updateSkillLevels(); + }); + + Engine.Clickables.devMenuDefenseExp = document.getElementById("dev-defense-exp"); + Engine.Clickables.devMenuAddDefense = document.getElementById("dev-add-defense"); + Engine.Clickables.devMenuAddDefense.addEventListener("click", function() { + const exp = parseInt(Engine.Clickables.devMenuDefenseExp.value); + Player.gainDefenseExp(exp); + Player.updateSkillLevels(); + }); + + Engine.Clickables.devMenuDexterityExp = document.getElementById("dev-dexterity-exp"); + Engine.Clickables.devMenuAddDexterity = document.getElementById("dev-add-dexterity"); + Engine.Clickables.devMenuAddDexterity.addEventListener("click", function() { + const exp = parseInt(Engine.Clickables.devMenuDexterityExp.value); + Player.gainDexterityExp(exp); + Player.updateSkillLevels(); + }); + + Engine.Clickables.devMenuAgilityExp = document.getElementById("dev-agility-exp"); + Engine.Clickables.devMenuAddAgility = document.getElementById("dev-add-agility"); + Engine.Clickables.devMenuAddAgility.addEventListener("click", function() { + const exp = parseInt(Engine.Clickables.devMenuAgilityExp.value); + Player.gainAgilityExp(exp); + Player.updateSkillLevels(); + }); + + Engine.Clickables.devMenuCharismaExp = document.getElementById("dev-charisma-exp"); + Engine.Clickables.devMenuAddCharisma = document.getElementById("dev-add-charisma"); + Engine.Clickables.devMenuAddCharisma.addEventListener("click", function() { + const exp = parseInt(Engine.Clickables.devMenuCharismaExp.value); + Player.gainCharismaExp(exp); + Player.updateSkillLevels(); + }); + + Engine.Clickables.devMenuIntelligenceExp = document.getElementById("dev-intelligence-exp"); + Engine.Clickables.devMenuAddIntelligence = document.getElementById("dev-add-intelligence"); + Engine.Clickables.devMenuAddIntelligence.addEventListener("click", function() { + const exp = parseInt(Engine.Clickables.devMenuIntelligenceExp.value); + Player.gainIntelligenceExp(exp); + Player.updateSkillLevels(); + }); + + Engine.Clickables.devMenuUnlockIntelligence = document.getElementById("dev-unlock-intelligence"); + Engine.Clickables.devMenuUnlockIntelligence.addEventListener("click", function() { + Player.intelligence = 1; + }); + //If DarkWeb already purchased, disable the button if (SpecialServerIps.hasOwnProperty("Darkweb Server")) { document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button-inactive"); From ad90a0bb6f7469c26730d2fe3072474db37f5bf1 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Tue, 12 Jun 2018 16:44:21 -0400 Subject: [PATCH 4/8] added home ram upgrade button, enable+disable intelligence, source file modifications --- index.html | 17 ++++++++++++--- src/Player.js | 1 + src/engine.js | 57 ++++++++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 67 insertions(+), 8 deletions(-) diff --git a/index.html b/index.html index 6a689bc03..4b30fe133 100644 --- a/index.html +++ b/index.html @@ -481,27 +481,37 @@

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 $1000t + More home RAM + +

Augmentation related:

Add Augmentation - Trigger BitFlume + Add/Remove source file +

Faction related:

Receive invite +

Program related:

Connect Add Program + Trigger BitFlume + +

Server related:

NUKE + ports all servers minimize all servers security maximize all servers money +

Exp/stats related:

add hacking exp @@ -516,7 +526,8 @@ add charisma exp add intelligence exp - unlock intelligence + enable intelligence + disable intelligence
diff --git a/src/Player.js b/src/Player.js index 6e780dbf4..bdbf12df8 100644 --- a/src/Player.js +++ b/src/Player.js @@ -2356,6 +2356,7 @@ PlayerObject.prototype.queueAugmentation = function(name) { } } + this.firstAugPurchased = true; this.queuedAugmentations.push(new PlayerOwnedAugmentation(name)); } diff --git a/src/engine.js b/src/engine.js index 9c56825ca..2d694a41d 100644 --- a/src/engine.js +++ b/src/engine.js @@ -51,7 +51,8 @@ import {loadAllRunningScripts, scriptEditorInit, updateScriptEditorContent} from "./Script.js"; import {AllServers, Server, initForeignServers} from "./Server.js"; import {Settings, setSettingsLabels} from "./Settings.js"; -import {initSourceFiles, SourceFiles} from "./SourceFile.js"; +import {initSourceFiles, SourceFiles, + PlayerOwnedSourceFile} from "./SourceFile.js"; import {SpecialServerIps, initSpecialServerIps} from "./SpecialServerIps.js"; import {StockMarket, StockSymbols, SymbolToStockMap, initStockSymbols, @@ -163,6 +164,7 @@ let Engine = { //Dev menu devMenuGiveMoney: null, + devMenuGiveRam: null, devMenuAugDropdown: null, devMenuAddAug: null, devMenuTriggerBitFlume: null, @@ -189,7 +191,11 @@ let Engine = { devMenuAddCharisma: null, devMenuIntelligenceExp: null, devMenuAddIntelligence: null, - devMenuUnlockIntelligence: null, + devMenuEnableIntelligence: null, + devMenuDisableIntelligence: null, + devMenuSFN: null, + devMenuSFLvl: null, + devMenuAddSF: null, }, //Display objects @@ -830,6 +836,7 @@ let Engine = { displayDevMenuContent: function() { Engine.Clickables.devMenuGiveMoney.style.display = "block"; + Engine.Clickables.devMenuGiveRam.style.display = "block"; Engine.Clickables.devMenuAugDropdown.style.display = "block"; Engine.Clickables.devMenuAddAug.style.display = "block"; Engine.Clickables.devMenuTriggerBitFlume.style.display = "block"; @@ -857,7 +864,11 @@ let Engine = { Engine.Clickables.devMenuAddCharisma.style.display = "block"; Engine.Clickables.devMenuIntelligenceExp.style.display = "block"; Engine.Clickables.devMenuAddIntelligence.style.display = "block"; - Engine.Clickables.devMenuUnlockIntelligence.style.display = "block"; + Engine.Clickables.devMenuEnableIntelligence.style.display = "block"; + Engine.Clickables.devMenuDisableIntelligence.style.display = "block"; + Engine.Clickables.devMenuSFN.style.display = "block"; + Engine.Clickables.devMenuSFLvl.style.display = "block"; + Engine.Clickables.devMenuAddSF.style.display = "block"; }, //Displays the text when a section of the Tutorial is opened @@ -1538,6 +1549,11 @@ let Engine = { Player.gainMoney(1e15); }); + Engine.Clickables.devMenuGiveRam = document.getElementById("dev-need-ram"); + Engine.Clickables.devMenuGiveRam.addEventListener("click", function() { + Player.getHomeComputer().maxRam *= 2; + }); + Engine.Clickables.devMenuAugDropdown = document.getElementById("dev-menu-aug-dropdown"); const augDD = Engine.Clickables.devMenuAugDropdown; for(const i in AugmentationNames) { @@ -1675,11 +1691,42 @@ let Engine = { Player.updateSkillLevels(); }); - Engine.Clickables.devMenuUnlockIntelligence = document.getElementById("dev-unlock-intelligence"); - Engine.Clickables.devMenuUnlockIntelligence.addEventListener("click", function() { + Engine.Clickables.devMenuEnableIntelligence = document.getElementById("dev-enable-intelligence"); + Engine.Clickables.devMenuEnableIntelligence.addEventListener("click", function() { Player.intelligence = 1; }); + Engine.Clickables.devMenuDisableIntelligence = document.getElementById("dev-disable-intelligence"); + Engine.Clickables.devMenuDisableIntelligence.addEventListener("click", function() { + Player.intelligence = 0; + }); + + Engine.Clickables.devMenuSFN = document.getElementById("dev-sf-n"); + Engine.Clickables.devMenuSFLvl = document.getElementById("dev-sf-lvl"); + Engine.Clickables.devMenuAddSF = document.getElementById("dev-add-source-file"); + Engine.Clickables.devMenuAddSF.addEventListener("click", function() { + const sfN = parseInt(Engine.Clickables.devMenuSFN.value); + const sfLvl = parseInt(Engine.Clickables.devMenuSFLvl.value); + let sfIndex = -1; + for(const i in Player.sourceFiles) { + if(Player.sourceFiles[i].n === sfN) { + sfIndex = i; + break; + } + } + + if(sfIndex === -1) { // add fresh source file + Player.sourceFiles.push(new PlayerOwnedSourceFile(sfN, sfLvl)); + } else if(sfLvl === 0) { // remove a source file. + if(sfIndex === -1) { // doesn't have it anyway. + return; + } + Player.sourceFiles.splice(sfIndex, 1); + } else { // set source file level + Player.sourceFiles[sfIndex].lvl=sfLvl; + } + }); + //If DarkWeb already purchased, disable the button if (SpecialServerIps.hasOwnProperty("Darkweb Server")) { document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button-inactive"); From d43aa68a676c7492b2c89280ac5ba1f2a9960902 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Tue, 12 Jun 2018 17:11:00 -0400 Subject: [PATCH 5/8] tooltips and placeholders to explain --- index.html | 56 +++++++++++++++++++++++++++--------------------------- 1 file changed, 28 insertions(+), 28 deletions(-) diff --git a/index.html b/index.html index 4b30fe133..cc02be725 100644 --- a/index.html +++ b/index.html @@ -482,52 +482,52 @@

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 - More home RAM +

Generic

+ Add $1000t + Double home RAM

Augmentation related:

- Add Augmentation + Queue AugmentationMay require save + reload - Add/Remove source file + Add/Remove source file If Lvl == 0 the sf will be removed, calling it with another level will replace your current source file. You CAN set a source file higher than it's maximum level.

Faction related:

- Receive invite + Receive inviteMay require save + reload

Program related:

- Connect + ConnectConnect to the target server. - Add Program + Add ProgramAdd this program to the player home server, won't add the same program twice. - Trigger BitFlume + Trigger BitFlumeQuick escape to change BN, does not give SFs

Server related:

- NUKE + ports all servers - minimize all servers security - maximize all servers money + NUKE + ports all serversOpens all ports, nukes all servers, gains root access to everything (still need the appropriate hacking level) + minimize all servers securityAll servers security will be set to their minimum security + maximize all servers moneySet all servers available money to maximum for that server

Exp/stats related:

- - add hacking exp - - add strength exp - - add defense exp - - add dexterity exp - - add agility exp - - add charisma exp - - add intelligence exp - enable intelligence - disable intelligence + + add hacking expAdd that many hacking experience point, use negative numbers to remove, don't worry about going under 0 exp + + add strength expAdd that many strength experience point, use negative numbers to remove, don't worry about going under 0 exp + + add defense expAdd that many defense experience point, use negative numbers to remove, don't worry about going under 0 exp + + add dexterity expAdd that many dexterity experience point, use negative numbers to remove, don't worry about going under 0 exp + + add agility expAdd that many agility experience point, use negative numbers to remove, don't worry about going under 0 exp + + add charisma expAdd that many charisma experience point, use negative numbers to remove, don't worry about going under 0 exp + + add intelligence expAdd that many intelligence experience point, use negative numbers to remove, don't worry about going under 0 exp + enable intelligenceEnables the intelligence stat + disable intelligenceDisables the intelligence stat
From a4ef94c0e0697b40d76068a18a52ac74295e7ce6 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Tue, 12 Jun 2018 17:16:25 -0400 Subject: [PATCH 6/8] styling dev menu --- css/menupages.css | 12 ++++++++++++ index.html | 24 ++++++++++++------------ 2 files changed, 24 insertions(+), 12 deletions(-) diff --git a/css/menupages.css b/css/menupages.css index 8a73b0322..d86f2ea46 100644 --- a/css/menupages.css +++ b/css/menupages.css @@ -501,6 +501,18 @@ width: 50%; } +.dev-text-input { + color: var(--my-font-color); + border: 1px solid white; + background-color:black; +} + +.dev-dropdown-input { + color: var(--my-font-color); + border: 1px solid white; + background-color:black; +} + /* Location */ #location-container { position: fixed; diff --git a/index.html b/index.html index cc02be725..9c3bc8de3 100644 --- a/index.html +++ b/index.html @@ -488,20 +488,20 @@

Augmentation related:

- + Queue AugmentationMay require save + reload - Add/Remove source file If Lvl == 0 the sf will be removed, calling it with another level will replace your current source file. You CAN set a source file higher than it's maximum level. + Add/Remove source file If Lvl == 0 the sf will be removed, calling it with another level will replace your current source file. You CAN set a source file higher than it's maximum level.

Faction related:

- + Receive inviteMay require save + reload

Program related:

- + ConnectConnect to the target server. - + Add ProgramAdd this program to the player home server, won't add the same program twice. Trigger BitFlumeQuick escape to change BN, does not give SFs @@ -512,19 +512,19 @@ maximize all servers moneySet all servers available money to maximum for that server

Exp/stats related:

- + add hacking expAdd that many hacking experience point, use negative numbers to remove, don't worry about going under 0 exp - + add strength expAdd that many strength experience point, use negative numbers to remove, don't worry about going under 0 exp - + add defense expAdd that many defense experience point, use negative numbers to remove, don't worry about going under 0 exp - + add dexterity expAdd that many dexterity experience point, use negative numbers to remove, don't worry about going under 0 exp - + add agility expAdd that many agility experience point, use negative numbers to remove, don't worry about going under 0 exp - + add charisma expAdd that many charisma experience point, use negative numbers to remove, don't worry about going under 0 exp - + add intelligence expAdd that many intelligence experience point, use negative numbers to remove, don't worry about going under 0 exp enable intelligenceEnables the intelligence stat disable intelligenceDisables the intelligence stat From cc5731baae0df24ff346c91bb5ab75d5a38afad3 Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Tue, 12 Jun 2018 17:24:53 -0400 Subject: [PATCH 7/8] enable/disable dev mode with a global var --- src/devmode.js | 1 + src/engine.js | 19 +++++++++---------- 2 files changed, 10 insertions(+), 10 deletions(-) create mode 100644 src/devmode.js diff --git a/src/devmode.js b/src/devmode.js new file mode 100644 index 000000000..4148b3a8a --- /dev/null +++ b/src/devmode.js @@ -0,0 +1 @@ +export const DevModeEnabled = false; \ No newline at end of file diff --git a/src/engine.js b/src/engine.js index 2d694a41d..4d1c7e900 100644 --- a/src/engine.js +++ b/src/engine.js @@ -24,6 +24,7 @@ import {CONSTANTS} from "./Constants.js"; import {Programs, displayCreateProgramContent, getNumAvailableCreateProgram, initCreateProgramButtons} from "./CreateProgram.js"; +import {DevModeEnabled} from "./devmode.js" import {displayFactionContent, joinFaction, processPassiveFactionRepGain, Factions, inviteToFaction, initFactions} from "./Faction.js"; @@ -1823,19 +1824,17 @@ 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"); + const elems = [tutorial, options]; + const links = [tutorialLink, optionsLink]; + if(DevModeEnabled) { + elems.push(document.getElementById("dev-tab")); + links.push(document.getElementById("dev-menu-link")); + } if (tutorial.style.maxHeight) { - Engine.toggleMainMenuHeader(false, - [tutorial, options, dev], - [tutorialLink, optionsLink, devLink] - ); + Engine.toggleMainMenuHeader(false, elems, links); } else { - Engine.toggleMainMenuHeader(true, - [tutorial, options, dev], - [tutorialLink, optionsLink, devLink] - ); + Engine.toggleMainMenuHeader(true, elems, links); } } From 520f96865a71ba8edfd4dfe694aacacb836f5d3f Mon Sep 17 00:00:00 2001 From: Olivier Gagnon Date: Tue, 12 Jun 2018 17:25:45 -0400 Subject: [PATCH 8/8] added devmode to .gitignore, prevent pushing devmode to prod --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index 8375e2318..4db5e8435 100644 --- a/.gitignore +++ b/.gitignore @@ -2,3 +2,4 @@ Changelog.txt Netburner.txt /node_modules /dist/*.map +src/devmode.js