diff --git a/dist/engine.bundle.js b/dist/engine.bundle.js index 7d8300444..811652824 100644 --- a/dist/engine.bundle.js +++ b/dist/engine.bundle.js @@ -80,13 +80,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Player", function() { return Player; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadPlayer", function() { return loadPlayer; }); -/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 18); +/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 19); /* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BitNode.js */ 15); /* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Company.js */ 9); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Constants.js */ 3); /* harmony import */ var _CompanyManagement_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./CompanyManagement.js */ 40); /* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./CreateProgram.js */ 14); -/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Crimes.js */ 19); +/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Crimes.js */ 20); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./engine.js */ 5); /* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Faction.js */ 11); /* harmony import */ var _Gang_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Gang.js */ 36); @@ -95,7 +95,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Server.js */ 10); /* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); /* harmony import */ var _SourceFile_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./SourceFile.js */ 42); -/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/decimal.js */ 23); +/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/decimal.js */ 24); /* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_utils_decimal_js__WEBPACK_IMPORTED_MODULE_15__); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); @@ -309,7 +309,10 @@ function PlayerObject() { PlayerObject.prototype.init = function() { /* Initialize Player's home computer */ - var t_homeComp = new _Server_js__WEBPACK_IMPORTED_MODULE_12__["Server"](Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_18__["createRandomIp"])(), "home", "Home PC", true, true, true, 8); + var t_homeComp = new _Server_js__WEBPACK_IMPORTED_MODULE_12__["Server"]({ + ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_18__["createRandomIp"])(), hostname:"home", organizationName:"Home PC", + isConnectedTo:true, adminRights:true, purchasedByPlayer:true, maxRam:8 + }); this.homeComputer = t_homeComp.ip; this.currentServer = t_homeComp.ip; Object(_Server_js__WEBPACK_IMPORTED_MODULE_12__["AddToAllServers"])(t_homeComp); @@ -1379,7 +1382,7 @@ PlayerObject.prototype.finishCreateProgramWork = function(cancelled, sing=false) this.getHomeComputer().programs.push(programName); } else { - var perc = Math.floor(this.timeWorkedCreateProgram / this.timeNeededToCompleteWork * 100).toString(); + var perc = (Math.floor(this.timeWorkedCreateProgram / this.timeNeededToCompleteWork * 10000)/100).toString(); var incompleteName = programName + "-" + perc + "%-INC"; this.getHomeComputer().programs.push(incompleteName); } @@ -1681,14 +1684,16 @@ PlayerObject.prototype.finishCrime = function(cancelled) { this.workAgiExpGained *= 2; this.workChaExpGained *= 2; if (this.committingCrimeThruSingFn) { - this.singFnCrimeWorkerScript.scriptRef.log("Crime successful! Gained " + - _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_20___default()(this.workMoneyGained).format("$0.000a") + ", " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workHackExpGained, 3) + " hack exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workStrExpGained, 3) + " str exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDefExpGained, 3) + " def exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDexExpGained, 3) + " dex exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workAgiExpGained, 3) + " agi exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workChaExpGained, 3) + " cha exp."); + if(this.singFnCrimeWorkerScript.disableLogs.ALL == null && this.singFnCrimeWorkerScript.disableLogs.commitCrime == null) { + this.singFnCrimeWorkerScript.scriptRef.log("Crime successful! Gained " + + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_20___default()(this.workMoneyGained).format("$0.000a") + ", " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workHackExpGained, 3) + " hack exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workStrExpGained, 3) + " str exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDefExpGained, 3) + " def exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDexExpGained, 3) + " dex exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workAgiExpGained, 3) + " agi exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workChaExpGained, 3) + " cha exp."); + } } else { Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Crime successful!

" + "You gained:
"+ @@ -1710,13 +1715,15 @@ PlayerObject.prototype.finishCrime = function(cancelled) { this.workAgiExpGained /= 2; this.workChaExpGained /= 2; if (this.committingCrimeThruSingFn) { - this.singFnCrimeWorkerScript.scriptRef.log("Crime failed! Gained " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workHackExpGained, 3) + " hack exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workStrExpGained, 3) + " str exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDefExpGained, 3) + " def exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDexExpGained, 3) + " dex exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workAgiExpGained, 3) + " agi exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workChaExpGained, 3) + " chaexp."); + if(this.singFnCrimeWorkerScript.disableLogs.ALL == null && this.singFnCrimeWorkerScript.disableLogs.commitCrime == null) { + this.singFnCrimeWorkerScript.scriptRef.log("Crime failed! Gained " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workHackExpGained, 3) + " hack exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workStrExpGained, 3) + " str exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDefExpGained, 3) + " def exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDexExpGained, 3) + " dex exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workAgiExpGained, 3) + " agi exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workChaExpGained, 3) + " cha exp."); + } } else { Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Crime failed!

" + "You gained:
"+ @@ -2950,7 +2957,7 @@ function generateRandomString(n) { __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONSTANTS", function() { return CONSTANTS; }); let CONSTANTS = { - Version: "0.36.0", + Version: "0.36.1", //Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience //and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then @@ -2991,6 +2998,7 @@ let CONSTANTS = { /* Netscript Constants */ //RAM Costs for different commands + ScriptBaseRamCost: 1.4, ScriptWhileRamCost: 0.2, ScriptForRamCost: 0.2, ScriptIfRamCost: 0.15, @@ -3641,6 +3649,7 @@ let CONSTANTS = { "hostname/ip, regardless of arguments. Returns true if one or more scripts were successfully killed, and false if there were none.

" + "The first argument must be a string with the name of the script. The script name is case sensitive. The second argument is " + "a string with the hostname or IP of the target server. Both arguments are required.

" + + "getScriptName()
Returns the filename of the current script (including the extension)

" + "getScriptRam(scriptname, hostname/ip)
Returns the amount of RAM required to run the specified script on the " + "target server. The first argument must be a string with the name of the script. The script name is case sensitive. " + "The second argument is a string with the hostname or IP of the server where that script is. Both arguments are required.

" + @@ -4090,11 +4099,28 @@ let CONSTANTS = { LatestUpdate: "v0.36.1
" + - "* The ctrl+b hotkey in the text editor is now also triggered by command+b or winkey+b
" + - "v0.36.0
" + - "* Added BN-6: Bladeburners
" + - "* Rebalanced many combat Augmentations so that they are slightly less powerful
" + - "* Bug Fix: When faction invites are suppressed, an invitation will no longer load the Faction page
" + "* Bladeburner Changes:
" + + "** Bug Fix: You can no longer get Bladeburner faction reputation through Infiltration
" + + "** Initial difficulty of Tracking contracts reduced
" + + "** Datamancer skill effect increased from 4% per level to 5%
" + + "** Slightly decreased the base stamina cost of contracts/operations
" + + "** Slightly increased the effects of the Tracer, Digital Observer, Short Circuit, Cloak, and Blade's Intuition skills
" + + "** Overclock skill capped at level 95, rather than 99
" + + "** Training gives significantly more exp/s
" + + "* Crime, Infiltration, and Hacking are now slightly more profitable in BN-6
" + + "* Gyms are now more expensive, but give slightly more exp
" + + "* Added getScriptName() and getHacknetMultipliers() Netscript functions (added by Github user hydroflame)
" + + "* getScriptRam() Netscript function now has default value for the second argument, which is hostname/ip (implemented by Github user hydroflame)
" + + "* There is now a soft-cap on stock price, which means it's no longer possible for the price of a stock to reach insanely-high values
" + + "* The ctrl+b hotkey in the text editor should now also be triggered by command+b on OSX (I don't have OSX so I can't confirm if this works)
" + + "* Many servers now have additional RAM
" + + "* Added an option to disable hotkeys/keyboard shortcuts
" + + "* Refactored 'Active Scripts' UI page to optimize its performance
" + + "* Added a new .fconf Terminal setting: ENABLE_TIMESTAMP
" + + "* 'Netscript Execution Time', which can be found in the Options, now has a minimum value of 15ms rather than 25ms
" + + "* Bug Fix: Fixed a typo in the Fulcrum Technologies company name (Technolgies -> Technologies)
" + + "* Bug Fix: hacknetnodes keyword should no longer incur RAM cost if its in a comment
" + + "* Bug Fix: disableLog() now works for the commitCrime() Netscript function (fixed by Github user hydroflame)" } @@ -4117,7 +4143,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Company.js */ 9); /* harmony import */ var _CompanyManagement_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CompanyManagement.js */ 40); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Constants.js */ 3); -/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Crimes.js */ 19); +/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Crimes.js */ 20); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./engine.js */ 5); /* harmony import */ var _Infiltration_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Infiltration.js */ 119); /* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 29); @@ -4169,7 +4195,7 @@ var Locations = { AevumECorp: "ECorp", AevumBachmanAndAssociates: "Bachman & Associates", AevumClarkeIncorporated: "Clarke Incorporated", - AevumFulcrumTechnologies: "Fulcrum Technolgies", + AevumFulcrumTechnologies: "Fulcrum Technologies", AevumAeroCorp: "AeroCorp", AevumGalacticCybersystems: "Galactic Cybersystems", AevumWatchdogSecurity: "Watchdog Security", @@ -4682,13 +4708,13 @@ function displayLocationContent() { break; case Locations.AevumCrushFitnessGym: - var costMult = 2, expMult = 1.5; + var costMult = 3, expMult = 2; displayGymLocationContent(costMult); setGymLocationButtons(costMult, expMult); break; case Locations.AevumSnapFitnessGym: - var costMult = 6, expMult = 4; + var costMult = 10, expMult = 5; displayGymLocationContent(costMult); setGymLocationButtons(costMult, expMult); break; @@ -4910,7 +4936,7 @@ function displayLocationContent() { break; case Locations.Sector12PowerhouseGym: - var costMult = 10, expMult = 7.5; + var costMult = 20, expMult = 10; displayGymLocationContent(costMult); setGymLocationButtons(costMult, expMult); break; @@ -5162,7 +5188,7 @@ function displayLocationContent() { break; case Locations.VolhavenMilleniumFitnessGym: - var costMult = 3, expMult = 2.5; + var costMult = 7, expMult = 4; displayGymLocationContent(costMult); setGymLocationButtons(costMult, expMult); break; @@ -6130,7 +6156,10 @@ function purchaseTorRouter() { } _Player_js__WEBPACK_IMPORTED_MODULE_8__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].TorRouterCost); - var darkweb = new _Server_js__WEBPACK_IMPORTED_MODULE_9__["Server"](Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_14__["createRandomIp"])(), "darkweb", "", false, false, false, 1); + var darkweb = new _Server_js__WEBPACK_IMPORTED_MODULE_9__["Server"]({ + ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_14__["createRandomIp"])(), hostname:"darkweb", organizationName:"", + isConnectedTo:false, adminRights:false, purchasedByPlayer:false, maxRam:1 + }); Object(_Server_js__WEBPACK_IMPORTED_MODULE_9__["AddToAllServers"])(darkweb); _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_11__["SpecialServerIps"].addIp("Darkweb Server", darkweb.ip); @@ -6330,7 +6359,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2); /* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/LogBox.js */ 51); /* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ActiveScriptsUI.js */ 43); -/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Augmentations.js */ 18); +/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Augmentations.js */ 19); /* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./BitNode.js */ 15); /* harmony import */ var _Bladeburner_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Bladeburner.js */ 47); /* harmony import */ var _CinematicText_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./CinematicText.js */ 70); @@ -6339,27 +6368,27 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Constants.js */ 3); /* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./CreateProgram.js */ 14); /* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Faction.js */ 11); -/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Fconf.js */ 35); +/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Fconf.js */ 32); /* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Location.js */ 4); /* harmony import */ var _Gang_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Gang.js */ 36); /* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./HacknetNode.js */ 39); /* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 25); /* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Literature.js */ 53); /* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Message.js */ 28); -/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Missions.js */ 32); +/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Missions.js */ 33); /* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 29); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _Prestige_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Prestige.js */ 57); /* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./RedPill.js */ 44); /* harmony import */ var _SaveObject_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./SaveObject.js */ 46); /* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Script.js */ 26); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./Settings.js */ 24); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./Settings.js */ 23); /* harmony import */ var _SourceFile_js__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./SourceFile.js */ 42); /* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); -/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./StockMarket.js */ 21); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Terminal.js */ 22); +/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./StockMarket.js */ 22); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Terminal.js */ 18); @@ -6415,51 +6444,52 @@ __webpack_require__.r(__webpack_exports__); * Alt-o - Options */ $(document).keydown(function(e) { + if (_Settings_js__WEBPACK_IMPORTED_MODULE_32__["Settings"].DisableHotkeys === true) {return;} if (!_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].isWorking && !_RedPill_js__WEBPACK_IMPORTED_MODULE_28__["redPillFlag"] && !_Missions_js__WEBPACK_IMPORTED_MODULE_23__["inMission"] && !_CinematicText_js__WEBPACK_IMPORTED_MODULE_10__["cinematicTextFlag"]) { if (e.keyCode == 84 && e.altKey) { e.preventDefault(); Engine.loadTerminalContent(); - } else if (e.keyCode == 67 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].C && e.altKey) { e.preventDefault(); Engine.loadCharacterContent(); - } else if (e.keyCode == 69 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].E && e.altKey) { e.preventDefault(); Engine.loadScriptEditorContent(); - } else if (e.keyCode == 83 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].S && e.altKey) { e.preventDefault(); Engine.loadActiveScriptsContent(); - } else if (e.keyCode == 72 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].H && e.altKey) { e.preventDefault(); Engine.loadHacknetNodesContent(); - } else if (e.keyCode == 87 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].W && e.altKey) { e.preventDefault(); Engine.loadWorldContent(); - } else if (e.keyCode == 74 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].J && e.altKey) { e.preventDefault(); Engine.loadJobContent(); - } else if (e.keyCode == 82 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].R && e.altKey) { e.preventDefault(); Engine.loadTravelContent(); - } else if (e.keyCode == 80 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].P && e.altKey) { e.preventDefault(); Engine.loadCreateProgramContent(); - } else if (e.keyCode == 70 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].F && e.altKey) { //Overriden by Fconf if (Engine.currentPage === Engine.Page.Terminal && _Fconf_js__WEBPACK_IMPORTED_MODULE_16__["FconfSettings"].ENABLE_BASH_HOTKEYS) { return; } e.preventDefault(); Engine.loadFactionsContent(); - } else if (e.keyCode == 65 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].A && e.altKey) { e.preventDefault(); Engine.loadAugmentationsContent(); - } else if (e.keyCode == 85 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].U && e.altKey) { e.preventDefault(); Engine.loadTutorialContent(); } } - if (e.keyCode == 79 && e.altKey) { + if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].O && e.altKey) { e.preventDefault(); Object(_utils_GameOptions_js__WEBPACK_IMPORTED_MODULE_1__["gameOptionsBoxOpen"])(); } @@ -6599,7 +6629,6 @@ let Engine = { loadActiveScriptsContent: function() { Engine.hideAllContent(); Engine.Display.activeScriptsContent.style.display = "block"; - Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_6__["setActiveScriptsClickHandlers"])(); Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_6__["updateActiveScriptsItems"])(); Engine.currentPage = Engine.Page.ActiveScripts; document.getElementById("active-scripts-menu-link").classList.add("active"); @@ -6838,30 +6867,18 @@ let Engine = { displayCharacterOverviewInfo: function() { if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hp == null) {_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hp = _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].max_hp;} + var overviewText = "Hp: " + _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hp + " / " + _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].max_hp + "
" + + "Money: " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_3___default()(_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].money.toNumber()).format('($0.000a)') + "
" + + "Hack: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hacking_skill).toLocaleString() + "
" + + "Str: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].strength).toLocaleString() + "
" + + "Def: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].defense).toLocaleString() + "
" + + "Dex: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].dexterity).toLocaleString() + "
" + + "Agi: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].agility).toLocaleString() + "
" + + "Cha: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].charisma).toLocaleString(); if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].intelligence >= 1) { - document.getElementById("character-overview-text").innerHTML = - ("Hp: " + _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hp + " / " + _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].max_hp + "
" + - "Money: " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_3___default()(_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].money.toNumber()).format('($0.000a)') + "
" + - "Hack: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hacking_skill).toLocaleString() + "
" + - "Str: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].strength).toLocaleString() + "
" + - "Def: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].defense).toLocaleString() + "
" + - "Dex: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].dexterity).toLocaleString() + "
" + - "Agi: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].agility).toLocaleString() + "
" + - "Cha: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].charisma).toLocaleString() + "
" + - "Int: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].intelligence).toLocaleString() - ).replace( / /g, " " ); - } else { - document.getElementById("character-overview-text").innerHTML = - ("Hp: " + _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hp + " / " + _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].max_hp + "
" + - "Money: " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_3___default()(_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].money.toNumber()).format('($0.000a)') + "
" + - "Hack: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hacking_skill).toLocaleString() + "
" + - "Str: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].strength).toLocaleString() + "
" + - "Def: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].defense).toLocaleString() + "
" + - "Dex: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].dexterity).toLocaleString() + "
" + - "Agi: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].agility).toLocaleString() + "
" + - "Cha: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].charisma).toLocaleString() - ).replace( / /g, " " ); + overviewText += "
Int: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].intelligence).toLocaleString(); } + document.getElementById("character-overview-text").innerHTML = overviewText.replace( / /g, " "); }, /* Display character info */ @@ -7239,9 +7256,10 @@ let Engine = { Counters: { autoSaveCounter: 300, //Autosave every minute updateSkillLevelsCounter: 10, //Only update skill levels every 2 seconds. Might improve performance - updateDisplays: 3, //Update displays such as Active Scripts display and character display + updateDisplays: 3, updateDisplaysMed: 9, updateDisplaysLong: 15, + updateActiveScriptsDisplay: 5, createProgramNotifications: 10, //Checks whether any programs can be created and notifies checkFactionInvitations: 100, //Check whether you qualify for any faction invitations passiveFactionGrowth: 600, @@ -7279,6 +7297,16 @@ let Engine = { Engine.Counters.updateSkillLevelsCounter = 10; } + if (Engine.Counters.updateActiveScriptsDisplay <= 0) { + //Always update, but make the interval longer if the page isn't active + Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_6__["updateActiveScriptsItems"])(); + if (Engine.currentPage === Engine.Page.ActiveScripts) { + Engine.Counters.updateActiveScriptsDisplay = 5; + } else { + Engine.Counters.updateActiveScriptsDisplay = 15; + } + } + if (Engine.Counters.updateDisplays <= 0) { Engine.displayCharacterOverviewInfo(); if (Engine.currentPage == Engine.Page.CharacterInfo) { @@ -7297,9 +7325,7 @@ let Engine = { } if (Engine.Counters.updateDisplaysMed <= 0) { - if (Engine.currentPage == Engine.Page.ActiveScripts) { - Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_6__["updateActiveScriptsItems"])(); - } else if (Engine.currentPage === Engine.Page.Corporation) { + if (Engine.currentPage === Engine.Page.Corporation) { _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].corporation.updateUIContent(); } Engine.Counters.updateDisplaysMed = 9; @@ -8225,11 +8251,11 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 69); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Settings.js */ 24); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Settings.js */ 23); /* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Script.js */ 26); -/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/acorn.js */ 34); +/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/acorn.js */ 35); /* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); /* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/IPAddress.js */ 16); @@ -10470,16 +10496,16 @@ function Server(params={ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7 ++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 @@ -10491,22 +10517,22 @@ function Server(params={ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7 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 * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerStartingMoney : 1e6; + this.requiredHackingSkill = params.requiredHackingSkill != null ? params.requiredHackingSkill : 1; + this.moneyAvailable = params.moneyAvailable != null ? params.moneyAvailable * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerStartingMoney : 0; this.moneyMax = 25 * this.moneyAvailable * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerMaxMoney; //Hack Difficulty is synonymous with server security. Base Difficulty = Starting difficulty - this.hackDifficulty = params.hackDifficulty ? params.hackDifficulty * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerStartingSecurity : 1; + this.hackDifficulty = params.hackDifficulty != null ? params.hackDifficulty * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["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 @@ -10515,29 +10541,6 @@ function Server(params={ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7 this.openPortCount = 0; }; -/* -//Set the hacking properties of a server -Server.prototype.setHackingParameters = function(requiredHackingSkill, moneyAvailable, hackDifficulty, serverGrowth) { - this.requiredHackingSkill = requiredHackingSkill; - if (isNaN(moneyAvailable)) { - this.moneyAvailable = 1e6; - } else { - this.moneyAvailable = moneyAvailable * BitNodeMultipliers.ServerStartingMoney; - } - this.moneyMax = - this.hackDifficulty = hackDifficulty * BitNodeMultipliers.ServerStartingSecurity; - this.baseDifficulty = hackDifficulty * BitNodeMultipliers.ServerStartingSecurity; - this.minDifficulty = Math.max(1, Math.round(this.hackDifficulty / 3)); - this.serverGrowth = serverGrowth; -} - -//Set the port properties of a server -//Right now its only the number of open ports needed to PortHack the server. -Server.prototype.setPortProperties = function(numOpenPortsReq) { - this.numOpenPortsRequired = numOpenPortsReq; -} -*/ - Server.prototype.setMaxRam = function(ram) { this.maxRam = ram; } @@ -10974,7 +10977,6 @@ function initForeignServers() { requiredHackingSkill:20, moneyAvailable:2.75e6, hackDifficulty:20, serverGrowth:25, numOpenPortsRequired:0 }); - NectarNightclubServer.setPortProperties(0); AddToAllServers(NectarNightclubServer); var NeoNightclubServer = new Server({ @@ -11409,15 +11411,15 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Faction", function() { return Faction; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "purchaseAugmentation", function() { return purchaseAugmentation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "factionExists", function() { return factionExists; }); -/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 18); +/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 19); /* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BitNode.js */ 15); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Constants.js */ 3); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./engine.js */ 5); /* harmony import */ var _FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./FactionInfo.js */ 27); /* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Location.js */ 4); -/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Missions.js */ 32); +/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Missions.js */ 33); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Player.js */ 0); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Settings.js */ 24); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Settings.js */ 23); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_FactionInvitationBox_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/FactionInvitationBox.js */ 117); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); @@ -12519,7 +12521,9 @@ function getNextNeurofluxLevel() { } } if (aug == null) { - console.log("ERROR, Could not find NeuroFlux Governor aug"); + console.log("WARNING: Could not find NeuroFlux Governor aug. This is OK if " + + "it happens during the loading/initialization of the game, but probably " + + "indicates something seriously wrong at other times"); return 1; } } @@ -13077,10 +13081,10 @@ function initBitNodes() { "for progression. Furthermore:

" + "Hacking and Hacknet Nodes will be significantly less profitable
" + "Your hacking level is reduced by 50%
" + - "Hacking experience gain from scripts is reduced by 80%
" + + "Hacking experience gain from scripts is reduced by 75%
" + "Corporations have 80% lower valuations and are therefore less profitable
" + "Working for companies is 50% less profitable
" + - "Crimes and Infiltration are 75% less profitable

" + + "Crimes and Infiltration are 50% less profitable

" + "Destroying this BitNode will give you Source-File 6, or if you already have this Source-File it will upgrade " + "its level up to a maximum of 3. This Source-File allows you to access the NSA's Bladeburner Division in other " + "BitNodes. In addition, this Source-File will raise the experience gain rate of all your combat stats by:

" + @@ -13246,12 +13250,12 @@ function initBitNodeMultipliers() { BitNodeMultipliers.ServerStartingSecurity = 1.5; BitNodeMultipliers.ScriptHackMoney = 0.5; BitNodeMultipliers.CompanyWorkMoney = 0.5; - BitNodeMultipliers.CrimeMoney = 0.25; - BitNodeMultipliers.InfiltrationMoney = 0.25; + BitNodeMultipliers.CrimeMoney = 0.5; + BitNodeMultipliers.InfiltrationMoney = 0.5; BitNodeMultipliers.CorporationValuation = 0.2; BitNodeMultipliers.HacknetNodeMoney = 0.2; BitNodeMultipliers.FactionPassiveRepGain = 0; - BitNodeMultipliers.HackExpGain = 0.2; + BitNodeMultipliers.HackExpGain = 0.25; break; case 8: //Ghost of Wall Street BitNodeMultipliers.ScriptHackMoney = 0; @@ -13411,6 +13415,2078 @@ function initSpecialServerIps() { /***/ }), /* 18 */ +/*!*************************!*\ + !*** ./src/Terminal.js ***! + \*************************/ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postNetburnerText", function() { return postNetburnerText; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "post", function() { return post; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Terminal", function() { return Terminal; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KEY", function() { return KEY; }); +/* harmony import */ var _Alias_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Alias.js */ 30); +/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3); +/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CreateProgram.js */ 14); +/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DarkWeb.js */ 34); +/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./engine.js */ 5); +/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 32); +/* harmony import */ var _HelpText_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./HelpText.js */ 72); +/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 25); +/* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Literature.js */ 53); +/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Message.js */ 28); +/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 7); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); +/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Player.js */ 0); +/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./RedPill.js */ 44); +/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Script.js */ 26); +/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Server.js */ 10); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Settings.js */ 23); +/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); +/* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./TextFile.js */ 41); +/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2); +/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); +/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../utils/LogBox.js */ 51); +/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12); +/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! jszip */ 121); +/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_23___default = /*#__PURE__*/__webpack_require__.n(jszip__WEBPACK_IMPORTED_MODULE_23__); +/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! file-saver */ 120); +/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(file_saver__WEBPACK_IMPORTED_MODULE_24__); + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* Write text to terminal */ +//If replace is true then spaces are replaced with " " +function post(input) { + $("#terminal-input").before('' + input + ''); + updateTerminalScroll(); +} + +//Same thing as post but the td cells have ids so they can be animated for the hack progress bar +function hackProgressBarPost(input) { + $("#terminal-input").before('' + input + ''); + updateTerminalScroll(); +} + +function hackProgressPost(input) { + $("#terminal-input").before('' + input + ''); + updateTerminalScroll(); +} + +//Scroll to the bottom of the terminal's 'text area' +function updateTerminalScroll() { + var element = document.getElementById("terminal-container"); + element.scrollTop = element.scrollHeight; +} + +function postNetburnerText() { + post("Bitburner v" + _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].Version); +} + + +//Key Codes +var KEY = { + TAB: 9, + ENTER: 13, + CTRL: 17, + UPARROW: 38, + DOWNARROW: 40, + A: 65, + B: 66, + C: 67, + D: 68, + 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, +} + +//Defines key commands in terminal +$(document).keydown(function(event) { + //Terminal + if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { + var terminalInput = document.getElementById("terminal-input-text-box"); + if (terminalInput != null && !event.ctrlKey && !event.shiftKey) {terminalInput.focus();} + + if (event.keyCode === KEY.ENTER) { + event.preventDefault(); //Prevent newline from being entered in Script Editor + var command = $('input[class=terminal-input]').val(); + if (command.length > 0) { + post( + "[" + + (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_TIMESTAMPS ? Terminal.getTimestamp() + " " : "") + + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname + + " ~]> " + command + ); + + Terminal.resetTerminalInput(); //Clear input first + Terminal.executeCommand(command); + } + } + + if (event.keyCode === KEY.C && event.ctrlKey) { + if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"]._actionInProgress) { + //Cancel action + post("Cancelling..."); + _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"]._actionInProgress = false; + Terminal.finishAction(true); + } else if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) { + //Dont prevent default so it still copies + Terminal.resetTerminalInput(); //Clear Terminal + } + } + + if (event.keyCode === KEY.L && event.ctrlKey) { + event.preventDefault(); + Terminal.executeCommand("clear"); //Clear screen + } + + //Ctrl p same as up arrow + //Ctrl n same as down arrow + + if (event.keyCode === KEY.UPARROW || + (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS && event.keyCode === KEY.P && event.ctrlKey)) { + if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) {event.preventDefault();} + //Cycle through past commands + if (terminalInput == null) {return;} + var i = Terminal.commandHistoryIndex; + var len = Terminal.commandHistory.length; + + if (len == 0) {return;} + if (i < 0 || i > len) { + Terminal.commandHistoryIndex = len; + } + + if (i != 0) { + --Terminal.commandHistoryIndex; + } + var prevCommand = Terminal.commandHistory[Terminal.commandHistoryIndex]; + terminalInput.value = prevCommand; + setTimeout(function(){terminalInput.selectionStart = terminalInput.selectionEnd = 10000; }, 0); + } + + if (event.keyCode === KEY.DOWNARROW || + (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS && event.keyCode === KEY.M && event.ctrlKey)) { + if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) {event.preventDefault();} + //Cycle through past commands + if (terminalInput == null) {return;} + var i = Terminal.commandHistoryIndex; + var len = Terminal.commandHistory.length; + + if (len == 0) {return;} + if (i < 0 || i > len) { + Terminal.commandHistoryIndex = len; + } + + //Latest command, put nothing + if (i == len || i == len-1) { + Terminal.commandHistoryIndex = len; + terminalInput.value = ""; + } else { + ++Terminal.commandHistoryIndex; + var prevCommand = Terminal.commandHistory[Terminal.commandHistoryIndex]; + terminalInput.value = prevCommand; + } + } + + if (event.keyCode === KEY.TAB) { + //Autocomplete + if (terminalInput == null) {return;} + var input = terminalInput.value; + if (input == "") {return;} + input = input.trim(); + input = input.replace(/\s\s+/g, ' '); + + var commandArray = input.split(" "); + var index = commandArray.length - 2; + if (index < -1) {index = 0;} + var allPos = determineAllPossibilitiesForTabCompletion(input, index); + if (allPos.length == 0) {return;} + + var arg = ""; + var command = ""; + if (commandArray.length == 0) {return;} + if (commandArray.length == 1) {command = commandArray[0];} + else if (commandArray.length == 2) { + command = commandArray[0]; + arg = commandArray[1]; + } else if (commandArray.length == 3) { + command = commandArray[0] + " " + commandArray[1]; + arg = commandArray[2]; + } else { + arg = commandArray.pop(); + command = commandArray.join(" "); + } + + tabCompletion(command, arg, allPos); + } + + //Extra Bash Emulation Hotkeys, must be enabled through .fconf + if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) { + if (event.keyCode === KEY.A && event.ctrlKey) { + event.preventDefault(); + Terminal.moveTextCursor("home"); + } + + if (event.keyCode === KEY.E && event.ctrlKey) { + event.preventDefault(); + Terminal.moveTextCursor("end"); + } + + if (event.keyCode === KEY.B && event.ctrlKey) { + event.preventDefault(); + Terminal.moveTextCursor("prevchar"); + } + + if (event.keyCode === KEY.B && event.altKey) { + event.preventDefault(); + Terminal.moveTextCursor("prevword"); + } + + if (event.keyCode === KEY.F && event.ctrlKey) { + event.preventDefault(); + Terminal.moveTextCursor("nextchar"); + } + + if (event.keyCode === KEY.F && event.altKey) { + event.preventDefault(); + Terminal.moveTextCursor("nextword"); + } + + + if ((event.keyCode === KEY.H || event.keyCode === KEY.D) && event.ctrlKey) { + Terminal.modifyInput("backspace"); + event.preventDefault(); + } + + //TODO AFTER THIS: + + //alt + d deletes word after cursor + //^w deletes word before cursor + //^k clears line after cursor + //^u clears line before cursor + } + } +}); + +//Keep terminal in focus +let terminalCtrlPressed = false, shiftKeyPressed = false; +$(document).ready(function() { + if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { + $('.terminal-input').focus(); + } +}); +$(document).keydown(function(e) { + if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { + if (e.which == 17) { + 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();} + + terminalCtrlPressed = false; + shiftKeyPressed = false; + } + } +}) +$(document).keyup(function(e) { + if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { + if (e.which == 17) { + terminalCtrlPressed = false; + } + if (e.shiftKey) { + shiftKeyPressed = false; + } + } +}) + +//Implements a tab completion feature for terminal +// command - Command (first arg only) +// arg - Incomplete argument string that the function will try to complete, or will display +// a series of possible options for +// allPossibilities - Array of strings containing all possibilities that the +// string can complete to +// index - index of argument that is being "tab completed". By default is 0, the first argument +function tabCompletion(command, arg, allPossibilities, index=0) { + if (!(allPossibilities.constructor === Array)) {return;} + if (!Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["containsAllStrings"])(allPossibilities)) {return;} + + if (!command.startsWith("./")) { + command = command.toLowerCase(); + } + + //Remove all options in allPossibilities that do not match the current string + //that we are attempting to autocomplete + if (arg == "") { + for (var i = allPossibilities.length-1; i >= 0; --i) { + if (!allPossibilities[i].toLowerCase().startsWith(command.toLowerCase())) { + allPossibilities.splice(i, 1); + } + } + } else { + for (var i = allPossibilities.length-1; i >= 0; --i) { + if (!allPossibilities[i].toLowerCase().startsWith(arg.toLowerCase())) { + allPossibilities.splice(i, 1); + } + } + } + + var val = ""; + if (allPossibilities.length == 0) { + return; + } else if (allPossibilities.length == 1) { + if (arg == "") { + //Autocomplete command + val = allPossibilities[0] + " "; + } else { + val = command + " " + allPossibilities[0]; + } + document.getElementById("terminal-input-text-box").value = val; + document.getElementById("terminal-input-text-box").focus(); + } else { + var longestStartSubstr = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["longestCommonStart"])(allPossibilities); + //If the longest common starting substring of remaining possibilities is the same + //as whatevers already in terminal, just list all possible options. Otherwise, + //change the input in the terminal to the longest common starting substr + var allOptionsStr = ""; + for (var i = 0; i < allPossibilities.length; ++i) { + allOptionsStr += allPossibilities[i]; + allOptionsStr += " "; + } + if (arg == "") { + if (longestStartSubstr == command) { + post("> " + command); + post(allOptionsStr); + } else { + document.getElementById("terminal-input-text-box").value = longestStartSubstr; + document.getElementById("terminal-input-text-box").focus(); + } + } else { + if (longestStartSubstr == arg) { + //List all possible options + post("> " + command + " " + arg); + post(allOptionsStr); + } else { + document.getElementById("terminal-input-text-box").value = command + " " + longestStartSubstr; + document.getElementById("terminal-input-text-box").focus(); + } + } + + } +} + +function determineAllPossibilitiesForTabCompletion(input, index=0) { + var allPos = []; + allPos = allPos.concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["GlobalAliases"])); + var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + input = input.toLowerCase(); + + //If the command starts with './' and the index == -1, then the user + //has input ./partialexecutablename so autocomplete the script or program + //Put './' in front of each script/executable + if (input.startsWith("./") && index == -1) { + //All programs and scripts + for (var i = 0; i < currServ.scripts.length; ++i) { + allPos.push("./" + currServ.scripts[i].filename); + } + + //Programs are on home computer + var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getHomeComputer(); + for(var i = 0; i < homeComputer.programs.length; ++i) { + allPos.push("./" + homeComputer.programs[i]); + } + return allPos; + } + + //Autocomplete the command + if (index == -1) { + return ["alias", "analyze", "cat", "check", "clear", "cls", "connect", "download", "free", + "hack", "help", "home", "hostname", "ifconfig", "kill", "killall", + "ls", "lscpu", "mem", "nano", "ps", "rm", "run", "scan", "scan-analyze", + "scp", "sudov", "tail", "theme", "top"].concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["Aliases"])).concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["GlobalAliases"])); + } + + if (input.startsWith ("buy ")) { + return [_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BruteSSHProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].FTPCrackProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].RelaySMTPProgram, + _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].HTTPWormProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].SQLInjectProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1, + _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2].concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["GlobalAliases"])); + } + + if (input.startsWith("scp ") && index == 1) { + for (var iphostname in _Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"]) { + if (_Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"].hasOwnProperty(iphostname)) { + allPos.push(_Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"][iphostname].ip); + allPos.push(_Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"][iphostname].hostname); + } + } + } + + if (input.startsWith("scp ") && index == 0) { + //All Scripts and lit files + for (var i = 0; i < currServ.scripts.length; ++i) { + allPos.push(currServ.scripts[i].filename); + } + for (var i = 0; i < currServ.messages.length; ++i) { + if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"])) { + allPos.push(currServ.messages[i]); + } + } + for (var i = 0; i < currServ.textFiles.length; ++i) { + allPos.push(currServ.textFiles[i].fn); + } + } + + if (input.startsWith("connect ") || input.startsWith("telnet ")) { + //All network connections + for (var i = 0; i < currServ.serversOnNetwork.length; ++i) { + var serv = _Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"][currServ.serversOnNetwork[i]]; + if (serv == null) {continue;} + allPos.push(serv.ip); //IP + allPos.push(serv.hostname); //Hostname + } + return allPos; + } + + if (input.startsWith("kill ") || input.startsWith("tail ") || + input.startsWith("mem ") || input.startsWith("check ")) { + //All Scripts + for (var i = 0; i < currServ.scripts.length; ++i) { + allPos.push(currServ.scripts[i].filename); + } + return allPos; + } + + if (input.startsWith("nano ")) { + //Scripts and text files and .fconf + for (var i = 0; i < currServ.scripts.length; ++i) { + allPos.push(currServ.scripts[i].filename); + } + for (var i = 0; i < currServ.textFiles.length; ++i) { + allPos.push(currServ.textFiles[i].fn); + } + allPos.push(".fconf"); + return allPos; + } + + if (input.startsWith("rm ")) { + for (var i = 0; i < currServ.scripts.length; ++i) { + allPos.push(currServ.scripts[i].filename); + } + for (var i = 0; i < currServ.programs.length; ++i) { + allPos.push(currServ.programs[i]); + } + for (var i = 0; i < currServ.messages.length; ++i) { + if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["isString"])(currServ.messages[i]) && + currServ.messages[i].endsWith(".lit")) { + allPos.push(currServ.messages[i]); + } + } + for (var i = 0; i < currServ.textFiles.length; ++i) { + allPos.push(currServ.textFiles[i].fn); + } + return allPos; + } + + if (input.startsWith("run ")) { + //All programs and scripts + for (var i = 0; i < currServ.scripts.length; ++i) { + allPos.push(currServ.scripts[i].filename); + } + + //Programs are on home computer + var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getHomeComputer(); + for(var i = 0; i < homeComputer.programs.length; ++i) { + allPos.push(homeComputer.programs[i]); + } + return allPos; + } + + if (input.startsWith("cat ")) { + for (var i = 0; i < currServ.messages.length; ++i) { + if (currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) { + allPos.push(currServ.messages[i].filename); + } else { + allPos.push(currServ.messages[i]); + } + } + for (var i = 0; i < currServ.textFiles.length; ++i) { + allPos.push(currServ.textFiles[i].fn); + } + return allPos; + } + + if (input.startsWith("download ")) { + for (var i = 0; i < currServ.textFiles.length; ++i) { + allPos.push(currServ.textFiles[i].fn); + } + for (var i = 0; i < currServ.scripts.length; ++i) { + allPos.push(currServ.scripts[i].filename); + } + } + return allPos; +} + +let Terminal = { + //Flags to determine whether the player is currently running a hack or an analyze + hackFlag: false, + analyzeFlag: false, + + commandHistory: [], + commandHistoryIndex: 0, + + resetTerminalInput: function() { + document.getElementById("terminal-input-td").innerHTML = + "
[" + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname + " ~]" + "$
" + + ''; + var hdr = document.getElementById("terminal-input-header"); + hdr.style.display = "inline"; + }, + + modifyInput: function(mod) { + try { + var terminalInput = document.getElementById("terminal-input-text-box"); + if (terminalInput == null) {return;} + terminalInput.focus(); + + var inputLength = terminalInput.value.length; + var start = terminalInput.selectionStart; + var end = terminalInput.selectionEnd; + var inputText = terminalInput.value; + + switch(mod.toLowerCase()) { + case "backspace": + if (start > 0 && start <= inputLength+1) { + terminalInput.value = inputText.substr(0, start-1) + inputText.substr(start); + } + break; + case "deletewordbefore": //Delete rest of word before the cursor + for (var delStart = start-1; delStart > 0; --delStart) { + if (inputText.charAt(delStart) === " ") { + terminalInput.value = inputText.substr(0, delStart) + inputText.substr(start); + return; + } + } + break; + case "deletewordafter": //Delete rest of word after the cursor + for (var delStart = start+1; delStart <= text.length+1; ++delStart) { + if (inputText.charAt(delStart) === " ") { + terminalInput.value = inputText.substr(0, start) + inputText.substr(delStart); + return; + } + } + break; + case "clearafter": //Deletes everything after cursor + break; + case "clearbefore:": //Deleetes everything before cursor + break; + } + } catch(e) { + console.log("Exception in Terminal.modifyInput: " + e); + } + }, + + moveTextCursor: function(loc) { + try { + var terminalInput = document.getElementById("terminal-input-text-box"); + if (terminalInput == null) {return;} + terminalInput.focus(); + + var inputLength = terminalInput.value.length; + var start = terminalInput.selectionStart; + var end = terminalInput.selectionEnd; + + switch(loc.toLowerCase()) { + case "home": + terminalInput.setSelectionRange(0,0); + break; + case "end": + terminalInput.setSelectionRange(inputLength, inputLength); + break; + case "prevchar": + if (start > 0) {terminalInput.setSelectionRange(start-1, start-1);} + break; + case "prevword": + for (var i = start-2; i >= 0; --i) { + if (terminalInput.value.charAt(i) === " ") { + terminalInput.setSelectionRange(i+1, i+1); + return; + } + } + terminalInput.setSelectionRange(0, 0); + break; + case "nextchar": + terminalInput.setSelectionRange(start+1, start+1); + break; + case "nextword": + for (var i = start+1; i <= inputLength; ++i) { + if (terminalInput.value.charAt(i) === " ") { + terminalInput.setSelectionRange(i, i); + return; + } + } + terminalInput.setSelectionRange(inputLength, inputLength); + break; + default: + console.log("WARNING: Invalid loc argument in Terminal.moveTextCursor()"); + break; + } + } catch(e) { + console.log("Exception in Terminal.moveTextCursor: " + e); + } + }, + + getTimestamp: function() { + let d = new Date(); + return (d.getMonth() + "/" + d.getDay() + " " + d.getHours() + ":" + d.getMinutes()); + }, + + finishAction: function(cancelled = false) { + if (Terminal.hackFlag) { + Terminal.finishHack(cancelled); + } else if (Terminal.analyzeFlag) { + Terminal.finishAnalyze(cancelled); + } + }, + + //Complete the hack/analyze command + finishHack: function(cancelled = false) { + if (cancelled == false) { + var server = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + + //Calculate whether hack was successful + var hackChance = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingChance(); + var rand = Math.random(); + console.log("Hack success chance: " + hackChance + ", rand: " + rand); + var expGainedOnSuccess = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateExpGain(); + var expGainedOnFailure = (expGainedOnSuccess / 4); + if (rand < hackChance) { //Success! + if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerNames"].WorldDaemon] && + _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerNames"].WorldDaemon] == server.ip) { + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN == null) { + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN = 1; + } + Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_13__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN); + return; + } + server.manuallyHacked = true; + var moneyGained = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculatePercentMoneyHacked(); + moneyGained = Math.floor(server.moneyAvailable * moneyGained); + + if (moneyGained <= 0) {moneyGained = 0;} //Safety check + + server.moneyAvailable -= moneyGained; + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainMoney(moneyGained); + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainHackingExp(expGainedOnSuccess) + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainIntelligenceExp(expGainedOnSuccess / _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].IntelligenceTerminalHackBaseExpGain); + + server.fortify(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].ServerFortifyAmount); + + post("Hack successful! Gained $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(moneyGained, 2) + " and " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(expGainedOnSuccess, 4) + " hacking EXP"); + } else { //Failure + //Player only gains 25% exp for failure? TODO Can change this later to balance + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainHackingExp(expGainedOnFailure) + post("Failed to hack " + server.hostname + ". Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(expGainedOnFailure, 4) + " hacking EXP"); + } + } + + //Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal + $("#hack-progress-bar").attr('id', "old-hack-progress-bar"); + $("#hack-progress").attr('id', "old-hack-progress"); + Terminal.resetTerminalInput(); + $('input[class=terminal-input]').prop('disabled', false); + + Terminal.hackFlag = false; + }, + + finishAnalyze: function(cancelled = false) { + if (cancelled == false) { + post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname + ": "); + post("Organization name: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().organizationName); + var rootAccess = ""; + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights) {rootAccess = "YES";} + else {rootAccess = "NO";} + post("Root Access: " + rootAccess); + post("Required hacking skill: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().requiredHackingSkill); + post("Estimated server security level: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hackDifficulty, 5), 3)); + post("Estimated chance to hack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingChance() * 100, 5), 2) + "%"); + post("Estimated time to hack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingTime(), 5), 3) + " seconds"); + post("Estimated total money available on server: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().moneyAvailable, 5), 2)); + post("Required number of open ports for NUKE: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().numOpenPortsRequired); + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().sshPortOpen) { + post("SSH port: Open") + } else { + post("SSH port: Closed") + } + + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ftpPortOpen) { + post("FTP port: Open") + } else { + post("FTP port: Closed") + } + + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().smtpPortOpen) { + post("SMTP port: Open") + } else { + post("SMTP port: Closed") + } + + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().httpPortOpen) { + post("HTTP port: Open") + } else { + post("HTTP port: Closed") + } + + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().sqlPortOpen) { + post("SQL port: Open") + } else { + post("SQL port: Closed") + } + } + Terminal.analyzeFlag = false; + + //Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal + $("#hack-progress-bar").attr('id', "old-hack-progress-bar"); + $("#hack-progress").attr('id', "old-hack-progress"); + Terminal.resetTerminalInput(); + $('input[class=terminal-input]').prop('disabled', false); + }, + + executeCommand: function(command) { + command = command.trim(); + //Replace all extra whitespace in command with a single space + command = command.replace(/\s\s+/g, ' '); + + //Terminal history + if (Terminal.commandHistory[Terminal.commandHistory.length-1] != command) { + Terminal.commandHistory.push(command); + if (Terminal.commandHistory.length > 50) { + Terminal.commandHistory.splice(0, 1); + } + } + Terminal.commandHistoryIndex = Terminal.commandHistory.length; + + //Process any aliases + command = Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["substituteAliases"])(command); + + //Allow usage of ./ + if (command.startsWith("./")) { + command = "run " + command.slice(2); + } + + //Only split the first space + var commandArray = command.split(" "); + if (commandArray.length > 1) { + commandArray = [commandArray.shift(), commandArray.join(" ")]; + } + + if (commandArray.length == 0) {return;} + + /****************** Interactive Tutorial Terminal Commands ******************/ + if (_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialIsRunning"]) { + var foodnstuffServ = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["GetServerByHostname"])("foodnstuff"); + if (foodnstuffServ == null) {throw new Error("Could not get foodnstuff server"); return;} + + switch(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["currITutorialStep"]) { + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalHelp: + if (commandArray[0] == "help") { + post(_HelpText_js__WEBPACK_IMPORTED_MODULE_6__["TerminalHelpText"]); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalLs: + if (commandArray[0] == "ls") { + Terminal.executeListCommand(commandArray); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScan: + if (commandArray[0] == "scan") { + Terminal.executeScanCommand(commandArray); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScanAnalyze1: + if (commandArray.length == 1 && commandArray[0] == "scan-analyze") { + Terminal.executeScanAnalyzeCommand(1); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScanAnalyze2: + if (commandArray.length == 2 && commandArray[0] == "scan-analyze" && + commandArray[1] == "2") { + Terminal.executeScanAnalyzeCommand(2); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalConnect: + if (commandArray.length == 2) { + if ((commandArray[0] == "connect") && + (commandArray[1] == "foodnstuff" || commandArray[1] == foodnstuffServ.ip)) { + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false; + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = foodnstuffServ.ip; + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true; + post("Connected to foodnstuff"); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Wrong command! Try again!"); return;} + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalAnalyze: + if (commandArray[0] == "analyze") { + if (commandArray.length != 1) { + post("Incorrect usage of analyze command. Usage: analyze"); return; + } + //Analyze the current server for information + Terminal.analyzeFlag = true; + post("Analyzing system..."); + hackProgressPost("Time left:"); + hackProgressBarPost("["); + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].analyze(); + + //Disable terminal + //Terminal.resetTerminalInput(); + document.getElementById("terminal-input-td").innerHTML = ''; + $('input[class=terminal-input]').prop('disabled', true); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else { + post("Bad command. Please follow the tutorial"); + } + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalNuke: + if (commandArray.length == 2 && + commandArray[0] == "run" && commandArray[1] == "NUKE.exe") { + foodnstuffServ.hasAdminRights = true; + post("NUKE successful! Gained root access to foodnstuff"); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalManualHack: + if (commandArray.length == 1 && commandArray[0] == "hack") { + Terminal.hackFlag = true; + hackProgressPost("Time left:"); + hackProgressBarPost("["); + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hack(); + + //Disable terminal + //Terminal.resetTerminalInput(); + document.getElementById("terminal-input-td").innerHTML = ''; + $('input[class=terminal-input]').prop('disabled', true); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalCreateScript: + if (commandArray.length == 2 && + commandArray[0] == "nano" && commandArray[1] == "foodnstuff.script") { + _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent("foodnstuff.script", ""); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalFree: + if (commandArray.length == 1 && commandArray[0] == "free") { + Terminal.executeFreeCommand(commandArray); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalRunScript: + if (commandArray.length == 2 && + commandArray[0] == "run" && commandArray[1] == "foodnstuff.script") { + Terminal.runScript("foodnstuff.script"); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].ActiveScriptsToTerminal: + if (commandArray.length == 2 && + commandArray[0] == "tail" && commandArray[1] == "foodnstuff.script") { + //Check that the script exists on this machine + var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])("foodnstuff.script", [], _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer()); + if (runningScript == null) { + post("Error: No such script exists"); + return; + } + Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__["logBoxCreate"])(runningScript); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + default: + post("Please follow the tutorial, or click 'Exit Tutorial' if you'd like to skip it"); + return; + } + return; + } + + /****************** END INTERACTIVE TUTORIAL ******************/ + + /* Command parser */ + var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + switch (commandArray[0].toLowerCase()) { + case "alias": + if (commandArray.length == 1) { + Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["printAliases"])(); + return; + } + if (commandArray.length == 2) { + if (commandArray[1].startsWith("-g ")) { + var alias = commandArray[1].substring(3); + if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["parseAliasDeclaration"])(alias, true)) { + return; + } + } else { + if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["parseAliasDeclaration"])(commandArray[1])) { + return; + } + } + } + post('Incorrect usage of alias command. Usage: alias [-g] [aliasname="value"]'); + break; + case "analyze": + if (commandArray.length != 1) { + post("Incorrect usage of analyze command. Usage: analyze"); return; + } + //Analyze the current server for information + Terminal.analyzeFlag = true; + post("Analyzing system..."); + hackProgressPost("Time left:"); + hackProgressBarPost("["); + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].analyze(); + + //Disable terminal + //Terminal.resetTerminalInput(); + document.getElementById("terminal-input-td").innerHTML = ''; + $('input[class=terminal-input]').prop('disabled', true); + break; + case "buy": + if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"].hasOwnProperty("Darkweb Server")) { + Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__["executeDarkwebTerminalCommand"])(commandArray); + } else { + post("You need to be able to connect to the Dark Web to use the buy command. (Maybe there's a TOR router you can buy somewhere)"); + } + break; + case "cat": + if (commandArray.length != 2) { + post("Incorrect usage of cat command. Usage: cat [file]"); return; + } + var filename = commandArray[1]; + if (!filename.endsWith(".msg") && !filename.endsWith(".lit") && !filename.endsWith(".txt")) { + post("Error: Only .msg, .txt, and .lit files are viewable with cat (filename must end with .msg, .txt, or .lit)"); return; + } + for (var i = 0; i < s.messages.length; ++i) { + if (filename.endsWith(".lit") && s.messages[i] == filename) { + Object(_Literature_js__WEBPACK_IMPORTED_MODULE_8__["showLiterature"])(s.messages[i]); + return; + } else if (filename.endsWith(".msg") && s.messages[i].filename == filename) { + Object(_Message_js__WEBPACK_IMPORTED_MODULE_9__["showMessage"])(s.messages[i]); + return; + } + } + for (var i = 0; i < s.textFiles.length; ++i) { + if (s.textFiles[i].fn === filename) { + s.textFiles[i].show(); + return; + } + } + post("Error: No such file " + filename); + break; + case "check": + if (commandArray.length < 2) { + post("Incorrect number of arguments. Usage: check [script] [arg1] [arg2]..."); + } else { + var results = commandArray[1].split(" "); + var scriptName = results[0]; + var args = []; + for (var i = 1; i < results.length; ++i) { + args.push(results[i]); + } + + //Can only tail script files + if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(scriptName) == false) { + post("Error: tail can only be called on .script files (filename must end with .script)"); return; + } + + //Check that the script exists on this machine + var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s); + if (runningScript == null) { + post("Error: No such script exists"); + return; + } + runningScript.displayLog(); + } + break; + case "clear": + case "cls": + if (commandArray.length != 1) { + post("Incorrect usage of clear/cls command. Usage: clear/cls"); return; + } + $("#terminal tr:not(:last)").remove(); + postNetburnerText(); + break; + case "connect": + //Disconnect from current server in terminal and connect to new one + if (commandArray.length != 2) { + post("Incorrect usage of connect command. Usage: connect [ip/hostname]"); + return; + } + + var ip = commandArray[1]; + + for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().serversOnNetwork.length; i++) { + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip == ip || _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).hostname == ip) { + Terminal.connectToServer(ip); + return; + } + } + + post("Host not found"); + break; + case "download": + if (commandArray.length != 2) { + post("Incorrect usage of download command. Usage: download [text file]"); + return; + } + var fn = commandArray[1]; + if (fn === "*" || fn === "*.script" || fn === "*.txt") { + //Download all scripts as a zip + var zip = new jszip__WEBPACK_IMPORTED_MODULE_23__(); + if (fn === "*" || fn === "*.script") { + for (var i = 0; i < s.scripts.length; ++i) { + var file = new Blob([s.scripts[i].code], {type:"text/plain"}); + zip.file(s.scripts[i].filename + ".js", file); + } + } + if (fn === "*" || fn === "*.txt") { + for (var i = 0; i < s.textFiles.length; ++i) { + var file = new Blob([s.textFiles[i].text], {type:"text/plain"}); + zip.file(s.textFiles[i].fn, file); + } + } + + var filename; + switch (fn) { + case "*.script": + filename = "bitburnerScripts.zip"; break; + case "*.txt": + filename = "bitburnerTexts.zip"; break; + default: + filename = "bitburnerFiles.zip"; break; + } + + zip.generateAsync({type:"blob"}).then(function(content) { + file_saver__WEBPACK_IMPORTED_MODULE_24__["saveAs"](content, filename); + }); + return; + } else if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(fn)) { + //Download a single script + for (var i = 0; i < s.scripts.length; ++i) { + if (s.scripts[i].filename === fn) { + return s.scripts[i].download(); + } + } + } else if (fn.endsWith(".txt")) { + //Download a single text file + var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_18__["getTextFile"])(fn, s); + if (txtFile !== null) { + return txtFile.download(); + } + } + post("Error: " + fn + " does not exist"); + break; + case "free": + Terminal.executeFreeCommand(commandArray); + break; + case "hack": + if (commandArray.length != 1) { + post("Incorrect usage of hack command. Usage: hack"); return; + } + //Hack the current PC (usually for money) + //You can't hack your home pc or servers you purchased + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().purchasedByPlayer) { + post("Cannot hack your own machines! You are currently connected to your home PC or one of your purchased servers"); + } else if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights == false ) { + post("You do not have admin rights for this machine! Cannot hack"); + } else if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().requiredHackingSkill > _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hacking_skill) { + post("Your hacking skill is not high enough to attempt hacking this machine. Try analyzing the machine to determine the required hacking skill"); + } else { + Terminal.hackFlag = true; + hackProgressPost("Time left:"); + hackProgressBarPost("["); + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hack(); + + //Disable terminal + //Terminal.resetTerminalInput(); + document.getElementById("terminal-input-td").innerHTML = ''; + $('input[class=terminal-input]').prop('disabled', true); + } + break; + case "help": + if (commandArray.length != 1 && commandArray.length != 2) { + post("Incorrect usage of help command. Usage: help"); return; + } + if (commandArray.length == 1) { + post(_HelpText_js__WEBPACK_IMPORTED_MODULE_6__["TerminalHelpText"]); + } else { + var cmd = commandArray[1]; + var txt = _HelpText_js__WEBPACK_IMPORTED_MODULE_6__["HelpTexts"][cmd]; + if (txt == null) { + post("Error: No help topics match '" + cmd + "'"); + return; + } + post(txt); + } + break; + case "home": + if (commandArray.length != 1) { + post("Incorrect usage of home command. Usage: home"); return; + } + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false; + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getHomeComputer().ip; + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true; + post("Connected to home"); + Terminal.resetTerminalInput(); + break; + case "hostname": + if (commandArray.length != 1) { + post("Incorrect usage of hostname command. Usage: hostname"); return; + } + //Print the hostname of current system + post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname); + break; + case "ifconfig": + if (commandArray.length != 1) { + post("Incorrect usage of ifconfig command. Usage: ifconfig"); return; + } + //Print the IP address of the current system + post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ip); + break; + case "kill": + if (commandArray.length < 2) { + post("Incorrect usage of kill command. Usage: kill [scriptname] [arg1] [arg2]..."); return; + } + var results = commandArray[1].split(" "); + var scriptName = results[0]; + var args = []; + for (var i = 1; i < results.length; ++i) { + args.push(results[i]); + } + var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s); + if (runningScript == null) { + post("No such script is running. Nothing to kill"); + return; + } + Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["killWorkerScript"])(runningScript, s.ip); + post("Killing " + scriptName + ". May take up to a few minutes for the scripts to die..."); + break; + case "killall": + for (var i = s.runningScripts.length-1; i >= 0; --i) { + Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["killWorkerScript"])(s.runningScripts[i], s.ip); + } + post("Killing all running scripts. May take up to a few minutes for the scripts to die..."); + break; + case "ls": + Terminal.executeListCommand(commandArray); + break; + case "lscpu": + post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().cpuCores + " Core(s)"); + break; + case "mem": + if (commandArray.length != 2) { + post("Incorrect usage of mem command. usage: mem [scriptname] [-t] [number threads]"); return; + } + var scriptName = commandArray[1]; + var numThreads = 1; + if (scriptName.indexOf(" -t ") != -1) { + var results = scriptName.split(" "); + if (results.length != 3) { + post("Invalid use of run command. Usage: mem [script] [-t] [number threads]"); + return; + } + numThreads = Math.round(Number(results[2])); + if (isNaN(numThreads) || numThreads < 1) { + post("Invalid number of threads specified. Number of threads must be greater than 1"); + return; + } + scriptName = results[0]; + } + + var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + for (var i = 0; i < currServ.scripts.length; ++i) { + if (scriptName == currServ.scripts[i].filename) { + var scriptBaseRamUsage = currServ.scripts[i].ramUsage; + var ramUsage = scriptBaseRamUsage * numThreads * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, numThreads-1); + + post("This script requires " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(ramUsage, 2) + "GB of RAM to run for " + numThreads + " thread(s)"); + return; + } + } + post("ERR: No such script exists!"); + break; + case "nano": + if (commandArray.length != 2) { + post("Incorrect usage of nano command. Usage: nano [scriptname]"); return; + } + + var filename = commandArray[1]; + if (filename === ".fconf") { + var text = Object(_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["createFconf"])(); + _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, text); + return; + } else if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(filename)) { + for (var i = 0; i < s.scripts.length; i++) { + if (filename == s.scripts[i].filename) { + _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, s.scripts[i].code); + return; + } + } + } else if (filename.endsWith(".txt")) { + for (var i = 0; i < s.textFiles.length; ++i) { + if (filename === s.textFiles[i].fn) { + _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, s.textFiles[i].text); + return; + } + } + } else { + post("Error: Invalid file. Only scripts (.script), text files (.txt), or .fconf can be edited with nano"); return; + } + _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename); + break; + case "ps": + if (commandArray.length != 1) { + post("Incorrect usage of ps command. Usage: ps"); return; + } + for (var i = 0; i < s.runningScripts.length; i++) { + var rsObj = s.runningScripts[i]; + var res = rsObj.filename; + for (var j = 0; j < rsObj.args.length; ++j) { + res += (" " + rsObj.args[j].toString()); + } + post(res); + } + break; + case "rm": + if (commandArray.length != 2) { + post("Incorrect number of arguments. Usage: rm [program/script]"); return; + } + + //Check programs + var delTarget = commandArray[1]; + + if (delTarget.includes(".exe")) { + for (var i = 0; i < s.programs.length; ++i) { + if (s.programs[i] == delTarget) { + s.programs.splice(i, 1); + return; + } + } + } else if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(delTarget)) { + for (var i = 0; i < s.scripts.length; ++i) { + if (s.scripts[i].filename == delTarget) { + //Check that the script isnt currently running + for (var j = 0; j < s.runningScripts.length; ++j) { + if (s.runningScripts[j].filename == delTarget) { + post("Cannot delete a script that is currently running!"); + return; + } + } + s.scripts.splice(i, 1); + return; + } + } + } else if (delTarget.endsWith(".lit")) { + for (var i = 0; i < s.messages.length; ++i) { + var f = s.messages[i]; + if (!(f instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["isString"])(f) && f === delTarget) { + s.messages.splice(i, 1); + return; + } + } + } else if (delTarget.endsWith(".txt")) { + for (var i = 0; i < s.textFiles.length; ++i) { + if (s.textFiles[i].fn === delTarget) { + s.textFiles.splice(i, 1); + return; + } + } + } + post("Error: No such file exists"); + break; + case "run": + //Run a program or a script + if (commandArray.length != 2) { + post("Incorrect number of arguments. Usage: run [program/script] [-t] [num threads] [arg1] [arg2]..."); + } else { + var executableName = commandArray[1]; + + //Secret Music player! + if (executableName === "musicplayer") { + post('', false); + return; + } + + //Check if its a script or just a program/executable + //if (isScriptFilename(executableName)) { + if (executableName.includes(".script") || executableName.includes(".js") || executableName.includes(".ns")) { + Terminal.runScript(executableName); + } else { + Terminal.runProgram(executableName); + } + } + break; + case "scan": + Terminal.executeScanCommand(commandArray); + break; + case "scan-analyze": + if (commandArray.length == 1) { + Terminal.executeScanAnalyzeCommand(1); + } else if (commandArray.length == 2) { + var all = false; + if (commandArray[1].endsWith("-a")) { + all = true; + commandArray[1] = commandArray[1].replace("-a", ""); + } + var depth; + if (commandArray[1].length === 0) { + depth = 1; + } else { + depth = Number(commandArray[1]); + } + if (isNaN(depth) || depth < 0) { + post("Incorrect usage of scan-analyze command. depth argument must be positive numeric"); + return; + } + if (depth > 3 && !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1) && + !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2)) { + post("You cannot scan-analyze with that high of a depth. Maximum depth is 3"); + return; + } else if (depth > 5 && !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2)) { + post("You cannot scan-analyze with that high of a depth. Maximum depth is 5"); + return; + } else if (depth > 10) { + post("You cannot scan-analyze with that high of a depth. Maximum depth is 10"); + return; + } + Terminal.executeScanAnalyzeCommand(depth, all); + } else { + post("Incorrect usage of scan-analyze command. usage: scan-analyze [depth]"); + } + break; + case "scp": + if (commandArray.length != 2) { + post("Incorrect usage of scp command. Usage: scp [file] [destination hostname/ip]"); + return; + } + var args = commandArray[1].split(" "); + if (args.length != 2) { + post("Incorrect usage of scp command. Usage: scp [file] [destination hostname/ip]"); + return; + } + var scriptname = args[0]; + if (!scriptname.endsWith(".lit") && !Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(scriptName) && + !scriptname.endsWith(".txt")){ + post("Error: scp only works for .script, .txt, and .lit files"); + return; + } + var destServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(args[1]); + if (destServer == null) { + post("Invalid destination. " + args[1] + " not found"); + return; + } + var ip = destServer.ip; + var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + + //Scp for lit files + if (scriptname.endsWith(".lit")) { + var found = false; + for (var i = 0; i < currServ.messages.length; ++i) { + if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && currServ.messages[i] == scriptname) { + found = true; + break; + } + } + + if (!found) {return post("Error: no such file exists!");} + + for (var i = 0; i < destServer.messages.length; ++i) { + if (destServer.messages[i] === scriptname) { + post(scriptname + " copied over to " + destServer.hostname); + return; //Already exists + } + } + destServer.messages.push(scriptname); + post(scriptname + " copied over to " + destServer.hostname); + return; + } + + //Scp for txt files + if (scriptname.endsWith(".txt")) { + var found = false, txtFile; + for (var i = 0; i < currServ.textFiles.length; ++i) { + if (currServ.textFiles[i].fn === scriptname) { + found = true; + txtFile = currServ.textFiles[i]; + break; + } + } + + if (!found) {return post("Error: no such file exists!");} + + for (var i = 0; i < destServer.textFiles.length; ++i) { + if (destServer.textFiles[i].fn === scriptname) { + //Overwrite + destServer.textFiles[i].text = txtFile.text; + post("WARNING: " + scriptname + " already exists on " + destServer.hostname + + "and will be overwriten"); + return post(scriptname + " copied over to " + destServer.hostname); + } + } + var newFile = new _TextFile_js__WEBPACK_IMPORTED_MODULE_18__["TextFile"](txtFile.fn, txtFile.text); + destServer.textFiles.push(newFile); + return post(scriptname + " copied over to " + destServer.hostname); + } + + //Get the current script + var sourceScript = null; + for (var i = 0; i < currServ.scripts.length; ++i) { + if (scriptname == currServ.scripts[i].filename) { + sourceScript = currServ.scripts[i]; + break; + } + } + if (sourceScript == null) { + post("ERROR: scp() failed. No such script exists"); + return; + } + + //Overwrite script if it exists + for (var i = 0; i < destServer.scripts.length; ++i) { + if (scriptname == destServer.scripts[i].filename) { + post("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and will be overwritten"); + var oldScript = destServer.scripts[i]; + oldScript.code = sourceScript.code; + oldScript.ramUsage = sourceScript.ramUsage; + post(scriptname + " overwriten on " + destServer.hostname); + return; + } + } + + var newScript = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["Script"](); + newScript.filename = scriptname; + newScript.code = sourceScript.code; + newScript.ramUsage = sourceScript.ramUsage; + newScript.destServer = ip; + destServer.scripts.push(newScript); + post(scriptname + " copied over to " + destServer.hostname); + break; + case "sudov": + if (commandArray.length != 1) { + post("Incorrect number of arguments. Usage: sudov"); return; + } + + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights) { + post("You have ROOT access to this machine"); + } else { + post("You do NOT have root access to this machine"); + } + break; + case "tail": + if (commandArray.length < 2) { + post("Incorrect number of arguments. Usage: tail [script] [arg1] [arg2]..."); + } else { + var results = commandArray[1].split(" "); + var scriptName = results[0]; + var args = []; + for (var i = 1; i < results.length; ++i) { + args.push(results[i]); + } + + //Can only tail script files + if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(scriptName) == false) { + post("Error: tail can only be called on .script files (filename must end with .script)"); return; + } + + //Check that the script exists on this machine + var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s); + if (runningScript == null) { + post("Error: No such script exists"); + return; + } + Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__["logBoxCreate"])(runningScript); + } + break; + case "theme": + //todo support theme saving + var args = commandArray[1] ? commandArray[1].split(" ") : []; + if (args.length != 1 && args.length != 3) { + post("Incorrect number of arguments."); + post("Usage: theme [default|muted|solarized] | #[background color hex] #[text color hex] #[highlight color hex]"); + } else if(args.length == 1){ + var themeName = args[0]; + if (themeName == "default"){ + document.body.style.setProperty('--my-highlight-color',"#ffffff"); + document.body.style.setProperty('--my-font-color',"#66ff33"); + document.body.style.setProperty('--my-background-color',"#000000"); + } else if (themeName == "muted"){ + document.body.style.setProperty('--my-highlight-color',"#ffffff"); + document.body.style.setProperty('--my-font-color',"#66ff33"); + document.body.style.setProperty('--my-background-color',"#252527"); + } else if (themeName == "solarized"){ + document.body.style.setProperty('--my-highlight-color',"#6c71c4"); + document.body.style.setProperty('--my-font-color',"#839496"); + document.body.style.setProperty('--my-background-color',"#002b36"); + } else { + return post("Theme not found"); + } + _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeHighlightColor = document.body.style.getPropertyValue("--my-highlight-color"); + _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeFontColor = document.body.style.getPropertyValue("--my-font-color"); + _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeBackgroundColor = document.body.style.getPropertyValue("--my-background-color"); + } else { + var inputBackgroundHex = args[0]; + var inputTextHex = args[1]; + var inputHighlightHex = args[2]; + if (/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputBackgroundHex) && + /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputTextHex) && + /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputHighlightHex)){ + document.body.style.setProperty('--my-highlight-color',inputHighlightHex); + document.body.style.setProperty('--my-font-color',inputTextHex); + document.body.style.setProperty('--my-background-color',inputBackgroundHex); + _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeHighlightColor = document.body.style.getPropertyValue("--my-highlight-color"); + _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeFontColor = document.body.style.getPropertyValue("--my-font-color"); + _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeBackgroundColor = document.body.style.getPropertyValue("--my-background-color"); + } else { + return post("Invalid Hex Input for theme"); + } + } + break; + case "top": + if(commandArray.length != 1) { + post("Incorrect usage of top command. Usage: top"); return; + } + + post("Script Threads RAM Usage"); + + var currRunningScripts = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().runningScripts; + //Iterate through scripts on current server + for(var i = 0; i < currRunningScripts.length; i++) { + var script = currRunningScripts[i]; + + //Calculate name padding + var numSpacesScript = 32 - script.filename.length; //26 -> width of name column + if (numSpacesScript < 0) {numSpacesScript = 0;} + var spacesScript = Array(numSpacesScript+1).join(" "); + + //Calculate thread padding + var numSpacesThread = 16 - (script.threads + "").length; //16 -> width of thread column + var spacesThread = Array(numSpacesThread+1).join(" "); + + //Calculate and transform RAM usage + ramUsage = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(script.scriptRef.ramUsage * script.threads, 2).toString() + "GB"; + + var entry = [script.filename, spacesScript, script.threads, spacesThread, ramUsage]; + post(entry.join("")); + } + break; + case "unalias": + if (commandArray.length != 2) { + post('Incorrect usage of unalias name. Usage: unalias "[alias]"'); + return; + } else if (!(commandArray[1].startsWith('"') && commandArray[1].endsWith('"'))) { + post('Incorrect usage of unalias name. Usage: unalias "[alias]"'); + } else { + var alias = commandArray[1].slice(1, -1); + if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["removeAlias"])(alias)) { + post("Removed alias " + alias); + } else { + post("No such alias exists"); + } + } + break; + default: + post("Command not found"); + } + }, + + connectToServer: function(ip) { + console.log("Connect to server called"); + var serv = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(ip); + if (serv == null) { + post("Invalid server. Connection failed."); + return; + } + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false; + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = serv.ip; + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true; + post("Connected to " + serv.hostname); + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname == "darkweb") { + Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__["checkIfConnectedToDarkweb"])(); //Posts a 'help' message if connecting to dark web + } + Terminal.resetTerminalInput(); + }, + + executeListCommand: function(commandArray) { + if (commandArray.length != 1 && commandArray.length != 2) { + post("Incorrect usage of ls command. Usage: ls [| grep pattern]"); return; + } + + //grep + var filter = null; + if (commandArray.length == 2) { + if (commandArray[1].startsWith("| grep ")) { + var pattern = commandArray[1].replace("| grep ", ""); + if (pattern != " ") { + filter = pattern; + } + } else { + post("Incorrect usage of ls command. Usage: ls [| grep pattern]"); return; + } + } + + //Display all programs and scripts + var allFiles = []; + + //Get all of the programs and scripts on the machine into one temporary array + var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + for (var i = 0; i < s.programs.length; i++) { + if (filter) { + if (s.programs[i].includes(filter)) { + allFiles.push(s.programs[i]); + } + } else { + allFiles.push(s.programs[i]); + } + } + for (var i = 0; i < s.scripts.length; i++) { + if (filter) { + if (s.scripts[i].filename.includes(filter)) { + allFiles.push(s.scripts[i].filename); + } + } else { + allFiles.push(s.scripts[i].filename); + } + + } + for (var i = 0; i < s.messages.length; i++) { + if (filter) { + if (s.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) { + if (s.messages[i].filename.includes(filter)) { + allFiles.push(s.messages[i].filename); + } + } else if (s.messages[i].includes(filter)) { + allFiles.push(s.messages[i]); + } + } else { + if (s.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) { + allFiles.push(s.messages[i].filename); + } else { + allFiles.push(s.messages[i]); + } + } + } + for (var i = 0; i < s.textFiles.length; ++i) { + if (filter) { + if (s.textFiles[i].fn.includes(filter)) { + allFiles.push(s.textFiles[i].fn); + } + } else { + allFiles.push(s.textFiles[i].fn); + } + } + + //Sort the files alphabetically then print each + allFiles.sort(); + + for (var i = 0; i < allFiles.length; i++) { + post(allFiles[i]); + } + }, + + executeScanCommand: function(commandArray) { + if (commandArray.length != 1) { + post("Incorrect usage of netstat/scan command. Usage: netstat/scan"); return; + } + //Displays available network connections using TCP + post("Hostname IP Root Access"); + for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().serversOnNetwork.length; i++) { + //Add hostname + var entry = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i); + if (entry == null) {continue;} + entry = entry.hostname; + + //Calculate padding and add IP + var numSpaces = 21 - entry.length; + var spaces = Array(numSpaces+1).join(" "); + entry += spaces; + entry += _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip; + + //Calculate padding and add root access info + var hasRoot; + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).hasAdminRights) { + hasRoot = 'Y'; + } else { + hasRoot = 'N'; + } + numSpaces = 21 - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip.length; + spaces = Array(numSpaces+1).join(" "); + entry += spaces; + entry += hasRoot; + post(entry); + } + }, + + executeScanAnalyzeCommand: function(depth=1, all=false) { + //We'll use the AllServersMap as a visited() array + //TODO Using array as stack for now, can make more efficient + post("~~~~~~~~~~ Beginning scan-analyze ~~~~~~~~~~"); + post(" "); + var visited = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["AllServersMap"](); + + var stack = []; + var depthQueue = [0]; + var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + stack.push(currServ); + while(stack.length != 0) { + var s = stack.pop(); + var d = depthQueue.pop(); + if (!all && s.purchasedByPlayer && s.hostname != "home") { + continue; //Purchased server + } else if (visited[s.ip] || d > depth) { + continue; //Already visited or out-of-depth + } else { + visited[s.ip] = 1; + } + for (var i = s.serversOnNetwork.length-1; i >= 0; --i) { + stack.push(s.getServerOnNetwork(i)); + depthQueue.push(d+1); + } + if (d == 0) {continue;} //Don't print current server + var titleDashes = Array((d-1) * 4 + 1).join("-"); + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].AutoLink)) { + post("" + titleDashes + "> " + s.hostname + "", false); + } else { + post("" + titleDashes + ">" + s.hostname + ""); + } + + var dashes = titleDashes + "--"; + //var dashes = Array(d * 2 + 1).join("-"); + var c = "NO"; + if (s.hasAdminRights) {c = "YES";} + post(dashes + "Root Access: " + c + ", Required hacking skill: " + s.requiredHackingSkill); + post(dashes + "Number of open ports required to NUKE: " + s.numOpenPortsRequired); + post(dashes + "RAM: " + s.maxRam); + post(" "); + } + + var links = document.getElementsByClassName("scan-analyze-link"); + for (var i = 0; i < links.length; ++i) { + (function() { + var hostname = links[i].innerHTML.toString(); + links[i].onclick = function() { + if (Terminal.analyzeFlag || Terminal.hackFlag) {return;} + Terminal.connectToServer(hostname); + } + }());//Immediate invocation + } + + }, + + executeFreeCommand: function(commandArray) { + if (commandArray.length != 1) { + post("Incorrect usage of free command. Usage: free"); return; + } + post("Total: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().maxRam, 2) + " GB"); + post("Used: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ramUsed, 2) + " GB"); + post("Available: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().maxRam - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ramUsed, 2) + " GB"); + }, + + //First called when the "run [program]" command is called. Checks to see if you + //have the executable and, if you do, calls the executeProgram() function + runProgram: function(programName) { + //Check if you have the program on your computer. If you do, execute it, otherwise + //display an error message + var splitArgs = programName.split(" "); + var name = " "; + if (splitArgs.length > 1) { + name = splitArgs[0]; + } else { + name = programName; + } + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(name)) { + Terminal.executeProgram(programName); + return; + } + post("ERROR: No such executable on home computer (Only programs that exist on your home computer can be run)"); + }, + + //Contains the implementations of all possible programs + executeProgram: function(programName) { + var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + var splitArgs = programName.split(" "); + if (splitArgs.length > 1) { + programName = splitArgs[0]; + } + switch (programName) { + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].NukeProgram: + if (s.hasAdminRights) { + post("You already have root access to this computer. There is no reason to run NUKE.exe"); + } else { + if (s.openPortCount >= _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().numOpenPortsRequired) { + s.hasAdminRights = true; + post("NUKE successful! Gained root access to " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname); + //TODO Make this take time rather than be instant + } else { + post("NUKE unsuccessful. Not enough ports have been opened"); + } + } + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BruteSSHProgram: + if (s.sshPortOpen) { + post("SSH Port (22) is already open!"); + } else { + s.sshPortOpen = true; + post("Opened SSH Port(22)!") + ++s.openPortCount; + } + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].FTPCrackProgram: + if (s.ftpPortOpen) { + post("FTP Port (21) is already open!"); + } else { + s.ftpPortOpen = true; + post("Opened FTP Port (21)!"); + ++s.openPortCount; + } + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].RelaySMTPProgram: + if (s.smtpPortOpen) { + post("SMTP Port (25) is already open!"); + } else { + s.smtpPortOpen = true; + post("Opened SMTP Port (25)!"); + ++s.openPortCount; + } + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].HTTPWormProgram: + if (s.httpPortOpen) { + post("HTTP Port (80) is already open!"); + } else { + s.httpPortOpen = true; + post("Opened HTTP Port (80)!"); + ++s.openPortCount; + } + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].SQLInjectProgram: + if (s.sqlPortOpen) { + post("SQL Port (1433) is already open!"); + } else { + s.sqlPortOpen = true; + post("Opened SQL Port (1433)!"); + ++s.openPortCount; + } + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].ServerProfiler: + if (splitArgs.length != 2) { + post("Must pass a server hostname or IP as an argument for ServerProfiler.exe"); + return; + } + var serv = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(splitArgs[1]); + if (serv == null) { + post("Invalid server IP/hostname"); + return; + } + post(serv.hostname + ":"); + post("Server base security level: " + serv.baseDifficulty); + post("Server current security level: " + serv.hackDifficulty); + post("Server growth rate: " + serv.serverGrowth); + post("Netscript hack() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateHackingTime"])(serv), 1) + "s"); + post("Netscript grow() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateGrowTime"])(serv)/1000, 1) + "s"); + post("Netscript weaken() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateWeakenTime"])(serv)/1000, 1) + "s"); + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].AutoLink: + post("This executable cannot be run."); + post("AutoLink.exe lets you automatically connect to other servers when using 'scan-analyze'."); + post("When using scan-analyze, click on a server's hostname to connect to it."); + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1: + post("This executable cannot be run."); + post("DeepscanV1.exe lets you run 'scan-analyze' with a depth up to 5."); + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2: + post("This executable cannot be run."); + post("DeepscanV2.exe lets you run 'scan-analyze' with a depth up to 10."); + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].Flight: + post("Augmentations: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].augmentations.length + " / 30"); + post("Money: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].money.toNumber(), 2) + " / $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(100000000000, 2)); + post("One path below must be fulfilled..."); + post("----------HACKING PATH----------"); + post("Hacking skill: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hacking_skill + " / 2500"); + post("----------COMBAT PATH----------"); + post("Strength: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].strength + " / 1500"); + post("Defense: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].defense + " / 1500"); + post("Dexterity: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].dexterity + " / 1500"); + post("Agility: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].agility + " / 1500"); + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BitFlume: + var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxGetYesButton"])(), + noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxGetNoButton"])(); + yesBtn.innerHTML = "Travel to BitNode Nexus"; + noBtn.innerHTML = "Cancel"; + yesBtn.addEventListener("click", function() { + Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_13__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN, true); + return Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxClose"])(); + }); + noBtn.addEventListener("click", function() { + return Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxClose"])(); + }); + Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxCreate"])("WARNING: USING THIS PROGRAM WILL CAUSE YOU TO LOSE ALL OF YOUR PROGRESS ON THE CURRENT BITNODE.

" + + "Do you want to travel to the BitNode Nexus? This allows you to reset the current BitNode " + + "and select a new one."); + + break; + default: + post("Invalid executable. Cannot be run"); + return; + } + }, + + runScript: function(scriptName) { + var server = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + + var numThreads = 1; + var args = []; + var results = scriptName.split(" "); + if (results.length <= 0) { + post("This is a bug. Please contact developer"); + } + scriptName = results[0]; + if (results.length > 1) { + if (results.length >= 3 && results[1] == "-t") { + numThreads = Math.round(Number(results[2])); + if (isNaN(numThreads) || numThreads < 1) { + post("Invalid number of threads specified. Number of threads must be greater than 0"); + return; + } + for (var i = 3; i < results.length; ++i) { + var arg = results[i]; + + //Forced string + if ((arg.startsWith("'") && arg.endsWith("'")) || + (arg.startsWith('"') && arg.endsWith('"'))) { + args.push(arg.slice(1, -1)); + continue; + } + //Number + var tempNum = Number(arg); + if (!isNaN(tempNum)) { + args.push(tempNum); + continue; + } + //Otherwise string + args.push(arg); + } + } else { + for (var i = 1; i < results.length; ++i) { + var arg = results[i]; + + //Forced string + if ((arg.startsWith("'") && arg.endsWith("'")) || + (arg.startsWith('"') && arg.endsWith('"'))) { + args.push(arg.slice(1, -1)); + continue; + } + //Number + var tempNum = Number(arg); + if (!isNaN(tempNum)) { + args.push(tempNum); + continue; + } + //Otherwise string + args.push(arg); + } + } + } + + + //Check if this script is already running + if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, server) != null) { + post("ERROR: This script is already running. Cannot run multiple instances"); + return; + } + + //Check if the script exists and if it does run it + for (var i = 0; i < server.scripts.length; i++) { + if (server.scripts[i].filename == scriptName) { + //Check for admin rights and that there is enough RAM availble to run + var script = server.scripts[i]; + var ramUsage = script.ramUsage * numThreads * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, numThreads-1); + var ramAvailable = server.maxRam - server.ramUsed; + + if (server.hasAdminRights == false) { + post("Need root access to run script"); + return; + } else if (ramUsage > ramAvailable){ + post("This machine does not have enough RAM to run this script with " + + numThreads + " threads. Script requires " + ramUsage + "GB of RAM"); + return; + } else { + //Able to run script + post("Running script with " + numThreads + " thread(s) and args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["printArray"])(args) + "."); + post("May take a few seconds to start up the process..."); + var runningScriptObj = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["RunningScript"](script, args); + runningScriptObj.threads = numThreads; + server.runningScripts.push(runningScriptObj); + + Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["addWorkerScript"])(runningScriptObj, server); + return; + } + } + } + + post("ERROR: No such script"); + } +}; + + + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 38))) + +/***/ }), +/* 19 */ /*!******************************!*\ !*** ./src/Augmentations.js ***! \******************************/ @@ -13432,7 +15508,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engine.js */ 5); /* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Faction.js */ 11); /* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 29); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _Prestige_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Prestige.js */ 57); /* harmony import */ var _SaveObject_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./SaveObject.js */ 46); @@ -16050,7 +18126,7 @@ function displaySourceFiles(listElement, sourceFiles) { /***/ }), -/* 19 */ +/* 20 */ /*!***********************!*\ !*** ./src/Crimes.js ***! \***********************/ @@ -16365,7 +18441,7 @@ function determineCrimeChanceHeist() { /***/ }), -/* 20 */ +/* 21 */ /*!********************************!*\ !*** ./src/NetscriptWorker.js ***! \********************************/ @@ -16389,8 +18465,8 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _NetscriptJSEvaluator_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptJSEvaluator.js */ 63); /* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptPort.js */ 45); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Settings.js */ 24); -/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/acorn.js */ 34); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Settings.js */ 23); +/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/acorn.js */ 35); /* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); @@ -16445,6 +18521,7 @@ function prestigeWorkerScripts() { Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["deleteActiveScriptsItem"])(workerScripts[i]); workerScripts[i].env.stopFlag = true; } + Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])(); //Force UI to update workerScripts.length = 0; } @@ -16454,36 +18531,48 @@ function prestigeWorkerScripts() { function startJsScript(workerScript) { workerScript.running = true; + // The name of the currently running netscript function, to prevent concurrent + // calls to hack, grow, etc. + let runningFn = null; + // We need to go through the environment and wrap each function in such a way that it // can be called at most once at a time. This will prevent situations where multiple // hack promises are outstanding, for example. function wrap(propName, f) { - let running = null; // The name of the currently running netscript function. // This function unfortunately cannot be an async function, because we don't // know if the original one was, and there's no way to tell. return function (...args) { + // Wrap every netscript function with a check for the stop flag. + // This prevents cases where we never stop because we are only calling + // netscript functions that don't check this. + // This is not a problem for legacy Netscript because it also checks the + // stop flag in the evaluator. + if (workerScript.env.stopFlag) {throw workerScript;} + + if (propName === "sleep") return f(...args); // OK for multiple simultaneous calls to sleep. + const msg = "Concurrent calls to Netscript functions not allowed! " + "Did you forget to await hack(), grow(), or some other " + "promise-returning function? (Currently running: %s tried to run: %s)" - if (running) { - workerScript.errorMessage = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["makeRuntimeRejectMsg"])(workerScript, sprintf(msg, running, propName), null) + if (runningFn) { + workerScript.errorMessage = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["makeRuntimeRejectMsg"])(workerScript, sprintf(msg, runningFn, propName), null) throw workerScript; } - running = propName; + runningFn = propName; let result = f(...args); if (result && result.finally !== undefined) { return result.finally(function () { - running = null; + runningFn = null; }); } else { - running = null; + runningFn = null; return result; } } }; + for (let prop in workerScript.env.vars) { if (typeof workerScript.env.vars[prop] !== "function") continue; - if (prop === "sleep") continue; // OK for multiple simultaneous calls to sleep. workerScript.env.vars[prop] = wrap(prop, workerScript.env.vars[prop]); } @@ -16496,7 +18585,8 @@ function startJsScript(workerScript) { return [mainReturnValue, workerScript]; }).catch(e => { if (e instanceof Error) { - workerScript.errorMessage = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["makeRuntimeRejectMsg"])(workerScript, e.message + (e.stack && ("\nstack:\n" + e.stack.toString()) || "")); + workerScript.errorMessage = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["makeRuntimeRejectMsg"])( + workerScript, e.message + (e.stack && ("\nstack:\n" + e.stack.toString()) || "")); throw workerScript; } else if (Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(e)) { workerScript.errorMessage = e; @@ -16679,7 +18769,7 @@ function updateOnlineScriptTimes(numCycles = 1) { /***/ }), -/* 21 */ +/* 22 */ /*!****************************!*\ !*** ./src/StockMarket.js ***! \****************************/ @@ -16713,7 +18803,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5); /* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Location.js */ 4); /* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 29); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); @@ -16736,7 +18826,8 @@ __webpack_require__.r(__webpack_exports__); -/* StockMarket.js */ +let StockPriceCap = 1e9; //Put a limit on how high a price can go + function Stock(name, symbol, mv, b, otlkMag, initPrice=10000) { this.symbol = symbol; this.name = name; @@ -17297,6 +19388,10 @@ function updateStockPrices() { chc = (chc - stock.otlkMag)/100; if (isNaN(chc)) {chc = 0.5;} } + if (stock.price >= StockPriceCap) { + chc = -1; //Limit on stock price + stock.b = false; + } var c = Math.random(); if (c < chc) { @@ -18054,2062 +20149,135 @@ function updateStockOrderList(stock) { /***/ }), -/* 22 */ +/* 23 */ /*!*************************!*\ - !*** ./src/Terminal.js ***! + !*** ./src/Settings.js ***! \*************************/ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); -/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postNetburnerText", function() { return postNetburnerText; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "post", function() { return post; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Terminal", function() { return Terminal; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KEY", function() { return KEY; }); -/* harmony import */ var _Alias_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Alias.js */ 30); -/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3); -/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CreateProgram.js */ 14); -/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DarkWeb.js */ 33); -/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./engine.js */ 5); -/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 35); -/* harmony import */ var _HelpText_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./HelpText.js */ 72); -/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 25); -/* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Literature.js */ 53); -/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Message.js */ 28); -/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 7); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); -/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Player.js */ 0); -/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./RedPill.js */ 44); -/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Script.js */ 26); -/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Settings.js */ 24); -/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); -/* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./TextFile.js */ 41); -/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2); -/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); -/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../utils/LogBox.js */ 51); -/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12); -/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! jszip */ 121); -/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_23___default = /*#__PURE__*/__webpack_require__.n(jszip__WEBPACK_IMPORTED_MODULE_23__); -/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! file-saver */ 120); -/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(file_saver__WEBPACK_IMPORTED_MODULE_24__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Settings", function() { return Settings; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSettings", function() { return initSettings; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setSettingsLabels", function() { return setSettingsLabels; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadSettings", function() { return loadSettings; }); +/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.js */ 5); - - - - - - - - - - - - - - - - - - - - - - - - - - -/* Write text to terminal */ -//If replace is true then spaces are replaced with " " -function post(input) { - $("#terminal-input").before('' + input + ''); - updateTerminalScroll(); +/* Settings.js */ +let Settings = { + CodeInstructionRunTime: 50, + MaxLogCapacity: 50, + MaxPortCapacity: 50, + SuppressMessages: false, + SuppressFactionInvites: false, + AutosaveInterval: 60, + DisableHotkeys: false, + ThemeHighlightColor: "#ffffff", + ThemeFontColor: "#66ff33", + ThemeBackgroundColor: "#000000", + EditorTheme: "Monokai", + EditorKeybinding: "ace", } -//Same thing as post but the td cells have ids so they can be animated for the hack progress bar -function hackProgressBarPost(input) { - $("#terminal-input").before('' + input + ''); - updateTerminalScroll(); +function loadSettings(saveString) { + Settings = JSON.parse(saveString); } -function hackProgressPost(input) { - $("#terminal-input").before('' + input + ''); - updateTerminalScroll(); +function initSettings() { + Settings.CodeInstructionRunTime = 50; + Settings.MaxLogCapacity = 50; + Settings.MaxPortCapacity = 50; + Settings.SuppressMessages = false; + Settings.SuppressFactionInvites = false; + Settings.AutosaveInterval = 60; + Settings.DisableHotkeys = false; } -//Scroll to the bottom of the terminal's 'text area' -function updateTerminalScroll() { - var element = document.getElementById("terminal-container"); - element.scrollTop = element.scrollHeight; -} +function setSettingsLabels() { + var nsExecTime = document.getElementById("settingsNSExecTimeRangeValLabel"); + var nsLogLimit = document.getElementById("settingsNSLogRangeValLabel"); + var nsPortLimit = document.getElementById("settingsNSPortRangeValLabel"); + var suppressMsgs = document.getElementById("settingsSuppressMessages"); + var suppressFactionInv = document.getElementById("settingsSuppressFactionInvites") + var autosaveInterval = document.getElementById("settingsAutosaveIntervalValLabel"); + var disableHotkeys = document.getElementById("settingsDisableHotkeys"); -function postNetburnerText() { - post("Bitburner v" + _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].Version); -} + //Initialize values on labels + nsExecTime.innerHTML = Settings.CodeInstructionRunTime + "ms"; + nsLogLimit.innerHTML = Settings.MaxLogCapacity; + nsPortLimit.innerHTML = Settings.MaxPortCapacity; + 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"); + var nsLogRangeInput = document.getElementById("settingsNSLogRangeVal"); + var nsPortRangeInput = document.getElementById("settingsNSPortRangeVal"); + var nsAutosaveIntervalInput = document.getElementById("settingsAutosaveIntervalVal"); + nsExecTimeInput.value = Settings.CodeInstructionRunTime; + nsLogRangeInput.value = Settings.MaxLogCapacity; + nsPortRangeInput.value = Settings.MaxPortCapacity; + nsAutosaveIntervalInput.value = Settings.AutosaveInterval; -//Key Codes -var KEY = { - TAB: 9, - ENTER: 13, - CTRL: 17, - UPARROW: 38, - DOWNARROW: 40, - A: 65, - B: 66, - C: 67, - D: 68, - E: 69, - F: 70, - H: 72, - K: 75, - L: 76, - M: 77, - N: 78, - P: 80, - U: 85, - W: 87, -} + nsExecTimeInput.oninput = function() { + nsExecTime.innerHTML = this.value + 'ms'; + Settings.CodeInstructionRunTime = this.value; + }; -//Defines key commands in terminal -$(document).keydown(function(event) { - //Terminal - if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { - var terminalInput = document.getElementById("terminal-input-text-box"); - if (terminalInput != null && !event.ctrlKey && !event.shiftKey) {terminalInput.focus();} + nsLogRangeInput.oninput = function() { + nsLogLimit.innerHTML = this.value; + Settings.MaxLogCapacity = this.value; + }; - if (event.keyCode === KEY.ENTER) { - event.preventDefault(); //Prevent newline from being entered in Script Editor - var command = $('input[class=terminal-input]').val(); - if (command.length > 0) { - post("[" + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname + " ~]> " + command); + nsPortRangeInput.oninput = function() { + nsPortLimit.innerHTML = this.value; + Settings.MaxPortCapacity = this.value; + }; - Terminal.resetTerminalInput(); //Clear input first - Terminal.executeCommand(command); - } - } - - if (event.keyCode === KEY.C && event.ctrlKey) { - if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"]._actionInProgress) { - //Cancel action - post("Cancelling..."); - _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"]._actionInProgress = false; - Terminal.finishAction(true); - } else if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) { - //Dont prevent default so it still copies - Terminal.resetTerminalInput(); //Clear Terminal - } - } - - if (event.keyCode === KEY.L && event.ctrlKey) { - event.preventDefault(); - Terminal.executeCommand("clear"); //Clear screen + nsAutosaveIntervalInput.oninput = function() { + autosaveInterval.innerHTML = this.value; + Settings.AutosaveInterval = Number(this.value); + if (Number(this.value) === 0) { + _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = Infinity; + } else { + _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = Number(this.value) * 5; } + }; - //Ctrl p same as up arrow - //Ctrl n same as down arrow + suppressMsgs.onclick = function() { + Settings.SuppressMessages = this.checked; + }; - if (event.keyCode === KEY.UPARROW || - (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS && event.keyCode === KEY.P && event.ctrlKey)) { - if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) {event.preventDefault();} - //Cycle through past commands - if (terminalInput == null) {return;} - var i = Terminal.commandHistoryIndex; - var len = Terminal.commandHistory.length; + suppressFactionInv.onclick = function() { + Settings.SuppressFactionInvites = this.checked; + }; - if (len == 0) {return;} - if (i < 0 || i > len) { - Terminal.commandHistoryIndex = len; - } - - if (i != 0) { - --Terminal.commandHistoryIndex; - } - var prevCommand = Terminal.commandHistory[Terminal.commandHistoryIndex]; - terminalInput.value = prevCommand; - setTimeout(function(){terminalInput.selectionStart = terminalInput.selectionEnd = 10000; }, 0); - } - - if (event.keyCode === KEY.DOWNARROW || - (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS && event.keyCode === KEY.M && event.ctrlKey)) { - if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) {event.preventDefault();} - //Cycle through past commands - if (terminalInput == null) {return;} - var i = Terminal.commandHistoryIndex; - var len = Terminal.commandHistory.length; - - if (len == 0) {return;} - if (i < 0 || i > len) { - Terminal.commandHistoryIndex = len; - } - - //Latest command, put nothing - if (i == len || i == len-1) { - Terminal.commandHistoryIndex = len; - terminalInput.value = ""; - } else { - ++Terminal.commandHistoryIndex; - var prevCommand = Terminal.commandHistory[Terminal.commandHistoryIndex]; - terminalInput.value = prevCommand; - } - } - - if (event.keyCode === KEY.TAB) { - //Autocomplete - if (terminalInput == null) {return;} - var input = terminalInput.value; - if (input == "") {return;} - input = input.trim(); - input = input.replace(/\s\s+/g, ' '); - - var commandArray = input.split(" "); - var index = commandArray.length - 2; - if (index < -1) {index = 0;} - var allPos = determineAllPossibilitiesForTabCompletion(input, index); - if (allPos.length == 0) {return;} - - var arg = ""; - var command = ""; - if (commandArray.length == 0) {return;} - if (commandArray.length == 1) {command = commandArray[0];} - else if (commandArray.length == 2) { - command = commandArray[0]; - arg = commandArray[1]; - } else if (commandArray.length == 3) { - command = commandArray[0] + " " + commandArray[1]; - arg = commandArray[2]; - } else { - arg = commandArray.pop(); - command = commandArray.join(" "); - } - - tabCompletion(command, arg, allPos); - } - - //Extra Bash Emulation Hotkeys, must be enabled through .fconf - if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) { - if (event.keyCode === KEY.A && event.ctrlKey) { - event.preventDefault(); - Terminal.moveTextCursor("home"); - } - - if (event.keyCode === KEY.E && event.ctrlKey) { - event.preventDefault(); - Terminal.moveTextCursor("end"); - } - - if (event.keyCode === KEY.B && event.ctrlKey) { - event.preventDefault(); - Terminal.moveTextCursor("prevchar"); - } - - if (event.keyCode === KEY.B && event.altKey) { - event.preventDefault(); - Terminal.moveTextCursor("prevword"); - } - - if (event.keyCode === KEY.F && event.ctrlKey) { - event.preventDefault(); - Terminal.moveTextCursor("nextchar"); - } - - if (event.keyCode === KEY.F && event.altKey) { - event.preventDefault(); - Terminal.moveTextCursor("nextword"); - } - - - if ((event.keyCode === KEY.H || event.keyCode === KEY.D) && event.ctrlKey) { - Terminal.modifyInput("backspace"); - event.preventDefault(); - } - - //TODO AFTER THIS: - - //alt + d deletes word after cursor - //^w deletes word before cursor - //^k clears line after cursor - //^u clears line before cursor - } - } -}); - -//Keep terminal in focus -let terminalCtrlPressed = false; -$(document).ready(function() { - if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { - $('.terminal-input').focus(); - } -}); -$(document).keydown(function(e) { - if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { - if (e.which == 17) { - terminalCtrlPressed = true; - } else if (terminalCtrlPressed == true) { - //Don't focus - } else { - var inputTextBox = document.getElementById("terminal-input-text-box"); - if (inputTextBox != null) { - inputTextBox.focus(); - } - - terminalCtrlPressed = false; - } - } -}) -$(document).keyup(function(e) { - if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { - if (e.which == 17) { - terminalCtrlPressed = false; - } - } -}) - -//Implements a tab completion feature for terminal -// command - Command (first arg only) -// arg - Incomplete argument string that the function will try to complete, or will display -// a series of possible options for -// allPossibilities - Array of strings containing all possibilities that the -// string can complete to -// index - index of argument that is being "tab completed". By default is 0, the first argument -function tabCompletion(command, arg, allPossibilities, index=0) { - if (!(allPossibilities.constructor === Array)) {return;} - if (!Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["containsAllStrings"])(allPossibilities)) {return;} - - if (!command.startsWith("./")) { - command = command.toLowerCase(); + disableHotkeys.onclick = function() { + Settings.DisableHotkeys = this.checked; } - //Remove all options in allPossibilities that do not match the current string - //that we are attempting to autocomplete - if (arg == "") { - for (var i = allPossibilities.length-1; i >= 0; --i) { - if (!allPossibilities[i].toLowerCase().startsWith(command.toLowerCase())) { - allPossibilities.splice(i, 1); - } - } - } else { - for (var i = allPossibilities.length-1; i >= 0; --i) { - if (!allPossibilities[i].toLowerCase().startsWith(arg.toLowerCase())) { - allPossibilities.splice(i, 1); - } - } - } - - var val = ""; - if (allPossibilities.length == 0) { + //Theme + if (Settings.ThemeHighlightColor == null || Settings.ThemeFontColor == null || Settings.ThemeBackgroundColor == null) { + console.log("ERROR: Cannot find Theme Settings"); return; - } else if (allPossibilities.length == 1) { - if (arg == "") { - //Autocomplete command - val = allPossibilities[0] + " "; - } else { - val = command + " " + allPossibilities[0]; - } - document.getElementById("terminal-input-text-box").value = val; - document.getElementById("terminal-input-text-box").focus(); - } else { - var longestStartSubstr = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["longestCommonStart"])(allPossibilities); - //If the longest common starting substring of remaining possibilities is the same - //as whatevers already in terminal, just list all possible options. Otherwise, - //change the input in the terminal to the longest common starting substr - var allOptionsStr = ""; - for (var i = 0; i < allPossibilities.length; ++i) { - allOptionsStr += allPossibilities[i]; - allOptionsStr += " "; - } - if (arg == "") { - if (longestStartSubstr == command) { - post("> " + command); - post(allOptionsStr); - } else { - document.getElementById("terminal-input-text-box").value = longestStartSubstr; - document.getElementById("terminal-input-text-box").focus(); - } - } else { - if (longestStartSubstr == arg) { - //List all possible options - post("> " + command + " " + arg); - post(allOptionsStr); - } else { - document.getElementById("terminal-input-text-box").value = command + " " + longestStartSubstr; - document.getElementById("terminal-input-text-box").focus(); - } - } - + } + if (/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeHighlightColor) && + /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeFontColor) && + /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeBackgroundColor)) { + document.body.style.setProperty('--my-highlight-color', Settings.ThemeHighlightColor); + document.body.style.setProperty('--my-font-color', Settings.ThemeFontColor); + document.body.style.setProperty('--my-background-color', Settings.ThemeBackgroundColor); } } -function determineAllPossibilitiesForTabCompletion(input, index=0) { - var allPos = []; - allPos = allPos.concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["GlobalAliases"])); - var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - input = input.toLowerCase(); - //If the command starts with './' and the index == -1, then the user - //has input ./partialexecutablename so autocomplete the script or program - //Put './' in front of each script/executable - if (input.startsWith("./") && index == -1) { - //All programs and scripts - for (var i = 0; i < currServ.scripts.length; ++i) { - allPos.push("./" + currServ.scripts[i].filename); - } - //Programs are on home computer - var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getHomeComputer(); - for(var i = 0; i < homeComputer.programs.length; ++i) { - allPos.push("./" + homeComputer.programs[i]); - } - return allPos; - } - - //Autocomplete the command - if (index == -1) { - return ["alias", "analyze", "cat", "check", "clear", "cls", "connect", "download", "free", - "hack", "help", "home", "hostname", "ifconfig", "kill", "killall", - "ls", "lscpu", "mem", "nano", "ps", "rm", "run", "scan", "scan-analyze", - "scp", "sudov", "tail", "theme", "top"].concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["Aliases"])).concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["GlobalAliases"])); - } - - if (input.startsWith ("buy ")) { - return [_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BruteSSHProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].FTPCrackProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].RelaySMTPProgram, - _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].HTTPWormProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].SQLInjectProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1, - _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2].concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["GlobalAliases"])); - } - - if (input.startsWith("scp ") && index == 1) { - for (var iphostname in _Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"]) { - if (_Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"].hasOwnProperty(iphostname)) { - allPos.push(_Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"][iphostname].ip); - allPos.push(_Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"][iphostname].hostname); - } - } - } - - if (input.startsWith("scp ") && index == 0) { - //All Scripts and lit files - for (var i = 0; i < currServ.scripts.length; ++i) { - allPos.push(currServ.scripts[i].filename); - } - for (var i = 0; i < currServ.messages.length; ++i) { - if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"])) { - allPos.push(currServ.messages[i]); - } - } - for (var i = 0; i < currServ.textFiles.length; ++i) { - allPos.push(currServ.textFiles[i].fn); - } - } - - if (input.startsWith("connect ") || input.startsWith("telnet ")) { - //All network connections - for (var i = 0; i < currServ.serversOnNetwork.length; ++i) { - var serv = _Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"][currServ.serversOnNetwork[i]]; - if (serv == null) {continue;} - allPos.push(serv.ip); //IP - allPos.push(serv.hostname); //Hostname - } - return allPos; - } - - if (input.startsWith("kill ") || input.startsWith("tail ") || - input.startsWith("mem ") || input.startsWith("check ")) { - //All Scripts - for (var i = 0; i < currServ.scripts.length; ++i) { - allPos.push(currServ.scripts[i].filename); - } - return allPos; - } - - if (input.startsWith("nano ")) { - //Scripts and text files and .fconf - for (var i = 0; i < currServ.scripts.length; ++i) { - allPos.push(currServ.scripts[i].filename); - } - for (var i = 0; i < currServ.textFiles.length; ++i) { - allPos.push(currServ.textFiles[i].fn); - } - allPos.push(".fconf"); - return allPos; - } - - if (input.startsWith("rm ")) { - for (var i = 0; i < currServ.scripts.length; ++i) { - allPos.push(currServ.scripts[i].filename); - } - for (var i = 0; i < currServ.programs.length; ++i) { - allPos.push(currServ.programs[i]); - } - for (var i = 0; i < currServ.messages.length; ++i) { - if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["isString"])(currServ.messages[i]) && - currServ.messages[i].endsWith(".lit")) { - allPos.push(currServ.messages[i]); - } - } - for (var i = 0; i < currServ.textFiles.length; ++i) { - allPos.push(currServ.textFiles[i].fn); - } - return allPos; - } - - if (input.startsWith("run ")) { - //All programs and scripts - for (var i = 0; i < currServ.scripts.length; ++i) { - allPos.push(currServ.scripts[i].filename); - } - - //Programs are on home computer - var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getHomeComputer(); - for(var i = 0; i < homeComputer.programs.length; ++i) { - allPos.push(homeComputer.programs[i]); - } - return allPos; - } - - if (input.startsWith("cat ")) { - for (var i = 0; i < currServ.messages.length; ++i) { - if (currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) { - allPos.push(currServ.messages[i].filename); - } else { - allPos.push(currServ.messages[i]); - } - } - for (var i = 0; i < currServ.textFiles.length; ++i) { - allPos.push(currServ.textFiles[i].fn); - } - return allPos; - } - - if (input.startsWith("download ")) { - for (var i = 0; i < currServ.textFiles.length; ++i) { - allPos.push(currServ.textFiles[i].fn); - } - for (var i = 0; i < currServ.scripts.length; ++i) { - allPos.push(currServ.scripts[i].filename); - } - } - return allPos; -} - -let Terminal = { - //Flags to determine whether the player is currently running a hack or an analyze - hackFlag: false, - analyzeFlag: false, - - commandHistory: [], - commandHistoryIndex: 0, - - resetTerminalInput: function() { - document.getElementById("terminal-input-td").innerHTML = - "
[" + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname + " ~]" + "$
" + - ''; - var hdr = document.getElementById("terminal-input-header"); - hdr.style.display = "inline"; - }, - - modifyInput: function(mod) { - try { - var terminalInput = document.getElementById("terminal-input-text-box"); - if (terminalInput == null) {return;} - terminalInput.focus(); - - var inputLength = terminalInput.value.length; - var start = terminalInput.selectionStart; - var end = terminalInput.selectionEnd; - var inputText = terminalInput.value; - - switch(mod.toLowerCase()) { - case "backspace": - if (start > 0 && start <= inputLength+1) { - terminalInput.value = inputText.substr(0, start-1) + inputText.substr(start); - } - break; - case "deletewordbefore": //Delete rest of word before the cursor - for (var delStart = start-1; delStart > 0; --delStart) { - if (inputText.charAt(delStart) === " ") { - terminalInput.value = inputText.substr(0, delStart) + inputText.substr(start); - return; - } - } - break; - case "deletewordafter": //Delete rest of word after the cursor - for (var delStart = start+1; delStart <= text.length+1; ++delStart) { - if (inputText.charAt(delStart) === " ") { - terminalInput.value = inputText.substr(0, start) + inputText.substr(delStart); - return; - } - } - break; - case "clearafter": //Deletes everything after cursor - break; - case "clearbefore:": //Deleetes everything before cursor - break; - } - } catch(e) { - console.log("Exception in Terminal.modifyInput: " + e); - } - }, - - moveTextCursor: function(loc) { - try { - var terminalInput = document.getElementById("terminal-input-text-box"); - if (terminalInput == null) {return;} - terminalInput.focus(); - - var inputLength = terminalInput.value.length; - var start = terminalInput.selectionStart; - var end = terminalInput.selectionEnd; - - switch(loc.toLowerCase()) { - case "home": - terminalInput.setSelectionRange(0,0); - break; - case "end": - terminalInput.setSelectionRange(inputLength, inputLength); - break; - case "prevchar": - if (start > 0) {terminalInput.setSelectionRange(start-1, start-1);} - break; - case "prevword": - for (var i = start-2; i >= 0; --i) { - if (terminalInput.value.charAt(i) === " ") { - terminalInput.setSelectionRange(i+1, i+1); - return; - } - } - terminalInput.setSelectionRange(0, 0); - break; - case "nextchar": - terminalInput.setSelectionRange(start+1, start+1); - break; - case "nextword": - for (var i = start+1; i <= inputLength; ++i) { - if (terminalInput.value.charAt(i) === " ") { - terminalInput.setSelectionRange(i, i); - return; - } - } - terminalInput.setSelectionRange(inputLength, inputLength); - break; - default: - console.log("WARNING: Invalid loc argument in Terminal.moveTextCursor()"); - break; - } - } catch(e) { - console.log("Exception in Terminal.moveTextCursor: " + e); - } - }, - - finishAction: function(cancelled = false) { - if (Terminal.hackFlag) { - Terminal.finishHack(cancelled); - } else if (Terminal.analyzeFlag) { - Terminal.finishAnalyze(cancelled); - } - }, - - //Complete the hack/analyze command - finishHack: function(cancelled = false) { - if (cancelled == false) { - var server = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - - //Calculate whether hack was successful - var hackChance = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingChance(); - var rand = Math.random(); - console.log("Hack success chance: " + hackChance + ", rand: " + rand); - var expGainedOnSuccess = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateExpGain(); - var expGainedOnFailure = (expGainedOnSuccess / 4); - if (rand < hackChance) { //Success! - if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerNames"].WorldDaemon] && - _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerNames"].WorldDaemon] == server.ip) { - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN == null) { - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN = 1; - } - Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_13__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN); - return; - } - server.manuallyHacked = true; - var moneyGained = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculatePercentMoneyHacked(); - moneyGained = Math.floor(server.moneyAvailable * moneyGained); - - if (moneyGained <= 0) {moneyGained = 0;} //Safety check - - server.moneyAvailable -= moneyGained; - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainMoney(moneyGained); - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainHackingExp(expGainedOnSuccess) - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainIntelligenceExp(expGainedOnSuccess / _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].IntelligenceTerminalHackBaseExpGain); - - server.fortify(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].ServerFortifyAmount); - - post("Hack successful! Gained $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(moneyGained, 2) + " and " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(expGainedOnSuccess, 4) + " hacking EXP"); - } else { //Failure - //Player only gains 25% exp for failure? TODO Can change this later to balance - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainHackingExp(expGainedOnFailure) - post("Failed to hack " + server.hostname + ". Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(expGainedOnFailure, 4) + " hacking EXP"); - } - } - - //Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal - $("#hack-progress-bar").attr('id', "old-hack-progress-bar"); - $("#hack-progress").attr('id', "old-hack-progress"); - Terminal.resetTerminalInput(); - $('input[class=terminal-input]').prop('disabled', false); - - Terminal.hackFlag = false; - }, - - finishAnalyze: function(cancelled = false) { - if (cancelled == false) { - post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname + ": "); - post("Organization name: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().organizationName); - var rootAccess = ""; - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights) {rootAccess = "YES";} - else {rootAccess = "NO";} - post("Root Access: " + rootAccess); - post("Required hacking skill: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().requiredHackingSkill); - post("Estimated server security level: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hackDifficulty, 5), 3)); - post("Estimated chance to hack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingChance() * 100, 5), 2) + "%"); - post("Estimated time to hack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingTime(), 5), 3) + " seconds"); - post("Estimated total money available on server: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().moneyAvailable, 5), 2)); - post("Required number of open ports for NUKE: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().numOpenPortsRequired); - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().sshPortOpen) { - post("SSH port: Open") - } else { - post("SSH port: Closed") - } - - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ftpPortOpen) { - post("FTP port: Open") - } else { - post("FTP port: Closed") - } - - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().smtpPortOpen) { - post("SMTP port: Open") - } else { - post("SMTP port: Closed") - } - - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().httpPortOpen) { - post("HTTP port: Open") - } else { - post("HTTP port: Closed") - } - - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().sqlPortOpen) { - post("SQL port: Open") - } else { - post("SQL port: Closed") - } - } - Terminal.analyzeFlag = false; - - //Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal - $("#hack-progress-bar").attr('id', "old-hack-progress-bar"); - $("#hack-progress").attr('id', "old-hack-progress"); - Terminal.resetTerminalInput(); - $('input[class=terminal-input]').prop('disabled', false); - }, - - executeCommand: function(command) { - command = command.trim(); - //Replace all extra whitespace in command with a single space - command = command.replace(/\s\s+/g, ' '); - - //Terminal history - if (Terminal.commandHistory[Terminal.commandHistory.length-1] != command) { - Terminal.commandHistory.push(command); - if (Terminal.commandHistory.length > 50) { - Terminal.commandHistory.splice(0, 1); - } - } - Terminal.commandHistoryIndex = Terminal.commandHistory.length; - - //Process any aliases - command = Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["substituteAliases"])(command); - - //Allow usage of ./ - if (command.startsWith("./")) { - command = "run " + command.slice(2); - } - - //Only split the first space - var commandArray = command.split(" "); - if (commandArray.length > 1) { - commandArray = [commandArray.shift(), commandArray.join(" ")]; - } - - if (commandArray.length == 0) {return;} - - /****************** Interactive Tutorial Terminal Commands ******************/ - if (_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialIsRunning"]) { - var foodnstuffServ = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["GetServerByHostname"])("foodnstuff"); - if (foodnstuffServ == null) {throw new Error("Could not get foodnstuff server"); return;} - - switch(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["currITutorialStep"]) { - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalHelp: - if (commandArray[0] == "help") { - post(_HelpText_js__WEBPACK_IMPORTED_MODULE_6__["TerminalHelpText"]); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalLs: - if (commandArray[0] == "ls") { - Terminal.executeListCommand(commandArray); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScan: - if (commandArray[0] == "scan") { - Terminal.executeScanCommand(commandArray); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScanAnalyze1: - if (commandArray.length == 1 && commandArray[0] == "scan-analyze") { - Terminal.executeScanAnalyzeCommand(1); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScanAnalyze2: - if (commandArray.length == 2 && commandArray[0] == "scan-analyze" && - commandArray[1] == "2") { - Terminal.executeScanAnalyzeCommand(2); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalConnect: - if (commandArray.length == 2) { - if ((commandArray[0] == "connect") && - (commandArray[1] == "foodnstuff" || commandArray[1] == foodnstuffServ.ip)) { - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false; - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = foodnstuffServ.ip; - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true; - post("Connected to foodnstuff"); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Wrong command! Try again!"); return;} - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalAnalyze: - if (commandArray[0] == "analyze") { - if (commandArray.length != 1) { - post("Incorrect usage of analyze command. Usage: analyze"); return; - } - //Analyze the current server for information - Terminal.analyzeFlag = true; - post("Analyzing system..."); - hackProgressPost("Time left:"); - hackProgressBarPost("["); - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].analyze(); - - //Disable terminal - //Terminal.resetTerminalInput(); - document.getElementById("terminal-input-td").innerHTML = ''; - $('input[class=terminal-input]').prop('disabled', true); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else { - post("Bad command. Please follow the tutorial"); - } - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalNuke: - if (commandArray.length == 2 && - commandArray[0] == "run" && commandArray[1] == "NUKE.exe") { - foodnstuffServ.hasAdminRights = true; - post("NUKE successful! Gained root access to foodnstuff"); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalManualHack: - if (commandArray.length == 1 && commandArray[0] == "hack") { - Terminal.hackFlag = true; - hackProgressPost("Time left:"); - hackProgressBarPost("["); - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hack(); - - //Disable terminal - //Terminal.resetTerminalInput(); - document.getElementById("terminal-input-td").innerHTML = ''; - $('input[class=terminal-input]').prop('disabled', true); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalCreateScript: - if (commandArray.length == 2 && - commandArray[0] == "nano" && commandArray[1] == "foodnstuff.script") { - _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent("foodnstuff.script", ""); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalFree: - if (commandArray.length == 1 && commandArray[0] == "free") { - Terminal.executeFreeCommand(commandArray); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalRunScript: - if (commandArray.length == 2 && - commandArray[0] == "run" && commandArray[1] == "foodnstuff.script") { - Terminal.runScript("foodnstuff.script"); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].ActiveScriptsToTerminal: - if (commandArray.length == 2 && - commandArray[0] == "tail" && commandArray[1] == "foodnstuff.script") { - //Check that the script exists on this machine - var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])("foodnstuff.script", [], _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer()); - if (runningScript == null) { - post("Error: No such script exists"); - return; - } - Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__["logBoxCreate"])(runningScript); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - default: - post("Please follow the tutorial, or click 'Exit Tutorial' if you'd like to skip it"); - return; - } - return; - } - - /****************** END INTERACTIVE TUTORIAL ******************/ - - /* Command parser */ - var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - switch (commandArray[0].toLowerCase()) { - case "alias": - if (commandArray.length == 1) { - Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["printAliases"])(); - return; - } - if (commandArray.length == 2) { - if (commandArray[1].startsWith("-g ")) { - var alias = commandArray[1].substring(3); - if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["parseAliasDeclaration"])(alias, true)) { - return; - } - } else { - if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["parseAliasDeclaration"])(commandArray[1])) { - return; - } - } - } - post('Incorrect usage of alias command. Usage: alias [-g] [aliasname="value"]'); - break; - case "analyze": - if (commandArray.length != 1) { - post("Incorrect usage of analyze command. Usage: analyze"); return; - } - //Analyze the current server for information - Terminal.analyzeFlag = true; - post("Analyzing system..."); - hackProgressPost("Time left:"); - hackProgressBarPost("["); - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].analyze(); - - //Disable terminal - //Terminal.resetTerminalInput(); - document.getElementById("terminal-input-td").innerHTML = ''; - $('input[class=terminal-input]').prop('disabled', true); - break; - case "buy": - if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"].hasOwnProperty("Darkweb Server")) { - Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__["executeDarkwebTerminalCommand"])(commandArray); - } else { - post("You need to be able to connect to the Dark Web to use the buy command. (Maybe there's a TOR router you can buy somewhere)"); - } - break; - case "cat": - if (commandArray.length != 2) { - post("Incorrect usage of cat command. Usage: cat [file]"); return; - } - var filename = commandArray[1]; - if (!filename.endsWith(".msg") && !filename.endsWith(".lit") && !filename.endsWith(".txt")) { - post("Error: Only .msg, .txt, and .lit files are viewable with cat (filename must end with .msg, .txt, or .lit)"); return; - } - for (var i = 0; i < s.messages.length; ++i) { - if (filename.endsWith(".lit") && s.messages[i] == filename) { - Object(_Literature_js__WEBPACK_IMPORTED_MODULE_8__["showLiterature"])(s.messages[i]); - return; - } else if (filename.endsWith(".msg") && s.messages[i].filename == filename) { - Object(_Message_js__WEBPACK_IMPORTED_MODULE_9__["showMessage"])(s.messages[i]); - return; - } - } - for (var i = 0; i < s.textFiles.length; ++i) { - if (s.textFiles[i].fn === filename) { - s.textFiles[i].show(); - return; - } - } - post("Error: No such file " + filename); - break; - case "check": - if (commandArray.length < 2) { - post("Incorrect number of arguments. Usage: check [script] [arg1] [arg2]..."); - } else { - var results = commandArray[1].split(" "); - var scriptName = results[0]; - var args = []; - for (var i = 1; i < results.length; ++i) { - args.push(results[i]); - } - - //Can only tail script files - if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(scriptName) == false) { - post("Error: tail can only be called on .script files (filename must end with .script)"); return; - } - - //Check that the script exists on this machine - var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s); - if (runningScript == null) { - post("Error: No such script exists"); - return; - } - runningScript.displayLog(); - } - break; - case "clear": - case "cls": - if (commandArray.length != 1) { - post("Incorrect usage of clear/cls command. Usage: clear/cls"); return; - } - $("#terminal tr:not(:last)").remove(); - postNetburnerText(); - break; - case "connect": - //Disconnect from current server in terminal and connect to new one - if (commandArray.length != 2) { - post("Incorrect usage of connect command. Usage: connect [ip/hostname]"); - return; - } - - var ip = commandArray[1]; - - for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().serversOnNetwork.length; i++) { - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip == ip || _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).hostname == ip) { - Terminal.connectToServer(ip); - return; - } - } - - post("Host not found"); - break; - case "download": - if (commandArray.length != 2) { - post("Incorrect usage of download command. Usage: download [text file]"); - return; - } - var fn = commandArray[1]; - if (fn === "*" || fn === "*.script" || fn === "*.txt") { - //Download all scripts as a zip - var zip = new jszip__WEBPACK_IMPORTED_MODULE_23__(); - if (fn === "*" || fn === "*.script") { - for (var i = 0; i < s.scripts.length; ++i) { - var file = new Blob([s.scripts[i].code], {type:"text/plain"}); - zip.file(s.scripts[i].filename + ".js", file); - } - } - if (fn === "*" || fn === "*.txt") { - for (var i = 0; i < s.textFiles.length; ++i) { - var file = new Blob([s.textFiles[i].text], {type:"text/plain"}); - zip.file(s.textFiles[i].fn, file); - } - } - - var filename; - switch (fn) { - case "*.script": - filename = "bitburnerScripts.zip"; break; - case "*.txt": - filename = "bitburnerTexts.zip"; break; - default: - filename = "bitburnerFiles.zip"; break; - } - - zip.generateAsync({type:"blob"}).then(function(content) { - file_saver__WEBPACK_IMPORTED_MODULE_24__["saveAs"](content, filename); - }); - return; - } else if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(fn)) { - //Download a single script - for (var i = 0; i < s.scripts.length; ++i) { - if (s.scripts[i].filename === fn) { - return s.scripts[i].download(); - } - } - } else if (fn.endsWith(".txt")) { - //Download a single text file - var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_18__["getTextFile"])(fn, s); - if (txtFile !== null) { - return txtFile.download(); - } - } - post("Error: " + fn + " does not exist"); - break; - case "free": - Terminal.executeFreeCommand(commandArray); - break; - case "hack": - if (commandArray.length != 1) { - post("Incorrect usage of hack command. Usage: hack"); return; - } - //Hack the current PC (usually for money) - //You can't hack your home pc or servers you purchased - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().purchasedByPlayer) { - post("Cannot hack your own machines! You are currently connected to your home PC or one of your purchased servers"); - } else if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights == false ) { - post("You do not have admin rights for this machine! Cannot hack"); - } else if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().requiredHackingSkill > _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hacking_skill) { - post("Your hacking skill is not high enough to attempt hacking this machine. Try analyzing the machine to determine the required hacking skill"); - } else { - Terminal.hackFlag = true; - hackProgressPost("Time left:"); - hackProgressBarPost("["); - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hack(); - - //Disable terminal - //Terminal.resetTerminalInput(); - document.getElementById("terminal-input-td").innerHTML = ''; - $('input[class=terminal-input]').prop('disabled', true); - } - break; - case "help": - if (commandArray.length != 1 && commandArray.length != 2) { - post("Incorrect usage of help command. Usage: help"); return; - } - if (commandArray.length == 1) { - post(_HelpText_js__WEBPACK_IMPORTED_MODULE_6__["TerminalHelpText"]); - } else { - var cmd = commandArray[1]; - var txt = _HelpText_js__WEBPACK_IMPORTED_MODULE_6__["HelpTexts"][cmd]; - if (txt == null) { - post("Error: No help topics match '" + cmd + "'"); - return; - } - post(txt); - } - break; - case "home": - if (commandArray.length != 1) { - post("Incorrect usage of home command. Usage: home"); return; - } - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false; - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getHomeComputer().ip; - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true; - post("Connected to home"); - Terminal.resetTerminalInput(); - break; - case "hostname": - if (commandArray.length != 1) { - post("Incorrect usage of hostname command. Usage: hostname"); return; - } - //Print the hostname of current system - post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname); - break; - case "ifconfig": - if (commandArray.length != 1) { - post("Incorrect usage of ifconfig command. Usage: ifconfig"); return; - } - //Print the IP address of the current system - post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ip); - break; - case "kill": - if (commandArray.length < 2) { - post("Incorrect usage of kill command. Usage: kill [scriptname] [arg1] [arg2]..."); return; - } - var results = commandArray[1].split(" "); - var scriptName = results[0]; - var args = []; - for (var i = 1; i < results.length; ++i) { - args.push(results[i]); - } - var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s); - if (runningScript == null) { - post("No such script is running. Nothing to kill"); - return; - } - Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["killWorkerScript"])(runningScript, s.ip); - post("Killing " + scriptName + ". May take up to a few minutes for the scripts to die..."); - break; - case "killall": - for (var i = s.runningScripts.length-1; i >= 0; --i) { - Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["killWorkerScript"])(s.runningScripts[i], s.ip); - } - post("Killing all running scripts. May take up to a few minutes for the scripts to die..."); - break; - case "ls": - Terminal.executeListCommand(commandArray); - break; - case "lscpu": - post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().cpuCores + " Core(s)"); - break; - case "mem": - if (commandArray.length != 2) { - post("Incorrect usage of mem command. usage: mem [scriptname] [-t] [number threads]"); return; - } - var scriptName = commandArray[1]; - var numThreads = 1; - if (scriptName.indexOf(" -t ") != -1) { - var results = scriptName.split(" "); - if (results.length != 3) { - post("Invalid use of run command. Usage: mem [script] [-t] [number threads]"); - return; - } - numThreads = Math.round(Number(results[2])); - if (isNaN(numThreads) || numThreads < 1) { - post("Invalid number of threads specified. Number of threads must be greater than 1"); - return; - } - scriptName = results[0]; - } - - var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - for (var i = 0; i < currServ.scripts.length; ++i) { - if (scriptName == currServ.scripts[i].filename) { - var scriptBaseRamUsage = currServ.scripts[i].ramUsage; - var ramUsage = scriptBaseRamUsage * numThreads * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, numThreads-1); - - post("This script requires " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(ramUsage, 2) + "GB of RAM to run for " + numThreads + " thread(s)"); - return; - } - } - post("ERR: No such script exists!"); - break; - case "nano": - if (commandArray.length != 2) { - post("Incorrect usage of nano command. Usage: nano [scriptname]"); return; - } - - var filename = commandArray[1]; - if (filename === ".fconf") { - var text = Object(_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["createFconf"])(); - _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, text); - return; - } else if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(filename)) { - for (var i = 0; i < s.scripts.length; i++) { - if (filename == s.scripts[i].filename) { - _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, s.scripts[i].code); - return; - } - } - } else if (filename.endsWith(".txt")) { - for (var i = 0; i < s.textFiles.length; ++i) { - if (filename === s.textFiles[i].fn) { - _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, s.textFiles[i].text); - return; - } - } - } else { - post("Error: Invalid file. Only scripts (.script), text files (.txt), or .fconf can be edited with nano"); return; - } - _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename); - break; - case "ps": - if (commandArray.length != 1) { - post("Incorrect usage of ps command. Usage: ps"); return; - } - for (var i = 0; i < s.runningScripts.length; i++) { - var rsObj = s.runningScripts[i]; - var res = rsObj.filename; - for (var j = 0; j < rsObj.args.length; ++j) { - res += (" " + rsObj.args[j].toString()); - } - post(res); - } - break; - case "rm": - if (commandArray.length != 2) { - post("Incorrect number of arguments. Usage: rm [program/script]"); return; - } - - //Check programs - var delTarget = commandArray[1]; - - if (delTarget.includes(".exe")) { - for (var i = 0; i < s.programs.length; ++i) { - if (s.programs[i] == delTarget) { - s.programs.splice(i, 1); - return; - } - } - } else if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(delTarget)) { - for (var i = 0; i < s.scripts.length; ++i) { - if (s.scripts[i].filename == delTarget) { - //Check that the script isnt currently running - for (var j = 0; j < s.runningScripts.length; ++j) { - if (s.runningScripts[j].filename == delTarget) { - post("Cannot delete a script that is currently running!"); - return; - } - } - s.scripts.splice(i, 1); - return; - } - } - } else if (delTarget.endsWith(".lit")) { - for (var i = 0; i < s.messages.length; ++i) { - var f = s.messages[i]; - if (!(f instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["isString"])(f) && f === delTarget) { - s.messages.splice(i, 1); - return; - } - } - } else if (delTarget.endsWith(".txt")) { - for (var i = 0; i < s.textFiles.length; ++i) { - if (s.textFiles[i].fn === delTarget) { - s.textFiles.splice(i, 1); - return; - } - } - } - post("Error: No such file exists"); - break; - case "run": - //Run a program or a script - if (commandArray.length != 2) { - post("Incorrect number of arguments. Usage: run [program/script] [-t] [num threads] [arg1] [arg2]..."); - } else { - var executableName = commandArray[1]; - - //Secret Music player! - if (executableName === "musicplayer") { - post('', false); - return; - } - - //Check if its a script or just a program/executable - if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(executableName) == -1) { - // Not a script - Terminal.runProgram(executableName); - } else { - //Script - Terminal.runScript(executableName); - } - } - break; - case "scan": - Terminal.executeScanCommand(commandArray); - break; - case "scan-analyze": - if (commandArray.length == 1) { - Terminal.executeScanAnalyzeCommand(1); - } else if (commandArray.length == 2) { - var all = false; - if (commandArray[1].endsWith("-a")) { - all = true; - commandArray[1] = commandArray[1].replace("-a", ""); - } - var depth; - if (commandArray[1].length === 0) { - depth = 1; - } else { - depth = Number(commandArray[1]); - } - if (isNaN(depth) || depth < 0) { - post("Incorrect usage of scan-analyze command. depth argument must be positive numeric"); - return; - } - if (depth > 3 && !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1) && - !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2)) { - post("You cannot scan-analyze with that high of a depth. Maximum depth is 3"); - return; - } else if (depth > 5 && !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2)) { - post("You cannot scan-analyze with that high of a depth. Maximum depth is 5"); - return; - } else if (depth > 10) { - post("You cannot scan-analyze with that high of a depth. Maximum depth is 10"); - return; - } - Terminal.executeScanAnalyzeCommand(depth, all); - } else { - post("Incorrect usage of scan-analyze command. usage: scan-analyze [depth]"); - } - break; - case "scp": - if (commandArray.length != 2) { - post("Incorrect usage of scp command. Usage: scp [file] [destination hostname/ip]"); - return; - } - var args = commandArray[1].split(" "); - if (args.length != 2) { - post("Incorrect usage of scp command. Usage: scp [file] [destination hostname/ip]"); - return; - } - var scriptname = args[0]; - if (!scriptname.endsWith(".lit") && !Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(scriptName) && - !scriptname.endsWith(".txt")){ - post("Error: scp only works for .script, .txt, and .lit files"); - return; - } - var destServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(args[1]); - if (destServer == null) { - post("Invalid destination. " + args[1] + " not found"); - return; - } - var ip = destServer.ip; - var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - - //Scp for lit files - if (scriptname.endsWith(".lit")) { - var found = false; - for (var i = 0; i < currServ.messages.length; ++i) { - if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && currServ.messages[i] == scriptname) { - found = true; - break; - } - } - - if (!found) {return post("Error: no such file exists!");} - - for (var i = 0; i < destServer.messages.length; ++i) { - if (destServer.messages[i] === scriptname) { - post(scriptname + " copied over to " + destServer.hostname); - return; //Already exists - } - } - destServer.messages.push(scriptname); - post(scriptname + " copied over to " + destServer.hostname); - return; - } - - //Scp for txt files - if (scriptname.endsWith(".txt")) { - var found = false, txtFile; - for (var i = 0; i < currServ.textFiles.length; ++i) { - if (currServ.textFiles[i].fn === scriptname) { - found = true; - txtFile = currServ.textFiles[i]; - break; - } - } - - if (!found) {return post("Error: no such file exists!");} - - for (var i = 0; i < destServer.textFiles.length; ++i) { - if (destServer.textFiles[i].fn === scriptname) { - //Overwrite - destServer.textFiles[i].text = txtFile.text; - post("WARNING: " + scriptname + " already exists on " + destServer.hostname + - "and will be overwriten"); - return post(scriptname + " copied over to " + destServer.hostname); - } - } - var newFile = new _TextFile_js__WEBPACK_IMPORTED_MODULE_18__["TextFile"](txtFile.fn, txtFile.text); - destServer.textFiles.push(newFile); - return post(scriptname + " copied over to " + destServer.hostname); - } - - //Get the current script - var sourceScript = null; - for (var i = 0; i < currServ.scripts.length; ++i) { - if (scriptname == currServ.scripts[i].filename) { - sourceScript = currServ.scripts[i]; - break; - } - } - if (sourceScript == null) { - post("ERROR: scp() failed. No such script exists"); - return; - } - - //Overwrite script if it exists - for (var i = 0; i < destServer.scripts.length; ++i) { - if (scriptname == destServer.scripts[i].filename) { - post("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and will be overwritten"); - var oldScript = destServer.scripts[i]; - oldScript.code = sourceScript.code; - oldScript.ramUsage = sourceScript.ramUsage; - post(scriptname + " overwriten on " + destServer.hostname); - return; - } - } - - var newScript = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["Script"](); - newScript.filename = scriptname; - newScript.code = sourceScript.code; - newScript.ramUsage = sourceScript.ramUsage; - newScript.destServer = ip; - destServer.scripts.push(newScript); - post(scriptname + " copied over to " + destServer.hostname); - break; - case "sudov": - if (commandArray.length != 1) { - post("Incorrect number of arguments. Usage: sudov"); return; - } - - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights) { - post("You have ROOT access to this machine"); - } else { - post("You do NOT have root access to this machine"); - } - break; - case "tail": - if (commandArray.length < 2) { - post("Incorrect number of arguments. Usage: tail [script] [arg1] [arg2]..."); - } else { - var results = commandArray[1].split(" "); - var scriptName = results[0]; - var args = []; - for (var i = 1; i < results.length; ++i) { - args.push(results[i]); - } - - //Can only tail script files - if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(scriptName) == false) { - post("Error: tail can only be called on .script files (filename must end with .script)"); return; - } - - //Check that the script exists on this machine - var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s); - if (runningScript == null) { - post("Error: No such script exists"); - return; - } - Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__["logBoxCreate"])(runningScript); - } - break; - case "theme": - //todo support theme saving - var args = commandArray[1] ? commandArray[1].split(" ") : []; - if (args.length != 1 && args.length != 3) { - post("Incorrect number of arguments."); - post("Usage: theme [default|muted|solarized] | #[background color hex] #[text color hex] #[highlight color hex]"); - } else if(args.length == 1){ - var themeName = args[0]; - if (themeName == "default"){ - document.body.style.setProperty('--my-highlight-color',"#ffffff"); - document.body.style.setProperty('--my-font-color',"#66ff33"); - document.body.style.setProperty('--my-background-color',"#000000"); - } else if (themeName == "muted"){ - document.body.style.setProperty('--my-highlight-color',"#ffffff"); - document.body.style.setProperty('--my-font-color',"#66ff33"); - document.body.style.setProperty('--my-background-color',"#252527"); - } else if (themeName == "solarized"){ - document.body.style.setProperty('--my-highlight-color',"#6c71c4"); - document.body.style.setProperty('--my-font-color',"#839496"); - document.body.style.setProperty('--my-background-color',"#002b36"); - } else { - return post("Theme not found"); - } - _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeHighlightColor = document.body.style.getPropertyValue("--my-highlight-color"); - _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeFontColor = document.body.style.getPropertyValue("--my-font-color"); - _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeBackgroundColor = document.body.style.getPropertyValue("--my-background-color"); - } else { - var inputBackgroundHex = args[0]; - var inputTextHex = args[1]; - var inputHighlightHex = args[2]; - if (/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputBackgroundHex) && - /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputTextHex) && - /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputHighlightHex)){ - document.body.style.setProperty('--my-highlight-color',inputHighlightHex); - document.body.style.setProperty('--my-font-color',inputTextHex); - document.body.style.setProperty('--my-background-color',inputBackgroundHex); - _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeHighlightColor = document.body.style.getPropertyValue("--my-highlight-color"); - _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeFontColor = document.body.style.getPropertyValue("--my-font-color"); - _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeBackgroundColor = document.body.style.getPropertyValue("--my-background-color"); - } else { - return post("Invalid Hex Input for theme"); - } - } - break; - case "top": - if(commandArray.length != 1) { - post("Incorrect usage of top command. Usage: top"); return; - } - - post("Script Threads RAM Usage"); - - var currRunningScripts = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().runningScripts; - //Iterate through scripts on current server - for(var i = 0; i < currRunningScripts.length; i++) { - var script = currRunningScripts[i]; - - //Calculate name padding - var numSpacesScript = 32 - script.filename.length; //26 -> width of name column - if (numSpacesScript < 0) {numSpacesScript = 0;} - var spacesScript = Array(numSpacesScript+1).join(" "); - - //Calculate thread padding - var numSpacesThread = 16 - (script.threads + "").length; //16 -> width of thread column - var spacesThread = Array(numSpacesThread+1).join(" "); - - //Calculate and transform RAM usage - ramUsage = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(script.scriptRef.ramUsage * script.threads, 2).toString() + "GB"; - - var entry = [script.filename, spacesScript, script.threads, spacesThread, ramUsage]; - post(entry.join("")); - } - break; - case "unalias": - if (commandArray.length != 2) { - post('Incorrect usage of unalias name. Usage: unalias "[alias]"'); - return; - } else if (!(commandArray[1].startsWith('"') && commandArray[1].endsWith('"'))) { - post('Incorrect usage of unalias name. Usage: unalias "[alias]"'); - } else { - var alias = commandArray[1].slice(1, -1); - if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["removeAlias"])(alias)) { - post("Removed alias " + alias); - } else { - post("No such alias exists"); - } - } - break; - default: - post("Command not found"); - } - }, - - connectToServer: function(ip) { - console.log("Connect to server called"); - var serv = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(ip); - if (serv == null) { - post("Invalid server. Connection failed."); - return; - } - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false; - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = serv.ip; - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true; - post("Connected to " + serv.hostname); - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname == "darkweb") { - Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__["checkIfConnectedToDarkweb"])(); //Posts a 'help' message if connecting to dark web - } - Terminal.resetTerminalInput(); - }, - - executeListCommand: function(commandArray) { - if (commandArray.length != 1 && commandArray.length != 2) { - post("Incorrect usage of ls command. Usage: ls [| grep pattern]"); return; - } - - //grep - var filter = null; - if (commandArray.length == 2) { - if (commandArray[1].startsWith("| grep ")) { - var pattern = commandArray[1].replace("| grep ", ""); - if (pattern != " ") { - filter = pattern; - } - } else { - post("Incorrect usage of ls command. Usage: ls [| grep pattern]"); return; - } - } - - //Display all programs and scripts - var allFiles = []; - - //Get all of the programs and scripts on the machine into one temporary array - var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - for (var i = 0; i < s.programs.length; i++) { - if (filter) { - if (s.programs[i].includes(filter)) { - allFiles.push(s.programs[i]); - } - } else { - allFiles.push(s.programs[i]); - } - } - for (var i = 0; i < s.scripts.length; i++) { - if (filter) { - if (s.scripts[i].filename.includes(filter)) { - allFiles.push(s.scripts[i].filename); - } - } else { - allFiles.push(s.scripts[i].filename); - } - - } - for (var i = 0; i < s.messages.length; i++) { - if (filter) { - if (s.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) { - if (s.messages[i].filename.includes(filter)) { - allFiles.push(s.messages[i].filename); - } - } else if (s.messages[i].includes(filter)) { - allFiles.push(s.messages[i]); - } - } else { - if (s.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) { - allFiles.push(s.messages[i].filename); - } else { - allFiles.push(s.messages[i]); - } - } - } - for (var i = 0; i < s.textFiles.length; ++i) { - if (filter) { - if (s.textFiles[i].fn.includes(filter)) { - allFiles.push(s.textFiles[i].fn); - } - } else { - allFiles.push(s.textFiles[i].fn); - } - } - - //Sort the files alphabetically then print each - allFiles.sort(); - - for (var i = 0; i < allFiles.length; i++) { - post(allFiles[i]); - } - }, - - executeScanCommand: function(commandArray) { - if (commandArray.length != 1) { - post("Incorrect usage of netstat/scan command. Usage: netstat/scan"); return; - } - //Displays available network connections using TCP - post("Hostname IP Root Access"); - for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().serversOnNetwork.length; i++) { - //Add hostname - var entry = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i); - if (entry == null) {continue;} - entry = entry.hostname; - - //Calculate padding and add IP - var numSpaces = 21 - entry.length; - var spaces = Array(numSpaces+1).join(" "); - entry += spaces; - entry += _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip; - - //Calculate padding and add root access info - var hasRoot; - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).hasAdminRights) { - hasRoot = 'Y'; - } else { - hasRoot = 'N'; - } - numSpaces = 21 - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip.length; - spaces = Array(numSpaces+1).join(" "); - entry += spaces; - entry += hasRoot; - post(entry); - } - }, - - executeScanAnalyzeCommand: function(depth=1, all=false) { - //We'll use the AllServersMap as a visited() array - //TODO Using array as stack for now, can make more efficient - post("~~~~~~~~~~ Beginning scan-analyze ~~~~~~~~~~"); - post(" "); - var visited = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["AllServersMap"](); - - var stack = []; - var depthQueue = [0]; - var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - stack.push(currServ); - while(stack.length != 0) { - var s = stack.pop(); - var d = depthQueue.pop(); - if (!all && s.purchasedByPlayer && s.hostname != "home") { - continue; //Purchased server - } else if (visited[s.ip] || d > depth) { - continue; //Already visited or out-of-depth - } else { - visited[s.ip] = 1; - } - for (var i = s.serversOnNetwork.length-1; i >= 0; --i) { - stack.push(s.getServerOnNetwork(i)); - depthQueue.push(d+1); - } - if (d == 0) {continue;} //Don't print current server - var titleDashes = Array((d-1) * 4 + 1).join("-"); - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].AutoLink)) { - post("" + titleDashes + "> " + s.hostname + "", false); - } else { - post("" + titleDashes + ">" + s.hostname + ""); - } - - var dashes = titleDashes + "--"; - //var dashes = Array(d * 2 + 1).join("-"); - var c = "NO"; - if (s.hasAdminRights) {c = "YES";} - post(dashes + "Root Access: " + c + ", Required hacking skill: " + s.requiredHackingSkill); - post(dashes + "Number of open ports required to NUKE: " + s.numOpenPortsRequired); - post(dashes + "RAM: " + s.maxRam); - post(" "); - } - - var links = document.getElementsByClassName("scan-analyze-link"); - for (var i = 0; i < links.length; ++i) { - (function() { - var hostname = links[i].innerHTML.toString(); - links[i].onclick = function() { - if (Terminal.analyzeFlag || Terminal.hackFlag) {return;} - Terminal.connectToServer(hostname); - } - }());//Immediate invocation - } - - }, - - executeFreeCommand: function(commandArray) { - if (commandArray.length != 1) { - post("Incorrect usage of free command. Usage: free"); return; - } - post("Total: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().maxRam, 2) + " GB"); - post("Used: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ramUsed, 2) + " GB"); - post("Available: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().maxRam - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ramUsed, 2) + " GB"); - }, - - //First called when the "run [program]" command is called. Checks to see if you - //have the executable and, if you do, calls the executeProgram() function - runProgram: function(programName) { - //Check if you have the program on your computer. If you do, execute it, otherwise - //display an error message - var splitArgs = programName.split(" "); - var name = " "; - if (splitArgs.length > 1) { - name = splitArgs[0]; - } else { - name = programName; - } - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(name)) { - Terminal.executeProgram(programName); - return; - } - post("ERROR: No such executable on home computer (Only programs that exist on your home computer can be run)"); - }, - - //Contains the implementations of all possible programs - executeProgram: function(programName) { - var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - var splitArgs = programName.split(" "); - if (splitArgs.length > 1) { - programName = splitArgs[0]; - } - switch (programName) { - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].NukeProgram: - if (s.hasAdminRights) { - post("You already have root access to this computer. There is no reason to run NUKE.exe"); - } else { - if (s.openPortCount >= _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().numOpenPortsRequired) { - s.hasAdminRights = true; - post("NUKE successful! Gained root access to " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname); - //TODO Make this take time rather than be instant - } else { - post("NUKE unsuccessful. Not enough ports have been opened"); - } - } - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BruteSSHProgram: - if (s.sshPortOpen) { - post("SSH Port (22) is already open!"); - } else { - s.sshPortOpen = true; - post("Opened SSH Port(22)!") - ++s.openPortCount; - } - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].FTPCrackProgram: - if (s.ftpPortOpen) { - post("FTP Port (21) is already open!"); - } else { - s.ftpPortOpen = true; - post("Opened FTP Port (21)!"); - ++s.openPortCount; - } - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].RelaySMTPProgram: - if (s.smtpPortOpen) { - post("SMTP Port (25) is already open!"); - } else { - s.smtpPortOpen = true; - post("Opened SMTP Port (25)!"); - ++s.openPortCount; - } - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].HTTPWormProgram: - if (s.httpPortOpen) { - post("HTTP Port (80) is already open!"); - } else { - s.httpPortOpen = true; - post("Opened HTTP Port (80)!"); - ++s.openPortCount; - } - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].SQLInjectProgram: - if (s.sqlPortOpen) { - post("SQL Port (1433) is already open!"); - } else { - s.sqlPortOpen = true; - post("Opened SQL Port (1433)!"); - ++s.openPortCount; - } - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].ServerProfiler: - if (splitArgs.length != 2) { - post("Must pass a server hostname or IP as an argument for ServerProfiler.exe"); - return; - } - var serv = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(splitArgs[1]); - if (serv == null) { - post("Invalid server IP/hostname"); - return; - } - post(serv.hostname + ":"); - post("Server base security level: " + serv.baseDifficulty); - post("Server current security level: " + serv.hackDifficulty); - post("Server growth rate: " + serv.serverGrowth); - post("Netscript hack() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateHackingTime"])(serv), 1) + "s"); - post("Netscript grow() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateGrowTime"])(serv)/1000, 1) + "s"); - post("Netscript weaken() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateWeakenTime"])(serv)/1000, 1) + "s"); - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].AutoLink: - post("This executable cannot be run."); - post("AutoLink.exe lets you automatically connect to other servers when using 'scan-analyze'."); - post("When using scan-analyze, click on a server's hostname to connect to it."); - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1: - post("This executable cannot be run."); - post("DeepscanV1.exe lets you run 'scan-analyze' with a depth up to 5."); - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2: - post("This executable cannot be run."); - post("DeepscanV2.exe lets you run 'scan-analyze' with a depth up to 10."); - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].Flight: - post("Augmentations: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].augmentations.length + " / 30"); - post("Money: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].money.toNumber(), 2) + " / $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(100000000000, 2)); - post("One path below must be fulfilled..."); - post("----------HACKING PATH----------"); - post("Hacking skill: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hacking_skill + " / 2500"); - post("----------COMBAT PATH----------"); - post("Strength: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].strength + " / 1500"); - post("Defense: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].defense + " / 1500"); - post("Dexterity: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].dexterity + " / 1500"); - post("Agility: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].agility + " / 1500"); - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BitFlume: - var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxGetYesButton"])(), - noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxGetNoButton"])(); - yesBtn.innerHTML = "Travel to BitNode Nexus"; - noBtn.innerHTML = "Cancel"; - yesBtn.addEventListener("click", function() { - Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_13__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN, true); - return Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxClose"])(); - }); - noBtn.addEventListener("click", function() { - return Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxClose"])(); - }); - Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxCreate"])("WARNING: USING THIS PROGRAM WILL CAUSE YOU TO LOSE ALL OF YOUR PROGRESS ON THE CURRENT BITNODE.

" + - "Do you want to travel to the BitNode Nexus? This allows you to reset the current BitNode " + - "and select a new one."); - - break; - default: - post("Invalid executable. Cannot be run"); - return; - } - }, - - runScript: function(scriptName) { - var server = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - - var numThreads = 1; - var args = []; - var results = scriptName.split(" "); - if (results.length <= 0) { - post("This is a bug. Please contact developer"); - } - scriptName = results[0]; - if (results.length > 1) { - if (results.length >= 3 && results[1] == "-t") { - numThreads = Math.round(Number(results[2])); - if (isNaN(numThreads) || numThreads < 1) { - post("Invalid number of threads specified. Number of threads must be greater than 0"); - return; - } - for (var i = 3; i < results.length; ++i) { - var arg = results[i]; - - //Forced string - if ((arg.startsWith("'") && arg.endsWith("'")) || - (arg.startsWith('"') && arg.endsWith('"'))) { - args.push(arg.slice(1, -1)); - continue; - } - //Number - var tempNum = Number(arg); - if (!isNaN(tempNum)) { - args.push(tempNum); - continue; - } - //Otherwise string - args.push(arg); - } - } else { - for (var i = 1; i < results.length; ++i) { - var arg = results[i]; - - //Forced string - if ((arg.startsWith("'") && arg.endsWith("'")) || - (arg.startsWith('"') && arg.endsWith('"'))) { - args.push(arg.slice(1, -1)); - continue; - } - //Number - var tempNum = Number(arg); - if (!isNaN(tempNum)) { - args.push(tempNum); - continue; - } - //Otherwise string - args.push(arg); - } - } - } - - - //Check if this script is already running - if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, server) != null) { - post("ERROR: This script is already running. Cannot run multiple instances"); - return; - } - - //Check if the script exists and if it does run it - for (var i = 0; i < server.scripts.length; i++) { - if (server.scripts[i].filename == scriptName) { - //Check for admin rights and that there is enough RAM availble to run - var script = server.scripts[i]; - var ramUsage = script.ramUsage * numThreads * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, numThreads-1); - var ramAvailable = server.maxRam - server.ramUsed; - - if (server.hasAdminRights == false) { - post("Need root access to run script"); - return; - } else if (ramUsage > ramAvailable){ - post("This machine does not have enough RAM to run this script with " + - numThreads + " threads. Script requires " + ramUsage + "GB of RAM"); - return; - } else { - //Able to run script - post("Running script with " + numThreads + " thread(s) and args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["printArray"])(args) + "."); - post("May take a few seconds to start up the process..."); - var runningScriptObj = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["RunningScript"](script, args); - runningScriptObj.threads = numThreads; - server.runningScripts.push(runningScriptObj); - - Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["addWorkerScript"])(runningScriptObj, server); - return; - } - } - } - - post("ERROR: No such script"); - } -}; - - - -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 38))) /***/ }), -/* 23 */ +/* 24 */ /*!**************************!*\ !*** ./utils/decimal.js ***! \**************************/ @@ -24913,126 +25081,6 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/*! decimal.js v7.2.3 https://github.com/MikeM })(this); -/***/ }), -/* 24 */ -/*!*************************!*\ - !*** ./src/Settings.js ***! - \*************************/ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Settings", function() { return Settings; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSettings", function() { return initSettings; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setSettingsLabels", function() { return setSettingsLabels; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadSettings", function() { return loadSettings; }); -/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.js */ 5); - - -/* 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", -} - -function loadSettings(saveString) { - Settings = JSON.parse(saveString); -} - -function initSettings() { - Settings.CodeInstructionRunTime = 50; - Settings.MaxLogCapacity = 50; - Settings.MaxPortCapacity = 50; - Settings.SuppressMessages = false; - Settings.SuppressFactionInvites = false; - Settings.AutosaveInterval = 60; -} - -function setSettingsLabels() { - var nsExecTime = document.getElementById("settingsNSExecTimeRangeValLabel"); - var nsLogLimit = document.getElementById("settingsNSLogRangeValLabel"); - var nsPortLimit = document.getElementById("settingsNSPortRangeValLabel"); - var suppressMsgs = document.getElementById("settingsSuppressMessages"); - var suppressFactionInv = document.getElementById("settingsSuppressFactionInvites") - var autosaveInterval = document.getElementById("settingsAutosaveIntervalValLabel"); - - //Initialize values on labels - nsExecTime.innerHTML = Settings.CodeInstructionRunTime + "ms"; - nsLogLimit.innerHTML = Settings.MaxLogCapacity; - nsPortLimit.innerHTML = Settings.MaxPortCapacity; - suppressMsgs.checked = Settings.SuppressMessages; - suppressFactionInv.checked = Settings.SuppressFactionInvites; - autosaveInterval.innerHTML = Settings.AutosaveInterval; - - //Set handlers for when input changes - var nsExecTimeInput = document.getElementById("settingsNSExecTimeRangeVal"); - var nsLogRangeInput = document.getElementById("settingsNSLogRangeVal"); - var nsPortRangeInput = document.getElementById("settingsNSPortRangeVal"); - var nsAutosaveIntervalInput = document.getElementById("settingsAutosaveIntervalVal"); - nsExecTimeInput.value = Settings.CodeInstructionRunTime; - nsLogRangeInput.value = Settings.MaxLogCapacity; - nsPortRangeInput.value = Settings.MaxPortCapacity; - nsAutosaveIntervalInput.value = Settings.AutosaveInterval; - - nsExecTimeInput.oninput = function() { - nsExecTime.innerHTML = this.value + 'ms'; - Settings.CodeInstructionRunTime = this.value; - }; - - nsLogRangeInput.oninput = function() { - nsLogLimit.innerHTML = this.value; - Settings.MaxLogCapacity = this.value; - }; - - nsPortRangeInput.oninput = function() { - nsPortLimit.innerHTML = this.value; - Settings.MaxPortCapacity = this.value; - }; - - nsAutosaveIntervalInput.oninput = function() { - autosaveInterval.innerHTML = this.value; - Settings.AutosaveInterval = Number(this.value); - if (Number(this.value) === 0) { - _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = Infinity; - } else { - _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = Number(this.value) * 5; - } - }; - - document.getElementById("settingsSuppressMessages").onclick = function() { - Settings.SuppressMessages = this.checked; - }; - - document.getElementById("settingsSuppressFactionInvites").onclick = function() { - Settings.SuppressFactionInvites = this.checked; - }; - - //Theme - if (Settings.ThemeHighlightColor == null || Settings.ThemeFontColor == null || Settings.ThemeBackgroundColor == null) { - console.log("ERROR: Cannot find Theme Settings"); - return; - } - if (/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeHighlightColor) && - /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeFontColor) && - /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeBackgroundColor)) { - document.body.style.setProperty('--my-highlight-color', Settings.ThemeHighlightColor); - document.body.style.setProperty('--my-font-color', Settings.ThemeFontColor); - document.body.style.setProperty('--my-background-color', Settings.ThemeBackgroundColor); - } -} - - - - /***/ }), /* 25 */ /*!************************************!*\ @@ -25736,17 +25784,17 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isScriptFilename", function() { return isScriptFilename; }); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5); -/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Fconf.js */ 35); +/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Fconf.js */ 32); /* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 25); /* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 7); /* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 29); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Settings.js */ 24); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Terminal.js */ 22); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Settings.js */ 23); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Terminal.js */ 18); /* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./TextFile.js */ 41); -/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/acorn.js */ 34); +/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/acorn.js */ 35); /* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8); @@ -25809,7 +25857,7 @@ function scriptEditorInit() { } var closeButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_15__["createElement"])("a", { class:"a-link-button", display:"inline-block", - innerText:"Save & Close (Ctrl + b)", + innerText:"Save & Close (Ctrl/Cmd + b)", clickListener:()=>{ saveAndCloseScriptEditor(); return false; @@ -25983,6 +26031,7 @@ function updateScriptEditorContent() { //Define key commands in script editor (ctrl o to save + close, etc.) $(document).keydown(function(e) { + if (_Settings_js__WEBPACK_IMPORTED_MODULE_9__["Settings"].DisableHotkeys === true) {return;} if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.ScriptEditor) { //Ctrl + b if (e.keyCode == 66 && (e.ctrlKey || e.metaKey)) { @@ -26167,7 +26216,7 @@ function parseOnlyRamCalculate(server, code, workerScript) { // Finally, walk the reference map and generate a ram cost. The initial set of keys to scan // are those that start with __SPECIAL_INITIAL_MODULE__. - let ram = 1.4; + let ram = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptBaseRamCost; const unresolvedRefs = Object.keys(dependencyMap).filter(s => s.startsWith(initialModule)); const resolvedRefs = new Set(); while (unresolvedRefs.length > 0) { @@ -26344,7 +26393,7 @@ function calculateRamUsage(codeCopy) { } //Search through AST, scanning for any 'Identifier' nodes for functions, or While/For/If nodes - var queue = [], ramUsage = 1.4; + var queue = [], ramUsage = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptBaseRamCost; var whileUsed = false, forUsed = false, ifUsed = false; queue.push(ast); while (queue.length != 0) { @@ -26608,7 +26657,11 @@ RunningScript.prototype.log = function(txt) { //to improve performance this.logs.shift(); } - this.logs.push(txt); + let logEntry = txt; + if (_Fconf_js__WEBPACK_IMPORTED_MODULE_2__["FconfSettings"].ENABLE_TIMESTAMPS) { + logEntry = "[" + _Terminal_js__WEBPACK_IMPORTED_MODULE_10__["Terminal"].getTimestamp() + "] " + logEntry; + } + this.logs.push(logEntry); this.logUpd = true; } @@ -26864,13 +26917,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadMessages", function() { return loadMessages; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initMessages", function() { return initMessages; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Message", function() { return Message; }); -/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 18); +/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 19); /* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CreateProgram.js */ 14); -/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Missions.js */ 32); +/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Missions.js */ 33); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./RedPill.js */ 44); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Settings.js */ 24); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Settings.js */ 23); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8); @@ -27085,32 +27138,32 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasAISF", function() { return hasAISF; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasBladeburnerSF", function() { return hasBladeburnerSF; }); /* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ActiveScriptsUI.js */ 43); -/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Augmentations.js */ 18); +/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Augmentations.js */ 19); /* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./BitNode.js */ 15); -/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Crimes.js */ 19); +/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Crimes.js */ 20); /* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Company.js */ 9); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Constants.js */ 3); /* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./CreateProgram.js */ 14); -/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./DarkWeb.js */ 33); +/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./DarkWeb.js */ 34); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./engine.js */ 5); /* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Faction.js */ 11); /* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./HacknetNode.js */ 39); /* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Location.js */ 4); /* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Message.js */ 28); -/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Missions.js */ 32); +/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Missions.js */ 33); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Script.js */ 26); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Settings.js */ 24); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Settings.js */ 23); /* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); -/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./StockMarket.js */ 21); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Terminal.js */ 22); +/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./StockMarket.js */ 22); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Terminal.js */ 18); /* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./TextFile.js */ 41); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); /* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 7); /* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 69); /* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./NetscriptPort.js */ 45); -/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../utils/decimal.js */ 23); +/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../utils/decimal.js */ 24); /* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_26___default = /*#__PURE__*/__webpack_require__.n(_utils_decimal_js__WEBPACK_IMPORTED_MODULE_26__); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); @@ -27163,6 +27216,55 @@ var hasCorporationSF=false, //Source-File 3 hasBn11SF=false; //Source-File 11 +var possibleLogs = { + ALL: true, + scan: true, + hack: true, + sleep: true, + disableLog: true, + enableLog: true, + grow: true, + weaken: true, + nuke: true, + brutessh: true, + ftpcrack: true, + relaysmtp: true, + httpworm: true, + sqlinject: true, + spawn: true, + kill: true, + killall: true, + scp: true, + getHackingLevel: true, + getServerMoneyAvailable: true, + getServerSecurityLevel: true, + getServerBaseSecurityLevel: true, + getServerMinSecurityLevel: true, + getServerRequiredHackingLevel: true, + getServerMaxMoney: true, + getServerGrowth: true, + getServerNumPortsRequired: true, + getServerRam: true, + buyStock: true, + sellStock: true, + purchaseServer: true, + deleteServer: true, + universityCourse: true, + gymWorkout: true, + travelToCity: true, + purchaseTor: true, + purchaseProgram: true, + stopAction: true, + upgradeHomeRam: true, + workForCompany: true, + applyToCompany: true, + joinFaction: true, + workForFaction: true, + createProgram: true, + commitCrime: true, + shortStock: true, + sellShort: true, +} var singularitySFLvl=1, wallStreetSFLvl=1; @@ -27443,13 +27545,23 @@ function NetscriptFunctions(workerScript) { }, disableLog : function(fn) { if (workerScript.checkingRam) {return 0;} + if(possibleLogs[fn]===undefined) { + throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument to disableLog: "+fn); + } workerScript.disableLogs[fn] = true; - workerScript.scriptRef.log("Disabled logging for " + fn); + if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.disableLog == null) { + workerScript.scriptRef.log("Disabled logging for " + fn); + } }, enableLog : function(fn) { if (workerScript.checkingRam) {return 0;} + if(possibleLogs[fn]===undefined) { + throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument to enableLog: "+fn); + } delete workerScript.disableLogs[fn]; - workerScript.scriptRef.log("Enabled logging for " + fn); + if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.enableLog == null) { + workerScript.scriptRef.log("Enabled logging for " + fn); + } }, nuke : function(ip){ if (workerScript.checkingRam) { @@ -28125,6 +28237,23 @@ function NetscriptFunctions(workerScript) { growth: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_grow_mult, }; }, + getHacknetMultipliers : function() { + if (workerScript.checkingRam) { + if (workerScript.loadedFns.getHacknetMultipliers) { + return 0; + } else { + workerScript.loadedFns.getHacknetMultipliers = true; + return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetMultipliersRamCost; + } + } + return { + production: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacknet_node_money_mult, + purchaseCost: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacknet_node_purchase_cost_mult, + ramCost: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacknet_node_ram_cost_mult, + coreCost: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacknet_node_core_cost_mult, + levelCost: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacknet_node_level_cost_mult, + }; + }, getBitNodeMultipliers: function() { if (workerScript.checkingRam) { if (workerScript.loadedFns.getBitNodeMultipliers) { @@ -28722,7 +28851,15 @@ function NetscriptFunctions(workerScript) { workerScript.scriptRef.log("Error: Not enough money to purchase server. Need $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(cost, 2)); return ""; } - var newServ = new _Server_js__WEBPACK_IMPORTED_MODULE_16__["Server"](Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_29__["createRandomIp"])(), hostnameStr, "", false, true, true, ram); + var newServ = new _Server_js__WEBPACK_IMPORTED_MODULE_16__["Server"]({ + ip: Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_29__["createRandomIp"])(), + hostname: hostnameStr, + organizationName: "", + isConnectedTo: false, + adminRights: true, + purchasedByPlayer: true, + maxRam: ram, + }); Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["AddToAllServers"])(newServ); _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].purchasedServers.push(newServ.ip); @@ -29083,7 +29220,11 @@ function NetscriptFunctions(workerScript) { } return suc; }, - getScriptRam : function (scriptname, ip) { + getScriptName : function() { + if (workerScript.checkingRam) {return 0;} + return workerScript.name; + }, + getScriptRam : function (scriptname, ip=workerScript.serverIp) { if (workerScript.checkingRam) { if (workerScript.loadedFns.getScriptRam) { return 0; @@ -29521,7 +29662,10 @@ function NetscriptFunctions(workerScript) { } _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].TorRouterCost); - var darkweb = new _Server_js__WEBPACK_IMPORTED_MODULE_16__["Server"](Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_29__["createRandomIp"])(), "darkweb", "", false, false, false, 1); + var darkweb = new _Server_js__WEBPACK_IMPORTED_MODULE_16__["Server"]({ + ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_29__["createRandomIp"])(), hostname:"darkweb", organizationName:"", + isConnectedTo:false, adminRights:false, purchasedByPlayer:false, maxRam:1 + }); Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["AddToAllServers"])(darkweb); _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_18__["SpecialServerIps"].addIp("Darkweb Server", darkweb.ip); @@ -30388,41 +30532,42 @@ function NetscriptFunctions(workerScript) { } crime = crime.toLowerCase(); + let enableCommitCrimeLog = workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null if (crime.includes("shoplift")) { - workerScript.scriptRef.log("Attempting to shoplift..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to shoplift...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitShopliftCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("rob") && crime.includes("store")) { - workerScript.scriptRef.log("Attempting to rob a store..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to rob a store...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitRobStoreCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("mug")) { - workerScript.scriptRef.log("Attempting to mug someone..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to mug someone...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitMugCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("larceny")) { - workerScript.scriptRef.log("Attempting to commit larceny..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit larceny...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitLarcenyCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("drugs")) { - workerScript.scriptRef.log("Attempting to deal drugs..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to deal drugs...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitDealDrugsCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("bond") && crime.includes("forge")) { - workerScript.scriptRef.log("Attempting to forge corporate bonds..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to forge corporate bonds...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitBondForgeryCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("traffick") && crime.includes("arms")) { - workerScript.scriptRef.log("Attempting to traffick illegal arms..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to traffick illegal arms...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitTraffickArmsCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("homicide")) { - workerScript.scriptRef.log("Attempting to commit homicide..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit homicide...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitHomicideCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("grand") && crime.includes("auto")) { - workerScript.scriptRef.log("Attempting to commit grand theft auto..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit grand theft auto...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitGrandTheftAutoCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("kidnap")) { - workerScript.scriptRef.log("Attempting to kidnap and ransom a high-profile target..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to kidnap and ransom a high-profile target...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitKidnapCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("assassinate")) { - workerScript.scriptRef.log("Attempting to assassinate a high-profile target..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to assassinate a high-profile target...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitAssassinationCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}) } else if (crime.includes("heist")) { - workerScript.scriptRef.log("Attempting to pull off a heist..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to pull off a heist...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitHeistCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else { throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid crime passed into commitCrime(): " + crime); @@ -30678,7 +30823,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "substituteAliases", function() { return substituteAliases; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadAliases", function() { return loadAliases; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadGlobalAliases", function() { return loadGlobalAliases; }); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Terminal.js */ 22); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Terminal.js */ 18); let Aliases = {}; @@ -31282,6 +31427,150 @@ exports.prepareContent = function(name, inputData, isBinary, isOptimizedBinarySt /***/ }), /* 32 */ +/*!**********************!*\ + !*** ./src/Fconf.js ***! + \**********************/ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FconfSettings", function() { return FconfSettings; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFconf", function() { return createFconf; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseFconfSettings", function() { return parseFconfSettings; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadFconf", function() { return loadFconf; }); +/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/acorn.js */ 35); +/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__); + + +var FconfSettings = { + ENABLE_BASH_HOTKEYS: false, + ENABLE_TIMESTAMPS: false, +} + +var FconfComments = { + ENABLE_BASH_HOTKEYS: "Improved Bash emulation mode. Setting this to 1 enables several\n" + + "new Terminal shortcuts and features that more closely resemble\n" + + "a real Bash-style shell. Note that when this mode is enabled,\n" + + "the default browser shortcuts are overriden by the new Bash\n" + + "shortcuts.\n\n" + + "To see a full list of the Terminal shortcuts that this enables, see:\n" + + "http://bitburner.readthedocs.io/en/latest/shortcuts.html", + ENABLE_TIMESTAMPS: "Terminal commands and log entries will be timestamped. The timestamp\n" + + "will have the format: M/D h:m", +} + +//Parse Fconf settings from the config text +//Throws an exception if parsing fails +function parseFconfSettings(config) { + var ast = Object(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["parse"])(config, {sourceType:"module"}); + var queue = []; + queue.push(ast); + while (queue.length != 0) { + var exp = queue.shift(); + switch (exp.type) { + case "BlockStatement": + case "Program": + for (var i = 0; i < exp.body.length; ++i) { + if (exp.body[i] instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["Node"]) { + queue.push(exp.body[i]); + } + } + break; + case "AssignmentExpression": + var setting, value; + if (exp.left != null && exp.left.name != null) { + setting = exp.left.name; + } else { + break; + } + if (exp.right != null && exp.right.raw != null) { + value = exp.right.raw; + } else { + break; + } + parseFconfSetting(setting, value); + break; + default: + break; + } + + for (var prop in exp) { + if (exp.hasOwnProperty(prop)) { + if (exp[prop] instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["Node"]) { + queue.push(exp[prop]); + } + } + } + } +} + +function parseFconfSetting(setting, value) { + setting = String(setting); + value = String(value); + if (setting == null || value == null || FconfSettings[setting] == null) { + console.log("WARNING: Invalid .fconf setting: " + setting); + return; + } + + //Needed to convert entered value to boolean/strings accordingly + switch(setting) { + case "ENABLE_BASH_HOTKEYS": + case "ENABLE_TIMESTAMPS": + var value = value.toLowerCase(); + if (value === "1" || value === "true" || value === "y") { + value = true; + } else { + value = false; + } + FconfSettings[setting] = value; + break; + default: + break; + } + return; +} + +//Create the .fconf file text from the settings +function createFconf() { + var res = ""; + for (var setting in FconfSettings) { + if (FconfSettings.hasOwnProperty(setting)) { + //Setting comments (description) + var comment = FconfComments[setting]; + if (comment == null) {continue;} + var comment = comment.split("\n"); + for (var i = 0; i < comment.length; ++i) { + res += ("//" + comment[i] + "\n"); + } + + var value = 0; + if (FconfSettings[setting] === true) { + value = "1"; + } else if (FconfSettings[setting] === false) { + value = "0"; + } else { + value = String(FconfSettings[setting]); + } + res += (setting + "=" + value + "\n\n"); + } + } + return res; +} + +function loadFconf(saveString) { + let tempFconfSettings = JSON.parse(saveString); + for (var setting in tempFconfSettings) { + if (tempFconfSettings.hasOwnProperty(setting)) { + FconfSettings[setting] = tempFconfSettings[setting]; + } + } +} + + + + +/***/ }), +/* 33 */ /*!*************************!*\ !*** ./src/Missions.js ***! \*************************/ @@ -32840,7 +33129,7 @@ HackingMission.prototype.finishMission = function(win) { /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 38))) /***/ }), -/* 33 */ +/* 34 */ /*!************************!*\ !*** ./src/DarkWeb.js ***! \************************/ @@ -32857,7 +33146,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./CreateProgram.js */ 14); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Terminal.js */ 22); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Terminal.js */ 18); /* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/IPAddress.js */ 16); /* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2); @@ -33059,7 +33348,7 @@ let DarkWebItems = { /***/ }), -/* 34 */ +/* 35 */ /*!************************!*\ !*** ./utils/acorn.js ***! \************************/ @@ -36696,141 +36985,6 @@ Object.defineProperty(exports, '__esModule', { value: true }); }))); -/***/ }), -/* 35 */ -/*!**********************!*\ - !*** ./src/Fconf.js ***! - \**********************/ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FconfSettings", function() { return FconfSettings; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFconf", function() { return createFconf; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseFconfSettings", function() { return parseFconfSettings; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadFconf", function() { return loadFconf; }); -/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/acorn.js */ 34); -/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__); - - -var FconfSettings = { - ENABLE_BASH_HOTKEYS: false -} - -var FconfComments = { - ENABLE_BASH_HOTKEYS: "Improved Bash emulation mode. Setting this to 1 enables several\n" + - "new Terminal shortcuts and features that more closely resemble\n" + - "a real Bash-style shell. Note that when this mode is enabled,\n" + - "the default browser shortcuts are overriden by the new Bash\n" + - "shortcuts.\n\n" + - "To see a full list of the Terminal shortcuts that this enables, see:\n" + - "http://bitburner.readthedocs.io/en/latest/shortcuts.html", -} - -//Parse Fconf settings from the config text -//Throws an exception if parsing fails -function parseFconfSettings(config) { - var ast = Object(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["parse"])(config, {sourceType:"module"}); - var queue = []; - queue.push(ast); - while (queue.length != 0) { - var exp = queue.shift(); - switch (exp.type) { - case "BlockStatement": - case "Program": - for (var i = 0; i < exp.body.length; ++i) { - if (exp.body[i] instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["Node"]) { - queue.push(exp.body[i]); - } - } - break; - case "AssignmentExpression": - var setting, value; - if (exp.left != null && exp.left.name != null) { - setting = exp.left.name; - } else { - break; - } - if (exp.right != null && exp.right.raw != null) { - value = exp.right.raw; - } else { - break; - } - parseFconfSetting(setting, value); - break; - default: - break; - } - - for (var prop in exp) { - if (exp.hasOwnProperty(prop)) { - if (exp[prop] instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["Node"]) { - queue.push(exp[prop]); - } - } - } - } -} - -function parseFconfSetting(setting, value) { - setting = String(setting); - value = String(value); - if (setting == null || value == null || FconfSettings[setting] == null) { - console.log("WARNING: Invalid .fconf setting: " + setting); - return; - } - - //Needed to convert entered value to boolean/strings accordingly - switch(setting) { - case "ENABLE_BASH_HOTKEYS": - var value = value.toLowerCase(); - if (value === "1" || value === "true" || value === "y") { - value = true; - } else { - value = false; - } - FconfSettings[setting] = value; - break; - default: - break; - } - return; -} - -//Create the .fconf file text from the settings -function createFconf() { - var res = ""; - for (var setting in FconfSettings) { - if (FconfSettings.hasOwnProperty(setting)) { - //Setting comments (description) - var comment = FconfComments[setting]; - if (comment == null) {continue;} - var comment = comment.split("\n"); - for (var i = 0; i < comment.length; ++i) { - res += ("//" + comment[i] + "\n"); - } - - var value = 0; - if (FconfSettings[setting] === true) { - value = "1"; - } else if (FconfSettings[setting] === false) { - value = "0"; - } else { - value = String(FconfSettings[setting]); - } - res += (setting + "=" + value + "\n"); - } - } - return res; -} - -function loadFconf(saveString) { - FconfSettings = JSON.parse(saveString); -} - - - - /***/ }), /* 36 */ /*!*********************!*\ @@ -38021,12 +38175,24 @@ function updateGangContent() { for (var gangname in AllGangs) { if (AllGangs.hasOwnProperty(gangname)) { var gangTerritoryInfo = AllGangs[gangname]; + let territory = gangTerritoryInfo.territory*100; + + //Fix some rounding issues graphically + let displayNumber; + if (territory <= 0) { + displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(0, 2); + } else if (territory >= 100) { + displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(100, 2); + } else { + displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(territory, 2); + } + if (gangname == _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName) { gangTerritoryInfoText.innerHTML += ("" + gangname + "
(Power: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(gangTerritoryInfo.power, 6) + "): " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(100*gangTerritoryInfo.territory, 2) + "%

"); + displayNumber + "%

"); } else { gangTerritoryInfoText.innerHTML += (gangname + "
(Power: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(gangTerritoryInfo.power, 6) + "): " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(100*gangTerritoryInfo.territory, 2) + "%

"); + displayNumber + "%

"); } } } @@ -38078,10 +38244,19 @@ function updateGangContent() { })); gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {})); - var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory; + //Fix some rounding issues graphically + var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory * 100; + let displayNumber; + if (territoryMult <= 0) { + displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(0, 2); + } else if (territoryMult >= 100) { + displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(100, 2); + } else { + displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(territoryMult, 2); + } gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", { //Territory multiplier display:"inline-block", - innerText:"Territory: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(territoryMult * 100, 3) + "%", + innerText:"Territory: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(displayNumber, 3) + "%", tooltip:"The percentage of total territory your Gang controls" })); gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {})); @@ -49494,7 +49669,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Literature.js */ 53); /* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Location.js */ 4); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Player.js */ 0); -/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/decimal.js */ 23); +/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/decimal.js */ 24); /* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_utils_decimal_js__WEBPACK_IMPORTED_MODULE_6__); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); @@ -54741,19 +54916,19 @@ function applySourceFile(srcFile) { "use strict"; __webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setActiveScriptsClickHandlers", function() { return setActiveScriptsClickHandlers; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addActiveScriptsItem", function() { return addActiveScriptsItem; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "deleteActiveScriptsItem", function() { return deleteActiveScriptsItem; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateActiveScriptsItems", function() { return updateActiveScriptsItems; }); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); -/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0); -/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); -/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); -/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/LogBox.js */ 51); -/* harmony import */ var _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/numeral.min.js */ 13); -/* harmony import */ var _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_6__); -/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2); +/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.js */ 5); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); +/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0); +/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Server.js */ 10); +/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); +/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); +/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/LogBox.js */ 51); +/* harmony import */ var _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/numeral.min.js */ 13); +/* harmony import */ var _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7__); +/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2); @@ -54764,272 +54939,274 @@ __webpack_require__.r(__webpack_exports__); -/* 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 = {}; +let ActiveScriptsTasks = []; //Sequentially schedule the creation/deletion of UI elements function createActiveScriptsServerPanel(server) { - var panelname = "active-scripts-server-panel-" + server.hostname; - var activeScriptsList = document.getElementById("active-scripts-list"); + ActiveScriptsTasks.push(function(server) { + let hostname = server.hostname; - //Div of entire Panel - var panelDiv = document.createElement("div"); - panelDiv.setAttribute("id", panelname); + var activeScriptsList = document.getElementById("active-scripts-list"); - //Panel Header - var panelHdr = document.createElement("button"); - panelHdr.setAttribute("class", "active-scripts-server-header") - panelHdr.setAttribute("id", panelname + "-hdr"); - panelHdr.innerHTML = server.hostname; + let res = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createAccordionElement"])({hdrText:hostname}); + let li = res[0]; + var hdr = res[1]; + let panel = res[2]; - //Panel content - var panelContentDiv = document.createElement("div"); - panelContentDiv.setAttribute("class", "active-scripts-server-panel"); - panelContentDiv.setAttribute("id", panelname + "-content"); + if (ActiveScriptsUI[hostname] != null) { + console.log("WARNING: Tried to create already-existing Active Scripts Server panel. This is most likely fine. It probably means many scripts just got started up on a new server. Aborting"); + return; + } - //List of scripts - var panelScriptList = document.createElement("ul"); - panelScriptList.setAttribute("id", panelname + "-script-list"); + var panelScriptList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("ul"); + panel.appendChild(panelScriptList); + activeScriptsList.appendChild(li); - panelContentDiv.appendChild(panelScriptList); - panelDiv.appendChild(panelHdr); - panelDiv.appendChild(panelContentDiv); - activeScriptsList.appendChild(panelDiv); + 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 + }; - setActiveScriptsClickHandlers() //Reset click handlers - - return panelDiv; + return li; + }.bind(null, server)); } //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); - return; - } + ActiveScriptsTasks.push(function(server) { + 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; + } + + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(ActiveScriptsUI[hostname].panel); + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(ActiveScriptsUI[hostname].header); + delete ActiveScriptsUI[hostname]; + }.bind(null, server)); } function addActiveScriptsItem(workerscript) { - //Get server panel - var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_2__["getServer"])(workerscript.serverIp); + var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["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 - 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); + ActiveScriptsTasks.push(function(workerscript, hostname) { + //Create the unique identifier (key) for this script + var itemNameArray = ["active", "scripts", hostname, workerscript.name]; + for (var i = 0; i < workerscript.args.length; ++i) { + itemNameArray.push(String(workerscript.args[i])); + } + var itemName = itemNameArray.join("-"); - var btn = document.createElement("button"); - btn.setAttribute("class", "active-scripts-script-header"); - btn.setAttribute("id", itemName + "-header"); - btn.innerHTML = workerscript.name; + let res = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["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); + //Handle the constant elements on the panel that don't change after creation + //Threads, args, kill/log button + panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("p", { + innerHTML: "Threads: " + workerscript.scriptRef.threads + "
" + + "Args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["printArray"])(workerscript.args) + })); + var panelText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("p", { + innerText:"Loading...", fontSize:"14px", + }); + panel.appendChild(panelText); + panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("br")); + panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("span", { + innerText:"Log", class:"active-scripts-button", margin:"4px", padding:"4px", + clickListener:()=>{ + Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_6__["logBoxCreate"])(workerscript.scriptRef); + return false; + } + })); + panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("span", { + innerText:"Kill Script", class:"active-scripts-button", margin:"4px", padding:"4px", + clickListener:()=>{ + Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["killWorkerScript"])(workerscript.scriptRef, workerscript.scriptRef.scriptRef.server); + Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Killing script, may take a few minutes to complete..."); + return false; + } + })); - createActiveScriptsText(workerscript, itemContentDiv); - - //Append element to list - var list = getActiveScriptsServerList(server); - list.appendChild(item); - - setActiveScriptsClickHandlers() //Reset click handlers + //Append element to list + ActiveScriptsUI[hostname]["panelList"].appendChild(li); + ActiveScriptsUI[hostname].scripts[itemName] = li; + ActiveScriptsUI[hostname].scriptHdrs[itemName] = hdr; + ActiveScriptsUI[hostname].scriptStats[itemName] = panelText; + }.bind(null, workerscript, hostname)); } function deleteActiveScriptsItem(workerscript) { - var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_2__["getServer"])(workerscript.serverIp); - if (server == null) { - console.log("ERROR: Invalid server IP for workerscript."); - 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); - if (li == null) { - console.log("could not find Active scripts li element for: " + workerscript.name); - return; - } - li.parentNode.removeChild(li); - deleteActiveScriptsServerPanel(server); + ActiveScriptsTasks.push(function(workerscript) { + var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp); + if (server == null) { + throw new Error("ERROR: Invalid server IP for workerscript. This most likely occurred because " + + "you tried to delete a large number of scripts and also purchased servers at the " + + "same time. It's not a big deal, just save and refresh the game."); + 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("-"); + + let li = ActiveScriptsUI[hostname].scripts[itemName]; + if (li == null) { + console.log("ERROR: Cannot find Active Script UI element for workerscript: "); + console.log(workerscript); + return; + } + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["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); + } + }.bind(null, workerscript)); } //Update the ActiveScriptsItems array function updateActiveScriptsItems() { + //Run tasks that need to be done sequentially (adding items, creating/deleting server panels) + //We'll limit this to 50 at a time in case someone decides to start a bunch of scripts all at once... + let numTasks = Math.min(100, ActiveScriptsTasks.length); + for (let i = 0; i < numTasks; ++i) { + let task = ActiveScriptsTasks.shift(); + try { + task(); + } catch(e) { + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["exceptionAlert"])(e); + console.log(task); + } + } + + if (_engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Page.ActiveScripts) {return;} var total = 0; - for (var i = 0; i < _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__["workerScripts"].length; ++i) { - total += updateActiveScriptsItemContent(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__["workerScripts"][i]); + for (var i = 0; i < _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["workerScripts"].length; ++i) { + try { + total += updateActiveScriptsItemContent(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["workerScripts"][i]); + } catch(e) { + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["exceptionAlert"])(e); + } } document.getElementById("active-scripts-total-prod").innerHTML = - "Total online production of Active Scripts: " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_6___default()(total).format('$0.000a') + " / sec
" + + "Total online production of Active Scripts: " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7___default()(total).format('$0.000a') + " / sec
" + "Total online production since last Aug installation: " + - _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_6___default()(_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].scriptProdSinceLastAug).format('$0.000a') + " (" + - _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_6___default()(_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].scriptProdSinceLastAug / (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].playtimeSinceLastAug/1000)).format('$0.000a') + " / sec)"; + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7___default()(_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].scriptProdSinceLastAug).format('$0.000a') + " (" + + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7___default()(_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].scriptProdSinceLastAug / (_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].playtimeSinceLastAug/1000)).format('$0.000a') + " / sec)"; return total; } //Updates the content of the given item in the Active Scripts list function updateActiveScriptsItemContent(workerscript) { - var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_2__["getServer"])(workerscript.serverIp); + var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp); if (server == null) { console.log("ERROR: Invalid server IP for workerscript."); return; } + let hostname = server.hostname; + if (ActiveScriptsUI[hostname] == null) { + return; //Hasn't been created yet. We'll skip it + } + 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") - //Add the updated text back. Returns the total online production rate - return updateActiveScriptsText(workerscript, itemContent); + if (ActiveScriptsUI[hostname].scriptStats[itemName] == null) { + return; //Hasn't been fully added yet. We'll skip it + } + var item = ActiveScriptsUI[hostname].scriptStats[itemName]; + + //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: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_4__["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() { - Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_5__["logBoxCreate"])(workerscript.scriptRef); - return false; - }); - killButton.addEventListener("click", function() { - Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__["killWorkerScript"])(workerscript.scriptRef, workerscript.scriptRef.scriptRef.server); - Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_3__["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 = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp); + if (server == null) { + console.log("ERROR: Invalid server IP for workerscript."); + return; + } + let hostname = server.hostname; + if (ActiveScriptsUI[hostname] == null || ActiveScriptsUI[hostname].scriptHdrs[itemName] == 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 - //Online - var onlineTotalMoneyMade = "Total online production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(workerscript.scriptRef.onlineMoneyMade, 2); - var onlineTotalExpEarned = (Array(26).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(workerscript.scriptRef.onlineExpGained, 2) + " hacking exp").replace( / /g, " "); - var onlineMps = workerscript.scriptRef.onlineMoneyMade / workerscript.scriptRef.onlineRunningTime; - var onlineMpsText = "Online production rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(onlineMps, 2) + "/second"; + + //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;} + + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeChildrenFromElement"])(item); + + //Online + var onlineTotalMoneyMade = "Total online production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.onlineMoneyMade, 2); + var onlineTotalExpEarned = (Array(26).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.onlineExpGained, 2) + " hacking exp").replace( / /g, " "); + + var onlineMpsText = "Online production rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(onlineMps, 2) + "/second"; var onlineEps = workerscript.scriptRef.onlineExpGained / workerscript.scriptRef.onlineRunningTime; - var onlineEpsText = (Array(25).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(onlineEps, 4) + " hacking exp/second").replace( / /g, " "); + var onlineEpsText = (Array(25).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(onlineEps, 4) + " hacking exp/second").replace( / /g, " "); //Offline - var offlineTotalMoneyMade = "Total offline production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(workerscript.scriptRef.offlineMoneyMade, 2); - var offlineTotalExpEarned = (Array(27).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(workerscript.scriptRef.offlineExpGained, 2) + " hacking exp").replace( / /g, " "); + var offlineTotalMoneyMade = "Total offline production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.offlineMoneyMade, 2); + var offlineTotalExpEarned = (Array(27).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.offlineExpGained, 2) + " hacking exp").replace( / /g, " "); var offlineMps = workerscript.scriptRef.offlineMoneyMade / workerscript.scriptRef.offlineRunningTime; - var offlineMpsText = "Offline production rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(offlineMps, 2) + "/second"; + var offlineMpsText = "Offline production rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(offlineMps, 2) + "/second"; var offlineEps = workerscript.scriptRef.offlineExpGained / workerscript.scriptRef.offlineRunningTime; - var offlineEpsText = (Array(26).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(offlineEps, 4) + " hacking exp/second").replace( / /g, " "); + var offlineEpsText = (Array(26).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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; } @@ -55052,7 +55229,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _Prestige_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Prestige.js */ 57); /* harmony import */ var _SourceFile_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./SourceFile.js */ 42); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Terminal.js */ 22); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Terminal.js */ 18); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); /* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12); @@ -55395,7 +55572,7 @@ function createBitNodeYesNoEventListeners(newBitNode, destroyedBitNode, flume=fa "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NetscriptPort", function() { return NetscriptPort; }); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Settings.js */ 24); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Settings.js */ 23); function NetscriptPort() { @@ -55465,22 +55642,22 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Constants.js */ 3); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./engine.js */ 5); /* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Faction.js */ 11); -/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 35); +/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 32); /* harmony import */ var _Gang_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Gang.js */ 36); /* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HacknetNode.js */ 39); /* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Message.js */ 28); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Script.js */ 26); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Settings.js */ 24); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Settings.js */ 23); /* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); -/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./StockMarket.js */ 21); +/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./StockMarket.js */ 22); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_GameOptions_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../utils/GameOptions.js */ 54); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); /* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8); /* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2); -/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/decimal.js */ 23); +/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/decimal.js */ 24); /* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_20___default = /*#__PURE__*/__webpack_require__.n(_utils_decimal_js__WEBPACK_IMPORTED_MODULE_20__); @@ -56111,7 +56288,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Location.js */ 4); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./RedPill.js */ 44); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Terminal.js */ 22); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Terminal.js */ 18); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); /* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8); @@ -56138,7 +56315,7 @@ var CityNames = ["Aevum", "Chongqing", "Sector-12", "New Tokyo", "Ishima", "Volh var CyclesPerSecond = 5; //Game cycle is 200 ms var StaminaGainPerSecond = 0.0085; -var BaseStaminaLoss = 0.29; //Base stamina loss per action. Increased based on difficulty +var BaseStaminaLoss = 0.285; //Base stamina loss per action. Increased based on difficulty var MaxStaminaToGainFactor = 70000; //Max Stamina is divided by this to get bonus stamina gain var DifficultyToTimeFactor = 10; //Action Difficulty divided by this to get base action time @@ -56805,9 +56982,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(400, 800), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, 5), + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(300, 800), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56819,7 +56996,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(250, 500), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, 3), + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(200, 750), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56831,7 +57008,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(300, 600), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1,4), + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(300, 900), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56846,7 +57023,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(100, 300), countGrowth:1, + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56859,7 +57036,7 @@ Bladeburner.prototype.create = function() { "data.", baseDifficulty:500, difficultyFac:1.04, rewardFac:1.09, reqdRank:100, rankGain:4, rankLoss:0.4, hpLoss:2, - count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(100, 250), countGrowth:1, + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56870,7 +57047,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(100,250), countGrowth:0.75, + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56882,7 +57059,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(50, 100), countGrowth:0.2, + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56894,7 +57071,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(50, 200), countGrowth:0.1, + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56906,7 +57083,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(50, 150), countGrowth:0.1, + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -57362,10 +57539,10 @@ Bladeburner.prototype.completeAction = function() { break; case ActionTypes["Training"]: this.stamina -= (0.5 * BaseStaminaLoss); - var strExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].strength_exp_mult, - defExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].defense_exp_mult, - dexExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].dexterity_exp_mult, - agiExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].agility_exp_mult, + var strExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].strength_exp_mult, + defExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].defense_exp_mult, + dexExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].dexterity_exp_mult, + agiExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].agility_exp_mult, staminaGain = 0.04 * this.skillMultipliers.stamina; _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainStrengthExp(strExpGain); _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainDefenseExp(defExpGain); @@ -59263,9 +59440,9 @@ function initBladeburner() { Skills[SkillNames.BladesIntuition] = new Skill({ name:SkillNames.BladesIntuition, desc:"Each level of this skill increases your success chance " + - "for all contracts and operations by 2%", + "for all contracts and operations by 3%", baseCost:5, costInc:2, - successChanceAll:2 + successChanceAll:3 }); Skills[SkillNames.Reaper] = new Skill({ name:SkillNames.Reaper, @@ -59277,9 +59454,9 @@ function initBladeburner() { Skills[SkillNames.Cloak] = new Skill({ name:SkillNames.Cloak, desc:"Each level of this skill increases your " + - "success chance in stealth-related contracts and operations by 5%", + "success chance in stealth-related contracts and operations by 5.5%", baseCost:3, costInc:1, - successChanceStealth:5 + successChanceStealth:5.5 }); //TODO Marksman @@ -59289,7 +59466,7 @@ function initBladeburner() { name:SkillNames.Overclock, desc:"Each level of this skill decreases the time it takes " + "to attempt a contract or operation by 1% (Max Level: 99)", - baseCost:5, costInc:1, maxLvl:99, + baseCost:5, costInc:1, maxLvl:95, actionTime:1 }); Skills[SkillNames.EvasiveSystem] = new Skill({ @@ -59302,32 +59479,32 @@ function initBladeburner() { Skills[SkillNames.ShortCircuit] = new Skill({ name:SkillNames.ShortCircuit, desc:"Each level of this skill increases your success chance " + - "in contracts and operations that involve retirement by 5%", + "in contracts and operations that involve retirement by 5.5%", baseCost:3, costInc:2, - successChanceKill:5 + successChanceKill:5.5 }); Skills[SkillNames.DigitalObserver] = new Skill({ name:SkillNames.DigitalObserver, desc:"Each level of this skill increases your success chance in " + - "all operations by 3%", + "all operations by 4%", baseCost:5, costInc:2, - successChanceOperation:3 + successChanceOperation:4 }); Skills[SkillNames.Datamancer] = new Skill({ name:SkillNames.Datamancer, desc:"Each level of this skill increases your effectiveness in " + - "synthoid population analysis and investigation by 4%. " + + "synthoid population analysis and investigation by 5%. " + "This affects all actions that can potentially increase " + "the accuracy of your synthoid population/community estimates.", baseCost:3,costInc:1, - successChanceEstimate:4 + successChanceEstimate:5 }); Skills[SkillNames.Tracer] = new Skill({ name:SkillNames.Tracer, desc:"Each level of this skill increases your success chance in " + - "all contracts by 3%", + "all contracts by 4%", baseCost:3, costInc:2, - successChanceContract:3 + successChanceContract:4 }); Skills[SkillNames.CybersEdge] = new Skill({ name:SkillNames.CybersEdge, @@ -59915,7 +60092,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logBoxUpdateText", function() { return logBoxUpdateText; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logBoxOpened", function() { return logBoxOpened; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logBoxCurrentScript", function() { return logBoxCurrentScript; }); -/* harmony import */ var _src_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../src/NetscriptWorker.js */ 20); +/* harmony import */ var _src_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../src/NetscriptWorker.js */ 21); /* harmony import */ var _HelperFunctions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./HelperFunctions.js */ 1); @@ -60954,7 +61131,7 @@ __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prestigeAugmentation", function() { return prestigeAugmentation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prestigeSourceFile", function() { return prestigeSourceFile; }); /* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ActiveScriptsUI.js */ 43); -/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Augmentations.js */ 18); +/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Augmentations.js */ 19); /* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./BitNode.js */ 15); /* harmony import */ var _CinematicText_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./CinematicText.js */ 70); /* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Company.js */ 9); @@ -60965,13 +61142,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Location.js */ 4); /* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Message.js */ 28); /* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 29); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Server.js */ 10); /* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); -/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./StockMarket.js */ 21); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Terminal.js */ 22); -/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../utils/decimal.js */ 23); +/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./StockMarket.js */ 22); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Terminal.js */ 18); +/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../utils/decimal.js */ 24); /* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(_utils_decimal_js__WEBPACK_IMPORTED_MODULE_18__); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); @@ -65795,7 +65972,10 @@ function purchaseServer(ram, cost) { } //Create server - var newServ = new _Server_js__WEBPACK_IMPORTED_MODULE_2__["Server"](Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_4__["createRandomIp"])(), hostname, "", false, true, true, ram); + var newServ = new _Server_js__WEBPACK_IMPORTED_MODULE_2__["Server"]({ + ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_4__["createRandomIp"])(), hostname:hostname, organizationName:"", + isConnectedTo:false, adminRights:true, purchasedByPlayer:true, maxRam:ram + }); Object(_Server_js__WEBPACK_IMPORTED_MODULE_2__["AddToAllServers"])(newServ); //Add to Player's purchasedServers array @@ -69151,6 +69331,7 @@ function infiltrationBoxCreate(inst) { var selector = document.getElementById("infiltration-faction-select"); selector.innerHTML = ""; for (var i = 0; i < _src_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].factions.length; ++i) { + if (_src_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].factions[i] === "Bladeburners") {continue;} selector.innerHTML += ""; } diff --git a/dist/tests.bundle.js b/dist/tests.bundle.js index fd8c39a39..58195a455 100644 --- a/dist/tests.bundle.js +++ b/dist/tests.bundle.js @@ -80,13 +80,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Player", function() { return Player; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadPlayer", function() { return loadPlayer; }); -/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 18); +/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 19); /* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BitNode.js */ 15); /* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Company.js */ 9); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Constants.js */ 3); /* harmony import */ var _CompanyManagement_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./CompanyManagement.js */ 40); /* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./CreateProgram.js */ 14); -/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Crimes.js */ 19); +/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Crimes.js */ 20); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./engine.js */ 5); /* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Faction.js */ 11); /* harmony import */ var _Gang_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Gang.js */ 36); @@ -95,7 +95,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Server.js */ 10); /* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); /* harmony import */ var _SourceFile_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./SourceFile.js */ 42); -/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/decimal.js */ 23); +/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/decimal.js */ 24); /* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_utils_decimal_js__WEBPACK_IMPORTED_MODULE_15__); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); @@ -309,7 +309,10 @@ function PlayerObject() { PlayerObject.prototype.init = function() { /* Initialize Player's home computer */ - var t_homeComp = new _Server_js__WEBPACK_IMPORTED_MODULE_12__["Server"](Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_18__["createRandomIp"])(), "home", "Home PC", true, true, true, 8); + var t_homeComp = new _Server_js__WEBPACK_IMPORTED_MODULE_12__["Server"]({ + ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_18__["createRandomIp"])(), hostname:"home", organizationName:"Home PC", + isConnectedTo:true, adminRights:true, purchasedByPlayer:true, maxRam:8 + }); this.homeComputer = t_homeComp.ip; this.currentServer = t_homeComp.ip; Object(_Server_js__WEBPACK_IMPORTED_MODULE_12__["AddToAllServers"])(t_homeComp); @@ -1379,7 +1382,7 @@ PlayerObject.prototype.finishCreateProgramWork = function(cancelled, sing=false) this.getHomeComputer().programs.push(programName); } else { - var perc = Math.floor(this.timeWorkedCreateProgram / this.timeNeededToCompleteWork * 100).toString(); + var perc = (Math.floor(this.timeWorkedCreateProgram / this.timeNeededToCompleteWork * 10000)/100).toString(); var incompleteName = programName + "-" + perc + "%-INC"; this.getHomeComputer().programs.push(incompleteName); } @@ -1681,14 +1684,16 @@ PlayerObject.prototype.finishCrime = function(cancelled) { this.workAgiExpGained *= 2; this.workChaExpGained *= 2; if (this.committingCrimeThruSingFn) { - this.singFnCrimeWorkerScript.scriptRef.log("Crime successful! Gained " + - _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_20___default()(this.workMoneyGained).format("$0.000a") + ", " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workHackExpGained, 3) + " hack exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workStrExpGained, 3) + " str exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDefExpGained, 3) + " def exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDexExpGained, 3) + " dex exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workAgiExpGained, 3) + " agi exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workChaExpGained, 3) + " cha exp."); + if(this.singFnCrimeWorkerScript.disableLogs.ALL == null && this.singFnCrimeWorkerScript.disableLogs.commitCrime == null) { + this.singFnCrimeWorkerScript.scriptRef.log("Crime successful! Gained " + + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_20___default()(this.workMoneyGained).format("$0.000a") + ", " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workHackExpGained, 3) + " hack exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workStrExpGained, 3) + " str exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDefExpGained, 3) + " def exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDexExpGained, 3) + " dex exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workAgiExpGained, 3) + " agi exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workChaExpGained, 3) + " cha exp."); + } } else { Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Crime successful!

" + "You gained:
"+ @@ -1710,13 +1715,15 @@ PlayerObject.prototype.finishCrime = function(cancelled) { this.workAgiExpGained /= 2; this.workChaExpGained /= 2; if (this.committingCrimeThruSingFn) { - this.singFnCrimeWorkerScript.scriptRef.log("Crime failed! Gained " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workHackExpGained, 3) + " hack exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workStrExpGained, 3) + " str exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDefExpGained, 3) + " def exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDexExpGained, 3) + " dex exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workAgiExpGained, 3) + " agi exp, " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workChaExpGained, 3) + " chaexp."); + if(this.singFnCrimeWorkerScript.disableLogs.ALL == null && this.singFnCrimeWorkerScript.disableLogs.commitCrime == null) { + this.singFnCrimeWorkerScript.scriptRef.log("Crime failed! Gained " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workHackExpGained, 3) + " hack exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workStrExpGained, 3) + " str exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDefExpGained, 3) + " def exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDexExpGained, 3) + " dex exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workAgiExpGained, 3) + " agi exp, " + + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workChaExpGained, 3) + " cha exp."); + } } else { Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Crime failed!

" + "You gained:
"+ @@ -2950,7 +2957,7 @@ function generateRandomString(n) { __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONSTANTS", function() { return CONSTANTS; }); let CONSTANTS = { - Version: "0.36.0", + Version: "0.36.1", //Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience //and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then @@ -2991,6 +2998,7 @@ let CONSTANTS = { /* Netscript Constants */ //RAM Costs for different commands + ScriptBaseRamCost: 1.4, ScriptWhileRamCost: 0.2, ScriptForRamCost: 0.2, ScriptIfRamCost: 0.15, @@ -3641,6 +3649,7 @@ let CONSTANTS = { "hostname/ip, regardless of arguments. Returns true if one or more scripts were successfully killed, and false if there were none.

" + "The first argument must be a string with the name of the script. The script name is case sensitive. The second argument is " + "a string with the hostname or IP of the target server. Both arguments are required.

" + + "getScriptName()
Returns the filename of the current script (including the extension)

" + "getScriptRam(scriptname, hostname/ip)
Returns the amount of RAM required to run the specified script on the " + "target server. The first argument must be a string with the name of the script. The script name is case sensitive. " + "The second argument is a string with the hostname or IP of the server where that script is. Both arguments are required.

" + @@ -4090,11 +4099,28 @@ let CONSTANTS = { LatestUpdate: "v0.36.1
" + - "* The ctrl+b hotkey in the text editor is now also triggered by command+b or winkey+b
" + - "v0.36.0
" + - "* Added BN-6: Bladeburners
" + - "* Rebalanced many combat Augmentations so that they are slightly less powerful
" + - "* Bug Fix: When faction invites are suppressed, an invitation will no longer load the Faction page
" + "* Bladeburner Changes:
" + + "** Bug Fix: You can no longer get Bladeburner faction reputation through Infiltration
" + + "** Initial difficulty of Tracking contracts reduced
" + + "** Datamancer skill effect increased from 4% per level to 5%
" + + "** Slightly decreased the base stamina cost of contracts/operations
" + + "** Slightly increased the effects of the Tracer, Digital Observer, Short Circuit, Cloak, and Blade's Intuition skills
" + + "** Overclock skill capped at level 95, rather than 99
" + + "** Training gives significantly more exp/s
" + + "* Crime, Infiltration, and Hacking are now slightly more profitable in BN-6
" + + "* Gyms are now more expensive, but give slightly more exp
" + + "* Added getScriptName() and getHacknetMultipliers() Netscript functions (added by Github user hydroflame)
" + + "* getScriptRam() Netscript function now has default value for the second argument, which is hostname/ip (implemented by Github user hydroflame)
" + + "* There is now a soft-cap on stock price, which means it's no longer possible for the price of a stock to reach insanely-high values
" + + "* The ctrl+b hotkey in the text editor should now also be triggered by command+b on OSX (I don't have OSX so I can't confirm if this works)
" + + "* Many servers now have additional RAM
" + + "* Added an option to disable hotkeys/keyboard shortcuts
" + + "* Refactored 'Active Scripts' UI page to optimize its performance
" + + "* Added a new .fconf Terminal setting: ENABLE_TIMESTAMP
" + + "* 'Netscript Execution Time', which can be found in the Options, now has a minimum value of 15ms rather than 25ms
" + + "* Bug Fix: Fixed a typo in the Fulcrum Technologies company name (Technolgies -> Technologies)
" + + "* Bug Fix: hacknetnodes keyword should no longer incur RAM cost if its in a comment
" + + "* Bug Fix: disableLog() now works for the commitCrime() Netscript function (fixed by Github user hydroflame)" } @@ -4117,7 +4143,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Company.js */ 9); /* harmony import */ var _CompanyManagement_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CompanyManagement.js */ 40); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Constants.js */ 3); -/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Crimes.js */ 19); +/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Crimes.js */ 20); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./engine.js */ 5); /* harmony import */ var _Infiltration_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Infiltration.js */ 119); /* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 29); @@ -4169,7 +4195,7 @@ var Locations = { AevumECorp: "ECorp", AevumBachmanAndAssociates: "Bachman & Associates", AevumClarkeIncorporated: "Clarke Incorporated", - AevumFulcrumTechnologies: "Fulcrum Technolgies", + AevumFulcrumTechnologies: "Fulcrum Technologies", AevumAeroCorp: "AeroCorp", AevumGalacticCybersystems: "Galactic Cybersystems", AevumWatchdogSecurity: "Watchdog Security", @@ -4682,13 +4708,13 @@ function displayLocationContent() { break; case Locations.AevumCrushFitnessGym: - var costMult = 2, expMult = 1.5; + var costMult = 3, expMult = 2; displayGymLocationContent(costMult); setGymLocationButtons(costMult, expMult); break; case Locations.AevumSnapFitnessGym: - var costMult = 6, expMult = 4; + var costMult = 10, expMult = 5; displayGymLocationContent(costMult); setGymLocationButtons(costMult, expMult); break; @@ -4910,7 +4936,7 @@ function displayLocationContent() { break; case Locations.Sector12PowerhouseGym: - var costMult = 10, expMult = 7.5; + var costMult = 20, expMult = 10; displayGymLocationContent(costMult); setGymLocationButtons(costMult, expMult); break; @@ -5162,7 +5188,7 @@ function displayLocationContent() { break; case Locations.VolhavenMilleniumFitnessGym: - var costMult = 3, expMult = 2.5; + var costMult = 7, expMult = 4; displayGymLocationContent(costMult); setGymLocationButtons(costMult, expMult); break; @@ -6130,7 +6156,10 @@ function purchaseTorRouter() { } _Player_js__WEBPACK_IMPORTED_MODULE_8__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].TorRouterCost); - var darkweb = new _Server_js__WEBPACK_IMPORTED_MODULE_9__["Server"](Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_14__["createRandomIp"])(), "darkweb", "", false, false, false, 1); + var darkweb = new _Server_js__WEBPACK_IMPORTED_MODULE_9__["Server"]({ + ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_14__["createRandomIp"])(), hostname:"darkweb", organizationName:"", + isConnectedTo:false, adminRights:false, purchasedByPlayer:false, maxRam:1 + }); Object(_Server_js__WEBPACK_IMPORTED_MODULE_9__["AddToAllServers"])(darkweb); _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_11__["SpecialServerIps"].addIp("Darkweb Server", darkweb.ip); @@ -6330,7 +6359,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2); /* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/LogBox.js */ 51); /* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./ActiveScriptsUI.js */ 43); -/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Augmentations.js */ 18); +/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Augmentations.js */ 19); /* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./BitNode.js */ 15); /* harmony import */ var _Bladeburner_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Bladeburner.js */ 47); /* harmony import */ var _CinematicText_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./CinematicText.js */ 70); @@ -6339,27 +6368,27 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Constants.js */ 3); /* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./CreateProgram.js */ 14); /* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Faction.js */ 11); -/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Fconf.js */ 35); +/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Fconf.js */ 32); /* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Location.js */ 4); /* harmony import */ var _Gang_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./Gang.js */ 36); /* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./HacknetNode.js */ 39); /* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 25); /* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./Literature.js */ 53); /* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./Message.js */ 28); -/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Missions.js */ 32); +/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./Missions.js */ 33); /* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 29); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _Prestige_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ./Prestige.js */ 57); /* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ./RedPill.js */ 44); /* harmony import */ var _SaveObject_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ./SaveObject.js */ 46); /* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ./Script.js */ 26); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./Settings.js */ 24); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_32__ = __webpack_require__(/*! ./Settings.js */ 23); /* harmony import */ var _SourceFile_js__WEBPACK_IMPORTED_MODULE_33__ = __webpack_require__(/*! ./SourceFile.js */ 42); /* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_34__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); -/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./StockMarket.js */ 21); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Terminal.js */ 22); +/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_35__ = __webpack_require__(/*! ./StockMarket.js */ 22); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_36__ = __webpack_require__(/*! ./Terminal.js */ 18); @@ -6415,51 +6444,52 @@ __webpack_require__.r(__webpack_exports__); * Alt-o - Options */ $(document).keydown(function(e) { + if (_Settings_js__WEBPACK_IMPORTED_MODULE_32__["Settings"].DisableHotkeys === true) {return;} if (!_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].isWorking && !_RedPill_js__WEBPACK_IMPORTED_MODULE_28__["redPillFlag"] && !_Missions_js__WEBPACK_IMPORTED_MODULE_23__["inMission"] && !_CinematicText_js__WEBPACK_IMPORTED_MODULE_10__["cinematicTextFlag"]) { if (e.keyCode == 84 && e.altKey) { e.preventDefault(); Engine.loadTerminalContent(); - } else if (e.keyCode == 67 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].C && e.altKey) { e.preventDefault(); Engine.loadCharacterContent(); - } else if (e.keyCode == 69 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].E && e.altKey) { e.preventDefault(); Engine.loadScriptEditorContent(); - } else if (e.keyCode == 83 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].S && e.altKey) { e.preventDefault(); Engine.loadActiveScriptsContent(); - } else if (e.keyCode == 72 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].H && e.altKey) { e.preventDefault(); Engine.loadHacknetNodesContent(); - } else if (e.keyCode == 87 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].W && e.altKey) { e.preventDefault(); Engine.loadWorldContent(); - } else if (e.keyCode == 74 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].J && e.altKey) { e.preventDefault(); Engine.loadJobContent(); - } else if (e.keyCode == 82 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].R && e.altKey) { e.preventDefault(); Engine.loadTravelContent(); - } else if (e.keyCode == 80 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].P && e.altKey) { e.preventDefault(); Engine.loadCreateProgramContent(); - } else if (e.keyCode == 70 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].F && e.altKey) { //Overriden by Fconf if (Engine.currentPage === Engine.Page.Terminal && _Fconf_js__WEBPACK_IMPORTED_MODULE_16__["FconfSettings"].ENABLE_BASH_HOTKEYS) { return; } e.preventDefault(); Engine.loadFactionsContent(); - } else if (e.keyCode == 65 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].A && e.altKey) { e.preventDefault(); Engine.loadAugmentationsContent(); - } else if (e.keyCode == 85 && e.altKey) { + } else if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].U && e.altKey) { e.preventDefault(); Engine.loadTutorialContent(); } } - if (e.keyCode == 79 && e.altKey) { + if (e.keyCode === _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["KEY"].O && e.altKey) { e.preventDefault(); Object(_utils_GameOptions_js__WEBPACK_IMPORTED_MODULE_1__["gameOptionsBoxOpen"])(); } @@ -6599,7 +6629,6 @@ let Engine = { loadActiveScriptsContent: function() { Engine.hideAllContent(); Engine.Display.activeScriptsContent.style.display = "block"; - Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_6__["setActiveScriptsClickHandlers"])(); Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_6__["updateActiveScriptsItems"])(); Engine.currentPage = Engine.Page.ActiveScripts; document.getElementById("active-scripts-menu-link").classList.add("active"); @@ -6838,30 +6867,18 @@ let Engine = { displayCharacterOverviewInfo: function() { if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hp == null) {_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hp = _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].max_hp;} + var overviewText = "Hp: " + _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hp + " / " + _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].max_hp + "
" + + "Money: " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_3___default()(_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].money.toNumber()).format('($0.000a)') + "
" + + "Hack: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hacking_skill).toLocaleString() + "
" + + "Str: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].strength).toLocaleString() + "
" + + "Def: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].defense).toLocaleString() + "
" + + "Dex: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].dexterity).toLocaleString() + "
" + + "Agi: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].agility).toLocaleString() + "
" + + "Cha: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].charisma).toLocaleString(); if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].intelligence >= 1) { - document.getElementById("character-overview-text").innerHTML = - ("Hp: " + _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hp + " / " + _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].max_hp + "
" + - "Money: " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_3___default()(_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].money.toNumber()).format('($0.000a)') + "
" + - "Hack: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hacking_skill).toLocaleString() + "
" + - "Str: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].strength).toLocaleString() + "
" + - "Def: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].defense).toLocaleString() + "
" + - "Dex: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].dexterity).toLocaleString() + "
" + - "Agi: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].agility).toLocaleString() + "
" + - "Cha: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].charisma).toLocaleString() + "
" + - "Int: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].intelligence).toLocaleString() - ).replace( / /g, " " ); - } else { - document.getElementById("character-overview-text").innerHTML = - ("Hp: " + _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hp + " / " + _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].max_hp + "
" + - "Money: " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_3___default()(_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].money.toNumber()).format('($0.000a)') + "
" + - "Hack: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hacking_skill).toLocaleString() + "
" + - "Str: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].strength).toLocaleString() + "
" + - "Def: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].defense).toLocaleString() + "
" + - "Dex: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].dexterity).toLocaleString() + "
" + - "Agi: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].agility).toLocaleString() + "
" + - "Cha: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].charisma).toLocaleString() - ).replace( / /g, " " ); + overviewText += "
Int: " + (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].intelligence).toLocaleString(); } + document.getElementById("character-overview-text").innerHTML = overviewText.replace( / /g, " "); }, /* Display character info */ @@ -7239,9 +7256,10 @@ let Engine = { Counters: { autoSaveCounter: 300, //Autosave every minute updateSkillLevelsCounter: 10, //Only update skill levels every 2 seconds. Might improve performance - updateDisplays: 3, //Update displays such as Active Scripts display and character display + updateDisplays: 3, updateDisplaysMed: 9, updateDisplaysLong: 15, + updateActiveScriptsDisplay: 5, createProgramNotifications: 10, //Checks whether any programs can be created and notifies checkFactionInvitations: 100, //Check whether you qualify for any faction invitations passiveFactionGrowth: 600, @@ -7279,6 +7297,16 @@ let Engine = { Engine.Counters.updateSkillLevelsCounter = 10; } + if (Engine.Counters.updateActiveScriptsDisplay <= 0) { + //Always update, but make the interval longer if the page isn't active + Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_6__["updateActiveScriptsItems"])(); + if (Engine.currentPage === Engine.Page.ActiveScripts) { + Engine.Counters.updateActiveScriptsDisplay = 5; + } else { + Engine.Counters.updateActiveScriptsDisplay = 15; + } + } + if (Engine.Counters.updateDisplays <= 0) { Engine.displayCharacterOverviewInfo(); if (Engine.currentPage == Engine.Page.CharacterInfo) { @@ -7297,9 +7325,7 @@ let Engine = { } if (Engine.Counters.updateDisplaysMed <= 0) { - if (Engine.currentPage == Engine.Page.ActiveScripts) { - Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_6__["updateActiveScriptsItems"])(); - } else if (Engine.currentPage === Engine.Page.Corporation) { + if (Engine.currentPage === Engine.Page.Corporation) { _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].corporation.updateUIContent(); } Engine.Counters.updateDisplaysMed = 9; @@ -8225,11 +8251,11 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 69); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Settings.js */ 24); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Settings.js */ 23); /* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Script.js */ 26); -/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/acorn.js */ 34); +/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/acorn.js */ 35); /* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); /* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/IPAddress.js */ 16); @@ -10470,16 +10496,16 @@ function Server(params={ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7 ++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 @@ -10491,22 +10517,22 @@ function Server(params={ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7 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 * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerStartingMoney : 1e6; + this.requiredHackingSkill = params.requiredHackingSkill != null ? params.requiredHackingSkill : 1; + this.moneyAvailable = params.moneyAvailable != null ? params.moneyAvailable * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerStartingMoney : 0; this.moneyMax = 25 * this.moneyAvailable * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerMaxMoney; //Hack Difficulty is synonymous with server security. Base Difficulty = Starting difficulty - this.hackDifficulty = params.hackDifficulty ? params.hackDifficulty * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerStartingSecurity : 1; + this.hackDifficulty = params.hackDifficulty != null ? params.hackDifficulty * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["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 @@ -10515,29 +10541,6 @@ function Server(params={ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7 this.openPortCount = 0; }; -/* -//Set the hacking properties of a server -Server.prototype.setHackingParameters = function(requiredHackingSkill, moneyAvailable, hackDifficulty, serverGrowth) { - this.requiredHackingSkill = requiredHackingSkill; - if (isNaN(moneyAvailable)) { - this.moneyAvailable = 1e6; - } else { - this.moneyAvailable = moneyAvailable * BitNodeMultipliers.ServerStartingMoney; - } - this.moneyMax = - this.hackDifficulty = hackDifficulty * BitNodeMultipliers.ServerStartingSecurity; - this.baseDifficulty = hackDifficulty * BitNodeMultipliers.ServerStartingSecurity; - this.minDifficulty = Math.max(1, Math.round(this.hackDifficulty / 3)); - this.serverGrowth = serverGrowth; -} - -//Set the port properties of a server -//Right now its only the number of open ports needed to PortHack the server. -Server.prototype.setPortProperties = function(numOpenPortsReq) { - this.numOpenPortsRequired = numOpenPortsReq; -} -*/ - Server.prototype.setMaxRam = function(ram) { this.maxRam = ram; } @@ -10974,7 +10977,6 @@ function initForeignServers() { requiredHackingSkill:20, moneyAvailable:2.75e6, hackDifficulty:20, serverGrowth:25, numOpenPortsRequired:0 }); - NectarNightclubServer.setPortProperties(0); AddToAllServers(NectarNightclubServer); var NeoNightclubServer = new Server({ @@ -11409,15 +11411,15 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Faction", function() { return Faction; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "purchaseAugmentation", function() { return purchaseAugmentation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "factionExists", function() { return factionExists; }); -/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 18); +/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 19); /* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BitNode.js */ 15); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Constants.js */ 3); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./engine.js */ 5); /* harmony import */ var _FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./FactionInfo.js */ 27); /* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Location.js */ 4); -/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Missions.js */ 32); +/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Missions.js */ 33); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Player.js */ 0); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Settings.js */ 24); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Settings.js */ 23); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_FactionInvitationBox_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/FactionInvitationBox.js */ 117); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); @@ -12519,7 +12521,9 @@ function getNextNeurofluxLevel() { } } if (aug == null) { - console.log("ERROR, Could not find NeuroFlux Governor aug"); + console.log("WARNING: Could not find NeuroFlux Governor aug. This is OK if " + + "it happens during the loading/initialization of the game, but probably " + + "indicates something seriously wrong at other times"); return 1; } } @@ -13077,10 +13081,10 @@ function initBitNodes() { "for progression. Furthermore:

" + "Hacking and Hacknet Nodes will be significantly less profitable
" + "Your hacking level is reduced by 50%
" + - "Hacking experience gain from scripts is reduced by 80%
" + + "Hacking experience gain from scripts is reduced by 75%
" + "Corporations have 80% lower valuations and are therefore less profitable
" + "Working for companies is 50% less profitable
" + - "Crimes and Infiltration are 75% less profitable

" + + "Crimes and Infiltration are 50% less profitable

" + "Destroying this BitNode will give you Source-File 6, or if you already have this Source-File it will upgrade " + "its level up to a maximum of 3. This Source-File allows you to access the NSA's Bladeburner Division in other " + "BitNodes. In addition, this Source-File will raise the experience gain rate of all your combat stats by:

" + @@ -13246,12 +13250,12 @@ function initBitNodeMultipliers() { BitNodeMultipliers.ServerStartingSecurity = 1.5; BitNodeMultipliers.ScriptHackMoney = 0.5; BitNodeMultipliers.CompanyWorkMoney = 0.5; - BitNodeMultipliers.CrimeMoney = 0.25; - BitNodeMultipliers.InfiltrationMoney = 0.25; + BitNodeMultipliers.CrimeMoney = 0.5; + BitNodeMultipliers.InfiltrationMoney = 0.5; BitNodeMultipliers.CorporationValuation = 0.2; BitNodeMultipliers.HacknetNodeMoney = 0.2; BitNodeMultipliers.FactionPassiveRepGain = 0; - BitNodeMultipliers.HackExpGain = 0.2; + BitNodeMultipliers.HackExpGain = 0.25; break; case 8: //Ghost of Wall Street BitNodeMultipliers.ScriptHackMoney = 0; @@ -13411,6 +13415,2078 @@ function initSpecialServerIps() { /***/ }), /* 18 */ +/*!*************************!*\ + !*** ./src/Terminal.js ***! + \*************************/ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postNetburnerText", function() { return postNetburnerText; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "post", function() { return post; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Terminal", function() { return Terminal; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KEY", function() { return KEY; }); +/* harmony import */ var _Alias_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Alias.js */ 30); +/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3); +/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CreateProgram.js */ 14); +/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DarkWeb.js */ 34); +/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./engine.js */ 5); +/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 32); +/* harmony import */ var _HelpText_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./HelpText.js */ 72); +/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 25); +/* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Literature.js */ 53); +/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Message.js */ 28); +/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 7); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); +/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Player.js */ 0); +/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./RedPill.js */ 44); +/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Script.js */ 26); +/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Server.js */ 10); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Settings.js */ 23); +/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); +/* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./TextFile.js */ 41); +/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2); +/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); +/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../utils/LogBox.js */ 51); +/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12); +/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! jszip */ 121); +/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_23___default = /*#__PURE__*/__webpack_require__.n(jszip__WEBPACK_IMPORTED_MODULE_23__); +/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! file-saver */ 120); +/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(file_saver__WEBPACK_IMPORTED_MODULE_24__); + + + + + + + + + + + + + + + + + + + + + + + + + + + + +/* Write text to terminal */ +//If replace is true then spaces are replaced with " " +function post(input) { + $("#terminal-input").before('' + input + ''); + updateTerminalScroll(); +} + +//Same thing as post but the td cells have ids so they can be animated for the hack progress bar +function hackProgressBarPost(input) { + $("#terminal-input").before('' + input + ''); + updateTerminalScroll(); +} + +function hackProgressPost(input) { + $("#terminal-input").before('' + input + ''); + updateTerminalScroll(); +} + +//Scroll to the bottom of the terminal's 'text area' +function updateTerminalScroll() { + var element = document.getElementById("terminal-container"); + element.scrollTop = element.scrollHeight; +} + +function postNetburnerText() { + post("Bitburner v" + _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].Version); +} + + +//Key Codes +var KEY = { + TAB: 9, + ENTER: 13, + CTRL: 17, + UPARROW: 38, + DOWNARROW: 40, + A: 65, + B: 66, + C: 67, + D: 68, + 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, +} + +//Defines key commands in terminal +$(document).keydown(function(event) { + //Terminal + if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { + var terminalInput = document.getElementById("terminal-input-text-box"); + if (terminalInput != null && !event.ctrlKey && !event.shiftKey) {terminalInput.focus();} + + if (event.keyCode === KEY.ENTER) { + event.preventDefault(); //Prevent newline from being entered in Script Editor + var command = $('input[class=terminal-input]').val(); + if (command.length > 0) { + post( + "[" + + (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_TIMESTAMPS ? Terminal.getTimestamp() + " " : "") + + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname + + " ~]> " + command + ); + + Terminal.resetTerminalInput(); //Clear input first + Terminal.executeCommand(command); + } + } + + if (event.keyCode === KEY.C && event.ctrlKey) { + if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"]._actionInProgress) { + //Cancel action + post("Cancelling..."); + _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"]._actionInProgress = false; + Terminal.finishAction(true); + } else if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) { + //Dont prevent default so it still copies + Terminal.resetTerminalInput(); //Clear Terminal + } + } + + if (event.keyCode === KEY.L && event.ctrlKey) { + event.preventDefault(); + Terminal.executeCommand("clear"); //Clear screen + } + + //Ctrl p same as up arrow + //Ctrl n same as down arrow + + if (event.keyCode === KEY.UPARROW || + (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS && event.keyCode === KEY.P && event.ctrlKey)) { + if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) {event.preventDefault();} + //Cycle through past commands + if (terminalInput == null) {return;} + var i = Terminal.commandHistoryIndex; + var len = Terminal.commandHistory.length; + + if (len == 0) {return;} + if (i < 0 || i > len) { + Terminal.commandHistoryIndex = len; + } + + if (i != 0) { + --Terminal.commandHistoryIndex; + } + var prevCommand = Terminal.commandHistory[Terminal.commandHistoryIndex]; + terminalInput.value = prevCommand; + setTimeout(function(){terminalInput.selectionStart = terminalInput.selectionEnd = 10000; }, 0); + } + + if (event.keyCode === KEY.DOWNARROW || + (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS && event.keyCode === KEY.M && event.ctrlKey)) { + if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) {event.preventDefault();} + //Cycle through past commands + if (terminalInput == null) {return;} + var i = Terminal.commandHistoryIndex; + var len = Terminal.commandHistory.length; + + if (len == 0) {return;} + if (i < 0 || i > len) { + Terminal.commandHistoryIndex = len; + } + + //Latest command, put nothing + if (i == len || i == len-1) { + Terminal.commandHistoryIndex = len; + terminalInput.value = ""; + } else { + ++Terminal.commandHistoryIndex; + var prevCommand = Terminal.commandHistory[Terminal.commandHistoryIndex]; + terminalInput.value = prevCommand; + } + } + + if (event.keyCode === KEY.TAB) { + //Autocomplete + if (terminalInput == null) {return;} + var input = terminalInput.value; + if (input == "") {return;} + input = input.trim(); + input = input.replace(/\s\s+/g, ' '); + + var commandArray = input.split(" "); + var index = commandArray.length - 2; + if (index < -1) {index = 0;} + var allPos = determineAllPossibilitiesForTabCompletion(input, index); + if (allPos.length == 0) {return;} + + var arg = ""; + var command = ""; + if (commandArray.length == 0) {return;} + if (commandArray.length == 1) {command = commandArray[0];} + else if (commandArray.length == 2) { + command = commandArray[0]; + arg = commandArray[1]; + } else if (commandArray.length == 3) { + command = commandArray[0] + " " + commandArray[1]; + arg = commandArray[2]; + } else { + arg = commandArray.pop(); + command = commandArray.join(" "); + } + + tabCompletion(command, arg, allPos); + } + + //Extra Bash Emulation Hotkeys, must be enabled through .fconf + if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) { + if (event.keyCode === KEY.A && event.ctrlKey) { + event.preventDefault(); + Terminal.moveTextCursor("home"); + } + + if (event.keyCode === KEY.E && event.ctrlKey) { + event.preventDefault(); + Terminal.moveTextCursor("end"); + } + + if (event.keyCode === KEY.B && event.ctrlKey) { + event.preventDefault(); + Terminal.moveTextCursor("prevchar"); + } + + if (event.keyCode === KEY.B && event.altKey) { + event.preventDefault(); + Terminal.moveTextCursor("prevword"); + } + + if (event.keyCode === KEY.F && event.ctrlKey) { + event.preventDefault(); + Terminal.moveTextCursor("nextchar"); + } + + if (event.keyCode === KEY.F && event.altKey) { + event.preventDefault(); + Terminal.moveTextCursor("nextword"); + } + + + if ((event.keyCode === KEY.H || event.keyCode === KEY.D) && event.ctrlKey) { + Terminal.modifyInput("backspace"); + event.preventDefault(); + } + + //TODO AFTER THIS: + + //alt + d deletes word after cursor + //^w deletes word before cursor + //^k clears line after cursor + //^u clears line before cursor + } + } +}); + +//Keep terminal in focus +let terminalCtrlPressed = false, shiftKeyPressed = false; +$(document).ready(function() { + if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { + $('.terminal-input').focus(); + } +}); +$(document).keydown(function(e) { + if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { + if (e.which == 17) { + 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();} + + terminalCtrlPressed = false; + shiftKeyPressed = false; + } + } +}) +$(document).keyup(function(e) { + if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { + if (e.which == 17) { + terminalCtrlPressed = false; + } + if (e.shiftKey) { + shiftKeyPressed = false; + } + } +}) + +//Implements a tab completion feature for terminal +// command - Command (first arg only) +// arg - Incomplete argument string that the function will try to complete, or will display +// a series of possible options for +// allPossibilities - Array of strings containing all possibilities that the +// string can complete to +// index - index of argument that is being "tab completed". By default is 0, the first argument +function tabCompletion(command, arg, allPossibilities, index=0) { + if (!(allPossibilities.constructor === Array)) {return;} + if (!Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["containsAllStrings"])(allPossibilities)) {return;} + + if (!command.startsWith("./")) { + command = command.toLowerCase(); + } + + //Remove all options in allPossibilities that do not match the current string + //that we are attempting to autocomplete + if (arg == "") { + for (var i = allPossibilities.length-1; i >= 0; --i) { + if (!allPossibilities[i].toLowerCase().startsWith(command.toLowerCase())) { + allPossibilities.splice(i, 1); + } + } + } else { + for (var i = allPossibilities.length-1; i >= 0; --i) { + if (!allPossibilities[i].toLowerCase().startsWith(arg.toLowerCase())) { + allPossibilities.splice(i, 1); + } + } + } + + var val = ""; + if (allPossibilities.length == 0) { + return; + } else if (allPossibilities.length == 1) { + if (arg == "") { + //Autocomplete command + val = allPossibilities[0] + " "; + } else { + val = command + " " + allPossibilities[0]; + } + document.getElementById("terminal-input-text-box").value = val; + document.getElementById("terminal-input-text-box").focus(); + } else { + var longestStartSubstr = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["longestCommonStart"])(allPossibilities); + //If the longest common starting substring of remaining possibilities is the same + //as whatevers already in terminal, just list all possible options. Otherwise, + //change the input in the terminal to the longest common starting substr + var allOptionsStr = ""; + for (var i = 0; i < allPossibilities.length; ++i) { + allOptionsStr += allPossibilities[i]; + allOptionsStr += " "; + } + if (arg == "") { + if (longestStartSubstr == command) { + post("> " + command); + post(allOptionsStr); + } else { + document.getElementById("terminal-input-text-box").value = longestStartSubstr; + document.getElementById("terminal-input-text-box").focus(); + } + } else { + if (longestStartSubstr == arg) { + //List all possible options + post("> " + command + " " + arg); + post(allOptionsStr); + } else { + document.getElementById("terminal-input-text-box").value = command + " " + longestStartSubstr; + document.getElementById("terminal-input-text-box").focus(); + } + } + + } +} + +function determineAllPossibilitiesForTabCompletion(input, index=0) { + var allPos = []; + allPos = allPos.concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["GlobalAliases"])); + var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + input = input.toLowerCase(); + + //If the command starts with './' and the index == -1, then the user + //has input ./partialexecutablename so autocomplete the script or program + //Put './' in front of each script/executable + if (input.startsWith("./") && index == -1) { + //All programs and scripts + for (var i = 0; i < currServ.scripts.length; ++i) { + allPos.push("./" + currServ.scripts[i].filename); + } + + //Programs are on home computer + var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getHomeComputer(); + for(var i = 0; i < homeComputer.programs.length; ++i) { + allPos.push("./" + homeComputer.programs[i]); + } + return allPos; + } + + //Autocomplete the command + if (index == -1) { + return ["alias", "analyze", "cat", "check", "clear", "cls", "connect", "download", "free", + "hack", "help", "home", "hostname", "ifconfig", "kill", "killall", + "ls", "lscpu", "mem", "nano", "ps", "rm", "run", "scan", "scan-analyze", + "scp", "sudov", "tail", "theme", "top"].concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["Aliases"])).concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["GlobalAliases"])); + } + + if (input.startsWith ("buy ")) { + return [_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BruteSSHProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].FTPCrackProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].RelaySMTPProgram, + _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].HTTPWormProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].SQLInjectProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1, + _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2].concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["GlobalAliases"])); + } + + if (input.startsWith("scp ") && index == 1) { + for (var iphostname in _Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"]) { + if (_Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"].hasOwnProperty(iphostname)) { + allPos.push(_Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"][iphostname].ip); + allPos.push(_Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"][iphostname].hostname); + } + } + } + + if (input.startsWith("scp ") && index == 0) { + //All Scripts and lit files + for (var i = 0; i < currServ.scripts.length; ++i) { + allPos.push(currServ.scripts[i].filename); + } + for (var i = 0; i < currServ.messages.length; ++i) { + if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"])) { + allPos.push(currServ.messages[i]); + } + } + for (var i = 0; i < currServ.textFiles.length; ++i) { + allPos.push(currServ.textFiles[i].fn); + } + } + + if (input.startsWith("connect ") || input.startsWith("telnet ")) { + //All network connections + for (var i = 0; i < currServ.serversOnNetwork.length; ++i) { + var serv = _Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"][currServ.serversOnNetwork[i]]; + if (serv == null) {continue;} + allPos.push(serv.ip); //IP + allPos.push(serv.hostname); //Hostname + } + return allPos; + } + + if (input.startsWith("kill ") || input.startsWith("tail ") || + input.startsWith("mem ") || input.startsWith("check ")) { + //All Scripts + for (var i = 0; i < currServ.scripts.length; ++i) { + allPos.push(currServ.scripts[i].filename); + } + return allPos; + } + + if (input.startsWith("nano ")) { + //Scripts and text files and .fconf + for (var i = 0; i < currServ.scripts.length; ++i) { + allPos.push(currServ.scripts[i].filename); + } + for (var i = 0; i < currServ.textFiles.length; ++i) { + allPos.push(currServ.textFiles[i].fn); + } + allPos.push(".fconf"); + return allPos; + } + + if (input.startsWith("rm ")) { + for (var i = 0; i < currServ.scripts.length; ++i) { + allPos.push(currServ.scripts[i].filename); + } + for (var i = 0; i < currServ.programs.length; ++i) { + allPos.push(currServ.programs[i]); + } + for (var i = 0; i < currServ.messages.length; ++i) { + if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["isString"])(currServ.messages[i]) && + currServ.messages[i].endsWith(".lit")) { + allPos.push(currServ.messages[i]); + } + } + for (var i = 0; i < currServ.textFiles.length; ++i) { + allPos.push(currServ.textFiles[i].fn); + } + return allPos; + } + + if (input.startsWith("run ")) { + //All programs and scripts + for (var i = 0; i < currServ.scripts.length; ++i) { + allPos.push(currServ.scripts[i].filename); + } + + //Programs are on home computer + var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getHomeComputer(); + for(var i = 0; i < homeComputer.programs.length; ++i) { + allPos.push(homeComputer.programs[i]); + } + return allPos; + } + + if (input.startsWith("cat ")) { + for (var i = 0; i < currServ.messages.length; ++i) { + if (currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) { + allPos.push(currServ.messages[i].filename); + } else { + allPos.push(currServ.messages[i]); + } + } + for (var i = 0; i < currServ.textFiles.length; ++i) { + allPos.push(currServ.textFiles[i].fn); + } + return allPos; + } + + if (input.startsWith("download ")) { + for (var i = 0; i < currServ.textFiles.length; ++i) { + allPos.push(currServ.textFiles[i].fn); + } + for (var i = 0; i < currServ.scripts.length; ++i) { + allPos.push(currServ.scripts[i].filename); + } + } + return allPos; +} + +let Terminal = { + //Flags to determine whether the player is currently running a hack or an analyze + hackFlag: false, + analyzeFlag: false, + + commandHistory: [], + commandHistoryIndex: 0, + + resetTerminalInput: function() { + document.getElementById("terminal-input-td").innerHTML = + "
[" + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname + " ~]" + "$
" + + ''; + var hdr = document.getElementById("terminal-input-header"); + hdr.style.display = "inline"; + }, + + modifyInput: function(mod) { + try { + var terminalInput = document.getElementById("terminal-input-text-box"); + if (terminalInput == null) {return;} + terminalInput.focus(); + + var inputLength = terminalInput.value.length; + var start = terminalInput.selectionStart; + var end = terminalInput.selectionEnd; + var inputText = terminalInput.value; + + switch(mod.toLowerCase()) { + case "backspace": + if (start > 0 && start <= inputLength+1) { + terminalInput.value = inputText.substr(0, start-1) + inputText.substr(start); + } + break; + case "deletewordbefore": //Delete rest of word before the cursor + for (var delStart = start-1; delStart > 0; --delStart) { + if (inputText.charAt(delStart) === " ") { + terminalInput.value = inputText.substr(0, delStart) + inputText.substr(start); + return; + } + } + break; + case "deletewordafter": //Delete rest of word after the cursor + for (var delStart = start+1; delStart <= text.length+1; ++delStart) { + if (inputText.charAt(delStart) === " ") { + terminalInput.value = inputText.substr(0, start) + inputText.substr(delStart); + return; + } + } + break; + case "clearafter": //Deletes everything after cursor + break; + case "clearbefore:": //Deleetes everything before cursor + break; + } + } catch(e) { + console.log("Exception in Terminal.modifyInput: " + e); + } + }, + + moveTextCursor: function(loc) { + try { + var terminalInput = document.getElementById("terminal-input-text-box"); + if (terminalInput == null) {return;} + terminalInput.focus(); + + var inputLength = terminalInput.value.length; + var start = terminalInput.selectionStart; + var end = terminalInput.selectionEnd; + + switch(loc.toLowerCase()) { + case "home": + terminalInput.setSelectionRange(0,0); + break; + case "end": + terminalInput.setSelectionRange(inputLength, inputLength); + break; + case "prevchar": + if (start > 0) {terminalInput.setSelectionRange(start-1, start-1);} + break; + case "prevword": + for (var i = start-2; i >= 0; --i) { + if (terminalInput.value.charAt(i) === " ") { + terminalInput.setSelectionRange(i+1, i+1); + return; + } + } + terminalInput.setSelectionRange(0, 0); + break; + case "nextchar": + terminalInput.setSelectionRange(start+1, start+1); + break; + case "nextword": + for (var i = start+1; i <= inputLength; ++i) { + if (terminalInput.value.charAt(i) === " ") { + terminalInput.setSelectionRange(i, i); + return; + } + } + terminalInput.setSelectionRange(inputLength, inputLength); + break; + default: + console.log("WARNING: Invalid loc argument in Terminal.moveTextCursor()"); + break; + } + } catch(e) { + console.log("Exception in Terminal.moveTextCursor: " + e); + } + }, + + getTimestamp: function() { + let d = new Date(); + return (d.getMonth() + "/" + d.getDay() + " " + d.getHours() + ":" + d.getMinutes()); + }, + + finishAction: function(cancelled = false) { + if (Terminal.hackFlag) { + Terminal.finishHack(cancelled); + } else if (Terminal.analyzeFlag) { + Terminal.finishAnalyze(cancelled); + } + }, + + //Complete the hack/analyze command + finishHack: function(cancelled = false) { + if (cancelled == false) { + var server = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + + //Calculate whether hack was successful + var hackChance = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingChance(); + var rand = Math.random(); + console.log("Hack success chance: " + hackChance + ", rand: " + rand); + var expGainedOnSuccess = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateExpGain(); + var expGainedOnFailure = (expGainedOnSuccess / 4); + if (rand < hackChance) { //Success! + if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerNames"].WorldDaemon] && + _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerNames"].WorldDaemon] == server.ip) { + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN == null) { + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN = 1; + } + Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_13__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN); + return; + } + server.manuallyHacked = true; + var moneyGained = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculatePercentMoneyHacked(); + moneyGained = Math.floor(server.moneyAvailable * moneyGained); + + if (moneyGained <= 0) {moneyGained = 0;} //Safety check + + server.moneyAvailable -= moneyGained; + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainMoney(moneyGained); + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainHackingExp(expGainedOnSuccess) + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainIntelligenceExp(expGainedOnSuccess / _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].IntelligenceTerminalHackBaseExpGain); + + server.fortify(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].ServerFortifyAmount); + + post("Hack successful! Gained $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(moneyGained, 2) + " and " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(expGainedOnSuccess, 4) + " hacking EXP"); + } else { //Failure + //Player only gains 25% exp for failure? TODO Can change this later to balance + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainHackingExp(expGainedOnFailure) + post("Failed to hack " + server.hostname + ". Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(expGainedOnFailure, 4) + " hacking EXP"); + } + } + + //Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal + $("#hack-progress-bar").attr('id', "old-hack-progress-bar"); + $("#hack-progress").attr('id', "old-hack-progress"); + Terminal.resetTerminalInput(); + $('input[class=terminal-input]').prop('disabled', false); + + Terminal.hackFlag = false; + }, + + finishAnalyze: function(cancelled = false) { + if (cancelled == false) { + post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname + ": "); + post("Organization name: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().organizationName); + var rootAccess = ""; + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights) {rootAccess = "YES";} + else {rootAccess = "NO";} + post("Root Access: " + rootAccess); + post("Required hacking skill: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().requiredHackingSkill); + post("Estimated server security level: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hackDifficulty, 5), 3)); + post("Estimated chance to hack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingChance() * 100, 5), 2) + "%"); + post("Estimated time to hack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingTime(), 5), 3) + " seconds"); + post("Estimated total money available on server: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().moneyAvailable, 5), 2)); + post("Required number of open ports for NUKE: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().numOpenPortsRequired); + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().sshPortOpen) { + post("SSH port: Open") + } else { + post("SSH port: Closed") + } + + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ftpPortOpen) { + post("FTP port: Open") + } else { + post("FTP port: Closed") + } + + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().smtpPortOpen) { + post("SMTP port: Open") + } else { + post("SMTP port: Closed") + } + + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().httpPortOpen) { + post("HTTP port: Open") + } else { + post("HTTP port: Closed") + } + + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().sqlPortOpen) { + post("SQL port: Open") + } else { + post("SQL port: Closed") + } + } + Terminal.analyzeFlag = false; + + //Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal + $("#hack-progress-bar").attr('id', "old-hack-progress-bar"); + $("#hack-progress").attr('id', "old-hack-progress"); + Terminal.resetTerminalInput(); + $('input[class=terminal-input]').prop('disabled', false); + }, + + executeCommand: function(command) { + command = command.trim(); + //Replace all extra whitespace in command with a single space + command = command.replace(/\s\s+/g, ' '); + + //Terminal history + if (Terminal.commandHistory[Terminal.commandHistory.length-1] != command) { + Terminal.commandHistory.push(command); + if (Terminal.commandHistory.length > 50) { + Terminal.commandHistory.splice(0, 1); + } + } + Terminal.commandHistoryIndex = Terminal.commandHistory.length; + + //Process any aliases + command = Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["substituteAliases"])(command); + + //Allow usage of ./ + if (command.startsWith("./")) { + command = "run " + command.slice(2); + } + + //Only split the first space + var commandArray = command.split(" "); + if (commandArray.length > 1) { + commandArray = [commandArray.shift(), commandArray.join(" ")]; + } + + if (commandArray.length == 0) {return;} + + /****************** Interactive Tutorial Terminal Commands ******************/ + if (_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialIsRunning"]) { + var foodnstuffServ = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["GetServerByHostname"])("foodnstuff"); + if (foodnstuffServ == null) {throw new Error("Could not get foodnstuff server"); return;} + + switch(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["currITutorialStep"]) { + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalHelp: + if (commandArray[0] == "help") { + post(_HelpText_js__WEBPACK_IMPORTED_MODULE_6__["TerminalHelpText"]); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalLs: + if (commandArray[0] == "ls") { + Terminal.executeListCommand(commandArray); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScan: + if (commandArray[0] == "scan") { + Terminal.executeScanCommand(commandArray); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScanAnalyze1: + if (commandArray.length == 1 && commandArray[0] == "scan-analyze") { + Terminal.executeScanAnalyzeCommand(1); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScanAnalyze2: + if (commandArray.length == 2 && commandArray[0] == "scan-analyze" && + commandArray[1] == "2") { + Terminal.executeScanAnalyzeCommand(2); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalConnect: + if (commandArray.length == 2) { + if ((commandArray[0] == "connect") && + (commandArray[1] == "foodnstuff" || commandArray[1] == foodnstuffServ.ip)) { + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false; + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = foodnstuffServ.ip; + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true; + post("Connected to foodnstuff"); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Wrong command! Try again!"); return;} + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalAnalyze: + if (commandArray[0] == "analyze") { + if (commandArray.length != 1) { + post("Incorrect usage of analyze command. Usage: analyze"); return; + } + //Analyze the current server for information + Terminal.analyzeFlag = true; + post("Analyzing system..."); + hackProgressPost("Time left:"); + hackProgressBarPost("["); + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].analyze(); + + //Disable terminal + //Terminal.resetTerminalInput(); + document.getElementById("terminal-input-td").innerHTML = ''; + $('input[class=terminal-input]').prop('disabled', true); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else { + post("Bad command. Please follow the tutorial"); + } + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalNuke: + if (commandArray.length == 2 && + commandArray[0] == "run" && commandArray[1] == "NUKE.exe") { + foodnstuffServ.hasAdminRights = true; + post("NUKE successful! Gained root access to foodnstuff"); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalManualHack: + if (commandArray.length == 1 && commandArray[0] == "hack") { + Terminal.hackFlag = true; + hackProgressPost("Time left:"); + hackProgressBarPost("["); + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hack(); + + //Disable terminal + //Terminal.resetTerminalInput(); + document.getElementById("terminal-input-td").innerHTML = ''; + $('input[class=terminal-input]').prop('disabled', true); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalCreateScript: + if (commandArray.length == 2 && + commandArray[0] == "nano" && commandArray[1] == "foodnstuff.script") { + _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent("foodnstuff.script", ""); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalFree: + if (commandArray.length == 1 && commandArray[0] == "free") { + Terminal.executeFreeCommand(commandArray); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalRunScript: + if (commandArray.length == 2 && + commandArray[0] == "run" && commandArray[1] == "foodnstuff.script") { + Terminal.runScript("foodnstuff.script"); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].ActiveScriptsToTerminal: + if (commandArray.length == 2 && + commandArray[0] == "tail" && commandArray[1] == "foodnstuff.script") { + //Check that the script exists on this machine + var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])("foodnstuff.script", [], _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer()); + if (runningScript == null) { + post("Error: No such script exists"); + return; + } + Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__["logBoxCreate"])(runningScript); + Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); + } else {post("Bad command. Please follow the tutorial");} + break; + default: + post("Please follow the tutorial, or click 'Exit Tutorial' if you'd like to skip it"); + return; + } + return; + } + + /****************** END INTERACTIVE TUTORIAL ******************/ + + /* Command parser */ + var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + switch (commandArray[0].toLowerCase()) { + case "alias": + if (commandArray.length == 1) { + Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["printAliases"])(); + return; + } + if (commandArray.length == 2) { + if (commandArray[1].startsWith("-g ")) { + var alias = commandArray[1].substring(3); + if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["parseAliasDeclaration"])(alias, true)) { + return; + } + } else { + if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["parseAliasDeclaration"])(commandArray[1])) { + return; + } + } + } + post('Incorrect usage of alias command. Usage: alias [-g] [aliasname="value"]'); + break; + case "analyze": + if (commandArray.length != 1) { + post("Incorrect usage of analyze command. Usage: analyze"); return; + } + //Analyze the current server for information + Terminal.analyzeFlag = true; + post("Analyzing system..."); + hackProgressPost("Time left:"); + hackProgressBarPost("["); + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].analyze(); + + //Disable terminal + //Terminal.resetTerminalInput(); + document.getElementById("terminal-input-td").innerHTML = ''; + $('input[class=terminal-input]').prop('disabled', true); + break; + case "buy": + if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"].hasOwnProperty("Darkweb Server")) { + Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__["executeDarkwebTerminalCommand"])(commandArray); + } else { + post("You need to be able to connect to the Dark Web to use the buy command. (Maybe there's a TOR router you can buy somewhere)"); + } + break; + case "cat": + if (commandArray.length != 2) { + post("Incorrect usage of cat command. Usage: cat [file]"); return; + } + var filename = commandArray[1]; + if (!filename.endsWith(".msg") && !filename.endsWith(".lit") && !filename.endsWith(".txt")) { + post("Error: Only .msg, .txt, and .lit files are viewable with cat (filename must end with .msg, .txt, or .lit)"); return; + } + for (var i = 0; i < s.messages.length; ++i) { + if (filename.endsWith(".lit") && s.messages[i] == filename) { + Object(_Literature_js__WEBPACK_IMPORTED_MODULE_8__["showLiterature"])(s.messages[i]); + return; + } else if (filename.endsWith(".msg") && s.messages[i].filename == filename) { + Object(_Message_js__WEBPACK_IMPORTED_MODULE_9__["showMessage"])(s.messages[i]); + return; + } + } + for (var i = 0; i < s.textFiles.length; ++i) { + if (s.textFiles[i].fn === filename) { + s.textFiles[i].show(); + return; + } + } + post("Error: No such file " + filename); + break; + case "check": + if (commandArray.length < 2) { + post("Incorrect number of arguments. Usage: check [script] [arg1] [arg2]..."); + } else { + var results = commandArray[1].split(" "); + var scriptName = results[0]; + var args = []; + for (var i = 1; i < results.length; ++i) { + args.push(results[i]); + } + + //Can only tail script files + if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(scriptName) == false) { + post("Error: tail can only be called on .script files (filename must end with .script)"); return; + } + + //Check that the script exists on this machine + var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s); + if (runningScript == null) { + post("Error: No such script exists"); + return; + } + runningScript.displayLog(); + } + break; + case "clear": + case "cls": + if (commandArray.length != 1) { + post("Incorrect usage of clear/cls command. Usage: clear/cls"); return; + } + $("#terminal tr:not(:last)").remove(); + postNetburnerText(); + break; + case "connect": + //Disconnect from current server in terminal and connect to new one + if (commandArray.length != 2) { + post("Incorrect usage of connect command. Usage: connect [ip/hostname]"); + return; + } + + var ip = commandArray[1]; + + for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().serversOnNetwork.length; i++) { + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip == ip || _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).hostname == ip) { + Terminal.connectToServer(ip); + return; + } + } + + post("Host not found"); + break; + case "download": + if (commandArray.length != 2) { + post("Incorrect usage of download command. Usage: download [text file]"); + return; + } + var fn = commandArray[1]; + if (fn === "*" || fn === "*.script" || fn === "*.txt") { + //Download all scripts as a zip + var zip = new jszip__WEBPACK_IMPORTED_MODULE_23__(); + if (fn === "*" || fn === "*.script") { + for (var i = 0; i < s.scripts.length; ++i) { + var file = new Blob([s.scripts[i].code], {type:"text/plain"}); + zip.file(s.scripts[i].filename + ".js", file); + } + } + if (fn === "*" || fn === "*.txt") { + for (var i = 0; i < s.textFiles.length; ++i) { + var file = new Blob([s.textFiles[i].text], {type:"text/plain"}); + zip.file(s.textFiles[i].fn, file); + } + } + + var filename; + switch (fn) { + case "*.script": + filename = "bitburnerScripts.zip"; break; + case "*.txt": + filename = "bitburnerTexts.zip"; break; + default: + filename = "bitburnerFiles.zip"; break; + } + + zip.generateAsync({type:"blob"}).then(function(content) { + file_saver__WEBPACK_IMPORTED_MODULE_24__["saveAs"](content, filename); + }); + return; + } else if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(fn)) { + //Download a single script + for (var i = 0; i < s.scripts.length; ++i) { + if (s.scripts[i].filename === fn) { + return s.scripts[i].download(); + } + } + } else if (fn.endsWith(".txt")) { + //Download a single text file + var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_18__["getTextFile"])(fn, s); + if (txtFile !== null) { + return txtFile.download(); + } + } + post("Error: " + fn + " does not exist"); + break; + case "free": + Terminal.executeFreeCommand(commandArray); + break; + case "hack": + if (commandArray.length != 1) { + post("Incorrect usage of hack command. Usage: hack"); return; + } + //Hack the current PC (usually for money) + //You can't hack your home pc or servers you purchased + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().purchasedByPlayer) { + post("Cannot hack your own machines! You are currently connected to your home PC or one of your purchased servers"); + } else if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights == false ) { + post("You do not have admin rights for this machine! Cannot hack"); + } else if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().requiredHackingSkill > _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hacking_skill) { + post("Your hacking skill is not high enough to attempt hacking this machine. Try analyzing the machine to determine the required hacking skill"); + } else { + Terminal.hackFlag = true; + hackProgressPost("Time left:"); + hackProgressBarPost("["); + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hack(); + + //Disable terminal + //Terminal.resetTerminalInput(); + document.getElementById("terminal-input-td").innerHTML = ''; + $('input[class=terminal-input]').prop('disabled', true); + } + break; + case "help": + if (commandArray.length != 1 && commandArray.length != 2) { + post("Incorrect usage of help command. Usage: help"); return; + } + if (commandArray.length == 1) { + post(_HelpText_js__WEBPACK_IMPORTED_MODULE_6__["TerminalHelpText"]); + } else { + var cmd = commandArray[1]; + var txt = _HelpText_js__WEBPACK_IMPORTED_MODULE_6__["HelpTexts"][cmd]; + if (txt == null) { + post("Error: No help topics match '" + cmd + "'"); + return; + } + post(txt); + } + break; + case "home": + if (commandArray.length != 1) { + post("Incorrect usage of home command. Usage: home"); return; + } + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false; + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getHomeComputer().ip; + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true; + post("Connected to home"); + Terminal.resetTerminalInput(); + break; + case "hostname": + if (commandArray.length != 1) { + post("Incorrect usage of hostname command. Usage: hostname"); return; + } + //Print the hostname of current system + post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname); + break; + case "ifconfig": + if (commandArray.length != 1) { + post("Incorrect usage of ifconfig command. Usage: ifconfig"); return; + } + //Print the IP address of the current system + post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ip); + break; + case "kill": + if (commandArray.length < 2) { + post("Incorrect usage of kill command. Usage: kill [scriptname] [arg1] [arg2]..."); return; + } + var results = commandArray[1].split(" "); + var scriptName = results[0]; + var args = []; + for (var i = 1; i < results.length; ++i) { + args.push(results[i]); + } + var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s); + if (runningScript == null) { + post("No such script is running. Nothing to kill"); + return; + } + Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["killWorkerScript"])(runningScript, s.ip); + post("Killing " + scriptName + ". May take up to a few minutes for the scripts to die..."); + break; + case "killall": + for (var i = s.runningScripts.length-1; i >= 0; --i) { + Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["killWorkerScript"])(s.runningScripts[i], s.ip); + } + post("Killing all running scripts. May take up to a few minutes for the scripts to die..."); + break; + case "ls": + Terminal.executeListCommand(commandArray); + break; + case "lscpu": + post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().cpuCores + " Core(s)"); + break; + case "mem": + if (commandArray.length != 2) { + post("Incorrect usage of mem command. usage: mem [scriptname] [-t] [number threads]"); return; + } + var scriptName = commandArray[1]; + var numThreads = 1; + if (scriptName.indexOf(" -t ") != -1) { + var results = scriptName.split(" "); + if (results.length != 3) { + post("Invalid use of run command. Usage: mem [script] [-t] [number threads]"); + return; + } + numThreads = Math.round(Number(results[2])); + if (isNaN(numThreads) || numThreads < 1) { + post("Invalid number of threads specified. Number of threads must be greater than 1"); + return; + } + scriptName = results[0]; + } + + var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + for (var i = 0; i < currServ.scripts.length; ++i) { + if (scriptName == currServ.scripts[i].filename) { + var scriptBaseRamUsage = currServ.scripts[i].ramUsage; + var ramUsage = scriptBaseRamUsage * numThreads * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, numThreads-1); + + post("This script requires " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(ramUsage, 2) + "GB of RAM to run for " + numThreads + " thread(s)"); + return; + } + } + post("ERR: No such script exists!"); + break; + case "nano": + if (commandArray.length != 2) { + post("Incorrect usage of nano command. Usage: nano [scriptname]"); return; + } + + var filename = commandArray[1]; + if (filename === ".fconf") { + var text = Object(_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["createFconf"])(); + _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, text); + return; + } else if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(filename)) { + for (var i = 0; i < s.scripts.length; i++) { + if (filename == s.scripts[i].filename) { + _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, s.scripts[i].code); + return; + } + } + } else if (filename.endsWith(".txt")) { + for (var i = 0; i < s.textFiles.length; ++i) { + if (filename === s.textFiles[i].fn) { + _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, s.textFiles[i].text); + return; + } + } + } else { + post("Error: Invalid file. Only scripts (.script), text files (.txt), or .fconf can be edited with nano"); return; + } + _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename); + break; + case "ps": + if (commandArray.length != 1) { + post("Incorrect usage of ps command. Usage: ps"); return; + } + for (var i = 0; i < s.runningScripts.length; i++) { + var rsObj = s.runningScripts[i]; + var res = rsObj.filename; + for (var j = 0; j < rsObj.args.length; ++j) { + res += (" " + rsObj.args[j].toString()); + } + post(res); + } + break; + case "rm": + if (commandArray.length != 2) { + post("Incorrect number of arguments. Usage: rm [program/script]"); return; + } + + //Check programs + var delTarget = commandArray[1]; + + if (delTarget.includes(".exe")) { + for (var i = 0; i < s.programs.length; ++i) { + if (s.programs[i] == delTarget) { + s.programs.splice(i, 1); + return; + } + } + } else if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(delTarget)) { + for (var i = 0; i < s.scripts.length; ++i) { + if (s.scripts[i].filename == delTarget) { + //Check that the script isnt currently running + for (var j = 0; j < s.runningScripts.length; ++j) { + if (s.runningScripts[j].filename == delTarget) { + post("Cannot delete a script that is currently running!"); + return; + } + } + s.scripts.splice(i, 1); + return; + } + } + } else if (delTarget.endsWith(".lit")) { + for (var i = 0; i < s.messages.length; ++i) { + var f = s.messages[i]; + if (!(f instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["isString"])(f) && f === delTarget) { + s.messages.splice(i, 1); + return; + } + } + } else if (delTarget.endsWith(".txt")) { + for (var i = 0; i < s.textFiles.length; ++i) { + if (s.textFiles[i].fn === delTarget) { + s.textFiles.splice(i, 1); + return; + } + } + } + post("Error: No such file exists"); + break; + case "run": + //Run a program or a script + if (commandArray.length != 2) { + post("Incorrect number of arguments. Usage: run [program/script] [-t] [num threads] [arg1] [arg2]..."); + } else { + var executableName = commandArray[1]; + + //Secret Music player! + if (executableName === "musicplayer") { + post('', false); + return; + } + + //Check if its a script or just a program/executable + //if (isScriptFilename(executableName)) { + if (executableName.includes(".script") || executableName.includes(".js") || executableName.includes(".ns")) { + Terminal.runScript(executableName); + } else { + Terminal.runProgram(executableName); + } + } + break; + case "scan": + Terminal.executeScanCommand(commandArray); + break; + case "scan-analyze": + if (commandArray.length == 1) { + Terminal.executeScanAnalyzeCommand(1); + } else if (commandArray.length == 2) { + var all = false; + if (commandArray[1].endsWith("-a")) { + all = true; + commandArray[1] = commandArray[1].replace("-a", ""); + } + var depth; + if (commandArray[1].length === 0) { + depth = 1; + } else { + depth = Number(commandArray[1]); + } + if (isNaN(depth) || depth < 0) { + post("Incorrect usage of scan-analyze command. depth argument must be positive numeric"); + return; + } + if (depth > 3 && !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1) && + !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2)) { + post("You cannot scan-analyze with that high of a depth. Maximum depth is 3"); + return; + } else if (depth > 5 && !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2)) { + post("You cannot scan-analyze with that high of a depth. Maximum depth is 5"); + return; + } else if (depth > 10) { + post("You cannot scan-analyze with that high of a depth. Maximum depth is 10"); + return; + } + Terminal.executeScanAnalyzeCommand(depth, all); + } else { + post("Incorrect usage of scan-analyze command. usage: scan-analyze [depth]"); + } + break; + case "scp": + if (commandArray.length != 2) { + post("Incorrect usage of scp command. Usage: scp [file] [destination hostname/ip]"); + return; + } + var args = commandArray[1].split(" "); + if (args.length != 2) { + post("Incorrect usage of scp command. Usage: scp [file] [destination hostname/ip]"); + return; + } + var scriptname = args[0]; + if (!scriptname.endsWith(".lit") && !Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(scriptName) && + !scriptname.endsWith(".txt")){ + post("Error: scp only works for .script, .txt, and .lit files"); + return; + } + var destServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(args[1]); + if (destServer == null) { + post("Invalid destination. " + args[1] + " not found"); + return; + } + var ip = destServer.ip; + var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + + //Scp for lit files + if (scriptname.endsWith(".lit")) { + var found = false; + for (var i = 0; i < currServ.messages.length; ++i) { + if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && currServ.messages[i] == scriptname) { + found = true; + break; + } + } + + if (!found) {return post("Error: no such file exists!");} + + for (var i = 0; i < destServer.messages.length; ++i) { + if (destServer.messages[i] === scriptname) { + post(scriptname + " copied over to " + destServer.hostname); + return; //Already exists + } + } + destServer.messages.push(scriptname); + post(scriptname + " copied over to " + destServer.hostname); + return; + } + + //Scp for txt files + if (scriptname.endsWith(".txt")) { + var found = false, txtFile; + for (var i = 0; i < currServ.textFiles.length; ++i) { + if (currServ.textFiles[i].fn === scriptname) { + found = true; + txtFile = currServ.textFiles[i]; + break; + } + } + + if (!found) {return post("Error: no such file exists!");} + + for (var i = 0; i < destServer.textFiles.length; ++i) { + if (destServer.textFiles[i].fn === scriptname) { + //Overwrite + destServer.textFiles[i].text = txtFile.text; + post("WARNING: " + scriptname + " already exists on " + destServer.hostname + + "and will be overwriten"); + return post(scriptname + " copied over to " + destServer.hostname); + } + } + var newFile = new _TextFile_js__WEBPACK_IMPORTED_MODULE_18__["TextFile"](txtFile.fn, txtFile.text); + destServer.textFiles.push(newFile); + return post(scriptname + " copied over to " + destServer.hostname); + } + + //Get the current script + var sourceScript = null; + for (var i = 0; i < currServ.scripts.length; ++i) { + if (scriptname == currServ.scripts[i].filename) { + sourceScript = currServ.scripts[i]; + break; + } + } + if (sourceScript == null) { + post("ERROR: scp() failed. No such script exists"); + return; + } + + //Overwrite script if it exists + for (var i = 0; i < destServer.scripts.length; ++i) { + if (scriptname == destServer.scripts[i].filename) { + post("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and will be overwritten"); + var oldScript = destServer.scripts[i]; + oldScript.code = sourceScript.code; + oldScript.ramUsage = sourceScript.ramUsage; + post(scriptname + " overwriten on " + destServer.hostname); + return; + } + } + + var newScript = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["Script"](); + newScript.filename = scriptname; + newScript.code = sourceScript.code; + newScript.ramUsage = sourceScript.ramUsage; + newScript.destServer = ip; + destServer.scripts.push(newScript); + post(scriptname + " copied over to " + destServer.hostname); + break; + case "sudov": + if (commandArray.length != 1) { + post("Incorrect number of arguments. Usage: sudov"); return; + } + + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights) { + post("You have ROOT access to this machine"); + } else { + post("You do NOT have root access to this machine"); + } + break; + case "tail": + if (commandArray.length < 2) { + post("Incorrect number of arguments. Usage: tail [script] [arg1] [arg2]..."); + } else { + var results = commandArray[1].split(" "); + var scriptName = results[0]; + var args = []; + for (var i = 1; i < results.length; ++i) { + args.push(results[i]); + } + + //Can only tail script files + if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(scriptName) == false) { + post("Error: tail can only be called on .script files (filename must end with .script)"); return; + } + + //Check that the script exists on this machine + var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s); + if (runningScript == null) { + post("Error: No such script exists"); + return; + } + Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__["logBoxCreate"])(runningScript); + } + break; + case "theme": + //todo support theme saving + var args = commandArray[1] ? commandArray[1].split(" ") : []; + if (args.length != 1 && args.length != 3) { + post("Incorrect number of arguments."); + post("Usage: theme [default|muted|solarized] | #[background color hex] #[text color hex] #[highlight color hex]"); + } else if(args.length == 1){ + var themeName = args[0]; + if (themeName == "default"){ + document.body.style.setProperty('--my-highlight-color',"#ffffff"); + document.body.style.setProperty('--my-font-color',"#66ff33"); + document.body.style.setProperty('--my-background-color',"#000000"); + } else if (themeName == "muted"){ + document.body.style.setProperty('--my-highlight-color',"#ffffff"); + document.body.style.setProperty('--my-font-color',"#66ff33"); + document.body.style.setProperty('--my-background-color',"#252527"); + } else if (themeName == "solarized"){ + document.body.style.setProperty('--my-highlight-color',"#6c71c4"); + document.body.style.setProperty('--my-font-color',"#839496"); + document.body.style.setProperty('--my-background-color',"#002b36"); + } else { + return post("Theme not found"); + } + _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeHighlightColor = document.body.style.getPropertyValue("--my-highlight-color"); + _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeFontColor = document.body.style.getPropertyValue("--my-font-color"); + _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeBackgroundColor = document.body.style.getPropertyValue("--my-background-color"); + } else { + var inputBackgroundHex = args[0]; + var inputTextHex = args[1]; + var inputHighlightHex = args[2]; + if (/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputBackgroundHex) && + /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputTextHex) && + /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputHighlightHex)){ + document.body.style.setProperty('--my-highlight-color',inputHighlightHex); + document.body.style.setProperty('--my-font-color',inputTextHex); + document.body.style.setProperty('--my-background-color',inputBackgroundHex); + _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeHighlightColor = document.body.style.getPropertyValue("--my-highlight-color"); + _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeFontColor = document.body.style.getPropertyValue("--my-font-color"); + _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeBackgroundColor = document.body.style.getPropertyValue("--my-background-color"); + } else { + return post("Invalid Hex Input for theme"); + } + } + break; + case "top": + if(commandArray.length != 1) { + post("Incorrect usage of top command. Usage: top"); return; + } + + post("Script Threads RAM Usage"); + + var currRunningScripts = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().runningScripts; + //Iterate through scripts on current server + for(var i = 0; i < currRunningScripts.length; i++) { + var script = currRunningScripts[i]; + + //Calculate name padding + var numSpacesScript = 32 - script.filename.length; //26 -> width of name column + if (numSpacesScript < 0) {numSpacesScript = 0;} + var spacesScript = Array(numSpacesScript+1).join(" "); + + //Calculate thread padding + var numSpacesThread = 16 - (script.threads + "").length; //16 -> width of thread column + var spacesThread = Array(numSpacesThread+1).join(" "); + + //Calculate and transform RAM usage + ramUsage = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(script.scriptRef.ramUsage * script.threads, 2).toString() + "GB"; + + var entry = [script.filename, spacesScript, script.threads, spacesThread, ramUsage]; + post(entry.join("")); + } + break; + case "unalias": + if (commandArray.length != 2) { + post('Incorrect usage of unalias name. Usage: unalias "[alias]"'); + return; + } else if (!(commandArray[1].startsWith('"') && commandArray[1].endsWith('"'))) { + post('Incorrect usage of unalias name. Usage: unalias "[alias]"'); + } else { + var alias = commandArray[1].slice(1, -1); + if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["removeAlias"])(alias)) { + post("Removed alias " + alias); + } else { + post("No such alias exists"); + } + } + break; + default: + post("Command not found"); + } + }, + + connectToServer: function(ip) { + console.log("Connect to server called"); + var serv = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(ip); + if (serv == null) { + post("Invalid server. Connection failed."); + return; + } + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false; + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = serv.ip; + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true; + post("Connected to " + serv.hostname); + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname == "darkweb") { + Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__["checkIfConnectedToDarkweb"])(); //Posts a 'help' message if connecting to dark web + } + Terminal.resetTerminalInput(); + }, + + executeListCommand: function(commandArray) { + if (commandArray.length != 1 && commandArray.length != 2) { + post("Incorrect usage of ls command. Usage: ls [| grep pattern]"); return; + } + + //grep + var filter = null; + if (commandArray.length == 2) { + if (commandArray[1].startsWith("| grep ")) { + var pattern = commandArray[1].replace("| grep ", ""); + if (pattern != " ") { + filter = pattern; + } + } else { + post("Incorrect usage of ls command. Usage: ls [| grep pattern]"); return; + } + } + + //Display all programs and scripts + var allFiles = []; + + //Get all of the programs and scripts on the machine into one temporary array + var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + for (var i = 0; i < s.programs.length; i++) { + if (filter) { + if (s.programs[i].includes(filter)) { + allFiles.push(s.programs[i]); + } + } else { + allFiles.push(s.programs[i]); + } + } + for (var i = 0; i < s.scripts.length; i++) { + if (filter) { + if (s.scripts[i].filename.includes(filter)) { + allFiles.push(s.scripts[i].filename); + } + } else { + allFiles.push(s.scripts[i].filename); + } + + } + for (var i = 0; i < s.messages.length; i++) { + if (filter) { + if (s.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) { + if (s.messages[i].filename.includes(filter)) { + allFiles.push(s.messages[i].filename); + } + } else if (s.messages[i].includes(filter)) { + allFiles.push(s.messages[i]); + } + } else { + if (s.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) { + allFiles.push(s.messages[i].filename); + } else { + allFiles.push(s.messages[i]); + } + } + } + for (var i = 0; i < s.textFiles.length; ++i) { + if (filter) { + if (s.textFiles[i].fn.includes(filter)) { + allFiles.push(s.textFiles[i].fn); + } + } else { + allFiles.push(s.textFiles[i].fn); + } + } + + //Sort the files alphabetically then print each + allFiles.sort(); + + for (var i = 0; i < allFiles.length; i++) { + post(allFiles[i]); + } + }, + + executeScanCommand: function(commandArray) { + if (commandArray.length != 1) { + post("Incorrect usage of netstat/scan command. Usage: netstat/scan"); return; + } + //Displays available network connections using TCP + post("Hostname IP Root Access"); + for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().serversOnNetwork.length; i++) { + //Add hostname + var entry = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i); + if (entry == null) {continue;} + entry = entry.hostname; + + //Calculate padding and add IP + var numSpaces = 21 - entry.length; + var spaces = Array(numSpaces+1).join(" "); + entry += spaces; + entry += _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip; + + //Calculate padding and add root access info + var hasRoot; + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).hasAdminRights) { + hasRoot = 'Y'; + } else { + hasRoot = 'N'; + } + numSpaces = 21 - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip.length; + spaces = Array(numSpaces+1).join(" "); + entry += spaces; + entry += hasRoot; + post(entry); + } + }, + + executeScanAnalyzeCommand: function(depth=1, all=false) { + //We'll use the AllServersMap as a visited() array + //TODO Using array as stack for now, can make more efficient + post("~~~~~~~~~~ Beginning scan-analyze ~~~~~~~~~~"); + post(" "); + var visited = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["AllServersMap"](); + + var stack = []; + var depthQueue = [0]; + var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + stack.push(currServ); + while(stack.length != 0) { + var s = stack.pop(); + var d = depthQueue.pop(); + if (!all && s.purchasedByPlayer && s.hostname != "home") { + continue; //Purchased server + } else if (visited[s.ip] || d > depth) { + continue; //Already visited or out-of-depth + } else { + visited[s.ip] = 1; + } + for (var i = s.serversOnNetwork.length-1; i >= 0; --i) { + stack.push(s.getServerOnNetwork(i)); + depthQueue.push(d+1); + } + if (d == 0) {continue;} //Don't print current server + var titleDashes = Array((d-1) * 4 + 1).join("-"); + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].AutoLink)) { + post("" + titleDashes + "> " + s.hostname + "", false); + } else { + post("" + titleDashes + ">" + s.hostname + ""); + } + + var dashes = titleDashes + "--"; + //var dashes = Array(d * 2 + 1).join("-"); + var c = "NO"; + if (s.hasAdminRights) {c = "YES";} + post(dashes + "Root Access: " + c + ", Required hacking skill: " + s.requiredHackingSkill); + post(dashes + "Number of open ports required to NUKE: " + s.numOpenPortsRequired); + post(dashes + "RAM: " + s.maxRam); + post(" "); + } + + var links = document.getElementsByClassName("scan-analyze-link"); + for (var i = 0; i < links.length; ++i) { + (function() { + var hostname = links[i].innerHTML.toString(); + links[i].onclick = function() { + if (Terminal.analyzeFlag || Terminal.hackFlag) {return;} + Terminal.connectToServer(hostname); + } + }());//Immediate invocation + } + + }, + + executeFreeCommand: function(commandArray) { + if (commandArray.length != 1) { + post("Incorrect usage of free command. Usage: free"); return; + } + post("Total: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().maxRam, 2) + " GB"); + post("Used: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ramUsed, 2) + " GB"); + post("Available: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().maxRam - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ramUsed, 2) + " GB"); + }, + + //First called when the "run [program]" command is called. Checks to see if you + //have the executable and, if you do, calls the executeProgram() function + runProgram: function(programName) { + //Check if you have the program on your computer. If you do, execute it, otherwise + //display an error message + var splitArgs = programName.split(" "); + var name = " "; + if (splitArgs.length > 1) { + name = splitArgs[0]; + } else { + name = programName; + } + if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(name)) { + Terminal.executeProgram(programName); + return; + } + post("ERROR: No such executable on home computer (Only programs that exist on your home computer can be run)"); + }, + + //Contains the implementations of all possible programs + executeProgram: function(programName) { + var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + var splitArgs = programName.split(" "); + if (splitArgs.length > 1) { + programName = splitArgs[0]; + } + switch (programName) { + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].NukeProgram: + if (s.hasAdminRights) { + post("You already have root access to this computer. There is no reason to run NUKE.exe"); + } else { + if (s.openPortCount >= _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().numOpenPortsRequired) { + s.hasAdminRights = true; + post("NUKE successful! Gained root access to " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname); + //TODO Make this take time rather than be instant + } else { + post("NUKE unsuccessful. Not enough ports have been opened"); + } + } + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BruteSSHProgram: + if (s.sshPortOpen) { + post("SSH Port (22) is already open!"); + } else { + s.sshPortOpen = true; + post("Opened SSH Port(22)!") + ++s.openPortCount; + } + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].FTPCrackProgram: + if (s.ftpPortOpen) { + post("FTP Port (21) is already open!"); + } else { + s.ftpPortOpen = true; + post("Opened FTP Port (21)!"); + ++s.openPortCount; + } + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].RelaySMTPProgram: + if (s.smtpPortOpen) { + post("SMTP Port (25) is already open!"); + } else { + s.smtpPortOpen = true; + post("Opened SMTP Port (25)!"); + ++s.openPortCount; + } + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].HTTPWormProgram: + if (s.httpPortOpen) { + post("HTTP Port (80) is already open!"); + } else { + s.httpPortOpen = true; + post("Opened HTTP Port (80)!"); + ++s.openPortCount; + } + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].SQLInjectProgram: + if (s.sqlPortOpen) { + post("SQL Port (1433) is already open!"); + } else { + s.sqlPortOpen = true; + post("Opened SQL Port (1433)!"); + ++s.openPortCount; + } + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].ServerProfiler: + if (splitArgs.length != 2) { + post("Must pass a server hostname or IP as an argument for ServerProfiler.exe"); + return; + } + var serv = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(splitArgs[1]); + if (serv == null) { + post("Invalid server IP/hostname"); + return; + } + post(serv.hostname + ":"); + post("Server base security level: " + serv.baseDifficulty); + post("Server current security level: " + serv.hackDifficulty); + post("Server growth rate: " + serv.serverGrowth); + post("Netscript hack() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateHackingTime"])(serv), 1) + "s"); + post("Netscript grow() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateGrowTime"])(serv)/1000, 1) + "s"); + post("Netscript weaken() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateWeakenTime"])(serv)/1000, 1) + "s"); + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].AutoLink: + post("This executable cannot be run."); + post("AutoLink.exe lets you automatically connect to other servers when using 'scan-analyze'."); + post("When using scan-analyze, click on a server's hostname to connect to it."); + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1: + post("This executable cannot be run."); + post("DeepscanV1.exe lets you run 'scan-analyze' with a depth up to 5."); + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2: + post("This executable cannot be run."); + post("DeepscanV2.exe lets you run 'scan-analyze' with a depth up to 10."); + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].Flight: + post("Augmentations: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].augmentations.length + " / 30"); + post("Money: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].money.toNumber(), 2) + " / $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(100000000000, 2)); + post("One path below must be fulfilled..."); + post("----------HACKING PATH----------"); + post("Hacking skill: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hacking_skill + " / 2500"); + post("----------COMBAT PATH----------"); + post("Strength: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].strength + " / 1500"); + post("Defense: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].defense + " / 1500"); + post("Dexterity: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].dexterity + " / 1500"); + post("Agility: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].agility + " / 1500"); + break; + case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BitFlume: + var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxGetYesButton"])(), + noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxGetNoButton"])(); + yesBtn.innerHTML = "Travel to BitNode Nexus"; + noBtn.innerHTML = "Cancel"; + yesBtn.addEventListener("click", function() { + Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_13__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN, true); + return Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxClose"])(); + }); + noBtn.addEventListener("click", function() { + return Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxClose"])(); + }); + Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxCreate"])("WARNING: USING THIS PROGRAM WILL CAUSE YOU TO LOSE ALL OF YOUR PROGRESS ON THE CURRENT BITNODE.

" + + "Do you want to travel to the BitNode Nexus? This allows you to reset the current BitNode " + + "and select a new one."); + + break; + default: + post("Invalid executable. Cannot be run"); + return; + } + }, + + runScript: function(scriptName) { + var server = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); + + var numThreads = 1; + var args = []; + var results = scriptName.split(" "); + if (results.length <= 0) { + post("This is a bug. Please contact developer"); + } + scriptName = results[0]; + if (results.length > 1) { + if (results.length >= 3 && results[1] == "-t") { + numThreads = Math.round(Number(results[2])); + if (isNaN(numThreads) || numThreads < 1) { + post("Invalid number of threads specified. Number of threads must be greater than 0"); + return; + } + for (var i = 3; i < results.length; ++i) { + var arg = results[i]; + + //Forced string + if ((arg.startsWith("'") && arg.endsWith("'")) || + (arg.startsWith('"') && arg.endsWith('"'))) { + args.push(arg.slice(1, -1)); + continue; + } + //Number + var tempNum = Number(arg); + if (!isNaN(tempNum)) { + args.push(tempNum); + continue; + } + //Otherwise string + args.push(arg); + } + } else { + for (var i = 1; i < results.length; ++i) { + var arg = results[i]; + + //Forced string + if ((arg.startsWith("'") && arg.endsWith("'")) || + (arg.startsWith('"') && arg.endsWith('"'))) { + args.push(arg.slice(1, -1)); + continue; + } + //Number + var tempNum = Number(arg); + if (!isNaN(tempNum)) { + args.push(tempNum); + continue; + } + //Otherwise string + args.push(arg); + } + } + } + + + //Check if this script is already running + if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, server) != null) { + post("ERROR: This script is already running. Cannot run multiple instances"); + return; + } + + //Check if the script exists and if it does run it + for (var i = 0; i < server.scripts.length; i++) { + if (server.scripts[i].filename == scriptName) { + //Check for admin rights and that there is enough RAM availble to run + var script = server.scripts[i]; + var ramUsage = script.ramUsage * numThreads * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, numThreads-1); + var ramAvailable = server.maxRam - server.ramUsed; + + if (server.hasAdminRights == false) { + post("Need root access to run script"); + return; + } else if (ramUsage > ramAvailable){ + post("This machine does not have enough RAM to run this script with " + + numThreads + " threads. Script requires " + ramUsage + "GB of RAM"); + return; + } else { + //Able to run script + post("Running script with " + numThreads + " thread(s) and args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["printArray"])(args) + "."); + post("May take a few seconds to start up the process..."); + var runningScriptObj = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["RunningScript"](script, args); + runningScriptObj.threads = numThreads; + server.runningScripts.push(runningScriptObj); + + Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["addWorkerScript"])(runningScriptObj, server); + return; + } + } + } + + post("ERROR: No such script"); + } +}; + + + +/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 38))) + +/***/ }), +/* 19 */ /*!******************************!*\ !*** ./src/Augmentations.js ***! \******************************/ @@ -13432,7 +15508,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engine.js */ 5); /* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Faction.js */ 11); /* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 29); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _Prestige_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Prestige.js */ 57); /* harmony import */ var _SaveObject_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./SaveObject.js */ 46); @@ -16050,7 +18126,7 @@ function displaySourceFiles(listElement, sourceFiles) { /***/ }), -/* 19 */ +/* 20 */ /*!***********************!*\ !*** ./src/Crimes.js ***! \***********************/ @@ -16365,7 +18441,7 @@ function determineCrimeChanceHeist() { /***/ }), -/* 20 */ +/* 21 */ /*!********************************!*\ !*** ./src/NetscriptWorker.js ***! \********************************/ @@ -16389,8 +18465,8 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _NetscriptJSEvaluator_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptJSEvaluator.js */ 63); /* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptPort.js */ 45); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Settings.js */ 24); -/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/acorn.js */ 34); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Settings.js */ 23); +/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/acorn.js */ 35); /* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_9__); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); @@ -16445,6 +18521,7 @@ function prestigeWorkerScripts() { Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["deleteActiveScriptsItem"])(workerScripts[i]); workerScripts[i].env.stopFlag = true; } + Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])(); //Force UI to update workerScripts.length = 0; } @@ -16454,36 +18531,48 @@ function prestigeWorkerScripts() { function startJsScript(workerScript) { workerScript.running = true; + // The name of the currently running netscript function, to prevent concurrent + // calls to hack, grow, etc. + let runningFn = null; + // We need to go through the environment and wrap each function in such a way that it // can be called at most once at a time. This will prevent situations where multiple // hack promises are outstanding, for example. function wrap(propName, f) { - let running = null; // The name of the currently running netscript function. // This function unfortunately cannot be an async function, because we don't // know if the original one was, and there's no way to tell. return function (...args) { + // Wrap every netscript function with a check for the stop flag. + // This prevents cases where we never stop because we are only calling + // netscript functions that don't check this. + // This is not a problem for legacy Netscript because it also checks the + // stop flag in the evaluator. + if (workerScript.env.stopFlag) {throw workerScript;} + + if (propName === "sleep") return f(...args); // OK for multiple simultaneous calls to sleep. + const msg = "Concurrent calls to Netscript functions not allowed! " + "Did you forget to await hack(), grow(), or some other " + "promise-returning function? (Currently running: %s tried to run: %s)" - if (running) { - workerScript.errorMessage = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["makeRuntimeRejectMsg"])(workerScript, sprintf(msg, running, propName), null) + if (runningFn) { + workerScript.errorMessage = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["makeRuntimeRejectMsg"])(workerScript, sprintf(msg, runningFn, propName), null) throw workerScript; } - running = propName; + runningFn = propName; let result = f(...args); if (result && result.finally !== undefined) { return result.finally(function () { - running = null; + runningFn = null; }); } else { - running = null; + runningFn = null; return result; } } }; + for (let prop in workerScript.env.vars) { if (typeof workerScript.env.vars[prop] !== "function") continue; - if (prop === "sleep") continue; // OK for multiple simultaneous calls to sleep. workerScript.env.vars[prop] = wrap(prop, workerScript.env.vars[prop]); } @@ -16496,7 +18585,8 @@ function startJsScript(workerScript) { return [mainReturnValue, workerScript]; }).catch(e => { if (e instanceof Error) { - workerScript.errorMessage = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["makeRuntimeRejectMsg"])(workerScript, e.message + (e.stack && ("\nstack:\n" + e.stack.toString()) || "")); + workerScript.errorMessage = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["makeRuntimeRejectMsg"])( + workerScript, e.message + (e.stack && ("\nstack:\n" + e.stack.toString()) || "")); throw workerScript; } else if (Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(e)) { workerScript.errorMessage = e; @@ -16679,7 +18769,7 @@ function updateOnlineScriptTimes(numCycles = 1) { /***/ }), -/* 21 */ +/* 22 */ /*!****************************!*\ !*** ./src/StockMarket.js ***! \****************************/ @@ -16713,7 +18803,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5); /* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Location.js */ 4); /* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 29); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); @@ -16736,7 +18826,8 @@ __webpack_require__.r(__webpack_exports__); -/* StockMarket.js */ +let StockPriceCap = 1e9; //Put a limit on how high a price can go + function Stock(name, symbol, mv, b, otlkMag, initPrice=10000) { this.symbol = symbol; this.name = name; @@ -17297,6 +19388,10 @@ function updateStockPrices() { chc = (chc - stock.otlkMag)/100; if (isNaN(chc)) {chc = 0.5;} } + if (stock.price >= StockPriceCap) { + chc = -1; //Limit on stock price + stock.b = false; + } var c = Math.random(); if (c < chc) { @@ -18054,2062 +20149,135 @@ function updateStockOrderList(stock) { /***/ }), -/* 22 */ +/* 23 */ /*!*************************!*\ - !*** ./src/Terminal.js ***! + !*** ./src/Settings.js ***! \*************************/ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; __webpack_require__.r(__webpack_exports__); -/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postNetburnerText", function() { return postNetburnerText; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "post", function() { return post; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Terminal", function() { return Terminal; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KEY", function() { return KEY; }); -/* harmony import */ var _Alias_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Alias.js */ 30); -/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3); -/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CreateProgram.js */ 14); -/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DarkWeb.js */ 33); -/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./engine.js */ 5); -/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 35); -/* harmony import */ var _HelpText_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./HelpText.js */ 72); -/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 25); -/* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Literature.js */ 53); -/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Message.js */ 28); -/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 7); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); -/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Player.js */ 0); -/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./RedPill.js */ 44); -/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Script.js */ 26); -/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Settings.js */ 24); -/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); -/* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./TextFile.js */ 41); -/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2); -/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); -/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../utils/LogBox.js */ 51); -/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12); -/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! jszip */ 121); -/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_23___default = /*#__PURE__*/__webpack_require__.n(jszip__WEBPACK_IMPORTED_MODULE_23__); -/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! file-saver */ 120); -/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(file_saver__WEBPACK_IMPORTED_MODULE_24__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Settings", function() { return Settings; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSettings", function() { return initSettings; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setSettingsLabels", function() { return setSettingsLabels; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadSettings", function() { return loadSettings; }); +/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.js */ 5); - - - - - - - - - - - - - - - - - - - - - - - - - - -/* Write text to terminal */ -//If replace is true then spaces are replaced with " " -function post(input) { - $("#terminal-input").before('' + input + ''); - updateTerminalScroll(); +/* Settings.js */ +let Settings = { + CodeInstructionRunTime: 50, + MaxLogCapacity: 50, + MaxPortCapacity: 50, + SuppressMessages: false, + SuppressFactionInvites: false, + AutosaveInterval: 60, + DisableHotkeys: false, + ThemeHighlightColor: "#ffffff", + ThemeFontColor: "#66ff33", + ThemeBackgroundColor: "#000000", + EditorTheme: "Monokai", + EditorKeybinding: "ace", } -//Same thing as post but the td cells have ids so they can be animated for the hack progress bar -function hackProgressBarPost(input) { - $("#terminal-input").before('' + input + ''); - updateTerminalScroll(); +function loadSettings(saveString) { + Settings = JSON.parse(saveString); } -function hackProgressPost(input) { - $("#terminal-input").before('' + input + ''); - updateTerminalScroll(); +function initSettings() { + Settings.CodeInstructionRunTime = 50; + Settings.MaxLogCapacity = 50; + Settings.MaxPortCapacity = 50; + Settings.SuppressMessages = false; + Settings.SuppressFactionInvites = false; + Settings.AutosaveInterval = 60; + Settings.DisableHotkeys = false; } -//Scroll to the bottom of the terminal's 'text area' -function updateTerminalScroll() { - var element = document.getElementById("terminal-container"); - element.scrollTop = element.scrollHeight; -} +function setSettingsLabels() { + var nsExecTime = document.getElementById("settingsNSExecTimeRangeValLabel"); + var nsLogLimit = document.getElementById("settingsNSLogRangeValLabel"); + var nsPortLimit = document.getElementById("settingsNSPortRangeValLabel"); + var suppressMsgs = document.getElementById("settingsSuppressMessages"); + var suppressFactionInv = document.getElementById("settingsSuppressFactionInvites") + var autosaveInterval = document.getElementById("settingsAutosaveIntervalValLabel"); + var disableHotkeys = document.getElementById("settingsDisableHotkeys"); -function postNetburnerText() { - post("Bitburner v" + _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].Version); -} + //Initialize values on labels + nsExecTime.innerHTML = Settings.CodeInstructionRunTime + "ms"; + nsLogLimit.innerHTML = Settings.MaxLogCapacity; + nsPortLimit.innerHTML = Settings.MaxPortCapacity; + 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"); + var nsLogRangeInput = document.getElementById("settingsNSLogRangeVal"); + var nsPortRangeInput = document.getElementById("settingsNSPortRangeVal"); + var nsAutosaveIntervalInput = document.getElementById("settingsAutosaveIntervalVal"); + nsExecTimeInput.value = Settings.CodeInstructionRunTime; + nsLogRangeInput.value = Settings.MaxLogCapacity; + nsPortRangeInput.value = Settings.MaxPortCapacity; + nsAutosaveIntervalInput.value = Settings.AutosaveInterval; -//Key Codes -var KEY = { - TAB: 9, - ENTER: 13, - CTRL: 17, - UPARROW: 38, - DOWNARROW: 40, - A: 65, - B: 66, - C: 67, - D: 68, - E: 69, - F: 70, - H: 72, - K: 75, - L: 76, - M: 77, - N: 78, - P: 80, - U: 85, - W: 87, -} + nsExecTimeInput.oninput = function() { + nsExecTime.innerHTML = this.value + 'ms'; + Settings.CodeInstructionRunTime = this.value; + }; -//Defines key commands in terminal -$(document).keydown(function(event) { - //Terminal - if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { - var terminalInput = document.getElementById("terminal-input-text-box"); - if (terminalInput != null && !event.ctrlKey && !event.shiftKey) {terminalInput.focus();} + nsLogRangeInput.oninput = function() { + nsLogLimit.innerHTML = this.value; + Settings.MaxLogCapacity = this.value; + }; - if (event.keyCode === KEY.ENTER) { - event.preventDefault(); //Prevent newline from being entered in Script Editor - var command = $('input[class=terminal-input]').val(); - if (command.length > 0) { - post("[" + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname + " ~]> " + command); + nsPortRangeInput.oninput = function() { + nsPortLimit.innerHTML = this.value; + Settings.MaxPortCapacity = this.value; + }; - Terminal.resetTerminalInput(); //Clear input first - Terminal.executeCommand(command); - } - } - - if (event.keyCode === KEY.C && event.ctrlKey) { - if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"]._actionInProgress) { - //Cancel action - post("Cancelling..."); - _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"]._actionInProgress = false; - Terminal.finishAction(true); - } else if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) { - //Dont prevent default so it still copies - Terminal.resetTerminalInput(); //Clear Terminal - } - } - - if (event.keyCode === KEY.L && event.ctrlKey) { - event.preventDefault(); - Terminal.executeCommand("clear"); //Clear screen + nsAutosaveIntervalInput.oninput = function() { + autosaveInterval.innerHTML = this.value; + Settings.AutosaveInterval = Number(this.value); + if (Number(this.value) === 0) { + _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = Infinity; + } else { + _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = Number(this.value) * 5; } + }; - //Ctrl p same as up arrow - //Ctrl n same as down arrow + suppressMsgs.onclick = function() { + Settings.SuppressMessages = this.checked; + }; - if (event.keyCode === KEY.UPARROW || - (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS && event.keyCode === KEY.P && event.ctrlKey)) { - if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) {event.preventDefault();} - //Cycle through past commands - if (terminalInput == null) {return;} - var i = Terminal.commandHistoryIndex; - var len = Terminal.commandHistory.length; + suppressFactionInv.onclick = function() { + Settings.SuppressFactionInvites = this.checked; + }; - if (len == 0) {return;} - if (i < 0 || i > len) { - Terminal.commandHistoryIndex = len; - } - - if (i != 0) { - --Terminal.commandHistoryIndex; - } - var prevCommand = Terminal.commandHistory[Terminal.commandHistoryIndex]; - terminalInput.value = prevCommand; - setTimeout(function(){terminalInput.selectionStart = terminalInput.selectionEnd = 10000; }, 0); - } - - if (event.keyCode === KEY.DOWNARROW || - (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS && event.keyCode === KEY.M && event.ctrlKey)) { - if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) {event.preventDefault();} - //Cycle through past commands - if (terminalInput == null) {return;} - var i = Terminal.commandHistoryIndex; - var len = Terminal.commandHistory.length; - - if (len == 0) {return;} - if (i < 0 || i > len) { - Terminal.commandHistoryIndex = len; - } - - //Latest command, put nothing - if (i == len || i == len-1) { - Terminal.commandHistoryIndex = len; - terminalInput.value = ""; - } else { - ++Terminal.commandHistoryIndex; - var prevCommand = Terminal.commandHistory[Terminal.commandHistoryIndex]; - terminalInput.value = prevCommand; - } - } - - if (event.keyCode === KEY.TAB) { - //Autocomplete - if (terminalInput == null) {return;} - var input = terminalInput.value; - if (input == "") {return;} - input = input.trim(); - input = input.replace(/\s\s+/g, ' '); - - var commandArray = input.split(" "); - var index = commandArray.length - 2; - if (index < -1) {index = 0;} - var allPos = determineAllPossibilitiesForTabCompletion(input, index); - if (allPos.length == 0) {return;} - - var arg = ""; - var command = ""; - if (commandArray.length == 0) {return;} - if (commandArray.length == 1) {command = commandArray[0];} - else if (commandArray.length == 2) { - command = commandArray[0]; - arg = commandArray[1]; - } else if (commandArray.length == 3) { - command = commandArray[0] + " " + commandArray[1]; - arg = commandArray[2]; - } else { - arg = commandArray.pop(); - command = commandArray.join(" "); - } - - tabCompletion(command, arg, allPos); - } - - //Extra Bash Emulation Hotkeys, must be enabled through .fconf - if (_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["FconfSettings"].ENABLE_BASH_HOTKEYS) { - if (event.keyCode === KEY.A && event.ctrlKey) { - event.preventDefault(); - Terminal.moveTextCursor("home"); - } - - if (event.keyCode === KEY.E && event.ctrlKey) { - event.preventDefault(); - Terminal.moveTextCursor("end"); - } - - if (event.keyCode === KEY.B && event.ctrlKey) { - event.preventDefault(); - Terminal.moveTextCursor("prevchar"); - } - - if (event.keyCode === KEY.B && event.altKey) { - event.preventDefault(); - Terminal.moveTextCursor("prevword"); - } - - if (event.keyCode === KEY.F && event.ctrlKey) { - event.preventDefault(); - Terminal.moveTextCursor("nextchar"); - } - - if (event.keyCode === KEY.F && event.altKey) { - event.preventDefault(); - Terminal.moveTextCursor("nextword"); - } - - - if ((event.keyCode === KEY.H || event.keyCode === KEY.D) && event.ctrlKey) { - Terminal.modifyInput("backspace"); - event.preventDefault(); - } - - //TODO AFTER THIS: - - //alt + d deletes word after cursor - //^w deletes word before cursor - //^k clears line after cursor - //^u clears line before cursor - } - } -}); - -//Keep terminal in focus -let terminalCtrlPressed = false; -$(document).ready(function() { - if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { - $('.terminal-input').focus(); - } -}); -$(document).keydown(function(e) { - if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { - if (e.which == 17) { - terminalCtrlPressed = true; - } else if (terminalCtrlPressed == true) { - //Don't focus - } else { - var inputTextBox = document.getElementById("terminal-input-text-box"); - if (inputTextBox != null) { - inputTextBox.focus(); - } - - terminalCtrlPressed = false; - } - } -}) -$(document).keyup(function(e) { - if (_engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].Page.Terminal) { - if (e.which == 17) { - terminalCtrlPressed = false; - } - } -}) - -//Implements a tab completion feature for terminal -// command - Command (first arg only) -// arg - Incomplete argument string that the function will try to complete, or will display -// a series of possible options for -// allPossibilities - Array of strings containing all possibilities that the -// string can complete to -// index - index of argument that is being "tab completed". By default is 0, the first argument -function tabCompletion(command, arg, allPossibilities, index=0) { - if (!(allPossibilities.constructor === Array)) {return;} - if (!Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["containsAllStrings"])(allPossibilities)) {return;} - - if (!command.startsWith("./")) { - command = command.toLowerCase(); + disableHotkeys.onclick = function() { + Settings.DisableHotkeys = this.checked; } - //Remove all options in allPossibilities that do not match the current string - //that we are attempting to autocomplete - if (arg == "") { - for (var i = allPossibilities.length-1; i >= 0; --i) { - if (!allPossibilities[i].toLowerCase().startsWith(command.toLowerCase())) { - allPossibilities.splice(i, 1); - } - } - } else { - for (var i = allPossibilities.length-1; i >= 0; --i) { - if (!allPossibilities[i].toLowerCase().startsWith(arg.toLowerCase())) { - allPossibilities.splice(i, 1); - } - } - } - - var val = ""; - if (allPossibilities.length == 0) { + //Theme + if (Settings.ThemeHighlightColor == null || Settings.ThemeFontColor == null || Settings.ThemeBackgroundColor == null) { + console.log("ERROR: Cannot find Theme Settings"); return; - } else if (allPossibilities.length == 1) { - if (arg == "") { - //Autocomplete command - val = allPossibilities[0] + " "; - } else { - val = command + " " + allPossibilities[0]; - } - document.getElementById("terminal-input-text-box").value = val; - document.getElementById("terminal-input-text-box").focus(); - } else { - var longestStartSubstr = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["longestCommonStart"])(allPossibilities); - //If the longest common starting substring of remaining possibilities is the same - //as whatevers already in terminal, just list all possible options. Otherwise, - //change the input in the terminal to the longest common starting substr - var allOptionsStr = ""; - for (var i = 0; i < allPossibilities.length; ++i) { - allOptionsStr += allPossibilities[i]; - allOptionsStr += " "; - } - if (arg == "") { - if (longestStartSubstr == command) { - post("> " + command); - post(allOptionsStr); - } else { - document.getElementById("terminal-input-text-box").value = longestStartSubstr; - document.getElementById("terminal-input-text-box").focus(); - } - } else { - if (longestStartSubstr == arg) { - //List all possible options - post("> " + command + " " + arg); - post(allOptionsStr); - } else { - document.getElementById("terminal-input-text-box").value = command + " " + longestStartSubstr; - document.getElementById("terminal-input-text-box").focus(); - } - } - + } + if (/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeHighlightColor) && + /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeFontColor) && + /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeBackgroundColor)) { + document.body.style.setProperty('--my-highlight-color', Settings.ThemeHighlightColor); + document.body.style.setProperty('--my-font-color', Settings.ThemeFontColor); + document.body.style.setProperty('--my-background-color', Settings.ThemeBackgroundColor); } } -function determineAllPossibilitiesForTabCompletion(input, index=0) { - var allPos = []; - allPos = allPos.concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["GlobalAliases"])); - var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - input = input.toLowerCase(); - //If the command starts with './' and the index == -1, then the user - //has input ./partialexecutablename so autocomplete the script or program - //Put './' in front of each script/executable - if (input.startsWith("./") && index == -1) { - //All programs and scripts - for (var i = 0; i < currServ.scripts.length; ++i) { - allPos.push("./" + currServ.scripts[i].filename); - } - //Programs are on home computer - var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getHomeComputer(); - for(var i = 0; i < homeComputer.programs.length; ++i) { - allPos.push("./" + homeComputer.programs[i]); - } - return allPos; - } - - //Autocomplete the command - if (index == -1) { - return ["alias", "analyze", "cat", "check", "clear", "cls", "connect", "download", "free", - "hack", "help", "home", "hostname", "ifconfig", "kill", "killall", - "ls", "lscpu", "mem", "nano", "ps", "rm", "run", "scan", "scan-analyze", - "scp", "sudov", "tail", "theme", "top"].concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["Aliases"])).concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["GlobalAliases"])); - } - - if (input.startsWith ("buy ")) { - return [_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BruteSSHProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].FTPCrackProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].RelaySMTPProgram, - _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].HTTPWormProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].SQLInjectProgram, _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1, - _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2].concat(Object.keys(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["GlobalAliases"])); - } - - if (input.startsWith("scp ") && index == 1) { - for (var iphostname in _Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"]) { - if (_Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"].hasOwnProperty(iphostname)) { - allPos.push(_Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"][iphostname].ip); - allPos.push(_Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"][iphostname].hostname); - } - } - } - - if (input.startsWith("scp ") && index == 0) { - //All Scripts and lit files - for (var i = 0; i < currServ.scripts.length; ++i) { - allPos.push(currServ.scripts[i].filename); - } - for (var i = 0; i < currServ.messages.length; ++i) { - if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"])) { - allPos.push(currServ.messages[i]); - } - } - for (var i = 0; i < currServ.textFiles.length; ++i) { - allPos.push(currServ.textFiles[i].fn); - } - } - - if (input.startsWith("connect ") || input.startsWith("telnet ")) { - //All network connections - for (var i = 0; i < currServ.serversOnNetwork.length; ++i) { - var serv = _Server_js__WEBPACK_IMPORTED_MODULE_15__["AllServers"][currServ.serversOnNetwork[i]]; - if (serv == null) {continue;} - allPos.push(serv.ip); //IP - allPos.push(serv.hostname); //Hostname - } - return allPos; - } - - if (input.startsWith("kill ") || input.startsWith("tail ") || - input.startsWith("mem ") || input.startsWith("check ")) { - //All Scripts - for (var i = 0; i < currServ.scripts.length; ++i) { - allPos.push(currServ.scripts[i].filename); - } - return allPos; - } - - if (input.startsWith("nano ")) { - //Scripts and text files and .fconf - for (var i = 0; i < currServ.scripts.length; ++i) { - allPos.push(currServ.scripts[i].filename); - } - for (var i = 0; i < currServ.textFiles.length; ++i) { - allPos.push(currServ.textFiles[i].fn); - } - allPos.push(".fconf"); - return allPos; - } - - if (input.startsWith("rm ")) { - for (var i = 0; i < currServ.scripts.length; ++i) { - allPos.push(currServ.scripts[i].filename); - } - for (var i = 0; i < currServ.programs.length; ++i) { - allPos.push(currServ.programs[i]); - } - for (var i = 0; i < currServ.messages.length; ++i) { - if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["isString"])(currServ.messages[i]) && - currServ.messages[i].endsWith(".lit")) { - allPos.push(currServ.messages[i]); - } - } - for (var i = 0; i < currServ.textFiles.length; ++i) { - allPos.push(currServ.textFiles[i].fn); - } - return allPos; - } - - if (input.startsWith("run ")) { - //All programs and scripts - for (var i = 0; i < currServ.scripts.length; ++i) { - allPos.push(currServ.scripts[i].filename); - } - - //Programs are on home computer - var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getHomeComputer(); - for(var i = 0; i < homeComputer.programs.length; ++i) { - allPos.push(homeComputer.programs[i]); - } - return allPos; - } - - if (input.startsWith("cat ")) { - for (var i = 0; i < currServ.messages.length; ++i) { - if (currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) { - allPos.push(currServ.messages[i].filename); - } else { - allPos.push(currServ.messages[i]); - } - } - for (var i = 0; i < currServ.textFiles.length; ++i) { - allPos.push(currServ.textFiles[i].fn); - } - return allPos; - } - - if (input.startsWith("download ")) { - for (var i = 0; i < currServ.textFiles.length; ++i) { - allPos.push(currServ.textFiles[i].fn); - } - for (var i = 0; i < currServ.scripts.length; ++i) { - allPos.push(currServ.scripts[i].filename); - } - } - return allPos; -} - -let Terminal = { - //Flags to determine whether the player is currently running a hack or an analyze - hackFlag: false, - analyzeFlag: false, - - commandHistory: [], - commandHistoryIndex: 0, - - resetTerminalInput: function() { - document.getElementById("terminal-input-td").innerHTML = - "
[" + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname + " ~]" + "$
" + - ''; - var hdr = document.getElementById("terminal-input-header"); - hdr.style.display = "inline"; - }, - - modifyInput: function(mod) { - try { - var terminalInput = document.getElementById("terminal-input-text-box"); - if (terminalInput == null) {return;} - terminalInput.focus(); - - var inputLength = terminalInput.value.length; - var start = terminalInput.selectionStart; - var end = terminalInput.selectionEnd; - var inputText = terminalInput.value; - - switch(mod.toLowerCase()) { - case "backspace": - if (start > 0 && start <= inputLength+1) { - terminalInput.value = inputText.substr(0, start-1) + inputText.substr(start); - } - break; - case "deletewordbefore": //Delete rest of word before the cursor - for (var delStart = start-1; delStart > 0; --delStart) { - if (inputText.charAt(delStart) === " ") { - terminalInput.value = inputText.substr(0, delStart) + inputText.substr(start); - return; - } - } - break; - case "deletewordafter": //Delete rest of word after the cursor - for (var delStart = start+1; delStart <= text.length+1; ++delStart) { - if (inputText.charAt(delStart) === " ") { - terminalInput.value = inputText.substr(0, start) + inputText.substr(delStart); - return; - } - } - break; - case "clearafter": //Deletes everything after cursor - break; - case "clearbefore:": //Deleetes everything before cursor - break; - } - } catch(e) { - console.log("Exception in Terminal.modifyInput: " + e); - } - }, - - moveTextCursor: function(loc) { - try { - var terminalInput = document.getElementById("terminal-input-text-box"); - if (terminalInput == null) {return;} - terminalInput.focus(); - - var inputLength = terminalInput.value.length; - var start = terminalInput.selectionStart; - var end = terminalInput.selectionEnd; - - switch(loc.toLowerCase()) { - case "home": - terminalInput.setSelectionRange(0,0); - break; - case "end": - terminalInput.setSelectionRange(inputLength, inputLength); - break; - case "prevchar": - if (start > 0) {terminalInput.setSelectionRange(start-1, start-1);} - break; - case "prevword": - for (var i = start-2; i >= 0; --i) { - if (terminalInput.value.charAt(i) === " ") { - terminalInput.setSelectionRange(i+1, i+1); - return; - } - } - terminalInput.setSelectionRange(0, 0); - break; - case "nextchar": - terminalInput.setSelectionRange(start+1, start+1); - break; - case "nextword": - for (var i = start+1; i <= inputLength; ++i) { - if (terminalInput.value.charAt(i) === " ") { - terminalInput.setSelectionRange(i, i); - return; - } - } - terminalInput.setSelectionRange(inputLength, inputLength); - break; - default: - console.log("WARNING: Invalid loc argument in Terminal.moveTextCursor()"); - break; - } - } catch(e) { - console.log("Exception in Terminal.moveTextCursor: " + e); - } - }, - - finishAction: function(cancelled = false) { - if (Terminal.hackFlag) { - Terminal.finishHack(cancelled); - } else if (Terminal.analyzeFlag) { - Terminal.finishAnalyze(cancelled); - } - }, - - //Complete the hack/analyze command - finishHack: function(cancelled = false) { - if (cancelled == false) { - var server = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - - //Calculate whether hack was successful - var hackChance = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingChance(); - var rand = Math.random(); - console.log("Hack success chance: " + hackChance + ", rand: " + rand); - var expGainedOnSuccess = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateExpGain(); - var expGainedOnFailure = (expGainedOnSuccess / 4); - if (rand < hackChance) { //Success! - if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerNames"].WorldDaemon] && - _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerNames"].WorldDaemon] == server.ip) { - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN == null) { - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN = 1; - } - Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_13__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN); - return; - } - server.manuallyHacked = true; - var moneyGained = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculatePercentMoneyHacked(); - moneyGained = Math.floor(server.moneyAvailable * moneyGained); - - if (moneyGained <= 0) {moneyGained = 0;} //Safety check - - server.moneyAvailable -= moneyGained; - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainMoney(moneyGained); - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainHackingExp(expGainedOnSuccess) - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainIntelligenceExp(expGainedOnSuccess / _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].IntelligenceTerminalHackBaseExpGain); - - server.fortify(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].ServerFortifyAmount); - - post("Hack successful! Gained $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(moneyGained, 2) + " and " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(expGainedOnSuccess, 4) + " hacking EXP"); - } else { //Failure - //Player only gains 25% exp for failure? TODO Can change this later to balance - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainHackingExp(expGainedOnFailure) - post("Failed to hack " + server.hostname + ". Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(expGainedOnFailure, 4) + " hacking EXP"); - } - } - - //Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal - $("#hack-progress-bar").attr('id', "old-hack-progress-bar"); - $("#hack-progress").attr('id', "old-hack-progress"); - Terminal.resetTerminalInput(); - $('input[class=terminal-input]').prop('disabled', false); - - Terminal.hackFlag = false; - }, - - finishAnalyze: function(cancelled = false) { - if (cancelled == false) { - post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname + ": "); - post("Organization name: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().organizationName); - var rootAccess = ""; - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights) {rootAccess = "YES";} - else {rootAccess = "NO";} - post("Root Access: " + rootAccess); - post("Required hacking skill: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().requiredHackingSkill); - post("Estimated server security level: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hackDifficulty, 5), 3)); - post("Estimated chance to hack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingChance() * 100, 5), 2) + "%"); - post("Estimated time to hack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingTime(), 5), 3) + " seconds"); - post("Estimated total money available on server: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().moneyAvailable, 5), 2)); - post("Required number of open ports for NUKE: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().numOpenPortsRequired); - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().sshPortOpen) { - post("SSH port: Open") - } else { - post("SSH port: Closed") - } - - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ftpPortOpen) { - post("FTP port: Open") - } else { - post("FTP port: Closed") - } - - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().smtpPortOpen) { - post("SMTP port: Open") - } else { - post("SMTP port: Closed") - } - - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().httpPortOpen) { - post("HTTP port: Open") - } else { - post("HTTP port: Closed") - } - - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().sqlPortOpen) { - post("SQL port: Open") - } else { - post("SQL port: Closed") - } - } - Terminal.analyzeFlag = false; - - //Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal - $("#hack-progress-bar").attr('id', "old-hack-progress-bar"); - $("#hack-progress").attr('id', "old-hack-progress"); - Terminal.resetTerminalInput(); - $('input[class=terminal-input]').prop('disabled', false); - }, - - executeCommand: function(command) { - command = command.trim(); - //Replace all extra whitespace in command with a single space - command = command.replace(/\s\s+/g, ' '); - - //Terminal history - if (Terminal.commandHistory[Terminal.commandHistory.length-1] != command) { - Terminal.commandHistory.push(command); - if (Terminal.commandHistory.length > 50) { - Terminal.commandHistory.splice(0, 1); - } - } - Terminal.commandHistoryIndex = Terminal.commandHistory.length; - - //Process any aliases - command = Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["substituteAliases"])(command); - - //Allow usage of ./ - if (command.startsWith("./")) { - command = "run " + command.slice(2); - } - - //Only split the first space - var commandArray = command.split(" "); - if (commandArray.length > 1) { - commandArray = [commandArray.shift(), commandArray.join(" ")]; - } - - if (commandArray.length == 0) {return;} - - /****************** Interactive Tutorial Terminal Commands ******************/ - if (_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialIsRunning"]) { - var foodnstuffServ = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["GetServerByHostname"])("foodnstuff"); - if (foodnstuffServ == null) {throw new Error("Could not get foodnstuff server"); return;} - - switch(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["currITutorialStep"]) { - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalHelp: - if (commandArray[0] == "help") { - post(_HelpText_js__WEBPACK_IMPORTED_MODULE_6__["TerminalHelpText"]); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalLs: - if (commandArray[0] == "ls") { - Terminal.executeListCommand(commandArray); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScan: - if (commandArray[0] == "scan") { - Terminal.executeScanCommand(commandArray); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScanAnalyze1: - if (commandArray.length == 1 && commandArray[0] == "scan-analyze") { - Terminal.executeScanAnalyzeCommand(1); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScanAnalyze2: - if (commandArray.length == 2 && commandArray[0] == "scan-analyze" && - commandArray[1] == "2") { - Terminal.executeScanAnalyzeCommand(2); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalConnect: - if (commandArray.length == 2) { - if ((commandArray[0] == "connect") && - (commandArray[1] == "foodnstuff" || commandArray[1] == foodnstuffServ.ip)) { - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false; - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = foodnstuffServ.ip; - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true; - post("Connected to foodnstuff"); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Wrong command! Try again!"); return;} - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalAnalyze: - if (commandArray[0] == "analyze") { - if (commandArray.length != 1) { - post("Incorrect usage of analyze command. Usage: analyze"); return; - } - //Analyze the current server for information - Terminal.analyzeFlag = true; - post("Analyzing system..."); - hackProgressPost("Time left:"); - hackProgressBarPost("["); - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].analyze(); - - //Disable terminal - //Terminal.resetTerminalInput(); - document.getElementById("terminal-input-td").innerHTML = ''; - $('input[class=terminal-input]').prop('disabled', true); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else { - post("Bad command. Please follow the tutorial"); - } - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalNuke: - if (commandArray.length == 2 && - commandArray[0] == "run" && commandArray[1] == "NUKE.exe") { - foodnstuffServ.hasAdminRights = true; - post("NUKE successful! Gained root access to foodnstuff"); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalManualHack: - if (commandArray.length == 1 && commandArray[0] == "hack") { - Terminal.hackFlag = true; - hackProgressPost("Time left:"); - hackProgressBarPost("["); - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hack(); - - //Disable terminal - //Terminal.resetTerminalInput(); - document.getElementById("terminal-input-td").innerHTML = ''; - $('input[class=terminal-input]').prop('disabled', true); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalCreateScript: - if (commandArray.length == 2 && - commandArray[0] == "nano" && commandArray[1] == "foodnstuff.script") { - _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent("foodnstuff.script", ""); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalFree: - if (commandArray.length == 1 && commandArray[0] == "free") { - Terminal.executeFreeCommand(commandArray); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalRunScript: - if (commandArray.length == 2 && - commandArray[0] == "run" && commandArray[1] == "foodnstuff.script") { - Terminal.runScript("foodnstuff.script"); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].ActiveScriptsToTerminal: - if (commandArray.length == 2 && - commandArray[0] == "tail" && commandArray[1] == "foodnstuff.script") { - //Check that the script exists on this machine - var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])("foodnstuff.script", [], _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer()); - if (runningScript == null) { - post("Error: No such script exists"); - return; - } - Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__["logBoxCreate"])(runningScript); - Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])(); - } else {post("Bad command. Please follow the tutorial");} - break; - default: - post("Please follow the tutorial, or click 'Exit Tutorial' if you'd like to skip it"); - return; - } - return; - } - - /****************** END INTERACTIVE TUTORIAL ******************/ - - /* Command parser */ - var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - switch (commandArray[0].toLowerCase()) { - case "alias": - if (commandArray.length == 1) { - Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["printAliases"])(); - return; - } - if (commandArray.length == 2) { - if (commandArray[1].startsWith("-g ")) { - var alias = commandArray[1].substring(3); - if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["parseAliasDeclaration"])(alias, true)) { - return; - } - } else { - if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["parseAliasDeclaration"])(commandArray[1])) { - return; - } - } - } - post('Incorrect usage of alias command. Usage: alias [-g] [aliasname="value"]'); - break; - case "analyze": - if (commandArray.length != 1) { - post("Incorrect usage of analyze command. Usage: analyze"); return; - } - //Analyze the current server for information - Terminal.analyzeFlag = true; - post("Analyzing system..."); - hackProgressPost("Time left:"); - hackProgressBarPost("["); - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].analyze(); - - //Disable terminal - //Terminal.resetTerminalInput(); - document.getElementById("terminal-input-td").innerHTML = ''; - $('input[class=terminal-input]').prop('disabled', true); - break; - case "buy": - if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"].hasOwnProperty("Darkweb Server")) { - Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__["executeDarkwebTerminalCommand"])(commandArray); - } else { - post("You need to be able to connect to the Dark Web to use the buy command. (Maybe there's a TOR router you can buy somewhere)"); - } - break; - case "cat": - if (commandArray.length != 2) { - post("Incorrect usage of cat command. Usage: cat [file]"); return; - } - var filename = commandArray[1]; - if (!filename.endsWith(".msg") && !filename.endsWith(".lit") && !filename.endsWith(".txt")) { - post("Error: Only .msg, .txt, and .lit files are viewable with cat (filename must end with .msg, .txt, or .lit)"); return; - } - for (var i = 0; i < s.messages.length; ++i) { - if (filename.endsWith(".lit") && s.messages[i] == filename) { - Object(_Literature_js__WEBPACK_IMPORTED_MODULE_8__["showLiterature"])(s.messages[i]); - return; - } else if (filename.endsWith(".msg") && s.messages[i].filename == filename) { - Object(_Message_js__WEBPACK_IMPORTED_MODULE_9__["showMessage"])(s.messages[i]); - return; - } - } - for (var i = 0; i < s.textFiles.length; ++i) { - if (s.textFiles[i].fn === filename) { - s.textFiles[i].show(); - return; - } - } - post("Error: No such file " + filename); - break; - case "check": - if (commandArray.length < 2) { - post("Incorrect number of arguments. Usage: check [script] [arg1] [arg2]..."); - } else { - var results = commandArray[1].split(" "); - var scriptName = results[0]; - var args = []; - for (var i = 1; i < results.length; ++i) { - args.push(results[i]); - } - - //Can only tail script files - if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(scriptName) == false) { - post("Error: tail can only be called on .script files (filename must end with .script)"); return; - } - - //Check that the script exists on this machine - var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s); - if (runningScript == null) { - post("Error: No such script exists"); - return; - } - runningScript.displayLog(); - } - break; - case "clear": - case "cls": - if (commandArray.length != 1) { - post("Incorrect usage of clear/cls command. Usage: clear/cls"); return; - } - $("#terminal tr:not(:last)").remove(); - postNetburnerText(); - break; - case "connect": - //Disconnect from current server in terminal and connect to new one - if (commandArray.length != 2) { - post("Incorrect usage of connect command. Usage: connect [ip/hostname]"); - return; - } - - var ip = commandArray[1]; - - for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().serversOnNetwork.length; i++) { - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip == ip || _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).hostname == ip) { - Terminal.connectToServer(ip); - return; - } - } - - post("Host not found"); - break; - case "download": - if (commandArray.length != 2) { - post("Incorrect usage of download command. Usage: download [text file]"); - return; - } - var fn = commandArray[1]; - if (fn === "*" || fn === "*.script" || fn === "*.txt") { - //Download all scripts as a zip - var zip = new jszip__WEBPACK_IMPORTED_MODULE_23__(); - if (fn === "*" || fn === "*.script") { - for (var i = 0; i < s.scripts.length; ++i) { - var file = new Blob([s.scripts[i].code], {type:"text/plain"}); - zip.file(s.scripts[i].filename + ".js", file); - } - } - if (fn === "*" || fn === "*.txt") { - for (var i = 0; i < s.textFiles.length; ++i) { - var file = new Blob([s.textFiles[i].text], {type:"text/plain"}); - zip.file(s.textFiles[i].fn, file); - } - } - - var filename; - switch (fn) { - case "*.script": - filename = "bitburnerScripts.zip"; break; - case "*.txt": - filename = "bitburnerTexts.zip"; break; - default: - filename = "bitburnerFiles.zip"; break; - } - - zip.generateAsync({type:"blob"}).then(function(content) { - file_saver__WEBPACK_IMPORTED_MODULE_24__["saveAs"](content, filename); - }); - return; - } else if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(fn)) { - //Download a single script - for (var i = 0; i < s.scripts.length; ++i) { - if (s.scripts[i].filename === fn) { - return s.scripts[i].download(); - } - } - } else if (fn.endsWith(".txt")) { - //Download a single text file - var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_18__["getTextFile"])(fn, s); - if (txtFile !== null) { - return txtFile.download(); - } - } - post("Error: " + fn + " does not exist"); - break; - case "free": - Terminal.executeFreeCommand(commandArray); - break; - case "hack": - if (commandArray.length != 1) { - post("Incorrect usage of hack command. Usage: hack"); return; - } - //Hack the current PC (usually for money) - //You can't hack your home pc or servers you purchased - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().purchasedByPlayer) { - post("Cannot hack your own machines! You are currently connected to your home PC or one of your purchased servers"); - } else if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights == false ) { - post("You do not have admin rights for this machine! Cannot hack"); - } else if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().requiredHackingSkill > _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hacking_skill) { - post("Your hacking skill is not high enough to attempt hacking this machine. Try analyzing the machine to determine the required hacking skill"); - } else { - Terminal.hackFlag = true; - hackProgressPost("Time left:"); - hackProgressBarPost("["); - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hack(); - - //Disable terminal - //Terminal.resetTerminalInput(); - document.getElementById("terminal-input-td").innerHTML = ''; - $('input[class=terminal-input]').prop('disabled', true); - } - break; - case "help": - if (commandArray.length != 1 && commandArray.length != 2) { - post("Incorrect usage of help command. Usage: help"); return; - } - if (commandArray.length == 1) { - post(_HelpText_js__WEBPACK_IMPORTED_MODULE_6__["TerminalHelpText"]); - } else { - var cmd = commandArray[1]; - var txt = _HelpText_js__WEBPACK_IMPORTED_MODULE_6__["HelpTexts"][cmd]; - if (txt == null) { - post("Error: No help topics match '" + cmd + "'"); - return; - } - post(txt); - } - break; - case "home": - if (commandArray.length != 1) { - post("Incorrect usage of home command. Usage: home"); return; - } - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false; - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getHomeComputer().ip; - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true; - post("Connected to home"); - Terminal.resetTerminalInput(); - break; - case "hostname": - if (commandArray.length != 1) { - post("Incorrect usage of hostname command. Usage: hostname"); return; - } - //Print the hostname of current system - post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname); - break; - case "ifconfig": - if (commandArray.length != 1) { - post("Incorrect usage of ifconfig command. Usage: ifconfig"); return; - } - //Print the IP address of the current system - post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ip); - break; - case "kill": - if (commandArray.length < 2) { - post("Incorrect usage of kill command. Usage: kill [scriptname] [arg1] [arg2]..."); return; - } - var results = commandArray[1].split(" "); - var scriptName = results[0]; - var args = []; - for (var i = 1; i < results.length; ++i) { - args.push(results[i]); - } - var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s); - if (runningScript == null) { - post("No such script is running. Nothing to kill"); - return; - } - Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["killWorkerScript"])(runningScript, s.ip); - post("Killing " + scriptName + ". May take up to a few minutes for the scripts to die..."); - break; - case "killall": - for (var i = s.runningScripts.length-1; i >= 0; --i) { - Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["killWorkerScript"])(s.runningScripts[i], s.ip); - } - post("Killing all running scripts. May take up to a few minutes for the scripts to die..."); - break; - case "ls": - Terminal.executeListCommand(commandArray); - break; - case "lscpu": - post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().cpuCores + " Core(s)"); - break; - case "mem": - if (commandArray.length != 2) { - post("Incorrect usage of mem command. usage: mem [scriptname] [-t] [number threads]"); return; - } - var scriptName = commandArray[1]; - var numThreads = 1; - if (scriptName.indexOf(" -t ") != -1) { - var results = scriptName.split(" "); - if (results.length != 3) { - post("Invalid use of run command. Usage: mem [script] [-t] [number threads]"); - return; - } - numThreads = Math.round(Number(results[2])); - if (isNaN(numThreads) || numThreads < 1) { - post("Invalid number of threads specified. Number of threads must be greater than 1"); - return; - } - scriptName = results[0]; - } - - var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - for (var i = 0; i < currServ.scripts.length; ++i) { - if (scriptName == currServ.scripts[i].filename) { - var scriptBaseRamUsage = currServ.scripts[i].ramUsage; - var ramUsage = scriptBaseRamUsage * numThreads * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, numThreads-1); - - post("This script requires " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(ramUsage, 2) + "GB of RAM to run for " + numThreads + " thread(s)"); - return; - } - } - post("ERR: No such script exists!"); - break; - case "nano": - if (commandArray.length != 2) { - post("Incorrect usage of nano command. Usage: nano [scriptname]"); return; - } - - var filename = commandArray[1]; - if (filename === ".fconf") { - var text = Object(_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["createFconf"])(); - _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, text); - return; - } else if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(filename)) { - for (var i = 0; i < s.scripts.length; i++) { - if (filename == s.scripts[i].filename) { - _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, s.scripts[i].code); - return; - } - } - } else if (filename.endsWith(".txt")) { - for (var i = 0; i < s.textFiles.length; ++i) { - if (filename === s.textFiles[i].fn) { - _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, s.textFiles[i].text); - return; - } - } - } else { - post("Error: Invalid file. Only scripts (.script), text files (.txt), or .fconf can be edited with nano"); return; - } - _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename); - break; - case "ps": - if (commandArray.length != 1) { - post("Incorrect usage of ps command. Usage: ps"); return; - } - for (var i = 0; i < s.runningScripts.length; i++) { - var rsObj = s.runningScripts[i]; - var res = rsObj.filename; - for (var j = 0; j < rsObj.args.length; ++j) { - res += (" " + rsObj.args[j].toString()); - } - post(res); - } - break; - case "rm": - if (commandArray.length != 2) { - post("Incorrect number of arguments. Usage: rm [program/script]"); return; - } - - //Check programs - var delTarget = commandArray[1]; - - if (delTarget.includes(".exe")) { - for (var i = 0; i < s.programs.length; ++i) { - if (s.programs[i] == delTarget) { - s.programs.splice(i, 1); - return; - } - } - } else if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(delTarget)) { - for (var i = 0; i < s.scripts.length; ++i) { - if (s.scripts[i].filename == delTarget) { - //Check that the script isnt currently running - for (var j = 0; j < s.runningScripts.length; ++j) { - if (s.runningScripts[j].filename == delTarget) { - post("Cannot delete a script that is currently running!"); - return; - } - } - s.scripts.splice(i, 1); - return; - } - } - } else if (delTarget.endsWith(".lit")) { - for (var i = 0; i < s.messages.length; ++i) { - var f = s.messages[i]; - if (!(f instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["isString"])(f) && f === delTarget) { - s.messages.splice(i, 1); - return; - } - } - } else if (delTarget.endsWith(".txt")) { - for (var i = 0; i < s.textFiles.length; ++i) { - if (s.textFiles[i].fn === delTarget) { - s.textFiles.splice(i, 1); - return; - } - } - } - post("Error: No such file exists"); - break; - case "run": - //Run a program or a script - if (commandArray.length != 2) { - post("Incorrect number of arguments. Usage: run [program/script] [-t] [num threads] [arg1] [arg2]..."); - } else { - var executableName = commandArray[1]; - - //Secret Music player! - if (executableName === "musicplayer") { - post('', false); - return; - } - - //Check if its a script or just a program/executable - if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(executableName) == -1) { - // Not a script - Terminal.runProgram(executableName); - } else { - //Script - Terminal.runScript(executableName); - } - } - break; - case "scan": - Terminal.executeScanCommand(commandArray); - break; - case "scan-analyze": - if (commandArray.length == 1) { - Terminal.executeScanAnalyzeCommand(1); - } else if (commandArray.length == 2) { - var all = false; - if (commandArray[1].endsWith("-a")) { - all = true; - commandArray[1] = commandArray[1].replace("-a", ""); - } - var depth; - if (commandArray[1].length === 0) { - depth = 1; - } else { - depth = Number(commandArray[1]); - } - if (isNaN(depth) || depth < 0) { - post("Incorrect usage of scan-analyze command. depth argument must be positive numeric"); - return; - } - if (depth > 3 && !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1) && - !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2)) { - post("You cannot scan-analyze with that high of a depth. Maximum depth is 3"); - return; - } else if (depth > 5 && !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2)) { - post("You cannot scan-analyze with that high of a depth. Maximum depth is 5"); - return; - } else if (depth > 10) { - post("You cannot scan-analyze with that high of a depth. Maximum depth is 10"); - return; - } - Terminal.executeScanAnalyzeCommand(depth, all); - } else { - post("Incorrect usage of scan-analyze command. usage: scan-analyze [depth]"); - } - break; - case "scp": - if (commandArray.length != 2) { - post("Incorrect usage of scp command. Usage: scp [file] [destination hostname/ip]"); - return; - } - var args = commandArray[1].split(" "); - if (args.length != 2) { - post("Incorrect usage of scp command. Usage: scp [file] [destination hostname/ip]"); - return; - } - var scriptname = args[0]; - if (!scriptname.endsWith(".lit") && !Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(scriptName) && - !scriptname.endsWith(".txt")){ - post("Error: scp only works for .script, .txt, and .lit files"); - return; - } - var destServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(args[1]); - if (destServer == null) { - post("Invalid destination. " + args[1] + " not found"); - return; - } - var ip = destServer.ip; - var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - - //Scp for lit files - if (scriptname.endsWith(".lit")) { - var found = false; - for (var i = 0; i < currServ.messages.length; ++i) { - if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && currServ.messages[i] == scriptname) { - found = true; - break; - } - } - - if (!found) {return post("Error: no such file exists!");} - - for (var i = 0; i < destServer.messages.length; ++i) { - if (destServer.messages[i] === scriptname) { - post(scriptname + " copied over to " + destServer.hostname); - return; //Already exists - } - } - destServer.messages.push(scriptname); - post(scriptname + " copied over to " + destServer.hostname); - return; - } - - //Scp for txt files - if (scriptname.endsWith(".txt")) { - var found = false, txtFile; - for (var i = 0; i < currServ.textFiles.length; ++i) { - if (currServ.textFiles[i].fn === scriptname) { - found = true; - txtFile = currServ.textFiles[i]; - break; - } - } - - if (!found) {return post("Error: no such file exists!");} - - for (var i = 0; i < destServer.textFiles.length; ++i) { - if (destServer.textFiles[i].fn === scriptname) { - //Overwrite - destServer.textFiles[i].text = txtFile.text; - post("WARNING: " + scriptname + " already exists on " + destServer.hostname + - "and will be overwriten"); - return post(scriptname + " copied over to " + destServer.hostname); - } - } - var newFile = new _TextFile_js__WEBPACK_IMPORTED_MODULE_18__["TextFile"](txtFile.fn, txtFile.text); - destServer.textFiles.push(newFile); - return post(scriptname + " copied over to " + destServer.hostname); - } - - //Get the current script - var sourceScript = null; - for (var i = 0; i < currServ.scripts.length; ++i) { - if (scriptname == currServ.scripts[i].filename) { - sourceScript = currServ.scripts[i]; - break; - } - } - if (sourceScript == null) { - post("ERROR: scp() failed. No such script exists"); - return; - } - - //Overwrite script if it exists - for (var i = 0; i < destServer.scripts.length; ++i) { - if (scriptname == destServer.scripts[i].filename) { - post("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and will be overwritten"); - var oldScript = destServer.scripts[i]; - oldScript.code = sourceScript.code; - oldScript.ramUsage = sourceScript.ramUsage; - post(scriptname + " overwriten on " + destServer.hostname); - return; - } - } - - var newScript = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["Script"](); - newScript.filename = scriptname; - newScript.code = sourceScript.code; - newScript.ramUsage = sourceScript.ramUsage; - newScript.destServer = ip; - destServer.scripts.push(newScript); - post(scriptname + " copied over to " + destServer.hostname); - break; - case "sudov": - if (commandArray.length != 1) { - post("Incorrect number of arguments. Usage: sudov"); return; - } - - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights) { - post("You have ROOT access to this machine"); - } else { - post("You do NOT have root access to this machine"); - } - break; - case "tail": - if (commandArray.length < 2) { - post("Incorrect number of arguments. Usage: tail [script] [arg1] [arg2]..."); - } else { - var results = commandArray[1].split(" "); - var scriptName = results[0]; - var args = []; - for (var i = 1; i < results.length; ++i) { - args.push(results[i]); - } - - //Can only tail script files - if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["isScriptFilename"])(scriptName) == false) { - post("Error: tail can only be called on .script files (filename must end with .script)"); return; - } - - //Check that the script exists on this machine - var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s); - if (runningScript == null) { - post("Error: No such script exists"); - return; - } - Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__["logBoxCreate"])(runningScript); - } - break; - case "theme": - //todo support theme saving - var args = commandArray[1] ? commandArray[1].split(" ") : []; - if (args.length != 1 && args.length != 3) { - post("Incorrect number of arguments."); - post("Usage: theme [default|muted|solarized] | #[background color hex] #[text color hex] #[highlight color hex]"); - } else if(args.length == 1){ - var themeName = args[0]; - if (themeName == "default"){ - document.body.style.setProperty('--my-highlight-color',"#ffffff"); - document.body.style.setProperty('--my-font-color',"#66ff33"); - document.body.style.setProperty('--my-background-color',"#000000"); - } else if (themeName == "muted"){ - document.body.style.setProperty('--my-highlight-color',"#ffffff"); - document.body.style.setProperty('--my-font-color',"#66ff33"); - document.body.style.setProperty('--my-background-color',"#252527"); - } else if (themeName == "solarized"){ - document.body.style.setProperty('--my-highlight-color',"#6c71c4"); - document.body.style.setProperty('--my-font-color',"#839496"); - document.body.style.setProperty('--my-background-color',"#002b36"); - } else { - return post("Theme not found"); - } - _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeHighlightColor = document.body.style.getPropertyValue("--my-highlight-color"); - _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeFontColor = document.body.style.getPropertyValue("--my-font-color"); - _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeBackgroundColor = document.body.style.getPropertyValue("--my-background-color"); - } else { - var inputBackgroundHex = args[0]; - var inputTextHex = args[1]; - var inputHighlightHex = args[2]; - if (/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputBackgroundHex) && - /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputTextHex) && - /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputHighlightHex)){ - document.body.style.setProperty('--my-highlight-color',inputHighlightHex); - document.body.style.setProperty('--my-font-color',inputTextHex); - document.body.style.setProperty('--my-background-color',inputBackgroundHex); - _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeHighlightColor = document.body.style.getPropertyValue("--my-highlight-color"); - _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeFontColor = document.body.style.getPropertyValue("--my-font-color"); - _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeBackgroundColor = document.body.style.getPropertyValue("--my-background-color"); - } else { - return post("Invalid Hex Input for theme"); - } - } - break; - case "top": - if(commandArray.length != 1) { - post("Incorrect usage of top command. Usage: top"); return; - } - - post("Script Threads RAM Usage"); - - var currRunningScripts = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().runningScripts; - //Iterate through scripts on current server - for(var i = 0; i < currRunningScripts.length; i++) { - var script = currRunningScripts[i]; - - //Calculate name padding - var numSpacesScript = 32 - script.filename.length; //26 -> width of name column - if (numSpacesScript < 0) {numSpacesScript = 0;} - var spacesScript = Array(numSpacesScript+1).join(" "); - - //Calculate thread padding - var numSpacesThread = 16 - (script.threads + "").length; //16 -> width of thread column - var spacesThread = Array(numSpacesThread+1).join(" "); - - //Calculate and transform RAM usage - ramUsage = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(script.scriptRef.ramUsage * script.threads, 2).toString() + "GB"; - - var entry = [script.filename, spacesScript, script.threads, spacesThread, ramUsage]; - post(entry.join("")); - } - break; - case "unalias": - if (commandArray.length != 2) { - post('Incorrect usage of unalias name. Usage: unalias "[alias]"'); - return; - } else if (!(commandArray[1].startsWith('"') && commandArray[1].endsWith('"'))) { - post('Incorrect usage of unalias name. Usage: unalias "[alias]"'); - } else { - var alias = commandArray[1].slice(1, -1); - if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["removeAlias"])(alias)) { - post("Removed alias " + alias); - } else { - post("No such alias exists"); - } - } - break; - default: - post("Command not found"); - } - }, - - connectToServer: function(ip) { - console.log("Connect to server called"); - var serv = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(ip); - if (serv == null) { - post("Invalid server. Connection failed."); - return; - } - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false; - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = serv.ip; - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true; - post("Connected to " + serv.hostname); - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname == "darkweb") { - Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__["checkIfConnectedToDarkweb"])(); //Posts a 'help' message if connecting to dark web - } - Terminal.resetTerminalInput(); - }, - - executeListCommand: function(commandArray) { - if (commandArray.length != 1 && commandArray.length != 2) { - post("Incorrect usage of ls command. Usage: ls [| grep pattern]"); return; - } - - //grep - var filter = null; - if (commandArray.length == 2) { - if (commandArray[1].startsWith("| grep ")) { - var pattern = commandArray[1].replace("| grep ", ""); - if (pattern != " ") { - filter = pattern; - } - } else { - post("Incorrect usage of ls command. Usage: ls [| grep pattern]"); return; - } - } - - //Display all programs and scripts - var allFiles = []; - - //Get all of the programs and scripts on the machine into one temporary array - var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - for (var i = 0; i < s.programs.length; i++) { - if (filter) { - if (s.programs[i].includes(filter)) { - allFiles.push(s.programs[i]); - } - } else { - allFiles.push(s.programs[i]); - } - } - for (var i = 0; i < s.scripts.length; i++) { - if (filter) { - if (s.scripts[i].filename.includes(filter)) { - allFiles.push(s.scripts[i].filename); - } - } else { - allFiles.push(s.scripts[i].filename); - } - - } - for (var i = 0; i < s.messages.length; i++) { - if (filter) { - if (s.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) { - if (s.messages[i].filename.includes(filter)) { - allFiles.push(s.messages[i].filename); - } - } else if (s.messages[i].includes(filter)) { - allFiles.push(s.messages[i]); - } - } else { - if (s.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) { - allFiles.push(s.messages[i].filename); - } else { - allFiles.push(s.messages[i]); - } - } - } - for (var i = 0; i < s.textFiles.length; ++i) { - if (filter) { - if (s.textFiles[i].fn.includes(filter)) { - allFiles.push(s.textFiles[i].fn); - } - } else { - allFiles.push(s.textFiles[i].fn); - } - } - - //Sort the files alphabetically then print each - allFiles.sort(); - - for (var i = 0; i < allFiles.length; i++) { - post(allFiles[i]); - } - }, - - executeScanCommand: function(commandArray) { - if (commandArray.length != 1) { - post("Incorrect usage of netstat/scan command. Usage: netstat/scan"); return; - } - //Displays available network connections using TCP - post("Hostname IP Root Access"); - for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().serversOnNetwork.length; i++) { - //Add hostname - var entry = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i); - if (entry == null) {continue;} - entry = entry.hostname; - - //Calculate padding and add IP - var numSpaces = 21 - entry.length; - var spaces = Array(numSpaces+1).join(" "); - entry += spaces; - entry += _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip; - - //Calculate padding and add root access info - var hasRoot; - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).hasAdminRights) { - hasRoot = 'Y'; - } else { - hasRoot = 'N'; - } - numSpaces = 21 - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip.length; - spaces = Array(numSpaces+1).join(" "); - entry += spaces; - entry += hasRoot; - post(entry); - } - }, - - executeScanAnalyzeCommand: function(depth=1, all=false) { - //We'll use the AllServersMap as a visited() array - //TODO Using array as stack for now, can make more efficient - post("~~~~~~~~~~ Beginning scan-analyze ~~~~~~~~~~"); - post(" "); - var visited = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["AllServersMap"](); - - var stack = []; - var depthQueue = [0]; - var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - stack.push(currServ); - while(stack.length != 0) { - var s = stack.pop(); - var d = depthQueue.pop(); - if (!all && s.purchasedByPlayer && s.hostname != "home") { - continue; //Purchased server - } else if (visited[s.ip] || d > depth) { - continue; //Already visited or out-of-depth - } else { - visited[s.ip] = 1; - } - for (var i = s.serversOnNetwork.length-1; i >= 0; --i) { - stack.push(s.getServerOnNetwork(i)); - depthQueue.push(d+1); - } - if (d == 0) {continue;} //Don't print current server - var titleDashes = Array((d-1) * 4 + 1).join("-"); - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].AutoLink)) { - post("" + titleDashes + "> " + s.hostname + "", false); - } else { - post("" + titleDashes + ">" + s.hostname + ""); - } - - var dashes = titleDashes + "--"; - //var dashes = Array(d * 2 + 1).join("-"); - var c = "NO"; - if (s.hasAdminRights) {c = "YES";} - post(dashes + "Root Access: " + c + ", Required hacking skill: " + s.requiredHackingSkill); - post(dashes + "Number of open ports required to NUKE: " + s.numOpenPortsRequired); - post(dashes + "RAM: " + s.maxRam); - post(" "); - } - - var links = document.getElementsByClassName("scan-analyze-link"); - for (var i = 0; i < links.length; ++i) { - (function() { - var hostname = links[i].innerHTML.toString(); - links[i].onclick = function() { - if (Terminal.analyzeFlag || Terminal.hackFlag) {return;} - Terminal.connectToServer(hostname); - } - }());//Immediate invocation - } - - }, - - executeFreeCommand: function(commandArray) { - if (commandArray.length != 1) { - post("Incorrect usage of free command. Usage: free"); return; - } - post("Total: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().maxRam, 2) + " GB"); - post("Used: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ramUsed, 2) + " GB"); - post("Available: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().maxRam - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ramUsed, 2) + " GB"); - }, - - //First called when the "run [program]" command is called. Checks to see if you - //have the executable and, if you do, calls the executeProgram() function - runProgram: function(programName) { - //Check if you have the program on your computer. If you do, execute it, otherwise - //display an error message - var splitArgs = programName.split(" "); - var name = " "; - if (splitArgs.length > 1) { - name = splitArgs[0]; - } else { - name = programName; - } - if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(name)) { - Terminal.executeProgram(programName); - return; - } - post("ERROR: No such executable on home computer (Only programs that exist on your home computer can be run)"); - }, - - //Contains the implementations of all possible programs - executeProgram: function(programName) { - var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - var splitArgs = programName.split(" "); - if (splitArgs.length > 1) { - programName = splitArgs[0]; - } - switch (programName) { - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].NukeProgram: - if (s.hasAdminRights) { - post("You already have root access to this computer. There is no reason to run NUKE.exe"); - } else { - if (s.openPortCount >= _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().numOpenPortsRequired) { - s.hasAdminRights = true; - post("NUKE successful! Gained root access to " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname); - //TODO Make this take time rather than be instant - } else { - post("NUKE unsuccessful. Not enough ports have been opened"); - } - } - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BruteSSHProgram: - if (s.sshPortOpen) { - post("SSH Port (22) is already open!"); - } else { - s.sshPortOpen = true; - post("Opened SSH Port(22)!") - ++s.openPortCount; - } - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].FTPCrackProgram: - if (s.ftpPortOpen) { - post("FTP Port (21) is already open!"); - } else { - s.ftpPortOpen = true; - post("Opened FTP Port (21)!"); - ++s.openPortCount; - } - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].RelaySMTPProgram: - if (s.smtpPortOpen) { - post("SMTP Port (25) is already open!"); - } else { - s.smtpPortOpen = true; - post("Opened SMTP Port (25)!"); - ++s.openPortCount; - } - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].HTTPWormProgram: - if (s.httpPortOpen) { - post("HTTP Port (80) is already open!"); - } else { - s.httpPortOpen = true; - post("Opened HTTP Port (80)!"); - ++s.openPortCount; - } - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].SQLInjectProgram: - if (s.sqlPortOpen) { - post("SQL Port (1433) is already open!"); - } else { - s.sqlPortOpen = true; - post("Opened SQL Port (1433)!"); - ++s.openPortCount; - } - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].ServerProfiler: - if (splitArgs.length != 2) { - post("Must pass a server hostname or IP as an argument for ServerProfiler.exe"); - return; - } - var serv = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(splitArgs[1]); - if (serv == null) { - post("Invalid server IP/hostname"); - return; - } - post(serv.hostname + ":"); - post("Server base security level: " + serv.baseDifficulty); - post("Server current security level: " + serv.hackDifficulty); - post("Server growth rate: " + serv.serverGrowth); - post("Netscript hack() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateHackingTime"])(serv), 1) + "s"); - post("Netscript grow() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateGrowTime"])(serv)/1000, 1) + "s"); - post("Netscript weaken() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateWeakenTime"])(serv)/1000, 1) + "s"); - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].AutoLink: - post("This executable cannot be run."); - post("AutoLink.exe lets you automatically connect to other servers when using 'scan-analyze'."); - post("When using scan-analyze, click on a server's hostname to connect to it."); - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1: - post("This executable cannot be run."); - post("DeepscanV1.exe lets you run 'scan-analyze' with a depth up to 5."); - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2: - post("This executable cannot be run."); - post("DeepscanV2.exe lets you run 'scan-analyze' with a depth up to 10."); - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].Flight: - post("Augmentations: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].augmentations.length + " / 30"); - post("Money: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].money.toNumber(), 2) + " / $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(100000000000, 2)); - post("One path below must be fulfilled..."); - post("----------HACKING PATH----------"); - post("Hacking skill: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hacking_skill + " / 2500"); - post("----------COMBAT PATH----------"); - post("Strength: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].strength + " / 1500"); - post("Defense: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].defense + " / 1500"); - post("Dexterity: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].dexterity + " / 1500"); - post("Agility: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].agility + " / 1500"); - break; - case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BitFlume: - var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxGetYesButton"])(), - noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxGetNoButton"])(); - yesBtn.innerHTML = "Travel to BitNode Nexus"; - noBtn.innerHTML = "Cancel"; - yesBtn.addEventListener("click", function() { - Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_13__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN, true); - return Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxClose"])(); - }); - noBtn.addEventListener("click", function() { - return Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxClose"])(); - }); - Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxCreate"])("WARNING: USING THIS PROGRAM WILL CAUSE YOU TO LOSE ALL OF YOUR PROGRESS ON THE CURRENT BITNODE.

" + - "Do you want to travel to the BitNode Nexus? This allows you to reset the current BitNode " + - "and select a new one."); - - break; - default: - post("Invalid executable. Cannot be run"); - return; - } - }, - - runScript: function(scriptName) { - var server = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer(); - - var numThreads = 1; - var args = []; - var results = scriptName.split(" "); - if (results.length <= 0) { - post("This is a bug. Please contact developer"); - } - scriptName = results[0]; - if (results.length > 1) { - if (results.length >= 3 && results[1] == "-t") { - numThreads = Math.round(Number(results[2])); - if (isNaN(numThreads) || numThreads < 1) { - post("Invalid number of threads specified. Number of threads must be greater than 0"); - return; - } - for (var i = 3; i < results.length; ++i) { - var arg = results[i]; - - //Forced string - if ((arg.startsWith("'") && arg.endsWith("'")) || - (arg.startsWith('"') && arg.endsWith('"'))) { - args.push(arg.slice(1, -1)); - continue; - } - //Number - var tempNum = Number(arg); - if (!isNaN(tempNum)) { - args.push(tempNum); - continue; - } - //Otherwise string - args.push(arg); - } - } else { - for (var i = 1; i < results.length; ++i) { - var arg = results[i]; - - //Forced string - if ((arg.startsWith("'") && arg.endsWith("'")) || - (arg.startsWith('"') && arg.endsWith('"'))) { - args.push(arg.slice(1, -1)); - continue; - } - //Number - var tempNum = Number(arg); - if (!isNaN(tempNum)) { - args.push(tempNum); - continue; - } - //Otherwise string - args.push(arg); - } - } - } - - - //Check if this script is already running - if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, server) != null) { - post("ERROR: This script is already running. Cannot run multiple instances"); - return; - } - - //Check if the script exists and if it does run it - for (var i = 0; i < server.scripts.length; i++) { - if (server.scripts[i].filename == scriptName) { - //Check for admin rights and that there is enough RAM availble to run - var script = server.scripts[i]; - var ramUsage = script.ramUsage * numThreads * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, numThreads-1); - var ramAvailable = server.maxRam - server.ramUsed; - - if (server.hasAdminRights == false) { - post("Need root access to run script"); - return; - } else if (ramUsage > ramAvailable){ - post("This machine does not have enough RAM to run this script with " + - numThreads + " threads. Script requires " + ramUsage + "GB of RAM"); - return; - } else { - //Able to run script - post("Running script with " + numThreads + " thread(s) and args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["printArray"])(args) + "."); - post("May take a few seconds to start up the process..."); - var runningScriptObj = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["RunningScript"](script, args); - runningScriptObj.threads = numThreads; - server.runningScripts.push(runningScriptObj); - - Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["addWorkerScript"])(runningScriptObj, server); - return; - } - } - } - - post("ERROR: No such script"); - } -}; - - - -/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 38))) /***/ }), -/* 23 */ +/* 24 */ /*!**************************!*\ !*** ./utils/decimal.js ***! \**************************/ @@ -24913,126 +25081,6 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/*! decimal.js v7.2.3 https://github.com/MikeM })(this); -/***/ }), -/* 24 */ -/*!*************************!*\ - !*** ./src/Settings.js ***! - \*************************/ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Settings", function() { return Settings; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSettings", function() { return initSettings; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setSettingsLabels", function() { return setSettingsLabels; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadSettings", function() { return loadSettings; }); -/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.js */ 5); - - -/* 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", -} - -function loadSettings(saveString) { - Settings = JSON.parse(saveString); -} - -function initSettings() { - Settings.CodeInstructionRunTime = 50; - Settings.MaxLogCapacity = 50; - Settings.MaxPortCapacity = 50; - Settings.SuppressMessages = false; - Settings.SuppressFactionInvites = false; - Settings.AutosaveInterval = 60; -} - -function setSettingsLabels() { - var nsExecTime = document.getElementById("settingsNSExecTimeRangeValLabel"); - var nsLogLimit = document.getElementById("settingsNSLogRangeValLabel"); - var nsPortLimit = document.getElementById("settingsNSPortRangeValLabel"); - var suppressMsgs = document.getElementById("settingsSuppressMessages"); - var suppressFactionInv = document.getElementById("settingsSuppressFactionInvites") - var autosaveInterval = document.getElementById("settingsAutosaveIntervalValLabel"); - - //Initialize values on labels - nsExecTime.innerHTML = Settings.CodeInstructionRunTime + "ms"; - nsLogLimit.innerHTML = Settings.MaxLogCapacity; - nsPortLimit.innerHTML = Settings.MaxPortCapacity; - suppressMsgs.checked = Settings.SuppressMessages; - suppressFactionInv.checked = Settings.SuppressFactionInvites; - autosaveInterval.innerHTML = Settings.AutosaveInterval; - - //Set handlers for when input changes - var nsExecTimeInput = document.getElementById("settingsNSExecTimeRangeVal"); - var nsLogRangeInput = document.getElementById("settingsNSLogRangeVal"); - var nsPortRangeInput = document.getElementById("settingsNSPortRangeVal"); - var nsAutosaveIntervalInput = document.getElementById("settingsAutosaveIntervalVal"); - nsExecTimeInput.value = Settings.CodeInstructionRunTime; - nsLogRangeInput.value = Settings.MaxLogCapacity; - nsPortRangeInput.value = Settings.MaxPortCapacity; - nsAutosaveIntervalInput.value = Settings.AutosaveInterval; - - nsExecTimeInput.oninput = function() { - nsExecTime.innerHTML = this.value + 'ms'; - Settings.CodeInstructionRunTime = this.value; - }; - - nsLogRangeInput.oninput = function() { - nsLogLimit.innerHTML = this.value; - Settings.MaxLogCapacity = this.value; - }; - - nsPortRangeInput.oninput = function() { - nsPortLimit.innerHTML = this.value; - Settings.MaxPortCapacity = this.value; - }; - - nsAutosaveIntervalInput.oninput = function() { - autosaveInterval.innerHTML = this.value; - Settings.AutosaveInterval = Number(this.value); - if (Number(this.value) === 0) { - _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = Infinity; - } else { - _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = Number(this.value) * 5; - } - }; - - document.getElementById("settingsSuppressMessages").onclick = function() { - Settings.SuppressMessages = this.checked; - }; - - document.getElementById("settingsSuppressFactionInvites").onclick = function() { - Settings.SuppressFactionInvites = this.checked; - }; - - //Theme - if (Settings.ThemeHighlightColor == null || Settings.ThemeFontColor == null || Settings.ThemeBackgroundColor == null) { - console.log("ERROR: Cannot find Theme Settings"); - return; - } - if (/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeHighlightColor) && - /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeFontColor) && - /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeBackgroundColor)) { - document.body.style.setProperty('--my-highlight-color', Settings.ThemeHighlightColor); - document.body.style.setProperty('--my-font-color', Settings.ThemeFontColor); - document.body.style.setProperty('--my-background-color', Settings.ThemeBackgroundColor); - } -} - - - - /***/ }), /* 25 */ /*!************************************!*\ @@ -25736,17 +25784,17 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isScriptFilename", function() { return isScriptFilename; }); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5); -/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Fconf.js */ 35); +/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Fconf.js */ 32); /* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 25); /* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 7); /* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 29); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Settings.js */ 24); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Terminal.js */ 22); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Settings.js */ 23); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Terminal.js */ 18); /* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./TextFile.js */ 41); -/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/acorn.js */ 34); +/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/acorn.js */ 35); /* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8); @@ -25809,7 +25857,7 @@ function scriptEditorInit() { } var closeButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_15__["createElement"])("a", { class:"a-link-button", display:"inline-block", - innerText:"Save & Close (Ctrl + b)", + innerText:"Save & Close (Ctrl/Cmd + b)", clickListener:()=>{ saveAndCloseScriptEditor(); return false; @@ -25983,6 +26031,7 @@ function updateScriptEditorContent() { //Define key commands in script editor (ctrl o to save + close, etc.) $(document).keydown(function(e) { + if (_Settings_js__WEBPACK_IMPORTED_MODULE_9__["Settings"].DisableHotkeys === true) {return;} if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.ScriptEditor) { //Ctrl + b if (e.keyCode == 66 && (e.ctrlKey || e.metaKey)) { @@ -26167,7 +26216,7 @@ function parseOnlyRamCalculate(server, code, workerScript) { // Finally, walk the reference map and generate a ram cost. The initial set of keys to scan // are those that start with __SPECIAL_INITIAL_MODULE__. - let ram = 1.4; + let ram = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptBaseRamCost; const unresolvedRefs = Object.keys(dependencyMap).filter(s => s.startsWith(initialModule)); const resolvedRefs = new Set(); while (unresolvedRefs.length > 0) { @@ -26344,7 +26393,7 @@ function calculateRamUsage(codeCopy) { } //Search through AST, scanning for any 'Identifier' nodes for functions, or While/For/If nodes - var queue = [], ramUsage = 1.4; + var queue = [], ramUsage = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptBaseRamCost; var whileUsed = false, forUsed = false, ifUsed = false; queue.push(ast); while (queue.length != 0) { @@ -26608,7 +26657,11 @@ RunningScript.prototype.log = function(txt) { //to improve performance this.logs.shift(); } - this.logs.push(txt); + let logEntry = txt; + if (_Fconf_js__WEBPACK_IMPORTED_MODULE_2__["FconfSettings"].ENABLE_TIMESTAMPS) { + logEntry = "[" + _Terminal_js__WEBPACK_IMPORTED_MODULE_10__["Terminal"].getTimestamp() + "] " + logEntry; + } + this.logs.push(logEntry); this.logUpd = true; } @@ -26864,13 +26917,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadMessages", function() { return loadMessages; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initMessages", function() { return initMessages; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Message", function() { return Message; }); -/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 18); +/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 19); /* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CreateProgram.js */ 14); -/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Missions.js */ 32); +/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Missions.js */ 33); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./RedPill.js */ 44); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Settings.js */ 24); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Settings.js */ 23); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8); @@ -27085,32 +27138,32 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasAISF", function() { return hasAISF; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasBladeburnerSF", function() { return hasBladeburnerSF; }); /* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ActiveScriptsUI.js */ 43); -/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Augmentations.js */ 18); +/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Augmentations.js */ 19); /* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./BitNode.js */ 15); -/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Crimes.js */ 19); +/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Crimes.js */ 20); /* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Company.js */ 9); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Constants.js */ 3); /* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./CreateProgram.js */ 14); -/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./DarkWeb.js */ 33); +/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./DarkWeb.js */ 34); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./engine.js */ 5); /* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Faction.js */ 11); /* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./HacknetNode.js */ 39); /* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Location.js */ 4); /* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Message.js */ 28); -/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Missions.js */ 32); +/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Missions.js */ 33); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Script.js */ 26); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Settings.js */ 24); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Settings.js */ 23); /* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); -/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./StockMarket.js */ 21); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Terminal.js */ 22); +/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./StockMarket.js */ 22); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Terminal.js */ 18); /* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./TextFile.js */ 41); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); /* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 7); /* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 69); /* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./NetscriptPort.js */ 45); -/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../utils/decimal.js */ 23); +/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../utils/decimal.js */ 24); /* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_26___default = /*#__PURE__*/__webpack_require__.n(_utils_decimal_js__WEBPACK_IMPORTED_MODULE_26__); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); @@ -27163,6 +27216,55 @@ var hasCorporationSF=false, //Source-File 3 hasBn11SF=false; //Source-File 11 +var possibleLogs = { + ALL: true, + scan: true, + hack: true, + sleep: true, + disableLog: true, + enableLog: true, + grow: true, + weaken: true, + nuke: true, + brutessh: true, + ftpcrack: true, + relaysmtp: true, + httpworm: true, + sqlinject: true, + spawn: true, + kill: true, + killall: true, + scp: true, + getHackingLevel: true, + getServerMoneyAvailable: true, + getServerSecurityLevel: true, + getServerBaseSecurityLevel: true, + getServerMinSecurityLevel: true, + getServerRequiredHackingLevel: true, + getServerMaxMoney: true, + getServerGrowth: true, + getServerNumPortsRequired: true, + getServerRam: true, + buyStock: true, + sellStock: true, + purchaseServer: true, + deleteServer: true, + universityCourse: true, + gymWorkout: true, + travelToCity: true, + purchaseTor: true, + purchaseProgram: true, + stopAction: true, + upgradeHomeRam: true, + workForCompany: true, + applyToCompany: true, + joinFaction: true, + workForFaction: true, + createProgram: true, + commitCrime: true, + shortStock: true, + sellShort: true, +} var singularitySFLvl=1, wallStreetSFLvl=1; @@ -27443,13 +27545,23 @@ function NetscriptFunctions(workerScript) { }, disableLog : function(fn) { if (workerScript.checkingRam) {return 0;} + if(possibleLogs[fn]===undefined) { + throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument to disableLog: "+fn); + } workerScript.disableLogs[fn] = true; - workerScript.scriptRef.log("Disabled logging for " + fn); + if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.disableLog == null) { + workerScript.scriptRef.log("Disabled logging for " + fn); + } }, enableLog : function(fn) { if (workerScript.checkingRam) {return 0;} + if(possibleLogs[fn]===undefined) { + throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument to enableLog: "+fn); + } delete workerScript.disableLogs[fn]; - workerScript.scriptRef.log("Enabled logging for " + fn); + if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.enableLog == null) { + workerScript.scriptRef.log("Enabled logging for " + fn); + } }, nuke : function(ip){ if (workerScript.checkingRam) { @@ -28125,6 +28237,23 @@ function NetscriptFunctions(workerScript) { growth: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_grow_mult, }; }, + getHacknetMultipliers : function() { + if (workerScript.checkingRam) { + if (workerScript.loadedFns.getHacknetMultipliers) { + return 0; + } else { + workerScript.loadedFns.getHacknetMultipliers = true; + return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetMultipliersRamCost; + } + } + return { + production: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacknet_node_money_mult, + purchaseCost: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacknet_node_purchase_cost_mult, + ramCost: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacknet_node_ram_cost_mult, + coreCost: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacknet_node_core_cost_mult, + levelCost: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacknet_node_level_cost_mult, + }; + }, getBitNodeMultipliers: function() { if (workerScript.checkingRam) { if (workerScript.loadedFns.getBitNodeMultipliers) { @@ -28722,7 +28851,15 @@ function NetscriptFunctions(workerScript) { workerScript.scriptRef.log("Error: Not enough money to purchase server. Need $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(cost, 2)); return ""; } - var newServ = new _Server_js__WEBPACK_IMPORTED_MODULE_16__["Server"](Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_29__["createRandomIp"])(), hostnameStr, "", false, true, true, ram); + var newServ = new _Server_js__WEBPACK_IMPORTED_MODULE_16__["Server"]({ + ip: Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_29__["createRandomIp"])(), + hostname: hostnameStr, + organizationName: "", + isConnectedTo: false, + adminRights: true, + purchasedByPlayer: true, + maxRam: ram, + }); Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["AddToAllServers"])(newServ); _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].purchasedServers.push(newServ.ip); @@ -29083,7 +29220,11 @@ function NetscriptFunctions(workerScript) { } return suc; }, - getScriptRam : function (scriptname, ip) { + getScriptName : function() { + if (workerScript.checkingRam) {return 0;} + return workerScript.name; + }, + getScriptRam : function (scriptname, ip=workerScript.serverIp) { if (workerScript.checkingRam) { if (workerScript.loadedFns.getScriptRam) { return 0; @@ -29521,7 +29662,10 @@ function NetscriptFunctions(workerScript) { } _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].TorRouterCost); - var darkweb = new _Server_js__WEBPACK_IMPORTED_MODULE_16__["Server"](Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_29__["createRandomIp"])(), "darkweb", "", false, false, false, 1); + var darkweb = new _Server_js__WEBPACK_IMPORTED_MODULE_16__["Server"]({ + ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_29__["createRandomIp"])(), hostname:"darkweb", organizationName:"", + isConnectedTo:false, adminRights:false, purchasedByPlayer:false, maxRam:1 + }); Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["AddToAllServers"])(darkweb); _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_18__["SpecialServerIps"].addIp("Darkweb Server", darkweb.ip); @@ -30388,41 +30532,42 @@ function NetscriptFunctions(workerScript) { } crime = crime.toLowerCase(); + let enableCommitCrimeLog = workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null if (crime.includes("shoplift")) { - workerScript.scriptRef.log("Attempting to shoplift..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to shoplift...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitShopliftCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("rob") && crime.includes("store")) { - workerScript.scriptRef.log("Attempting to rob a store..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to rob a store...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitRobStoreCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("mug")) { - workerScript.scriptRef.log("Attempting to mug someone..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to mug someone...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitMugCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("larceny")) { - workerScript.scriptRef.log("Attempting to commit larceny..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit larceny...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitLarcenyCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("drugs")) { - workerScript.scriptRef.log("Attempting to deal drugs..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to deal drugs...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitDealDrugsCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("bond") && crime.includes("forge")) { - workerScript.scriptRef.log("Attempting to forge corporate bonds..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to forge corporate bonds...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitBondForgeryCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("traffick") && crime.includes("arms")) { - workerScript.scriptRef.log("Attempting to traffick illegal arms..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to traffick illegal arms...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitTraffickArmsCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("homicide")) { - workerScript.scriptRef.log("Attempting to commit homicide..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit homicide...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitHomicideCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("grand") && crime.includes("auto")) { - workerScript.scriptRef.log("Attempting to commit grand theft auto..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to commit grand theft auto...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitGrandTheftAutoCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("kidnap")) { - workerScript.scriptRef.log("Attempting to kidnap and ransom a high-profile target..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to kidnap and ransom a high-profile target...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitKidnapCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else if (crime.includes("assassinate")) { - workerScript.scriptRef.log("Attempting to assassinate a high-profile target..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to assassinate a high-profile target...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitAssassinationCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}) } else if (crime.includes("heist")) { - workerScript.scriptRef.log("Attempting to pull off a heist..."); + if(enableCommitCrimeLog) {workerScript.scriptRef.log("Attempting to pull off a heist...");} return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitHeistCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript}); } else { throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid crime passed into commitCrime(): " + crime); @@ -30678,7 +30823,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "substituteAliases", function() { return substituteAliases; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadAliases", function() { return loadAliases; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadGlobalAliases", function() { return loadGlobalAliases; }); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Terminal.js */ 22); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Terminal.js */ 18); let Aliases = {}; @@ -31282,6 +31427,150 @@ exports.prepareContent = function(name, inputData, isBinary, isOptimizedBinarySt /***/ }), /* 32 */ +/*!**********************!*\ + !*** ./src/Fconf.js ***! + \**********************/ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +__webpack_require__.r(__webpack_exports__); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FconfSettings", function() { return FconfSettings; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFconf", function() { return createFconf; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseFconfSettings", function() { return parseFconfSettings; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadFconf", function() { return loadFconf; }); +/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/acorn.js */ 35); +/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__); + + +var FconfSettings = { + ENABLE_BASH_HOTKEYS: false, + ENABLE_TIMESTAMPS: false, +} + +var FconfComments = { + ENABLE_BASH_HOTKEYS: "Improved Bash emulation mode. Setting this to 1 enables several\n" + + "new Terminal shortcuts and features that more closely resemble\n" + + "a real Bash-style shell. Note that when this mode is enabled,\n" + + "the default browser shortcuts are overriden by the new Bash\n" + + "shortcuts.\n\n" + + "To see a full list of the Terminal shortcuts that this enables, see:\n" + + "http://bitburner.readthedocs.io/en/latest/shortcuts.html", + ENABLE_TIMESTAMPS: "Terminal commands and log entries will be timestamped. The timestamp\n" + + "will have the format: M/D h:m", +} + +//Parse Fconf settings from the config text +//Throws an exception if parsing fails +function parseFconfSettings(config) { + var ast = Object(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["parse"])(config, {sourceType:"module"}); + var queue = []; + queue.push(ast); + while (queue.length != 0) { + var exp = queue.shift(); + switch (exp.type) { + case "BlockStatement": + case "Program": + for (var i = 0; i < exp.body.length; ++i) { + if (exp.body[i] instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["Node"]) { + queue.push(exp.body[i]); + } + } + break; + case "AssignmentExpression": + var setting, value; + if (exp.left != null && exp.left.name != null) { + setting = exp.left.name; + } else { + break; + } + if (exp.right != null && exp.right.raw != null) { + value = exp.right.raw; + } else { + break; + } + parseFconfSetting(setting, value); + break; + default: + break; + } + + for (var prop in exp) { + if (exp.hasOwnProperty(prop)) { + if (exp[prop] instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["Node"]) { + queue.push(exp[prop]); + } + } + } + } +} + +function parseFconfSetting(setting, value) { + setting = String(setting); + value = String(value); + if (setting == null || value == null || FconfSettings[setting] == null) { + console.log("WARNING: Invalid .fconf setting: " + setting); + return; + } + + //Needed to convert entered value to boolean/strings accordingly + switch(setting) { + case "ENABLE_BASH_HOTKEYS": + case "ENABLE_TIMESTAMPS": + var value = value.toLowerCase(); + if (value === "1" || value === "true" || value === "y") { + value = true; + } else { + value = false; + } + FconfSettings[setting] = value; + break; + default: + break; + } + return; +} + +//Create the .fconf file text from the settings +function createFconf() { + var res = ""; + for (var setting in FconfSettings) { + if (FconfSettings.hasOwnProperty(setting)) { + //Setting comments (description) + var comment = FconfComments[setting]; + if (comment == null) {continue;} + var comment = comment.split("\n"); + for (var i = 0; i < comment.length; ++i) { + res += ("//" + comment[i] + "\n"); + } + + var value = 0; + if (FconfSettings[setting] === true) { + value = "1"; + } else if (FconfSettings[setting] === false) { + value = "0"; + } else { + value = String(FconfSettings[setting]); + } + res += (setting + "=" + value + "\n\n"); + } + } + return res; +} + +function loadFconf(saveString) { + let tempFconfSettings = JSON.parse(saveString); + for (var setting in tempFconfSettings) { + if (tempFconfSettings.hasOwnProperty(setting)) { + FconfSettings[setting] = tempFconfSettings[setting]; + } + } +} + + + + +/***/ }), +/* 33 */ /*!*************************!*\ !*** ./src/Missions.js ***! \*************************/ @@ -32840,7 +33129,7 @@ HackingMission.prototype.finishMission = function(win) { /* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 38))) /***/ }), -/* 33 */ +/* 34 */ /*!************************!*\ !*** ./src/DarkWeb.js ***! \************************/ @@ -32857,7 +33146,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./CreateProgram.js */ 14); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Terminal.js */ 22); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Terminal.js */ 18); /* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/IPAddress.js */ 16); /* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2); @@ -33059,7 +33348,7 @@ let DarkWebItems = { /***/ }), -/* 34 */ +/* 35 */ /*!************************!*\ !*** ./utils/acorn.js ***! \************************/ @@ -36696,141 +36985,6 @@ Object.defineProperty(exports, '__esModule', { value: true }); }))); -/***/ }), -/* 35 */ -/*!**********************!*\ - !*** ./src/Fconf.js ***! - \**********************/ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -__webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FconfSettings", function() { return FconfSettings; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFconf", function() { return createFconf; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseFconfSettings", function() { return parseFconfSettings; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadFconf", function() { return loadFconf; }); -/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/acorn.js */ 34); -/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__); - - -var FconfSettings = { - ENABLE_BASH_HOTKEYS: false -} - -var FconfComments = { - ENABLE_BASH_HOTKEYS: "Improved Bash emulation mode. Setting this to 1 enables several\n" + - "new Terminal shortcuts and features that more closely resemble\n" + - "a real Bash-style shell. Note that when this mode is enabled,\n" + - "the default browser shortcuts are overriden by the new Bash\n" + - "shortcuts.\n\n" + - "To see a full list of the Terminal shortcuts that this enables, see:\n" + - "http://bitburner.readthedocs.io/en/latest/shortcuts.html", -} - -//Parse Fconf settings from the config text -//Throws an exception if parsing fails -function parseFconfSettings(config) { - var ast = Object(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["parse"])(config, {sourceType:"module"}); - var queue = []; - queue.push(ast); - while (queue.length != 0) { - var exp = queue.shift(); - switch (exp.type) { - case "BlockStatement": - case "Program": - for (var i = 0; i < exp.body.length; ++i) { - if (exp.body[i] instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["Node"]) { - queue.push(exp.body[i]); - } - } - break; - case "AssignmentExpression": - var setting, value; - if (exp.left != null && exp.left.name != null) { - setting = exp.left.name; - } else { - break; - } - if (exp.right != null && exp.right.raw != null) { - value = exp.right.raw; - } else { - break; - } - parseFconfSetting(setting, value); - break; - default: - break; - } - - for (var prop in exp) { - if (exp.hasOwnProperty(prop)) { - if (exp[prop] instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["Node"]) { - queue.push(exp[prop]); - } - } - } - } -} - -function parseFconfSetting(setting, value) { - setting = String(setting); - value = String(value); - if (setting == null || value == null || FconfSettings[setting] == null) { - console.log("WARNING: Invalid .fconf setting: " + setting); - return; - } - - //Needed to convert entered value to boolean/strings accordingly - switch(setting) { - case "ENABLE_BASH_HOTKEYS": - var value = value.toLowerCase(); - if (value === "1" || value === "true" || value === "y") { - value = true; - } else { - value = false; - } - FconfSettings[setting] = value; - break; - default: - break; - } - return; -} - -//Create the .fconf file text from the settings -function createFconf() { - var res = ""; - for (var setting in FconfSettings) { - if (FconfSettings.hasOwnProperty(setting)) { - //Setting comments (description) - var comment = FconfComments[setting]; - if (comment == null) {continue;} - var comment = comment.split("\n"); - for (var i = 0; i < comment.length; ++i) { - res += ("//" + comment[i] + "\n"); - } - - var value = 0; - if (FconfSettings[setting] === true) { - value = "1"; - } else if (FconfSettings[setting] === false) { - value = "0"; - } else { - value = String(FconfSettings[setting]); - } - res += (setting + "=" + value + "\n"); - } - } - return res; -} - -function loadFconf(saveString) { - FconfSettings = JSON.parse(saveString); -} - - - - /***/ }), /* 36 */ /*!*********************!*\ @@ -38021,12 +38175,24 @@ function updateGangContent() { for (var gangname in AllGangs) { if (AllGangs.hasOwnProperty(gangname)) { var gangTerritoryInfo = AllGangs[gangname]; + let territory = gangTerritoryInfo.territory*100; + + //Fix some rounding issues graphically + let displayNumber; + if (territory <= 0) { + displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(0, 2); + } else if (territory >= 100) { + displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(100, 2); + } else { + displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(territory, 2); + } + if (gangname == _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName) { gangTerritoryInfoText.innerHTML += ("" + gangname + "
(Power: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(gangTerritoryInfo.power, 6) + "): " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(100*gangTerritoryInfo.territory, 2) + "%

"); + displayNumber + "%

"); } else { gangTerritoryInfoText.innerHTML += (gangname + "
(Power: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(gangTerritoryInfo.power, 6) + "): " + - Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(100*gangTerritoryInfo.territory, 2) + "%

"); + displayNumber + "%

"); } } } @@ -38078,10 +38244,19 @@ function updateGangContent() { })); gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {})); - var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory; + //Fix some rounding issues graphically + var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory * 100; + let displayNumber; + if (territoryMult <= 0) { + displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(0, 2); + } else if (territoryMult >= 100) { + displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(100, 2); + } else { + displayNumber = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(territoryMult, 2); + } gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", { //Territory multiplier display:"inline-block", - innerText:"Territory: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(territoryMult * 100, 3) + "%", + innerText:"Territory: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(displayNumber, 3) + "%", tooltip:"The percentage of total territory your Gang controls" })); gangInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {})); @@ -49494,7 +49669,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Literature.js */ 53); /* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Location.js */ 4); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Player.js */ 0); -/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/decimal.js */ 23); +/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/decimal.js */ 24); /* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_utils_decimal_js__WEBPACK_IMPORTED_MODULE_6__); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); @@ -54741,19 +54916,19 @@ function applySourceFile(srcFile) { "use strict"; __webpack_require__.r(__webpack_exports__); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setActiveScriptsClickHandlers", function() { return setActiveScriptsClickHandlers; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addActiveScriptsItem", function() { return addActiveScriptsItem; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "deleteActiveScriptsItem", function() { return deleteActiveScriptsItem; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateActiveScriptsItems", function() { return updateActiveScriptsItems; }); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); -/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0); -/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); -/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); -/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/LogBox.js */ 51); -/* harmony import */ var _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/numeral.min.js */ 13); -/* harmony import */ var _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_6__); -/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2); +/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.js */ 5); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); +/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0); +/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Server.js */ 10); +/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); +/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); +/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/LogBox.js */ 51); +/* harmony import */ var _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/numeral.min.js */ 13); +/* harmony import */ var _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7__); +/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2); @@ -54764,272 +54939,274 @@ __webpack_require__.r(__webpack_exports__); -/* 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 = {}; +let ActiveScriptsTasks = []; //Sequentially schedule the creation/deletion of UI elements function createActiveScriptsServerPanel(server) { - var panelname = "active-scripts-server-panel-" + server.hostname; - var activeScriptsList = document.getElementById("active-scripts-list"); + ActiveScriptsTasks.push(function(server) { + let hostname = server.hostname; - //Div of entire Panel - var panelDiv = document.createElement("div"); - panelDiv.setAttribute("id", panelname); + var activeScriptsList = document.getElementById("active-scripts-list"); - //Panel Header - var panelHdr = document.createElement("button"); - panelHdr.setAttribute("class", "active-scripts-server-header") - panelHdr.setAttribute("id", panelname + "-hdr"); - panelHdr.innerHTML = server.hostname; + let res = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createAccordionElement"])({hdrText:hostname}); + let li = res[0]; + var hdr = res[1]; + let panel = res[2]; - //Panel content - var panelContentDiv = document.createElement("div"); - panelContentDiv.setAttribute("class", "active-scripts-server-panel"); - panelContentDiv.setAttribute("id", panelname + "-content"); + if (ActiveScriptsUI[hostname] != null) { + console.log("WARNING: Tried to create already-existing Active Scripts Server panel. This is most likely fine. It probably means many scripts just got started up on a new server. Aborting"); + return; + } - //List of scripts - var panelScriptList = document.createElement("ul"); - panelScriptList.setAttribute("id", panelname + "-script-list"); + var panelScriptList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("ul"); + panel.appendChild(panelScriptList); + activeScriptsList.appendChild(li); - panelContentDiv.appendChild(panelScriptList); - panelDiv.appendChild(panelHdr); - panelDiv.appendChild(panelContentDiv); - activeScriptsList.appendChild(panelDiv); + 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 + }; - setActiveScriptsClickHandlers() //Reset click handlers - - return panelDiv; + return li; + }.bind(null, server)); } //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); - return; - } + ActiveScriptsTasks.push(function(server) { + 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; + } + + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(ActiveScriptsUI[hostname].panel); + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeElement"])(ActiveScriptsUI[hostname].header); + delete ActiveScriptsUI[hostname]; + }.bind(null, server)); } function addActiveScriptsItem(workerscript) { - //Get server panel - var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_2__["getServer"])(workerscript.serverIp); + var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["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 - 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); + ActiveScriptsTasks.push(function(workerscript, hostname) { + //Create the unique identifier (key) for this script + var itemNameArray = ["active", "scripts", hostname, workerscript.name]; + for (var i = 0; i < workerscript.args.length; ++i) { + itemNameArray.push(String(workerscript.args[i])); + } + var itemName = itemNameArray.join("-"); - var btn = document.createElement("button"); - btn.setAttribute("class", "active-scripts-script-header"); - btn.setAttribute("id", itemName + "-header"); - btn.innerHTML = workerscript.name; + let res = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["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); + //Handle the constant elements on the panel that don't change after creation + //Threads, args, kill/log button + panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("p", { + innerHTML: "Threads: " + workerscript.scriptRef.threads + "
" + + "Args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["printArray"])(workerscript.args) + })); + var panelText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("p", { + innerText:"Loading...", fontSize:"14px", + }); + panel.appendChild(panelText); + panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("br")); + panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("span", { + innerText:"Log", class:"active-scripts-button", margin:"4px", padding:"4px", + clickListener:()=>{ + Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_6__["logBoxCreate"])(workerscript.scriptRef); + return false; + } + })); + panel.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["createElement"])("span", { + innerText:"Kill Script", class:"active-scripts-button", margin:"4px", padding:"4px", + clickListener:()=>{ + Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["killWorkerScript"])(workerscript.scriptRef, workerscript.scriptRef.scriptRef.server); + Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Killing script, may take a few minutes to complete..."); + return false; + } + })); - createActiveScriptsText(workerscript, itemContentDiv); - - //Append element to list - var list = getActiveScriptsServerList(server); - list.appendChild(item); - - setActiveScriptsClickHandlers() //Reset click handlers + //Append element to list + ActiveScriptsUI[hostname]["panelList"].appendChild(li); + ActiveScriptsUI[hostname].scripts[itemName] = li; + ActiveScriptsUI[hostname].scriptHdrs[itemName] = hdr; + ActiveScriptsUI[hostname].scriptStats[itemName] = panelText; + }.bind(null, workerscript, hostname)); } function deleteActiveScriptsItem(workerscript) { - var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_2__["getServer"])(workerscript.serverIp); - if (server == null) { - console.log("ERROR: Invalid server IP for workerscript."); - 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); - if (li == null) { - console.log("could not find Active scripts li element for: " + workerscript.name); - return; - } - li.parentNode.removeChild(li); - deleteActiveScriptsServerPanel(server); + ActiveScriptsTasks.push(function(workerscript) { + var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp); + if (server == null) { + throw new Error("ERROR: Invalid server IP for workerscript. This most likely occurred because " + + "you tried to delete a large number of scripts and also purchased servers at the " + + "same time. It's not a big deal, just save and refresh the game."); + 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("-"); + + let li = ActiveScriptsUI[hostname].scripts[itemName]; + if (li == null) { + console.log("ERROR: Cannot find Active Script UI element for workerscript: "); + console.log(workerscript); + return; + } + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["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); + } + }.bind(null, workerscript)); } //Update the ActiveScriptsItems array function updateActiveScriptsItems() { + //Run tasks that need to be done sequentially (adding items, creating/deleting server panels) + //We'll limit this to 50 at a time in case someone decides to start a bunch of scripts all at once... + let numTasks = Math.min(100, ActiveScriptsTasks.length); + for (let i = 0; i < numTasks; ++i) { + let task = ActiveScriptsTasks.shift(); + try { + task(); + } catch(e) { + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["exceptionAlert"])(e); + console.log(task); + } + } + + if (_engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Page.ActiveScripts) {return;} var total = 0; - for (var i = 0; i < _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__["workerScripts"].length; ++i) { - total += updateActiveScriptsItemContent(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__["workerScripts"][i]); + for (var i = 0; i < _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["workerScripts"].length; ++i) { + try { + total += updateActiveScriptsItemContent(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_1__["workerScripts"][i]); + } catch(e) { + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["exceptionAlert"])(e); + } } document.getElementById("active-scripts-total-prod").innerHTML = - "Total online production of Active Scripts: " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_6___default()(total).format('$0.000a') + " / sec
" + + "Total online production of Active Scripts: " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7___default()(total).format('$0.000a') + " / sec
" + "Total online production since last Aug installation: " + - _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_6___default()(_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].scriptProdSinceLastAug).format('$0.000a') + " (" + - _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_6___default()(_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].scriptProdSinceLastAug / (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].playtimeSinceLastAug/1000)).format('$0.000a') + " / sec)"; + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7___default()(_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].scriptProdSinceLastAug).format('$0.000a') + " (" + + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7___default()(_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].scriptProdSinceLastAug / (_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].playtimeSinceLastAug/1000)).format('$0.000a') + " / sec)"; return total; } //Updates the content of the given item in the Active Scripts list function updateActiveScriptsItemContent(workerscript) { - var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_2__["getServer"])(workerscript.serverIp); + var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp); if (server == null) { console.log("ERROR: Invalid server IP for workerscript."); return; } + let hostname = server.hostname; + if (ActiveScriptsUI[hostname] == null) { + return; //Hasn't been created yet. We'll skip it + } + 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") - //Add the updated text back. Returns the total online production rate - return updateActiveScriptsText(workerscript, itemContent); + if (ActiveScriptsUI[hostname].scriptStats[itemName] == null) { + return; //Hasn't been fully added yet. We'll skip it + } + var item = ActiveScriptsUI[hostname].scriptStats[itemName]; + + //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: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_4__["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() { - Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_5__["logBoxCreate"])(workerscript.scriptRef); - return false; - }); - killButton.addEventListener("click", function() { - Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__["killWorkerScript"])(workerscript.scriptRef, workerscript.scriptRef.scriptRef.server); - Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_3__["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 = Object(_Server_js__WEBPACK_IMPORTED_MODULE_3__["getServer"])(workerscript.serverIp); + if (server == null) { + console.log("ERROR: Invalid server IP for workerscript."); + return; + } + let hostname = server.hostname; + if (ActiveScriptsUI[hostname] == null || ActiveScriptsUI[hostname].scriptHdrs[itemName] == 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 - //Online - var onlineTotalMoneyMade = "Total online production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(workerscript.scriptRef.onlineMoneyMade, 2); - var onlineTotalExpEarned = (Array(26).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(workerscript.scriptRef.onlineExpGained, 2) + " hacking exp").replace( / /g, " "); - var onlineMps = workerscript.scriptRef.onlineMoneyMade / workerscript.scriptRef.onlineRunningTime; - var onlineMpsText = "Online production rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(onlineMps, 2) + "/second"; + + //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;} + + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["removeChildrenFromElement"])(item); + + //Online + var onlineTotalMoneyMade = "Total online production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.onlineMoneyMade, 2); + var onlineTotalExpEarned = (Array(26).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.onlineExpGained, 2) + " hacking exp").replace( / /g, " "); + + var onlineMpsText = "Online production rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(onlineMps, 2) + "/second"; var onlineEps = workerscript.scriptRef.onlineExpGained / workerscript.scriptRef.onlineRunningTime; - var onlineEpsText = (Array(25).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(onlineEps, 4) + " hacking exp/second").replace( / /g, " "); + var onlineEpsText = (Array(25).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(onlineEps, 4) + " hacking exp/second").replace( / /g, " "); //Offline - var offlineTotalMoneyMade = "Total offline production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(workerscript.scriptRef.offlineMoneyMade, 2); - var offlineTotalExpEarned = (Array(27).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(workerscript.scriptRef.offlineExpGained, 2) + " hacking exp").replace( / /g, " "); + var offlineTotalMoneyMade = "Total offline production: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.offlineMoneyMade, 2); + var offlineTotalExpEarned = (Array(27).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(workerscript.scriptRef.offlineExpGained, 2) + " hacking exp").replace( / /g, " "); var offlineMps = workerscript.scriptRef.offlineMoneyMade / workerscript.scriptRef.offlineRunningTime; - var offlineMpsText = "Offline production rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(offlineMps, 2) + "/second"; + var offlineMpsText = "Offline production rate: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(offlineMps, 2) + "/second"; var offlineEps = workerscript.scriptRef.offlineExpGained / workerscript.scriptRef.offlineRunningTime; - var offlineEpsText = (Array(26).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["formatNumber"])(offlineEps, 4) + " hacking exp/second").replace( / /g, " "); + var offlineEpsText = (Array(26).join(" ") + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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; } @@ -55052,7 +55229,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _Prestige_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Prestige.js */ 57); /* harmony import */ var _SourceFile_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./SourceFile.js */ 42); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Terminal.js */ 22); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Terminal.js */ 18); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); /* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 12); @@ -55395,7 +55572,7 @@ function createBitNodeYesNoEventListeners(newBitNode, destroyedBitNode, flume=fa "use strict"; __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NetscriptPort", function() { return NetscriptPort; }); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Settings.js */ 24); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Settings.js */ 23); function NetscriptPort() { @@ -55465,22 +55642,22 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Constants.js */ 3); /* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./engine.js */ 5); /* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Faction.js */ 11); -/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 35); +/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 32); /* harmony import */ var _Gang_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Gang.js */ 36); /* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./HacknetNode.js */ 39); /* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Message.js */ 28); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Script.js */ 26); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Server.js */ 10); -/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Settings.js */ 24); +/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Settings.js */ 23); /* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); -/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./StockMarket.js */ 21); +/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./StockMarket.js */ 22); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_GameOptions_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../utils/GameOptions.js */ 54); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); /* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8); /* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2); -/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/decimal.js */ 23); +/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/decimal.js */ 24); /* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_20___default = /*#__PURE__*/__webpack_require__.n(_utils_decimal_js__WEBPACK_IMPORTED_MODULE_20__); @@ -56111,7 +56288,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Location.js */ 4); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./RedPill.js */ 44); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Terminal.js */ 22); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Terminal.js */ 18); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); /* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8); @@ -56138,7 +56315,7 @@ var CityNames = ["Aevum", "Chongqing", "Sector-12", "New Tokyo", "Ishima", "Volh var CyclesPerSecond = 5; //Game cycle is 200 ms var StaminaGainPerSecond = 0.0085; -var BaseStaminaLoss = 0.29; //Base stamina loss per action. Increased based on difficulty +var BaseStaminaLoss = 0.285; //Base stamina loss per action. Increased based on difficulty var MaxStaminaToGainFactor = 70000; //Max Stamina is divided by this to get bonus stamina gain var DifficultyToTimeFactor = 10; //Action Difficulty divided by this to get base action time @@ -56805,9 +56982,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(400, 800), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, 5), + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(300, 800), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56819,7 +56996,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(250, 500), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1, 3), + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(200, 750), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56831,7 +57008,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(300, 600), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(1,4), + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(300, 900), countGrowth:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56846,7 +57023,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(100, 300), countGrowth:1, + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56859,7 +57036,7 @@ Bladeburner.prototype.create = function() { "data.", baseDifficulty:500, difficultyFac:1.04, rewardFac:1.09, reqdRank:100, rankGain:4, rankLoss:0.4, hpLoss:2, - count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(100, 250), countGrowth:1, + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56870,7 +57047,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(100,250), countGrowth:0.75, + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56882,7 +57059,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(50, 100), countGrowth:0.2, + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56894,7 +57071,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(50, 200), countGrowth:0.1, + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -56906,7 +57083,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:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(50, 150), countGrowth:0.1, + count:Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["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 @@ -57362,10 +57539,10 @@ Bladeburner.prototype.completeAction = function() { break; case ActionTypes["Training"]: this.stamina -= (0.5 * BaseStaminaLoss); - var strExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].strength_exp_mult, - defExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].defense_exp_mult, - dexExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].dexterity_exp_mult, - agiExpGain = 20 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].agility_exp_mult, + var strExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].strength_exp_mult, + defExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].defense_exp_mult, + dexExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].dexterity_exp_mult, + agiExpGain = 30 * _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].agility_exp_mult, staminaGain = 0.04 * this.skillMultipliers.stamina; _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainStrengthExp(strExpGain); _Player_js__WEBPACK_IMPORTED_MODULE_4__["Player"].gainDefenseExp(defExpGain); @@ -59263,9 +59440,9 @@ function initBladeburner() { Skills[SkillNames.BladesIntuition] = new Skill({ name:SkillNames.BladesIntuition, desc:"Each level of this skill increases your success chance " + - "for all contracts and operations by 2%", + "for all contracts and operations by 3%", baseCost:5, costInc:2, - successChanceAll:2 + successChanceAll:3 }); Skills[SkillNames.Reaper] = new Skill({ name:SkillNames.Reaper, @@ -59277,9 +59454,9 @@ function initBladeburner() { Skills[SkillNames.Cloak] = new Skill({ name:SkillNames.Cloak, desc:"Each level of this skill increases your " + - "success chance in stealth-related contracts and operations by 5%", + "success chance in stealth-related contracts and operations by 5.5%", baseCost:3, costInc:1, - successChanceStealth:5 + successChanceStealth:5.5 }); //TODO Marksman @@ -59289,7 +59466,7 @@ function initBladeburner() { name:SkillNames.Overclock, desc:"Each level of this skill decreases the time it takes " + "to attempt a contract or operation by 1% (Max Level: 99)", - baseCost:5, costInc:1, maxLvl:99, + baseCost:5, costInc:1, maxLvl:95, actionTime:1 }); Skills[SkillNames.EvasiveSystem] = new Skill({ @@ -59302,32 +59479,32 @@ function initBladeburner() { Skills[SkillNames.ShortCircuit] = new Skill({ name:SkillNames.ShortCircuit, desc:"Each level of this skill increases your success chance " + - "in contracts and operations that involve retirement by 5%", + "in contracts and operations that involve retirement by 5.5%", baseCost:3, costInc:2, - successChanceKill:5 + successChanceKill:5.5 }); Skills[SkillNames.DigitalObserver] = new Skill({ name:SkillNames.DigitalObserver, desc:"Each level of this skill increases your success chance in " + - "all operations by 3%", + "all operations by 4%", baseCost:5, costInc:2, - successChanceOperation:3 + successChanceOperation:4 }); Skills[SkillNames.Datamancer] = new Skill({ name:SkillNames.Datamancer, desc:"Each level of this skill increases your effectiveness in " + - "synthoid population analysis and investigation by 4%. " + + "synthoid population analysis and investigation by 5%. " + "This affects all actions that can potentially increase " + "the accuracy of your synthoid population/community estimates.", baseCost:3,costInc:1, - successChanceEstimate:4 + successChanceEstimate:5 }); Skills[SkillNames.Tracer] = new Skill({ name:SkillNames.Tracer, desc:"Each level of this skill increases your success chance in " + - "all contracts by 3%", + "all contracts by 4%", baseCost:3, costInc:2, - successChanceContract:3 + successChanceContract:4 }); Skills[SkillNames.CybersEdge] = new Skill({ name:SkillNames.CybersEdge, @@ -59915,7 +60092,7 @@ __webpack_require__.r(__webpack_exports__); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logBoxUpdateText", function() { return logBoxUpdateText; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logBoxOpened", function() { return logBoxOpened; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "logBoxCurrentScript", function() { return logBoxCurrentScript; }); -/* harmony import */ var _src_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../src/NetscriptWorker.js */ 20); +/* harmony import */ var _src_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../src/NetscriptWorker.js */ 21); /* harmony import */ var _HelperFunctions_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./HelperFunctions.js */ 1); @@ -60954,7 +61131,7 @@ __webpack_require__.r(__webpack_exports__); /* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prestigeAugmentation", function() { return prestigeAugmentation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prestigeSourceFile", function() { return prestigeSourceFile; }); /* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ActiveScriptsUI.js */ 43); -/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Augmentations.js */ 18); +/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Augmentations.js */ 19); /* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./BitNode.js */ 15); /* harmony import */ var _CinematicText_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./CinematicText.js */ 70); /* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Company.js */ 9); @@ -60965,13 +61142,13 @@ __webpack_require__.r(__webpack_exports__); /* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Location.js */ 4); /* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Message.js */ 28); /* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 29); -/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./NetscriptWorker.js */ 20); +/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21); /* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Player.js */ 0); /* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Server.js */ 10); /* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17); -/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./StockMarket.js */ 21); -/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Terminal.js */ 22); -/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../utils/decimal.js */ 23); +/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./StockMarket.js */ 22); +/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Terminal.js */ 18); +/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../utils/decimal.js */ 24); /* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(_utils_decimal_js__WEBPACK_IMPORTED_MODULE_18__); /* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6); /* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1); @@ -66091,7 +66268,10 @@ function purchaseServer(ram, cost) { } //Create server - var newServ = new _Server_js__WEBPACK_IMPORTED_MODULE_2__["Server"](Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_4__["createRandomIp"])(), hostname, "", false, true, true, ram); + var newServ = new _Server_js__WEBPACK_IMPORTED_MODULE_2__["Server"]({ + ip:Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_4__["createRandomIp"])(), hostname:hostname, organizationName:"", + isConnectedTo:false, adminRights:true, purchasedByPlayer:true, maxRam:ram + }); Object(_Server_js__WEBPACK_IMPORTED_MODULE_2__["AddToAllServers"])(newServ); //Add to Player's purchasedServers array @@ -69447,6 +69627,7 @@ function infiltrationBoxCreate(inst) { var selector = document.getElementById("infiltration-faction-select"); selector.innerHTML = ""; for (var i = 0; i < _src_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].factions.length; ++i) { + if (_src_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].factions[i] === "Bladeburners") {continue;} selector.innerHTML += ""; } diff --git a/index.html b/index.html index 49e843cd1..ad7741b63 100644 --- a/index.html +++ b/index.html @@ -744,7 +744,7 @@ - @@ -825,7 +825,7 @@ If this is set, then most hotkeys (keyboard shortcuts) in the game are disabled. This includes Terminal commands, hotkeys to navigate between different parts of the game, - and the "Save and Close (Ctrl + b)" hotkey in the Text Editor. + and the "Save and Close (Ctrl + b)" hotkey in the Text Editor. diff --git a/src/ActiveScriptsUI.js b/src/ActiveScriptsUI.js index d559251f3..4460bdfa4 100644 --- a/src/ActiveScriptsUI.js +++ b/src/ActiveScriptsUI.js @@ -1,3 +1,4 @@ +import {Engine} from "./engine.js"; import {workerScripts, addWorkerScript, killWorkerScript} from "./NetscriptWorker.js"; @@ -147,7 +148,9 @@ function deleteActiveScriptsItem(workerscript) { ActiveScriptsTasks.push(function(workerscript) { var server = getServer(workerscript.serverIp); if (server == null) { - console.log("ERROR: Invalid server IP for workerscript."); + throw new Error("ERROR: Invalid server IP for workerscript. This most likely occurred because " + + "you tried to delete a large number of scripts and also purchased servers at the " + + "same time. It's not a big deal, just save and refresh the game."); return; } let hostname = server.hostname; @@ -182,7 +185,7 @@ function deleteActiveScriptsItem(workerscript) { function updateActiveScriptsItems() { //Run tasks that need to be done sequentially (adding items, creating/deleting server panels) //We'll limit this to 50 at a time in case someone decides to start a bunch of scripts all at once... - let numTasks = Math.min(50, ActiveScriptsTasks.length); + let numTasks = Math.min(100, ActiveScriptsTasks.length); for (let i = 0; i < numTasks; ++i) { let task = ActiveScriptsTasks.shift(); try { @@ -193,6 +196,7 @@ function updateActiveScriptsItems() { } } + if (Engine.currentPage !== Engine.Page.ActiveScripts) {return;} var total = 0; for (var i = 0; i < workerScripts.length; ++i) { try { diff --git a/src/Bladeburner.js b/src/Bladeburner.js index 4c29f37b8..219042d35 100644 --- a/src/Bladeburner.js +++ b/src/Bladeburner.js @@ -1248,10 +1248,10 @@ Bladeburner.prototype.completeAction = function() { break; case ActionTypes["Training"]: this.stamina -= (0.5 * BaseStaminaLoss); - var strExpGain = 20 * Player.strength_exp_mult, - defExpGain = 20 * Player.defense_exp_mult, - dexExpGain = 20 * Player.dexterity_exp_mult, - agiExpGain = 20 * Player.agility_exp_mult, + var strExpGain = 30 * Player.strength_exp_mult, + defExpGain = 30 * Player.defense_exp_mult, + dexExpGain = 30 * Player.dexterity_exp_mult, + agiExpGain = 30 * Player.agility_exp_mult, staminaGain = 0.04 * this.skillMultipliers.stamina; Player.gainStrengthExp(strExpGain); Player.gainDefenseExp(defExpGain); @@ -3175,7 +3175,7 @@ function initBladeburner() { name:SkillNames.Overclock, desc:"Each level of this skill decreases the time it takes " + "to attempt a contract or operation by 1% (Max Level: 99)", - baseCost:5, costInc:1, maxLvl:99, + baseCost:5, costInc:1, maxLvl:95, actionTime:1 }); Skills[SkillNames.EvasiveSystem] = new Skill({ diff --git a/src/Constants.js b/src/Constants.js index 749baefa0..4010560ed 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -1,5 +1,5 @@ let CONSTANTS = { - Version: "0.36.0", + Version: "0.36.1", //Max level for any skill, assuming no multipliers. Determined by max numerical value in javascript for experience //and the skill level formula in Player.js. Note that all this means it that when experience hits MAX_INT, then @@ -1147,21 +1147,22 @@ let CONSTANTS = { "** Datamancer skill effect increased from 4% per level to 5%
" + "** Slightly decreased the base stamina cost of contracts/operations
" + "** Slightly increased the effects of the Tracer, Digital Observer, Short Circuit, Cloak, and Blade's Intuition skills
" + + "** Overclock skill capped at level 95, rather than 99
" + + "** Training gives significantly more exp/s
" + "* Crime, Infiltration, and Hacking are now slightly more profitable in BN-6
" + + "* Gyms are now more expensive, but give slightly more exp
" + "* Added getScriptName() and getHacknetMultipliers() Netscript functions (added by Github user hydroflame)
" + - "* getScriptRam() Netscript function now has default value for the second argument, which is hostname/ip (implemented by Github user hydroflame)
" + + "* getScriptRam() Netscript function now has default value for the second argument, which is hostname/ip (implemented by Github user hydroflame)
" + "* There is now a soft-cap on stock price, which means it's no longer possible for the price of a stock to reach insanely-high values
" + - "* The ctrl+b hotkey in the text editor is now also triggered by command+b or winkey+b
" + + "* The ctrl+b hotkey in the text editor should now also be triggered by command+b on OSX (I don't have OSX so I can't confirm if this works)
" + "* Many servers now have additional RAM
" + "* Added an option to disable hotkeys/keyboard shortcuts
" + "* Refactored 'Active Scripts' UI page to optimize its performance
" + - "* Added a new .fconf setting: ENABLE_TIMESTAMP
" + + "* Added a new .fconf Terminal setting: ENABLE_TIMESTAMP
" + + "* 'Netscript Execution Time', which can be found in the Options, now has a minimum value of 15ms rather than 25ms
" + "* Bug Fix: Fixed a typo in the Fulcrum Technologies company name (Technolgies -> Technologies)
" + "* Bug Fix: hacknetnodes keyword should no longer incur RAM cost if its in a comment
" + - "v0.36.0
" + - "* Added BN-6: Bladeburners
" + - "* Rebalanced many combat Augmentations so that they are slightly less powerful
" + - "* Bug Fix: When faction invites are suppressed, an invitation will no longer load the Faction page
" + "* Bug Fix: disableLog() now works for the commitCrime() Netscript function (fixed by Github user hydroflame)" } diff --git a/src/Faction.js b/src/Faction.js index bf01ad342..8abffd37b 100644 --- a/src/Faction.js +++ b/src/Faction.js @@ -1095,7 +1095,9 @@ function getNextNeurofluxLevel() { } } if (aug == null) { - console.log("ERROR, Could not find NeuroFlux Governor aug"); + console.log("WARNING: Could not find NeuroFlux Governor aug. This is OK if " + + "it happens during the loading/initialization of the game, but probably " + + "indicates something seriously wrong at other times"); return 1; } } diff --git a/src/Location.js b/src/Location.js index 37cdd30e2..65ad38c67 100644 --- a/src/Location.js +++ b/src/Location.js @@ -565,13 +565,13 @@ function displayLocationContent() { break; case Locations.AevumCrushFitnessGym: - var costMult = 2, expMult = 1.5; + var costMult = 3, expMult = 2; displayGymLocationContent(costMult); setGymLocationButtons(costMult, expMult); break; case Locations.AevumSnapFitnessGym: - var costMult = 6, expMult = 4; + var costMult = 10, expMult = 5; displayGymLocationContent(costMult); setGymLocationButtons(costMult, expMult); break; @@ -793,7 +793,7 @@ function displayLocationContent() { break; case Locations.Sector12PowerhouseGym: - var costMult = 10, expMult = 7.5; + var costMult = 20, expMult = 10; displayGymLocationContent(costMult); setGymLocationButtons(costMult, expMult); break; @@ -1045,7 +1045,7 @@ function displayLocationContent() { break; case Locations.VolhavenMilleniumFitnessGym: - var costMult = 3, expMult = 2.5; + var costMult = 7, expMult = 4; displayGymLocationContent(costMult); setGymLocationButtons(costMult, expMult); break; diff --git a/src/NetscriptWorker.js b/src/NetscriptWorker.js index 0fc043d26..719ba7f60 100644 --- a/src/NetscriptWorker.js +++ b/src/NetscriptWorker.js @@ -53,6 +53,7 @@ function prestigeWorkerScripts() { deleteActiveScriptsItem(workerScripts[i]); workerScripts[i].env.stopFlag = true; } + updateActiveScriptsItems(); //Force UI to update workerScripts.length = 0; } diff --git a/src/Script.js b/src/Script.js index 38d770554..8e616e34d 100644 --- a/src/Script.js +++ b/src/Script.js @@ -59,7 +59,7 @@ function scriptEditorInit() { } var closeButton = createElement("a", { class:"a-link-button", display:"inline-block", - innerText:"Save & Close (Ctrl + b)", + innerText:"Save & Close (Ctrl/Cmd + b)", clickListener:()=>{ saveAndCloseScriptEditor(); return false; diff --git a/src/Server.js b/src/Server.js index 0a09c43ad..a9346fc96 100644 --- a/src/Server.js +++ b/src/Server.js @@ -68,29 +68,6 @@ function Server(params={ip:createRandomIp(), hostname:""}) { this.openPortCount = 0; }; -/* -//Set the hacking properties of a server -Server.prototype.setHackingParameters = function(requiredHackingSkill, moneyAvailable, hackDifficulty, serverGrowth) { - this.requiredHackingSkill = requiredHackingSkill; - if (isNaN(moneyAvailable)) { - this.moneyAvailable = 1e6; - } else { - this.moneyAvailable = moneyAvailable * BitNodeMultipliers.ServerStartingMoney; - } - this.moneyMax = - this.hackDifficulty = hackDifficulty * BitNodeMultipliers.ServerStartingSecurity; - this.baseDifficulty = hackDifficulty * BitNodeMultipliers.ServerStartingSecurity; - this.minDifficulty = Math.max(1, Math.round(this.hackDifficulty / 3)); - this.serverGrowth = serverGrowth; -} - -//Set the port properties of a server -//Right now its only the number of open ports needed to PortHack the server. -Server.prototype.setPortProperties = function(numOpenPortsReq) { - this.numOpenPortsRequired = numOpenPortsReq; -} -*/ - Server.prototype.setMaxRam = function(ram) { this.maxRam = ram; } diff --git a/src/engine.js b/src/engine.js index 9f2c803d5..f6a0e2d73 100644 --- a/src/engine.js +++ b/src/engine.js @@ -498,30 +498,18 @@ let Engine = { displayCharacterOverviewInfo: function() { if (Player.hp == null) {Player.hp = Player.max_hp;} + var overviewText = "Hp: " + Player.hp + " / " + Player.max_hp + "
" + + "Money: " + numeral(Player.money.toNumber()).format('($0.000a)') + "
" + + "Hack: " + (Player.hacking_skill).toLocaleString() + "
" + + "Str: " + (Player.strength).toLocaleString() + "
" + + "Def: " + (Player.defense).toLocaleString() + "
" + + "Dex: " + (Player.dexterity).toLocaleString() + "
" + + "Agi: " + (Player.agility).toLocaleString() + "
" + + "Cha: " + (Player.charisma).toLocaleString(); if (Player.intelligence >= 1) { - document.getElementById("character-overview-text").innerHTML = - ("Hp: " + Player.hp + " / " + Player.max_hp + "
" + - "Money: " + numeral(Player.money.toNumber()).format('($0.000a)') + "
" + - "Hack: " + (Player.hacking_skill).toLocaleString() + "
" + - "Str: " + (Player.strength).toLocaleString() + "
" + - "Def: " + (Player.defense).toLocaleString() + "
" + - "Dex: " + (Player.dexterity).toLocaleString() + "
" + - "Agi: " + (Player.agility).toLocaleString() + "
" + - "Cha: " + (Player.charisma).toLocaleString() + "
" + - "Int: " + (Player.intelligence).toLocaleString() - ).replace( / /g, " " ); - } else { - document.getElementById("character-overview-text").innerHTML = - ("Hp: " + Player.hp + " / " + Player.max_hp + "
" + - "Money: " + numeral(Player.money.toNumber()).format('($0.000a)') + "
" + - "Hack: " + (Player.hacking_skill).toLocaleString() + "
" + - "Str: " + (Player.strength).toLocaleString() + "
" + - "Def: " + (Player.defense).toLocaleString() + "
" + - "Dex: " + (Player.dexterity).toLocaleString() + "
" + - "Agi: " + (Player.agility).toLocaleString() + "
" + - "Cha: " + (Player.charisma).toLocaleString() - ).replace( / /g, " " ); + overviewText += "
Int: " + (Player.intelligence).toLocaleString(); } + document.getElementById("character-overview-text").innerHTML = overviewText.replace( / /g, " "); }, /* Display character info */ @@ -899,9 +887,10 @@ let Engine = { Counters: { autoSaveCounter: 300, //Autosave every minute updateSkillLevelsCounter: 10, //Only update skill levels every 2 seconds. Might improve performance - updateDisplays: 3, //Update displays such as Active Scripts display and character display + updateDisplays: 3, updateDisplaysMed: 9, updateDisplaysLong: 15, + updateActiveScriptsDisplay: 5, createProgramNotifications: 10, //Checks whether any programs can be created and notifies checkFactionInvitations: 100, //Check whether you qualify for any faction invitations passiveFactionGrowth: 600, @@ -939,6 +928,16 @@ let Engine = { Engine.Counters.updateSkillLevelsCounter = 10; } + if (Engine.Counters.updateActiveScriptsDisplay <= 0) { + //Always update, but make the interval longer if the page isn't active + updateActiveScriptsItems(); + if (Engine.currentPage === Engine.Page.ActiveScripts) { + Engine.Counters.updateActiveScriptsDisplay = 5; + } else { + Engine.Counters.updateActiveScriptsDisplay = 15; + } + } + if (Engine.Counters.updateDisplays <= 0) { Engine.displayCharacterOverviewInfo(); if (Engine.currentPage == Engine.Page.CharacterInfo) { @@ -957,12 +956,10 @@ let Engine = { } if (Engine.Counters.updateDisplaysMed <= 0) { - if (Engine.currentPage == Engine.Page.ActiveScripts) { - updateActiveScriptsItems(); - } else if (Engine.currentPage === Engine.Page.Corporation) { + if (Engine.currentPage === Engine.Page.Corporation) { Player.corporation.updateUIContent(); } - Engine.Counters.updateDisplaysMed = 6; + Engine.Counters.updateDisplaysMed = 9; } if (Engine.Counters.updateDisplaysLong <= 0) {