diff --git a/doc/build/doctrees/environment.pickle b/doc/build/doctrees/environment.pickle index 924bc5a20..1ccccd8ce 100644 Binary files a/doc/build/doctrees/environment.pickle and b/doc/build/doctrees/environment.pickle differ diff --git a/doc/build/doctrees/terminal.doctree b/doc/build/doctrees/terminal.doctree index 496ab0ada..d6347a5ea 100644 Binary files a/doc/build/doctrees/terminal.doctree and b/doc/build/doctrees/terminal.doctree differ diff --git a/doc/build/html/_sources/terminal.rst.txt b/doc/build/html/_sources/terminal.rst.txt index 9b1114836..353d3d583 100644 --- a/doc/build/html/_sources/terminal.rst.txt +++ b/doc/build/html/_sources/terminal.rst.txt @@ -147,7 +147,7 @@ Terminal commands:: $ download * $ download *.script - $download *.txt + $ download *.txt free ^^^^ diff --git a/doc/build/html/terminal.html b/doc/build/html/terminal.html index 387b66d49..d7316d46a 100644 --- a/doc/build/html/terminal.html +++ b/doc/build/html/terminal.html @@ -185,7 +185,7 @@ $ download importantInfo.txt Terminal commands:

$ download *
 $ download *.script
-$download *.txt
+$ download *.txt
 
diff --git a/index.html b/index.html index 5a1a962d4..49e843cd1 100644 --- a/index.html +++ b/index.html @@ -819,6 +819,18 @@ + +
+ + +
+
diff --git a/src/ActiveScriptsUI.js b/src/ActiveScriptsUI.js index e3104f5e7..ab389bc4b 100644 --- a/src/ActiveScriptsUI.js +++ b/src/ActiveScriptsUI.js @@ -1,159 +1,139 @@ import {workerScripts, addWorkerScript, - killWorkerScript} from "./NetscriptWorker.js"; -import {Player} from "./Player.js"; -import {getServer} from "./Server.js"; -import {dialogBoxCreate} from "../utils/DialogBox.js"; -import {printArray} from "../utils/HelperFunctions.js"; -import {logBoxCreate} from "../utils/LogBox.js"; -import numeral from "../utils/numeral.min.js"; -import {formatNumber} from "../utils/StringHelperFunctions.js"; + killWorkerScript} from "./NetscriptWorker.js"; +import {Player} from "./Player.js"; +import {getServer} from "./Server.js"; +import {dialogBoxCreate} from "../utils/DialogBox.js"; +import {printArray, createElement, + createAccordionElement, removeElement, + removeChildrenFromElement} from "../utils/HelperFunctions.js"; +import {logBoxCreate} from "../utils/LogBox.js"; +import numeral from "../utils/numeral.min.js"; +import {formatNumber} from "../utils/StringHelperFunctions.js"; - -/* Active Scripts UI*/ -function setActiveScriptsClickHandlers() { - //Server panel click handlers - var serverPanels = document.getElementsByClassName("active-scripts-server-header"); - if (serverPanels == null) { - console.log("ERROR: Could not find Active Scripts server panels"); - return; - } - for (i = 0; i < serverPanels.length; ++i) { - serverPanels[i].onclick = function() { - this.classList.toggle("active"); - - var panel = this.nextElementSibling; - if (panel.style.display === "block") { - panel.style.display = "none"; - } else { - panel.style.display = "block"; - } - } - } - - //Script Panel click handlers - var scriptPanels = document.getElementsByClassName("active-scripts-script-header"); - if (scriptPanels == null) { - console.log("ERROR: Could not find Active Scripts panels for individual scripts"); - return; - } - for (var i = 0; i < scriptPanels.length; ++i) { - scriptPanels[i].onclick = function() { - this.classList.toggle("active"); - - var panel = this.nextElementSibling; - if (panel.style.display === "block") { - panel.style.display = "none"; - } else { - panel.style.display = "block"; - } - } - } -} - -//Returns the ul element containins all script items for a specific server -function getActiveScriptsServerList(server) { - if (server == null) {return null;} - var panelname = "active-scripts-server-panel-" + server.hostname; - var item = document.getElementById(panelname + "-script-list"); - if (item == null) { - console.log("ERROR: Cannot find list for: " + server.hostname); - } - return item; -} +/* { + * serverName: { + * header: Server Header Element + * panel: Server Panel List (ul) element + * scripts: { + * script id: Ref to Script information + * } + * } + * ... + */ +let ActiveScriptsUI = {}; function createActiveScriptsServerPanel(server) { - var panelname = "active-scripts-server-panel-" + server.hostname; + let hostname = server.hostname; + if (ActiveScriptsUI[hostname] != null) { + console.log("WARNING: Tried to create already-existing Active Scripts Server panel. Aborting"); + return; + } var activeScriptsList = document.getElementById("active-scripts-list"); - //Div of entire Panel - var panelDiv = document.createElement("div"); - panelDiv.setAttribute("id", panelname); + let res = createAccordionElement({hdrText:hostname}); + let li = res[0]; + var hdr = res[1]; + let panel = res[2]; - //Panel Header - var panelHdr = document.createElement("button"); - panelHdr.setAttribute("class", "active-scripts-server-header") - panelHdr.setAttribute("id", panelname + "-hdr"); - panelHdr.innerHTML = server.hostname; + var panelScriptList = createElement("ul"); + panel.appendChild(panelScriptList); + activeScriptsList.appendChild(li); - //Panel content - var panelContentDiv = document.createElement("div"); - panelContentDiv.setAttribute("class", "active-scripts-server-panel"); - panelContentDiv.setAttribute("id", panelname + "-content"); + ActiveScriptsUI[hostname] = { + header: hdr, + panel: panel, + panelList: panelScriptList, + scripts: {}, //Holds references to li elements for each active script + scriptHdrs: {}, //Holds references to header elements for each active script + scriptStats: {} //Holds references to the p elements containing text for each active script + }; - //List of scripts - var panelScriptList = document.createElement("ul"); - panelScriptList.setAttribute("id", panelname + "-script-list"); - - panelContentDiv.appendChild(panelScriptList); - panelDiv.appendChild(panelHdr); - panelDiv.appendChild(panelContentDiv); - activeScriptsList.appendChild(panelDiv); - - setActiveScriptsClickHandlers() //Reset click handlers - - return panelDiv; + return li; } //Deletes the info for a particular server (Dropdown header + Panel with all info) //in the Active Scripts page if it exists function deleteActiveScriptsServerPanel(server) { - var panelname = "active-scripts-server-panel-" + server.hostname; - var panel = document.getElementById(panelname); - if (panel == null) { - console.log("No such panel exists: " + panelname); + let hostname = server.hostname; + if (ActiveScriptsUI[hostname] == null) { + console.log("WARNING: Tried to delete non-existent Active Scripts Server panel. Aborting"); return; } - //Remove the panel if it has no elements - var scriptList = document.getElementById(panelname + "-script-list"); - if (scriptList.childNodes.length == 0) { - panel.parentNode.removeChild(panel); + //Make sure it's empty + if (Object.keys(ActiveScriptsUI[hostname].scripts).length > 0) { + console.log("WARNING: Tried to delete Active Scripts Server panel that still has scripts. Aborting"); + return; } + + removeElement(ActiveScriptsUI[hostname].panel); + removeElement(ActiveScriptsUI[hostname].header); + delete ActiveScriptsUI[hostname]; } function addActiveScriptsItem(workerscript) { //Get server panel var server = getServer(workerscript.serverIp); if (server == null) { - console.log("ERROR: Invalid server IP for workerscript."); + console.log("ERROR: Invalid server IP for workerscript in addActiveScriptsItem()"); return; } - var panelname = "active-scripts-server-panel-" + server.hostname; - - var panel = document.getElementById(panelname); - if (panel == null) { - panel = createActiveScriptsServerPanel(server); + let hostname = server.hostname; + if (ActiveScriptsUI[hostname] == null) { + createActiveScriptsServerPanel(server); } - //Create the element itself. Each element is an accordion collapsible + //Create the unique identifier (key) for this script var itemNameArray = ["active", "scripts", server.hostname, workerscript.name]; for (var i = 0; i < workerscript.args.length; ++i) { itemNameArray.push(String(workerscript.args[i])); } var itemName = itemNameArray.join("-"); - var item = document.createElement("li"); - item.setAttribute("id", itemName); - var btn = document.createElement("button"); - btn.setAttribute("class", "active-scripts-script-header"); - btn.setAttribute("id", itemName + "-header"); - btn.innerHTML = workerscript.name; + let res = createAccordionElement({hdrText:workerscript.name}); + let li = res[0]; + let hdr = res[1]; + let panel = res[2]; - var itemContentDiv = document.createElement("div"); - itemContentDiv.setAttribute("class", "active-scripts-script-panel"); - itemContentDiv.setAttribute("id", itemName + "-content"); + hdr.classList.remove("accordion-header"); + hdr.classList.add("active-scripts-script-header"); + panel.classList.remove("accordion-panel"); + panel.classList.add("active-scripts-script-panel"); - item.appendChild(btn); - item.appendChild(itemContentDiv); - - createActiveScriptsText(workerscript, itemContentDiv); + //Handle the constant elements on the panel that don't change after creation + //Threads, args, kill/log button + panel.appendChild(createElement("p", { + innerHTML: "Threads: " + workerscript.scriptRef.threads + "
" + + "Args: " + printArray(workerscript.args) + })); + var panelText = createElement("p", { + innerText:"Loading...", fontSize:"14px", + }); + updateActiveScriptsText(workerscript, panelText, itemName); + panel.appendChild(panelText); + panel.appendChild(createElement("br")); + panel.appendChild(createElement("span", { + innerText:"Log", class:"active-scripts-button", margin:"4px", padding:"4px", + clickListener:()=>{ + logBoxCreate(workerscript.scriptRef); + return false; + } + })); + panel.appendChild(createElement("span", { + innerText:"Kill Script", class:"active-scripts-button", margin:"4px", padding:"4px", + clickListener:()=>{ + killWorkerScript(workerscript.scriptRef, workerscript.scriptRef.scriptRef.server); + dialogBoxCreate("Killing script, may take a few minutes to complete..."); + return false; + } + })); //Append element to list - var list = getActiveScriptsServerList(server); - list.appendChild(item); - - setActiveScriptsClickHandlers() //Reset click handlers + ActiveScriptsUI[hostname]["panelList"].appendChild(li); + ActiveScriptsUI[hostname].scripts[itemName] = li; + ActiveScriptsUI[hostname].scriptHdrs[itemName] = hdr; + ActiveScriptsUI[hostname].scriptStats[itemName] = panelText; } function deleteActiveScriptsItem(workerscript) { @@ -162,18 +142,31 @@ function deleteActiveScriptsItem(workerscript) { console.log("ERROR: Invalid server IP for workerscript."); return; } + let hostname = server.hostname; + if (ActiveScriptsUI[hostname] == null) { + console.log("ERROR: Trying to delete Active Script UI Element with a hostname that cant be found in ActiveScriptsUI: " + hostname); + return; + } + var itemNameArray = ["active", "scripts", server.hostname, workerscript.name]; for (var i = 0; i < workerscript.args.length; ++i) { itemNameArray.push(String(workerscript.args[i])); } var itemName = itemNameArray.join("-"); - var li = document.getElementById(itemName); + + let li = ActiveScriptsUI[hostname].scripts[itemName]; if (li == null) { - console.log("could not find Active scripts li element for: " + workerscript.name); + console.log("ERROR: Cannot find Active Script UI element for workerscript: "); + console.log(workerscript); return; } - li.parentNode.removeChild(li); - deleteActiveScriptsServerPanel(server); + removeElement(li); + delete ActiveScriptsUI[hostname].scripts[itemName]; + delete ActiveScriptsUI[hostname].scriptHdrs[itemName]; + delete ActiveScriptsUI[hostname].scriptStats[itemName]; + if (Object.keys(ActiveScriptsUI[hostname].scripts).length === 0) { + deleteActiveScriptsServerPanel(server); + } } //Update the ActiveScriptsItems array @@ -197,69 +190,47 @@ function updateActiveScriptsItemContent(workerscript) { console.log("ERROR: Invalid server IP for workerscript."); return; } + let hostname = server.hostname; + if (ActiveScriptsUI[hostname] == null) { + console.log("ERROR: Trying to update Active Script UI Element with a hostname that cant be found in ActiveScriptsUI: " + hostname); + return; + } + var itemNameArray = ["active", "scripts", server.hostname, workerscript.name]; for (var i = 0; i < workerscript.args.length; ++i) { itemNameArray.push(String(workerscript.args[i])); } var itemName = itemNameArray.join("-"); - var itemContent = document.getElementById(itemName + "-content") + var item = ActiveScriptsUI[hostname].scriptStats[itemName]; - //Add the updated text back. Returns the total online production rate - return updateActiveScriptsText(workerscript, itemContent); + //Update the text if necessary. This fn returns the online $/s production + return updateActiveScriptsText(workerscript, item, itemName); } -function createActiveScriptsText(workerscript, item) { - var itemTextHeader = document.createElement("p"); - var itemTextStats = document.createElement("p"); - var itemId = item.id; - itemTextStats.setAttribute("id", itemId + "-stats"); - - //Server ip/hostname - var threads = "Threads: " + workerscript.scriptRef.threads; - var args = "Args: " + printArray(workerscript.args); - - itemTextHeader.innerHTML = threads + "
" + args + "
"; - - item.appendChild(itemTextHeader); - item.appendChild(itemTextStats); - - var onlineMps = updateActiveScriptsText(workerscript, item, itemTextStats); - - var logButton = document.createElement("span"); - logButton.innerHTML = "Log"; - var killButton = document.createElement("span"); - killButton.innerHTML = "Kill script"; - logButton.setAttribute("class", "active-scripts-button"); - killButton.setAttribute("class", "active-scripts-button"); - logButton.addEventListener("click", function() { - logBoxCreate(workerscript.scriptRef); - return false; - }); - killButton.addEventListener("click", function() { - killWorkerScript(workerscript.scriptRef, workerscript.scriptRef.scriptRef.server); - dialogBoxCreate("Killing script, may take a few minutes to complete..."); - return false; - }); - item.appendChild(logButton); - item.appendChild(killButton); - - //Return total online production rate - return onlineMps; -} - -function updateActiveScriptsText(workerscript, item, statsEl=null) { - var itemId = item.id - var itemTextStats = document.getElementById(itemId + "-stats"); - if (itemTextStats == null || itemTextStats === undefined) { - itemTextStats = statsEl; +function updateActiveScriptsText(workerscript, item, itemName) { + var server = getServer(workerscript.serverIp); + if (server == null) { + console.log("ERROR: Invalid server IP for workerscript."); + return; + } + let hostname = server.hostname; + if (ActiveScriptsUI[hostname] == null) { + console.log("ERROR: Trying to update Active Script UI Element with a hostname that cant be found in ActiveScriptsUI: " + hostname); + return; } - //Updates statistics only + var onlineMps = workerscript.scriptRef.onlineMoneyMade / workerscript.scriptRef.onlineRunningTime; + + //Only update if the item is visible + if (ActiveScriptsUI[hostname].header.classList.contains("active") === false) {return onlineMps;} + if (ActiveScriptsUI[hostname].scriptHdrs[itemName].classList.contains("active") === false) {return onlineMps;} + + removeChildrenFromElement(item); + //Online var onlineTotalMoneyMade = "Total online production: $" + formatNumber(workerscript.scriptRef.onlineMoneyMade, 2); var onlineTotalExpEarned = (Array(26).join(" ") + formatNumber(workerscript.scriptRef.onlineExpGained, 2) + " hacking exp").replace( / /g, " "); - var onlineMps = workerscript.scriptRef.onlineMoneyMade / workerscript.scriptRef.onlineRunningTime; var onlineMpsText = "Online production rate: $" + formatNumber(onlineMps, 2) + "/second"; var onlineEps = workerscript.scriptRef.onlineExpGained / workerscript.scriptRef.onlineRunningTime; var onlineEpsText = (Array(25).join(" ") + formatNumber(onlineEps, 4) + " hacking exp/second").replace( / /g, " "); @@ -273,10 +244,10 @@ function updateActiveScriptsText(workerscript, item, statsEl=null) { var offlineEps = workerscript.scriptRef.offlineExpGained / workerscript.scriptRef.offlineRunningTime; var offlineEpsText = (Array(26).join(" ") + formatNumber(offlineEps, 4) + " hacking exp/second").replace( / /g, " "); - itemTextStats.innerHTML = onlineTotalMoneyMade + "
" + onlineTotalExpEarned + "
" + - onlineMpsText + "
" + onlineEpsText + "
" + offlineTotalMoneyMade + "
" + offlineTotalExpEarned + "
" + - offlineMpsText + "
" + offlineEpsText + "
"; + item.innerHTML = onlineTotalMoneyMade + "
" + onlineTotalExpEarned + "
" + + onlineMpsText + "
" + onlineEpsText + "
" + offlineTotalMoneyMade + "
" + offlineTotalExpEarned + "
" + + offlineMpsText + "
" + offlineEpsText + "
"; return onlineMps; } -export {setActiveScriptsClickHandlers, addActiveScriptsItem, deleteActiveScriptsItem, updateActiveScriptsItems}; +export {addActiveScriptsItem, deleteActiveScriptsItem, updateActiveScriptsItems}; diff --git a/src/Bladeburner.js b/src/Bladeburner.js index 4c25bf25b..8066d7ab4 100644 --- a/src/Bladeburner.js +++ b/src/Bladeburner.js @@ -691,9 +691,9 @@ Bladeburner.prototype.create = function() { "and information-gathering ONLY. Do NOT engage. Stealth is of the utmost importance.

" + "Successfully completing Tracking contracts will slightly improve your Synthoid population estimate for " + "whatever city you are currently in.", - baseDifficulty:150,difficultyFac:1.02,rewardFac:1.041, + baseDifficulty:125,difficultyFac:1.02,rewardFac:1.041, rankGain:0.3, hpLoss:0.5, - count:getRandomInt(400, 800), countGrowth:getRandomInt(1, 5), + count:getRandomInt(300, 800), countGrowth:getRandomInt(1, 5), weights:{hack:0,str:0.05,def:0.05,dex:0.35,agi:0.35,cha:0.1, int:0.05}, decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.9, int:1}, isStealth:true @@ -705,7 +705,7 @@ Bladeburner.prototype.create = function() { "current city, and will also increase its chaos level.", baseDifficulty:250, difficultyFac:1.04,rewardFac:1.085, rankGain:0.9, hpLoss:1, - count:getRandomInt(250, 500), countGrowth:getRandomInt(1, 3), + count:getRandomInt(200, 750), countGrowth:getRandomInt(1, 3), weights:{hack:0,str:0.15,def:0.15,dex:0.25,agi:0.25,cha:0.1, int:0.1}, decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.8, int:0.9}, isKill:true @@ -717,7 +717,7 @@ Bladeburner.prototype.create = function() { "city, and will also increase its chaos level.", baseDifficulty:200, difficultyFac:1.03, rewardFac:1.065, rankGain:0.6, hpLoss:1, - count:getRandomInt(300, 600), countGrowth:getRandomInt(1,4), + count:getRandomInt(300, 900), countGrowth:getRandomInt(1,4), weights:{hack:0,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0.1, int:0.1}, decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.8, int:0.9}, isKill:true @@ -732,7 +732,7 @@ Bladeburner.prototype.create = function() { "You will NOT lose HP from failed Investigation ops.", baseDifficulty:400, difficultyFac:1.03,rewardFac:1.07,reqdRank:25, rankGain:2, rankLoss:0.2, - count:getRandomInt(100, 300), countGrowth:1, + count:getRandomInt(50, 400), countGrowth:1, weights:{hack:0.25,str:0.05,def:0.05,dex:0.2,agi:0.1,cha:0.25, int:0.1}, decays:{hack:0.85,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.7, int:0.9}, isStealth:true @@ -745,7 +745,7 @@ Bladeburner.prototype.create = function() { "data.", baseDifficulty:500, difficultyFac:1.04, rewardFac:1.09, reqdRank:100, rankGain:4, rankLoss:0.4, hpLoss:2, - count:getRandomInt(100, 250), countGrowth:1, + count:getRandomInt(50, 300), countGrowth:1, weights:{hack:0.2,str:0.05,def:0.05,dex:0.2,agi:0.2,cha:0.2, int:0.1}, decays:{hack:0.8,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.7, int:0.9}, isStealth:true @@ -756,7 +756,7 @@ Bladeburner.prototype.create = function() { "notorious Synthoid criminals.", baseDifficulty:650, difficultyFac:1.04, rewardFac:1.095, reqdRank:500, rankGain:5, rankLoss:0.5, hpLoss:2.5, - count:getRandomInt(100,250), countGrowth:0.75, + count:getRandomInt(25,400), countGrowth:0.75, weights:{hack:0.25,str:0.05,def:0.05,dex:0.25,agi:0.1,cha:0.2, int:0.1}, decays:{hack:0.8,str:0.85,def:0.85,dex:0.85,agi:0.85,cha:0.7, int:0.9}, isStealth:true @@ -768,7 +768,7 @@ Bladeburner.prototype.create = function() { "in order for this Operation to be successful", baseDifficulty:800, difficultyFac:1.045, rewardFac:1.1, reqdRank:3000, rankGain:50,rankLoss:2.5,hpLoss:50, - count:getRandomInt(50, 100), countGrowth:0.2, + count:getRandomInt(25, 150), countGrowth:0.2, weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1}, decays:{hack:0.7,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.9}, isKill:true @@ -780,7 +780,7 @@ Bladeburner.prototype.create = function() { "drawing any attention. Stealth and discretion are key.", baseDifficulty:1000, difficultyFac:1.05, rewardFac:1.11, reqdRank:20e3, rankGain:20, rankLoss:2, hpLoss:10, - count:getRandomInt(50, 200), countGrowth:0.1, + count:getRandomInt(25, 250), countGrowth:0.1, weights:{hack:0.1,str:0.1,def:0.1,dex:0.3,agi:0.3,cha:0, int:0.1}, decays:{hack:0.7,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.9}, isStealth:true, isKill:true @@ -792,7 +792,7 @@ Bladeburner.prototype.create = function() { "in the Synthoid communities.", baseDifficulty:1500, difficultyFac:1.06, rewardFac:1.14, reqdRank:50e3, rankGain:40, rankLoss:4, hpLoss:5, - count:getRandomInt(50, 150), countGrowth:0.1, + count:getRandomInt(25, 200), countGrowth:0.1, weights:{hack:0.1,str:0.1,def:0.1,dex:0.3,agi:0.3,cha:0, int:0.1}, decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.8}, isStealth:true, isKill:true diff --git a/src/Constants.js b/src/Constants.js index 8c6aebfc0..e8c67db72 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -1139,7 +1139,12 @@ let CONSTANTS = { LatestUpdate: "v0.36.1
" + + "* Bladeburner Changes:
" + + "** Bug Fix: You can no longer get Bladeburner faction reputation through Infiltration
" + + "** Initial difficulty of Tracking contracts reduced
" + "* The ctrl+b hotkey in the text editor is now also triggered by command+b or winkey+b
" + + "* Many servers now have additional RAM
" + + "* Added an option to disable hotkeys/keyboard shortcuts
" + "v0.36.0
" + "* Added BN-6: Bladeburners
" + "* Rebalanced many combat Augmentations so that they are slightly less powerful
" + diff --git a/src/Script.js b/src/Script.js index 5ccb5c05e..9f3479af9 100644 --- a/src/Script.js +++ b/src/Script.js @@ -233,6 +233,7 @@ function updateScriptEditorContent() { //Define key commands in script editor (ctrl o to save + close, etc.) $(document).keydown(function(e) { + if (Settings.DisableHotkeys === true) {return;} if (Engine.currentPage == Engine.Page.ScriptEditor) { //Ctrl + b if (e.keyCode == 66 && (e.ctrlKey || e.metaKey)) { diff --git a/src/Server.js b/src/Server.js index d324cd851..f009a0d68 100644 --- a/src/Server.js +++ b/src/Server.js @@ -23,16 +23,16 @@ function Server(params={ip:createRandomIp(), hostname:""}) { ++i; } this.hostname = hostname + suffix; - this.organizationName = params.organizationName ? params.organizationName : ""; - this.isConnectedTo = params.isConnectedTo ? params.isConnectedTo : false; + this.organizationName = params.organizationName != null ? params.organizationName : ""; + this.isConnectedTo = params.isConnectedTo != null ? params.isConnectedTo : false; //Access information - this.hasAdminRights = params.adminRights ? params.adminRights : false; - this.purchasedByPlayer = params.purchasedByPlayer ? params.purchasedByPlayer : false; + this.hasAdminRights = params.adminRights != null ? params.adminRights : false; + this.purchasedByPlayer = params.purchasedByPlayer != null ? params.purchasedByPlayer : false; this.manuallyHacked = false; //Flag that tracks whether or not the server has been hacked at least once //RAM, CPU speed and Scripts - this.maxRam = params.maxRam ? params.maxRam : 0; //GB + this.maxRam = params.maxRam != null ? params.maxRam : 0; //GB this.ramUsed = 0; this.cpuCores = 1; //Max of 8, affects hacking times and Hacking Mission starting Cores @@ -44,22 +44,22 @@ function Server(params={ip:createRandomIp(), hostname:""}) { this.dir = 0; //new Directory(this, null, ""); TODO /* Hacking information (only valid for "foreign" aka non-purchased servers) */ - this.requiredHackingSkill = params.requiredHackingSkill ? params.requiredHackingSkill : 1; - this.moneyAvailable = params.moneyAvailable ? params.moneyAvailable * BitNodeMultipliers.ServerStartingMoney : 1e6; + this.requiredHackingSkill = params.requiredHackingSkill != null ? params.requiredHackingSkill : 1; + this.moneyAvailable = params.moneyAvailable != null ? params.moneyAvailable * BitNodeMultipliers.ServerStartingMoney : 1e6; this.moneyMax = 25 * this.moneyAvailable * BitNodeMultipliers.ServerMaxMoney; //Hack Difficulty is synonymous with server security. Base Difficulty = Starting difficulty - this.hackDifficulty = params.hackDifficulty ? params.hackDifficulty * BitNodeMultipliers.ServerStartingSecurity : 1; + this.hackDifficulty = params.hackDifficulty != null ? params.hackDifficulty * BitNodeMultipliers.ServerStartingSecurity : 1; this.baseDifficulty = this.hackDifficulty; this.minDifficulty = Math.max(1, Math.round(this.hackDifficulty / 3)); - this.serverGrowth = params.serverGrowth ? params.serverGrowth : 1; //Integer from 0 to 100. Affects money increase from grow() + this.serverGrowth = params.serverGrowth != null ? params.serverGrowth : 1; //Integer from 0 to 100. Affects money increase from grow() //The IP's of all servers reachable from this one (what shows up if you run scan/netstat) // NOTE: Only contains IP and not the Server objects themselves this.serversOnNetwork = []; //Port information, required for porthacking servers to get admin rights - this.numOpenPortsRequired = params.numOpenPortsRequired ? params.numOpenPortsRequired : 5; + this.numOpenPortsRequired = params.numOpenPortsRequired != null ? params.numOpenPortsRequired : 5; this.sshPortOpen = false; //Port 22 this.ftpPortOpen = false; //Port 21 this.smtpPortOpen = false; //Port 25 @@ -527,7 +527,6 @@ function initForeignServers() { requiredHackingSkill:20, moneyAvailable:2.75e6, hackDifficulty:20, serverGrowth:25, numOpenPortsRequired:0 }); - NectarNightclubServer.setPortProperties(0); AddToAllServers(NectarNightclubServer); var NeoNightclubServer = new Server({ diff --git a/src/Settings.js b/src/Settings.js index 4210fd443..e3755e242 100644 --- a/src/Settings.js +++ b/src/Settings.js @@ -2,17 +2,18 @@ import {Engine} from "./engine.js"; /* Settings.js */ let Settings = { - CodeInstructionRunTime: 50, - MaxLogCapacity: 50, - MaxPortCapacity: 50, - SuppressMessages: false, - SuppressFactionInvites: false, - AutosaveInterval: 60, - ThemeHighlightColor: "#ffffff", - ThemeFontColor: "#66ff33", - ThemeBackgroundColor: "#000000", - EditorTheme: "Monokai", - EditorKeybinding: "ace", + CodeInstructionRunTime: 50, + MaxLogCapacity: 50, + MaxPortCapacity: 50, + SuppressMessages: false, + SuppressFactionInvites: false, + AutosaveInterval: 60, + DisableHotkeys: false, + ThemeHighlightColor: "#ffffff", + ThemeFontColor: "#66ff33", + ThemeBackgroundColor: "#000000", + EditorTheme: "Monokai", + EditorKeybinding: "ace", } function loadSettings(saveString) { @@ -26,6 +27,7 @@ function initSettings() { Settings.SuppressMessages = false; Settings.SuppressFactionInvites = false; Settings.AutosaveInterval = 60; + Settings.DisableHotkeys = false; } function setSettingsLabels() { @@ -35,6 +37,7 @@ function setSettingsLabels() { var suppressMsgs = document.getElementById("settingsSuppressMessages"); var suppressFactionInv = document.getElementById("settingsSuppressFactionInvites") var autosaveInterval = document.getElementById("settingsAutosaveIntervalValLabel"); + var disableHotkeys = document.getElementById("settingsDisableHotkeys"); //Initialize values on labels nsExecTime.innerHTML = Settings.CodeInstructionRunTime + "ms"; @@ -43,6 +46,7 @@ function setSettingsLabels() { suppressMsgs.checked = Settings.SuppressMessages; suppressFactionInv.checked = Settings.SuppressFactionInvites; autosaveInterval.innerHTML = Settings.AutosaveInterval; + disableHotkeys.checked = Settings.DisableHotkeys; //Set handlers for when input changes var nsExecTimeInput = document.getElementById("settingsNSExecTimeRangeVal"); @@ -79,14 +83,18 @@ function setSettingsLabels() { } }; - document.getElementById("settingsSuppressMessages").onclick = function() { + suppressMsgs.onclick = function() { Settings.SuppressMessages = this.checked; }; - document.getElementById("settingsSuppressFactionInvites").onclick = function() { + suppressFactionInv.onclick = function() { Settings.SuppressFactionInvites = this.checked; }; + disableHotkeys.onclick = function() { + Settings.DisableHotkeys = this.checked; + } + //Theme if (Settings.ThemeHighlightColor == null || Settings.ThemeFontColor == null || Settings.ThemeBackgroundColor == null) { console.log("ERROR: Cannot find Theme Settings"); diff --git a/src/Terminal.js b/src/Terminal.js index 59456cd9c..4af264ed7 100644 --- a/src/Terminal.js +++ b/src/Terminal.js @@ -86,11 +86,15 @@ var KEY = { E: 69, F: 70, H: 72, + J: 74, K: 75, L: 76, M: 77, N: 78, + O: 79, P: 80, + R: 82, + S: 83, U: 85, W: 87, } @@ -259,9 +263,9 @@ $(document).keydown(function(event) { }); //Keep terminal in focus -let terminalCtrlPressed = false; +let terminalCtrlPressed = false, shiftKeyPressed = false; $(document).ready(function() { - if (Engine.currentPage == Engine.Page.Terminal) { + if (Engine.currentPage === Engine.Page.Terminal) { $('.terminal-input').focus(); } }); @@ -269,15 +273,16 @@ $(document).keydown(function(e) { if (Engine.currentPage == Engine.Page.Terminal) { if (e.which == 17) { terminalCtrlPressed = true; - } else if (terminalCtrlPressed == true) { + } else if (e.shiftKey) { + shiftKeyPressed = true; + } else if (terminalCtrlPressed || shiftKeyPressed) { //Don't focus } else { var inputTextBox = document.getElementById("terminal-input-text-box"); - if (inputTextBox != null) { - inputTextBox.focus(); - } + if (inputTextBox != null) {inputTextBox.focus();} terminalCtrlPressed = false; + shiftKeyPressed = false; } } }) @@ -286,6 +291,9 @@ $(document).keyup(function(e) { if (e.which == 17) { terminalCtrlPressed = false; } + if (e.shiftKey) { + shiftKeyPressed = false; + } } }) @@ -1304,12 +1312,11 @@ let Terminal = { } //Check if its a script or just a program/executable - if (isScriptFilename(executableName) == -1) { - // Not a script - Terminal.runProgram(executableName); - } else { - //Script + //if (isScriptFilename(executableName)) { + if (executableName.includes(".script") || executableName.includes(".js") || executableName.includes(".ns")) { Terminal.runScript(executableName); + } else { + Terminal.runProgram(executableName); } } break; diff --git a/src/engine.js b/src/engine.js index 8c5123686..9f2c803d5 100644 --- a/src/engine.js +++ b/src/engine.js @@ -9,8 +9,7 @@ import {formatNumber, import {loxBoxCreate, logBoxUpdateText, logBoxOpened} from "../utils/LogBox.js"; -import {setActiveScriptsClickHandlers, - updateActiveScriptsItems} from "./ActiveScriptsUI.js"; +import {updateActiveScriptsItems} from "./ActiveScriptsUI.js"; import {Augmentations, installAugmentations, initAugmentations, AugmentationNames, displayAugmentationsContent} from "./Augmentations.js"; @@ -58,7 +57,7 @@ import {StockMarket, StockSymbols, initSymbolToStockMap, stockMarketCycle, updateStockPrices, displayStockMarketContent} from "./StockMarket.js"; -import {Terminal, postNetburnerText, post} from "./Terminal.js"; +import {Terminal, postNetburnerText, post, KEY} from "./Terminal.js"; /* Shortcuts to navigate through the game * Alt-t - Terminal @@ -76,51 +75,52 @@ import {Terminal, postNetburnerText, post} from "./Terminal.js"; * Alt-o - Options */ $(document).keydown(function(e) { + if (Settings.DisableHotkeys === true) {return;} if (!Player.isWorking && !redPillFlag && !inMission && !cinematicTextFlag) { if (e.keyCode == 84 && e.altKey) { e.preventDefault(); Engine.loadTerminalContent(); - } else if (e.keyCode == 67 && e.altKey) { + } else if (e.keyCode === KEY.C && e.altKey) { e.preventDefault(); Engine.loadCharacterContent(); - } else if (e.keyCode == 69 && e.altKey) { + } else if (e.keyCode === KEY.E && e.altKey) { e.preventDefault(); Engine.loadScriptEditorContent(); - } else if (e.keyCode == 83 && e.altKey) { + } else if (e.keyCode === KEY.S && e.altKey) { e.preventDefault(); Engine.loadActiveScriptsContent(); - } else if (e.keyCode == 72 && e.altKey) { + } else if (e.keyCode === KEY.H && e.altKey) { e.preventDefault(); Engine.loadHacknetNodesContent(); - } else if (e.keyCode == 87 && e.altKey) { + } else if (e.keyCode === KEY.W && e.altKey) { e.preventDefault(); Engine.loadWorldContent(); - } else if (e.keyCode == 74 && e.altKey) { + } else if (e.keyCode === KEY.J && e.altKey) { e.preventDefault(); Engine.loadJobContent(); - } else if (e.keyCode == 82 && e.altKey) { + } else if (e.keyCode === KEY.R && e.altKey) { e.preventDefault(); Engine.loadTravelContent(); - } else if (e.keyCode == 80 && e.altKey) { + } else if (e.keyCode === KEY.P && e.altKey) { e.preventDefault(); Engine.loadCreateProgramContent(); - } else if (e.keyCode == 70 && e.altKey) { + } else if (e.keyCode === KEY.F && e.altKey) { //Overriden by Fconf if (Engine.currentPage === Engine.Page.Terminal && FconfSettings.ENABLE_BASH_HOTKEYS) { return; } e.preventDefault(); Engine.loadFactionsContent(); - } else if (e.keyCode == 65 && e.altKey) { + } else if (e.keyCode === KEY.A && e.altKey) { e.preventDefault(); Engine.loadAugmentationsContent(); - } else if (e.keyCode == 85 && e.altKey) { + } else if (e.keyCode === KEY.U && e.altKey) { e.preventDefault(); Engine.loadTutorialContent(); } } - if (e.keyCode == 79 && e.altKey) { + if (e.keyCode === KEY.O && e.altKey) { e.preventDefault(); gameOptionsBoxOpen(); } @@ -260,7 +260,6 @@ let Engine = { loadActiveScriptsContent: function() { Engine.hideAllContent(); Engine.Display.activeScriptsContent.style.display = "block"; - setActiveScriptsClickHandlers(); updateActiveScriptsItems(); Engine.currentPage = Engine.Page.ActiveScripts; document.getElementById("active-scripts-menu-link").classList.add("active"); @@ -963,7 +962,7 @@ let Engine = { } else if (Engine.currentPage === Engine.Page.Corporation) { Player.corporation.updateUIContent(); } - Engine.Counters.updateDisplaysMed = 9; + Engine.Counters.updateDisplaysMed = 6; } if (Engine.Counters.updateDisplaysLong <= 0) { diff --git a/utils/InfiltrationBox.js b/utils/InfiltrationBox.js index 5c7538d4a..367d2c253 100644 --- a/utils/InfiltrationBox.js +++ b/utils/InfiltrationBox.js @@ -61,6 +61,7 @@ function infiltrationBoxCreate(inst) { var selector = document.getElementById("infiltration-faction-select"); selector.innerHTML = ""; for (var i = 0; i < Player.factions.length; ++i) { + if (Player.factions[i] === "Bladeburners") {continue;} selector.innerHTML += ""; }