From 4ccad83e5e8a4e8c6765ef3157f89734ac1adbf0 Mon Sep 17 00:00:00 2001 From: danielyxie Date: Fri, 20 Oct 2017 16:59:54 -0500 Subject: [PATCH 1/2] Initial implementation of BitNode-8: Ghost of Wall Street. Added TextFile.js to git. Added design for company management --- css/menupages.css | 23 +- dist/bundle.js | 5500 +++++++++++++++++++------------------ src/CompanyManagement.js | 154 +- src/Gang.js | 3 +- src/NetscriptFunctions.js | 35 +- src/SaveObject.js | 1 + src/StockMarket.js | 606 ++-- src/TextFile.js | 77 + 8 files changed, 3614 insertions(+), 2785 deletions(-) create mode 100644 src/TextFile.js diff --git a/css/menupages.css b/css/menupages.css index 0874ffee3..12f948013 100644 --- a/css/menupages.css +++ b/css/menupages.css @@ -596,21 +596,25 @@ div.faction-clear { margin: 10px; } -.stock-market-qty-input { +.stock-market-input { + display: inline-block; + padding: 4px; + margin: 2px; + background-color: black; border: 1px solid white; color: var(--my-font-color); - padding: 4px; - margin: 4px; - background-color:black; +} + +.stock-market-position-text { + color:white; + white-space: pre; + display:block; } .stock-market-buy-sell-button { color: #aaa; font-size: 16px; font-weight: bold; - padding: 2px; - margin: 6px; - border: 1px solid white; } .stock-market-buy-sell-button:hover, @@ -620,6 +624,11 @@ div.faction-clear { cursor: pointer; } +.stock-market-order-list { + overflow-y:auto; + max-height: 100px; +} + /* Gang */ #gang-container { position: fixed; diff --git a/dist/bundle.js b/dist/bundle.js index 4745a79c8..c56157077 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -70,9 +70,9 @@ "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Player; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return loadPlayer; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__ = __webpack_require__(20); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Company_js__ = __webpack_require__(20); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Company_js__ = __webpack_require__(21); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__CreateProgram_js__ = __webpack_require__(15); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Crimes_js__ = __webpack_require__(31); @@ -80,7 +80,7 @@ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Faction_js__ = __webpack_require__(10); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Gang_js__ = __webpack_require__(33); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Location_js__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__NetscriptFunctions_js__ = __webpack_require__(22); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__NetscriptFunctions_js__ = __webpack_require__(19); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Server_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__SpecialServerIps_js__ = __webpack_require__(12); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__SourceFile_js__ = __webpack_require__(34); @@ -3830,9 +3830,9 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_StringHelperFunctions_js__ = __webpack_require__(4); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_LogBox_js__ = __webpack_require__(29); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__ActiveScriptsUI_js__ = __webpack_require__(25); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Augmentations_js__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Augmentations_js__ = __webpack_require__(20); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Company_js__ = __webpack_require__(20); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Company_js__ = __webpack_require__(21); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__CreateProgram_js__ = __webpack_require__(15); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__Faction_js__ = __webpack_require__(10); @@ -3843,7 +3843,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__Literature_js__ = __webpack_require__(45); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__Message_js__ = __webpack_require__(24); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__Missions_js__ = __webpack_require__(32); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__NetscriptFunctions_js__ = __webpack_require__(22); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__NetscriptFunctions_js__ = __webpack_require__(19); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__ = __webpack_require__(11); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__Player_js__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__Prestige_js__ = __webpack_require__(35); @@ -3855,7 +3855,7 @@ Object.defineProperty(__webpack_exports__, "__esModule", { value: true }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_29__SourceFile_js__ = __webpack_require__(34); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_30__SpecialServerIps_js__ = __webpack_require__(12); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_31__StockMarket_js__ = __webpack_require__(28); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_32__Terminal_js__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_32__Terminal_js__ = __webpack_require__(23); @@ -4982,7 +4982,7 @@ let Engine = { Object(__WEBPACK_IMPORTED_MODULE_31__StockMarket_js__["f" /* initSymbolToStockMap */])(); } Object(__WEBPACK_IMPORTED_MODULE_17__Literature_js__["a" /* initLiterature */])(); - Object(__WEBPACK_IMPORTED_MODULE_20__NetscriptFunctions_js__["d" /* initSingularitySFFlags */])(); + Object(__WEBPACK_IMPORTED_MODULE_20__NetscriptFunctions_js__["e" /* initSingularitySFFlags */])(); console.log(__WEBPACK_IMPORTED_MODULE_22__Player_js__["a" /* Player */].intelligence_exp); @@ -5067,7 +5067,7 @@ let Engine = { Object(__WEBPACK_IMPORTED_MODULE_18__Message_js__["d" /* initMessages */])(); Object(__WEBPACK_IMPORTED_MODULE_31__StockMarket_js__["e" /* initStockSymbols */])(); Object(__WEBPACK_IMPORTED_MODULE_17__Literature_js__["a" /* initLiterature */])(); - Object(__WEBPACK_IMPORTED_MODULE_20__NetscriptFunctions_js__["d" /* initSingularitySFFlags */])(); + Object(__WEBPACK_IMPORTED_MODULE_20__NetscriptFunctions_js__["e" /* initSingularitySFFlags */])(); //Open main menu accordions for new game //Main menu accordions @@ -16968,7 +16968,7 @@ return jQuery; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Faction; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return purchaseAugmentation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return factionExists; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__ = __webpack_require__(20); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__BitNode_js__ = __webpack_require__(7); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__engine_js__ = __webpack_require__(5); @@ -16982,7 +16982,7 @@ return jQuery; /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__utils_HelperFunctions_js__ = __webpack_require__(2); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_JSONReviver_js__ = __webpack_require__(8); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__utils_StringHelperFunctions_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__utils_YesNoBox_js__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__utils_YesNoBox_js__ = __webpack_require__(22); @@ -18345,7 +18345,7 @@ function initSpecialServerIps() { /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Locations; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return displayLocationContent; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return initLocationButtons; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Company_js__ = __webpack_require__(20); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Company_js__ = __webpack_require__(21); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Crimes_js__ = __webpack_require__(31); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__engine_js__ = __webpack_require__(5); @@ -18360,7 +18360,7 @@ function initSpecialServerIps() { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_numeral_min_js__ = __webpack_require__(18); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_12__utils_numeral_min_js__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__utils_StringHelperFunctions_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__utils_YesNoBox_js__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__utils_YesNoBox_js__ = __webpack_require__(22); @@ -20753,7 +20753,7 @@ function initCreateProgramButtons() { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__InteractiveTutorial_js__ = __webpack_require__(26); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__ = __webpack_require__(22); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__ = __webpack_require__(19); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__ = __webpack_require__(11); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Player_js__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Server_js__ = __webpack_require__(6); @@ -21476,6 +21476,2244 @@ var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @preserve /* 19 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return NetscriptFunctions; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return initSingularitySFFlags; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return hasSingularitySF; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return hasBn11SF; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return hasWallStreetSF; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return wallStreetSFLvl; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ActiveScriptsUI_js__ = __webpack_require__(25); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__ = __webpack_require__(20); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__BitNode_js__ = __webpack_require__(7); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Crimes_js__ = __webpack_require__(31); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Company_js__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Constants_js__ = __webpack_require__(3); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__ = __webpack_require__(15); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__ = __webpack_require__(44); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__engine_js__ = __webpack_require__(5); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Faction_js__ = __webpack_require__(10); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__HacknetNode_js__ = __webpack_require__(38); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Location_js__ = __webpack_require__(13); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__Message_js__ = __webpack_require__(24); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__Script_js__ = __webpack_require__(16); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__Server_js__ = __webpack_require__(6); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__Settings_js__ = __webpack_require__(14); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__SpecialServerIps_js__ = __webpack_require__(12); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__ = __webpack_require__(28); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__Terminal_js__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__TextFile_js__ = __webpack_require__(47); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__ = __webpack_require__(37); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__NetscriptEnvironment_js__ = __webpack_require__(30); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__utils_decimal_js__ = __webpack_require__(27); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__utils_decimal_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_24__utils_decimal_js__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__utils_DialogBox_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__utils_IPAddress_js__ = __webpack_require__(17); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__ = __webpack_require__(4); +var sprintf = __webpack_require__(40).sprintf, + vsprintf = __webpack_require__(40).vsprintf + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +var hasSingularitySF=false, hasAISF=false, hasBn11SF=false, hasWallStreetSF=false; +var singularitySFLvl=1, wallStreetSFLvl=1; + +//Used to check and set flags for every Source File, despite the name of the function +function initSingularitySFFlags() { + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles.length; ++i) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].n === 4) { + hasSingularitySF = true; + singularitySFLvl = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].lvl; + } + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].n === 5) { + hasAISF = true; + } + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].n === 8) { + hasWallStreetSF = true; + wallStreetSFLvl = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].lvl; + } + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].n === 11) { + hasBn11SF = true; + } + } +} + +function NetscriptFunctions(workerScript) { + return { + Math : Math, + Date : Date, + hacknetnodes : __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacknetNodes, + sprintf : sprintf, + vsprintf: vsprintf, + scan : function(ip=workerScript.serverIp, hostnames=true){ + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, 'Invalid IP or hostname passed into scan() command'); + } + var out = []; + for (var i = 0; i < server.serversOnNetwork.length; i++) { + var entry; + if (hostnames) { + entry = server.getServerOnNetwork(i).hostname; + } else { + entry = server.getServerOnNetwork(i).ip; + } + if (entry == null) { + continue; + } + out.push(entry); + } + workerScript.scriptRef.log('scan() returned ' + server.serversOnNetwork.length + ' connections for ' + server.hostname); + return out; + }, + hack : function(ip){ + if (ip === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Hack() call has incorrect number of arguments. Takes 1 argument"); + } + var threads = workerScript.scriptRef.threads; + if (isNaN(threads) || threads < 1) {threads = 1;} + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping..."); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping..."); + } + + //Calculate the hacking time + var hackingTime = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["i" /* scriptCalculateHackingTime */])(server); //This is in seconds + + //No root access or skill level too low + if (server.hasAdminRights == false) { + workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user does not have root access"); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot hack this server (" + server.hostname + ") because user does not have root access"); + } + + if (server.requiredHackingSkill > __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill) { + workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough"); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough"); + } + + workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime.toFixed(3) + " seconds (t=" + threads + ")"); + //console.log("Hacking " + server.hostname + " after " + hackingTime.toString() + " seconds (t=" + threads + ")"); + return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["d" /* netscriptDelay */])(hackingTime* 1000, workerScript).then(function() { + if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} + var hackChance = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["h" /* scriptCalculateHackingChance */])(server); + var rand = Math.random(); + var expGainedOnSuccess = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["f" /* scriptCalculateExpGain */])(server) * threads; + var expGainedOnFailure = (expGainedOnSuccess / 4); + if (rand < hackChance) { //Success! + var moneyGained = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["j" /* scriptCalculatePercentMoneyHacked */])(server); + moneyGained = Math.floor(server.moneyAvailable * moneyGained) * threads; + + //Over-the-top safety checks + if (moneyGained <= 0) { + moneyGained = 0; + expGainedOnSuccess = expGainedOnFailure; + } + if (moneyGained > server.moneyAvailable) {moneyGained = server.moneyAvailable;} + server.moneyAvailable -= moneyGained; + if (server.moneyAvailable < 0) {server.moneyAvailable = 0;} + + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainMoney(moneyGained); + workerScript.scriptRef.onlineMoneyMade += moneyGained; + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].scriptProdSinceLastAug += moneyGained; + workerScript.scriptRef.recordHack(server.ip, moneyGained, threads); + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainHackingExp(expGainedOnSuccess); + workerScript.scriptRef.onlineExpGained += expGainedOnSuccess; + //console.log("Script successfully hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp"); + workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(moneyGained, 2) + " and " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGainedOnSuccess, 4) + " exp (t=" + threads + ")"); + server.fortify(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ServerFortifyAmount * threads); + return Promise.resolve(true); + } else { + //Player only gains 25% exp for failure? TODO Can change this later to balance + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainHackingExp(expGainedOnFailure); + workerScript.scriptRef.onlineExpGained += expGainedOnFailure; + //console.log("Script unsuccessful to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " exp"); + workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGainedOnFailure, 4) + " exp (t=" + threads + ")"); + return Promise.resolve(false); + } + }); + }, + sleep : function(time,log=true){ + if (time === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "sleep() call has incorrect number of arguments. Takes 1 argument"); + } + if (log) { + workerScript.scriptRef.log("Sleeping for " + time + " milliseconds"); + } + return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["d" /* netscriptDelay */])(time, workerScript).then(function() { + return Promise.resolve(true); + }); + }, + grow : function(ip){ + var threads = workerScript.scriptRef.threads; + if (isNaN(threads) || threads < 1) {threads = 1;} + if (ip === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "grow() call has incorrect number of arguments. Takes 1 argument"); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("Cannot grow(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot grow(). Invalid IP or hostname passed in: " + ip); + } + + //No root access or skill level too low + if (server.hasAdminRights == false) { + workerScript.scriptRef.log("Cannot grow this server (" + server.hostname + ") because user does not have root access"); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot grow this server (" + server.hostname + ") because user does not have root access"); + } + + var growTime = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["g" /* scriptCalculateGrowTime */])(server); + //console.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds") + workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(growTime/1000, 3) + " seconds (t=" + threads + ")"); + return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["d" /* netscriptDelay */])(growTime, workerScript).then(function() { + if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} + server.moneyAvailable += (1 * threads); //It can be grown even if it has no money + var growthPercentage = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["j" /* processSingleServerGrowth */])(server, 450 * threads); + workerScript.scriptRef.recordGrow(server.ip, threads); + var expGain = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["f" /* scriptCalculateExpGain */])(server) * threads; + if (growthPercentage == 1) { + expGain = 0; + } + workerScript.scriptRef.log("Available money on " + server.hostname + " grown by " + + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(growthPercentage*100 - 100, 6) + "%. Gained " + + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGain, 4) + " hacking exp (t=" + threads +")"); + workerScript.scriptRef.onlineExpGained += expGain; + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainHackingExp(expGain); + return Promise.resolve(growthPercentage); + }); + }, + weaken : function(ip){ + var threads = workerScript.scriptRef.threads; + if (isNaN(threads) || threads < 1) {threads = 1;} + if (ip === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "weaken() call has incorrect number of arguments. Takes 1 argument"); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("Cannot weaken(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot weaken(). Invalid IP or hostname passed in: " + ip); + } + + //No root access or skill level too low + if (server.hasAdminRights == false) { + workerScript.scriptRef.log("Cannot weaken this server (" + server.hostname + ") because user does not have root access"); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot weaken this server (" + server.hostname + ") because user does not have root access"); + } + + var weakenTime = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["k" /* scriptCalculateWeakenTime */])(server); + workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " + + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(weakenTime/1000, 3) + " seconds (t=" + threads + ")"); + return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["d" /* netscriptDelay */])(weakenTime, workerScript).then(function() { + if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} + server.weaken(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ServerWeakenAmount * threads); + workerScript.scriptRef.recordWeaken(server.ip, threads); + var expGain = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["f" /* scriptCalculateExpGain */])(server) * threads; + workerScript.scriptRef.log("Server security level on " + server.hostname + " weakened to " + server.hackDifficulty + + ". Gained " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGain, 4) + " hacking exp (t=" + threads + ")"); + workerScript.scriptRef.onlineExpGained += expGain; + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainHackingExp(expGain); + return Promise.resolve(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ServerWeakenAmount * threads); + }); + }, + print : function(args){ + if (args === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "print() call has incorrect number of arguments. Takes 1 argument"); + } + workerScript.scriptRef.log(args.toString()); + }, + tprint : function(args) { + if (args === undefined || args === null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "tprint() call has incorrect number of arguments. Takes 1 argument"); + } + var x = args.toString(); + if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["d" /* isHTML */])(x)) { + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].takeDamage(1); + Object(__WEBPACK_IMPORTED_MODULE_25__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You suddenly feel a sharp shooting pain through your body as an angry voice in your head exclaims:

" + + "DON'T USE TPRINT() TO OUTPUT HTML ELEMENTS TO YOUR TERMINAL!!!!

" + + "(You lost 1 HP)"); + return; + } + Object(__WEBPACK_IMPORTED_MODULE_19__Terminal_js__["b" /* post */])(workerScript.scriptRef.filename + ": " + args.toString()); + }, + clearLog : function() { + workerScript.scriptRef.clearLog(); + }, + nuke : function(ip){ + if (ip === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("Cannot call nuke(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call nuke(). Invalid IP or hostname passed in: " + ip); + } + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].NukeProgram)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the NUKE.exe virus!"); + } + if (server.openPortCount < server.numOpenPortsRequired) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Not enough ports opened to use NUKE.exe virus"); + } + if (server.hasAdminRights) { + workerScript.scriptRef.log("Already have root access to " + server.hostname); + } else { + server.hasAdminRights = true; + workerScript.scriptRef.log("Executed NUKE.exe virus on " + server.hostname + " to gain root access"); + } + return true; + }, + brutessh : function(ip){ + if (ip === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("Cannot call brutessh(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call brutessh(). Invalid IP or hostname passed in: " + ip); + } + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram)) { + workerScript.scriptRef.log("You do not have the BruteSSH.exe program!"); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the BruteSSH.exe program!"); + } + if (!server.sshPortOpen) { + workerScript.scriptRef.log("Executed BruteSSH.exe on " + server.hostname + " to open SSH port (22)"); + server.sshPortOpen = true; + ++server.openPortCount; + } else { + workerScript.scriptRef.log("SSH Port (22) already opened on " + server.hostname); + } + return true; + }, + ftpcrack : function(ip){ + if (ip === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip); + } + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the FTPCrack.exe program!"); + } + if (!server.ftpPortOpen) { + workerScript.scriptRef.log("Executed FTPCrack.exe on " + server.hostname + " to open FTP port (21)"); + server.ftpPortOpen = true; + ++server.openPortCount; + } else { + workerScript.scriptRef.log("FTP Port (21) already opened on " + server.hostname); + } + return true; + }, + relaysmtp : function(ip){ + if (ip === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip); + } + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the relaySMTP.exe program!"); + } + if (!server.smtpPortOpen) { + workerScript.scriptRef.log("Executed relaySMTP.exe on " + server.hostname + " to open SMTP port (25)"); + server.smtpPortOpen = true; + ++server.openPortCount; + } else { + workerScript.scriptRef.log("SMTP Port (25) already opened on " + server.hostname); + } + return true; + }, + httpworm : function(ip){ + if (ip === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("Cannot call httpworm(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call httpworm(). Invalid IP or hostname passed in: " + ip); + } + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the HTTPWorm.exe program!"); + } + if (!server.httpPortOpen) { + workerScript.scriptRef.log("Executed HTTPWorm.exe on " + server.hostname + " to open HTTP port (80)"); + server.httpPortOpen = true; + ++server.openPortCount; + } else { + workerScript.scriptRef.log("HTTP Port (80) already opened on " + server.hostname); + } + return true; + }, + sqlinject : function(ip){ + if (ip === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip); + } + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the SQLInject.exe program!"); + } + if (!server.sqlPortOpen) { + workerScript.scriptRef.log("Executed SQLInject.exe on " + server.hostname + " to open SQL port (1433)"); + server.sqlPortOpen = true; + ++server.openPortCount; + } else { + workerScript.scriptRef.log("SQL Port (1433) already opened on " + server.hostname); + } + return true; + }, + run : function(scriptname,threads = 1){ + if (scriptname === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "run() call has incorrect number of arguments. Usage: run(scriptname, [numThreads], [arg1], [arg2]...)"); + } + if (isNaN(threads) || threads < 1) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument for thread count passed into run(). Must be numeric and greater than 0"); + } + var argsForNewScript = []; + for (var i = 2; i < arguments.length; ++i) { + argsForNewScript.push(arguments[i]); + } + var scriptServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); + if (scriptServer == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server. This is a bug in the game. Report to game dev"); + } + + return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["e" /* runScriptFromScript */])(scriptServer, scriptname, argsForNewScript, workerScript, threads); + }, + exec : function(scriptname,ip,threads = 1){ + if (scriptname === undefined || ip === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "exec() call has incorrect number of arguments. Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)"); + } + if (isNaN(threads) || threads < 1) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument for thread count passed into exec(). Must be numeric and greater than 0"); + } + var argsForNewScript = []; + for (var i = 3; i < arguments.length; ++i) { + argsForNewScript.push(arguments[i]); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid hostname/ip passed into exec() command: " + ip); + } + return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["e" /* runScriptFromScript */])(server, scriptname, argsForNewScript, workerScript, threads); + }, + kill : function(filename,ip){ + if (filename === undefined || ip === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "kill() call has incorrect number of arguments. Usage: kill(scriptname, server, [arg1], [arg2]...)"); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("kill() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "kill() failed. Invalid IP or hostname passed in: " + ip); + } + var argsForKillTarget = []; + for (var i = 2; i < arguments.length; ++i) { + argsForKillTarget.push(arguments[i]); + } + var runningScriptObj = Object(__WEBPACK_IMPORTED_MODULE_14__Script_js__["d" /* findRunningScript */])(filename, argsForKillTarget, server); + if (runningScriptObj == null) { + workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForKillTarget)); + return false; + } + var res = Object(__WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["d" /* killWorkerScript */])(runningScriptObj, server.ip); + if (res) { + workerScript.scriptRef.log("Killing " + filename + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForKillTarget) + ". May take up to a few minutes for the scripts to die..."); + return true; + } else { + workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForKillTarget)); + return false; + } + }, + killall : function(ip){ + if (ip === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "killall() call has incorrect number of arguments. Takes 1 argument"); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("killall() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "killall() failed. Invalid IP or hostname passed in: " + ip); + } + for (var i = server.runningScripts.length-1; i >= 0; --i) { + Object(__WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["d" /* killWorkerScript */])(server.runningScripts[i], server.ip); + } + workerScript.scriptRef.log("killall(): Killing all scripts on " + server.hostname + ". May take a few minutes for the scripts to die"); + return true; + }, + scp : function(scriptname, ip1, ip2){ + if (arguments.length !== 2 && arguments.length !== 3) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments"); + } + if (scriptname && scriptname.constructor === Array) { + //Recursively call scp on all elements of array + var res = false; + scriptname.forEach(function(script) { + if (NetscriptFunctions(workerScript).scp(script, ip1, ip2)) { + res = true; + }; + }); + return res; + } + if (!scriptname.endsWith(".lit") && !scriptname.endsWith(".script")) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() only works for .script and .lit files"); + } + + var destServer, currServ; + + if (arguments.length === 3) { //scriptname, source, destination + if (scriptname === undefined || ip1 === undefined || ip2 === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments"); + } + destServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip2); + if (destServer == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: Invalid hostname/ip passed into scp() command: " + ip); + } + + currServ = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip1); + if (currServ == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer"); + } + } else if (arguments.length === 2) { //scriptname, destination + if (scriptname === undefined || ip1 === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments"); + } + destServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip1); + if (destServer == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: Invalid hostname/ip passed into scp() command: " + ip); + } + + currServ = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); + if (currServ == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer"); + } + } + + //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 __WEBPACK_IMPORTED_MODULE_12__Message_js__["a" /* Message */]) && currServ.messages[i] == scriptname) { + found = true; + } + } + + if (!found) { + workerScript.scriptRef.log(scriptname + " does not exist. scp() failed"); + return false; + } + + for (var i = 0; i < destServer.messages.length; ++i) { + if (destServer.messages[i] === scriptname) { + workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname); + return true; //Already exists + } + } + destServer.messages.push(scriptname); + workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname); + return true; + } + + //Scp for script files + 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) { + workerScript.scriptRef.log(scriptname + " does not exist. scp() failed"); + return false; + } + + //Overwrite script if it already exists + for (var i = 0; i < destServer.scripts.length; ++i) { + if (scriptname == destServer.scripts[i].filename) { + workerScript.scriptRef.log("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and it will be overwritten."); + workerScript.scriptRef.log(scriptname + " overwritten on " + destServer.hostname); + var oldScript = destServer.scripts[i]; + oldScript.code = sourceScript.code; + oldScript.ramUsage = sourceScript.ramUsage; + return true; + } + } + + //Create new script if it does not already exist + var newScript = new __WEBPACK_IMPORTED_MODULE_14__Script_js__["c" /* Script */](); + newScript.filename = scriptname; + newScript.code = sourceScript.code; + newScript.ramUsage = sourceScript.ramUsage; + newScript.server = destServer.ip; + destServer.scripts.push(newScript); + workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname); + return true; + }, + ls : function(ip, grep) { + if (ip === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ls() failed because of invalid arguments. Usage: ls(ip/hostname, [grep filter])"); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server === null) { + workerScript.scriptRef.log("ls() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ls() failed. Invalid IP or hostname passed in: " + ip); + } + + //Get the grep filter, if one exists + var filter = false; + if (arguments.length >= 2) { + filter = grep.toString(); + } + + var allFiles = []; + for (var i = 0; i < server.programs.length; i++) { + if (filter) { + if (server.programs[i].includes(filter)) { + allFiles.push(server.programs[i]); + } + } else { + allFiles.push(server.programs[i]); + } + } + for (var i = 0; i < server.scripts.length; i++) { + if (filter) { + if (server.scripts[i].filename.includes(filter)) { + allFiles.push(server.scripts[i].filename); + } + } else { + allFiles.push(server.scripts[i].filename); + } + + } + for (var i = 0; i < server.messages.length; i++) { + if (filter) { + if (server.messages[i] instanceof __WEBPACK_IMPORTED_MODULE_12__Message_js__["a" /* Message */]) { + if (server.messages[i].filename.includes(filter)) { + allFiles.push(server.messages[i].filename); + } + } else if (server.messages[i].includes(filter)) { + allFiles.push(server.messages[i]); + } + } else { + if (server.messages[i] instanceof __WEBPACK_IMPORTED_MODULE_12__Message_js__["a" /* Message */]) { + allFiles.push(server.messages[i].filename); + } else { + allFiles.push(server.messages[i]); + } + } + } + + //Sort the files alphabetically then print each + allFiles.sort(); + return allFiles; + }, + hasRootAccess : function(ip){ + if (ip===undefined){ + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "hasRootAccess() call has incorrect number of arguments. Takes 1 argument"); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null){ + workerScript.scriptRef.log("hasRootAccess() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "hasRootAccess() failed. Invalid IP or hostname passed in: " + ip); + } + return server.hasAdminRights; + }, + getIp : function() { + var scriptServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); + if (scriptServer == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server. This is a bug in the game. Report to game dev"); + } + return scriptServer.ip; + }, + getHostname : function(){ + var scriptServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); + if (scriptServer == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server. This is a bug in the game. Report to game dev"); + } + return scriptServer.hostname; + }, + getHackingLevel : function(){ + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].updateSkillLevels(); + workerScript.scriptRef.log("getHackingLevel() returned " + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill); + return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill; + }, + getHackingMultipliers : function() { + return { + chance: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_chance_mult, + speed: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_speed_mult, + money: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_money_mult, + growth: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_grow_mult, + }; + }, + getBitNodeMultipliers: function() { + if (!hasAISF) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getBitNodeMultipliers(). It requires Source-File 5 to run."); + } + return __WEBPACK_IMPORTED_MODULE_2__BitNode_js__["a" /* BitNodeMultipliers */]; + }, + getServerMoneyAvailable : function(ip){ + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("getServerMoneyAvailable() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerMoneyAvailable() failed. Invalid IP or hostname passed in: " + ip); + } + if (server.hostname == "home") { + //Return player's money + workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.toNumber(), 2)); + return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.toNumber(); + } + workerScript.scriptRef.log("getServerMoneyAvailable() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.moneyAvailable, 2) + " for " + server.hostname); + return server.moneyAvailable; + }, + getServerSecurityLevel : function(ip){ + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); + } + workerScript.scriptRef.log("getServerSecurityLevel() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.hackDifficulty, 3) + " for " + server.hostname); + return server.hackDifficulty; + }, + getServerBaseSecurityLevel : function(ip){ + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); + } + workerScript.scriptRef.log("getServerBaseSecurityLevel() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.baseDifficulty, 3) + " for " + server.hostname); + return server.baseDifficulty; + }, + getServerMinSecurityLevel : function(ip) { + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); + } + workerScript.scriptRef.log("getServerMinSecurityLevel() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.minDifficulty, 3) + " for " + server.hostname); + return server.minDifficulty; + }, + getServerRequiredHackingLevel : function(ip){ + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip); + } + workerScript.scriptRef.log("getServerRequiredHackingLevel returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.requiredHackingSkill, 0) + " for " + server.hostname); + return server.requiredHackingSkill; + }, + getServerMaxMoney : function(ip){ + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip); + } + workerScript.scriptRef.log("getServerMaxMoney() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.moneyMax, 0) + " for " + server.hostname); + return server.moneyMax; + }, + getServerGrowth : function(ip) { + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("getServerGrowth() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerGrowth() failed. Invalid IP or hostname passed in: " + ip); + } + workerScript.scriptRef.log("getServerGrowth() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.serverGrowth, 0) + " for " + server.hostname); + return server.serverGrowth; + }, + getServerNumPortsRequired : function(ip){ + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip); + } + workerScript.scriptRef.log("getServerNumPortsRequired() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.numOpenPortsRequired, 0) + " for " + server.hostname); + return server.numOpenPortsRequired; + }, + getServerRam : function(ip) { + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("getServerRam() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerRam() failed. Invalid IP or hostname passed in: " + ip); + } + workerScript.scriptRef.log("getServerRam() returned [" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.maxRam, 2) + "GB, " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.ramUsed, 2) + "GB]"); + return [server.maxRam, server.ramUsed]; + }, + serverExists : function(ip) { + return (Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip) !== null); + }, + fileExists : function(filename,ip=workerScript.serverIp){ + if (filename === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "fileExists() call has incorrect number of arguments. Usage: fileExists(scriptname, [server])"); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("fileExists() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "fileExists() failed. Invalid IP or hostname passed in: " + ip); + } + for (var i = 0; i < server.scripts.length; ++i) { + if (filename == server.scripts[i].filename) { + return true; + } + } + for (var i = 0; i < server.programs.length; ++i) { + if (filename.toLowerCase() == server.programs[i].toLowerCase()) { + return true; + } + } + for (var i = 0; i < server.messages.length; ++i) { + if (!(server.messages[i] instanceof __WEBPACK_IMPORTED_MODULE_12__Message_js__["a" /* Message */]) && + filename.toLowerCase() === server.messages[i]) { + return true; + } + } + return false; + }, + isRunning : function(filename,ip){ + if (filename === undefined || ip === undefined) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "isRunning() call has incorrect number of arguments. Usage: isRunning(scriptname, server, [arg1], [arg2]...)"); + } + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("isRunning() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "isRunning() failed. Invalid IP or hostname passed in: " + ip); + } + var argsForTargetScript = []; + for (var i = 2; i < arguments.length; ++i) { + argsForTargetScript.push(arguments[i]); + } + return (Object(__WEBPACK_IMPORTED_MODULE_14__Script_js__["d" /* findRunningScript */])(filename, argsForTargetScript, server) != null); + }, + getNextHacknetNodeCost : __WEBPACK_IMPORTED_MODULE_10__HacknetNode_js__["b" /* getCostOfNextHacknetNode */], + purchaseHacknetNode : __WEBPACK_IMPORTED_MODULE_10__HacknetNode_js__["d" /* purchaseHacknet */], + getStockPrice : function(symbol) { + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use getStockPrice()"); + } + var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* SymbolToStockMap */][symbol]; + if (stock == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); + } + return parseFloat(stock.price.toFixed(3)); + }, + getStockPosition : function(symbol) { + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use getStockPosition()"); + } + var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* SymbolToStockMap */][symbol]; + if (stock == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); + } + return [stock.playerShares, stock.playerAvgPx]; + }, + buyStock : function(symbol, shares) { + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use buyStock()"); + } + var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* SymbolToStockMap */][symbol]; + if (stock == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); + } + if (stock == null || shares < 0 || isNaN(shares)) { + workerScript.scriptRef.log("Error: Invalid 'shares' argument passed to buyStock()"); + return false; + } + shares = Math.round(shares); + if (shares === 0) {return false;} + + var totalPrice = stock.price * shares; + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.lt(totalPrice + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission)) { + workerScript.scriptRef.log("Not enough money to purchase " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + + symbol + ". Need $" + + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalPrice + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2).toString()); + return false; + } + + var origTotal = stock.playerShares * stock.playerAvgPx; + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(totalPrice + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission); + var newTotal = origTotal + totalPrice; + stock.playerShares += shares; + stock.playerAvgPx = newTotal / stock.playerShares; + if (__WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].Page.StockMarket) { + Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["j" /* updateStockPlayerPosition */])(stock); + } + workerScript.scriptRef.log("Bought " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share"); + return true; + }, + sellStock : function(symbol, shares) { + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use sellStock()"); + } + var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* SymbolToStockMap */][symbol]; + if (stock == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); + } + + if (stock == null || shares < 0 || isNaN(shares)) { + workerScript.scriptRef.log("Error: Invalid 'shares' argument passed to sellStock()"); + return false; + } + shares = Math.round(shares); + if (shares > stock.playerShares) {shares = stock.playerShares;} + if (shares === 0) {return false;} + var gains = stock.price * shares - __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission; + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainMoney(gains); + + //Calculate net profit and add to script stats + var netProfit = ((stock.price - stock.playerAvgPx) * shares) - __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission; + if (isNaN(netProfit)) {netProfit = 0;} + workerScript.scriptRef.onlineMoneyMade += netProfit; + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].scriptProdSinceLastAug += netProfit; + + stock.playerShares -= shares; + if (stock.playerShares == 0) { + stock.playerAvgPx = 0; + } + if (__WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].Page.StockMarket) { + Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["j" /* updateStockPlayerPosition */])(stock); + } + workerScript.scriptRef.log("Sold " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. Gained " + + "$" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gains, 2)); + return true; + }, + purchaseServer : function(hostname, ram) { + var hostnameStr = String(hostname); + hostnameStr = hostnameStr.replace(/\s\s+/g, ''); + if (hostnameStr == "") { + workerScript.scriptRef.log("Error: Passed empty string for hostname argument of purchaseServer()"); + return ""; + } + + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.length >= __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].PurchasedServerLimit) { + workerScript.scriptRef.log("Error: You have reached the maximum limit of " + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].PurchasedServerLimit + + " servers. You cannot purchase any more."); + return ""; + } + + ram = Math.round(ram); + if (isNaN(ram) || !Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["e" /* powerOfTwo */])(ram)) { + workerScript.scriptRef.log("Error: Invalid ram argument passed to purchaseServer(). Must be numeric and a power of 2"); + return ""; + } + + var cost = ram * __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].BaseCostFor1GBOfRamServer; + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.lt(cost)) { + workerScript.scriptRef.log("Error: Not enough money to purchase server. Need $" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(cost, 2)); + return ""; + } + var newServ = new __WEBPACK_IMPORTED_MODULE_15__Server_js__["d" /* Server */](Object(__WEBPACK_IMPORTED_MODULE_27__utils_IPAddress_js__["a" /* createRandomIp */])(), hostnameStr, "", false, true, true, ram); + Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["a" /* AddToAllServers */])(newServ); + + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.push(newServ.ip); + var homeComputer = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer(); + homeComputer.serversOnNetwork.push(newServ.ip); + newServ.serversOnNetwork.push(homeComputer.ip); + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(cost); + workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(cost, 2)); + return newServ.hostname; + }, + deleteServer : function(hostname) { + var hostnameStr = String(hostname); + hostnameStr = hostnameStr.replace(/\s\s+/g, ''); + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["c" /* GetServerByHostname */])(hostnameStr); + if (server == null) { + workerScript.scriptRef.log("Error: Could not find server with hostname " + hostnameStr + ". deleteServer() failed"); + return false; + } + + if (!server.purchasedByPlayer || server.hostname == "home") { + workerScript.scriptRef.log("Error: Server " + server.hostname + " is not a purchased server. " + + "Cannot be deleted. deleteServer failed"); + return false; + } + + var ip = server.ip; + + //A server cannot delete itself + if (ip == workerScript.serverIp) { + workerScript.scriptRef.log("Error: Cannot call deleteServer() on self. Function failed"); + return false; + } + + //Delete all scripts running on server + if (server.runningScripts.length > 0) { + workerScript.scriptRef.log("Error: Cannot delete server " + server.hostname + " because it still has scripts running."); + return false; + } + + //Delete from player's purchasedServers array + var found = false; + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.length; ++i) { + if (ip == __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers[i]) { + found = true; + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.splice(i, 1); + break; + } + } + + if (!found) { + workerScript.scriptRef.log("Error: Could not identify server " + server.hostname + + "as a purchased server. This is likely a bug please contact game dev"); + return false; + } + + //Delete from all servers + delete __WEBPACK_IMPORTED_MODULE_15__Server_js__["b" /* AllServers */][ip]; + + //Delete from home computer + found = false; + var homeComputer = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer(); + for (var i = 0; i < homeComputer.serversOnNetwork.length; ++i) { + if (ip == homeComputer.serversOnNetwork[i]) { + homeComputer.serversOnNetwork.splice(i, 1); + workerScript.scriptRef.log("Deleted server " + hostnameStr); + return true; + } + } + //Wasn't found on home computer + workerScript.scriptRef.log("Error: Could not find server " + server.hostname + + "as a purchased server. This is likely a bug please contact game dev"); + return false; + }, + getPurchasedServers : function(hostname=true) { + var res = []; + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.forEach(function(ip) { + if (hostname) { + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERR: Could not find server in getPurchasedServers(). This is a bug please report to game dev"); + } + res.push(server.hostname); + } else { + res.push(ip); + } + }); + return res; + }, + round : function(n) { + if (isNaN(n)) {return 0;} + return Math.round(n); + }, + write : function(port, data="", mode="a") { + if (!isNaN(port)) { //Write to port + //Port 1-10 + if (port < 1 || port > 10) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Trying to write to invalid port: " + port + ". Only ports 1-10 are valid."); + } + var portName = "Port" + String(port); + var port = __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["a" /* NetscriptPorts */][portName]; + if (port == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer"); + } + port.push(data); + if (port.length > __WEBPACK_IMPORTED_MODULE_16__Settings_js__["a" /* Settings */].MaxPortCapacity) { + port.shift(); + return true; + } + return false; + } else if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["f" /* isString */])(port)) { //Write to text file + var fn = port; + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); + if (server === null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error getting Server for this script in write(). This is a bug please contact game dev"); + } + var txtFile = Object(__WEBPACK_IMPORTED_MODULE_20__TextFile_js__["b" /* getTextFile */])(fn, server); + if (txtFile === null) { + txtFile = Object(__WEBPACK_IMPORTED_MODULE_20__TextFile_js__["a" /* createTextFile */])(fn, data, server); + return true; + } + if (mode === "w") { + txtFile.write(data); + } else { + txtFile.append(data); + } + return true; + } else { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument passed in for port: " + port + ". Must be a number between 1 and 10"); + } + }, + read : function(port) { + if (!isNaN(port)) { //Read from port + //Port 1-10 + if (port < 1 || port > 10) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Trying to write to invalid port: " + port + ". Only ports 1-10 are valid."); + } + var portName = "Port" + String(port); + var port = __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["a" /* NetscriptPorts */][portName]; + if (port == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer"); + } + if (port.length == 0) { + return "NULL PORT DATA"; + } else { + return port.shift(); + } + } else if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["f" /* isString */])(port)) { //Read from text file + var fn = port; + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); + if (server === null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error getting Server for this script in read(). This is a bug please contact game dev"); + } + var txtFile = Object(__WEBPACK_IMPORTED_MODULE_20__TextFile_js__["b" /* getTextFile */])(fn, server); + if (txtFile !== null) { + return txtFile.text; + } else { + return ""; + } + } else { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument passed in for port: " + port + ". Must be a number between 1 and 10"); + } + }, + scriptRunning : function(scriptname, ip) { + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("scriptRunning() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "scriptRunning() failed. Invalid IP or hostname passed in: " + ip); + } + for (var i = 0; i < server.runningScripts.length; ++i) { + if (server.runningScripts[i].filename == scriptname) { + return true; + } + } + return false; + }, + scriptKill : function(scriptname, ip) { + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("scriptKill() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "scriptKill() failed. Invalid IP or hostname passed in: " + ip); + } + var suc = false; + for (var i = 0; i < server.runningScripts.length; ++i) { + if (server.runningScripts[i].filename == scriptname) { + Object(__WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["d" /* killWorkerScript */])(server.runningScripts[i], server.ip); + suc = true; + } + } + return suc; + }, + getScriptRam : function (scriptname, ip) { + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("getScriptRam() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getScriptRam() failed. Invalid IP or hostname passed in: " + ip); + } + for (var i = 0; i < server.scripts.length; ++i) { + if (server.scripts[i].filename == scriptname) { + return server.scripts[i].ramUsage; + } + } + return 0; + }, + getHackTime : function(ip) { + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("getHackTime() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getHackTime() failed. Invalid IP or hostname passed in: " + ip); + } + return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["i" /* scriptCalculateHackingTime */])(server); //Returns seconds + }, + getGrowTime : function(ip) { + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("getGrowTime() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getGrowTime() failed. Invalid IP or hostname passed in: " + ip); + } + return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["g" /* scriptCalculateGrowTime */])(server) / 1000; //Returns seconds + }, + getWeakenTime : function(ip) { + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server == null) { + workerScript.scriptRef.log("getWeakenTime() failed. Invalid IP or hostname passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getWeakenTime() failed. Invalid IP or hostname passed in: " + ip); + } + return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["k" /* scriptCalculateWeakenTime */])(server) / 1000; //Returns seconds + }, + getScriptIncome : function(scriptname, ip) { + if (arguments.length === 0) { + //Get total script income + var res = []; + res.push(Object(__WEBPACK_IMPORTED_MODULE_0__ActiveScriptsUI_js__["d" /* updateActiveScriptsItems */])()); + res.push(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].scriptProdSinceLastAug / (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].playtimeSinceLastAug/1000)); + return res; + } else { + //Get income for a particular script + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server === null) { + workerScript.scriptRef.log("getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip); + } + var argsForScript = []; + for (var i = 2; i < arguments.length; ++i) { + argsForScript.push(arguments[i]); + } + var runningScriptObj = Object(__WEBPACK_IMPORTED_MODULE_14__Script_js__["d" /* findRunningScript */])(scriptname, argsForScript, server); + if (runningScriptObj == null) { + workerScript.scriptRef.log("getScriptIncome() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForScript)); + return -1; + } + return runningScriptObj.onlineMoneyMade / runningScriptObj.onlineRunningTime; + } + }, + getScriptExpGain : function(scriptname, ip) { + if (arguments.length === 0) { + var total = 0; + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["h" /* workerScripts */].length; ++i) { + total += (__WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["h" /* workerScripts */][i].scriptRef.onlineExpGained / __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["h" /* workerScripts */][i].scriptRef.onlineRunningTime); + } + return total; + } else { + //Get income for a particular script + var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); + if (server === null) { + workerScript.scriptRef.log("getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip); + } + var argsForScript = []; + for (var i = 2; i < arguments.length; ++i) { + argsForScript.push(arguments[i]); + } + var runningScriptObj = Object(__WEBPACK_IMPORTED_MODULE_14__Script_js__["d" /* findRunningScript */])(scriptname, argsForScript, server); + if (runningScriptObj == null) { + workerScript.scriptRef.log("getScriptExpGain() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForScript)); + return -1; + } + return runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime; + } + }, + getTimeSinceLastAug : function() { + return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].playtimeSinceLastAug; + }, + + /* Singularity Functions */ + universityCourse(universityName, className) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 1)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run universityCourse(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); + return false; + } + } + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { + var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); + workerScript.scriptRef.log(txt); + } + + var costMult, expMult; + switch(universityName.toLowerCase()) { + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSummitUniversity.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum) { + workerScript.scriptRef.log("ERROR: You cannot study at Summit University because you are not in Aevum. universityCourse() failed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSummitUniversity; + costMult = 4; + expMult = 3; + break; + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12RothmanUniversity.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12) { + workerScript.scriptRef.log("ERROR: You cannot study at Rothman University because you are not in Sector-12. universityCourse() failed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12RothmanUniversity; + costMult = 3; + expMult = 2; + break; + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenZBInstituteOfTechnology.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Volhaven) { + workerScript.scriptRef.log("ERROR: You cannot study at ZB Institute of Technology because you are not in Volhaven. universityCourse() failed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenZBInstituteOfTechnology; + costMult = 5; + expMult = 4; + break; + default: + workerScript.scriptRef.log("Invalid university name: " + universityName + ". universityCourse() failed"); + return false; + } + + var task; + switch(className.toLowerCase()) { + case "Study Computer Science".toLowerCase(): + task = __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassStudyComputerScience; + break; + case "Data Structures".toLowerCase(): + task = __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassDataStructures; + break; + case "Networks".toLowerCase(): + task = __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassNetworks; + break; + case "Algorithms".toLowerCase(): + task = __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassAlgorithms; + break; + case "Management".toLowerCase(): + task = __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassManagement; + break; + case "Leadership".toLowerCase(): + task = __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassLeadership; + break; + default: + workerScript.scriptRef.log("Invalid class name: " + className + ". universityCourse() failed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, task); + workerScript.scriptRef.log("Started " + task + " at " + universityName); + return true; + }, + + gymWorkout(gymName, stat) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 1)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run gymWorkout(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); + return false; + } + } + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { + var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); + workerScript.scriptRef.log(txt); + } + var costMult, expMult; + switch(gymName.toLowerCase()) { + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumCrushFitnessGym.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum) { + workerScript.scriptRef.log("ERROR: You cannot workout at Crush Fitness because you are not in Aevum. gymWorkout() failed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumCrushFitnessGym; + costMult = 2; + expMult = 1.5; + break; + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSnapFitnessGym.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum) { + workerScript.scriptRef.log("ERROR: You cannot workout at Snap Fitness because you are not in Aevum. gymWorkout() failed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSnapFitnessGym; + costMult = 6; + expMult = 4; + break; + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12IronGym.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12) { + workerScript.scriptRef.log("ERROR: You cannot workout at Iron Gym because you are not in Sector-12. gymWorkout() failed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12IronGym; + costMult = 1; + expMult = 1; + break; + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12PowerhouseGym.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12) { + workerScript.scriptRef.log("ERROR: You cannot workout at Powerhouse Gym because you are not in Sector-12. gymWorkout() failed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12PowerhouseGym; + costMult = 10; + expMult = 7.5; + break; + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenMilleniumFitnessGym: + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Volhaven) { + workerScript.scriptRef.log("ERROR: You cannot workout at Millenium Fitness Gym because you are not in Volhaven. gymWorkout() failed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenMilleniumFitnessGym; + costMult = 3; + expMult = 2.5; + break; + default: + workerScript.scriptRef.log("Invalid gym name: " + gymName + ". gymWorkout() failed"); + return false; + } + + switch(stat.toLowerCase()) { + case "strength".toLowerCase(): + case "str".toLowerCase(): + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymStrength); + break; + case "defense".toLowerCase(): + case "def".toLowerCase(): + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymDefense); + break; + case "dexterity".toLowerCase(): + case "dex".toLowerCase(): + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymDexterity); + break; + case "agility".toLowerCase(): + case "agi".toLowerCase(): + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymAgility); + break; + default: + workerScript.scriptRef.log("Invalid stat: " + stat + ". gymWorkout() failed"); + return false; + } + workerScript.scriptRef.log("Started training " + stat + " at " + gymName); + return true; + }, + + travelToCity(cityname) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 1)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run travelToCity(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); + return false; + } + } + + switch(cityname) { + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum: + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Chongqing: + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12: + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].NewTokyo: + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Ishima: + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Volhaven: + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(200000); + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city = cityname; + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); + workerScript.scriptRef.log("Traveled to " + cityname); + return true; + default: + workerScript.scriptRef.log("ERROR: Invalid city name passed into travelToCity()."); + return false; + } + }, + + purchaseTor() { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 1)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run purchaseTor(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); + return false; + } + } + + if (__WEBPACK_IMPORTED_MODULE_17__SpecialServerIps_js__["a" /* SpecialServerIps */]["Darkweb Server"] != null) { + workerScript.scriptRef.log("You already have a TOR router! purchaseTor() failed"); + return false; + } + + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.lt(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].TorRouterCost)) { + workerScript.scriptRef.log("ERROR: You cannot afford to purchase a Tor router. purchaseTor() failed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].TorRouterCost); + + var darkweb = new __WEBPACK_IMPORTED_MODULE_15__Server_js__["d" /* Server */](Object(__WEBPACK_IMPORTED_MODULE_27__utils_IPAddress_js__["a" /* createRandomIp */])(), "darkweb", "", false, false, false, 1); + Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["a" /* AddToAllServers */])(darkweb); + __WEBPACK_IMPORTED_MODULE_17__SpecialServerIps_js__["a" /* SpecialServerIps */].addIp("Darkweb Server", darkweb.ip); + + document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button-inactive"); + + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().serversOnNetwork.push(darkweb.ip); + darkweb.serversOnNetwork.push(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().ip); + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); + workerScript.scriptRef.log("You have purchased a Tor router!"); + return true; + }, + purchaseProgram(programName) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 1)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run purchaseProgram(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); + return false; + } + } + + if (__WEBPACK_IMPORTED_MODULE_17__SpecialServerIps_js__["a" /* SpecialServerIps */]["Darkweb Server"] == null) { + workerScript.scriptRef.log("ERROR: You do not have TOR router. purchaseProgram() failed."); + return false; + } + + switch(programName.toLowerCase()) { + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram.toLowerCase(): + var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].BruteSSHProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram); + workerScript.scriptRef.log("You have purchased the BruteSSH.exe program. The new program " + + "can be found on your home computer."); + } else { + workerScript.scriptRef.log("Not enough money to purchase " + programName); + return false; + } + return true; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram.toLowerCase(): + var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].FTPCrackProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram); + workerScript.scriptRef.log("You have purchased the FTPCrack.exe program. The new program " + + "can be found on your home computer."); + } else { + workerScript.scriptRef.log("Not enough money to purchase " + programName); + return false; + } + return true; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram.toLowerCase(): + var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].RelaySMTPProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram); + workerScript.scriptRef.log("You have purchased the relaySMTP.exe program. The new program " + + "can be found on your home computer."); + } else { + workerScript.scriptRef.log("Not enough money to purchase " + programName); + return false; + } + return true; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram.toLowerCase(): + var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].HTTPWormProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram); + workerScript.scriptRef.log("You have purchased the HTTPWorm.exe program. The new program " + + "can be found on your home computer."); + } else { + workerScript.scriptRef.log("Not enough money to purchase " + programName); + return false; + } + return true; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram.toLowerCase(): + var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].SQLInjectProgram); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram); + workerScript.scriptRef.log("You have purchased the SQLInject.exe program. The new program " + + "can be found on your home computer."); + } else { + workerScript.scriptRef.log("Not enough money to purchase " + programName); + return false; + } + return true; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV1.toLowerCase(): + var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].DeepScanV1Program); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV1); + workerScript.scriptRef.log("You have purchased the DeepscanV1.exe program. The new program " + + "can be found on your home computer."); + } else { + workerScript.scriptRef.log("Not enough money to purchase " + programName); + return false; + } + return true; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV2.toLowerCase(): + var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].DeepScanV2Program); + if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV2); + workerScript.scriptRef.log("You have purchased the DeepscanV2.exe program. The new program " + + "can be found on your home computer."); + } else { + workerScript.scriptRef.log("Not enough money to purchase " + programName); + return false; + } + return true; + default: + workerScript.scriptRef.log("ERROR: Invalid program passed into purchaseProgram()."); + return false; + } + return true; + }, + getStats : function() { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 1)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getStats(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); + return {}; + } + } + + return { + hacking: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill, + strength: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].strength, + defense: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].defense, + dexterity: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].dexterity, + agility: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].agility, + charisma: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].charisma, + intelligence: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].intelligence + } + }, + isBusy : function() { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 1)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run isBusy(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); + return; + } + } + return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking; + }, + upgradeHomeRam() { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 2)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run upgradeHomeRam(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + return false; + } + } + + //Calculate how many times ram has been upgraded (doubled) + var currentRam = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().maxRam; + var numUpgrades = Math.log2(currentRam); + + //Calculate cost + //Have cost increase by some percentage each time RAM has been upgraded + var cost = currentRam * __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].BaseCostFor1GBOfRamHome; + var mult = Math.pow(1.55, numUpgrades); + cost = cost * mult; + + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.lt(cost)) { + workerScript.scriptRef.log("ERROR: upgradeHomeRam() failed because you don't have enough money"); + return false; + } + + var homeComputer = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer(); + homeComputer.maxRam *= 2; + + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(cost); + + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); + workerScript.scriptRef.log("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM."); + return true; + }, + getUpgradeHomeRamCost() { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 2)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getUpgradeHomeRamCost(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + return false; + } + } + + //Calculate how many times ram has been upgraded (doubled) + var currentRam = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().maxRam; + var numUpgrades = Math.log2(currentRam); + + //Calculate cost + //Have cost increase by some percentage each time RAM has been upgraded + var cost = currentRam * __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].BaseCostFor1GBOfRamHome; + var mult = Math.pow(1.55, numUpgrades); + return cost * mult; + }, + workForCompany() { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 2)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run workForCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + return false; + } + } + + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition == "" || !(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition instanceof __WEBPACK_IMPORTED_MODULE_4__Company_js__["c" /* CompanyPosition */])) { + workerScript.scriptRef.log("ERROR: workForCompany() failed because you do not have a job"); + return false; + } + + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { + var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); + workerScript.scriptRef.log(txt); + } + + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition.isPartTimeJob()) { + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startWorkPartTime(); + } else { + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startWork(); + } + workerScript.scriptRef.log("Began working at " + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyName + " as a " + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition.positionName); + return true; + }, + applyToCompany(companyName, field) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 2)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run applyToCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + return false; + } + } + + if (!Object(__WEBPACK_IMPORTED_MODULE_4__Company_js__["e" /* companyExists */])(companyName)) { + workerScript.scriptRef.log("ERROR: applyToCompany() failed because specified company " + companyName + " does not exist."); + return false; + } + + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = companyName; + var res; + switch (field.toLowerCase()) { + case "software": + res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForSoftwareJob(true); + break; + case "software consultant": + res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForSoftwareConsultantJob(true); + break; + case "it": + res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForItJob(true); + break; + case "security engineer": + res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForSecurityEngineerJob(true); + break; + case "network engineer": + res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForNetworkEngineerJob(true); + break; + case "business": + res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForBusinessJob(true); + break; + case "business consultant": + res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForBusinessConsultantJob(true); + break; + case "security": + res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForSecurityJob(true); + break; + case "agent": + res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForAgentJob(true); + break; + case "employee": + res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForEmployeeJob(true); + break; + case "part-time employee": + res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForPartTimeEmployeeJob(true); + break; + case "waiter": + res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForWaiterJob(true); + break; + case "part-time waiter": + res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForPartTimeWaiterJob(true); + break; + default: + workerScript.scriptRef.log("ERROR: Invalid job passed into applyToCompany: " + field + ". applyToCompany() failed"); + return false; + } + //The Player object's applyForJob function can return string with special error messages + if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["f" /* isString */])(res)) { + workerScript.scriptRef.log(res); + return false; + } + if (res) { + workerScript.scriptRef.log("You were offered a new job at " + companyName + " as a " + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition.positionName); + } else { + workerScript.scriptRef.log("You failed to get a new job/promotion at " + companyName + " in the " + field + " field."); + } + return res; + }, + getCompanyRep(companyName) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 2)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getCompanyRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + return false; + } + } + + var company = __WEBPACK_IMPORTED_MODULE_4__Company_js__["a" /* Companies */][companyName]; + if (company === null || !(company instanceof __WEBPACK_IMPORTED_MODULE_4__Company_js__["b" /* Company */])) { + workerScript.scriptRef.log("ERROR: Invalid companyName passed into getCompanyRep(): " + companyName); + return -1; + } + return company.playerReputation; + }, + checkFactionInvitations() { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 2)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run checkFactionInvitations(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + return false; + } + } + //Make a copy of Player.factionInvitations + return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factionInvitations.slice(); + }, + joinFaction(name) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 2)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run joinFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + return false; + } + } + + if (!Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["d" /* factionExists */])(name)) { + workerScript.scriptRef.log("ERROR: Faction specified in joinFaction() does not exist."); + return false; + } + + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factionInvitations.includes(name)) { + workerScript.scriptRef.log("ERROR: Cannot join " + name + " Faction because you have not been invited. joinFaction() failed"); + return false; + } + + var index = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factionInvitations.indexOf(name); + if (index === -1) { + //Redundant and should never happen... + workerScript.scriptRef.log("ERROR: Cannot join " + name + " Faction because you have not been invited. joinFaction() failed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factionInvitations.splice(index, 1); + var fac = __WEBPACK_IMPORTED_MODULE_9__Faction_js__["b" /* Factions */][name]; + Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["h" /* joinFaction */])(fac); + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); + workerScript.scriptRef.log("Joined the " + name + " faction."); + return true; + }, + workForFaction(name, type) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 2)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run workForFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + return false; + } + } + + if (!Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["d" /* factionExists */])(name)) { + workerScript.scriptRef.log("ERROR: Faction specified in workForFaction() does not exist."); + return false; + } + + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factions.includes(name)) { + workerScript.scriptRef.log("ERROR: workForFaction() failed because you are not a member of " + name); + return false; + } + + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { + var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); + workerScript.scriptRef.log(txt); + } + + var fac = __WEBPACK_IMPORTED_MODULE_9__Faction_js__["b" /* Factions */][name]; + //Arrays listing factions that allow each time of work + var hackAvailable = ["Illuminati", "Daedalus", "The Covenant", "ECorp", "MegaCorp", + "Bachman & Associates", "Blade Industries", "NWO", "Clarke Incorporated", + "OmniTek Incorporated", "Four Sigma", "KuaiGong International", + "Fulcrum Secret Technologies", "BitRunners", "The Black Hand", + "NiteSec", "Chongqing", "Sector-12", "New Tokyo", "Aevum", + "Ishima", "Volhaven", "Speakers for the Dead", "The Dark Army", + "The Syndicate", "Silhouette", "Netburners", "Tian Di Hui", "CyberSec"]; + var fdWkAvailable = ["Illuminati", "Daedalus", "The Covenant", "ECorp", "MegaCorp", + "Bachman & Associates", "Blade Industries", "NWO", "Clarke Incorporated", + "OmniTek Incorporated", "Four Sigma", "KuaiGong International", + "The Black Hand", "Chongqing", "Sector-12", "New Tokyo", "Aevum", + "Ishima", "Volhaven", "Speakers for the Dead", "The Dark Army", + "The Syndicate", "Silhouette", "Tetrads", "Slum Snakes"]; + var scWkAvailable = ["ECorp", "MegaCorp", + "Bachman & Associates", "Blade Industries", "NWO", "Clarke Incorporated", + "OmniTek Incorporated", "Four Sigma", "KuaiGong International", + "Fulcrum Secret Technologies", "Chongqing", "Sector-12", "New Tokyo", "Aevum", + "Ishima", "Volhaven", "Speakers for the Dead", + "The Syndicate", "Tetrads", "Slum Snakes", "Tian Di Hui"]; + + switch (type.toLowerCase()) { + case "hacking": + case "hacking contracts": + case "hackingcontracts": + if (!hackAvailable.includes(fac.name)) { + workerScript.scriptRef.log("ERROR: Cannot carry out hacking contracts for " + fac.name + ". workForFaction() failed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startFactionHackWork(fac); + workerScript.scriptRef.log("Started carrying out hacking contracts for " + fac.name); + return true; + case "field": + case "fieldwork": + case "field work": + if (!fdWkAvailable.includes(fac.name)) { + workerScript.scriptRef.log("ERROR: Cannot carry out field missions for " + fac.name + ". workForFaction() failed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startFactionFieldWork(fac); + workerScript.scriptRef.log("Started carrying out field missions for " + fac.name); + return true; + case "security": + case "securitywork": + case "security work": + if (!scWkAvailable.includes(fac.name)) { + workerScript.scriptRef.log("ERROR: Cannot serve as security detail for " + fac.name + ". workForFaction() failed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startFactionSecurityWork(fac); + workerScript.scriptRef.log("Started serving as security details for " + fac.name); + return true; + default: + workerScript.scriptRef.log("ERROR: Invalid work type passed into workForFaction(): " + type); + } + return true; + }, + getFactionRep(name) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 2)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getFactionRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); + return -1; + } + } + + if (!Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["d" /* factionExists */])(name)) { + workerScript.scriptRef.log("ERROR: Faction specified in getFactionRep() does not exist."); + return -1; + } + + return __WEBPACK_IMPORTED_MODULE_9__Faction_js__["b" /* Factions */][name].playerReputation; + }, + createProgram(name) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 3)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run createProgram(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + return false; + } + } + + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { + var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); + workerScript.scriptRef.log(txt); + } + + switch(name.toLowerCase()) { + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].NukeProgram.toLowerCase(): + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].NukeProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerFiveMinutes, 1); + break; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 50) { + workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create BruteSSH (level 50 req)"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerFiveMinutes * 2, 50); + break; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 100) { + workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create FTPCrack (level 100 req)"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerHalfHour, 100); + break; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 250) { + workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create relaySMTP (level 250 req)"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer2Hours, 250); + break; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 500) { + workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create HTTPWorm (level 500 req)"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer4Hours, 500); + break; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 750) { + workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create SQLInject (level 750 req)"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer8Hours, 750); + break; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV1.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 75) { + workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV1 (level 75 req)"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV1, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerQuarterHour, 75); + break; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV2.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 400) { + workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV2 (level 400 req)"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV2, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer2Hours, 400); + break; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].ServerProfiler.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 75) { + workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create ServerProfiler (level 75 req)"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].ServerProfiler, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerHalfHour, 75); + break; + case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].AutoLink.toLowerCase(): + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 25) { + workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create AutoLink (level 25 req)"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].AutoLink, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerQuarterHour, 25); + break; + default: + workerScript.scriptRef.log("ERROR: createProgram() failed because the specified program does not exist: " + name); + return false; + } + workerScript.scriptRef.log("Began creating program: " + name); + return true; + }, + commitCrime(crime) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 3)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run commitCrime(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + return; + } + } + + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { + var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); + workerScript.scriptRef.log(txt); + } + + //Set Location to slums + switch(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city) { + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum: + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSlums; + break; + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Chongqing: + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].ChongqingSlums; + break; + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12: + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12Slums; + break; + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].NewTokyo: + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].NewTokyoSlums; + break; + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Ishima: + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].IshimaSlums; + break; + case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Volhaven: + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenSlums; + break; + default: + console.log("Invalid Player.city value"); + } + + crime = crime.toLowerCase(); + if (crime.includes("shoplift")) { + workerScript.scriptRef.log("Attempting to shoplift..."); + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["k" /* commitShopliftCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); + } else if (crime.includes("rob") && crime.includes("store")) { + workerScript.scriptRef.log("Attempting to rob a store..."); + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["j" /* commitRobStoreCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); + } else if (crime.includes("mug")) { + workerScript.scriptRef.log("Attempting to mug someone..."); + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["i" /* commitMugCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); + } else if (crime.includes("larceny")) { + workerScript.scriptRef.log("Attempting to commit larceny..."); + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["h" /* commitLarcenyCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); + } else if (crime.includes("drugs")) { + workerScript.scriptRef.log("Attempting to deal drugs..."); + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["c" /* commitDealDrugsCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); + } else if (crime.includes("bond") && crime.includes("forge")) { + workerScript.scriptRef.log("Attempting to forge corporate bonds..."); + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["b" /* commitBondForgeryCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); + } else if (crime.includes("traffick") && crime.includes("arms")) { + workerScript.scriptRef.log("Attempting to traffick illegal arms..."); + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["l" /* commitTraffickArmsCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); + } else if (crime.includes("homicide")) { + workerScript.scriptRef.log("Attempting to commit homicide..."); + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["f" /* commitHomicideCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); + } else if (crime.includes("grand") && crime.includes("auto")) { + workerScript.scriptRef.log("Attempting to commit grand theft auto..."); + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["d" /* commitGrandTheftAutoCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); + } else if (crime.includes("kidnap")) { + workerScript.scriptRef.log("Attempting to kidnap and ransom a high-profile target..."); + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["g" /* commitKidnapCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); + } else if (crime.includes("assassinate")) { + workerScript.scriptRef.log("Attempting to assassinate a high-profile target..."); + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["a" /* commitAssassinationCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}) + } else if (crime.includes("heist")) { + workerScript.scriptRef.log("Attempting to pull off a heist..."); + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["e" /* commitHeistCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); + } else { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid crime passed into commitCrime(): " + crime); + } + }, + getCrimeChance(crime) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 3)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getCrimeChance(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + return; + } + } + + crime = crime.toLowerCase(); + if (crime.includes("shoplift")) { + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["w" /* determineCrimeChanceShoplift */])(); + } else if (crime.includes("rob") && crime.includes("store")) { + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["v" /* determineCrimeChanceRobStore */])(); + } else if (crime.includes("mug")) { + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["u" /* determineCrimeChanceMug */])(); + } else if (crime.includes("larceny")) { + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["t" /* determineCrimeChanceLarceny */])(); + } else if (crime.includes("drugs")) { + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["o" /* determineCrimeChanceDealDrugs */])(); + } else if (crime.includes("bond") && crime.includes("forge")) { + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["n" /* determineCrimeChanceBondForgery */])(); + } else if (crime.includes("traffick") && crime.includes("arms")) { + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["x" /* determineCrimeChanceTraffickArms */])(); + } else if (crime.includes("homicide")) { + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["r" /* determineCrimeChanceHomicide */])(); + } else if (crime.includes("grand") && crime.includes("auto")) { + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["p" /* determineCrimeChanceGrandTheftAuto */])(); + } else if (crime.includes("kidnap")) { + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["s" /* determineCrimeChanceKidnap */])(); + } else if (crime.includes("assassinate")) { + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["m" /* determineCrimeChanceAssassination */])(); + } else if (crime.includes("heist")) { + return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["q" /* determineCrimeChanceHeist */])(); + } else { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid crime passed into getCrimeChance(): " + crime); + } + }, + getOwnedAugmentations(purchased=false) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 3)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getOwnedAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + return []; + } + } + var res = []; + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].augmentations.length; ++i) { + res.push(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].augmentations[i].name); + } + if (purchased) { + for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations.length; ++i) { + res.push(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations[i].name); + } + } + return res; + }, + getAugmentationsFromFaction(facname) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 3)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getAugmentationsFromFaction(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + return []; + } + } + + if (!Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["d" /* factionExists */])(facname)) { + workerScript.scriptRef.log("ERROR: getAugmentationsFromFaction() failed. Invalid faction name passed in (this is case-sensitive): " + facname); + return []; + } + + var fac = __WEBPACK_IMPORTED_MODULE_9__Faction_js__["b" /* Factions */][facname]; + var res = []; + for (var i = 0; i < fac.augmentations.length; ++i) { + res.push(fac.augmentations[i]); + } + return res; + }, + getAugmentationCost(name) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 3)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getAugmentationCost(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + return false; + } + } + + if (!Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["f" /* augmentationExists */])(name)) { + workerScript.scriptRef.log("ERROR: getAugmentationCost() failed. Invalid Augmentation name passed in (note: this is case-sensitive): " + name); + return [-1, -1]; + } + + var aug = __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */][name]; + return [aug.baseRepRequirement, aug.baseCost]; + }, + purchaseAugmentation(faction, name) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 3)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run purchaseAugmentation(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + return false; + } + } + + var fac = __WEBPACK_IMPORTED_MODULE_9__Faction_js__["b" /* Factions */][faction]; + if (fac === null || !(fac instanceof __WEBPACK_IMPORTED_MODULE_9__Faction_js__["a" /* Faction */])) { + workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because of invalid faction name: " + faction); + return false; + } + + if (!fac.augmentations.includes(name)) { + workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because the faction " + faction + " does not contain the " + name + " augmentation"); + return false; + } + + var aug = __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */][name]; + if (aug === null || !(aug instanceof __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["a" /* Augmentation */])) { + workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because of invalid augmentation name: " + name); + return false; + } + + var isNeuroflux = false; + if (aug.name === __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["b" /* AugmentationNames */].NeuroFluxGovernor) { + isNeuroflux = true; + } + + if (!isNeuroflux) { + for (var j = 0; j < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations.length; ++j) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations[j].name === aug.name) { + workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name); + return false; + } + } + for (var j = 0; j < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].augmentations.length; ++j) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].augmentations[j].name === aug.name) { + workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name); + return false; + } + } + } + + if (fac.playerReputation < aug.baseRepRequirement) { + workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you do not have enough reputation with " + fac.name); + return false; + } + + var res = Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["k" /* purchaseAugmentation */])(aug, fac, true); + workerScript.scriptRef.log(res); + if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["f" /* isString */])(res) && res.startsWith("You purchased")) { + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); + return true; + } else { + return false; + } + }, + installAugmentations(cbScript) { + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { + if (!(hasSingularitySF && singularitySFLvl >= 3)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run installAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); + return false; + } + } + + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations.length === 0) { + workerScript.scriptRef.log("ERROR: installAugmentations() failed because you do not have any Augmentations to be installed"); + return false; + } + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); + workerScript.scriptRef.log("Installing Augmentations. This will cause this script to be killed"); + Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["h" /* installAugmentations */])(cbScript); + return true; + } + } +} + + + + +/***/ }), +/* 20 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return AugmentationNames; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return Augmentations; }); @@ -23489,7 +25727,7 @@ function giveAllAugmentations() { /***/ }), -/* 20 */ +/* 21 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -24656,7 +26894,104 @@ function getJobRequirementText(company, pos, tooltiptext=false) { /***/ }), -/* 21 */ +/* 22 */ +/***/ (function(module, __webpack_exports__, __webpack_require__) { + +"use strict"; +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return yesNoBoxCreate; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return yesNoTxtInpBoxCreate; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return yesNoBoxGetYesButton; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return yesNoBoxGetNoButton; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return yesNoTxtInpBoxGetYesButton; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return yesNoTxtInpBoxGetNoButton; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return yesNoTxtInpBoxGetInput; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return yesNoBoxClose; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return yesNoTxtInpBoxClose; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return yesNoBoxOpen; }); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__ = __webpack_require__(2); + +/* Generic Yes-No Pop-up box + * Can be used to create pop-up boxes that require a yes/no response from player + */ +var yesNoBoxOpen = false; +function yesNoBoxClose() { + var container = document.getElementById("yes-no-box-container"); + if (container) { + container.style.display = "none"; + } else { + console.log("ERROR: Container not found for YesNoBox"); + } + yesNoBoxOpen = false; +} + +function yesNoBoxGetYesButton() { + return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-box-yes"); +} + +function yesNoBoxGetNoButton() { + return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-box-no"); +} + +function yesNoBoxCreate(txt) { + yesNoBoxOpen = true; + var textElement = document.getElementById("yes-no-box-text"); + if (textElement) { + textElement.innerHTML = txt; + } + + var c = document.getElementById("yes-no-box-container"); + if (c) { + c.style.display = "block"; + } else { + console.log("ERROR: Container not found for YesNoBox"); + } +} + +/* Generic Yes-No POp-up Box with Text input */ +function yesNoTxtInpBoxClose() { + var c = document.getElementById("yes-no-text-input-box-container"); + if (c) { + c.style.display = "none"; + } else { + console.log("ERROR: Container not found for YesNoTextInputBox"); + } + yesNoBoxOpen = false; +} + +function yesNoTxtInpBoxGetYesButton() { + return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-text-input-box-yes"); +} + +function yesNoTxtInpBoxGetNoButton() { + return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-text-input-box-no"); +} + +function yesNoTxtInpBoxGetInput() { + var val = document.getElementById("yes-no-text-input-box-input").value; + val = val.replace(/\s+/g, ''); + return val; +} + +function yesNoTxtInpBoxCreate(txt) { + yesNoBoxOpen = true; + var txtE = document.getElementById("yes-no-text-input-box-text"); + if (txtE) { + txtE.innerHTML = txt; + } + + var c = document.getElementById("yes-no-text-input-box-container"); + if (c) { + c.style.display = "block"; + } else { + console.log("ERROR: Container not found for YesNoTextInputBox"); + } +} + + + + +/***/ }), +/* 23 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; @@ -26407,2311 +28742,6 @@ let Terminal = { /* WEBPACK VAR INJECTION */}.call(__webpack_exports__, __webpack_require__(9))) -/***/ }), -/* 22 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return NetscriptFunctions; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return initSingularitySFFlags; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return hasSingularitySF; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return hasBn11SF; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ActiveScriptsUI_js__ = __webpack_require__(25); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__ = __webpack_require__(19); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Crimes_js__ = __webpack_require__(31); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Company_js__ = __webpack_require__(20); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Constants_js__ = __webpack_require__(3); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__ = __webpack_require__(15); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__ = __webpack_require__(44); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__engine_js__ = __webpack_require__(5); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__Faction_js__ = __webpack_require__(10); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__HacknetNode_js__ = __webpack_require__(38); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Location_js__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__Message_js__ = __webpack_require__(24); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__Script_js__ = __webpack_require__(16); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__Server_js__ = __webpack_require__(6); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__Settings_js__ = __webpack_require__(14); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_17__SpecialServerIps_js__ = __webpack_require__(12); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__ = __webpack_require__(28); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_19__Terminal_js__ = __webpack_require__(21); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_20__TextFile_js__ = __webpack_require__(47); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__ = __webpack_require__(37); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_23__NetscriptEnvironment_js__ = __webpack_require__(30); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__utils_decimal_js__ = __webpack_require__(27); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_24__utils_decimal_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_24__utils_decimal_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_25__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_27__utils_IPAddress_js__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__ = __webpack_require__(4); -var sprintf = __webpack_require__(40).sprintf, - vsprintf = __webpack_require__(40).vsprintf - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -var hasSingularitySF = false, hasAISF = false, hasBn11SF = false; -var singularitySFLvl = 1; - -//Used to check and set flags for every Source File, despite the name of the function -function initSingularitySFFlags() { - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles.length; ++i) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].n === 4) { - hasSingularitySF = true; - singularitySFLvl = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].lvl; - } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].n === 5) { - hasAISF = true; - } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].sourceFiles[i].n === 11) { - hasBn11SF = true; - } - } -} - -function NetscriptFunctions(workerScript) { - return { - Math : Math, - Date : Date, - hacknetnodes : __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacknetNodes, - sprintf : sprintf, - vsprintf: vsprintf, - scan : function(ip=workerScript.serverIp, hostnames=true){ - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, 'Invalid IP or hostname passed into scan() command'); - } - var out = []; - for (var i = 0; i < server.serversOnNetwork.length; i++) { - var entry; - if (hostnames) { - entry = server.getServerOnNetwork(i).hostname; - } else { - entry = server.getServerOnNetwork(i).ip; - } - if (entry == null) { - continue; - } - out.push(entry); - } - workerScript.scriptRef.log('scan() returned ' + server.serversOnNetwork.length + ' connections for ' + server.hostname); - return out; - }, - hack : function(ip){ - if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Hack() call has incorrect number of arguments. Takes 1 argument"); - } - var threads = workerScript.scriptRef.threads; - if (isNaN(threads) || threads < 1) {threads = 1;} - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping..."); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping..."); - } - - //Calculate the hacking time - var hackingTime = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["i" /* scriptCalculateHackingTime */])(server); //This is in seconds - - //No root access or skill level too low - if (server.hasAdminRights == false) { - workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user does not have root access"); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot hack this server (" + server.hostname + ") because user does not have root access"); - } - - if (server.requiredHackingSkill > __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill) { - workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough"); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough"); - } - - workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime.toFixed(3) + " seconds (t=" + threads + ")"); - //console.log("Hacking " + server.hostname + " after " + hackingTime.toString() + " seconds (t=" + threads + ")"); - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["d" /* netscriptDelay */])(hackingTime* 1000, workerScript).then(function() { - if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} - var hackChance = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["h" /* scriptCalculateHackingChance */])(server); - var rand = Math.random(); - var expGainedOnSuccess = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["f" /* scriptCalculateExpGain */])(server) * threads; - var expGainedOnFailure = (expGainedOnSuccess / 4); - if (rand < hackChance) { //Success! - var moneyGained = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["j" /* scriptCalculatePercentMoneyHacked */])(server); - moneyGained = Math.floor(server.moneyAvailable * moneyGained) * threads; - - //Over-the-top safety checks - if (moneyGained <= 0) { - moneyGained = 0; - expGainedOnSuccess = expGainedOnFailure; - } - if (moneyGained > server.moneyAvailable) {moneyGained = server.moneyAvailable;} - server.moneyAvailable -= moneyGained; - if (server.moneyAvailable < 0) {server.moneyAvailable = 0;} - - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainMoney(moneyGained); - workerScript.scriptRef.onlineMoneyMade += moneyGained; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].scriptProdSinceLastAug += moneyGained; - workerScript.scriptRef.recordHack(server.ip, moneyGained, threads); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainHackingExp(expGainedOnSuccess); - workerScript.scriptRef.onlineExpGained += expGainedOnSuccess; - //console.log("Script successfully hacked " + server.hostname + " for $" + formatNumber(moneyGained, 2) + " and " + formatNumber(expGainedOnSuccess, 4) + " exp"); - workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(moneyGained, 2) + " and " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGainedOnSuccess, 4) + " exp (t=" + threads + ")"); - server.fortify(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ServerFortifyAmount * threads); - return Promise.resolve(true); - } else { - //Player only gains 25% exp for failure? TODO Can change this later to balance - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainHackingExp(expGainedOnFailure); - workerScript.scriptRef.onlineExpGained += expGainedOnFailure; - //console.log("Script unsuccessful to hack " + server.hostname + ". Gained " + formatNumber(expGainedOnFailure, 4) + " exp"); - workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGainedOnFailure, 4) + " exp (t=" + threads + ")"); - return Promise.resolve(false); - } - }); - }, - sleep : function(time,log=true){ - if (time === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "sleep() call has incorrect number of arguments. Takes 1 argument"); - } - if (log) { - workerScript.scriptRef.log("Sleeping for " + time + " milliseconds"); - } - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["d" /* netscriptDelay */])(time, workerScript).then(function() { - return Promise.resolve(true); - }); - }, - grow : function(ip){ - var threads = workerScript.scriptRef.threads; - if (isNaN(threads) || threads < 1) {threads = 1;} - if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "grow() call has incorrect number of arguments. Takes 1 argument"); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("Cannot grow(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot grow(). Invalid IP or hostname passed in: " + ip); - } - - //No root access or skill level too low - if (server.hasAdminRights == false) { - workerScript.scriptRef.log("Cannot grow this server (" + server.hostname + ") because user does not have root access"); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot grow this server (" + server.hostname + ") because user does not have root access"); - } - - var growTime = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["g" /* scriptCalculateGrowTime */])(server); - //console.log("Executing grow() on server " + server.hostname + " in " + formatNumber(growTime/1000, 3) + " seconds") - workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(growTime/1000, 3) + " seconds (t=" + threads + ")"); - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["d" /* netscriptDelay */])(growTime, workerScript).then(function() { - if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} - server.moneyAvailable += (1 * threads); //It can be grown even if it has no money - var growthPercentage = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["j" /* processSingleServerGrowth */])(server, 450 * threads); - workerScript.scriptRef.recordGrow(server.ip, threads); - var expGain = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["f" /* scriptCalculateExpGain */])(server) * threads; - if (growthPercentage == 1) { - expGain = 0; - } - workerScript.scriptRef.log("Available money on " + server.hostname + " grown by " - + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(growthPercentage*100 - 100, 6) + "%. Gained " + - Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGain, 4) + " hacking exp (t=" + threads +")"); - workerScript.scriptRef.onlineExpGained += expGain; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainHackingExp(expGain); - return Promise.resolve(growthPercentage); - }); - }, - weaken : function(ip){ - var threads = workerScript.scriptRef.threads; - if (isNaN(threads) || threads < 1) {threads = 1;} - if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "weaken() call has incorrect number of arguments. Takes 1 argument"); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("Cannot weaken(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot weaken(). Invalid IP or hostname passed in: " + ip); - } - - //No root access or skill level too low - if (server.hasAdminRights == false) { - workerScript.scriptRef.log("Cannot weaken this server (" + server.hostname + ") because user does not have root access"); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot weaken this server (" + server.hostname + ") because user does not have root access"); - } - - var weakenTime = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["k" /* scriptCalculateWeakenTime */])(server); - workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " + - Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(weakenTime/1000, 3) + " seconds (t=" + threads + ")"); - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["d" /* netscriptDelay */])(weakenTime, workerScript).then(function() { - if (workerScript.env.stopFlag) {return Promise.reject(workerScript);} - server.weaken(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ServerWeakenAmount * threads); - workerScript.scriptRef.recordWeaken(server.ip, threads); - var expGain = Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["f" /* scriptCalculateExpGain */])(server) * threads; - workerScript.scriptRef.log("Server security level on " + server.hostname + " weakened to " + server.hackDifficulty + - ". Gained " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(expGain, 4) + " hacking exp (t=" + threads + ")"); - workerScript.scriptRef.onlineExpGained += expGain; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainHackingExp(expGain); - return Promise.resolve(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ServerWeakenAmount * threads); - }); - }, - print : function(args){ - if (args === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "print() call has incorrect number of arguments. Takes 1 argument"); - } - workerScript.scriptRef.log(args.toString()); - }, - tprint : function(args) { - if (args === undefined || args === null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "tprint() call has incorrect number of arguments. Takes 1 argument"); - } - var x = args.toString(); - if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["d" /* isHTML */])(x)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].takeDamage(1); - Object(__WEBPACK_IMPORTED_MODULE_25__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You suddenly feel a sharp shooting pain through your body as an angry voice in your head exclaims:

" + - "DON'T USE TPRINT() TO OUTPUT HTML ELEMENTS TO YOUR TERMINAL!!!!

" + - "(You lost 1 HP)"); - return; - } - Object(__WEBPACK_IMPORTED_MODULE_19__Terminal_js__["b" /* post */])(workerScript.scriptRef.filename + ": " + args.toString()); - }, - clearLog : function() { - workerScript.scriptRef.clearLog(); - }, - nuke : function(ip){ - if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("Cannot call nuke(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call nuke(). Invalid IP or hostname passed in: " + ip); - } - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].NukeProgram)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the NUKE.exe virus!"); - } - if (server.openPortCount < server.numOpenPortsRequired) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Not enough ports opened to use NUKE.exe virus"); - } - if (server.hasAdminRights) { - workerScript.scriptRef.log("Already have root access to " + server.hostname); - } else { - server.hasAdminRights = true; - workerScript.scriptRef.log("Executed NUKE.exe virus on " + server.hostname + " to gain root access"); - } - return true; - }, - brutessh : function(ip){ - if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("Cannot call brutessh(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call brutessh(). Invalid IP or hostname passed in: " + ip); - } - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram)) { - workerScript.scriptRef.log("You do not have the BruteSSH.exe program!"); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the BruteSSH.exe program!"); - } - if (!server.sshPortOpen) { - workerScript.scriptRef.log("Executed BruteSSH.exe on " + server.hostname + " to open SSH port (22)"); - server.sshPortOpen = true; - ++server.openPortCount; - } else { - workerScript.scriptRef.log("SSH Port (22) already opened on " + server.hostname); - } - return true; - }, - ftpcrack : function(ip){ - if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip); - } - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the FTPCrack.exe program!"); - } - if (!server.ftpPortOpen) { - workerScript.scriptRef.log("Executed FTPCrack.exe on " + server.hostname + " to open FTP port (21)"); - server.ftpPortOpen = true; - ++server.openPortCount; - } else { - workerScript.scriptRef.log("FTP Port (21) already opened on " + server.hostname); - } - return true; - }, - relaysmtp : function(ip){ - if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip); - } - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the relaySMTP.exe program!"); - } - if (!server.smtpPortOpen) { - workerScript.scriptRef.log("Executed relaySMTP.exe on " + server.hostname + " to open SMTP port (25)"); - server.smtpPortOpen = true; - ++server.openPortCount; - } else { - workerScript.scriptRef.log("SMTP Port (25) already opened on " + server.hostname); - } - return true; - }, - httpworm : function(ip){ - if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("Cannot call httpworm(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call httpworm(). Invalid IP or hostname passed in: " + ip); - } - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the HTTPWorm.exe program!"); - } - if (!server.httpPortOpen) { - workerScript.scriptRef.log("Executed HTTPWorm.exe on " + server.hostname + " to open HTTP port (80)"); - server.httpPortOpen = true; - ++server.openPortCount; - } else { - workerScript.scriptRef.log("HTTP Port (80) already opened on " + server.hostname); - } - return true; - }, - sqlinject : function(ip){ - if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument"); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip); - } - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasProgram(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You do not have the SQLInject.exe program!"); - } - if (!server.sqlPortOpen) { - workerScript.scriptRef.log("Executed SQLInject.exe on " + server.hostname + " to open SQL port (1433)"); - server.sqlPortOpen = true; - ++server.openPortCount; - } else { - workerScript.scriptRef.log("SQL Port (1433) already opened on " + server.hostname); - } - return true; - }, - run : function(scriptname,threads = 1){ - if (scriptname === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "run() call has incorrect number of arguments. Usage: run(scriptname, [numThreads], [arg1], [arg2]...)"); - } - if (isNaN(threads) || threads < 1) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument for thread count passed into run(). Must be numeric and greater than 0"); - } - var argsForNewScript = []; - for (var i = 2; i < arguments.length; ++i) { - argsForNewScript.push(arguments[i]); - } - var scriptServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); - if (scriptServer == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server. This is a bug in the game. Report to game dev"); - } - - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["e" /* runScriptFromScript */])(scriptServer, scriptname, argsForNewScript, workerScript, threads); - }, - exec : function(scriptname,ip,threads = 1){ - if (scriptname === undefined || ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "exec() call has incorrect number of arguments. Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)"); - } - if (isNaN(threads) || threads < 1) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument for thread count passed into exec(). Must be numeric and greater than 0"); - } - var argsForNewScript = []; - for (var i = 3; i < arguments.length; ++i) { - argsForNewScript.push(arguments[i]); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid hostname/ip passed into exec() command: " + ip); - } - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["e" /* runScriptFromScript */])(server, scriptname, argsForNewScript, workerScript, threads); - }, - kill : function(filename,ip){ - if (filename === undefined || ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "kill() call has incorrect number of arguments. Usage: kill(scriptname, server, [arg1], [arg2]...)"); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("kill() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "kill() failed. Invalid IP or hostname passed in: " + ip); - } - var argsForKillTarget = []; - for (var i = 2; i < arguments.length; ++i) { - argsForKillTarget.push(arguments[i]); - } - var runningScriptObj = Object(__WEBPACK_IMPORTED_MODULE_14__Script_js__["d" /* findRunningScript */])(filename, argsForKillTarget, server); - if (runningScriptObj == null) { - workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForKillTarget)); - return false; - } - var res = Object(__WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["d" /* killWorkerScript */])(runningScriptObj, server.ip); - if (res) { - workerScript.scriptRef.log("Killing " + filename + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForKillTarget) + ". May take up to a few minutes for the scripts to die..."); - return true; - } else { - workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForKillTarget)); - return false; - } - }, - killall : function(ip){ - if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "killall() call has incorrect number of arguments. Takes 1 argument"); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("killall() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "killall() failed. Invalid IP or hostname passed in: " + ip); - } - for (var i = server.runningScripts.length-1; i >= 0; --i) { - Object(__WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["d" /* killWorkerScript */])(server.runningScripts[i], server.ip); - } - workerScript.scriptRef.log("killall(): Killing all scripts on " + server.hostname + ". May take a few minutes for the scripts to die"); - return true; - }, - scp : function(scriptname, ip1, ip2){ - if (arguments.length !== 2 && arguments.length !== 3) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments"); - } - if (scriptname && scriptname.constructor === Array) { - //Recursively call scp on all elements of array - var res = false; - scriptname.forEach(function(script) { - if (NetscriptFunctions(workerScript).scp(script, ip1, ip2)) { - res = true; - }; - }); - return res; - } - if (!scriptname.endsWith(".lit") && !scriptname.endsWith(".script")) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() only works for .script and .lit files"); - } - - var destServer, currServ; - - if (arguments.length === 3) { //scriptname, source, destination - if (scriptname === undefined || ip1 === undefined || ip2 === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments"); - } - destServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip2); - if (destServer == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: Invalid hostname/ip passed into scp() command: " + ip); - } - - currServ = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip1); - if (currServ == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer"); - } - } else if (arguments.length === 2) { //scriptname, destination - if (scriptname === undefined || ip1 === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments"); - } - destServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip1); - if (destServer == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error: Invalid hostname/ip passed into scp() command: " + ip); - } - - currServ = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); - if (currServ == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer"); - } - } - - //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 __WEBPACK_IMPORTED_MODULE_12__Message_js__["a" /* Message */]) && currServ.messages[i] == scriptname) { - found = true; - } - } - - if (!found) { - workerScript.scriptRef.log(scriptname + " does not exist. scp() failed"); - return false; - } - - for (var i = 0; i < destServer.messages.length; ++i) { - if (destServer.messages[i] === scriptname) { - workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname); - return true; //Already exists - } - } - destServer.messages.push(scriptname); - workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname); - return true; - } - - //Scp for script files - 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) { - workerScript.scriptRef.log(scriptname + " does not exist. scp() failed"); - return false; - } - - //Overwrite script if it already exists - for (var i = 0; i < destServer.scripts.length; ++i) { - if (scriptname == destServer.scripts[i].filename) { - workerScript.scriptRef.log("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and it will be overwritten."); - workerScript.scriptRef.log(scriptname + " overwritten on " + destServer.hostname); - var oldScript = destServer.scripts[i]; - oldScript.code = sourceScript.code; - oldScript.ramUsage = sourceScript.ramUsage; - return true; - } - } - - //Create new script if it does not already exist - var newScript = new __WEBPACK_IMPORTED_MODULE_14__Script_js__["c" /* Script */](); - newScript.filename = scriptname; - newScript.code = sourceScript.code; - newScript.ramUsage = sourceScript.ramUsage; - newScript.server = destServer.ip; - destServer.scripts.push(newScript); - workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname); - return true; - }, - ls : function(ip, grep) { - if (ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ls() failed because of invalid arguments. Usage: ls(ip/hostname, [grep filter])"); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server === null) { - workerScript.scriptRef.log("ls() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ls() failed. Invalid IP or hostname passed in: " + ip); - } - - //Get the grep filter, if one exists - var filter = false; - if (arguments.length >= 2) { - filter = grep.toString(); - } - - var allFiles = []; - for (var i = 0; i < server.programs.length; i++) { - if (filter) { - if (server.programs[i].includes(filter)) { - allFiles.push(server.programs[i]); - } - } else { - allFiles.push(server.programs[i]); - } - } - for (var i = 0; i < server.scripts.length; i++) { - if (filter) { - if (server.scripts[i].filename.includes(filter)) { - allFiles.push(server.scripts[i].filename); - } - } else { - allFiles.push(server.scripts[i].filename); - } - - } - for (var i = 0; i < server.messages.length; i++) { - if (filter) { - if (server.messages[i] instanceof __WEBPACK_IMPORTED_MODULE_12__Message_js__["a" /* Message */]) { - if (server.messages[i].filename.includes(filter)) { - allFiles.push(server.messages[i].filename); - } - } else if (server.messages[i].includes(filter)) { - allFiles.push(server.messages[i]); - } - } else { - if (server.messages[i] instanceof __WEBPACK_IMPORTED_MODULE_12__Message_js__["a" /* Message */]) { - allFiles.push(server.messages[i].filename); - } else { - allFiles.push(server.messages[i]); - } - } - } - - //Sort the files alphabetically then print each - allFiles.sort(); - return allFiles; - }, - hasRootAccess : function(ip){ - if (ip===undefined){ - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "hasRootAccess() call has incorrect number of arguments. Takes 1 argument"); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null){ - workerScript.scriptRef.log("hasRootAccess() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "hasRootAccess() failed. Invalid IP or hostname passed in: " + ip); - } - return server.hasAdminRights; - }, - getIp : function() { - var scriptServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); - if (scriptServer == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server. This is a bug in the game. Report to game dev"); - } - return scriptServer.ip; - }, - getHostname : function(){ - var scriptServer = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); - if (scriptServer == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find server. This is a bug in the game. Report to game dev"); - } - return scriptServer.hostname; - }, - getHackingLevel : function(){ - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].updateSkillLevels(); - workerScript.scriptRef.log("getHackingLevel() returned " + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill); - return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill; - }, - getHackingMultipliers : function() { - return { - chance: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_chance_mult, - speed: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_speed_mult, - money: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_money_mult, - growth: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_grow_mult, - }; - }, - getBitNodeMultipliers: function() { - if (!hasAISF) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getBitNodeMultipliers(). It requires Source-File 5 to run."); - } - return __WEBPACK_IMPORTED_MODULE_2__BitNode_js__["a" /* BitNodeMultipliers */]; - }, - getServerMoneyAvailable : function(ip){ - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("getServerMoneyAvailable() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerMoneyAvailable() failed. Invalid IP or hostname passed in: " + ip); - } - if (server.hostname == "home") { - //Return player's money - workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.toNumber(), 2)); - return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.toNumber(); - } - workerScript.scriptRef.log("getServerMoneyAvailable() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.moneyAvailable, 2) + " for " + server.hostname); - return server.moneyAvailable; - }, - getServerSecurityLevel : function(ip){ - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); - } - workerScript.scriptRef.log("getServerSecurityLevel() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.hackDifficulty, 3) + " for " + server.hostname); - return server.hackDifficulty; - }, - getServerBaseSecurityLevel : function(ip){ - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); - } - workerScript.scriptRef.log("getServerBaseSecurityLevel() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.baseDifficulty, 3) + " for " + server.hostname); - return server.baseDifficulty; - }, - getServerMinSecurityLevel : function(ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip); - } - workerScript.scriptRef.log("getServerMinSecurityLevel() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.minDifficulty, 3) + " for " + server.hostname); - return server.minDifficulty; - }, - getServerRequiredHackingLevel : function(ip){ - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip); - } - workerScript.scriptRef.log("getServerRequiredHackingLevel returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.requiredHackingSkill, 0) + " for " + server.hostname); - return server.requiredHackingSkill; - }, - getServerMaxMoney : function(ip){ - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip); - } - workerScript.scriptRef.log("getServerMaxMoney() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.moneyMax, 0) + " for " + server.hostname); - return server.moneyMax; - }, - getServerGrowth : function(ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("getServerGrowth() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerGrowth() failed. Invalid IP or hostname passed in: " + ip); - } - workerScript.scriptRef.log("getServerGrowth() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.serverGrowth, 0) + " for " + server.hostname); - return server.serverGrowth; - }, - getServerNumPortsRequired : function(ip){ - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip); - } - workerScript.scriptRef.log("getServerNumPortsRequired() returned " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.numOpenPortsRequired, 0) + " for " + server.hostname); - return server.numOpenPortsRequired; - }, - getServerRam : function(ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("getServerRam() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getServerRam() failed. Invalid IP or hostname passed in: " + ip); - } - workerScript.scriptRef.log("getServerRam() returned [" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.maxRam, 2) + "GB, " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(server.ramUsed, 2) + "GB]"); - return [server.maxRam, server.ramUsed]; - }, - serverExists : function(ip) { - return (Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip) !== null); - }, - fileExists : function(filename,ip=workerScript.serverIp){ - if (filename === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "fileExists() call has incorrect number of arguments. Usage: fileExists(scriptname, [server])"); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("fileExists() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "fileExists() failed. Invalid IP or hostname passed in: " + ip); - } - for (var i = 0; i < server.scripts.length; ++i) { - if (filename == server.scripts[i].filename) { - return true; - } - } - for (var i = 0; i < server.programs.length; ++i) { - if (filename.toLowerCase() == server.programs[i].toLowerCase()) { - return true; - } - } - for (var i = 0; i < server.messages.length; ++i) { - if (!(server.messages[i] instanceof __WEBPACK_IMPORTED_MODULE_12__Message_js__["a" /* Message */]) && - filename.toLowerCase() === server.messages[i]) { - return true; - } - } - return false; - }, - isRunning : function(filename,ip){ - if (filename === undefined || ip === undefined) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "isRunning() call has incorrect number of arguments. Usage: isRunning(scriptname, server, [arg1], [arg2]...)"); - } - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("isRunning() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "isRunning() failed. Invalid IP or hostname passed in: " + ip); - } - var argsForTargetScript = []; - for (var i = 2; i < arguments.length; ++i) { - argsForTargetScript.push(arguments[i]); - } - return (Object(__WEBPACK_IMPORTED_MODULE_14__Script_js__["d" /* findRunningScript */])(filename, argsForTargetScript, server) != null); - }, - getNextHacknetNodeCost : __WEBPACK_IMPORTED_MODULE_10__HacknetNode_js__["b" /* getCostOfNextHacknetNode */], - purchaseHacknetNode : __WEBPACK_IMPORTED_MODULE_10__HacknetNode_js__["d" /* purchaseHacknet */], - getStockPrice : function(symbol) { - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use getStockPrice()"); - } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* SymbolToStockMap */][symbol]; - if (stock == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); - } - return parseFloat(stock.price.toFixed(3)); - }, - getStockPosition : function(symbol) { - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use getStockPosition()"); - } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* SymbolToStockMap */][symbol]; - if (stock == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); - } - return [stock.playerShares, stock.playerAvgPx]; - }, - buyStock : function(symbol, shares) { - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use buyStock()"); - } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* SymbolToStockMap */][symbol]; - if (stock == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); - } - if (stock == null || shares < 0 || isNaN(shares)) { - workerScript.scriptRef.log("Error: Invalid 'shares' argument passed to buyStock()"); - return false; - } - shares = Math.round(shares); - if (shares === 0) {return false;} - - var totalPrice = stock.price * shares; - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.lt(totalPrice + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission)) { - workerScript.scriptRef.log("Not enough money to purchase " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + - symbol + ". Need $" + - Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalPrice + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2).toString()); - return false; - } - - var origTotal = stock.playerShares * stock.playerAvgPx; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(totalPrice + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission); - var newTotal = origTotal + totalPrice; - stock.playerShares += shares; - stock.playerAvgPx = newTotal / stock.playerShares; - if (__WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].Page.StockMarket) { - Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["j" /* updateStockPlayerPosition */])(stock); - } - workerScript.scriptRef.log("Bought " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + - Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share"); - return true; - }, - sellStock : function(symbol, shares) { - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use sellStock()"); - } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* SymbolToStockMap */][symbol]; - if (stock == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); - } - - if (stock == null || shares < 0 || isNaN(shares)) { - workerScript.scriptRef.log("Error: Invalid 'shares' argument passed to sellStock()"); - return false; - } - shares = Math.round(shares); - if (shares > stock.playerShares) {shares = stock.playerShares;} - if (shares === 0) {return false;} - var gains = stock.price * shares - __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainMoney(gains); - - //Calculate net profit and add to script stats - var netProfit = ((stock.price - stock.playerAvgPx) * shares) - __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].StockMarketCommission; - if (isNaN(netProfit)) {netProfit = 0;} - workerScript.scriptRef.onlineMoneyMade += netProfit; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].scriptProdSinceLastAug += netProfit; - - stock.playerShares -= shares; - if (stock.playerShares == 0) { - stock.playerAvgPx = 0; - } - if (__WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].Page.StockMarket) { - Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["j" /* updateStockPlayerPosition */])(stock); - } - workerScript.scriptRef.log("Sold " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + - Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. Gained " + - "$" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gains, 2)); - return true; - }, - purchaseServer : function(hostname, ram) { - var hostnameStr = String(hostname); - hostnameStr = hostnameStr.replace(/\s\s+/g, ''); - if (hostnameStr == "") { - workerScript.scriptRef.log("Error: Passed empty string for hostname argument of purchaseServer()"); - return ""; - } - - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.length >= __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].PurchasedServerLimit) { - workerScript.scriptRef.log("Error: You have reached the maximum limit of " + __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].PurchasedServerLimit + - " servers. You cannot purchase any more."); - return ""; - } - - ram = Math.round(ram); - if (isNaN(ram) || !Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["e" /* powerOfTwo */])(ram)) { - workerScript.scriptRef.log("Error: Invalid ram argument passed to purchaseServer(). Must be numeric and a power of 2"); - return ""; - } - - var cost = ram * __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].BaseCostFor1GBOfRamServer; - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.lt(cost)) { - workerScript.scriptRef.log("Error: Not enough money to purchase server. Need $" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(cost, 2)); - return ""; - } - var newServ = new __WEBPACK_IMPORTED_MODULE_15__Server_js__["d" /* Server */](Object(__WEBPACK_IMPORTED_MODULE_27__utils_IPAddress_js__["a" /* createRandomIp */])(), hostnameStr, "", false, true, true, ram); - Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["a" /* AddToAllServers */])(newServ); - - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.push(newServ.ip); - var homeComputer = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer(); - homeComputer.serversOnNetwork.push(newServ.ip); - newServ.serversOnNetwork.push(homeComputer.ip); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(cost); - workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(cost, 2)); - return newServ.hostname; - }, - deleteServer : function(hostname) { - var hostnameStr = String(hostname); - hostnameStr = hostnameStr.replace(/\s\s+/g, ''); - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["c" /* GetServerByHostname */])(hostnameStr); - if (server == null) { - workerScript.scriptRef.log("Error: Could not find server with hostname " + hostnameStr + ". deleteServer() failed"); - return false; - } - - if (!server.purchasedByPlayer || server.hostname == "home") { - workerScript.scriptRef.log("Error: Server " + server.hostname + " is not a purchased server. " + - "Cannot be deleted. deleteServer failed"); - return false; - } - - var ip = server.ip; - - //A server cannot delete itself - if (ip == workerScript.serverIp) { - workerScript.scriptRef.log("Error: Cannot call deleteServer() on self. Function failed"); - return false; - } - - //Delete all scripts running on server - if (server.runningScripts.length > 0) { - workerScript.scriptRef.log("Error: Cannot delete server " + server.hostname + " because it still has scripts running."); - return false; - } - - //Delete from player's purchasedServers array - var found = false; - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.length; ++i) { - if (ip == __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers[i]) { - found = true; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.splice(i, 1); - break; - } - } - - if (!found) { - workerScript.scriptRef.log("Error: Could not identify server " + server.hostname + - "as a purchased server. This is likely a bug please contact game dev"); - return false; - } - - //Delete from all servers - delete __WEBPACK_IMPORTED_MODULE_15__Server_js__["b" /* AllServers */][ip]; - - //Delete from home computer - found = false; - var homeComputer = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer(); - for (var i = 0; i < homeComputer.serversOnNetwork.length; ++i) { - if (ip == homeComputer.serversOnNetwork[i]) { - homeComputer.serversOnNetwork.splice(i, 1); - workerScript.scriptRef.log("Deleted server " + hostnameStr); - return true; - } - } - //Wasn't found on home computer - workerScript.scriptRef.log("Error: Could not find server " + server.hostname + - "as a purchased server. This is likely a bug please contact game dev"); - return false; - }, - getPurchasedServers : function(hostname=true) { - var res = []; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].purchasedServers.forEach(function(ip) { - if (hostname) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERR: Could not find server in getPurchasedServers(). This is a bug please report to game dev"); - } - res.push(server.hostname); - } else { - res.push(ip); - } - }); - return res; - }, - round : function(n) { - if (isNaN(n)) {return 0;} - return Math.round(n); - }, - write : function(port, data="", mode="a") { - if (!isNaN(port)) { //Write to port - //Port 1-10 - if (port < 1 || port > 10) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Trying to write to invalid port: " + port + ". Only ports 1-10 are valid."); - } - var portName = "Port" + String(port); - var port = __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["a" /* NetscriptPorts */][portName]; - if (port == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer"); - } - port.push(data); - if (port.length > __WEBPACK_IMPORTED_MODULE_16__Settings_js__["a" /* Settings */].MaxPortCapacity) { - port.shift(); - return true; - } - return false; - } else if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["f" /* isString */])(port)) { //Write to text file - var fn = port; - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); - if (server === null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error getting Server for this script in write(). This is a bug please contact game dev"); - } - var txtFile = Object(__WEBPACK_IMPORTED_MODULE_20__TextFile_js__["b" /* getTextFile */])(fn, server); - if (txtFile === null) { - txtFile = Object(__WEBPACK_IMPORTED_MODULE_20__TextFile_js__["a" /* createTextFile */])(fn, data, server); - return true; - } - if (mode === "w") { - txtFile.write(data); - } else { - txtFile.append(data); - } - return true; - } else { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument passed in for port: " + port + ". Must be a number between 1 and 10"); - } - }, - read : function(port) { - if (!isNaN(port)) { //Read from port - //Port 1-10 - if (port < 1 || port > 10) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Trying to write to invalid port: " + port + ". Only ports 1-10 are valid."); - } - var portName = "Port" + String(port); - var port = __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["a" /* NetscriptPorts */][portName]; - if (port == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer"); - } - if (port.length == 0) { - return "NULL PORT DATA"; - } else { - return port.shift(); - } - } else if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["f" /* isString */])(port)) { //Read from text file - var fn = port; - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(workerScript.serverIp); - if (server === null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Error getting Server for this script in read(). This is a bug please contact game dev"); - } - var txtFile = Object(__WEBPACK_IMPORTED_MODULE_20__TextFile_js__["b" /* getTextFile */])(fn, server); - if (txtFile !== null) { - return txtFile.text; - } else { - return ""; - } - } else { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid argument passed in for port: " + port + ". Must be a number between 1 and 10"); - } - }, - scriptRunning : function(scriptname, ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("scriptRunning() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "scriptRunning() failed. Invalid IP or hostname passed in: " + ip); - } - for (var i = 0; i < server.runningScripts.length; ++i) { - if (server.runningScripts[i].filename == scriptname) { - return true; - } - } - return false; - }, - scriptKill : function(scriptname, ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("scriptKill() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "scriptKill() failed. Invalid IP or hostname passed in: " + ip); - } - var suc = false; - for (var i = 0; i < server.runningScripts.length; ++i) { - if (server.runningScripts[i].filename == scriptname) { - Object(__WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["d" /* killWorkerScript */])(server.runningScripts[i], server.ip); - suc = true; - } - } - return suc; - }, - getScriptRam : function (scriptname, ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("getScriptRam() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getScriptRam() failed. Invalid IP or hostname passed in: " + ip); - } - for (var i = 0; i < server.scripts.length; ++i) { - if (server.scripts[i].filename == scriptname) { - return server.scripts[i].ramUsage; - } - } - return 0; - }, - getHackTime : function(ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("getHackTime() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getHackTime() failed. Invalid IP or hostname passed in: " + ip); - } - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["i" /* scriptCalculateHackingTime */])(server); //Returns seconds - }, - getGrowTime : function(ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("getGrowTime() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getGrowTime() failed. Invalid IP or hostname passed in: " + ip); - } - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["g" /* scriptCalculateGrowTime */])(server) / 1000; //Returns seconds - }, - getWeakenTime : function(ip) { - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server == null) { - workerScript.scriptRef.log("getWeakenTime() failed. Invalid IP or hostname passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getWeakenTime() failed. Invalid IP or hostname passed in: " + ip); - } - return Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["k" /* scriptCalculateWeakenTime */])(server) / 1000; //Returns seconds - }, - getScriptIncome : function(scriptname, ip) { - if (arguments.length === 0) { - //Get total script income - var res = []; - res.push(Object(__WEBPACK_IMPORTED_MODULE_0__ActiveScriptsUI_js__["d" /* updateActiveScriptsItems */])()); - res.push(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].scriptProdSinceLastAug / (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].playtimeSinceLastAug/1000)); - return res; - } else { - //Get income for a particular script - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server === null) { - workerScript.scriptRef.log("getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip); - } - var argsForScript = []; - for (var i = 2; i < arguments.length; ++i) { - argsForScript.push(arguments[i]); - } - var runningScriptObj = Object(__WEBPACK_IMPORTED_MODULE_14__Script_js__["d" /* findRunningScript */])(scriptname, argsForScript, server); - if (runningScriptObj == null) { - workerScript.scriptRef.log("getScriptIncome() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForScript)); - return -1; - } - return runningScriptObj.onlineMoneyMade / runningScriptObj.onlineRunningTime; - } - }, - getScriptExpGain : function(scriptname, ip) { - if (arguments.length === 0) { - var total = 0; - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["h" /* workerScripts */].length; ++i) { - total += (__WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["h" /* workerScripts */][i].scriptRef.onlineExpGained / __WEBPACK_IMPORTED_MODULE_21__NetscriptWorker_js__["h" /* workerScripts */][i].scriptRef.onlineRunningTime); - } - return total; - } else { - //Get income for a particular script - var server = Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["e" /* getServer */])(ip); - if (server === null) { - workerScript.scriptRef.log("getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip); - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip); - } - var argsForScript = []; - for (var i = 2; i < arguments.length; ++i) { - argsForScript.push(arguments[i]); - } - var runningScriptObj = Object(__WEBPACK_IMPORTED_MODULE_14__Script_js__["d" /* findRunningScript */])(scriptname, argsForScript, server); - if (runningScriptObj == null) { - workerScript.scriptRef.log("getScriptExpGain() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(__WEBPACK_IMPORTED_MODULE_26__utils_HelperFunctions_js__["f" /* printArray */])(argsForScript)); - return -1; - } - return runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime; - } - }, - getTimeSinceLastAug : function() { - return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].playtimeSinceLastAug; - }, - - /* Singularity Functions */ - universityCourse(universityName, className) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 1)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run universityCourse(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); - return false; - } - } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { - var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); - workerScript.scriptRef.log(txt); - } - - var costMult, expMult; - switch(universityName.toLowerCase()) { - case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSummitUniversity.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum) { - workerScript.scriptRef.log("ERROR: You cannot study at Summit University because you are not in Aevum. universityCourse() failed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSummitUniversity; - costMult = 4; - expMult = 3; - break; - case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12RothmanUniversity.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12) { - workerScript.scriptRef.log("ERROR: You cannot study at Rothman University because you are not in Sector-12. universityCourse() failed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12RothmanUniversity; - costMult = 3; - expMult = 2; - break; - case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenZBInstituteOfTechnology.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Volhaven) { - workerScript.scriptRef.log("ERROR: You cannot study at ZB Institute of Technology because you are not in Volhaven. universityCourse() failed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenZBInstituteOfTechnology; - costMult = 5; - expMult = 4; - break; - default: - workerScript.scriptRef.log("Invalid university name: " + universityName + ". universityCourse() failed"); - return false; - } - - var task; - switch(className.toLowerCase()) { - case "Study Computer Science".toLowerCase(): - task = __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassStudyComputerScience; - break; - case "Data Structures".toLowerCase(): - task = __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassDataStructures; - break; - case "Networks".toLowerCase(): - task = __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassNetworks; - break; - case "Algorithms".toLowerCase(): - task = __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassAlgorithms; - break; - case "Management".toLowerCase(): - task = __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassManagement; - break; - case "Leadership".toLowerCase(): - task = __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassLeadership; - break; - default: - workerScript.scriptRef.log("Invalid class name: " + className + ". universityCourse() failed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, task); - workerScript.scriptRef.log("Started " + task + " at " + universityName); - return true; - }, - - gymWorkout(gymName, stat) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 1)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run gymWorkout(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); - return false; - } - } - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { - var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); - workerScript.scriptRef.log(txt); - } - var costMult, expMult; - switch(gymName.toLowerCase()) { - case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumCrushFitnessGym.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum) { - workerScript.scriptRef.log("ERROR: You cannot workout at Crush Fitness because you are not in Aevum. gymWorkout() failed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumCrushFitnessGym; - costMult = 2; - expMult = 1.5; - break; - case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSnapFitnessGym.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum) { - workerScript.scriptRef.log("ERROR: You cannot workout at Snap Fitness because you are not in Aevum. gymWorkout() failed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].AevumSnapFitnessGym; - costMult = 6; - expMult = 4; - break; - case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12IronGym.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12) { - workerScript.scriptRef.log("ERROR: You cannot workout at Iron Gym because you are not in Sector-12. gymWorkout() failed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12IronGym; - costMult = 1; - expMult = 1; - break; - case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12PowerhouseGym.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12) { - workerScript.scriptRef.log("ERROR: You cannot workout at Powerhouse Gym because you are not in Sector-12. gymWorkout() failed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12PowerhouseGym; - costMult = 10; - expMult = 7.5; - break; - case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenMilleniumFitnessGym: - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city != __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Volhaven) { - workerScript.scriptRef.log("ERROR: You cannot workout at Millenium Fitness Gym because you are not in Volhaven. gymWorkout() failed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].VolhavenMilleniumFitnessGym; - costMult = 3; - expMult = 2.5; - break; - default: - workerScript.scriptRef.log("Invalid gym name: " + gymName + ". gymWorkout() failed"); - return false; - } - - switch(stat.toLowerCase()) { - case "strength".toLowerCase(): - case "str".toLowerCase(): - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymStrength); - break; - case "defense".toLowerCase(): - case "def".toLowerCase(): - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymDefense); - break; - case "dexterity".toLowerCase(): - case "dex".toLowerCase(): - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymDexterity); - break; - case "agility".toLowerCase(): - case "agi".toLowerCase(): - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startClass(costMult, expMult, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].ClassGymAgility); - break; - default: - workerScript.scriptRef.log("Invalid stat: " + stat + ". gymWorkout() failed"); - return false; - } - workerScript.scriptRef.log("Started training " + stat + " at " + gymName); - return true; - }, - - travelToCity(cityname) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 1)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run travelToCity(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); - return false; - } - } - - switch(cityname) { - case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Aevum: - case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Chongqing: - case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Sector12: - case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].NewTokyo: - case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Ishima: - case __WEBPACK_IMPORTED_MODULE_11__Location_js__["a" /* Locations */].Volhaven: - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(200000); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].city = cityname; - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); - workerScript.scriptRef.log("Traveled to " + cityname); - return true; - default: - workerScript.scriptRef.log("ERROR: Invalid city name passed into travelToCity()."); - return false; - } - }, - - purchaseTor() { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 1)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run purchaseTor(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); - return false; - } - } - - if (__WEBPACK_IMPORTED_MODULE_17__SpecialServerIps_js__["a" /* SpecialServerIps */]["Darkweb Server"] != null) { - workerScript.scriptRef.log("You already have a TOR router! purchaseTor() failed"); - return false; - } - - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.lt(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].TorRouterCost)) { - workerScript.scriptRef.log("ERROR: You cannot afford to purchase a Tor router. purchaseTor() failed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].TorRouterCost); - - var darkweb = new __WEBPACK_IMPORTED_MODULE_15__Server_js__["d" /* Server */](Object(__WEBPACK_IMPORTED_MODULE_27__utils_IPAddress_js__["a" /* createRandomIp */])(), "darkweb", "", false, false, false, 1); - Object(__WEBPACK_IMPORTED_MODULE_15__Server_js__["a" /* AddToAllServers */])(darkweb); - __WEBPACK_IMPORTED_MODULE_17__SpecialServerIps_js__["a" /* SpecialServerIps */].addIp("Darkweb Server", darkweb.ip); - - document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button-inactive"); - - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().serversOnNetwork.push(darkweb.ip); - darkweb.serversOnNetwork.push(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().ip); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); - workerScript.scriptRef.log("You have purchased a Tor router!"); - return true; - }, - purchaseProgram(programName) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 1)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run purchaseProgram(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); - return false; - } - } - - if (__WEBPACK_IMPORTED_MODULE_17__SpecialServerIps_js__["a" /* SpecialServerIps */]["Darkweb Server"] == null) { - workerScript.scriptRef.log("ERROR: You do not have TOR router. purchaseProgram() failed."); - return false; - } - - switch(programName.toLowerCase()) { - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram.toLowerCase(): - var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].BruteSSHProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram); - workerScript.scriptRef.log("You have purchased the BruteSSH.exe program. The new program " + - "can be found on your home computer."); - } else { - workerScript.scriptRef.log("Not enough money to purchase " + programName); - return false; - } - return true; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram.toLowerCase(): - var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].FTPCrackProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram); - workerScript.scriptRef.log("You have purchased the FTPCrack.exe program. The new program " + - "can be found on your home computer."); - } else { - workerScript.scriptRef.log("Not enough money to purchase " + programName); - return false; - } - return true; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram.toLowerCase(): - var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].RelaySMTPProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram); - workerScript.scriptRef.log("You have purchased the relaySMTP.exe program. The new program " + - "can be found on your home computer."); - } else { - workerScript.scriptRef.log("Not enough money to purchase " + programName); - return false; - } - return true; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram.toLowerCase(): - var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].HTTPWormProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram); - workerScript.scriptRef.log("You have purchased the HTTPWorm.exe program. The new program " + - "can be found on your home computer."); - } else { - workerScript.scriptRef.log("Not enough money to purchase " + programName); - return false; - } - return true; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram.toLowerCase(): - var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].SQLInjectProgram); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram); - workerScript.scriptRef.log("You have purchased the SQLInject.exe program. The new program " + - "can be found on your home computer."); - } else { - workerScript.scriptRef.log("Not enough money to purchase " + programName); - return false; - } - return true; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV1.toLowerCase(): - var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].DeepScanV1Program); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV1); - workerScript.scriptRef.log("You have purchased the DeepscanV1.exe program. The new program " + - "can be found on your home computer."); - } else { - workerScript.scriptRef.log("Not enough money to purchase " + programName); - return false; - } - return true; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV2.toLowerCase(): - var price = Object(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["d" /* parseDarkwebItemPrice */])(__WEBPACK_IMPORTED_MODULE_7__DarkWeb_js__["a" /* DarkWebItems */].DeepScanV2Program); - if (price > 0 && __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.gt(price)) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(price); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().programs.push(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV2); - workerScript.scriptRef.log("You have purchased the DeepscanV2.exe program. The new program " + - "can be found on your home computer."); - } else { - workerScript.scriptRef.log("Not enough money to purchase " + programName); - return false; - } - return true; - default: - workerScript.scriptRef.log("ERROR: Invalid program passed into purchaseProgram()."); - return false; - } - return true; - }, - getStats : function() { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 1)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getStats(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); - return {}; - } - } - - return { - hacking: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill, - strength: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].strength, - defense: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].defense, - dexterity: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].dexterity, - agility: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].agility, - charisma: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].charisma, - intelligence: __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].intelligence - } - }, - isBusy : function() { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 1)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run isBusy(). It is a Singularity Function and requires SourceFile-4 (level 1) to run."); - return; - } - } - return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking; - }, - upgradeHomeRam() { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run upgradeHomeRam(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); - return false; - } - } - - //Calculate how many times ram has been upgraded (doubled) - var currentRam = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().maxRam; - var numUpgrades = Math.log2(currentRam); - - //Calculate cost - //Have cost increase by some percentage each time RAM has been upgraded - var cost = currentRam * __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].BaseCostFor1GBOfRamHome; - var mult = Math.pow(1.55, numUpgrades); - cost = cost * mult; - - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].money.lt(cost)) { - workerScript.scriptRef.log("ERROR: upgradeHomeRam() failed because you don't have enough money"); - return false; - } - - var homeComputer = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer(); - homeComputer.maxRam *= 2; - - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].loseMoney(cost); - - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); - workerScript.scriptRef.log("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM."); - return true; - }, - getUpgradeHomeRamCost() { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getUpgradeHomeRamCost(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); - return false; - } - } - - //Calculate how many times ram has been upgraded (doubled) - var currentRam = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].getHomeComputer().maxRam; - var numUpgrades = Math.log2(currentRam); - - //Calculate cost - //Have cost increase by some percentage each time RAM has been upgraded - var cost = currentRam * __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].BaseCostFor1GBOfRamHome; - var mult = Math.pow(1.55, numUpgrades); - return cost * mult; - }, - workForCompany() { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run workForCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); - return false; - } - } - - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition == "" || !(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition instanceof __WEBPACK_IMPORTED_MODULE_4__Company_js__["c" /* CompanyPosition */])) { - workerScript.scriptRef.log("ERROR: workForCompany() failed because you do not have a job"); - return false; - } - - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { - var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); - workerScript.scriptRef.log(txt); - } - - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition.isPartTimeJob()) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startWorkPartTime(); - } else { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startWork(); - } - workerScript.scriptRef.log("Began working at " + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyName + " as a " + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition.positionName); - return true; - }, - applyToCompany(companyName, field) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run applyToCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); - return false; - } - } - - if (!Object(__WEBPACK_IMPORTED_MODULE_4__Company_js__["e" /* companyExists */])(companyName)) { - workerScript.scriptRef.log("ERROR: applyToCompany() failed because specified company " + companyName + " does not exist."); - return false; - } - - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].location = companyName; - var res; - switch (field.toLowerCase()) { - case "software": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForSoftwareJob(true); - break; - case "software consultant": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForSoftwareConsultantJob(true); - break; - case "it": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForItJob(true); - break; - case "security engineer": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForSecurityEngineerJob(true); - break; - case "network engineer": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForNetworkEngineerJob(true); - break; - case "business": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForBusinessJob(true); - break; - case "business consultant": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForBusinessConsultantJob(true); - break; - case "security": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForSecurityJob(true); - break; - case "agent": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForAgentJob(true); - break; - case "employee": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForEmployeeJob(true); - break; - case "part-time employee": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForPartTimeEmployeeJob(true); - break; - case "waiter": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForWaiterJob(true); - break; - case "part-time waiter": - res = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].applyForPartTimeWaiterJob(true); - break; - default: - workerScript.scriptRef.log("ERROR: Invalid job passed into applyToCompany: " + field + ". applyToCompany() failed"); - return false; - } - //The Player object's applyForJob function can return string with special error messages - if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["f" /* isString */])(res)) { - workerScript.scriptRef.log(res); - return false; - } - if (res) { - workerScript.scriptRef.log("You were offered a new job at " + companyName + " as a " + __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].companyPosition.positionName); - } else { - workerScript.scriptRef.log("You failed to get a new job/promotion at " + companyName + " in the " + field + " field."); - } - return res; - }, - getCompanyRep(companyName) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getCompanyRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); - return false; - } - } - - var company = __WEBPACK_IMPORTED_MODULE_4__Company_js__["a" /* Companies */][companyName]; - if (company === null || !(company instanceof __WEBPACK_IMPORTED_MODULE_4__Company_js__["b" /* Company */])) { - workerScript.scriptRef.log("ERROR: Invalid companyName passed into getCompanyRep(): " + companyName); - return -1; - } - return company.playerReputation; - }, - checkFactionInvitations() { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run checkFactionInvitations(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); - return false; - } - } - //Make a copy of Player.factionInvitations - return __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factionInvitations.slice(); - }, - joinFaction(name) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run joinFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); - return false; - } - } - - if (!Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["d" /* factionExists */])(name)) { - workerScript.scriptRef.log("ERROR: Faction specified in joinFaction() does not exist."); - return false; - } - - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factionInvitations.includes(name)) { - workerScript.scriptRef.log("ERROR: Cannot join " + name + " Faction because you have not been invited. joinFaction() failed"); - return false; - } - - var index = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factionInvitations.indexOf(name); - if (index === -1) { - //Redundant and should never happen... - workerScript.scriptRef.log("ERROR: Cannot join " + name + " Faction because you have not been invited. joinFaction() failed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factionInvitations.splice(index, 1); - var fac = __WEBPACK_IMPORTED_MODULE_9__Faction_js__["b" /* Factions */][name]; - Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["h" /* joinFaction */])(fac); - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); - workerScript.scriptRef.log("Joined the " + name + " faction."); - return true; - }, - workForFaction(name, type) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run workForFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); - return false; - } - } - - if (!Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["d" /* factionExists */])(name)) { - workerScript.scriptRef.log("ERROR: Faction specified in workForFaction() does not exist."); - return false; - } - - if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].factions.includes(name)) { - workerScript.scriptRef.log("ERROR: workForFaction() failed because you are not a member of " + name); - return false; - } - - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { - var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); - workerScript.scriptRef.log(txt); - } - - var fac = __WEBPACK_IMPORTED_MODULE_9__Faction_js__["b" /* Factions */][name]; - //Arrays listing factions that allow each time of work - var hackAvailable = ["Illuminati", "Daedalus", "The Covenant", "ECorp", "MegaCorp", - "Bachman & Associates", "Blade Industries", "NWO", "Clarke Incorporated", - "OmniTek Incorporated", "Four Sigma", "KuaiGong International", - "Fulcrum Secret Technologies", "BitRunners", "The Black Hand", - "NiteSec", "Chongqing", "Sector-12", "New Tokyo", "Aevum", - "Ishima", "Volhaven", "Speakers for the Dead", "The Dark Army", - "The Syndicate", "Silhouette", "Netburners", "Tian Di Hui", "CyberSec"]; - var fdWkAvailable = ["Illuminati", "Daedalus", "The Covenant", "ECorp", "MegaCorp", - "Bachman & Associates", "Blade Industries", "NWO", "Clarke Incorporated", - "OmniTek Incorporated", "Four Sigma", "KuaiGong International", - "The Black Hand", "Chongqing", "Sector-12", "New Tokyo", "Aevum", - "Ishima", "Volhaven", "Speakers for the Dead", "The Dark Army", - "The Syndicate", "Silhouette", "Tetrads", "Slum Snakes"]; - var scWkAvailable = ["ECorp", "MegaCorp", - "Bachman & Associates", "Blade Industries", "NWO", "Clarke Incorporated", - "OmniTek Incorporated", "Four Sigma", "KuaiGong International", - "Fulcrum Secret Technologies", "Chongqing", "Sector-12", "New Tokyo", "Aevum", - "Ishima", "Volhaven", "Speakers for the Dead", - "The Syndicate", "Tetrads", "Slum Snakes", "Tian Di Hui"]; - - switch (type.toLowerCase()) { - case "hacking": - case "hacking contracts": - case "hackingcontracts": - if (!hackAvailable.includes(fac.name)) { - workerScript.scriptRef.log("ERROR: Cannot carry out hacking contracts for " + fac.name + ". workForFaction() failed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startFactionHackWork(fac); - workerScript.scriptRef.log("Started carrying out hacking contracts for " + fac.name); - return true; - case "field": - case "fieldwork": - case "field work": - if (!fdWkAvailable.includes(fac.name)) { - workerScript.scriptRef.log("ERROR: Cannot carry out field missions for " + fac.name + ". workForFaction() failed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startFactionFieldWork(fac); - workerScript.scriptRef.log("Started carrying out field missions for " + fac.name); - return true; - case "security": - case "securitywork": - case "security work": - if (!scWkAvailable.includes(fac.name)) { - workerScript.scriptRef.log("ERROR: Cannot serve as security detail for " + fac.name + ". workForFaction() failed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startFactionSecurityWork(fac); - workerScript.scriptRef.log("Started serving as security details for " + fac.name); - return true; - default: - workerScript.scriptRef.log("ERROR: Invalid work type passed into workForFaction(): " + type); - } - return true; - }, - getFactionRep(name) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 2)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getFactionRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run."); - return -1; - } - } - - if (!Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["d" /* factionExists */])(name)) { - workerScript.scriptRef.log("ERROR: Faction specified in getFactionRep() does not exist."); - return -1; - } - - return __WEBPACK_IMPORTED_MODULE_9__Faction_js__["b" /* Factions */][name].playerReputation; - }, - createProgram(name) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run createProgram(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); - return false; - } - } - - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { - var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); - workerScript.scriptRef.log(txt); - } - - switch(name.toLowerCase()) { - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].NukeProgram.toLowerCase(): - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].NukeProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerFiveMinutes, 1); - break; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 50) { - workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create BruteSSH (level 50 req)"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].BruteSSHProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerFiveMinutes * 2, 50); - break; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 100) { - workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create FTPCrack (level 100 req)"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].FTPCrackProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerHalfHour, 100); - break; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 250) { - workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create relaySMTP (level 250 req)"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].RelaySMTPProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer2Hours, 250); - break; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 500) { - workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create HTTPWorm (level 500 req)"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].HTTPWormProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer4Hours, 500); - break; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 750) { - workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create SQLInject (level 750 req)"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].SQLInjectProgram, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer8Hours, 750); - break; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV1.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 75) { - workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV1 (level 75 req)"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV1, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerQuarterHour, 75); - break; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV2.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 400) { - workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV2 (level 400 req)"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].DeepscanV2, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPer2Hours, 400); - break; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].ServerProfiler.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 75) { - workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create ServerProfiler (level 75 req)"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].ServerProfiler, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerHalfHour, 75); - break; - case __WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].AutoLink.toLowerCase(): - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hacking_skill < 25) { - workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create AutoLink (level 25 req)"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].startCreateProgramWork(__WEBPACK_IMPORTED_MODULE_6__CreateProgram_js__["a" /* Programs */].AutoLink, __WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].MillisecondsPerQuarterHour, 25); - break; - default: - workerScript.scriptRef.log("ERROR: createProgram() failed because the specified program does not exist: " + name); - return false; - } - workerScript.scriptRef.log("Began creating program: " + name); - return true; - }, - commitCrime(crime) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run commitCrime(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); - return; - } - } - - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].isWorking) { - var txt = __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].singularityStopWork(); - workerScript.scriptRef.log(txt); - } - - crime = crime.toLowerCase(); - if (crime.includes("shoplift")) { - workerScript.scriptRef.log("Attempting to shoplift..."); - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["k" /* commitShopliftCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); - } else if (crime.includes("rob") && crime.includes("store")) { - workerScript.scriptRef.log("Attempting to rob a store..."); - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["j" /* commitRobStoreCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); - } else if (crime.includes("mug")) { - workerScript.scriptRef.log("Attempting to mug someone..."); - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["i" /* commitMugCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); - } else if (crime.includes("larceny")) { - workerScript.scriptRef.log("Attempting to commit larceny..."); - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["h" /* commitLarcenyCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); - } else if (crime.includes("drugs")) { - workerScript.scriptRef.log("Attempting to deal drugs..."); - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["c" /* commitDealDrugsCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); - } else if (crime.includes("bond") && crime.includes("forge")) { - workerScript.scriptRef.log("Attempting to forge corporate bonds..."); - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["b" /* commitBondForgeryCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); - } else if (crime.includes("traffick") && crime.includes("arms")) { - workerScript.scriptRef.log("Attempting to traffick illegal arms..."); - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["l" /* commitTraffickArmsCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); - } else if (crime.includes("homicide")) { - workerScript.scriptRef.log("Attempting to commit homicide..."); - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["f" /* commitHomicideCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); - } else if (crime.includes("grand") && crime.includes("auto")) { - workerScript.scriptRef.log("Attempting to commit grand theft auto..."); - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["d" /* commitGrandTheftAutoCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); - } else if (crime.includes("kidnap")) { - workerScript.scriptRef.log("Attempting to kidnap and ransom a high-profile target..."); - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["g" /* commitKidnapCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); - } else if (crime.includes("assassinate")) { - workerScript.scriptRef.log("Attempting to assassinate a high-profile target..."); - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["a" /* commitAssassinationCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}) - } else if (crime.includes("heist")) { - workerScript.scriptRef.log("Attempting to pull off a heist..."); - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["e" /* commitHeistCrime */])(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].CrimeSingFnDivider, {workerscript: workerScript}); - } else { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid crime passed into commitCrime(): " + crime); - } - }, - getCrimeChance(crime) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getCrimeChance(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); - return; - } - } - - crime = crime.toLowerCase(); - if (crime.includes("shoplift")) { - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["w" /* determineCrimeChanceShoplift */])(); - } else if (crime.includes("rob") && crime.includes("store")) { - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["v" /* determineCrimeChanceRobStore */])(); - } else if (crime.includes("mug")) { - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["u" /* determineCrimeChanceMug */])(); - } else if (crime.includes("larceny")) { - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["t" /* determineCrimeChanceLarceny */])(); - } else if (crime.includes("drugs")) { - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["o" /* determineCrimeChanceDealDrugs */])(); - } else if (crime.includes("bond") && crime.includes("forge")) { - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["n" /* determineCrimeChanceBondForgery */])(); - } else if (crime.includes("traffick") && crime.includes("arms")) { - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["x" /* determineCrimeChanceTraffickArms */])(); - } else if (crime.includes("homicide")) { - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["r" /* determineCrimeChanceHomicide */])(); - } else if (crime.includes("grand") && crime.includes("auto")) { - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["p" /* determineCrimeChanceGrandTheftAuto */])(); - } else if (crime.includes("kidnap")) { - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["s" /* determineCrimeChanceKidnap */])(); - } else if (crime.includes("assassinate")) { - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["m" /* determineCrimeChanceAssassination */])(); - } else if (crime.includes("heist")) { - return Object(__WEBPACK_IMPORTED_MODULE_3__Crimes_js__["q" /* determineCrimeChanceHeist */])(); - } else { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid crime passed into getCrimeChance(): " + crime); - } - }, - getOwnedAugmentations(purchased=false) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getOwnedAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); - return []; - } - } - var res = []; - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].augmentations.length; ++i) { - res.push(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].augmentations[i].name); - } - if (purchased) { - for (var i = 0; i < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations.length; ++i) { - res.push(__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations[i].name); - } - } - return res; - }, - getAugmentationsFromFaction(facname) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getAugmentationsFromFaction(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); - return []; - } - } - - if (!Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["d" /* factionExists */])(facname)) { - workerScript.scriptRef.log("ERROR: getAugmentationsFromFaction() failed. Invalid faction name passed in (this is case-sensitive): " + facname); - return []; - } - - var fac = __WEBPACK_IMPORTED_MODULE_9__Faction_js__["b" /* Factions */][facname]; - var res = []; - for (var i = 0; i < fac.augmentations.length; ++i) { - res.push(fac.augmentations[i]); - } - return res; - }, - getAugmentationCost(name) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run getAugmentationCost(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); - return false; - } - } - - if (!Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["f" /* augmentationExists */])(name)) { - workerScript.scriptRef.log("ERROR: getAugmentationCost() failed. Invalid Augmentation name passed in (note: this is case-sensitive): " + name); - return [-1, -1]; - } - - var aug = __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */][name]; - return [aug.baseRepRequirement, aug.baseCost]; - }, - purchaseAugmentation(faction, name) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run purchaseAugmentation(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); - return false; - } - } - - var fac = __WEBPACK_IMPORTED_MODULE_9__Faction_js__["b" /* Factions */][faction]; - if (fac === null || !(fac instanceof __WEBPACK_IMPORTED_MODULE_9__Faction_js__["a" /* Faction */])) { - workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because of invalid faction name: " + faction); - return false; - } - - if (!fac.augmentations.includes(name)) { - workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because the faction " + faction + " does not contain the " + name + " augmentation"); - return false; - } - - var aug = __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["c" /* Augmentations */][name]; - if (aug === null || !(aug instanceof __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["a" /* Augmentation */])) { - workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because of invalid augmentation name: " + name); - return false; - } - - var isNeuroflux = false; - if (aug.name === __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["b" /* AugmentationNames */].NeuroFluxGovernor) { - isNeuroflux = true; - } - - if (!isNeuroflux) { - for (var j = 0; j < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations.length; ++j) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations[j].name === aug.name) { - workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name); - return false; - } - } - for (var j = 0; j < __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].augmentations.length; ++j) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].augmentations[j].name === aug.name) { - workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name); - return false; - } - } - } - - if (fac.playerReputation < aug.baseRepRequirement) { - workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you do not have enough reputation with " + fac.name); - return false; - } - - var res = Object(__WEBPACK_IMPORTED_MODULE_9__Faction_js__["k" /* purchaseAugmentation */])(aug, fac, true); - workerScript.scriptRef.log(res); - if (Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["f" /* isString */])(res) && res.startsWith("You purchased")) { - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); - return true; - } else { - return false; - } - }, - installAugmentations(cbScript) { - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN != 4) { - if (!(hasSingularitySF && singularitySFLvl >= 3)) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Cannot run installAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run."); - return false; - } - } - - if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].queuedAugmentations.length === 0) { - workerScript.scriptRef.log("ERROR: installAugmentations() failed because you do not have any Augmentations to be installed"); - return false; - } - __WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].gainIntelligenceExp(__WEBPACK_IMPORTED_MODULE_5__Constants_js__["a" /* CONSTANTS */].IntelligenceSingFnBaseExpGain); - workerScript.scriptRef.log("Installing Augmentations. This will cause this script to be killed"); - Object(__WEBPACK_IMPORTED_MODULE_1__Augmentations_js__["h" /* installAugmentations */])(cbScript); - return true; - } - } -} - - - - -/***/ }), -/* 23 */ -/***/ (function(module, __webpack_exports__, __webpack_require__) { - -"use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return yesNoBoxCreate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return yesNoTxtInpBoxCreate; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return yesNoBoxGetYesButton; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return yesNoBoxGetNoButton; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return yesNoTxtInpBoxGetYesButton; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return yesNoTxtInpBoxGetNoButton; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return yesNoTxtInpBoxGetInput; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return yesNoBoxClose; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return yesNoTxtInpBoxClose; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return yesNoBoxOpen; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__ = __webpack_require__(2); - -/* Generic Yes-No Pop-up box - * Can be used to create pop-up boxes that require a yes/no response from player - */ -var yesNoBoxOpen = false; -function yesNoBoxClose() { - var container = document.getElementById("yes-no-box-container"); - if (container) { - container.style.display = "none"; - } else { - console.log("ERROR: Container not found for YesNoBox"); - } - yesNoBoxOpen = false; -} - -function yesNoBoxGetYesButton() { - return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-box-yes"); -} - -function yesNoBoxGetNoButton() { - return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-box-no"); -} - -function yesNoBoxCreate(txt) { - yesNoBoxOpen = true; - var textElement = document.getElementById("yes-no-box-text"); - if (textElement) { - textElement.innerHTML = txt; - } - - var c = document.getElementById("yes-no-box-container"); - if (c) { - c.style.display = "block"; - } else { - console.log("ERROR: Container not found for YesNoBox"); - } -} - -/* Generic Yes-No POp-up Box with Text input */ -function yesNoTxtInpBoxClose() { - var c = document.getElementById("yes-no-text-input-box-container"); - if (c) { - c.style.display = "none"; - } else { - console.log("ERROR: Container not found for YesNoTextInputBox"); - } - yesNoBoxOpen = false; -} - -function yesNoTxtInpBoxGetYesButton() { - return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-text-input-box-yes"); -} - -function yesNoTxtInpBoxGetNoButton() { - return Object(__WEBPACK_IMPORTED_MODULE_0__HelperFunctions_js__["b" /* clearEventListeners */])("yes-no-text-input-box-no"); -} - -function yesNoTxtInpBoxGetInput() { - var val = document.getElementById("yes-no-text-input-box-input").value; - val = val.replace(/\s+/g, ''); - return val; -} - -function yesNoTxtInpBoxCreate(txt) { - yesNoBoxOpen = true; - var txtE = document.getElementById("yes-no-text-input-box-text"); - if (txtE) { - txtE.innerHTML = txt; - } - - var c = document.getElementById("yes-no-text-input-box-container"); - if (c) { - c.style.display = "block"; - } else { - console.log("ERROR: Container not found for YesNoTextInputBox"); - } -} - - - - /***/ }), /* 24 */ /***/ (function(module, __webpack_exports__, __webpack_require__) { @@ -28724,7 +28754,7 @@ function yesNoTxtInpBoxCreate(txt) { /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return loadMessages; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return initMessages; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Message; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Augmentations_js__ = __webpack_require__(20); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__CreateProgram_js__ = __webpack_require__(15); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Missions_js__ = __webpack_require__(32); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Player_js__ = __webpack_require__(0); @@ -34742,17 +34772,24 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/*! decimal.js v7.2.3 https://github.com/MikeM /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return updateStockPlayerPosition; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return loadStockMarket; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return setStockMarketContentCreated; }); +/* unused harmony export placeOrder */ +/* unused harmony export Order */ +/* unused harmony export OrderTypes */ /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Location_js__ = __webpack_require__(13); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptWorker_js__ = __webpack_require__(11); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Player_js__ = __webpack_require__(0); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__ = __webpack_require__(1); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_JSONReviver_js__ = __webpack_require__(8); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_numeral_min_js__ = __webpack_require__(18); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8__utils_numeral_min_js__); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__ = __webpack_require__(11); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Player_js__ = __webpack_require__(0); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__ = __webpack_require__(1); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__ = __webpack_require__(2); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__ = __webpack_require__(8); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js__ = __webpack_require__(18); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js__); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__ = __webpack_require__(4); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__ = __webpack_require__(22); + + @@ -34781,18 +34818,104 @@ function Stock(name, symbol, mv, b, otlkMag, initPrice=10000) { } Stock.prototype.toJSON = function() { - return Object(__WEBPACK_IMPORTED_MODULE_7__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Stock", this); + return Object(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Stock", this); } Stock.fromJSON = function(value) { - return Object(__WEBPACK_IMPORTED_MODULE_7__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Stock, value.data); + return Object(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Stock, value.data); } -__WEBPACK_IMPORTED_MODULE_7__utils_JSONReviver_js__["c" /* Reviver */].constructors.Stock = Stock; +__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["c" /* Reviver */].constructors.Stock = Stock; -//Order types (long and short for each): -// - Limit Order -// - Stop Order +var OrderTypes = { + LimitBuy: "Limit Buy Order", + LimitSell: "Limit Sell Order", + StopBuy: "Stop Buy Order", + StopSell: "Stop Sell Order" +} + +var PositionTypes = { + Long: "L", + Short: "S" +} + +function placeOrder(stock, shares, price, type, position, workerScript=null) { + var tixApi = (workerScript instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]); + var order = new Order(stock, shares, price, type, position); + if (isNaN(shares)) { + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: Invalid number of shares specifies for order"); + return false; + } + if (StockMarket["Orders"] === null) { + var orders = {}; + for (var name in StockMarket) { + if (StockMarket.hasOwnProperty(name)) { + var stock = StockMarket[name]; + if (!(stock instanceof Stock)) {continue;} + orders[stock.symbol] = []; + } + } + StockMarket["Orders"] = orders; + } + StockMarket["Orders"].push(order); + //Process to see if it should be executed immediately + processOrders(order.stock, order.type, order.pos); + return true; +} + +function executeOrder(order) { + var stock = order.stock; + var orderBook = StockMarket["Orders"]; + var stockOrders = orderBook[stock.symbol]; + var res = true; + switch (order.type) { + case OrderTypes.LimitBuy: + case OrderTypes.StopBuy: + if (order.pos === PositionTypes.Long) { + res = buyStock(order.stock, order.shares) && res; + } else if (order.pos === PositionTypes.Short) { + res = shortStock(oder.stock, order.shares) && res; + } + break; + case OrderTypes.LimitSell: + case OrderTypes.StopSell: + if (order.pos === PositionTypes.Long) { + res = sellStock(order.stock, order.shares) && res; + } else if (order.pos === PositionTypes.Short) { + res = sellShort(order.stock, order.shares) && res; + } + break; + } + if (res) { + //Remove order from order book + for (var i = 0; i < stockOrders.length; ++i) { + if (order == stockOrders[i]) { + stockOrders.splice(i, 1); + return; + } + } + console.log("ERROR: Could not find the following Order in Order Book: "); + console.log(order); + } +} + +function Order(stock, price, type, position) { + this.stock = stock; + this.shares = shares; + this.price = price; + this.type = type; + this.pos = position; +} + +Order.prototype.toJSON = function() { + return Object(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["b" /* Generic_toJSON */])("Order", this); +} + +Order.fromJSON = function(value) { + return Object(__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["a" /* Generic_fromJSON */])(Order, value.data); +} + +__WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["c" /* Reviver */].constructors.Order = Order; let StockMarket = {} //Full name to stock object let StockSymbols = {} //Full name to symbol @@ -34802,7 +34925,7 @@ function loadStockMarket(saveString) { if (saveString === "") { StockMarket = {}; } else { - StockMarket = JSON.parse(saveString, __WEBPACK_IMPORTED_MODULE_7__utils_JSONReviver_js__["c" /* Reviver */]); + StockMarket = JSON.parse(saveString, __WEBPACK_IMPORTED_MODULE_8__utils_JSONReviver_js__["c" /* Reviver */]); } } @@ -34853,136 +34976,146 @@ function initStockMarket() { } var ecorp = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumECorp; - var ecorpStk = new Stock(ecorp, StockSymbols[ecorp], 0.5, true, 16, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(20000, 25000)); + var ecorpStk = new Stock(ecorp, StockSymbols[ecorp], 0.5, true, 16, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(20000, 25000)); StockMarket[ecorp] = ecorpStk; var megacorp = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12MegaCorp; - var megacorpStk = new Stock(megacorp, StockSymbols[megacorp], 0.5, true, 16, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(25000, 33000)); + var megacorpStk = new Stock(megacorp, StockSymbols[megacorp], 0.5, true, 16, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(25000, 33000)); StockMarket[megacorp] = megacorpStk; var blade = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12BladeIndustries; - var bladeStk = new Stock(blade, StockSymbols[blade], 0.75, true, 13, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(15000, 22000)); + var bladeStk = new Stock(blade, StockSymbols[blade], 0.75, true, 13, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(15000, 22000)); StockMarket[blade] = bladeStk; var clarke = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumClarkeIncorporated; - var clarkeStk = new Stock(clarke, StockSymbols[clarke], 0.7, true, 12, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(15000, 20000)); + var clarkeStk = new Stock(clarke, StockSymbols[clarke], 0.7, true, 12, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(15000, 20000)); StockMarket[clarke] = clarkeStk; var omnitek = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenOmniTekIncorporated; - var omnitekStk = new Stock(omnitek, StockSymbols[omnitek], 0.65, true, 12, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(35000, 40000)); + var omnitekStk = new Stock(omnitek, StockSymbols[omnitek], 0.65, true, 12, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(35000, 40000)); StockMarket[omnitek] = omnitekStk; var foursigma = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12FourSigma; - var foursigmaStk = new Stock(foursigma, StockSymbols[foursigma], 1.1, true, 18, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(60000, 70000)); + var foursigmaStk = new Stock(foursigma, StockSymbols[foursigma], 1.1, true, 18, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(60000, 70000)); StockMarket[foursigma] = foursigmaStk; var kuaigong = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].ChongqingKuaiGongInternational; - var kuaigongStk = new Stock(kuaigong, StockSymbols[kuaigong], 0.8, true, 10, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(20000, 24000)); + var kuaigongStk = new Stock(kuaigong, StockSymbols[kuaigong], 0.8, true, 10, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(20000, 24000)); StockMarket[kuaigong] = kuaigongStk; var fulcrum = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumFulcrumTechnologies; - var fulcrumStk = new Stock(fulcrum, StockSymbols[fulcrum], 1.25, true, 17, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(30000, 35000)); + var fulcrumStk = new Stock(fulcrum, StockSymbols[fulcrum], 1.25, true, 17, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(30000, 35000)); StockMarket[fulcrum] = fulcrumStk; var storm = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaStormTechnologies; - var stormStk = new Stock(storm, StockSymbols[storm], 0.85, true, 7, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(21000, 24000)); + var stormStk = new Stock(storm, StockSymbols[storm], 0.85, true, 7, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(21000, 24000)); StockMarket[storm] = stormStk; var defcomm = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoDefComm; - var defcommStk = new Stock(defcomm, StockSymbols[defcomm], 0.65, true, 10, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(10000, 15000)); + var defcommStk = new Stock(defcomm, StockSymbols[defcomm], 0.65, true, 10, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(10000, 15000)); StockMarket[defcomm] = defcommStk; var helios = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenHeliosLabs; - var heliosStk = new Stock(helios, StockSymbols[helios], 0.6, true, 9, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(12000, 16000)); + var heliosStk = new Stock(helios, StockSymbols[helios], 0.6, true, 9, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(12000, 16000)); StockMarket[helios] = heliosStk; var vitalife = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoVitaLife; - var vitalifeStk = new Stock(vitalife, StockSymbols[vitalife], 0.75, true, 7, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(10000, 12000)); + var vitalifeStk = new Stock(vitalife, StockSymbols[vitalife], 0.75, true, 7, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(10000, 12000)); StockMarket[vitalife] = vitalifeStk; var icarus = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12IcarusMicrosystems; - var icarusStk = new Stock(icarus, StockSymbols[icarus], 0.65, true, 7.5, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(16000, 20000)); + var icarusStk = new Stock(icarus, StockSymbols[icarus], 0.65, true, 7.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(16000, 20000)); StockMarket[icarus] = icarusStk; var universalenergy = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12UniversalEnergy; - var universalenergyStk = new Stock(universalenergy, StockSymbols[universalenergy], 0.55, true, 10, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(20000, 25000)); + var universalenergyStk = new Stock(universalenergy, StockSymbols[universalenergy], 0.55, true, 10, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(20000, 25000)); StockMarket[universalenergy] = universalenergyStk; var aerocorp = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumAeroCorp; - var aerocorpStk = new Stock(aerocorp, StockSymbols[aerocorp], 0.6, true, 6, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(10000, 15000)); + var aerocorpStk = new Stock(aerocorp, StockSymbols[aerocorp], 0.6, true, 6, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(10000, 15000)); StockMarket[aerocorp] = aerocorpStk; var omnia = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenOmniaCybersystems; - var omniaStk = new Stock(omnia, StockSymbols[omnia], 0.7, true, 4.5, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(9000, 12000)); + var omniaStk = new Stock(omnia, StockSymbols[omnia], 0.7, true, 4.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(9000, 12000)); StockMarket[omnia] = omniaStk; var solaris = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].ChongqingSolarisSpaceSystems; - var solarisStk = new Stock(solaris, StockSymbols[solaris], 0.75, true, 8.5, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(18000, 24000)); + var solarisStk = new Stock(solaris, StockSymbols[solaris], 0.75, true, 8.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(18000, 24000)); StockMarket[solaris] = solarisStk; var globalpharm = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].NewTokyoGlobalPharmaceuticals; - var globalpharmStk = new Stock(globalpharm, StockSymbols[globalpharm], 0.6, true, 10.5, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(18000, 24000)); + var globalpharmStk = new Stock(globalpharm, StockSymbols[globalpharm], 0.6, true, 10.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(18000, 24000)); StockMarket[globalpharm] = globalpharmStk; var nova = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaNovaMedical; - var novaStk = new Stock(nova, StockSymbols[nova], 0.75, true, 5, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(18000, 24000)); + var novaStk = new Stock(nova, StockSymbols[nova], 0.75, true, 5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(18000, 24000)); StockMarket[nova] = novaStk; var watchdog = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumWatchdogSecurity; - var watchdogStk = new Stock(watchdog, StockSymbols[watchdog], 1, true, 1.5, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(5000, 7500)); + var watchdogStk = new Stock(watchdog, StockSymbols[watchdog], 1, true, 1.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(5000, 7500)); StockMarket[watchdog] = watchdogStk; var lexocorp = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenLexoCorp; - var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 3, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(5000, 7500)); + var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 3, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(5000, 7500)); StockMarket[lexocorp] = lexocorpStk; var rho = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumRhoConstruction; - var rhoStk = new Stock(rho, StockSymbols[rho], 0.6, true, 1, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(3000, 6000)); + var rhoStk = new Stock(rho, StockSymbols[rho], 0.6, true, 1, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(3000, 6000)); StockMarket[rho] = rhoStk; var alpha = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12AlphaEnterprises; - var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.05, true, 2, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(5000, 7500)); + var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.05, true, 2, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(5000, 7500)); StockMarket[alpha] = alphaStk; var syscore = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenSysCoreSecurities; - var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.25, true, 0, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(4000, 7000)) + var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.25, true, 0, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(4000, 7000)) StockMarket[syscore] = syscoreStk; var computek = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenCompuTek; - var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 0, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(2000, 5000)); + var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 0, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(2000, 5000)); StockMarket[computek] = computekStk; var netlink = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumNetLinkTechnologies; - var netlinkStk = new Stock(netlink, StockSymbols[netlink], 1, true, 1, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(2000, 4000)); + var netlinkStk = new Stock(netlink, StockSymbols[netlink], 1, true, 1, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(2000, 4000)); StockMarket[netlink] = netlinkStk; var omega = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].IshimaOmegaSoftware; - var omegaStk = new Stock(omega, StockSymbols[omega], 1, true, 0.5, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(3000, 6000)); + var omegaStk = new Stock(omega, StockSymbols[omega], 1, true, 0.5, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(3000, 6000)); StockMarket[omega] = omegaStk; var fns = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12FoodNStuff; - var fnsStk = new Stock(fns, StockSymbols[fns], 0.75, false, 1, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(1000, 4000)); + var fnsStk = new Stock(fns, StockSymbols[fns], 0.75, false, 1, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(1000, 4000)); StockMarket[fns] = fnsStk; var sigmacosm = "Sigma Cosmetics"; - var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 0.9, true, 0, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(2000, 3000)); + var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 0.9, true, 0, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(2000, 3000)); StockMarket[sigmacosm] = sigmacosmStk; var joesguns = "Joes Guns"; - var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 1, true, 1, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(500, 1000)); + var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 1, true, 1, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(500, 1000)); StockMarket[joesguns] = joesgunsStk; var catalyst = "Catalyst Ventures"; - var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.25, true, 0, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(1000, 1500)); + var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.25, true, 0, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(1000, 1500)); StockMarket[catalyst] = catalystStk; var microdyne = "Microdyne Technologies"; - var microdyneStk = new Stock(microdyne, StockSymbols[microdyne], 0.75, true, 8, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(20000, 25000)); + var microdyneStk = new Stock(microdyne, StockSymbols[microdyne], 0.75, true, 8, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(20000, 25000)); StockMarket[microdyne] = microdyneStk; var titanlabs = "Titan Laboratories"; - var titanlabsStk = new Stock(titanlabs, StockSymbols[titanlabs], 0.6, true, 11, Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["d" /* getRandomInt */])(15000, 20000)); + var titanlabsStk = new Stock(titanlabs, StockSymbols[titanlabs], 0.6, true, 11, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(15000, 20000)); StockMarket[titanlabs] = titanlabsStk; + + var orders = {}; + for (var name in StockMarket) { + if (StockMarket.hasOwnProperty(name)) { + var stock = StockMarket[name]; + if (!(stock instanceof Stock)) {continue;} + orders[stock.symbol] = []; + } + } + StockMarket["Orders"] = orders; } function initSymbolToStockMap() { @@ -35016,28 +35149,28 @@ function stockMarketCycle() { //Returns true if successful, false otherwise function buyStock(stock, shares) { if (stock == null || shares < 0 || isNaN(shares)) { - Object(__WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Failed to buy stock. This may be a bug, contact developer"); + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Failed to buy stock. This may be a bug, contact developer"); return false; } shares = Math.round(shares); if (shares == 0) {return false;} var totalPrice = stock.price * shares; - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission)) { - Object(__WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You do not have enough money to purchase this. You need $" + - Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2).toString() + "."); + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.lt(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission)) { + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You do not have enough money to purchase this. You need $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2).toString() + "."); return false; } var origTotal = stock.playerShares * stock.playerAvgPx; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].loseMoney(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission); + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].loseMoney(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission); var newTotal = origTotal + totalPrice; stock.playerShares += shares; stock.playerAvgPx = newTotal / stock.playerShares; updateStockPlayerPosition(stock); - Object(__WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Bought " + Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + - Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. You also paid $" + - Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2) + " in commission fees."); + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Bought " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. You also paid $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2) + " in commission fees."); return true; } @@ -35045,33 +35178,33 @@ function buyStock(stock, shares) { function sellStock(stock, shares) { if (shares == 0) {return false;} if (stock == null || shares < 0 || isNaN(shares)) { - Object(__WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Failed to sell stock. This may be a bug, contact developer"); + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Failed to sell stock. This may be a bug, contact developer"); return false; } shares = Math.round(shares); if (shares > stock.playerShares) {shares = stock.playerShares;} if (shares === 0) {return false;} var gains = stock.price * shares - __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].gainMoney(gains); + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].gainMoney(gains); stock.playerShares -= shares; if (stock.playerShares == 0) { stock.playerAvgPx = 0; } updateStockPlayerPosition(stock); - Object(__WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Sold " + Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + - Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. After commissions, you gained " + - "a total of $" + Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gains, 2)); + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Sold " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. After commissions, you gained " + + "a total of $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gains, 2)); return true; } //Returns true if successful and false otherwise function shortStock(stock, shares, workerScript=null) { - var tixApi = (workerScript instanceof __WEBPACK_IMPORTED_MODULE_3__NetscriptWorker_js__["b" /* WorkerScript */]); + var tixApi = (workerScript instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]); if (stock === null || isNaN(shares) || shares < 0) { if (tixApi) { workerScript.scriptRef.log("ERROR: shortStock() failed because of invalid arguments."); } else { - Object(__WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Failed to initiate a short position in a stock. This is probably " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Failed to initiate a short position in a stock. This is probably " + "due to an invalid quantity. Otherwise, this may be a bug, so contact developer"); } return false; @@ -35080,21 +35213,21 @@ function shortStock(stock, shares, workerScript=null) { if (shares === 0) {return false;} var totalPrice = stock.price * shares; - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.lt(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission)) { + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.lt(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission)) { if (tixApi) { workerScript.scriptRef.log("ERROR: shortStock() failed because you do not have " + "money to purchase this short position. You need " + - __WEBPACK_IMPORTED_MODULE_8__utils_numeral_min_js___default()(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission).format('($0.000a)')); + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission).format('($0.000a)')); } else { - Object(__WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You do not have enough money to purchase this short position. You need $" + - Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2) + "."); + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("You do not have enough money to purchase this short position. You need $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2) + "."); } return false; } var origTotal = stock.playerShortShares * stock.playerAvgShortPx; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].loseMoney(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission); + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].loseMoney(totalPrice + __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission); var newTotal = origTotal + totalPrice; stock.playerShortShares += shares; stock.playerAvgShortPx = newTotal / stock.playerShortShares; @@ -35102,25 +35235,25 @@ function shortStock(stock, shares, workerScript=null) { updateStockPlayerPosition(stock); } if (tixApi) { - workerScript.scriptRef.log("Bought a short position of " + Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at " + - __WEBPACK_IMPORTED_MODULE_8__utils_numeral_min_js___default()(stock.price).format('($0.000a)') + " per share. Paid " + - __WEBPACK_IMPORTED_MODULE_8__utils_numeral_min_js___default()(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission).format('($0.000a)') + " in commission fees."); + workerScript.scriptRef.log("Bought a short position of " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at " + + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.price).format('($0.000a)') + " per share. Paid " + + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission).format('($0.000a)') + " in commission fees."); } else { - Object(__WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Bought a short position of " + Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + - Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. You also paid $" + - Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2) + " in commission fees."); + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Bought a short position of " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. You also paid $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2) + " in commission fees."); } return true; } //Returns true if successful and false otherwise function sellShort(stock, shares, workerScript=null) { - var tixApi = (workerScript instanceof __WEBPACK_IMPORTED_MODULE_3__NetscriptWorker_js__["b" /* WorkerScript */]); + var tixApi = (workerScript instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]); if (stock === null || isNaN(shares) || shares < 0) { if (tixApi) { workerScript.scriptRef.log("ERROR: sellShort() failed because of invalid arguments."); } else { - Object(__WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Failed to sell a short position in a stock. This is probably " + + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Failed to sell a short position in a stock. This is probably " + "due to an invalid quantity. Otherwise, this may be a bug, so contact developer"); } return false; @@ -35132,10 +35265,10 @@ function sellShort(stock, shares, workerScript=null) { var origCost = shares * stock.playerAvgShortPx; var profit = ((stock.playerAvgShortPx - stock.price) * shares) - __WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission; if (isNaN(profit)) {profit = 0;} - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].gainMoney(origCost + profit); + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].gainMoney(origCost + profit); if (tixApi) { workerScript.scriptRef.onlineMoneyMade += profit; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].scriptProdSinceLastAug += profit; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].scriptProdSinceLastAug += profit; } stock.playerShortShares -= shares; @@ -35147,12 +35280,12 @@ function sellShort(stock, shares, workerScript=null) { } if (tixApi) { workerScript.scriptRef.log("Sold your short position of " + shares + " shares of " + stock.symbol + " at " + - __WEBPACK_IMPORTED_MODULE_8__utils_numeral_min_js___default()(stock.price).format('($0.000a)') + " per share. After commissions, you gained " + - "a total of " + __WEBPACK_IMPORTED_MODULE_8__utils_numeral_min_js___default()(origCost + profit).format('($0.000a)')); + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.price).format('($0.000a)') + " per share. After commissions, you gained " + + "a total of " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(origCost + profit).format('($0.000a)')); } else { - Object(__WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Sold your short position of " + Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + - Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. After commissions, you gained " + - "a total of $" + Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(origCost + profit, 2)); + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Sold your short position of " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. After commissions, you gained " + + "a total of $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(origCost + profit, 2)); } return true; @@ -35162,6 +35295,7 @@ function updateStockPrices() { var v = Math.random(); for (var name in StockMarket) { if (StockMarket.hasOwnProperty(name)) { + if (!(stock instanceof Stock)) {continue;} var stock = StockMarket[name]; var av = (v * stock.mv) / 100; if (isNaN(av)) {av = .02;} @@ -35178,11 +35312,19 @@ function updateStockPrices() { var c = Math.random(); if (c < chc) { stock.price *= (1 + av); + processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Short); + processOrders(stock, OrderTypes.LimitSell, PositionTypes.Long); + processOrders(stock, OrderTypes.StopBuy, PositionTypes.Long); + processOrders(stock, OrderTypes.StopSell, PositionTypes.Short); if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.StockMarket) { updateStockTicker(stock, true); } } else { stock.price /= (1 + av); + processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Long); + processOrders(stock, OrderTypes.LimitSell, PositionTypes.Short); + processOrders(stock, OrderTypes.StopBuy, PositionTypes.Short); + processOrders(stock, OrderTypes.StopSell, PositionTypes.Long); if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.StockMarket) { updateStockTicker(stock, false); } @@ -35201,6 +35343,68 @@ function updateStockPrices() { stock.otlkMag *= -1; stock.b = !stock.b; } + + } + } +} + +//Checks and triggers any orders for the specified stock +function processOrders(stock, orderType, posType) { + var orderBook = StockMarket["Orders"]; + if (orderBook === null) { + var orders = {}; + for (var name in StockMarket) { + if (StockMarket.hasOwnProperty(name)) { + var stock = StockMarket[name]; + if (!(stock instanceof Stock)) {continue;} + orders[stock.symbol] = []; + } + } + StockMarket["Orders"] = orders; + return; //Newly created, so no orders to process + } + var stockOrders = orderBook[stock.symbol]; + if (stockOrders === null || !(stockOrders.constructor === Array)) { + console.log("ERROR: Invalid Order book for " + stock.symbol + " in processOrders()"); + stockOrders = []; + return; + } + for (var i = 0; i < stockOrders.length; ++i) { + var order = stockOrders[i]; + if (order.type === orderType && order.pos === posType) { + switch(order.type) { + case OrderTypes.LimitBuy: + if (order.pos === PositionTypes.Long && stock.price <= order.price) { + executeOrder/*66*/(order); + } else if (order.pos === PositionTypes.Short && stock.price >= order.price) { + executeOrder/*66*/(order); + } + break; + case OrderTypes.LimitSell: + if (order.pos === PositionTypes.Long && stock.price >= order.price) { + executeOrder/*66*/(order); + } else if (order.pos === PositionTypes.Short && stock.price <= order.price) { + executeOrder/*66*/(order); + } + break; + case OrderTypes.StopBuy: + if (order.pos === PositionTypes.Long && stock.price >= order.price) { + executeOrder/*66*/(order); + } else if (order.pos === PositionTypes.Short && stock.price <= order.price) { + executeOrder/*66*/(order); + } + break; + case OrderTypes.StopSell: + if (order.pos === PositionTypes.Long && stock.price <= order.price) { + executeOrder/*66*/(order); + } else if (order.pos === PositionTypes.Short && stock.price >= order.price) { + executeOrder/*66*/(order); + } + break; + default: + console.log("Invalid order type: " + order.type); + return; + } } } } @@ -35211,38 +35415,38 @@ function setStockMarketContentCreated(b) { var stockMarketContentCreated = false; function displayStockMarketContent() { - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hasWseAccount == null) {__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hasWseAccount = false;} - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hasTixApiAccess == null) {__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hasTixApiAccess = false;} + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount == null) {__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount = false;} + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasTixApiAccess == null) {__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasTixApiAccess = false;} //Purchase WSE Account button - var wseAccountButton = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["b" /* clearEventListeners */])("stock-market-buy-account"); - wseAccountButton.innerText = "Buy WSE Account - $" + Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].WSEAccountCost, 2).toString(); - if (!__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hasWseAccount && __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.gte(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].WSEAccountCost)) { + var wseAccountButton = Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* clearEventListeners */])("stock-market-buy-account"); + wseAccountButton.innerText = "Buy WSE Account - $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].WSEAccountCost, 2).toString(); + if (!__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount && __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.gte(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].WSEAccountCost)) { wseAccountButton.setAttribute("class", "a-link-button"); } else { wseAccountButton.setAttribute("class", "a-link-button-inactive"); } wseAccountButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hasWseAccount = true; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount = true; initStockMarket(); initSymbolToStockMap(); - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].loseMoney(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].WSEAccountCost); + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].loseMoney(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].WSEAccountCost); displayStockMarketContent(); return false; }); //Purchase TIX API Access account - var tixApiAccessButton = Object(__WEBPACK_IMPORTED_MODULE_6__utils_HelperFunctions_js__["b" /* clearEventListeners */])("stock-market-buy-tix-api"); + var tixApiAccessButton = Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* clearEventListeners */])("stock-market-buy-tix-api"); tixApiAccessButton.innerText = "Buy Trade Information eXchange (TIX) API Access - $" + - Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].TIXAPICost, 2).toString(); - if (!__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hasTixApiAccess && __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].money.gte(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].TIXAPICost)) { + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].TIXAPICost, 2).toString(); + if (!__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasTixApiAccess && __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].money.gte(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].TIXAPICost)) { tixApiAccessButton.setAttribute("class", "a-link-button"); } else { tixApiAccessButton.setAttribute("class", "a-link-button-inactive"); } tixApiAccessButton.addEventListener("click", function() { - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hasTixApiAccess = true; - __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].loseMoney(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].TIXAPICost); + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasTixApiAccess = true; + __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].loseMoney(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].TIXAPICost); displayStockMarketContent(); return false; }); @@ -35250,7 +35454,7 @@ function displayStockMarketContent() { var stockList = document.getElementById("stock-market-list"); if (stockList == null) {return;} - if (!__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hasWseAccount) { + if (!__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount) { stockMarketContentCreated = false; while (stockList.firstChild) { stockList.removeChild(stockList.firstChild); @@ -35259,151 +35463,27 @@ function displayStockMarketContent() { } //Create stock market content if you have an account - if (!stockMarketContentCreated && __WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hasWseAccount) { + if (!stockMarketContentCreated && __WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount) { console.log("Creating Stock Market UI"); document.getElementById("stock-market-commission").innerHTML = "Commission Fees: Every transaction you make has a $" + - Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2) + " commission fee.

" + + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(__WEBPACK_IMPORTED_MODULE_0__Constants_js__["a" /* CONSTANTS */].StockMarketCommission, 2) + " commission fee.

" + "WARNING: When you reset after installing Augmentations, the Stock Market is reset. " + "This means all your positions are lost, so make sure to sell your stocks before installing " + "Augmentations!"; - var hdrLi = document.createElement("li"); - var hdrName = document.createElement("p"); - var hdrSym = document.createElement("p"); - var hdrPrice = document.createElement("p"); - var hdrQty = document.createElement("p"); - var hdrBuySell = document.createElement("p") - var hdrAvgPrice = document.createElement("p"); - var hdrShares = document.createElement("p"); - var hdrReturn = document.createElement("p"); - hdrName.style.display = "inline-block"; - hdrName.innerText = "Stock Name"; - hdrName.style.width = "8%"; - hdrSym.style.display = "inline-block"; - hdrSym.innerText = "Symbol"; - hdrSym.style.width = "4%"; - hdrPrice.style.display = "inline-block"; - hdrPrice.innerText = "Price"; - hdrPrice.style.width = "8%"; - hdrQty.style.display = "inline-block"; - hdrQty.innerText = "Quantity"; - hdrQty.style.width = "3%"; - hdrBuySell.style.display = "inline-block"; - hdrBuySell.innerText = "Buy/Sell"; - hdrBuySell.style.width = "5%"; - hdrAvgPrice.style.display = "inline-block"; - hdrAvgPrice.innerText = "Avg price of owned shares"; - hdrAvgPrice.style.width = "7.5%"; - hdrShares.style.display = "inline-block"; - hdrShares.innerText = "Shares owned"; - hdrShares.style.width = "4%"; - hdrReturn.style.display = "inline-block"; - hdrReturn.innerText = "Total Return"; - hdrReturn.style.width = "6%"; - hdrLi.appendChild(hdrName); - hdrLi.appendChild(hdrSym); - hdrLi.appendChild(hdrPrice); - hdrLi.appendChild(hdrQty); - hdrLi.appendChild(hdrBuySell); - hdrLi.appendChild(hdrAvgPrice); - hdrLi.appendChild(hdrShares); - hdrLi.appendChild(hdrReturn); - stockList.appendChild(hdrLi); - for (var name in StockMarket) { if (StockMarket.hasOwnProperty(name)) { - (function() { var stock = StockMarket[name]; - - var li = document.createElement("li"); - var stkName = document.createElement("p"); - var stkSym = document.createElement("p"); - var stkPrice = document.createElement("p"); - var qtyInput = document.createElement("input"); - var buyButton = document.createElement("span"); - var sellButton = document.createElement("span"); - var avgPriceTxt = document.createElement("p"); - var sharesTxt = document.createElement("p"); - var returnTxt = document.createElement("p"); - - var tickerId = "stock-market-ticker-" + stock.symbol; - stkName.setAttribute("id", tickerId + "-name"); - stkSym.setAttribute("id", tickerId + "-sym"); - stkPrice.setAttribute("id", tickerId + "-price"); - stkName.style.display = "inline-block"; - stkName.style.width = "8%"; - stkSym.style.display = "inline-block"; - stkSym.style.width = "4%"; - stkPrice.style.display = "inline-block"; - stkPrice.style.width = "9%"; - - li.setAttribute("display", "inline-block"); - - qtyInput.setAttribute("type", "text"); - qtyInput.setAttribute("id", tickerId + "-qty-input"); - qtyInput.setAttribute("class", "stock-market-qty-input"); - qtyInput.setAttribute("onkeydown", "return ( event.ctrlKey || event.altKey " + - " || (4734 && event.keyCode<40) " + - " || (event.keyCode==46) )"); - qtyInput.style.width = "3%"; - qtyInput.style.display = "inline-block"; - - buyButton.innerHTML = "Buy"; - buyButton.setAttribute("class", "stock-market-buy-sell-button"); - buyButton.style.width = "3%"; - buyButton.style.display = "inline-block"; - buyButton.addEventListener("click", function() { - var shares = document.getElementById(tickerId + "-qty-input").value; - shares = Number(shares); - if (isNaN(shares)) {return false;} - buyStock(stock, shares); - }); - sellButton.innerHTML = "Sell"; - sellButton.setAttribute("class", "stock-market-buy-sell-button"); - sellButton.style.width = "3%"; - sellButton.style.display = "inline-block"; - sellButton.addEventListener("click", function() { - var shares = document.getElementById(tickerId + "-qty-input").value; - shares = Number(shares); - if (isNaN(shares)) {return false;} - sellStock(stock, shares); - }); - - avgPriceTxt.setAttribute("id", tickerId + "-avgprice"); - avgPriceTxt.style.display = "inline-block"; - avgPriceTxt.style.width = "8%"; - avgPriceTxt.style.color = "white"; - sharesTxt.setAttribute("id", tickerId + "-shares"); - sharesTxt.style.display = "inline-block"; - sharesTxt.style.width = "4%"; - sharesTxt.style.color = "white"; - returnTxt.setAttribute("id", tickerId + "-return"); - returnTxt.style.display = "inline-block"; - returnTxt.style.width = "6%"; - returnTxt.style.color = "white"; - - li.appendChild(stkName); - li.appendChild(stkSym); - li.appendChild(stkPrice); - li.appendChild(qtyInput); - li.appendChild(buyButton); - li.appendChild(sellButton); - li.appendChild(avgPriceTxt); - li.appendChild(sharesTxt); - li.appendChild(returnTxt); - stockList.appendChild(li); - }()); //Immediate invocation - }//End if - + if (!(stock instanceof Stock)) {continue;} //orders property is an array + createStockTicker(stock); + } } + setStockTickerClickHandlers(); //Clicking headers opens/closes panels stockMarketContentCreated = true; } - if (__WEBPACK_IMPORTED_MODULE_4__Player_js__["a" /* Player */].hasWseAccount) { + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].hasWseAccount) { for (var name in StockMarket) { if (StockMarket.hasOwnProperty(name)) { var stock = StockMarket[name]; @@ -35414,55 +35494,274 @@ function displayStockMarketContent() { } } -//'increase' argument is a boolean indicating whether the price increased or decreased -function updateStockTicker(stock, increase) { - var tickerId = "stock-market-ticker-" + stock.symbol; - let stkName = document.getElementById(tickerId + "-name"); - let stkSym = document.getElementById(tickerId + "-sym"); - let stkPrice = document.getElementById(tickerId + "-price"); - - if (stkName == null || stkSym == null || stkPrice == null) { - console.log("ERROR, couldn't find elements with tickerId " + tickerId); +function createStockTicker(stock) { + if (!(stock instanceof Stock)) { + console.log("Invalid stock in createStockSticker()"); return; } - stkName.innerText = stock.name; - stkSym.innerText = stock.symbol; - stkPrice.innerText = "$" + Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2).toString(); + var tickerId = "stock-market-ticker-" + stock.symbol; + var li = document.createElement("li"), hdr = document.createElement("button"); + hdr.classList.add("accordion-header"); + hdr.setAttribute("id", tickerId + "-hdr"); + hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + stock.price; - var returnTxt = document.getElementById(tickerId + "-return"); - var totalCost = stock.playerShares * stock.playerAvgPx; - var gains = (stock.price - stock.playerAvgPx) * stock.playerShares; - var percentageGains = gains / totalCost; - if (totalCost > 0) { - returnTxt.innerText = "$" + Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gains, 2) + " (" + - Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(percentageGains * 100, 2) + "%)"; - } else { - returnTxt.innerText = "N/A"; + //Div for entire panel + var stockDiv = document.createElement("div"); + stockDiv.classList.add("accordion-panel"); + + /* Create panel DOM */ + var qtyInput = document.createElement("input"), + longShortSelect = document.createElement("select"), + orderTypeSelect = document.createElement("select"), + buyButton = document.createElement("span"), + sellButton = document.createElement("span"), + positionTxt = document.createElement("p"), + orderList = document.createElement("ul"); + + qtyInput.classList.add("stock-market-input"); + qtyInput.setAttribute("id", tickerId + "-qty-input"); + qtyInput.setAttribute("onkeydown", "return ( event.ctrlKey || event.altKey " + + " || (4734 && event.keyCode<40) " + + " || (event.keyCode==46) )"); + + longShortSelect.classList.add("stock-market-input"); + longShortSelect.setAttribute("id", tickerId + "-pos-selector"); + var longOpt = document.createElement("option"); + longOpt.text = "Long"; + longShortSelect.add(longOpt); + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].bitNodeN === 8 || (__WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["d" /* hasWallStreetSF */] && __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["f" /* wallStreetSFLvl */] >= 2)) { + var shortOpt = document.createElement("option"); + shortOpt.text = "Short"; + longShortSelect.add(shortOpt); } + orderTypeSelect.classList.add("stock-market-input"); + orderTypeSelect.setAttribute("id", tickerId + "-order-selector"); + var marketOpt = document.createElement("option"); + marketOpt.text = "Market Order"; + orderTypeSelect.add(marketOpt); + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].bitNodeN === 8 || (__WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["d" /* hasWallStreetSF */] && __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["f" /* wallStreetSFLvl */] >= 3)) { + var limitOpt = document.createElement("option"); + limitOpt.text = "Limit Order"; + orderTypeSelect.add(limitOpt); + var stopOpt = document.createElement("option"); + stopOpt.text = "Stop Order"; + orderTypeSelect.add(stopOpt); + } - if (increase) { - stkName.style.color = "#66ff33"; - stkSym.style.color = "#66ff33"; - stkPrice.style.color = "#66ff33"; - } else { - stkName.style.color = "red"; - stkSym.style.color = "red"; - stkPrice.style.color = "red"; + buyButton.classList.add("stock-market-input"); + buyButton.innerHTML = "Buy"; + buyButton.addEventListener("click", ()=>{ + var pos = longShortSelect.options[longShortSelect.selectedIndex].text; + pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short; + var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text; + var shares = Number(document.getElementById(tickerId + "-qty-input").value); + if (isNaN(shares)) {return false;} + switch (ordType) { + case "Market Order": + buyStock(stock, shares); + break; + case "Limit Order": + case "Stop Order": + var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), + noBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); + yesBtn.innerText = "Place Buy" + ordType; + noBtn.innerText = "Cancel Order"; + yesBtn.addEventListener("click", ()=>{ + var price = Number(Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])()), type; + if (ordType === "Limit Order") { + type = OrderTypes.LimitBuy; + } else { + type = OrderTypes.StopBuy; + } + placeOrder(stock, shares, price, type, pos); + }); + noBtn.addEventListener("click", ()=>{ + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); + }); + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["g" /* yesNoTxtInpBoxCreate */])("Enter the price for your " + ordType); + break; + default: + console.log("ERROR: Invalid order type"); + break; + } + return false; + }); + + sellButton.classList.add("stock-market-input"); + sellButton.innerHTML = "Sell"; + sellButton.addEventListener("click", ()=>{ + var pos = longShortSelect.options[longShortSelect.selectedIndex].text; + pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short; + var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text; + var shares = Number(document.getElementById(tickerId + "-qty-input").value); + if (isNaN(shares)) {return false;} + switch (ordType) { + case "Market Order": + buyStock(stock, shares); + break; + case "Limit Order": + case "Stop Order": + var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), + noBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); + yesBtn.innerText = "Place Sell" + ordType; + noBtn.innerText = "Cancel Order"; + yesBtn.addEventListener("click", ()=>{ + var price = Number(Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])()), type; + if (ordType === "Limit Order") { + type = OrderTypes.LimitSell; + } else { + type = OrderTypes.StopSell; + } + placeOrder(stock, shares, price, type, pos); + }); + noBtn.addEventListener("click", ()=>{ + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); + }); + break; + default: + console.log("ERROR: Invalid order type"); + break; + } + return false; + }); + + positionTxt.setAttribute("id", tickerId + "-position-text"); + positionTxt.classList.add("stock-market-position-text"); + + orderList.setAttribute("id", tickerId + "-order-list"); + orderList.classList.add("stock-market-order-list"); + + stockDiv.appendChild(qtyInput); + stockDiv.appendChild(longShortSelect); + stockDiv.appendChild(orderTypeSelect); + stockDiv.appendChild(buyButton); + stockDiv.appendChild(sellButton); + stockDiv.appendChild(positionTxt); + stockDiv.appendChild(orderList); + + li.appendChild(hdr); + li.appendChild(stockDiv); + document.getElementById("stock-market-list").appendChild(li); + + updateStockTicker(stock, true); +} + +function setStockTickerClickHandlers() { + var stockList = document.getElementById("stock-market-list"); + var tickerHdrs = stockList.getElementsByClassName("accordion-header"); + if (tickerHdrs === null) { + console.log("ERROR: Could not find header elements for stock tickers"); + return; + } + for (var i = 0; i < tickerHdrs.length; ++i) { + tickerHdrs[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"; + } + } + } +} + +//'increase' argument is a boolean indicating whether the price increased or decreased +function updateStockTicker(stock, increase) { + if (!(stock instanceof Stock)) { + console.log("Invalid stock in updateStockTicker()"); + return; + } + var tickerId = "stock-market-ticker-" + stock.symbol; + var hdr = document.getElementById(tickerId + "-hdr"); + + if (hdr === null) { + console.log("ERROR: Couldn't find ticker element for stock: " + stock.symbol); + return; + } + hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + stock.price; + increase ? hdr.style.color = "#66ff33" : hdr.style.color = "red"; + + if (stock.playerShares > 0 || stock.playerShortShares > 0) { + updateStockPlayerPosition(stock); } } function updateStockPlayerPosition(stock) { - var tickerId = "stock-market-ticker-" + stock.symbol; - var avgPriceTxt = document.getElementById(tickerId + "-avgprice"); - var sharesTxt = document.getElementById(tickerId + "-shares"); - if (avgPriceTxt == null || sharesTxt == null) { - Object(__WEBPACK_IMPORTED_MODULE_5__utils_DialogBox_js__["a" /* dialogBoxCreate */])("Could not find element for player positions for stock " + - stock.symbol + ". This is a bug please contact developer"); + if (!(stock instanceof Stock)) { + console.log("Invalid stock in updateStockTicker()"); return; } - avgPriceTxt.innerText = "$" + Object(__WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.playerAvgPx, 2); - sharesTxt.innerText = stock.playerShares.toString(); + var tickerId = "stock-market-ticker-" + stock.symbol, + positionTxt = document.getElementById(tickerId + "-position-text"); + if (positionTxt === null) { + console.log("ERROR: Could not find stock position element for: " + stock.symbol); + return; + } + + //Calculate returns + var totalCost = stock.playerShares * stock.playerAvgPx, + gains = (stock.price - stock.playerAvgPx) * stock.playerShares, + percentageGains = gains / totalCost; + + var shortTotalCost = stock.playerShortShares * stock.playerAvgShortPx, + shortGains = (stock.playerAvgShortPx - stock.price) * stock.playerShortShares, + shortPercentageGains = shortGains/ shortTotalCost; + + positionTxt.innerHTML = + "

Long Position: " + + "Shares in the long position will increase " + + "in value if the price of the corresponding stock increases

" + + "
Shares: " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.playerShares, 0) + + "
Average Price: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.playerAvgPx).format('$0.000a') + + "
Profit: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(gains).format('$0.000a') + + " (" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(percentageGains, 2) + "%)

" + + "

Short Position: " + + "Shares in short position will increase " + + "in value if the price of the corresponding stock decreases

" + + "
Shares: " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.playerShortShares, 0) + + "
Average Price: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.playerAvgShortPx).format('$0.000a') + + "
Profit: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(shortGains).format('$0.000a') + + " (" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shortPercentageGains, 2) + "%)"; +} + +function updateStockOrderList(stock) { + var tickerId = "stock-market-ticker-" + stock.symbol; + var orderList = document.getElementById(tickerId + "-order-list"); + if (orderList === null) { + console.log("ERROR: Could not find order list for " + stock.symbol); + return; + } + + var orderBook = StockMarket["Orders"]; + if (orderBook === null) { + console.log("ERROR: Could not find order book in stock market"); + return; + } + var stockOrders = orderBook[stock.symbol]; + if (stockOrders === null) { + console.log("ERROR: Could nto find orders for: " + stock.symbol); + return; + } + + //Remove everything from list + while (orderList.firstChild) { + orderList.removeChild(orderList.firstChild); + } + + for (var i = 0; i < stockOrders.length; ++i) { + var order = stockOrders[i]; + var li = document.createElement("li"); + var posText = (order.pos === PositionTypes.Long ? "Long Position" : "Short Position"); + li.innerText = order.type + " - " + posText + " - " + + order.shares + " @ $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(order.price, 2); + orderList.appendChild(li); + } } @@ -35545,7 +35844,7 @@ function logBoxUpdateText() { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Environment; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__NetscriptFunctions_js__ = __webpack_require__(22); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__NetscriptFunctions_js__ = __webpack_require__(19); /* Environment * NetScript program environment @@ -37431,7 +37730,7 @@ HackingMission.prototype.finishMission = function(win) { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_numeral_min_js__ = __webpack_require__(18); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_numeral_min_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_8__utils_numeral_min_js__); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__utils_StringHelperFunctions_js__ = __webpack_require__(4); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_YesNoBox_js__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__utils_YesNoBox_js__ = __webpack_require__(22); @@ -38561,7 +38860,7 @@ function setGangMemberClickHandlers() { //Server panel click handlers var gangMemberHdrs = document.getElementsByClassName("gang-member-header"); if (gangMemberHdrs == null) { - console.log("ERROR: Could not find Active Scripts server panels"); + console.log("ERROR: Could not find Gang Member Headers"); return; } for (let i = 0; i < gangMemberHdrs.length; ++i) { @@ -38672,7 +38971,6 @@ function createGangMemberDisplayElement(memberObj) { taskDescP.style.display = "inline"; taskDescDiv.appendChild(taskDescP); - statsDiv.style.width = "30%"; taskDiv.style.width = "30%"; taskDescDiv.style.width = "30%"; @@ -38904,21 +39202,21 @@ function applySourceFile(srcFile) { /* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return prestigeAugmentation; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return prestigeSourceFile; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__ActiveScriptsUI_js__ = __webpack_require__(25); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__ = __webpack_require__(19); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Augmentations_js__ = __webpack_require__(20); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__BitNode_js__ = __webpack_require__(7); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Company_js__ = __webpack_require__(20); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Company_js__ = __webpack_require__(21); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__CreateProgram_js__ = __webpack_require__(15); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__engine_js__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__Faction_js__ = __webpack_require__(10); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__Location_js__ = __webpack_require__(13); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__Message_js__ = __webpack_require__(24); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__NetscriptFunctions_js__ = __webpack_require__(22); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_9__NetscriptFunctions_js__ = __webpack_require__(19); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_10__NetscriptWorker_js__ = __webpack_require__(11); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_11__Player_js__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_12__Server_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_13__SpecialServerIps_js__ = __webpack_require__(12); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_14__StockMarket_js__ = __webpack_require__(28); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__Terminal_js__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_15__Terminal_js__ = __webpack_require__(23); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__utils_decimal_js__ = __webpack_require__(27); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_16__utils_decimal_js___default = __webpack_require__.n(__WEBPACK_IMPORTED_MODULE_16__utils_decimal_js__); @@ -39135,7 +39433,7 @@ function prestigeSourceFile() { __WEBPACK_IMPORTED_MODULE_5__engine_js__["Engine"].loadTerminalContent(); //Reinitialize flags in case you just finished BN-4 - Object(__WEBPACK_IMPORTED_MODULE_9__NetscriptFunctions_js__["d" /* initSingularitySFFlags */])(); + Object(__WEBPACK_IMPORTED_MODULE_9__NetscriptFunctions_js__["e" /* initSingularitySFFlags */])(); //Gain int exp __WEBPACK_IMPORTED_MODULE_11__Player_js__["a" /* Player */].gainIntelligenceExp(5); @@ -39157,10 +39455,10 @@ function prestigeSourceFile() { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Player_js__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Prestige_js__ = __webpack_require__(35); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__SourceFile_js__ = __webpack_require__(34); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Terminal_js__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__Terminal_js__ = __webpack_require__(23); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__ = __webpack_require__(2); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_YesNoBox_js__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_8__utils_YesNoBox_js__ = __webpack_require__(22); @@ -41230,7 +41528,7 @@ module.exports.src = "\"no use strict\";(function(window){function resolveModule /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return substituteAliases; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return loadAliases; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return loadGlobalAliases; }); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Terminal_js__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Terminal_js__ = __webpack_require__(23); let Aliases = {}; @@ -41360,7 +41658,7 @@ function substituteAliases(origCommand) { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__CreateProgram_js__ = __webpack_require__(15); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Player_js__ = __webpack_require__(0); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__SpecialServerIps_js__ = __webpack_require__(12); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Terminal_js__ = __webpack_require__(21); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__Terminal_js__ = __webpack_require__(23); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_IPAddress_js__ = __webpack_require__(17); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_StringHelperFunctions_js__ = __webpack_require__(4); @@ -91753,7 +92051,7 @@ acequire("../config").defineOptions(Editor.prototype, "editor", { /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Server_js__ = __webpack_require__(6); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__utils_DialogBox_js__ = __webpack_require__(1); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__utils_IPAddress_js__ = __webpack_require__(17); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_YesNoBox_js__ = __webpack_require__(23); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_5__utils_YesNoBox_js__ = __webpack_require__(22); @@ -92049,7 +92347,7 @@ let HelpTexts = { /* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return saveObject; }); /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return loadGame; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Alias_js__ = __webpack_require__(43); -/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Company_js__ = __webpack_require__(20); +/* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__Company_js__ = __webpack_require__(21); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_3__engine_js__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_4__Faction_js__ = __webpack_require__(10); diff --git a/src/CompanyManagement.js b/src/CompanyManagement.js index 2a61e5406..4017fc19b 100644 --- a/src/CompanyManagement.js +++ b/src/CompanyManagement.js @@ -1,8 +1,156 @@ -/* CompanyManagement.js */ - /* -Company made up of +Products + For certain industries, players can created their own custom products + Essentially, these are just things you give a certain name to. + Products have certain properties that affect how well they sell. These properties + are just numbers. For each Industry, only some of these properties are applicable + (e.g. Performance isnt applicable for food industry) + Demand: Determined by industry. For most industries this will slowly decrease over time, meaning + that you must create new and better products to remain successful. The speed at which this + decreases over time is dependent on industry + Competition: Determined by industry + Markup : Determined by Industry + Quality: + Performance: + Durability: + Reliability: + Aesthetics: + Features: + Location: Only valid for 'building' products like Restaurants, Hospitals, etc. + Scientific Research affects the properties of products +Materials: + To create Products, you need materials. There are different tiers of Materials + Materials have several properties that determine how profitable they can be: + Quality: + Demand: + Competition: + Markup: How much price markup a material can have before theres a significant dropoff in how much its bought + Materials Types: + 1st tier: + Water - High Stable Demand, Medium competition, low markup + Energy - Suuuuuuper high stable demand, High competition, low markup + 2nd Tier: + Food - High Stable Demand, Lots of competition, medium markup + Plants - Initially high but volatile demand. Decent competition, low markup + Metal - Very high stable demand, lots of competition, low markup + 3rd Tier: + Hardware - Very high stable demand, lots of competition, med markup + Chemicals - High stable demand, good amount of competition, med markup + Real estate - Initially high but volatile demand. Decent competition, med markup. Tied to a certain city + 4th tier: + Drugs - High stable demand, lots of competition, medium markup + Robots - Very high stable demand, looots of competition, high markup + AI Cores - Very high stable demand, looooots of competition, veeery high markup + 5th tier: + Scientific Research +Industries: + - Some Industries let you create your own custom "Products", while others just produce Materials + - Each Industry has different characteristics for things + - List of Industries: + Energy - Requires hardware, real estate + Produces Energy + Can Use Hardware/AI Cores to increase production + More real estate = more production with very little dimishing returns + Production increased by scientific research + High starting cost + Utilities - Requires hardware, Real Estate + Produces Water + Can use Hardware, Robotics, and AI Cores to increase production + More real estate = more production with medium diminishing returns + Production increased by scientific research + High starting cost + Agriculture - Requires Water and Energy + Produces food and plants + Can use Hardware/Robotics/AI Cores to increase production + Production increased by scientific research + More real estate = more production with very little diminishing returns + Medium starting cost + Fishing - Requires energy + Produces lots of food + Can use Hardware/Robotics/AI Cores to increase production + Production increased by scientific research + More real estate = slightly more production with very high diminishing returns + Medium starting cost (higher than agriculture) + Mining - Requires Energy + Produces Metal + Can use hardware/Robotics/AI Cores to increase production + Production increased by scientific research + More real estate = more production with medium diminishing returns + High starting cost + Food - Create your own "restaurant" products + Restaurants require food, water, energy, and real estate + Restaurants in general are high stable demand, but lots of competition, and medium markup + Low starting cost + Production increase from real estate diminishes greatly in city. e.g. making many restaurants + in one city has high diminishing returns, but making a few in every city is good + Tobacco - Create your own tobacco products + Requires plants, water, and real estate + High volatile demand, but not much competition. Low markup + Low starting cost + Product quality significantly affected by scientific research + Chemical - Create your own chemical products. + Requires plants, energy, water, and real estate + High stable demand, high competition, low markup + Medium starting cost + Advertising does very little + Product quality significantly affected by scientific research + Pharmaceutical - Create your own drug products + Requires chemicals, energy, water, and real estate + Very high stable demand. High competition, very high markup + High starting cost + Requires constant creation of new and better products to be successful + Product quality significantly affected by scientific research + Computer - Creates 'Hardware' material + Requires metal, energy, real estate + Can use Robotics/AI Cores to increase production + More real estate = more production with high diminishing returns + Production significantly affected by scientific research + High starting cost + Robotics - Create 'Robots' material and create your own 'Robot' products + Requires hardware, energy, and real estate + Production can be improved by using AI Cores + Extremely high stable demand, medium competition, high markup + Extremely high starting cost + Product quality significantly affected by scientific research + more real estate = more production with medium diminishing returns for 'Robot' materials + Software - Create 'AI Cores' material and create your own software products + Requires hardware, energy, real estate + Very high stable demand, high competition, low markup + Low starting cost + Product quality slightly affected by scientific research + Healthcare - Open your own hospitals (each is its own product). + Requires real estate, robots, AI Cores, energy, water + Extremely high stable demand, semi-high competition, super high markup + Extremely high starting cost + Production increase from real estate diminishes greatly in city. e.g. making many hospitals + in one city has high diminishing returns, but making a few in every city is good + Real Estate - Create 'Real Estate'. + Requires metal, energy, water, hardware + Can use Hardware/Robotics/AI Cores to increase production + Production slightly affected by scientific research + Heavily affected by advertising + Biotechnology - + Entertainment - + Finance - + Mass Media - + Telecommunications - + + Employees: + Has morale and energy that must be managed to maintain productivity + Stats: + Intelligence, Charisma, Experience, Creativity, Efficiency + + Assigned to different positions. The productivity at each position is determined by + stats. I.e. each employe should be assigned to positions based on stats to optimize production + + Position + Operations - + Engineer - + Business - + Accounting - + Management - + Research and Development - */ diff --git a/src/Gang.js b/src/Gang.js index 7d070c2e5..e1d6892f6 100644 --- a/src/Gang.js +++ b/src/Gang.js @@ -1132,7 +1132,7 @@ function setGangMemberClickHandlers() { //Server panel click handlers var gangMemberHdrs = document.getElementsByClassName("gang-member-header"); if (gangMemberHdrs == null) { - console.log("ERROR: Could not find Active Scripts server panels"); + console.log("ERROR: Could not find Gang Member Headers"); return; } for (let i = 0; i < gangMemberHdrs.length; ++i) { @@ -1243,7 +1243,6 @@ function createGangMemberDisplayElement(memberObj) { taskDescP.style.display = "inline"; taskDescDiv.appendChild(taskDescP); - statsDiv.style.width = "30%"; taskDiv.style.width = "30%"; taskDescDiv.style.width = "30%"; diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index 6d79b2b18..b6bed4b6a 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -59,8 +59,8 @@ import {printArray, powerOfTwo} from "../utils/HelperFunctio import {createRandomIp} from "../utils/IPAddress.js"; import {formatNumber, isString, isHTML} from "../utils/StringHelperFunctions.js"; -var hasSingularitySF = false, hasAISF = false, hasBn11SF = false; -var singularitySFLvl = 1; +var hasSingularitySF=false, hasAISF=false, hasBn11SF=false, hasWallStreetSF=false; +var singularitySFLvl=1, wallStreetSFLvl=1; //Used to check and set flags for every Source File, despite the name of the function function initSingularitySFFlags() { @@ -72,6 +72,10 @@ function initSingularitySFFlags() { if (Player.sourceFiles[i].n === 5) { hasAISF = true; } + if (Player.sourceFiles[i].n === 8) { + hasWallStreetSF = true; + wallStreetSFLvl = Player.sourceFiles[i].lvl; + } if (Player.sourceFiles[i].n === 11) { hasBn11SF = true; } @@ -1979,6 +1983,30 @@ function NetscriptFunctions(workerScript) { workerScript.scriptRef.log(txt); } + //Set Location to slums + switch(Player.city) { + case Locations.Aevum: + Player.location = Locations.AevumSlums; + break; + case Locations.Chongqing: + Player.location = Locations.ChongqingSlums; + break; + case Locations.Sector12: + Player.location = Locations.Sector12Slums; + break; + case Locations.NewTokyo: + Player.location = Locations.NewTokyoSlums; + break; + case Locations.Ishima: + Player.location = Locations.IshimaSlums; + break; + case Locations.Volhaven: + Player.location = Locations.VolhavenSlums; + break; + default: + console.log("Invalid Player.city value"); + } + crime = crime.toLowerCase(); if (crime.includes("shoplift")) { workerScript.scriptRef.log("Attempting to shoplift..."); @@ -2190,4 +2218,5 @@ function NetscriptFunctions(workerScript) { } } -export {NetscriptFunctions, initSingularitySFFlags, hasSingularitySF, hasBn11SF}; +export {NetscriptFunctions, initSingularitySFFlags, hasSingularitySF, hasBn11SF, hasWallStreetSF, + wallStreetSFLvl}; diff --git a/src/SaveObject.js b/src/SaveObject.js index 9c6bd9f35..d43ec3d16 100644 --- a/src/SaveObject.js +++ b/src/SaveObject.js @@ -89,6 +89,7 @@ BitburnerSaveObject.prototype.saveGame = function(db) { window.localStorage.setItem("bitburnerSave", saveString); } catch(e) { if (e.code == 22) { + Engine.createStatusText("Save failed for localStorage! Check console(F12)"); console.log("Failed to save game to localStorage because the size of the save file " + "is too large. However, the game will still be saved to IndexedDb if your browser " + "supports it. If you would like to save to localStorage as well, then " + diff --git a/src/StockMarket.js b/src/StockMarket.js index 9ec719dc3..511af0ca3 100644 --- a/src/StockMarket.js +++ b/src/StockMarket.js @@ -1,6 +1,7 @@ import {CONSTANTS} from "./Constants.js"; import {Engine} from "./engine.js"; import {Locations} from "./Location.js"; +import {hasWallStreetSF, wallStreetSFLvl} from "./NetscriptFunctions.js"; import {WorkerScript} from "./NetscriptWorker.js"; import {Player} from "./Player.js"; @@ -10,6 +11,11 @@ import {Reviver, Generic_toJSON, Generic_fromJSON} from "../utils/JSONReviver.js"; import numeral from "../utils/numeral.min.js"; import {formatNumber} from "../utils/StringHelperFunctions.js"; +import {yesNoBoxCreate, yesNoTxtInpBoxCreate, + yesNoBoxGetYesButton, yesNoBoxGetNoButton, + yesNoTxtInpBoxGetYesButton, yesNoTxtInpBoxGetNoButton, + yesNoTxtInpBoxGetInput, yesNoBoxClose, + yesNoTxtInpBoxClose, yesNoBoxOpen} from "../utils/YesNoBox.js"; /* StockMarket.js */ function Stock(name, symbol, mv, b, otlkMag, initPrice=10000) { @@ -36,9 +42,95 @@ Stock.fromJSON = function(value) { Reviver.constructors.Stock = Stock; -//Order types (long and short for each): -// - Limit Order -// - Stop Order +var OrderTypes = { + LimitBuy: "Limit Buy Order", + LimitSell: "Limit Sell Order", + StopBuy: "Stop Buy Order", + StopSell: "Stop Sell Order" +} + +var PositionTypes = { + Long: "L", + Short: "S" +} + +function placeOrder(stock, shares, price, type, position, workerScript=null) { + var tixApi = (workerScript instanceof WorkerScript); + var order = new Order(stock, shares, price, type, position); + if (isNaN(shares)) { + dialogBoxCreate("ERROR: Invalid number of shares specifies for order"); + return false; + } + if (StockMarket["Orders"] === null) { + var orders = {}; + for (var name in StockMarket) { + if (StockMarket.hasOwnProperty(name)) { + var stock = StockMarket[name]; + if (!(stock instanceof Stock)) {continue;} + orders[stock.symbol] = []; + } + } + StockMarket["Orders"] = orders; + } + StockMarket["Orders"].push(order); + //Process to see if it should be executed immediately + processOrders(order.stock, order.type, order.pos); + return true; +} + +function executeOrder(order) { + var stock = order.stock; + var orderBook = StockMarket["Orders"]; + var stockOrders = orderBook[stock.symbol]; + var res = true; + switch (order.type) { + case OrderTypes.LimitBuy: + case OrderTypes.StopBuy: + if (order.pos === PositionTypes.Long) { + res = buyStock(order.stock, order.shares) && res; + } else if (order.pos === PositionTypes.Short) { + res = shortStock(oder.stock, order.shares) && res; + } + break; + case OrderTypes.LimitSell: + case OrderTypes.StopSell: + if (order.pos === PositionTypes.Long) { + res = sellStock(order.stock, order.shares) && res; + } else if (order.pos === PositionTypes.Short) { + res = sellShort(order.stock, order.shares) && res; + } + break; + } + if (res) { + //Remove order from order book + for (var i = 0; i < stockOrders.length; ++i) { + if (order == stockOrders[i]) { + stockOrders.splice(i, 1); + return; + } + } + console.log("ERROR: Could not find the following Order in Order Book: "); + console.log(order); + } +} + +function Order(stock, price, type, position) { + this.stock = stock; + this.shares = shares; + this.price = price; + this.type = type; + this.pos = position; +} + +Order.prototype.toJSON = function() { + return Generic_toJSON("Order", this); +} + +Order.fromJSON = function(value) { + return Generic_fromJSON(Order, value.data); +} + +Reviver.constructors.Order = Order; let StockMarket = {} //Full name to stock object let StockSymbols = {} //Full name to symbol @@ -229,6 +321,16 @@ function initStockMarket() { var titanlabs = "Titan Laboratories"; var titanlabsStk = new Stock(titanlabs, StockSymbols[titanlabs], 0.6, true, 11, getRandomInt(15000, 20000)); StockMarket[titanlabs] = titanlabsStk; + + var orders = {}; + for (var name in StockMarket) { + if (StockMarket.hasOwnProperty(name)) { + var stock = StockMarket[name]; + if (!(stock instanceof Stock)) {continue;} + orders[stock.symbol] = []; + } + } + StockMarket["Orders"] = orders; } function initSymbolToStockMap() { @@ -408,6 +510,7 @@ function updateStockPrices() { var v = Math.random(); for (var name in StockMarket) { if (StockMarket.hasOwnProperty(name)) { + if (!(stock instanceof Stock)) {continue;} var stock = StockMarket[name]; var av = (v * stock.mv) / 100; if (isNaN(av)) {av = .02;} @@ -424,11 +527,19 @@ function updateStockPrices() { var c = Math.random(); if (c < chc) { stock.price *= (1 + av); + processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Short); + processOrders(stock, OrderTypes.LimitSell, PositionTypes.Long); + processOrders(stock, OrderTypes.StopBuy, PositionTypes.Long); + processOrders(stock, OrderTypes.StopSell, PositionTypes.Short); if (Engine.currentPage == Engine.Page.StockMarket) { updateStockTicker(stock, true); } } else { stock.price /= (1 + av); + processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Long); + processOrders(stock, OrderTypes.LimitSell, PositionTypes.Short); + processOrders(stock, OrderTypes.StopBuy, PositionTypes.Short); + processOrders(stock, OrderTypes.StopSell, PositionTypes.Long); if (Engine.currentPage == Engine.Page.StockMarket) { updateStockTicker(stock, false); } @@ -447,6 +558,68 @@ function updateStockPrices() { stock.otlkMag *= -1; stock.b = !stock.b; } + + } + } +} + +//Checks and triggers any orders for the specified stock +function processOrders(stock, orderType, posType) { + var orderBook = StockMarket["Orders"]; + if (orderBook === null) { + var orders = {}; + for (var name in StockMarket) { + if (StockMarket.hasOwnProperty(name)) { + var stock = StockMarket[name]; + if (!(stock instanceof Stock)) {continue;} + orders[stock.symbol] = []; + } + } + StockMarket["Orders"] = orders; + return; //Newly created, so no orders to process + } + var stockOrders = orderBook[stock.symbol]; + if (stockOrders === null || !(stockOrders.constructor === Array)) { + console.log("ERROR: Invalid Order book for " + stock.symbol + " in processOrders()"); + stockOrders = []; + return; + } + for (var i = 0; i < stockOrders.length; ++i) { + var order = stockOrders[i]; + if (order.type === orderType && order.pos === posType) { + switch(order.type) { + case OrderTypes.LimitBuy: + if (order.pos === PositionTypes.Long && stock.price <= order.price) { + executeOrder/*66*/(order); + } else if (order.pos === PositionTypes.Short && stock.price >= order.price) { + executeOrder/*66*/(order); + } + break; + case OrderTypes.LimitSell: + if (order.pos === PositionTypes.Long && stock.price >= order.price) { + executeOrder/*66*/(order); + } else if (order.pos === PositionTypes.Short && stock.price <= order.price) { + executeOrder/*66*/(order); + } + break; + case OrderTypes.StopBuy: + if (order.pos === PositionTypes.Long && stock.price >= order.price) { + executeOrder/*66*/(order); + } else if (order.pos === PositionTypes.Short && stock.price <= order.price) { + executeOrder/*66*/(order); + } + break; + case OrderTypes.StopSell: + if (order.pos === PositionTypes.Long && stock.price <= order.price) { + executeOrder/*66*/(order); + } else if (order.pos === PositionTypes.Short && stock.price >= order.price) { + executeOrder/*66*/(order); + } + break; + default: + console.log("Invalid order type: " + order.type); + return; + } } } } @@ -514,138 +687,14 @@ function displayStockMarketContent() { "This means all your positions are lost, so make sure to sell your stocks before installing " + "Augmentations!"; - var hdrLi = document.createElement("li"); - var hdrName = document.createElement("p"); - var hdrSym = document.createElement("p"); - var hdrPrice = document.createElement("p"); - var hdrQty = document.createElement("p"); - var hdrBuySell = document.createElement("p") - var hdrAvgPrice = document.createElement("p"); - var hdrShares = document.createElement("p"); - var hdrReturn = document.createElement("p"); - hdrName.style.display = "inline-block"; - hdrName.innerText = "Stock Name"; - hdrName.style.width = "8%"; - hdrSym.style.display = "inline-block"; - hdrSym.innerText = "Symbol"; - hdrSym.style.width = "4%"; - hdrPrice.style.display = "inline-block"; - hdrPrice.innerText = "Price"; - hdrPrice.style.width = "8%"; - hdrQty.style.display = "inline-block"; - hdrQty.innerText = "Quantity"; - hdrQty.style.width = "3%"; - hdrBuySell.style.display = "inline-block"; - hdrBuySell.innerText = "Buy/Sell"; - hdrBuySell.style.width = "5%"; - hdrAvgPrice.style.display = "inline-block"; - hdrAvgPrice.innerText = "Avg price of owned shares"; - hdrAvgPrice.style.width = "7.5%"; - hdrShares.style.display = "inline-block"; - hdrShares.innerText = "Shares owned"; - hdrShares.style.width = "4%"; - hdrReturn.style.display = "inline-block"; - hdrReturn.innerText = "Total Return"; - hdrReturn.style.width = "6%"; - hdrLi.appendChild(hdrName); - hdrLi.appendChild(hdrSym); - hdrLi.appendChild(hdrPrice); - hdrLi.appendChild(hdrQty); - hdrLi.appendChild(hdrBuySell); - hdrLi.appendChild(hdrAvgPrice); - hdrLi.appendChild(hdrShares); - hdrLi.appendChild(hdrReturn); - stockList.appendChild(hdrLi); - for (var name in StockMarket) { if (StockMarket.hasOwnProperty(name)) { - (function() { var stock = StockMarket[name]; - - var li = document.createElement("li"); - var stkName = document.createElement("p"); - var stkSym = document.createElement("p"); - var stkPrice = document.createElement("p"); - var qtyInput = document.createElement("input"); - var buyButton = document.createElement("span"); - var sellButton = document.createElement("span"); - var avgPriceTxt = document.createElement("p"); - var sharesTxt = document.createElement("p"); - var returnTxt = document.createElement("p"); - - var tickerId = "stock-market-ticker-" + stock.symbol; - stkName.setAttribute("id", tickerId + "-name"); - stkSym.setAttribute("id", tickerId + "-sym"); - stkPrice.setAttribute("id", tickerId + "-price"); - stkName.style.display = "inline-block"; - stkName.style.width = "8%"; - stkSym.style.display = "inline-block"; - stkSym.style.width = "4%"; - stkPrice.style.display = "inline-block"; - stkPrice.style.width = "9%"; - - li.setAttribute("display", "inline-block"); - - qtyInput.setAttribute("type", "text"); - qtyInput.setAttribute("id", tickerId + "-qty-input"); - qtyInput.setAttribute("class", "stock-market-qty-input"); - qtyInput.setAttribute("onkeydown", "return ( event.ctrlKey || event.altKey " + - " || (4734 && event.keyCode<40) " + - " || (event.keyCode==46) )"); - qtyInput.style.width = "3%"; - qtyInput.style.display = "inline-block"; - - buyButton.innerHTML = "Buy"; - buyButton.setAttribute("class", "stock-market-buy-sell-button"); - buyButton.style.width = "3%"; - buyButton.style.display = "inline-block"; - buyButton.addEventListener("click", function() { - var shares = document.getElementById(tickerId + "-qty-input").value; - shares = Number(shares); - if (isNaN(shares)) {return false;} - buyStock(stock, shares); - }); - sellButton.innerHTML = "Sell"; - sellButton.setAttribute("class", "stock-market-buy-sell-button"); - sellButton.style.width = "3%"; - sellButton.style.display = "inline-block"; - sellButton.addEventListener("click", function() { - var shares = document.getElementById(tickerId + "-qty-input").value; - shares = Number(shares); - if (isNaN(shares)) {return false;} - sellStock(stock, shares); - }); - - avgPriceTxt.setAttribute("id", tickerId + "-avgprice"); - avgPriceTxt.style.display = "inline-block"; - avgPriceTxt.style.width = "8%"; - avgPriceTxt.style.color = "white"; - sharesTxt.setAttribute("id", tickerId + "-shares"); - sharesTxt.style.display = "inline-block"; - sharesTxt.style.width = "4%"; - sharesTxt.style.color = "white"; - returnTxt.setAttribute("id", tickerId + "-return"); - returnTxt.style.display = "inline-block"; - returnTxt.style.width = "6%"; - returnTxt.style.color = "white"; - - li.appendChild(stkName); - li.appendChild(stkSym); - li.appendChild(stkPrice); - li.appendChild(qtyInput); - li.appendChild(buyButton); - li.appendChild(sellButton); - li.appendChild(avgPriceTxt); - li.appendChild(sharesTxt); - li.appendChild(returnTxt); - stockList.appendChild(li); - }()); //Immediate invocation - }//End if - + if (!(stock instanceof Stock)) {continue;} //orders property is an array + createStockTicker(stock); + } } + setStockTickerClickHandlers(); //Clicking headers opens/closes panels stockMarketContentCreated = true; } @@ -660,59 +709,278 @@ function displayStockMarketContent() { } } -//'increase' argument is a boolean indicating whether the price increased or decreased -function updateStockTicker(stock, increase) { - var tickerId = "stock-market-ticker-" + stock.symbol; - let stkName = document.getElementById(tickerId + "-name"); - let stkSym = document.getElementById(tickerId + "-sym"); - let stkPrice = document.getElementById(tickerId + "-price"); - - if (stkName == null || stkSym == null || stkPrice == null) { - console.log("ERROR, couldn't find elements with tickerId " + tickerId); +function createStockTicker(stock) { + if (!(stock instanceof Stock)) { + console.log("Invalid stock in createStockSticker()"); return; } - stkName.innerText = stock.name; - stkSym.innerText = stock.symbol; - stkPrice.innerText = "$" + formatNumber(stock.price, 2).toString(); + var tickerId = "stock-market-ticker-" + stock.symbol; + var li = document.createElement("li"), hdr = document.createElement("button"); + hdr.classList.add("accordion-header"); + hdr.setAttribute("id", tickerId + "-hdr"); + hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + stock.price; - var returnTxt = document.getElementById(tickerId + "-return"); - var totalCost = stock.playerShares * stock.playerAvgPx; - var gains = (stock.price - stock.playerAvgPx) * stock.playerShares; - var percentageGains = gains / totalCost; - if (totalCost > 0) { - returnTxt.innerText = "$" + formatNumber(gains, 2) + " (" + - formatNumber(percentageGains * 100, 2) + "%)"; - } else { - returnTxt.innerText = "N/A"; + //Div for entire panel + var stockDiv = document.createElement("div"); + stockDiv.classList.add("accordion-panel"); + + /* Create panel DOM */ + var qtyInput = document.createElement("input"), + longShortSelect = document.createElement("select"), + orderTypeSelect = document.createElement("select"), + buyButton = document.createElement("span"), + sellButton = document.createElement("span"), + positionTxt = document.createElement("p"), + orderList = document.createElement("ul"); + + qtyInput.classList.add("stock-market-input"); + qtyInput.setAttribute("id", tickerId + "-qty-input"); + qtyInput.setAttribute("onkeydown", "return ( event.ctrlKey || event.altKey " + + " || (4734 && event.keyCode<40) " + + " || (event.keyCode==46) )"); + + longShortSelect.classList.add("stock-market-input"); + longShortSelect.setAttribute("id", tickerId + "-pos-selector"); + var longOpt = document.createElement("option"); + longOpt.text = "Long"; + longShortSelect.add(longOpt); + if (Player.bitNodeN === 8 || (hasWallStreetSF && wallStreetSFLvl >= 2)) { + var shortOpt = document.createElement("option"); + shortOpt.text = "Short"; + longShortSelect.add(shortOpt); } + orderTypeSelect.classList.add("stock-market-input"); + orderTypeSelect.setAttribute("id", tickerId + "-order-selector"); + var marketOpt = document.createElement("option"); + marketOpt.text = "Market Order"; + orderTypeSelect.add(marketOpt); + if (Player.bitNodeN === 8 || (hasWallStreetSF && wallStreetSFLvl >= 3)) { + var limitOpt = document.createElement("option"); + limitOpt.text = "Limit Order"; + orderTypeSelect.add(limitOpt); + var stopOpt = document.createElement("option"); + stopOpt.text = "Stop Order"; + orderTypeSelect.add(stopOpt); + } - if (increase) { - stkName.style.color = "#66ff33"; - stkSym.style.color = "#66ff33"; - stkPrice.style.color = "#66ff33"; - } else { - stkName.style.color = "red"; - stkSym.style.color = "red"; - stkPrice.style.color = "red"; + buyButton.classList.add("stock-market-input"); + buyButton.innerHTML = "Buy"; + buyButton.addEventListener("click", ()=>{ + var pos = longShortSelect.options[longShortSelect.selectedIndex].text; + pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short; + var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text; + var shares = Number(document.getElementById(tickerId + "-qty-input").value); + if (isNaN(shares)) {return false;} + switch (ordType) { + case "Market Order": + buyStock(stock, shares); + break; + case "Limit Order": + case "Stop Order": + var yesBtn = yesNoTxtInpBoxGetYesButton(), + noBtn = yesNoTxtInpBoxGetNoButton(); + yesBtn.innerText = "Place Buy" + ordType; + noBtn.innerText = "Cancel Order"; + yesBtn.addEventListener("click", ()=>{ + var price = Number(yesNoTxtInpBoxGetInput()), type; + if (ordType === "Limit Order") { + type = OrderTypes.LimitBuy; + } else { + type = OrderTypes.StopBuy; + } + placeOrder(stock, shares, price, type, pos); + }); + noBtn.addEventListener("click", ()=>{ + yesNoTxtInpBoxClose(); + }); + yesNoTxtInpBoxCreate("Enter the price for your " + ordType); + break; + default: + console.log("ERROR: Invalid order type"); + break; + } + return false; + }); + + sellButton.classList.add("stock-market-input"); + sellButton.innerHTML = "Sell"; + sellButton.addEventListener("click", ()=>{ + var pos = longShortSelect.options[longShortSelect.selectedIndex].text; + pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short; + var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text; + var shares = Number(document.getElementById(tickerId + "-qty-input").value); + if (isNaN(shares)) {return false;} + switch (ordType) { + case "Market Order": + buyStock(stock, shares); + break; + case "Limit Order": + case "Stop Order": + var yesBtn = yesNoTxtInpBoxGetYesButton(), + noBtn = yesNoTxtInpBoxGetNoButton(); + yesBtn.innerText = "Place Sell" + ordType; + noBtn.innerText = "Cancel Order"; + yesBtn.addEventListener("click", ()=>{ + var price = Number(yesNoTxtInpBoxGetInput()), type; + if (ordType === "Limit Order") { + type = OrderTypes.LimitSell; + } else { + type = OrderTypes.StopSell; + } + placeOrder(stock, shares, price, type, pos); + }); + noBtn.addEventListener("click", ()=>{ + yesNoTxtInpBoxClose(); + }); + break; + default: + console.log("ERROR: Invalid order type"); + break; + } + return false; + }); + + positionTxt.setAttribute("id", tickerId + "-position-text"); + positionTxt.classList.add("stock-market-position-text"); + + orderList.setAttribute("id", tickerId + "-order-list"); + orderList.classList.add("stock-market-order-list"); + + stockDiv.appendChild(qtyInput); + stockDiv.appendChild(longShortSelect); + stockDiv.appendChild(orderTypeSelect); + stockDiv.appendChild(buyButton); + stockDiv.appendChild(sellButton); + stockDiv.appendChild(positionTxt); + stockDiv.appendChild(orderList); + + li.appendChild(hdr); + li.appendChild(stockDiv); + document.getElementById("stock-market-list").appendChild(li); + + updateStockTicker(stock, true); +} + +function setStockTickerClickHandlers() { + var stockList = document.getElementById("stock-market-list"); + var tickerHdrs = stockList.getElementsByClassName("accordion-header"); + if (tickerHdrs === null) { + console.log("ERROR: Could not find header elements for stock tickers"); + return; + } + for (var i = 0; i < tickerHdrs.length; ++i) { + tickerHdrs[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"; + } + } + } +} + +//'increase' argument is a boolean indicating whether the price increased or decreased +function updateStockTicker(stock, increase) { + if (!(stock instanceof Stock)) { + console.log("Invalid stock in updateStockTicker()"); + return; + } + var tickerId = "stock-market-ticker-" + stock.symbol; + var hdr = document.getElementById(tickerId + "-hdr"); + + if (hdr === null) { + console.log("ERROR: Couldn't find ticker element for stock: " + stock.symbol); + return; + } + hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + stock.price; + increase ? hdr.style.color = "#66ff33" : hdr.style.color = "red"; + + if (stock.playerShares > 0 || stock.playerShortShares > 0) { + updateStockPlayerPosition(stock); } } function updateStockPlayerPosition(stock) { - var tickerId = "stock-market-ticker-" + stock.symbol; - var avgPriceTxt = document.getElementById(tickerId + "-avgprice"); - var sharesTxt = document.getElementById(tickerId + "-shares"); - if (avgPriceTxt == null || sharesTxt == null) { - dialogBoxCreate("Could not find element for player positions for stock " + - stock.symbol + ". This is a bug please contact developer"); + if (!(stock instanceof Stock)) { + console.log("Invalid stock in updateStockTicker()"); return; } - avgPriceTxt.innerText = "$" + formatNumber(stock.playerAvgPx, 2); - sharesTxt.innerText = stock.playerShares.toString(); + var tickerId = "stock-market-ticker-" + stock.symbol, + positionTxt = document.getElementById(tickerId + "-position-text"); + if (positionTxt === null) { + console.log("ERROR: Could not find stock position element for: " + stock.symbol); + return; + } + + //Calculate returns + var totalCost = stock.playerShares * stock.playerAvgPx, + gains = (stock.price - stock.playerAvgPx) * stock.playerShares, + percentageGains = gains / totalCost; + + var shortTotalCost = stock.playerShortShares * stock.playerAvgShortPx, + shortGains = (stock.playerAvgShortPx - stock.price) * stock.playerShortShares, + shortPercentageGains = shortGains/ shortTotalCost; + + positionTxt.innerHTML = + "

Long Position: " + + "Shares in the long position will increase " + + "in value if the price of the corresponding stock increases

" + + "
Shares: " + formatNumber(stock.playerShares, 0) + + "
Average Price: " + numeral(stock.playerAvgPx).format('$0.000a') + + "
Profit: " + numeral(gains).format('$0.000a') + + " (" + formatNumber(percentageGains, 2) + "%)

" + + "

Short Position: " + + "Shares in short position will increase " + + "in value if the price of the corresponding stock decreases

" + + "
Shares: " + formatNumber(stock.playerShortShares, 0) + + "
Average Price: " + numeral(stock.playerAvgShortPx).format('$0.000a') + + "
Profit: " + numeral(shortGains).format('$0.000a') + + " (" + formatNumber(shortPercentageGains, 2) + "%)"; +} + +function updateStockOrderList(stock) { + var tickerId = "stock-market-ticker-" + stock.symbol; + var orderList = document.getElementById(tickerId + "-order-list"); + if (orderList === null) { + console.log("ERROR: Could not find order list for " + stock.symbol); + return; + } + + var orderBook = StockMarket["Orders"]; + if (orderBook === null) { + console.log("ERROR: Could not find order book in stock market"); + return; + } + var stockOrders = orderBook[stock.symbol]; + if (stockOrders === null) { + console.log("ERROR: Could nto find orders for: " + stock.symbol); + return; + } + + //Remove everything from list + while (orderList.firstChild) { + orderList.removeChild(orderList.firstChild); + } + + for (var i = 0; i < stockOrders.length; ++i) { + var order = stockOrders[i]; + var li = document.createElement("li"); + var posText = (order.pos === PositionTypes.Long ? "Long Position" : "Short Position"); + li.innerText = order.type + " - " + posText + " - " + + order.shares + " @ $" + formatNumber(order.price, 2); + orderList.appendChild(li); + } } export {StockMarket, StockSymbols, SymbolToStockMap, initStockSymbols, initStockMarket, initSymbolToStockMap, stockMarketCycle, buyStock, sellStock, updateStockPrices, displayStockMarketContent, updateStockTicker, updateStockPlayerPosition, loadStockMarket, - setStockMarketContentCreated}; + setStockMarketContentCreated, placeOrder, Order, OrderTypes}; diff --git a/src/TextFile.js b/src/TextFile.js new file mode 100644 index 000000000..753c44b9c --- /dev/null +++ b/src/TextFile.js @@ -0,0 +1,77 @@ +import {Server} from "./Server.js"; +import {dialogBoxCreate} from "../utils/DialogBox.js"; +import {Reviver, Generic_toJSON, + Generic_fromJSON} from "../utils/JSONReviver.js"; + +function TextFile(fn="", txt="") { + this.fn = fn.endsWith(".txt") ? fn : fn + ".txt"; + this.text = String(txt); +} + +TextFile.prototype.append = function(txt) { + this.text += String(txt); +} + +TextFile.prototype.write = function(txt) { + this.text = String(txt); +} + +TextFile.prototype.read = function() { + return this.txt; +} + +TextFile.prototype.show = function() { + dialogBoxCreate(this.fn + "

" + this.text); +} + +TextFile.prototype.download = function() { + var filename = this.fn; + var file = new Blob([this.text], {type: 'text/plain'}); + if (window.navigator.msSaveOrOpenBlob) {// IE10+ + window.navigator.msSaveOrOpenBlob(file, filename); + } else { // Others + var a = document.createElement("a"), + url = URL.createObjectURL(file); + a.href = url; + a.download = this.fn; + document.body.appendChild(a); + a.click(); + setTimeout(function() { + document.body.removeChild(a); + window.URL.revokeObjectURL(url); + }, 0); + } +} + +TextFile.prototype.toJSON = function() { + return Generic_toJSON("TextFile", this); +} + +TextFile.fromJSON = function(value) { + return Generic_fromJSON(TextFile, value.data); +} + +Reviver.constructors.TextFile = TextFile; + +function getTextFile(fn, server) { + for (var i = 0; i < server.textFiles.length; ++i) { + if (server.textFiles[i].fn === fn) { + return server.textFiles[i]; + } + } + return null; +} + +//Returns the TextFile object that was just created +function createTextFile(fn, txt, server) { + if (getTextFile(fn, server) !== null) { + console.log("ERROR: createTextFile failed because the specified " + + "server already has a text file with the same fn"); + return; + } + var file = new TextFile(fn, txt); + server.textFiles.push(file); + return file; +} + +export {TextFile, getTextFile, createTextFile}; From 4dc87af132be6fff1f3b1e1fc14ac4e74d931c61 Mon Sep 17 00:00:00 2001 From: danielyxie Date: Wed, 25 Oct 2017 14:47:47 -0500 Subject: [PATCH 2/2] v0.32.0 - Added BitNode-8: Ghost of Wall Street --- css/menupages.css | 24 +- css/styles.css | 3 +- dist/bundle.js | 811 +++++++++++++++++++++++++++----------- index.html | 5 +- src/BitNode.js | 26 +- src/CompanyManagement.js | 4 +- src/Constants.js | 246 ++++++------ src/Faction.js | 2 +- src/Infiltration.js | 59 +-- src/NetscriptFunctions.js | 129 +++++- src/Player.js | 9 +- src/Prestige.js | 9 +- src/RedPill.js | 2 +- src/SaveObject.js | 4 +- src/Script.js | 10 +- src/SourceFile.js | 15 +- src/StockMarket.js | 233 ++++++++--- src/TextFile.js | 1 + src/engine.js | 3 +- utils/InfiltrationBox.js | 1 + 20 files changed, 1132 insertions(+), 464 deletions(-) diff --git a/css/menupages.css b/css/menupages.css index 12f948013..0fc5c0adb 100644 --- a/css/menupages.css +++ b/css/menupages.css @@ -607,21 +607,7 @@ div.faction-clear { .stock-market-position-text { color:white; - white-space: pre; - display:block; -} - -.stock-market-buy-sell-button { - color: #aaa; - font-size: 16px; - font-weight: bold; -} - -.stock-market-buy-sell-button:hover, -.stock-market-buy-sell-button:focus { - color: var(--my-font-color); - text-decoration: none; - cursor: pointer; + display:inline-block; } .stock-market-order-list { @@ -629,6 +615,14 @@ div.faction-clear { max-height: 100px; } +.stock-market-order-cancel-btn { + background-color: black; + border: 1px solid white; + color: var(--my-font-color); + margin: 2px; + padding: 0px; +} + /* Gang */ #gang-container { position: fixed; diff --git a/css/styles.css b/css/styles.css index 4eabfe0c0..c93a5c088 100644 --- a/css/styles.css +++ b/css/styles.css @@ -445,7 +445,8 @@ a:link, a:visited { margin-left: 5%; display: none; background-color: #555; - overflow:auto; + overflow-y:auto; + overflow-x:none; } .accordion-panel div, diff --git a/dist/bundle.js b/dist/bundle.js index c56157077..883339f9f 100644 --- a/dist/bundle.js +++ b/dist/bundle.js @@ -455,6 +455,13 @@ PlayerObject.prototype.prestigeSourceFile = function() { this.hasWseAccount = false; this.hasTixApiAccess = false; + //BitNode 8: Ghost of Wall Street + if (this.bitNodeN === 8) {this.money = new __WEBPACK_IMPORTED_MODULE_14__utils_decimal_js___default.a(100000000);} + if (this.bitNodeN === 8 || __WEBPACK_IMPORTED_MODULE_10__NetscriptFunctions_js__["d" /* hasWallStreetSF */]) { + this.hasWseAccount = true; + this.hasTixApiAccess = true; + } + this.playtimeSinceLastAug = 0; this.scriptProdSinceLastAug = 0; } @@ -2563,7 +2570,7 @@ function powerOfTwo(n) { "use strict"; /* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return CONSTANTS; }); let CONSTANTS = { - Version: "0.31.0", + Version: "0.32.0", //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 @@ -3004,18 +3011,18 @@ let CONSTANTS = { "

Functions


" + "You can NOT define you own functions in Netscript (yet), but there are several built in functions that " + "you may use:

" + - "hack(hostname/ip)
Core function that is used to try and hack servers to steal money and gain hacking experience. The argument passed in must be a string with " + + "hack(hostname/ip)
Core function that is used to try and hack servers to steal money and gain hacking experience. The argument passed in must be a string with " + "either the IP or hostname of the server you want to hack. The runtime for this command depends on your hacking level and the target server's security level. " + " A script can hack a server from anywhere. It does not need to be running on the same server to hack that server. " + "For example, you can create a script that hacks the 'foodnstuff' server and run that script on any server in the game. A successful hack() on " + "a server will raise that server's security level by 0.002. Returns true if the hack is successful and " + "false otherwise.
" + "Examples: hack('foodnstuff'); or hack('148.192.0.12');

" + - "sleep(n, log=true)
Suspends the script for n milliseconds. The second argument is an optional boolean that indicates " + + "sleep(n, log=true)
Suspends the script for n milliseconds. The second argument is an optional boolean that indicates " + "whether or not the function should log the sleep action. If this argument is true, then calling this function will write " + "'Sleeping for N milliseconds' to the script's logs. If it's false, then this function will not log anything. " + "If this argument is not specified then it will be true by default.
Example: sleep(5000);

" + - "grow(hostname/ip)
Use your hacking skills to increase the amount of money available on a server. The argument passed in " + + "grow(hostname/ip)
Use your hacking skills to increase the amount of money available on a server. The argument passed in " + "must be a string with either the IP or hostname of the target server. The runtime for this command depends on your hacking level and the target server's security level. " + "When grow() completes, the money available on a target server will be increased by a certain, fixed percentage. This percentage " + "is determined by the server's growth rate and varies between servers. Generally, higher-level servers have higher growth rates.

" + @@ -3024,28 +3031,28 @@ let CONSTANTS = { "It also raises the security level of the target server by 0.004. " + "Returns the number by which the money on the server was multiplied for the growth. " + "Works offline at a slower rate.
Example: grow('foodnstuff');

" + - "weaken(hostname/ip)
Use your hacking skills to attack a server's security, lowering the server's security level. The argument passed " + + "weaken(hostname/ip)
Use your hacking skills to attack a server's security, lowering the server's security level. The argument passed " + "in must be a string with either the IP or hostname of the target server. The runtime for this command depends on your " + "hacking level and the target server's security level. This function lowers the security level of the target server by " + "0.05.

Like hack() and grow(), weaken() can be called on " + "any server, regardless of where the script is running. This command requires root access to the target server, but " + "there is no required hacking level to run the command. Returns " + "0.1. Works offline at a slower rate
Example: weaken('foodnstuff');

" + - "print(x)
Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command ).

" + - "tprint(x)
Prints a value or a variable to the Terminal

" + - "clearLog()
Clears the script's logs.

" + - "scan(hostname/ip, [hostnames=true])
Returns an array containing the hostnames or IPs of all servers that are one node away from the specified server. " + + "print(x)
Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command ).

" + + "tprint(x)
Prints a value or a variable to the Terminal

" + + "clearLog()
Clears the script's logs.

" + + "scan(hostname/ip, [hostnames=true])
Returns an array containing the hostnames or IPs of all servers that are one node away from the specified server. " + "The argument must be a string containing the IP or hostname of the target server. The second argument is a boolean that specifies whether " + "the hostnames or IPs of the scanned servers should be output. If it is true then hostnames will be returned, and if false then IP addresses will. " + "This second argument is optional and, if ommitted, the function will output " + "the hostnames of the scanned servers. The hostnames/IPs in the returned array are strings.

" + - "nuke(hostname/ip)
Run NUKE.exe on the target server. NUKE.exe must exist on your home computer.
Example: nuke('foodnstuff');

" + - "brutessh(hostname/ip)
Run BruteSSH.exe on the target server. BruteSSH.exe must exist on your home computer.
Example: brutessh('foodnstuff');

" + - "ftpcrack(hostname/ip)
Run FTPCrack.exe on the target server. FTPCrack.exe must exist on your home computer.
Example: ftpcrack('foodnstuff');

" + - "relaysmtp(hostname/ip)
Run relaySMTP.exe on the target server. relaySMTP.exe must exist on your home computer.
Example: relaysmtp('foodnstuff');

" + - "httpworm(hostname/ip)
Run HTTPWorm.exe on the target server. HTTPWorm.exe must exist on your home computer.
Example: httpworm('foodnstuff');

" + - "sqlinject(hostname/ip)
Run SQLInject.exe on the target server. SQLInject.exe must exist on your home computer.
Example: sqlinject('foodnstuff');

" + - "run(script, [numThreads], [args...])
Run a script as a separate process. The first argument that is passed in is the name of the script as a string. This function can only " + + "nuke(hostname/ip)
Run NUKE.exe on the target server. NUKE.exe must exist on your home computer.
Example: nuke('foodnstuff');

" + + "brutessh(hostname/ip)
Run BruteSSH.exe on the target server. BruteSSH.exe must exist on your home computer.
Example: brutessh('foodnstuff');

" + + "ftpcrack(hostname/ip)
Run FTPCrack.exe on the target server. FTPCrack.exe must exist on your home computer.
Example: ftpcrack('foodnstuff');

" + + "relaysmtp(hostname/ip)
Run relaySMTP.exe on the target server. relaySMTP.exe must exist on your home computer.
Example: relaysmtp('foodnstuff');

" + + "httpworm(hostname/ip)
Run HTTPWorm.exe on the target server. HTTPWorm.exe must exist on your home computer.
Example: httpworm('foodnstuff');

" + + "sqlinject(hostname/ip)
Run SQLInject.exe on the target server. SQLInject.exe must exist on your home computer.
Example: sqlinject('foodnstuff');

" + + "run(script, [numThreads], [args...])
Run a script as a separate process. The first argument that is passed in is the name of the script as a string. This function can only " + "be used to run scripts located on the current server (the server running the script that calls this function). The second argument " + "is optional, and it specifies how many threads to run the script with. This argument must be a number greater than 0. If it is omitted, then the script will be run single-threaded. Any additional arguments will specify " + "arguments to pass into the new script that is being run. If arguments are specified for the new script, then the second argument numThreads argument must be filled in with a value.

" + @@ -3057,7 +3064,7 @@ let CONSTANTS = { "run('foo.script', 5);

" + "The following example will run 'foo.script' single-threaded, and will pass the string 'foodnstuff' into the script as an argument:

" + "run('foo.script', 1, 'foodnstuff');

" + - "exec(script, hostname/ip, [numThreads], [args...])
Run a script as a separate process on another server. The first argument is the name of the script as a string. The " + + "exec(script, hostname/ip, [numThreads], [args...])
Run a script as a separate process on another server. The first argument is the name of the script as a string. The " + "second argument is a string with the hostname or IP of the 'target server' on which to run the script. The specified script must exist on the target server. " + "The third argument is optional, and it specifies how many threads to run the script with. If it is omitted, then the script will be run single-threaded. " + "This argument must be a number that is greater than 0. Any additional arguments will specify arguments to pass into the new script that is being run. If " + @@ -3071,7 +3078,7 @@ let CONSTANTS = { "The following example will try to run the script 'foo.script' on the 'foodnstuff' server with 5 threads. It will also pass the number 1 and the string 'test' in as arguments " + "to the script.

" + "exec('foo.script', 'foodnstuff', 5, 1, 'test');

" + - "kill(script, hostname/ip, [args...])
Kills the script on the target server specified by the script's name and arguments. Remember that " + + "kill(script, hostname/ip, [args...])
Kills the script on the target server specified by the script's name and arguments. Remember that " + "scripts are uniquely identified by both their name and arguments. For example, if 'foo.script' is run with the argument 1, then this is not the " + "same as 'foo.script' run with the argument 2, even though they have the same code.

" + "The first argument must be a string with the name of the script. The name is case-sensitive. " + @@ -3086,9 +3093,9 @@ let CONSTANTS = { "kill('foo.script', getHostname());

" + "If you are trying to kill a script named 'foo.script' on the current server that was ran with the arguments 1 and 'foodnstuff', use this:

" + "kill('foo.script', getHostname(), 1, 'foodnstuff');

" + - "killall(hostname/ip)
Kills all running scripts on the specified server. This function takes a single argument which " + + "killall(hostname/ip)
Kills all running scripts on the specified server. This function takes a single argument which " + "must be a string containing the hostname or IP of the target server. This function will always return true.

" + - "scp(script, [source], destination)
Copies a script or literature (.lit) file to another server. The first argument is a string with " + + "scp(script, [source], destination)
Copies a script or literature (.lit) file to another server. The first argument is a string with " + "the filename of the script or literature file " + "to be copied, or an array of filenames to be copied. The next two arguments are strings containing the hostname/IPs of the source and target server. " + "The source refers to the server from which the script/literature file will be copied, while the destination " + @@ -3098,15 +3105,15 @@ let CONSTANTS = { "will return if at least one of the files in the array is successfully copied over.

" + "Example: scp('hack-template.script', 'foodnstuff'); //Copies hack-template.script from the current server to foodnstuff
" + "Example: scp('foo.lit', 'helios', 'home'); //Copies foo.lit from the helios server to the home computer

" + - "ls(hostname/ip)
Returns an array containing the names of all files on the specified server. The argument must be a " + + "ls(hostname/ip)
Returns an array containing the names of all files on the specified server. The argument must be a " + "string with the hostname or IP of the target server.

" + - "hasRootAccess(hostname/ip)
Returns a boolean (true or false) indicating whether or not the Player has root access to a server. " + + "hasRootAccess(hostname/ip)
Returns a boolean (true or false) indicating whether or not the Player has root access to a server. " + "The argument passed in must be a string with either the hostname or IP of the target server.
" + "Example:
if (hasRootAccess('foodnstuff') == false) {
    nuke('foodnstuff');
}

" + - "getIp()
Returns a string with the IP Address of the server that the script is running on

" + - "getHostname()
Returns a string with the hostname of the server that the script is running on

" + - "getHackingLevel()
Returns the Player's current hacking level.

" + - "getHackingMultipliers()
Returns an object containing the Player's hacking related multipliers. " + + "getIp()
Returns a string with the IP Address of the server that the script is running on

" + + "getHostname()
Returns a string with the hostname of the server that the script is running on

" + + "getHackingLevel()
Returns the Player's current hacking level.

" + + "getHackingMultipliers()
Returns an object containing the Player's hacking related multipliers. " + "These multipliers are returned in integer forms, not percentages (e.g. 1.5 instead of 150%). " + "The object has the following structure:

" + "{
" + @@ -3118,7 +3125,7 @@ let CONSTANTS = { "mults = getHackingMultipliers();
" + "print(mults.chance);
" + "print(mults.growth);

" + - "getBitNodeMultipliers()
Returns an object containing the current BitNode multipliers. " + + "getBitNodeMultipliers()
Returns an object containing the current BitNode multipliers. " + "This function requires Source-File 5 in order to run. The multipliers are returned in integer forms, not percentages " + "(e.g. 1.5 instead of 150%). The multipliers represent the difference between the current BitNode and the " + "original BitNode (BitNode-1). For example, if the 'CrimeMoney' multiplier has a value of 0.1 then that means " + @@ -3148,33 +3155,33 @@ let CONSTANTS = { "mults = getBitNodeMultipliers();
" + "print(mults.ServerMaxMoney);
" + "print(mults.HackExpGain);

" + - "getServerMoneyAvailable(hostname/ip)
Returns the amount of money available on a server. The argument passed in must be a string with either the " + + "getServerMoneyAvailable(hostname/ip)
Returns the amount of money available on a server. The argument passed in must be a string with either the " + "hostname or IP of the target server.
Example: getServerMoneyAvailable('foodnstuff');

" + - "getServerMaxMoney(hostname/ip)
Returns the maximum amount of money that can be available on a server. The argument passed in must be a string with " + + "getServerMaxMoney(hostname/ip)
Returns the maximum amount of money that can be available on a server. The argument passed in must be a string with " + "the hostname or IP of the target server.
Example: getServerMaxMoney('foodnstuff');

" + - "getServerGrowth(hostname/ip)
Returns the server's intrinsic 'growth parameter'. This growth parameter is a number " + + "getServerGrowth(hostname/ip)
Returns the server's intrinsic 'growth parameter'. This growth parameter is a number " + "between 1 and 100 that represents how quickly the server's money grows. This parameter affects the percentage by which this server's " + "money is increased when using the grow() function. A higher growth parameter will result in a higher percentage from grow().

" + "The argument passed in must be a string with the hostname or IP of the target server.

" + - "getServerSecurityLevel(hostname/ip)
Returns the security level of a server. The argument passed in must be a string with either the " + + "getServerSecurityLevel(hostname/ip)
Returns the security level of a server. The argument passed in must be a string with either the " + "hostname or IP of the target server. A server's security is denoted by a number, typically between 1 and 100.

" + - "getServerBaseSecurityLevel(hostname/ip)
Returns the base security level of a server. This is the security level that the server starts out with. " + + "getServerBaseSecurityLevel(hostname/ip)
Returns the base security level of a server. This is the security level that the server starts out with. " + "This is different than getServerSecurityLevel() because getServerSecurityLevel() returns the current security level of a server, which can constantly change " + "due to hack(), grow(), and weaken() calls on that server. The base security level will stay the same until you reset by installing an Augmentation.

" + "The argument passed in must be a string with either the hostname or IP of the target server. A server's base security is denoted by a number, typically between 1 and 100. " + "

" + - "getServerMinSecurityLevel(hostname/ip)Returns the minimum security level of a server. The argument passed in must be a string with " + + "getServerMinSecurityLevel(hostname/ip)Returns the minimum security level of a server. The argument passed in must be a string with " + "either the hostname or IP of the target server.

" + - "getServerRequiredHackingLevel(hostname/ip)
Returns the required hacking level of a server. The argument passed in must be a string with either the " + + "getServerRequiredHackingLevel(hostname/ip)
Returns the required hacking level of a server. The argument passed in must be a string with either the " + "hostname or IP or the target server.

" + - "getServerNumPortsRequired(hostname/ip)
Returns the number of open ports required to successfully run NUKE.exe on a server. The argument " + + "getServerNumPortsRequired(hostname/ip)
Returns the number of open ports required to successfully run NUKE.exe on a server. The argument " + "passed in must be a string with either the hostname or IP of the target server.

" + - "getServerRam(hostname/ip)
Returns an array with two elements that gives information about the target server's RAM. The first " + + "getServerRam(hostname/ip)
Returns an array with two elements that gives information about the target server's RAM. The first " + "element in the array is the amount of RAM that the server has (in GB). The second element in the array is the amount of RAM that " + "is currently being used on the server.

" + - "serverExists(hostname/ip)
Returns a boolean denoting whether or not the specified server exists. The argument " + + "serverExists(hostname/ip)
Returns a boolean denoting whether or not the specified server exists. The argument " + "must be a string with the hostname or IP of the target server.

" + - "fileExists(filename, [hostname/ip])
Returns a boolean (true or false) indicating whether the specified file exists on a server. " + + "fileExists(filename, [hostname/ip])
Returns a boolean (true or false) indicating whether the specified file exists on a server. " + "The first argument must be a string with the name of the file. A file can either be a script, program, or literature file. A script name is case-sensitive, but a " + "program/literature file is not. For example, fileExists('brutessh.exe') will work fine, even though the actual program is named BruteSSH.exe.

" + "The second argument is a string with the hostname or IP of the server on which to search for the program. This second argument is optional. " + @@ -3183,7 +3190,7 @@ let CONSTANTS = { "Example: fileExists('ftpcrack.exe');

" + "The first example above will return true if the script named 'foo.script' exists on the 'foodnstuff' server, and false otherwise. The second example above will " + "return true if the current server (the server on which this function runs) contains the FTPCrack.exe program, and false otherwise.

" + - "isRunning(filename, hostname/ip, [args...])
Returns a boolean (true or false) indicating whether the specified script is running on a server. " + + "isRunning(filename, hostname/ip, [args...])
Returns a boolean (true or false) indicating whether the specified script is running on a server. " + "Remember that a script is uniquely identified by both its name and its arguments.

" + "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. Any additional arguments passed to the function will specify the arguments passed into the target script. " + @@ -3195,45 +3202,45 @@ let CONSTANTS = { "example above will return true if there is a script named 'foo.script' with no arguments running on the current server, and false otherwise. " + "The third example above will return true if there is a script named 'foo.script' with the arguments 1, 5, and 'test' running on the 'joesguns' server, and " + "false otherwise.

" + - "getNextHacknetNodeCost()
Returns the cost of purchasing a new Hacknet Node

" + - "purchaseHacknetNode()
Purchases a new Hacknet Node. Returns a number with the index of the Hacknet Node. This index is equivalent to the number " + + "getNextHacknetNodeCost()
Returns the cost of purchasing a new Hacknet Node

" + + "purchaseHacknetNode()
Purchases a new Hacknet Node. Returns a number with the index of the Hacknet Node. This index is equivalent to the number " + "at the end of the Hacknet Node's name (e.g The Hacknet Node named 'hacknet-node-4' will have an index of 4). If the player cannot afford to purchase " + "a new Hacknet Node then the function will return false. Does NOT work offline

" + - "purchaseServer(hostname, ram)
Purchases a server with the specified hostname and amount of RAM. The first argument can be any data type, " + + "purchaseServer(hostname, ram)
Purchases a server with the specified hostname and amount of RAM. The first argument can be any data type, " + "but it will be converted to a string using Javascript's String function. Anything that resolves to an empty string will cause the function to fail. " + "The second argument specified the amount of RAM (in GB) for the server. This argument must resolve to a numeric and it must be a power of 2 " + "(2, 4, 8, etc...).

" + "This function returns the hostname of the newly purchased server as a string. If the function fails to purchase a server, then it will return " + "an empty string. The function will fail if the arguments passed in are invalid or if the player does not have enough money to purchase the specified server.

" + - "deleteServer(hostname)
Deletes one of the servers you've purchased with the specified hostname. The function will fail if " + + "deleteServer(hostname)
Deletes one of the servers you've purchased with the specified hostname. The function will fail if " + "there are any scripts running on the specified server. Returns true if successful and false otherwise

" + - "getPurchasedServers([hostname=true])
Returns an array with either the hostname or IPs of all of the servers you " + + "getPurchasedServers([hostname=true])
Returns an array with either the hostname or IPs of all of the servers you " + "have purchased. It takes an optional parameter specifying whether the hostname or IP addresses will be returned. If this " + "parameter is not specified, it is true by default and hostnames will be returned

" + - "round(n)
Rounds the number n to the nearest integer. If the argument passed in is not a number, then the function will return 0.

" + - "write(port, data)
Writes data to a port. The first argument must be a number between 1 and 10 that specifies the port. The second " + + "round(n)
Rounds the number n to the nearest integer. If the argument passed in is not a number, then the function will return 0.

" + + "write(port, data)
Writes data to a port. The first argument must be a number between 1 and 10 that specifies the port. The second " + "argument defines the data to write to the port. If the second argument is not specified then it will write an empty string to the port.

" + - "read(port)
Reads data from a port. The first argument must be a number between 1 and 10 that specifies the port. A port is a serialized queue. " + + "read(port)
Reads data from a port. The first argument must be a number between 1 and 10 that specifies the port. A port is a serialized queue. " + "This function will remove the first element from the queue and return it. If the queue is empty, then the string 'NULL PORT DATA' will be returned.

" + - "scriptRunning(scriptname, hostname/ip)
Returns a boolean indicating whether any instance of the specified script is running " + + "scriptRunning(scriptname, hostname/ip)
Returns a boolean indicating whether any instance of the specified script is running " + "on a server, regardless of its arguments. This is different than the isRunning() function because it does not " + "try to identify a specific instance of a running script by its arguments.

" + "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.

" + - "scriptKill(scriptname, hostname/ip)
Kills all scripts with the specified filename that are running on the server specified by the " + + "scriptKill(scriptname, hostname/ip)
Kills all scripts with the specified filename that are running on the server specified by the " + "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.

" + - "getScriptRam(scriptname, hostname/ip)
Returns the amount of RAM required to run the specified script on the " + + "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.

" + - "getHackTime(hostname/ip)
Returns the amount of time in seconds it takes to execute the hack() Netscript function " + + "getHackTime(hostname/ip)
Returns the amount of time in seconds it takes to execute the hack() Netscript function " + "on the server specified by the hostname/ip. The argument must be a string with the hostname/ip of the target server.

" + - "getGrowTime(hostname/ip)
Returns the amount of time in seconds it takes to execute the grow() Netscript function " + + "getGrowTime(hostname/ip)
Returns the amount of time in seconds it takes to execute the grow() Netscript function " + "on the server specified by the hostname/ip. The argument must be a string with the hostname/ip of the target server.

" + - "getWeakenTime(hostname/ip)
Returns the amount of time in seconds it takes to execute the weaken() Netscript function " + + "getWeakenTime(hostname/ip)
Returns the amount of time in seconds it takes to execute the weaken() Netscript function " + "on the server specified by the hostname/ip. The argument must be a string with the hostname/ip of the target server.

" + - "getScriptIncome([scriptname], [hostname/ip], [args...])
" + + "getScriptIncome([scriptname], [hostname/ip], [args...])
" + "Returns the amount of income the specified script generates while online (when the game is open, does not apply for " + "offline income). This function can also be called with no arguments. If called with no arguments, then this function " + "will return an array of two values. The first value is the total income ($/sec) of all of your active scripts (currently running). " + @@ -3245,7 +3252,7 @@ let CONSTANTS = { "The second argument must be a string with the hostname/IP of the target server. If the first argument is specified " + "then the second argument must be specified as well. Any additional arguments passed to the function will specify " + "the arguments passed into the target script.

" + - "getScriptExpGain([scriptname], [hostname/ip], [args...])
" + + "getScriptExpGain([scriptname], [hostname/ip], [args...])
" + "Returns the amount of hacking experience the specified script generates while online (when the game is open, does not apply for " + "offline experience gains). This function can also return the total experience gain rate of all of your active scripts by running the function " + "with no arguments.

" + @@ -3256,26 +3263,28 @@ let CONSTANTS = { "The second argument must be a string with the hostname/IP of the target server. If the first argument is specified " + "then the second argument must be specified as well. Any additional arguments passed to the function will specify " + "the arguments passed into the target script.

" + - "getTimeSinceLastAug()
" + + "getTimeSinceLastAug()
" + "Returns the amount of time in milliseconds that have passed since you last installed Augmentations (or destroyed a BitNode).

" + + "sprintf()/vsprintf()
" + + "See this link for details

" + "

Hacknet Nodes API


" + "Netscript provides the following API for accessing and upgrading your Hacknet Nodes through scripts. This API does NOT work offline.

" + - "hacknetnodes
A special variable. This is an array that maps to the Player's Hacknet Nodes. The Hacknet Nodes are accessed through " + + "hacknetnodes
A special variable. This is an array that maps to the Player's Hacknet Nodes. The Hacknet Nodes are accessed through " + "indexes. These indexes correspond to the number at the end of the name of the Hacknet Node. For example, the first Hacknet Node you purchase " + "will have the same 'hacknet-node-0' and can be accessed with hacknetnodes[0]. The fourth Hacknet Node you purchase will have the name " + "'hacknet-node-3' and can be accessed with hacknetnodes[3].

" + - "hacknetnodes.length
Returns the number of Hacknet Nodes that the player owns

" + - "hacknetnodes[i].level
Returns the level of the corresponding Hacknet Node

" + - "hacknetnodes[i].ram
Returns the amount of RAM on the corresponding Hacknet Node

" + - "hacknetnodes[i].cores
Returns the number of cores on the corresponding Hacknet Node

" + - "hacknetnodes[i].totalMoneyGenerated
Returns the total amount of money that the corresponding Hacknet Node has earned

" + - "hacknetnodes[i].onlineTimeSeconds
Returns the total amount of time that the corresponding Hacknet Node has existed

" + - "hacknetnodes[i].moneyGainRatePerSecond
Returns the income ($ / sec) that the corresponding Hacknet Node earns

" + - "hacknetnodes[i].upgradeLevel(n)
Tries to upgrade the level of the corresponding Hacknet Node n times. The argument n must be a " + + "hacknetnodes.length
Returns the number of Hacknet Nodes that the player owns

" + + "hacknetnodes[i].level
Returns the level of the corresponding Hacknet Node

" + + "hacknetnodes[i].ram
Returns the amount of RAM on the corresponding Hacknet Node

" + + "hacknetnodes[i].cores
Returns the number of cores on the corresponding Hacknet Node

" + + "hacknetnodes[i].totalMoneyGenerated
Returns the total amount of money that the corresponding Hacknet Node has earned

" + + "hacknetnodes[i].onlineTimeSeconds
Returns the total amount of time that the corresponding Hacknet Node has existed

" + + "hacknetnodes[i].moneyGainRatePerSecond
Returns the income ($ / sec) that the corresponding Hacknet Node earns

" + + "hacknetnodes[i].upgradeLevel(n)
Tries to upgrade the level of the corresponding Hacknet Node n times. The argument n must be a " + "positive integer. Returns true if the Hacknet Node's level is successfully upgraded n times or up to the max level (200), and false otherwise.

" + - "hacknetnodes[i].upgradeRam()
Tries to upgrade the amount of RAM on the corresponding Hacknet Node. Returns true if the " + + "hacknetnodes[i].upgradeRam()
Tries to upgrade the amount of RAM on the corresponding Hacknet Node. Returns true if the " + "RAM is successfully upgraded, and false otherwise.

" + - "hacknetnodes[i].upgradeCore()
Attempts to purchase an additional core for the corresponding Hacknet Node. Returns true if the " + + "hacknetnodes[i].upgradeCore()
Attempts to purchase an additional core for the corresponding Hacknet Node. Returns true if the " + "additional core is successfully purchase, and false otherwise.

" + "Example: The following is an example of one way a script can be used to automate the purchasing and upgrading of Hacknet Nodes. " + "This script purchases new Hacknet Nodes until the player has four. Then, it iteratively upgrades each of those four Hacknet Nodes " + @@ -3302,25 +3311,53 @@ let CONSTANTS = { "    }
" + "}

" + "

Trade Information eXchange (TIX) API


" + - "getStockPrice(sym)
Returns the price of a stock. The argument passed in must be the stock's symbol (NOT THE COMPANY NAME!). The symbol " + + "getStockPrice(sym)
Returns the price of a stock. The argument passed in must be the stock's symbol (NOT THE COMPANY NAME!). The symbol " + "is a sequence of two to four capital letters. The symbol argument must be a string.

" + "Example: getStockPrice('FSIG');

" + - "getStockPosition(sym)
Returns an array of two elements that represents the player's position in a stock. The first element " + + "getStockPosition(sym)
Returns an array of two elements that represents the player's position in a stock. The first element " + "in the array is the number of shares the player owns of the specified stock. The second element in the array is the average price of the player's " + "shares. Both elements are numbers. The argument passed in must be the stock's symbol, which is a sequence of two to four capital letters.

" + "Example:

pos = getStockPosition('ECP');
shares = pos[0];
avgPx = pos[1];

"+ - "buyStock(sym, shares)
Attempts to purchase shares of a stock. The first argument must be a string with the stock's symbol. The second argument " + + "buyStock(sym, shares)
Attempts to purchase shares of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument " + "must be the number of shares to purchase.

" + "If the player does not have enough money to purchase specified number of shares, then no shares will be purchased (it will not purchase the most you can afford). " + "Remember that every transaction on the stock exchange costs a certain commission fee.

" + "The function will return true if it successfully purchases the specified number of shares of stock, and false otherwise.

" + - "sellStock(sym, shares)
Attempts to sell shares of a stock. The first argument must be a string with the stock's symbol. The second argument " + + "sellStock(sym, shares)
Attempts to sell shares of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument " + "must be the number of shares to sell.

" + "If the specified number of shares in the function exceeds the amount that the player actually owns, then this function will sell all owned shares. " + "Remember that every transaction on the stock exchange costs a certain commission fee.

" + "The net profit made from selling stocks with this function is reflected in the script's statistics. This net profit is calculated as:

" + "shares * (sell price - average price of purchased shares)

" + "This function will return true if the shares of stock are successfully sold and false otherwise.

" + + "shortStock(sym, shares)
" + + "Attempts to purchase a short position of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument " + + "must be the number of shares to purchase.

" + + "In order to use this function the player must be in BitNode-8 or must have Level 2 of Source-File 8.

" + + "If the player does not have enough money to purchase the specified number of shares, then no shares will be purchased. Remember that every " + + "every transaction on the stock exchange costs a certain commission fee.

" + + "Returns true if it successfully shorts the stock with the specified number of shares, and false otherwise.

" + + "sellShort(sym, shares)
" + + "Attempts to sell a short position of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument must be the " + + "number of shares to sell.

" + + "In order to use this function the player must be in BitNode-8 or must have Level 2 of Source-File 8.

" + + "If the specified number of shares exceeds the amount that the player actually owns, then this function will sell all owned shares. " + + "Remember that every transaction on the stock exchange costs a certain commission fee.

" + + "This function returns true if it successfully sells any number of shares, and false otherwise.

" + + "placeOrder(sym, shares, price, type, pos)
" + + "Places an order on the stock market. This function only works for Limit and Stop Orders. Use the buyStock/sellStock/shortStock/sellShort functions " + + "to place Market Orders. In order to use this function the player must be in BitNode-8 or must have Level 3 of Source-File 8.

" + + "The 'sym' argument must be a string with the symbol of the stock. The 'shares' and 'price' arguments " + + "specify the number of shares and the execution price for the order. They must be numeric.

" + + "The 'type' argument is a string that specifies the type of order. It must specify either 'limit' or 'stop', and must " + + "also specify 'buy' or 'sell'. This argument is NOT case-sensitive. Here are four examples that will work:

" + + "limitbuy, limitsell, stopbuy, stopsell

" + + "The last argument, 'pos', is a string that specifies whether the order is a 'Long' or 'Short' position. The values 'L' and " + + "'S' can also be used. This argument is NOT case-sensitive.

" + + "Returns true if the order is successfully placed, and false otherwise.

" + + "cancelOrder(sym, shares, price, type, pos)
" + + "Cancels an oustanding order on the stock market. In order to use this function the player must be in BitNode-8 or must have " + + "Level 3 of Source-File 8. This function uses the same arguments as placeOrder()

" + "

While loops


" + "A while loop is a control flow statement that repeatedly executes code as long as a condition is met.

" + "while ([cond]) {
    [code]
}


" + @@ -3364,7 +3401,7 @@ let CONSTANTS = { "then you will be able to access all of the Singularity Functions.

" + "Note that Singularity Functions require a lot of RAM outside of BitNode-4 (their RAM costs are multiplied by " + "10 if you are not in BitNode-4).

" + - "universityCourse(universityName, courseName)
" + + "universityCourse(universityName, courseName)
" + "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.

" + "This function will automatically set you to start taking a course at a university. If you are already " + "in the middle of some 'working' action (such as working at a company, for a faction, or on a program), " + @@ -3378,7 +3415,7 @@ let CONSTANTS = { "The cost and experience gains for all of these universities and classes are the same as if you were to manually " + "visit and take these classes.

" + "This function will return true if you successfully start taking the course, and false otherwise.

" + - "gymWorkout(gymName, stat)
" + + "gymWorkout(gymName, stat)
" + "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.

" + "This function will automatically set you to start working out at a gym to train a particular stat. If you are " + "already in the middle of some 'working' action (such as working at a company, for a faction, or on a program), then " + @@ -3390,18 +3427,18 @@ let CONSTANTS = { "The valid stats are:

strength OR str
defense OR def
dexterity OR dex
agility OR agi

" + "The cost and experience gains for all of these gyms are the same as if you were to manually visit these gyms and train " + "This function will return true if you successfully start working out at the gym, and false otherwise.

" + - "travelToCity(cityname)
" + + "travelToCity(cityname)
" + "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.

" + "This function allows the player to travel to any city. The cost for using this function is the same as the cost for traveling through the Travel Agency.

" + "The argument passed into this must be a string with the name of the city to travel to. Note that this argument IS CASE SENSITIVE. The valid cities are:

" + "Aevum
Chongqing
Sector-12
New Tokyo
Ishima
Volhaven

" + "This function will return true if you successfully travel to the specified city and false otherwise.

" + - "purchaseTor()
" + + "purchaseTor()
" + "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.

" + "This function allows you to automatically purchase a TOR router. The cost for purchasing a TOR router using this " + "function is the same as if you were to manually purchase one.

" + "This function will return true if it successfully purchase a TOR router and false otherwise.

" + - "purchaseProgram(programName)
" + + "purchaseProgram(programName)
" + "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.

" + "This function allows you to automatically purchase programs. You MUST have a TOR router in order to use this function.

" + "The argument passed in must be a string with the name of the program (including the '.exe' extension). This argument is " + @@ -3410,29 +3447,29 @@ let CONSTANTS = { "The cost of purchasing programs using this function is the same as if you were purchasing them through the Dark Web (using " + "the buy Terminal command).

" + "This function will return true if the specified program is purchased, and false otherwise.

" + - "getStats()
If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to run this " + + "getStats()
If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to run this " + "function.

Returns an object with the Player's stats. The object has the following properties:

" + "Player.hacking
Player.strength
Player.defense
Player.dexterity
Player.agility
Player.charisma
Player.intelligence

" + "Example:

" + "res = getStats();
print('My charisma level is: ' + res.charisma);

" + - "isBusy()
If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to run this " + + "isBusy()
If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to run this " + "function.

Returns a boolean indicating whether or not the player is currently performing an 'action'. " + "These actions include working for a company/faction, studying at a univeristy, working out at a gym, " + "creating a program, or committing a crime.

" + - "upgradeHomeRam()
" + + "upgradeHomeRam()
" + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

" + "This function will upgrade amount of RAM on the player's home computer. The cost is the same as if you were to do it manually.

" + "This function will return true if the player's home computer RAM is successfully upgraded, and false otherwise.

" + - "getUpgradeHomeRamCost()
" + + "getUpgradeHomeRamCost()
" + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

" + "Returns the cost of upgrading the player's home computer RAM.

" + - "workForCompany()
" + + "workForCompany()
" + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

" + "This function will automatically set you to start working at the company at which you are employed. If you are already " + "in the middle of some 'working' action (such as working for a faction, training at a gym, or creating a program), then " + "running this function will automatically cancel that action and give you your earnings.

" + "This function will return true if the player starts working, and false otherwise.

" + - "applyToCompany(companyName, field)
" + + "applyToCompany(companyName, field)
" + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

" + "This function will automatically try to apply to the specified company for a position in the specified field. This " + "function can also be used to apply for promotions by specifying the company and field you are already employed at.

" + @@ -3443,19 +3480,19 @@ let CONSTANTS = { "security
agent
employee
part-time employee
waiter
part-time waiter

" + "This function will return true if you successfully get a job/promotion, and false otherwise. Note " + "that if you are trying to use this function to apply for a promotion and you don't get one, it will return false.

" + - "getCompanyRep(companyName)
" + + "getCompanyRep(companyName)
" + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

" + "This function will return the amount of reputation you have at the specified company. If the company passed in as " + "an argument is invalid, -1 will be returned.

" + "The argument passed in must be a string with the name of the company. This argument IS CASE-SENSITIVE.

" + - "checkFactionInvitations()
" + + "checkFactionInvitations()
" + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

" + "Returns an array with the name of all Factions you currently have oustanding invitations from.

" + - "joinFaction(name)
" + + "joinFaction(name)
" + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

" + "This function will automatically accept an invitation from a faction and join it.

" + "The argument must be a string with the name of the faction. This name IS CASE-SENSITIVE.

" + - "workForFaction(factionName, workType)
" + + "workForFaction(factionName, workType)
" + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

" + "This function will automatically set you to start working for the specified Faction. Obviously, you " + "must be a member of the Faction or else this function will fail. If you are already in the middle of " + @@ -3465,11 +3502,11 @@ let CONSTANTS = { "must be a string with the type of work you want to perform for the faction. The valid values for this argument are:

" + "
hacking/hacking contracts/hackingcontracts
field/fieldwork/field work
security/securitywork/security work

" + "This function will return true if you successfully start working for the specified faction, and false otherwise.

" + - "getFactionRep(factionName)
" + + "getFactionRep(factionName)
" + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

" + "This function returns the amount of reputation you have for the specified Faction. The argument must be a " + "string with the name of the Faction. The argument IS CASE-SENSITIVE.

" + - "createProgram(programName)
" + + "createProgram(programName)
" + "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.

" + "This function will automatically set you to start working on creating the specified program. If you are already in " + "the middle of some 'working' action (such as working for a company, training at a gym, or taking a course), then " + @@ -3480,7 +3517,7 @@ let CONSTANTS = { "BruteSSH.exe: 50
FTPCrack.exe: 100
relaySMTP.exe: 250
HTTPWorm.exe: 500
SQLInject.exe: 750
" + "DeepscanV1.exe: 75
DeepscanV2.exe: 400
ServerProfiler.exe: 75
AutoLink.exe: 25

" + "This function returns true if you successfully start working on the specified program, and false otherwise.

" + - "commitCrime(crime)
" + + "commitCrime(crime)
" + "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.

" + "This function is used to automatically attempt to commit crimes. If you are already in the middle of some 'working' " + "action (such as working for a company or training at a gym), then running this function will automatically cancel " + @@ -3489,40 +3526,41 @@ let CONSTANTS = { "lenient in terms of what inputs it accepts. Here is a list of valid inputs for all of the crimes:

" + "shoplift, rob store, mug, larceny, deal drugs, bond forgery, traffick arms, homicide, grand theft auto, " + "kidnap, assassinate, heist

" + + "Crimes committed using this function will have all of their earnings halved (this applies for both money and experience!)

" + "This function returns the number of seconds it takes to attempt the specified crime (e.g It takes 60 seconds to attempt " + "the 'Rob Store' crime, so running commitCrime('rob store') will return 60). Warning: I do not recommend using the time " + "returned from this function to try and schedule your crime attempts. Instead, I would use the isBusy() Singularity function " + "to check whether you have finished attempting a crime. This is because although the game sets a certain crime to be X amount of seconds, " + "there is no guarantee that your browser will follow that time limit.

" + - "getCrimeChance(crime)
If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to " + + "getCrimeChance(crime)
If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to " + "use this function.

" + "This function returns your chance of success at commiting the specified crime. The chance is returned as a decimal " + "(i.e. 60% would be returned as 0.6). The argument for this function is a string. It is not case-sensitive and is fairly " + "lenient in terms of what inputs it accepts. Check the documentation for the commitCrime() Singularity Function to see " + "examples of valid inputs.

" + - "getOwnedAugmentations(purchased=false)
" + + "getOwnedAugmentations(purchased=false)
" + "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.

" + "This function returns an array of the names of all Augmentations you own as strings. It takes a single optional " + "boolean argument that specifies whether the returned array should include Augmentations you have purchased " + "but not yet installed. If it is true, then the returned array will include these Augmentations. By default, " + "this argument is false.

" + - "getAugmentationsFromFaction(facName)
" + + "getAugmentationsFromFaction(facName)
" + "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.

" + "Returns an array containing the names (as strings) of all Augmentations that are available from the specified faction. " + "The argument must be a string with the faction's name. This argument is case-sensitive.

" + - "getAugmentationCost(augName)
" + + "getAugmentationCost(augName)
" + "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.

" + "This function returns an array with two elements that gives the cost for the specified Augmentation" + ". The first element in the returned array is the reputation requirement of the Augmentation, and the second element " + "is the money cost.

" + "The argument passed in must be a string with the name of the Augmentation. This argument IS CASE-SENSITIVE. " + "If an invalid Augmentation name is passed in, this function will return the array [-1, -1].

" + - "purchaseAugmentation(factionName, augName)
" + + "purchaseAugmentation(factionName, augName)
" + "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.

" + "This function will try to purchase the specified Augmentation through the given Faction.

" + "The two arguments must be strings specifying the name of the Faction and Augmentation, respectively. These arguments are both CASE-SENSITIVE.

" + "This function will return true if the Augmentation is successfully purchased, and false otherwise.

" + - "installAugmentations(cbScript)
" + + "installAugmentations(cbScript)
" + "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.

" + "This function will automatically install your Augmentations, resetting the game as usual.

" + "It will return true if successful, and false otherwise.

" + @@ -3629,27 +3667,10 @@ let CONSTANTS = { "World Stock Exchange account and TIX API Access
", LatestUpdate: - "v0.31.0
" + - "-Game now saves to IndexedDb (if your browser supports it). This means you should " + - "no longer have trouble saving the game when your save file gets too big (from running " + - "too many scripts). " + - "The game will still be saved to localStorage as well
" + - "-New file type: text files (.txt). You can read or write to text files using the read()/write() Netscript commands. " + - "You can view text files in Terminal using 'cat'. Eventually I will make it so you can edit them in the editor " + - "but that's not available yet. You can also download files to your real computer using the 'download' Terminal command
" + - "-Added a new Crime: Bond Forgery. This crime takes 5 minutes to attempt " + - "and gives $4,500,000 if successful. It is meant for mid game.
" + - "-Added commitCrime(), getCrimeChance(), isBusy(), and getStats() Singularity Functions.
" + - "-Removed getIntelligence() Netscript function
" + - "-Added sprintf and vsprintf to Netscript. See this Github page for details
" + - "-Increased the amount of money gained from Infiltration by 20%, and the amount of faction reputation by 12%
" + - "-Rebalanced BitNode-2 so that Crime and Infiltration are more profitable but hacking is less profitable. Infiltration also gives more faction rep
" + - "-Rebalanced BitNode-4 so that hacking is slightly less profitable
" + - "-Rebalanced BitNode-5 so that Infiltration is more profitable and gives more faction rep
" + - "-Rebalanced BitNode-11 so that Crime and Infiltration are more profitable. Infiltration also gives more faction rep.
" + - "-Fixed an annoying issue in Hacking Missions where sometimes you would click a Node but it wouldnt actually get selected
" + - "-Made the Hacking Mission gameplay a bit slower by lowering the effect of Scan and reducing Attack damage
" + - "-Slightly increased the base reputation gain rate for factions when doing Field Work and Security Work
" + "v0.32.0
" + + "-Released BitNode-8: Ghost of Wall Street
" + + "-Re-designed Stock Market UI
" + + "-Minor bugfixes
" } @@ -4214,8 +4235,8 @@ let Engine = { loadStockMarketContent: function() { Engine.hideAllContent(); Engine.Display.stockMarketContent.style.visibility = "visible"; - Object(__WEBPACK_IMPORTED_MODULE_31__StockMarket_js__["c" /* displayStockMarketContent */])(); Engine.currentPage = Engine.Page.StockMarket; + Object(__WEBPACK_IMPORTED_MODULE_31__StockMarket_js__["f" /* displayStockMarketContent */])(); }, loadGangContent: function() { @@ -4820,15 +4841,14 @@ let Engine = { if (Engine.Counters.stockTick <= 0) { if (__WEBPACK_IMPORTED_MODULE_22__Player_js__["a" /* Player */].hasWseAccount) { - Object(__WEBPACK_IMPORTED_MODULE_31__StockMarket_js__["k" /* updateStockPrices */])(); + Object(__WEBPACK_IMPORTED_MODULE_31__StockMarket_js__["q" /* updateStockPrices */])(); } Engine.Counters.stockTick = 30; } if (Engine.Counters.sCr <= 0) { - //Assume 4Sig will always indicate state of market if (__WEBPACK_IMPORTED_MODULE_22__Player_js__["a" /* Player */].hasWseAccount) { - Object(__WEBPACK_IMPORTED_MODULE_31__StockMarket_js__["i" /* stockMarketCycle */])(); + Object(__WEBPACK_IMPORTED_MODULE_31__StockMarket_js__["o" /* stockMarketCycle */])(); } Engine.Counters.sCr = 1500; } @@ -4977,9 +4997,9 @@ let Engine = { __WEBPACK_IMPORTED_MODULE_9__Company_js__["d" /* CompanyPositions */].init(); Object(__WEBPACK_IMPORTED_MODULE_7__Augmentations_js__["g" /* initAugmentations */])(); //Also calls Player.reapplyAllAugmentations() __WEBPACK_IMPORTED_MODULE_22__Player_js__["a" /* Player */].reapplyAllSourceFiles(); - Object(__WEBPACK_IMPORTED_MODULE_31__StockMarket_js__["e" /* initStockSymbols */])(); + Object(__WEBPACK_IMPORTED_MODULE_31__StockMarket_js__["h" /* initStockSymbols */])(); if (__WEBPACK_IMPORTED_MODULE_22__Player_js__["a" /* Player */].hasWseAccount) { - Object(__WEBPACK_IMPORTED_MODULE_31__StockMarket_js__["f" /* initSymbolToStockMap */])(); + Object(__WEBPACK_IMPORTED_MODULE_31__StockMarket_js__["i" /* initSymbolToStockMap */])(); } Object(__WEBPACK_IMPORTED_MODULE_17__Literature_js__["a" /* initLiterature */])(); Object(__WEBPACK_IMPORTED_MODULE_20__NetscriptFunctions_js__["e" /* initSingularitySFFlags */])(); @@ -5065,7 +5085,7 @@ let Engine = { __WEBPACK_IMPORTED_MODULE_9__Company_js__["d" /* CompanyPositions */].init(); Object(__WEBPACK_IMPORTED_MODULE_7__Augmentations_js__["g" /* initAugmentations */])(); Object(__WEBPACK_IMPORTED_MODULE_18__Message_js__["d" /* initMessages */])(); - Object(__WEBPACK_IMPORTED_MODULE_31__StockMarket_js__["e" /* initStockSymbols */])(); + Object(__WEBPACK_IMPORTED_MODULE_31__StockMarket_js__["h" /* initStockSymbols */])(); Object(__WEBPACK_IMPORTED_MODULE_17__Literature_js__["a" /* initLiterature */])(); Object(__WEBPACK_IMPORTED_MODULE_20__NetscriptFunctions_js__["e" /* initSingularitySFFlags */])(); @@ -6464,7 +6484,21 @@ function initBitNodes() { "Level 3: 7%"); BitNodes["BitNode6"] = new BitNode(6, "Do Androids Dream?", "COMING SOON"); //Build androids for automation BitNodes["BitNode7"] = new BitNode(7, "Waste Runner", "COMING SOON"); //Postapocalyptic wasteland + blade runner - BitNodes["BitNode8"] = new BitNode(8, "Ghost of Wall Street", "COMING SOON"); //Trading only viable strategy + BitNodes["BitNode8"] = new BitNode(8, "Ghost of Wall Street", "Money never sleeps", + "You are trying to make a name for yourself as an up-and-coming hedge fund manager on Wall Street.

" + + "In this BitNode:

" + + "You start with $100 million
" + + "The only way to earn money is by trading on the stock market
" + + "You start with a WSE membership and access to the TIX API
" + + "You are able to short stocks and place different types of orders (limit/stop)
" + + "You can immediately donate to factions to gain reputation

" + + "Destroying this BitNode will give you Source-File 8, or if you already have this Source-File it will " + + "upgrade its level up to a maximum of 3. This Source-File grants the following benefits:

" + + "Level 1: Permanent access to WSE and TIX API
" + + "Level 2: Ability to short stocks in other BitNodes
" + + "Level 3: Ability to use limit/stop orders in other BitNodes

" + + "This Source-File also increases your hacking growth multipliers by: " + + "
Level 1: 8%
Level 2: 12%
Level 3: 14%"); BitNodes["BitNode9"] = new BitNode(9, "Hacktocracy", "COMING SOON"); //Healthy Hacknet balancing mechanic BitNodes["BitNode10"] = new BitNode(10, "MegaCorp", "COMING SOON"); //Not sure yet BitNodes["BitNode11"] = new BitNode(11, "The Big Crash", "Okay. Sell it all.", @@ -6535,6 +6569,7 @@ let BitNodeMultipliers = { FactionWorkRepGain: 1, FactionPassiveRepGain: 1, + RepToDonateToFaction: 1, AugmentationRepCost: 1, AugmentationMoneyCost: 1, @@ -6590,6 +6625,15 @@ function initBitNodeMultipliers() { BitNodeMultipliers.AugmentationMoneyCost = 2; BitNodeMultipliers.HackExpGain = 0.5; break; + case 8: //Ghost of Wall Street + BitNodeMultipliers.ScriptHackMoney = 0; + BitNodeMultipliers.ManualHackMoney = 0; + BitNodeMultipliers.CompanyWorkMoney = 0; + BitNodeMultipliers.CrimeMoney = 0; + BitNodeMultipliers.HacknetNodeMoney = 0; + BitNodeMultipliers.InfiltrationMoney = 0; + BitNodeMultipliers.RepToDonateToFaction = 0 + break; case 11: //The Big Crash BitNodeMultipliers.ServerMaxMoney = 0.1; BitNodeMultipliers.ServerStartingMoney = 0.1; @@ -17587,7 +17631,7 @@ function displayFactionContent(factionName) { } if (faction.isMember) { - if (faction.favor >= 150) { + if (faction.favor >= (150 * __WEBPACK_IMPORTED_MODULE_1__BitNode_js__["a" /* BitNodeMultipliers */].RepToDonateToFaction)) { donateDiv.style.display = "inline"; } else { donateDiv.style.display = "none"; @@ -21047,7 +21091,11 @@ function calculateRamUsage(codeCopy) { var scriptGetStockCount = Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "getStockPrice(") + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "getStockPosition("); var scriptBuySellStockCount = Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "buyStock(") + - Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "sellStock("); + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "sellStock(") + + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "shortStock(") + + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "sellShort(") + + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "placeOrder(") + + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "cancelOrder("); var scriptPurchaseServerCount = Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "purchaseServer(") + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "deleteServer(") + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "getPurchasedServers("); @@ -21068,7 +21116,8 @@ function calculateRamUsage(codeCopy) { Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "travelToCity(") + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "purchaseTor(") + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "purchaseProgram(") + - Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "getStats("); + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "getStats(") + + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "isBusy("); var singFn2Count = Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "upgradeHomeRam(") + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "getUpgradeHomeRamCost(") + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "workForCompany(") + @@ -21080,6 +21129,7 @@ function calculateRamUsage(codeCopy) { Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "getFactionRep("); var singFn3Count = Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "createProgram(") + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "commitCrime(") + + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "getCrimeChance(") + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "getOwnedAugmentations(") + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "getAugmentationsFromFaction(") + Object(__WEBPACK_IMPORTED_MODULE_11__utils_StringHelperFunctions_js__["h" /* numOccurrences */])(codeCopy, "getAugmentationCost(") + @@ -22324,7 +22374,7 @@ function NetscriptFunctions(workerScript) { if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use getStockPrice()"); } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* SymbolToStockMap */][symbol]; + var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; if (stock == null) { throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); } @@ -22334,21 +22384,21 @@ function NetscriptFunctions(workerScript) { if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use getStockPosition()"); } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* SymbolToStockMap */][symbol]; + var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; if (stock == null) { throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); } - return [stock.playerShares, stock.playerAvgPx]; + return [stock.playerShares, stock.playerAvgPx, stock.playerShortShares, stock.playerAvgShortPx]; }, buyStock : function(symbol, shares) { if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use buyStock()"); } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* SymbolToStockMap */][symbol]; + var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; if (stock == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into buyStock()"); } - if (stock == null || shares < 0 || isNaN(shares)) { + if (shares < 0 || isNaN(shares)) { workerScript.scriptRef.log("Error: Invalid 'shares' argument passed to buyStock()"); return false; } @@ -22369,7 +22419,7 @@ function NetscriptFunctions(workerScript) { stock.playerShares += shares; stock.playerAvgPx = newTotal / stock.playerShares; if (__WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].Page.StockMarket) { - Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["j" /* updateStockPlayerPosition */])(stock); + Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["p" /* updateStockPlayerPosition */])(stock); } workerScript.scriptRef.log("Bought " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share"); @@ -22379,12 +22429,11 @@ function NetscriptFunctions(workerScript) { if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use sellStock()"); } - var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* SymbolToStockMap */][symbol]; + var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; if (stock == null) { - throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into getStockPrice()"); + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "Invalid stock symbol passed into sellStock()"); } - - if (stock == null || shares < 0 || isNaN(shares)) { + if (shares < 0 || isNaN(shares)) { workerScript.scriptRef.log("Error: Invalid 'shares' argument passed to sellStock()"); return false; } @@ -22405,13 +22454,128 @@ function NetscriptFunctions(workerScript) { stock.playerAvgPx = 0; } if (__WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].currentPage == __WEBPACK_IMPORTED_MODULE_8__engine_js__["Engine"].Page.StockMarket) { - Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["j" /* updateStockPlayerPosition */])(stock); + Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["p" /* updateStockPlayerPosition */])(stock); } workerScript.scriptRef.log("Sold " + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shares, 0) + " shares of " + stock.symbol + " at $" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2) + " per share. Gained " + "$" + Object(__WEBPACK_IMPORTED_MODULE_28__utils_StringHelperFunctions_js__["c" /* formatNumber */])(gains, 2)); return true; }, + shortStock(symbol, shares) { + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use shortStock()"); + } + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN !== 8) { + if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Cannot use shortStock(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8"); + } + } + var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; + if (stock == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid stock symbol passed into shortStock()"); + } + return Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["n" /* shortStock */])(stock, shares, workerScript); + }, + sellShort(symbol, shares) { + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use sellShort()"); + } + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN !== 8) { + if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Cannot use sellShort(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8"); + } + } + var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; + if (stock == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid stock symbol passed into sellShort()"); + } + return Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["l" /* sellShort */])(stock, shares, workerScript); + }, + placeOrder(symbol, shares, price, type, pos) { + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use placeOrder()"); + } + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN !== 8) { + if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Cannot use placeOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8"); + } + } + var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; + if (stock == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid stock symbol passed into placeOrder()"); + } + var orderType, orderPos; + type = type.toLowerCase(); + if (type.includes("limit") && type.includes("buy")) { + orderType = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["a" /* OrderTypes */].LimitBuy; + } else if (type.includes("limit") && type.includes("sell")) { + orderType = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["a" /* OrderTypes */].LimitSell; + } else if (type.includes("stop") && type.includes("buy")) { + orderType = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["a" /* OrderTypes */].StopBuy; + } else if (type.includes("stop") && type.includes("sell")) { + orderType = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["a" /* OrderTypes */].StopSell; + } else { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid Order Type passed into placeOrder()"); + } + + pos = pos.toLowerCase(); + if (pos.includes("l")) { + orderPos = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* PositionTypes */].Long; + } else if (pos.includes('s')) { + orderPos = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* PositionTypes */].Short; + } else { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid Position Type passed into placeOrder()"); + } + + return Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["k" /* placeOrder */])(stock, shares, price, orderType, orderPos, workerScript); + }, + cancelOrder(symbol, shares, price, type, pos) { + if (!__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].hasTixApiAccess) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "You don't have TIX API Access! Cannot use cancelOrder()"); + } + if (__WEBPACK_IMPORTED_MODULE_13__Player_js__["a" /* Player */].bitNodeN !== 8) { + if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Cannot use cancelOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8"); + } + } + var stock = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["d" /* SymbolToStockMap */][symbol]; + if (stock == null) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid stock symbol passed into cancelOrder()"); + } + if (isNaN(shares) || isNaN(price)) { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid shares or price argument passed into cancelOrder(). Must be numeric"); + } + var orderType, orderPos; + type = type.toLowerCase(); + if (type.includes("limit") && type.includes("buy")) { + orderType = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["a" /* OrderTypes */].LimitBuy; + } else if (type.includes("limit") && type.includes("sell")) { + orderType = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["a" /* OrderTypes */].LimitSell; + } else if (type.includes("stop") && type.includes("buy")) { + orderType = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["a" /* OrderTypes */].StopBuy; + } else if (type.includes("stop") && type.includes("sell")) { + orderType = OrderType.StopSell; + } else { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid Order Type passed into placeOrder()"); + } + + pos = pos.toLowerCase(); + if (pos.includes("l")) { + orderPos = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* PositionTypes */].Long; + } else if (pos.includes('s')) { + orderPos = __WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["b" /* PositionTypes */].Short; + } else { + throw Object(__WEBPACK_IMPORTED_MODULE_22__NetscriptEvaluator_js__["c" /* makeRuntimeRejectMsg */])(workerScript, "ERROR: Invalid Position Type passed into placeOrder()"); + } + params = { + stock: stock, + shares: shares, + price: price, + type: orderType, + pos: orderPos + }; + return Object(__WEBPACK_IMPORTED_MODULE_18__StockMarket_js__["e" /* cancelOrder */])(params, workerScript); + }, purchaseServer : function(hostname, ram) { var hostnameStr = String(hostname); hostnameStr = hostnameStr.replace(/\s\s+/g, ''); @@ -34757,24 +34921,28 @@ var __WEBPACK_AMD_DEFINE_RESULT__;/*! decimal.js v7.2.3 https://github.com/MikeM /***/ (function(module, __webpack_exports__, __webpack_require__) { "use strict"; -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return StockMarket; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return StockMarket; }); /* unused harmony export StockSymbols */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return SymbolToStockMap; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return initStockSymbols; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return initStockMarket; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return initSymbolToStockMap; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return stockMarketCycle; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return SymbolToStockMap; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return initStockSymbols; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return initStockMarket; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return initSymbolToStockMap; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return stockMarketCycle; }); /* unused harmony export buyStock */ /* unused harmony export sellStock */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return updateStockPrices; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return displayStockMarketContent; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return shortStock; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return sellShort; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return updateStockPrices; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return displayStockMarketContent; }); /* unused harmony export updateStockTicker */ -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return updateStockPlayerPosition; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return loadStockMarket; }); -/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return setStockMarketContentCreated; }); -/* unused harmony export placeOrder */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return updateStockPlayerPosition; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return loadStockMarket; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return setStockMarketContentCreated; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return placeOrder; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return cancelOrder; }); /* unused harmony export Order */ -/* unused harmony export OrderTypes */ +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return OrderTypes; }); +/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return PositionTypes; }); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_0__Constants_js__ = __webpack_require__(3); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_1__engine_js__ = __webpack_require__(5); /* harmony import */ var __WEBPACK_IMPORTED_MODULE_2__Location_js__ = __webpack_require__(13); @@ -34815,6 +34983,8 @@ function Stock(name, symbol, mv, b, otlkMag, initPrice=10000) { this.mv = mv; this.b = b; this.otlkMag = otlkMag; + + this.posTxtEl = null; } Stock.prototype.toJSON = function() { @@ -34842,8 +35012,12 @@ var PositionTypes = { function placeOrder(stock, shares, price, type, position, workerScript=null) { var tixApi = (workerScript instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]); var order = new Order(stock, shares, price, type, position); - if (isNaN(shares)) { - Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: Invalid number of shares specifies for order"); + if (isNaN(shares) || isNaN(price)) { + if (tixApi) { + workerScript.scriptRef.log("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument"); + } else { + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument"); + } return false; } if (StockMarket["Orders"] === null) { @@ -34857,24 +35031,71 @@ function placeOrder(stock, shares, price, type, position, workerScript=null) { } StockMarket["Orders"] = orders; } - StockMarket["Orders"].push(order); + StockMarket["Orders"][stock.symbol].push(order); //Process to see if it should be executed immediately processOrders(order.stock, order.type, order.pos); + updateStockOrderList(order.stock); return true; } +//Returns true if successfully cancels an order, false otherwise +function cancelOrder(params, workerScript=null) { + var tixApi = (workerScript instanceof __WEBPACK_IMPORTED_MODULE_4__NetscriptWorker_js__["b" /* WorkerScript */]); + if (StockMarket["Orders"] === null) {return false;} + if (params.order && params.order instanceof Order) { + var order = params.order; + //An 'Order' object is passed in + var stockOrders = StockMarket["Orders"][order.stock.symbol]; + for (var i = 0; i < stockOrders.length; ++i) { + if (order == stockOrders[i]) { + stockOrders.splice(i, 1); + updateStockOrderList(order.stock); + return true; + } + } + return false; + } else if (params.stock && params.shares && params.price && params.type && + params.pos && params.stock instanceof Stock) { + //Order properties are passed in. Need to look for the order + var stockOrders = StockMarket["Orders"][params.stock.symbol]; + var orderTxt = params.stock.symbol + " - " + params.shares + " @ " + + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(params.price).format('$0.000a'); + for (var i = 0; i < stockOrders.length; ++i) { + var order = stockOrders[i]; + if (params.shares === order.shares && + params.price === order.price && + params.type === order.type && + params.pos === order.pos) { + stockOrders.splice(i, 1); + updateStockOrderList(order.stock); + if (tixApi) { + workerScript.scriptRef.log("Successfully cancelled order: " + orderTxt); + } + return true; + } + } + if (tixApi) { + workerScript.scriptRef.log("Failed to cancel order: " + orderTxt); + } + return false; + } + return false; +} + function executeOrder(order) { var stock = order.stock; var orderBook = StockMarket["Orders"]; var stockOrders = orderBook[stock.symbol]; var res = true; + console.log("Executing the following order:"); + console.log(order); switch (order.type) { case OrderTypes.LimitBuy: case OrderTypes.StopBuy: if (order.pos === PositionTypes.Long) { res = buyStock(order.stock, order.shares) && res; } else if (order.pos === PositionTypes.Short) { - res = shortStock(oder.stock, order.shares) && res; + res = shortStock(order.stock, order.shares) && res; } break; case OrderTypes.LimitSell: @@ -34891,15 +35112,18 @@ function executeOrder(order) { for (var i = 0; i < stockOrders.length; ++i) { if (order == stockOrders[i]) { stockOrders.splice(i, 1); + updateStockOrderList(order.stock); return; } } console.log("ERROR: Could not find the following Order in Order Book: "); console.log(order); + } else { + console.log("Order failed to execute"); } } -function Order(stock, price, type, position) { +function Order(stock, shares, price, type, position) { this.stock = stock; this.shares = shares; this.price = price; @@ -35056,7 +35280,7 @@ function initStockMarket() { StockMarket[watchdog] = watchdogStk; var lexocorp = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenLexoCorp; - var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 3, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(5000, 7500)); + var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 6, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(5000, 7500)); StockMarket[lexocorp] = lexocorpStk; var rho = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumRhoConstruction; @@ -35064,15 +35288,15 @@ function initStockMarket() { StockMarket[rho] = rhoStk; var alpha = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].Sector12AlphaEnterprises; - var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.05, true, 2, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(5000, 7500)); + var alphaStk = new Stock(alpha, StockSymbols[alpha], 2, true, 10, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(5000, 7500)); StockMarket[alpha] = alphaStk; var syscore = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenSysCoreSecurities; - var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.25, true, 0, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(4000, 7000)) + var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.25, true, 2, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(4000, 7000)) StockMarket[syscore] = syscoreStk; var computek = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].VolhavenCompuTek; - var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 0, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(2000, 5000)); + var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 2, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(2000, 5000)); StockMarket[computek] = computekStk; var netlink = __WEBPACK_IMPORTED_MODULE_2__Location_js__["a" /* Locations */].AevumNetLinkTechnologies; @@ -35088,15 +35312,15 @@ function initStockMarket() { StockMarket[fns] = fnsStk; var sigmacosm = "Sigma Cosmetics"; - var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 0.9, true, 0, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(2000, 3000)); + var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 3, true, 0, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(2000, 3000)); StockMarket[sigmacosm] = sigmacosmStk; var joesguns = "Joes Guns"; - var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 1, true, 1, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(500, 1000)); + var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 4, true, 1, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(500, 1000)); StockMarket[joesguns] = joesgunsStk; var catalyst = "Catalyst Ventures"; - var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.25, true, 0, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(1000, 1500)); + var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.6, true, 20, Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["d" /* getRandomInt */])(500, 1000)); StockMarket[catalyst] = catalystStk; var microdyne = "Microdyne Technologies"; @@ -35137,8 +35361,8 @@ function stockMarketCycle() { for (var name in StockMarket) { if (StockMarket.hasOwnProperty(name)) { var stock = StockMarket[name]; - var thresh = 0.62; - if (stock.b) {thresh = 0.38;} + var thresh = 0.6; + if (stock.b) {thresh = 0.4;} if (Math.random() < thresh) { stock.b = !stock.b; } @@ -35295,8 +35519,8 @@ function updateStockPrices() { var v = Math.random(); for (var name in StockMarket) { if (StockMarket.hasOwnProperty(name)) { - if (!(stock instanceof Stock)) {continue;} var stock = StockMarket[name]; + if (!(stock instanceof Stock)) {continue;} var av = (v * stock.mv) / 100; if (isNaN(av)) {av = .02;} @@ -35451,6 +35675,51 @@ function displayStockMarketContent() { return false; }); + var investopediaButton = Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* clearEventListeners */])("stock-market-investopedia"); + investopediaButton.addEventListener("click", function() { + var txt = "When making a transaction on the stock market, there are two " + + "types of positions: Long and Short. A Long position is the typical " + + "scenario where you buy a stock and earn a profit if the price of that " + + "stock increases. Meanwhile, a Short position is the exact opposite. " + + "In a Short position you purchase shares of a stock and earn a profit " + + "if the price of that stock decreases. This is also called 'shorting' a stock.

" + + "NOTE: Shorting stocks is not available immediately, and must be unlocked later on in the game.

" + + "There are three different types of orders you can make to buy or sell " + + "stocks on the exchange: Market Order, Limit Order, and Stop Order. " + + "Note that Limit Orders and Stop Orders are not available immediately, and must be unlocked " + + "later on in the game.

" + + "When you place a Market Order to buy or sell a stock, the order executes " + + "immediately at whatever the current price of the stock is. For example " + + "if you choose to short a stock with 5000 shares using a Market Order, " + + "you immediately purchase those 5000 shares in a Short position at whatever " + + "the current market price is for that stock.

" + + "A Limit Order is an order that only executes under certain conditions. " + + "A Limit Order is used to buy or sell a stock at a specified price or better. " + + "For example, lets say you purchased a Long position of 100 shares of some stock " + + "at a price of $10 per share. You can place a Limit Order to sell those 100 shares " + + "at $50 or better. The Limit Order will execute when the price of the stock reaches a " + + "value of $50 or higher.

" + + "A Stop Order is the opposite of a Limit Order. It is used to buy or sell a stock " + + "at a specified price (before the price gets 'worse'). For example, lets say you purchased " + + "a Short position of 100 shares of some stock at a price of $100 per share. " + + "The current price of the stock is $80 (a profit of $20 per share). You can place a " + + "Stop Order to sell the Short position if the stock's price reaches $90 or higher. " + + "This can be used to lock in your profits and limit any losses.

" + + "Here is a summary of how each order works and when they execute:

" + + "In a LONG Position:

" + + "A Limit Order to buy will execute if the stock's price <= order's price
" + + "A Limit Order to sell will execute if the stock's price >= order's price
" + + "A Stop Order to buy will execute if the stock's price >= order's price
" + + "A Stop Order to sell will execute if the stock's price <= order's price

" + + "In a SHORT Position:

" + + "A Limit Order to buy will execute if the stock's price >= order's price
" + + "A Limit Order to sell will execute if the stock's price <= order's price
" + + "A Stop Order to buy will execute if the stock's price <= order's price
" + + "A Stop Order to sell will execute if the stock's price >= order's price."; + Object(__WEBPACK_IMPORTED_MODULE_6__utils_DialogBox_js__["a" /* dialogBoxCreate */])(txt); + return false; + }); + var stockList = document.getElementById("stock-market-list"); if (stockList == null) {return;} @@ -35487,8 +35756,9 @@ function displayStockMarketContent() { for (var name in StockMarket) { if (StockMarket.hasOwnProperty(name)) { var stock = StockMarket[name]; - updateStockTicker(stock, true); + updateStockTicker(stock, null); updateStockPlayerPosition(stock); + updateStockOrderList(stock); } } } @@ -35519,6 +35789,7 @@ function createStockTicker(stock) { orderList = document.createElement("ul"); qtyInput.classList.add("stock-market-input"); + qtyInput.placeholder = "Quantity (Shares)"; qtyInput.setAttribute("id", tickerId + "-qty-input"); qtyInput.setAttribute("onkeydown", "return ( event.ctrlKey || event.altKey " + " || (47{ var pos = longShortSelect.options[longShortSelect.selectedIndex].text; @@ -35562,13 +35834,13 @@ function createStockTicker(stock) { if (isNaN(shares)) {return false;} switch (ordType) { case "Market Order": - buyStock(stock, shares); + pos === PositionTypes.Long ? buyStock(stock, shares) : shortStock(stock, shares, null); break; case "Limit Order": case "Stop Order": var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), noBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); - yesBtn.innerText = "Place Buy" + ordType; + yesBtn.innerText = "Place Buy " + ordType; noBtn.innerText = "Cancel Order"; yesBtn.addEventListener("click", ()=>{ var price = Number(Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])()), type; @@ -35578,6 +35850,7 @@ function createStockTicker(stock) { type = OrderTypes.StopBuy; } placeOrder(stock, shares, price, type, pos); + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); }); noBtn.addEventListener("click", ()=>{ Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); @@ -35592,6 +35865,7 @@ function createStockTicker(stock) { }); sellButton.classList.add("stock-market-input"); + sellButton.classList.add("a-link-button"); sellButton.innerHTML = "Sell"; sellButton.addEventListener("click", ()=>{ var pos = longShortSelect.options[longShortSelect.selectedIndex].text; @@ -35601,13 +35875,13 @@ function createStockTicker(stock) { if (isNaN(shares)) {return false;} switch (ordType) { case "Market Order": - buyStock(stock, shares); + pos === PositionTypes.Long ? sellStock(stock, shares) : sellShort(stock, shares, null); break; case "Limit Order": case "Stop Order": var yesBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["j" /* yesNoTxtInpBoxGetYesButton */])(), noBtn = Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["i" /* yesNoTxtInpBoxGetNoButton */])(); - yesBtn.innerText = "Place Sell" + ordType; + yesBtn.innerText = "Place Sell " + ordType; noBtn.innerText = "Cancel Order"; yesBtn.addEventListener("click", ()=>{ var price = Number(Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["h" /* yesNoTxtInpBoxGetInput */])()), type; @@ -35616,11 +35890,13 @@ function createStockTicker(stock) { } else { type = OrderTypes.StopSell; } + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); placeOrder(stock, shares, price, type, pos); }); noBtn.addEventListener("click", ()=>{ Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["f" /* yesNoTxtInpBoxClose */])(); }); + Object(__WEBPACK_IMPORTED_MODULE_11__utils_YesNoBox_js__["g" /* yesNoTxtInpBoxCreate */])("Enter the price for your " + ordType); break; default: console.log("ERROR: Invalid order type"); @@ -35631,6 +35907,7 @@ function createStockTicker(stock) { positionTxt.setAttribute("id", tickerId + "-position-text"); positionTxt.classList.add("stock-market-position-text"); + stock.posTxtEl = positionTxt; orderList.setAttribute("id", tickerId + "-order-list"); orderList.classList.add("stock-market-order-list"); @@ -35648,6 +35925,7 @@ function createStockTicker(stock) { document.getElementById("stock-market-list").appendChild(li); updateStockTicker(stock, true); + updateStockOrderList(stock); } function setStockTickerClickHandlers() { @@ -35673,8 +35951,10 @@ function setStockTickerClickHandlers() { //'increase' argument is a boolean indicating whether the price increased or decreased function updateStockTicker(stock, increase) { + if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage !== __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.StockMarket) {return;} if (!(stock instanceof Stock)) { - console.log("Invalid stock in updateStockTicker()"); + console.log("Invalid stock in updateStockTicker():"); + console.log(stock); return; } var tickerId = "stock-market-ticker-" + stock.symbol; @@ -35684,8 +35964,10 @@ function updateStockTicker(stock, increase) { console.log("ERROR: Couldn't find ticker element for stock: " + stock.symbol); return; } - hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + stock.price; - increase ? hdr.style.color = "#66ff33" : hdr.style.color = "red"; + hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.price, 2); + if (increase !== null) { + increase ? hdr.style.color = "#66ff33" : hdr.style.color = "red"; + } if (stock.playerShares > 0 || stock.playerShortShares > 0) { updateStockPlayerPosition(stock); @@ -35693,13 +35975,17 @@ function updateStockTicker(stock, increase) { } function updateStockPlayerPosition(stock) { + if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage !== __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.StockMarket) {return;} if (!(stock instanceof Stock)) { - console.log("Invalid stock in updateStockTicker()"); + console.log("Invalid stock in updateStockPlayerPosition():"); + console.log(stock); return; } - var tickerId = "stock-market-ticker-" + stock.symbol, - positionTxt = document.getElementById(tickerId + "-position-text"); - if (positionTxt === null) { + var tickerId = "stock-market-ticker-" + stock.symbol; + if (!(stock.posTxtEl instanceof Element)) { + stock.posTxtEl = document.getElementById(tickerId + "-position-text"); + } + if (stock.posTxtEl === null) { console.log("ERROR: Could not find stock position element for: " + stock.symbol); return; } @@ -35708,29 +35994,39 @@ function updateStockPlayerPosition(stock) { var totalCost = stock.playerShares * stock.playerAvgPx, gains = (stock.price - stock.playerAvgPx) * stock.playerShares, percentageGains = gains / totalCost; + if (isNaN(percentageGains)) {percentageGains = 0;} var shortTotalCost = stock.playerShortShares * stock.playerAvgShortPx, shortGains = (stock.playerAvgShortPx - stock.price) * stock.playerShortShares, shortPercentageGains = shortGains/ shortTotalCost; + if (isNaN(shortPercentageGains)) {shortPercentageGains = 0;} - positionTxt.innerHTML = + stock.posTxtEl.innerHTML = "

Long Position: " + "Shares in the long position will increase " + "in value if the price of the corresponding stock increases

" + "
Shares: " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.playerShares, 0) + "
Average Price: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.playerAvgPx).format('$0.000a') + + " (Total Cost: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(totalCost).format('$0.000a') + ")" + "
Profit: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(gains).format('$0.000a') + - " (" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(percentageGains, 2) + "%)

" + - "

Short Position: " + - "Shares in short position will increase " + - "in value if the price of the corresponding stock decreases

" + - "
Shares: " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.playerShortShares, 0) + - "
Average Price: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.playerAvgShortPx).format('$0.000a') + - "
Profit: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(shortGains).format('$0.000a') + - " (" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shortPercentageGains, 2) + "%)"; + " (" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(percentageGains*100, 2) + "%)

"; + if (__WEBPACK_IMPORTED_MODULE_5__Player_js__["a" /* Player */].bitNodeN === 8 || (__WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["d" /* hasWallStreetSF */] && __WEBPACK_IMPORTED_MODULE_3__NetscriptFunctions_js__["f" /* wallStreetSFLvl */] >= 2)) { + stock.posTxtEl.innerHTML += + "

Short Position: " + + "Shares in short position will increase " + + "in value if the price of the corresponding stock decreases

" + + "
Shares: " + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(stock.playerShortShares, 0) + + "
Average Price: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(stock.playerAvgShortPx).format('$0.000a') + + " (Total Cost: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(shortTotalCost).format('$0.000a') + ")" + + "
Profit: " + __WEBPACK_IMPORTED_MODULE_9__utils_numeral_min_js___default()(shortGains).format('$0.000a') + + " (" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(shortPercentageGains*100, 2) + "%)" + + "

Orders:

"; + } + } function updateStockOrderList(stock) { + if (__WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].currentPage !== __WEBPACK_IMPORTED_MODULE_1__engine_js__["Engine"].Page.StockMarket) {return;} var tickerId = "stock-market-ticker-" + stock.symbol; var orderList = document.getElementById(tickerId + "-order-list"); if (orderList === null) { @@ -35745,7 +36041,7 @@ function updateStockOrderList(stock) { } var stockOrders = orderBook[stock.symbol]; if (stockOrders === null) { - console.log("ERROR: Could nto find orders for: " + stock.symbol); + console.log("ERROR: Could not find orders for: " + stock.symbol); return; } @@ -35755,12 +36051,27 @@ function updateStockOrderList(stock) { } for (var i = 0; i < stockOrders.length; ++i) { - var order = stockOrders[i]; - var li = document.createElement("li"); - var posText = (order.pos === PositionTypes.Long ? "Long Position" : "Short Position"); - li.innerText = order.type + " - " + posText + " - " + - order.shares + " @ $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(order.price, 2); - orderList.appendChild(li); + (function() { + var order = stockOrders[i]; + var li = document.createElement("li"); + li.style.padding = "4px"; + var posText = (order.pos === PositionTypes.Long ? "Long Position" : "Short Position"); + li.style.color = "white"; + li.innerText = order.type + " - " + posText + " - " + + order.shares + " @ $" + Object(__WEBPACK_IMPORTED_MODULE_10__utils_StringHelperFunctions_js__["c" /* formatNumber */])(order.price, 2); + + var cancelButton = document.createElement("span"); + cancelButton.classList.add("stock-market-order-cancel-btn"); + cancelButton.classList.add("a-link-button"); + cancelButton.innerHTML = "Cancel Order"; + cancelButton.addEventListener("click", function() { + cancelOrder({order: order}, null); + return false; + }); + li.appendChild(cancelButton); + orderList.appendChild(li); + }()); + } } @@ -39087,7 +39398,12 @@ function initSourceFiles() { "Level 3: 7%"); SourceFiles["SourceFile6"] = new SourceFile(6); SourceFiles["SourceFile7"] = new SourceFile(7); - SourceFiles["SourceFile8"] = new SourceFile(8); + SourceFiles["SourceFile8"] = new SourceFile(8, "This Source-File grants the following benefits:

" + + "Level 1: Permanent access to WSE and TIX API
" + + "Level 2: Ability to short stocks in other BitNodes
" + + "Level 3: Ability to use limit/stop orders in other BitNodes

" + + "This Source-File also increases your hacking growth multipliers by: " + + "
Level 1: 8%
Level 2: 12%
Level 3: 14%"); SourceFiles["SourceFile9"] = new SourceFile(9); SourceFiles["SourceFile10"] = new SourceFile(10); SourceFiles["SourceFile11"] = new SourceFile(11, "This Source-File makes it so that company favor increases BOTH the player's salary and reputation gain rate " + @@ -39174,6 +39490,14 @@ function applySourceFile(srcFile) { __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_mult *= incMult; __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_exp_mult *= incMult; break; + case 8: //Ghost of Wall Street + var mult = 0; + for (var i = 0; i < srcFile.lvl; ++i) { + mult += (8 / (Math.pow(2, i))); + } + var incMult = 1 + (mult / 100); + __WEBPACK_IMPORTED_MODULE_0__Player_js__["a" /* Player */].hacking_grow_mult *= incMult; + break; case 11: //The Big Crash var mult = 0; for (var i = 0; i < srcFile.lvl; ++i) { @@ -39310,9 +39634,9 @@ function prestigeAugmentation() { //Reset Stock market if (__WEBPACK_IMPORTED_MODULE_11__Player_js__["a" /* Player */].hasWseAccount) { - Object(__WEBPACK_IMPORTED_MODULE_14__StockMarket_js__["d" /* initStockMarket */])(); - Object(__WEBPACK_IMPORTED_MODULE_14__StockMarket_js__["f" /* initSymbolToStockMap */])(); - Object(__WEBPACK_IMPORTED_MODULE_14__StockMarket_js__["h" /* setStockMarketContentCreated */])(false); + Object(__WEBPACK_IMPORTED_MODULE_14__StockMarket_js__["g" /* initStockMarket */])(); + Object(__WEBPACK_IMPORTED_MODULE_14__StockMarket_js__["i" /* initSymbolToStockMap */])(); + Object(__WEBPACK_IMPORTED_MODULE_14__StockMarket_js__["m" /* setStockMarketContentCreated */])(false); var stockMarketList = document.getElementById("stock-market-list"); while(stockMarketList.firstChild) { stockMarketList.removeChild(stockMarketList.firstChild); @@ -39327,6 +39651,13 @@ function prestigeAugmentation() { } } + //BitNode 8: Ghost of Wall Street + if (__WEBPACK_IMPORTED_MODULE_11__Player_js__["a" /* Player */].bitNodeN === 8) {__WEBPACK_IMPORTED_MODULE_11__Player_js__["a" /* Player */].money = new __WEBPACK_IMPORTED_MODULE_16__utils_decimal_js___default.a(100000000);} + if (__WEBPACK_IMPORTED_MODULE_11__Player_js__["a" /* Player */].bitNodeN === 8 || __WEBPACK_IMPORTED_MODULE_9__NetscriptFunctions_js__["d" /* hasWallStreetSF */]) { + __WEBPACK_IMPORTED_MODULE_11__Player_js__["a" /* Player */].hasWseAccount = true; + __WEBPACK_IMPORTED_MODULE_11__Player_js__["a" /* Player */].hasTixApiAccess = true; + } + var mainMenu = document.getElementById("mainmenu-container"); mainMenu.style.visibility = "visible"; __WEBPACK_IMPORTED_MODULE_15__Terminal_js__["a" /* Terminal */].resetTerminalInput(); @@ -39668,7 +39999,7 @@ function loadBitVerse(destroyedBitNodeNum) { var elemId = "bitnode-" + i.toString(); var elem = Object(__WEBPACK_IMPORTED_MODULE_7__utils_HelperFunctions_js__["b" /* clearEventListeners */])(elemId); if (elem == null) {return;} - if (i === 1 || i === 2 || i === 4 || i === 5 || i === 11) { + if (i === 1 || i === 2 || i === 4 || i === 5 || i === 8 || i === 11) { elem.addEventListener("click", function() { var bitNodeKey = "BitNode" + i; var bitNode = __WEBPACK_IMPORTED_MODULE_0__BitNode_js__["b" /* BitNodes */][bitNodeKey]; @@ -45895,6 +46226,7 @@ TextFile.fromJSON = function(value) { __WEBPACK_IMPORTED_MODULE_2__utils_JSONReviver_js__["c" /* Reviver */].constructors.TextFile = TextFile; function getTextFile(fn, server) { + if (!fn.endsWith(".txt")) {fn += ".txt";} for (var i = 0; i < server.textFiles.length; ++i) { if (server.textFiles[i].fn === fn) { return server.textFiles[i]; @@ -45982,6 +46314,7 @@ function InfiltrationInstance(companyName, startLevel, val, maxClearance, diff) this.dexExpGained = 0; this.agiExpGained = 0; this.chaExpGained = 0; + this.intExpGained = 0; } InfiltrationInstance.prototype.gainHackingExp = function(amt) { @@ -46014,6 +46347,11 @@ InfiltrationInstance.prototype.gainCharismaExp = function(amt) { this.chaExpGained += amt; } +InfiltrationInstance.prototype.gainIntelligenceExp = function(amt) { + if (isNaN(amt)) {return;} + this.intExpGained += amt; +} + function beginInfiltration(companyName, startLevel, val, maxClearance, diff) { var inst = new InfiltrationInstance(companyName, startLevel, val, maxClearance, diff); clearInfiltrationStatusText(); @@ -46021,9 +46359,7 @@ function beginInfiltration(companyName, startLevel, val, maxClearance, diff) { } function endInfiltration(inst, success) { - if (success) { - Object(__WEBPACK_IMPORTED_MODULE_6__utils_InfiltrationBox_js__["a" /* infiltrationBoxCreate */])(inst); - } + if (success) {Object(__WEBPACK_IMPORTED_MODULE_6__utils_InfiltrationBox_js__["a" /* infiltrationBoxCreate */])(inst);} Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["b" /* clearEventListeners */])("infiltration-kill"); Object(__WEBPACK_IMPORTED_MODULE_5__utils_HelperFunctions_js__["b" /* clearEventListeners */])("infiltration-knockout"); @@ -46522,10 +46858,10 @@ let intWgt = __WEBPACK_IMPORTED_MODULE_1__Constants_js__["a" /* CONSTANTS */].In //Success: 5%, Failure 10%, -Karma function attemptInfiltrationKill(inst) { var chance = getInfiltrationKillChance(inst); - inst.gainStrengthExp(inst.securityLevel / 100) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].strength_exp_mult; - inst.gainDefenseExp(inst.securityLevel / 100) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].defense_exp_mult; - inst.gainDexterityExp(inst.securityLevel / 100) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].dexterity_exp_mult; - inst.gainAgilityExp(inst.securityLevel / 100) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].agility_exp_mult; + inst.gainStrengthExp(inst.securityLevel / 90) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].strength_exp_mult; + inst.gainDefenseExp(inst.securityLevel / 90) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].defense_exp_mult; + inst.gainDexterityExp(inst.securityLevel / 90) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].dexterity_exp_mult; + inst.gainAgilityExp(inst.securityLevel / 90) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].agility_exp_mult; if (Math.random() <= chance) { inst.securityLevel *= 1.05; return [true, 1.05]; @@ -46548,10 +46884,10 @@ function getInfiltrationKillChance(inst) { //Success: 3%, Failure: 10% function attemptInfiltrationKnockout(inst) { var chance = getInfiltrationKnockoutChance(inst); - inst.gainStrengthExp(inst.securityLevel / 100) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].strength_exp_mult; - inst.gainDefenseExp(inst.securityLevel / 100) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].defense_exp_mult; - inst.gainDexterityExp(inst.securityLevel / 100) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].dexterity_exp_mult; - inst.gainAgilityExp(inst.securityLevel / 100) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].agility_exp_mult; + inst.gainStrengthExp(inst.securityLevel / 85) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].strength_exp_mult; + inst.gainDefenseExp(inst.securityLevel / 85) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].defense_exp_mult; + inst.gainDexterityExp(inst.securityLevel / 85) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].dexterity_exp_mult; + inst.gainAgilityExp(inst.securityLevel / 85) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].agility_exp_mult; if (Math.random() <= chance) { inst.securityLevel *= 1.03; return [true, 1.03]; @@ -46573,9 +46909,9 @@ function getInfiltrationKnockoutChance(inst) { //Success: 0%, Failure: 10% function attemptInfiltrationStealthKnockout(inst) { var chance = getInfiltrationStealthKnockoutChance(inst); - inst.gainStrengthExp(inst.securityLevel / 100) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].strength_exp_mult; - inst.gainDexterityExp(inst.securityLevel / 75) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].dexterity_exp_mult; - inst.gainAgilityExp(inst.securityLevel / 75) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].agility_exp_mult; + inst.gainStrengthExp(inst.securityLevel / 90) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].strength_exp_mult; + inst.gainDexterityExp(inst.securityLevel / 70) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].dexterity_exp_mult; + inst.gainAgilityExp(inst.securityLevel / 70) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].agility_exp_mult; if (Math.random() <= chance) { return [true, 1]; } else { @@ -46597,9 +46933,9 @@ function getInfiltrationStealthKnockoutChance(inst) { //Success: 0%, Failure: 5%, -Karma function attemptInfiltrationAssassinate(inst) { var chance = getInfiltrationAssassinateChance(inst); - inst.gainStrengthExp(inst.securityLevel / 100) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].strength_exp_mult; - inst.gainDexterityExp(inst.securityLevel / 75) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].dexterity_exp_mult; - inst.gainAgilityExp(inst.securityLevel / 75) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].agility_exp_mult; + inst.gainStrengthExp(inst.securityLevel / 90) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].strength_exp_mult; + inst.gainDexterityExp(inst.securityLevel / 70) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].dexterity_exp_mult; + inst.gainAgilityExp(inst.securityLevel / 70) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].agility_exp_mult; if (Math.random() <= chance) { return [true, 1]; } else { @@ -46621,10 +46957,10 @@ function getInfiltrationAssassinateChance(inst) { //Success: 5%, Failure: 10% function attemptInfiltrationDestroySecurity(inst) { var chance = getInfiltrationDestroySecurityChance(inst); - inst.gainStrengthExp(inst.securityLevel / 100) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].strength_exp_mult; - inst.gainDefenseExp(inst.securityLevel / 100) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].defense_exp_mult; - inst.gainDexterityExp(inst.securityLevel / 100) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].dexterity_exp_mult; - inst.gainAgilityExp(inst.securityLevel / 100) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].agility_exp_mult; + inst.gainStrengthExp(inst.securityLevel / 90) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].strength_exp_mult; + inst.gainDefenseExp(inst.securityLevel / 90) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].defense_exp_mult; + inst.gainDexterityExp(inst.securityLevel / 90) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].dexterity_exp_mult; + inst.gainAgilityExp(inst.securityLevel / 90) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].agility_exp_mult; if (Math.random() <= chance) { inst.securityLevel *= 1.05; return [true, 1.05]; @@ -46648,7 +46984,8 @@ function getInfiltrationDestroySecurityChance(inst) { //Success: 1%, Failure: 5% function attemptInfiltrationHack(inst) { var chance = getInfiltrationHackChance(inst); - inst.gainHackingExp(inst.securityLevel / 75) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_exp_mult; + inst.gainHackingExp(inst.securityLevel / 50) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].hacking_exp_mult; + inst.gainIntelligenceExp(inst.securityLevel / 700); if (Math.random() <= chance) { inst.securityLevel *= 1.03; return [true, 1.03]; @@ -46670,7 +47007,7 @@ function getInfiltrationHackChance(inst) { //Success: 0%, Failure: 8% function attemptInfiltrationSneak(inst) { var chance = getInfiltrationSneakChance(inst); - inst.gainAgilityExp(inst.securityLevel / 75) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].agility_exp_mult; + inst.gainAgilityExp(inst.securityLevel / 50) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].agility_exp_mult; if (Math.random() <= chance) { return [true, 1]; } else { @@ -46691,7 +47028,7 @@ function getInfiltrationSneakChance(inst) { //Success: 1%, Failure: 3% function attemptInfiltrationPickLockedDoor(inst) { var chance = getInfiltrationPickLockedDoorChance(inst); - inst.gainDexterityExp(inst.securityLevel / 75) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].dexterity_exp_mult; + inst.gainDexterityExp(inst.securityLevel / 40) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].dexterity_exp_mult; if (Math.random() <= chance) { inst.securityLevel *= 1.01; return [true, 1.01]; @@ -46712,7 +47049,7 @@ function getInfiltrationPickLockedDoorChance(inst) { //Success: 0%, Failure: 15%, function attemptInfiltrationBribe(inst) { var chance = getInfiltrationBribeChance(inst); - inst.gainCharismaExp(inst.securityLevel / 50) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].charisma_exp_mult; + inst.gainCharismaExp(inst.securityLevel / 10) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].charisma_exp_mult; if (Math.random() <= chance) { return [true, 1]; } else { @@ -46731,8 +47068,8 @@ function getInfiltrationBribeChance(inst) { //Failure: 5% function attemptInfiltrationEscape(inst) { var chance = getInfiltrationEscapeChance(inst); - inst.gainAgilityExp(inst.securityLevel / 50) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].agility_exp_mult; - inst.gainDexterityExp(inst.securityLevel / 50) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].dexterity_exp_mult; + inst.gainAgilityExp(inst.securityLevel / 40) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].agility_exp_mult; + inst.gainDexterityExp(inst.securityLevel / 40) * __WEBPACK_IMPORTED_MODULE_3__Player_js__["a" /* Player */].dexterity_exp_mult; if (Math.random() <= chance) { return [true, 1]; } else { @@ -46798,6 +47135,7 @@ function infiltrationBoxCreate(inst) { __WEBPACK_IMPORTED_MODULE_3__src_Player_js__["a" /* Player */].gainDexterityExp(inst.dexExpGained); __WEBPACK_IMPORTED_MODULE_3__src_Player_js__["a" /* Player */].gainAgilityExp(inst.agiExpGained); __WEBPACK_IMPORTED_MODULE_3__src_Player_js__["a" /* Player */].gainCharismaExp(inst.chaExpGained); + __WEBPACK_IMPORTED_MODULE_3__src_Player_js__["a" /* Player */].gainIntelligenceExp(inst.intExpGained); var totalValue = 0; for (var i = 0; i < inst.secretsStolen.length; ++i) { @@ -92430,7 +92768,7 @@ BitburnerSaveObject.prototype.saveGame = function(db) { this.AliasesSave = JSON.stringify(__WEBPACK_IMPORTED_MODULE_0__Alias_js__["a" /* Aliases */]); this.GlobalAliasesSave = JSON.stringify(__WEBPACK_IMPORTED_MODULE_0__Alias_js__["b" /* GlobalAliases */]); this.MessagesSave = JSON.stringify(__WEBPACK_IMPORTED_MODULE_7__Message_js__["b" /* Messages */]); - this.StockMarketSave = JSON.stringify(__WEBPACK_IMPORTED_MODULE_13__StockMarket_js__["a" /* StockMarket */]); + this.StockMarketSave = JSON.stringify(__WEBPACK_IMPORTED_MODULE_13__StockMarket_js__["c" /* StockMarket */]); this.SettingsSave = JSON.stringify(__WEBPACK_IMPORTED_MODULE_11__Settings_js__["a" /* Settings */]); this.VersionSave = JSON.stringify(__WEBPACK_IMPORTED_MODULE_2__Constants_js__["a" /* CONSTANTS */].Version); if (__WEBPACK_IMPORTED_MODULE_8__Player_js__["a" /* Player */].bitNodeN == 2 && __WEBPACK_IMPORTED_MODULE_8__Player_js__["a" /* Player */].inGang()) { @@ -92447,13 +92785,15 @@ BitburnerSaveObject.prototype.saveGame = function(db) { } request.onsuccess = function(e) { - console.log("Successfully saved game to IndexedDB!"); + console.log("Saved game to IndexedDB!"); } try { window.localStorage.setItem("bitburnerSave", saveString); + console.log("Saved game to LocalStorage!"); } catch(e) { if (e.code == 22) { + __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].createStatusText("Save failed for localStorage! Check console(F12)"); console.log("Failed to save game to localStorage because the size of the save file " + "is too large. However, the game will still be saved to IndexedDb if your browser " + "supports it. If you would like to save to localStorage as well, then " + @@ -92462,7 +92802,6 @@ BitburnerSaveObject.prototype.saveGame = function(db) { } } - console.log("Game saved!"); __WEBPACK_IMPORTED_MODULE_3__engine_js__["Engine"].createStatusText("Game saved!"); } @@ -92516,12 +92855,12 @@ function loadGame(saveString) { } if (saveObj.hasOwnProperty("StockMarketSave")) { try { - Object(__WEBPACK_IMPORTED_MODULE_13__StockMarket_js__["g" /* loadStockMarket */])(saveObj.StockMarketSave); + Object(__WEBPACK_IMPORTED_MODULE_13__StockMarket_js__["j" /* loadStockMarket */])(saveObj.StockMarketSave); } catch(e) { - Object(__WEBPACK_IMPORTED_MODULE_13__StockMarket_js__["g" /* loadStockMarket */])(""); + Object(__WEBPACK_IMPORTED_MODULE_13__StockMarket_js__["j" /* loadStockMarket */])(""); } } else { - Object(__WEBPACK_IMPORTED_MODULE_13__StockMarket_js__["g" /* loadStockMarket */])(""); + Object(__WEBPACK_IMPORTED_MODULE_13__StockMarket_js__["j" /* loadStockMarket */])(""); } if (saveObj.hasOwnProperty("SettingsSave")) { try { @@ -92724,12 +93063,12 @@ function loadImportedGame(saveObj, saveString) { } if (saveObj.hasOwnProperty("StockMarketSave")) { try { - Object(__WEBPACK_IMPORTED_MODULE_13__StockMarket_js__["g" /* loadStockMarket */])(saveObj.StockMarketSave); + Object(__WEBPACK_IMPORTED_MODULE_13__StockMarket_js__["j" /* loadStockMarket */])(saveObj.StockMarketSave); } catch(e) { - Object(__WEBPACK_IMPORTED_MODULE_13__StockMarket_js__["g" /* loadStockMarket */])(""); + Object(__WEBPACK_IMPORTED_MODULE_13__StockMarket_js__["j" /* loadStockMarket */])(""); } } else { - Object(__WEBPACK_IMPORTED_MODULE_13__StockMarket_js__["g" /* loadStockMarket */])(""); + Object(__WEBPACK_IMPORTED_MODULE_13__StockMarket_js__["j" /* loadStockMarket */])(""); } if (saveObj.hasOwnProperty("SettingsSave")) { try { diff --git a/index.html b/index.html index 918de6ca0..ca8496da0 100644 --- a/index.html +++ b/index.html @@ -781,9 +781,8 @@ If you purchase access to the TIX API, you will retain that access even after you 'reset' by installing Augmentations.

- - Buy Trade Information eXchange (TIX) API Access - COMING SOON - + Buy Trade Information eXchange (TIX) API Access - COMING SOON + Investopedia

    diff --git a/src/BitNode.js b/src/BitNode.js index de22d5d01..c7ba7ae08 100644 --- a/src/BitNode.js +++ b/src/BitNode.js @@ -77,7 +77,21 @@ function initBitNodes() { "Level 3: 7%"); BitNodes["BitNode6"] = new BitNode(6, "Do Androids Dream?", "COMING SOON"); //Build androids for automation BitNodes["BitNode7"] = new BitNode(7, "Waste Runner", "COMING SOON"); //Postapocalyptic wasteland + blade runner - BitNodes["BitNode8"] = new BitNode(8, "Ghost of Wall Street", "COMING SOON"); //Trading only viable strategy + BitNodes["BitNode8"] = new BitNode(8, "Ghost of Wall Street", "Money never sleeps", + "You are trying to make a name for yourself as an up-and-coming hedge fund manager on Wall Street.

    " + + "In this BitNode:

    " + + "You start with $100 million
    " + + "The only way to earn money is by trading on the stock market
    " + + "You start with a WSE membership and access to the TIX API
    " + + "You are able to short stocks and place different types of orders (limit/stop)
    " + + "You can immediately donate to factions to gain reputation

    " + + "Destroying this BitNode will give you Source-File 8, or if you already have this Source-File it will " + + "upgrade its level up to a maximum of 3. This Source-File grants the following benefits:

    " + + "Level 1: Permanent access to WSE and TIX API
    " + + "Level 2: Ability to short stocks in other BitNodes
    " + + "Level 3: Ability to use limit/stop orders in other BitNodes

    " + + "This Source-File also increases your hacking growth multipliers by: " + + "
    Level 1: 8%
    Level 2: 12%
    Level 3: 14%"); BitNodes["BitNode9"] = new BitNode(9, "Hacktocracy", "COMING SOON"); //Healthy Hacknet balancing mechanic BitNodes["BitNode10"] = new BitNode(10, "MegaCorp", "COMING SOON"); //Not sure yet BitNodes["BitNode11"] = new BitNode(11, "The Big Crash", "Okay. Sell it all.", @@ -148,6 +162,7 @@ let BitNodeMultipliers = { FactionWorkRepGain: 1, FactionPassiveRepGain: 1, + RepToDonateToFaction: 1, AugmentationRepCost: 1, AugmentationMoneyCost: 1, @@ -203,6 +218,15 @@ function initBitNodeMultipliers() { BitNodeMultipliers.AugmentationMoneyCost = 2; BitNodeMultipliers.HackExpGain = 0.5; break; + case 8: //Ghost of Wall Street + BitNodeMultipliers.ScriptHackMoney = 0; + BitNodeMultipliers.ManualHackMoney = 0; + BitNodeMultipliers.CompanyWorkMoney = 0; + BitNodeMultipliers.CrimeMoney = 0; + BitNodeMultipliers.HacknetNodeMoney = 0; + BitNodeMultipliers.InfiltrationMoney = 0; + BitNodeMultipliers.RepToDonateToFaction = 0 + break; case 11: //The Big Crash BitNodeMultipliers.ServerMaxMoney = 0.1; BitNodeMultipliers.ServerStartingMoney = 0.1; diff --git a/src/CompanyManagement.js b/src/CompanyManagement.js index 4017fc19b..847dbb7e1 100644 --- a/src/CompanyManagement.js +++ b/src/CompanyManagement.js @@ -126,7 +126,7 @@ Industries: Extremely high stable demand, semi-high competition, super high markup Extremely high starting cost Production increase from real estate diminishes greatly in city. e.g. making many hospitals - in one city has high diminishing returns, but making a few in every city is good + in one city has high diminishing returns, but making a few in every city is goodIn Real Estate - Create 'Real Estate'. Requires metal, energy, water, hardware Can use Hardware/Robotics/AI Cores to increase production @@ -150,7 +150,7 @@ Industries: Operations - Engineer - Business - - Accounting - + Accounting - Management - Research and Development - */ diff --git a/src/Constants.js b/src/Constants.js index e6cbf2fdc..8a4168223 100644 --- a/src/Constants.js +++ b/src/Constants.js @@ -1,5 +1,5 @@ let CONSTANTS = { - Version: "0.31.0", + Version: "0.32.0", //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 @@ -440,18 +440,18 @@ let CONSTANTS = { "

    Functions


    " + "You can NOT define you own functions in Netscript (yet), but there are several built in functions that " + "you may use:

    " + - "hack(hostname/ip)
    Core function that is used to try and hack servers to steal money and gain hacking experience. The argument passed in must be a string with " + + "hack(hostname/ip)
    Core function that is used to try and hack servers to steal money and gain hacking experience. The argument passed in must be a string with " + "either the IP or hostname of the server you want to hack. The runtime for this command depends on your hacking level and the target server's security level. " + " A script can hack a server from anywhere. It does not need to be running on the same server to hack that server. " + "For example, you can create a script that hacks the 'foodnstuff' server and run that script on any server in the game. A successful hack() on " + "a server will raise that server's security level by 0.002. Returns true if the hack is successful and " + "false otherwise.
    " + "Examples: hack('foodnstuff'); or hack('148.192.0.12');

    " + - "sleep(n, log=true)
    Suspends the script for n milliseconds. The second argument is an optional boolean that indicates " + + "sleep(n, log=true)
    Suspends the script for n milliseconds. The second argument is an optional boolean that indicates " + "whether or not the function should log the sleep action. If this argument is true, then calling this function will write " + "'Sleeping for N milliseconds' to the script's logs. If it's false, then this function will not log anything. " + "If this argument is not specified then it will be true by default.
    Example: sleep(5000);

    " + - "grow(hostname/ip)
    Use your hacking skills to increase the amount of money available on a server. The argument passed in " + + "grow(hostname/ip)
    Use your hacking skills to increase the amount of money available on a server. The argument passed in " + "must be a string with either the IP or hostname of the target server. The runtime for this command depends on your hacking level and the target server's security level. " + "When grow() completes, the money available on a target server will be increased by a certain, fixed percentage. This percentage " + "is determined by the server's growth rate and varies between servers. Generally, higher-level servers have higher growth rates.

    " + @@ -460,28 +460,28 @@ let CONSTANTS = { "It also raises the security level of the target server by 0.004. " + "Returns the number by which the money on the server was multiplied for the growth. " + "Works offline at a slower rate.
    Example: grow('foodnstuff');

    " + - "weaken(hostname/ip)
    Use your hacking skills to attack a server's security, lowering the server's security level. The argument passed " + + "weaken(hostname/ip)
    Use your hacking skills to attack a server's security, lowering the server's security level. The argument passed " + "in must be a string with either the IP or hostname of the target server. The runtime for this command depends on your " + "hacking level and the target server's security level. This function lowers the security level of the target server by " + "0.05.

    Like hack() and grow(), weaken() can be called on " + "any server, regardless of where the script is running. This command requires root access to the target server, but " + "there is no required hacking level to run the command. Returns " + "0.1. Works offline at a slower rate
    Example: weaken('foodnstuff');

    " + - "print(x)
    Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command ).

    " + - "tprint(x)
    Prints a value or a variable to the Terminal

    " + - "clearLog()
    Clears the script's logs.

    " + - "scan(hostname/ip, [hostnames=true])
    Returns an array containing the hostnames or IPs of all servers that are one node away from the specified server. " + + "print(x)
    Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command ).

    " + + "tprint(x)
    Prints a value or a variable to the Terminal

    " + + "clearLog()
    Clears the script's logs.

    " + + "scan(hostname/ip, [hostnames=true])
    Returns an array containing the hostnames or IPs of all servers that are one node away from the specified server. " + "The argument must be a string containing the IP or hostname of the target server. The second argument is a boolean that specifies whether " + "the hostnames or IPs of the scanned servers should be output. If it is true then hostnames will be returned, and if false then IP addresses will. " + "This second argument is optional and, if ommitted, the function will output " + "the hostnames of the scanned servers. The hostnames/IPs in the returned array are strings.

    " + - "nuke(hostname/ip)
    Run NUKE.exe on the target server. NUKE.exe must exist on your home computer.
    Example: nuke('foodnstuff');

    " + - "brutessh(hostname/ip)
    Run BruteSSH.exe on the target server. BruteSSH.exe must exist on your home computer.
    Example: brutessh('foodnstuff');

    " + - "ftpcrack(hostname/ip)
    Run FTPCrack.exe on the target server. FTPCrack.exe must exist on your home computer.
    Example: ftpcrack('foodnstuff');

    " + - "relaysmtp(hostname/ip)
    Run relaySMTP.exe on the target server. relaySMTP.exe must exist on your home computer.
    Example: relaysmtp('foodnstuff');

    " + - "httpworm(hostname/ip)
    Run HTTPWorm.exe on the target server. HTTPWorm.exe must exist on your home computer.
    Example: httpworm('foodnstuff');

    " + - "sqlinject(hostname/ip)
    Run SQLInject.exe on the target server. SQLInject.exe must exist on your home computer.
    Example: sqlinject('foodnstuff');

    " + - "run(script, [numThreads], [args...])
    Run a script as a separate process. The first argument that is passed in is the name of the script as a string. This function can only " + + "nuke(hostname/ip)
    Run NUKE.exe on the target server. NUKE.exe must exist on your home computer.
    Example: nuke('foodnstuff');

    " + + "brutessh(hostname/ip)
    Run BruteSSH.exe on the target server. BruteSSH.exe must exist on your home computer.
    Example: brutessh('foodnstuff');

    " + + "ftpcrack(hostname/ip)
    Run FTPCrack.exe on the target server. FTPCrack.exe must exist on your home computer.
    Example: ftpcrack('foodnstuff');

    " + + "relaysmtp(hostname/ip)
    Run relaySMTP.exe on the target server. relaySMTP.exe must exist on your home computer.
    Example: relaysmtp('foodnstuff');

    " + + "httpworm(hostname/ip)
    Run HTTPWorm.exe on the target server. HTTPWorm.exe must exist on your home computer.
    Example: httpworm('foodnstuff');

    " + + "sqlinject(hostname/ip)
    Run SQLInject.exe on the target server. SQLInject.exe must exist on your home computer.
    Example: sqlinject('foodnstuff');

    " + + "run(script, [numThreads], [args...])
    Run a script as a separate process. The first argument that is passed in is the name of the script as a string. This function can only " + "be used to run scripts located on the current server (the server running the script that calls this function). The second argument " + "is optional, and it specifies how many threads to run the script with. This argument must be a number greater than 0. If it is omitted, then the script will be run single-threaded. Any additional arguments will specify " + "arguments to pass into the new script that is being run. If arguments are specified for the new script, then the second argument numThreads argument must be filled in with a value.

    " + @@ -493,7 +493,7 @@ let CONSTANTS = { "run('foo.script', 5);

    " + "The following example will run 'foo.script' single-threaded, and will pass the string 'foodnstuff' into the script as an argument:

    " + "run('foo.script', 1, 'foodnstuff');

    " + - "exec(script, hostname/ip, [numThreads], [args...])
    Run a script as a separate process on another server. The first argument is the name of the script as a string. The " + + "exec(script, hostname/ip, [numThreads], [args...])
    Run a script as a separate process on another server. The first argument is the name of the script as a string. The " + "second argument is a string with the hostname or IP of the 'target server' on which to run the script. The specified script must exist on the target server. " + "The third argument is optional, and it specifies how many threads to run the script with. If it is omitted, then the script will be run single-threaded. " + "This argument must be a number that is greater than 0. Any additional arguments will specify arguments to pass into the new script that is being run. If " + @@ -507,7 +507,7 @@ let CONSTANTS = { "The following example will try to run the script 'foo.script' on the 'foodnstuff' server with 5 threads. It will also pass the number 1 and the string 'test' in as arguments " + "to the script.

    " + "exec('foo.script', 'foodnstuff', 5, 1, 'test');

    " + - "kill(script, hostname/ip, [args...])
    Kills the script on the target server specified by the script's name and arguments. Remember that " + + "kill(script, hostname/ip, [args...])
    Kills the script on the target server specified by the script's name and arguments. Remember that " + "scripts are uniquely identified by both their name and arguments. For example, if 'foo.script' is run with the argument 1, then this is not the " + "same as 'foo.script' run with the argument 2, even though they have the same code.

    " + "The first argument must be a string with the name of the script. The name is case-sensitive. " + @@ -522,9 +522,9 @@ let CONSTANTS = { "kill('foo.script', getHostname());

    " + "If you are trying to kill a script named 'foo.script' on the current server that was ran with the arguments 1 and 'foodnstuff', use this:

    " + "kill('foo.script', getHostname(), 1, 'foodnstuff');

    " + - "killall(hostname/ip)
    Kills all running scripts on the specified server. This function takes a single argument which " + + "killall(hostname/ip)
    Kills all running scripts on the specified server. This function takes a single argument which " + "must be a string containing the hostname or IP of the target server. This function will always return true.

    " + - "scp(script, [source], destination)
    Copies a script or literature (.lit) file to another server. The first argument is a string with " + + "scp(script, [source], destination)
    Copies a script or literature (.lit) file to another server. The first argument is a string with " + "the filename of the script or literature file " + "to be copied, or an array of filenames to be copied. The next two arguments are strings containing the hostname/IPs of the source and target server. " + "The source refers to the server from which the script/literature file will be copied, while the destination " + @@ -534,15 +534,15 @@ let CONSTANTS = { "will return if at least one of the files in the array is successfully copied over.

    " + "Example: scp('hack-template.script', 'foodnstuff'); //Copies hack-template.script from the current server to foodnstuff
    " + "Example: scp('foo.lit', 'helios', 'home'); //Copies foo.lit from the helios server to the home computer

    " + - "ls(hostname/ip)
    Returns an array containing the names of all files on the specified server. The argument must be a " + + "ls(hostname/ip)
    Returns an array containing the names of all files on the specified server. The argument must be a " + "string with the hostname or IP of the target server.

    " + - "hasRootAccess(hostname/ip)
    Returns a boolean (true or false) indicating whether or not the Player has root access to a server. " + + "hasRootAccess(hostname/ip)
    Returns a boolean (true or false) indicating whether or not the Player has root access to a server. " + "The argument passed in must be a string with either the hostname or IP of the target server.
    " + "Example:
    if (hasRootAccess('foodnstuff') == false) {
        nuke('foodnstuff');
    }

    " + - "getIp()
    Returns a string with the IP Address of the server that the script is running on

    " + - "getHostname()
    Returns a string with the hostname of the server that the script is running on

    " + - "getHackingLevel()
    Returns the Player's current hacking level.

    " + - "getHackingMultipliers()
    Returns an object containing the Player's hacking related multipliers. " + + "getIp()
    Returns a string with the IP Address of the server that the script is running on

    " + + "getHostname()
    Returns a string with the hostname of the server that the script is running on

    " + + "getHackingLevel()
    Returns the Player's current hacking level.

    " + + "getHackingMultipliers()
    Returns an object containing the Player's hacking related multipliers. " + "These multipliers are returned in integer forms, not percentages (e.g. 1.5 instead of 150%). " + "The object has the following structure:

    " + "{
    " + @@ -554,7 +554,7 @@ let CONSTANTS = { "mults = getHackingMultipliers();
    " + "print(mults.chance);
    " + "print(mults.growth);

    " + - "getBitNodeMultipliers()
    Returns an object containing the current BitNode multipliers. " + + "getBitNodeMultipliers()
    Returns an object containing the current BitNode multipliers. " + "This function requires Source-File 5 in order to run. The multipliers are returned in integer forms, not percentages " + "(e.g. 1.5 instead of 150%). The multipliers represent the difference between the current BitNode and the " + "original BitNode (BitNode-1). For example, if the 'CrimeMoney' multiplier has a value of 0.1 then that means " + @@ -584,33 +584,33 @@ let CONSTANTS = { "mults = getBitNodeMultipliers();
    " + "print(mults.ServerMaxMoney);
    " + "print(mults.HackExpGain);

    " + - "getServerMoneyAvailable(hostname/ip)
    Returns the amount of money available on a server. The argument passed in must be a string with either the " + + "getServerMoneyAvailable(hostname/ip)
    Returns the amount of money available on a server. The argument passed in must be a string with either the " + "hostname or IP of the target server.
    Example: getServerMoneyAvailable('foodnstuff');

    " + - "getServerMaxMoney(hostname/ip)
    Returns the maximum amount of money that can be available on a server. The argument passed in must be a string with " + + "getServerMaxMoney(hostname/ip)
    Returns the maximum amount of money that can be available on a server. The argument passed in must be a string with " + "the hostname or IP of the target server.
    Example: getServerMaxMoney('foodnstuff');

    " + - "getServerGrowth(hostname/ip)
    Returns the server's intrinsic 'growth parameter'. This growth parameter is a number " + + "getServerGrowth(hostname/ip)
    Returns the server's intrinsic 'growth parameter'. This growth parameter is a number " + "between 1 and 100 that represents how quickly the server's money grows. This parameter affects the percentage by which this server's " + "money is increased when using the grow() function. A higher growth parameter will result in a higher percentage from grow().

    " + "The argument passed in must be a string with the hostname or IP of the target server.

    " + - "getServerSecurityLevel(hostname/ip)
    Returns the security level of a server. The argument passed in must be a string with either the " + + "getServerSecurityLevel(hostname/ip)
    Returns the security level of a server. The argument passed in must be a string with either the " + "hostname or IP of the target server. A server's security is denoted by a number, typically between 1 and 100.

    " + - "getServerBaseSecurityLevel(hostname/ip)
    Returns the base security level of a server. This is the security level that the server starts out with. " + + "getServerBaseSecurityLevel(hostname/ip)
    Returns the base security level of a server. This is the security level that the server starts out with. " + "This is different than getServerSecurityLevel() because getServerSecurityLevel() returns the current security level of a server, which can constantly change " + "due to hack(), grow(), and weaken() calls on that server. The base security level will stay the same until you reset by installing an Augmentation.

    " + "The argument passed in must be a string with either the hostname or IP of the target server. A server's base security is denoted by a number, typically between 1 and 100. " + "

    " + - "getServerMinSecurityLevel(hostname/ip)Returns the minimum security level of a server. The argument passed in must be a string with " + + "getServerMinSecurityLevel(hostname/ip)Returns the minimum security level of a server. The argument passed in must be a string with " + "either the hostname or IP of the target server.

    " + - "getServerRequiredHackingLevel(hostname/ip)
    Returns the required hacking level of a server. The argument passed in must be a string with either the " + + "getServerRequiredHackingLevel(hostname/ip)
    Returns the required hacking level of a server. The argument passed in must be a string with either the " + "hostname or IP or the target server.

    " + - "getServerNumPortsRequired(hostname/ip)
    Returns the number of open ports required to successfully run NUKE.exe on a server. The argument " + + "getServerNumPortsRequired(hostname/ip)
    Returns the number of open ports required to successfully run NUKE.exe on a server. The argument " + "passed in must be a string with either the hostname or IP of the target server.

    " + - "getServerRam(hostname/ip)
    Returns an array with two elements that gives information about the target server's RAM. The first " + + "getServerRam(hostname/ip)
    Returns an array with two elements that gives information about the target server's RAM. The first " + "element in the array is the amount of RAM that the server has (in GB). The second element in the array is the amount of RAM that " + "is currently being used on the server.

    " + - "serverExists(hostname/ip)
    Returns a boolean denoting whether or not the specified server exists. The argument " + + "serverExists(hostname/ip)
    Returns a boolean denoting whether or not the specified server exists. The argument " + "must be a string with the hostname or IP of the target server.

    " + - "fileExists(filename, [hostname/ip])
    Returns a boolean (true or false) indicating whether the specified file exists on a server. " + + "fileExists(filename, [hostname/ip])
    Returns a boolean (true or false) indicating whether the specified file exists on a server. " + "The first argument must be a string with the name of the file. A file can either be a script, program, or literature file. A script name is case-sensitive, but a " + "program/literature file is not. For example, fileExists('brutessh.exe') will work fine, even though the actual program is named BruteSSH.exe.

    " + "The second argument is a string with the hostname or IP of the server on which to search for the program. This second argument is optional. " + @@ -619,7 +619,7 @@ let CONSTANTS = { "Example: fileExists('ftpcrack.exe');

    " + "The first example above will return true if the script named 'foo.script' exists on the 'foodnstuff' server, and false otherwise. The second example above will " + "return true if the current server (the server on which this function runs) contains the FTPCrack.exe program, and false otherwise.

    " + - "isRunning(filename, hostname/ip, [args...])
    Returns a boolean (true or false) indicating whether the specified script is running on a server. " + + "isRunning(filename, hostname/ip, [args...])
    Returns a boolean (true or false) indicating whether the specified script is running on a server. " + "Remember that a script is uniquely identified by both its name and its arguments.

    " + "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. Any additional arguments passed to the function will specify the arguments passed into the target script. " + @@ -631,45 +631,45 @@ let CONSTANTS = { "example above will return true if there is a script named 'foo.script' with no arguments running on the current server, and false otherwise. " + "The third example above will return true if there is a script named 'foo.script' with the arguments 1, 5, and 'test' running on the 'joesguns' server, and " + "false otherwise.

    " + - "getNextHacknetNodeCost()
    Returns the cost of purchasing a new Hacknet Node

    " + - "purchaseHacknetNode()
    Purchases a new Hacknet Node. Returns a number with the index of the Hacknet Node. This index is equivalent to the number " + + "getNextHacknetNodeCost()
    Returns the cost of purchasing a new Hacknet Node

    " + + "purchaseHacknetNode()
    Purchases a new Hacknet Node. Returns a number with the index of the Hacknet Node. This index is equivalent to the number " + "at the end of the Hacknet Node's name (e.g The Hacknet Node named 'hacknet-node-4' will have an index of 4). If the player cannot afford to purchase " + "a new Hacknet Node then the function will return false. Does NOT work offline

    " + - "purchaseServer(hostname, ram)
    Purchases a server with the specified hostname and amount of RAM. The first argument can be any data type, " + + "purchaseServer(hostname, ram)
    Purchases a server with the specified hostname and amount of RAM. The first argument can be any data type, " + "but it will be converted to a string using Javascript's String function. Anything that resolves to an empty string will cause the function to fail. " + "The second argument specified the amount of RAM (in GB) for the server. This argument must resolve to a numeric and it must be a power of 2 " + "(2, 4, 8, etc...).

    " + "This function returns the hostname of the newly purchased server as a string. If the function fails to purchase a server, then it will return " + "an empty string. The function will fail if the arguments passed in are invalid or if the player does not have enough money to purchase the specified server.

    " + - "deleteServer(hostname)
    Deletes one of the servers you've purchased with the specified hostname. The function will fail if " + + "deleteServer(hostname)
    Deletes one of the servers you've purchased with the specified hostname. The function will fail if " + "there are any scripts running on the specified server. Returns true if successful and false otherwise

    " + - "getPurchasedServers([hostname=true])
    Returns an array with either the hostname or IPs of all of the servers you " + + "getPurchasedServers([hostname=true])
    Returns an array with either the hostname or IPs of all of the servers you " + "have purchased. It takes an optional parameter specifying whether the hostname or IP addresses will be returned. If this " + "parameter is not specified, it is true by default and hostnames will be returned

    " + - "round(n)
    Rounds the number n to the nearest integer. If the argument passed in is not a number, then the function will return 0.

    " + - "write(port, data)
    Writes data to a port. The first argument must be a number between 1 and 10 that specifies the port. The second " + + "round(n)
    Rounds the number n to the nearest integer. If the argument passed in is not a number, then the function will return 0.

    " + + "write(port, data)
    Writes data to a port. The first argument must be a number between 1 and 10 that specifies the port. The second " + "argument defines the data to write to the port. If the second argument is not specified then it will write an empty string to the port.

    " + - "read(port)
    Reads data from a port. The first argument must be a number between 1 and 10 that specifies the port. A port is a serialized queue. " + + "read(port)
    Reads data from a port. The first argument must be a number between 1 and 10 that specifies the port. A port is a serialized queue. " + "This function will remove the first element from the queue and return it. If the queue is empty, then the string 'NULL PORT DATA' will be returned.

    " + - "scriptRunning(scriptname, hostname/ip)
    Returns a boolean indicating whether any instance of the specified script is running " + + "scriptRunning(scriptname, hostname/ip)
    Returns a boolean indicating whether any instance of the specified script is running " + "on a server, regardless of its arguments. This is different than the isRunning() function because it does not " + "try to identify a specific instance of a running script by its arguments.

    " + "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.

    " + - "scriptKill(scriptname, hostname/ip)
    Kills all scripts with the specified filename that are running on the server specified by the " + + "scriptKill(scriptname, hostname/ip)
    Kills all scripts with the specified filename that are running on the server specified by the " + "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.

    " + - "getScriptRam(scriptname, hostname/ip)
    Returns the amount of RAM required to run the specified script on the " + + "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.

    " + - "getHackTime(hostname/ip)
    Returns the amount of time in seconds it takes to execute the hack() Netscript function " + + "getHackTime(hostname/ip)
    Returns the amount of time in seconds it takes to execute the hack() Netscript function " + "on the server specified by the hostname/ip. The argument must be a string with the hostname/ip of the target server.

    " + - "getGrowTime(hostname/ip)
    Returns the amount of time in seconds it takes to execute the grow() Netscript function " + + "getGrowTime(hostname/ip)
    Returns the amount of time in seconds it takes to execute the grow() Netscript function " + "on the server specified by the hostname/ip. The argument must be a string with the hostname/ip of the target server.

    " + - "getWeakenTime(hostname/ip)
    Returns the amount of time in seconds it takes to execute the weaken() Netscript function " + + "getWeakenTime(hostname/ip)
    Returns the amount of time in seconds it takes to execute the weaken() Netscript function " + "on the server specified by the hostname/ip. The argument must be a string with the hostname/ip of the target server.

    " + - "getScriptIncome([scriptname], [hostname/ip], [args...])
    " + + "getScriptIncome([scriptname], [hostname/ip], [args...])
    " + "Returns the amount of income the specified script generates while online (when the game is open, does not apply for " + "offline income). This function can also be called with no arguments. If called with no arguments, then this function " + "will return an array of two values. The first value is the total income ($/sec) of all of your active scripts (currently running). " + @@ -681,7 +681,7 @@ let CONSTANTS = { "The second argument must be a string with the hostname/IP of the target server. If the first argument is specified " + "then the second argument must be specified as well. Any additional arguments passed to the function will specify " + "the arguments passed into the target script.

    " + - "getScriptExpGain([scriptname], [hostname/ip], [args...])
    " + + "getScriptExpGain([scriptname], [hostname/ip], [args...])
    " + "Returns the amount of hacking experience the specified script generates while online (when the game is open, does not apply for " + "offline experience gains). This function can also return the total experience gain rate of all of your active scripts by running the function " + "with no arguments.

    " + @@ -692,26 +692,28 @@ let CONSTANTS = { "The second argument must be a string with the hostname/IP of the target server. If the first argument is specified " + "then the second argument must be specified as well. Any additional arguments passed to the function will specify " + "the arguments passed into the target script.

    " + - "getTimeSinceLastAug()
    " + + "getTimeSinceLastAug()
    " + "Returns the amount of time in milliseconds that have passed since you last installed Augmentations (or destroyed a BitNode).

    " + + "sprintf()/vsprintf()
    " + + "See this link for details

    " + "

    Hacknet Nodes API


    " + "Netscript provides the following API for accessing and upgrading your Hacknet Nodes through scripts. This API does NOT work offline.

    " + - "hacknetnodes
    A special variable. This is an array that maps to the Player's Hacknet Nodes. The Hacknet Nodes are accessed through " + + "hacknetnodes
    A special variable. This is an array that maps to the Player's Hacknet Nodes. The Hacknet Nodes are accessed through " + "indexes. These indexes correspond to the number at the end of the name of the Hacknet Node. For example, the first Hacknet Node you purchase " + "will have the same 'hacknet-node-0' and can be accessed with hacknetnodes[0]. The fourth Hacknet Node you purchase will have the name " + "'hacknet-node-3' and can be accessed with hacknetnodes[3].

    " + - "hacknetnodes.length
    Returns the number of Hacknet Nodes that the player owns

    " + - "hacknetnodes[i].level
    Returns the level of the corresponding Hacknet Node

    " + - "hacknetnodes[i].ram
    Returns the amount of RAM on the corresponding Hacknet Node

    " + - "hacknetnodes[i].cores
    Returns the number of cores on the corresponding Hacknet Node

    " + - "hacknetnodes[i].totalMoneyGenerated
    Returns the total amount of money that the corresponding Hacknet Node has earned

    " + - "hacknetnodes[i].onlineTimeSeconds
    Returns the total amount of time that the corresponding Hacknet Node has existed

    " + - "hacknetnodes[i].moneyGainRatePerSecond
    Returns the income ($ / sec) that the corresponding Hacknet Node earns

    " + - "hacknetnodes[i].upgradeLevel(n)
    Tries to upgrade the level of the corresponding Hacknet Node n times. The argument n must be a " + + "hacknetnodes.length
    Returns the number of Hacknet Nodes that the player owns

    " + + "hacknetnodes[i].level
    Returns the level of the corresponding Hacknet Node

    " + + "hacknetnodes[i].ram
    Returns the amount of RAM on the corresponding Hacknet Node

    " + + "hacknetnodes[i].cores
    Returns the number of cores on the corresponding Hacknet Node

    " + + "hacknetnodes[i].totalMoneyGenerated
    Returns the total amount of money that the corresponding Hacknet Node has earned

    " + + "hacknetnodes[i].onlineTimeSeconds
    Returns the total amount of time that the corresponding Hacknet Node has existed

    " + + "hacknetnodes[i].moneyGainRatePerSecond
    Returns the income ($ / sec) that the corresponding Hacknet Node earns

    " + + "hacknetnodes[i].upgradeLevel(n)
    Tries to upgrade the level of the corresponding Hacknet Node n times. The argument n must be a " + "positive integer. Returns true if the Hacknet Node's level is successfully upgraded n times or up to the max level (200), and false otherwise.

    " + - "hacknetnodes[i].upgradeRam()
    Tries to upgrade the amount of RAM on the corresponding Hacknet Node. Returns true if the " + + "hacknetnodes[i].upgradeRam()
    Tries to upgrade the amount of RAM on the corresponding Hacknet Node. Returns true if the " + "RAM is successfully upgraded, and false otherwise.

    " + - "hacknetnodes[i].upgradeCore()
    Attempts to purchase an additional core for the corresponding Hacknet Node. Returns true if the " + + "hacknetnodes[i].upgradeCore()
    Attempts to purchase an additional core for the corresponding Hacknet Node. Returns true if the " + "additional core is successfully purchase, and false otherwise.

    " + "Example: The following is an example of one way a script can be used to automate the purchasing and upgrading of Hacknet Nodes. " + "This script purchases new Hacknet Nodes until the player has four. Then, it iteratively upgrades each of those four Hacknet Nodes " + @@ -738,25 +740,53 @@ let CONSTANTS = { "    }
    " + "}

    " + "

    Trade Information eXchange (TIX) API


    " + - "getStockPrice(sym)
    Returns the price of a stock. The argument passed in must be the stock's symbol (NOT THE COMPANY NAME!). The symbol " + + "getStockPrice(sym)
    Returns the price of a stock. The argument passed in must be the stock's symbol (NOT THE COMPANY NAME!). The symbol " + "is a sequence of two to four capital letters. The symbol argument must be a string.

    " + "Example: getStockPrice('FSIG');

    " + - "getStockPosition(sym)
    Returns an array of two elements that represents the player's position in a stock. The first element " + + "getStockPosition(sym)
    Returns an array of two elements that represents the player's position in a stock. The first element " + "in the array is the number of shares the player owns of the specified stock. The second element in the array is the average price of the player's " + "shares. Both elements are numbers. The argument passed in must be the stock's symbol, which is a sequence of two to four capital letters.

    " + "Example:

    pos = getStockPosition('ECP');
    shares = pos[0];
    avgPx = pos[1];

    "+ - "buyStock(sym, shares)
    Attempts to purchase shares of a stock. The first argument must be a string with the stock's symbol. The second argument " + + "buyStock(sym, shares)
    Attempts to purchase shares of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument " + "must be the number of shares to purchase.

    " + "If the player does not have enough money to purchase specified number of shares, then no shares will be purchased (it will not purchase the most you can afford). " + "Remember that every transaction on the stock exchange costs a certain commission fee.

    " + "The function will return true if it successfully purchases the specified number of shares of stock, and false otherwise.

    " + - "sellStock(sym, shares)
    Attempts to sell shares of a stock. The first argument must be a string with the stock's symbol. The second argument " + + "sellStock(sym, shares)
    Attempts to sell shares of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument " + "must be the number of shares to sell.

    " + "If the specified number of shares in the function exceeds the amount that the player actually owns, then this function will sell all owned shares. " + "Remember that every transaction on the stock exchange costs a certain commission fee.

    " + "The net profit made from selling stocks with this function is reflected in the script's statistics. This net profit is calculated as:

    " + "shares * (sell price - average price of purchased shares)

    " + "This function will return true if the shares of stock are successfully sold and false otherwise.

    " + + "shortStock(sym, shares)
    " + + "Attempts to purchase a short position of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument " + + "must be the number of shares to purchase.

    " + + "In order to use this function the player must be in BitNode-8 or must have Level 2 of Source-File 8.

    " + + "If the player does not have enough money to purchase the specified number of shares, then no shares will be purchased. Remember that every " + + "every transaction on the stock exchange costs a certain commission fee.

    " + + "Returns true if it successfully shorts the stock with the specified number of shares, and false otherwise.

    " + + "sellShort(sym, shares)
    " + + "Attempts to sell a short position of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument must be the " + + "number of shares to sell.

    " + + "In order to use this function the player must be in BitNode-8 or must have Level 2 of Source-File 8.

    " + + "If the specified number of shares exceeds the amount that the player actually owns, then this function will sell all owned shares. " + + "Remember that every transaction on the stock exchange costs a certain commission fee.

    " + + "This function returns true if it successfully sells any number of shares, and false otherwise.

    " + + "placeOrder(sym, shares, price, type, pos)
    " + + "Places an order on the stock market. This function only works for Limit and Stop Orders. Use the buyStock/sellStock/shortStock/sellShort functions " + + "to place Market Orders. In order to use this function the player must be in BitNode-8 or must have Level 3 of Source-File 8.

    " + + "The 'sym' argument must be a string with the symbol of the stock. The 'shares' and 'price' arguments " + + "specify the number of shares and the execution price for the order. They must be numeric.

    " + + "The 'type' argument is a string that specifies the type of order. It must specify either 'limit' or 'stop', and must " + + "also specify 'buy' or 'sell'. This argument is NOT case-sensitive. Here are four examples that will work:

    " + + "limitbuy, limitsell, stopbuy, stopsell

    " + + "The last argument, 'pos', is a string that specifies whether the order is a 'Long' or 'Short' position. The values 'L' and " + + "'S' can also be used. This argument is NOT case-sensitive.

    " + + "Returns true if the order is successfully placed, and false otherwise.

    " + + "cancelOrder(sym, shares, price, type, pos)
    " + + "Cancels an oustanding order on the stock market. In order to use this function the player must be in BitNode-8 or must have " + + "Level 3 of Source-File 8. This function uses the same arguments as placeOrder()

    " + "

    While loops


    " + "A while loop is a control flow statement that repeatedly executes code as long as a condition is met.

    " + "while ([cond]) {
        [code]
    }


    " + @@ -800,7 +830,7 @@ let CONSTANTS = { "then you will be able to access all of the Singularity Functions.

    " + "Note that Singularity Functions require a lot of RAM outside of BitNode-4 (their RAM costs are multiplied by " + "10 if you are not in BitNode-4).

    " + - "universityCourse(universityName, courseName)
    " + + "universityCourse(universityName, courseName)
    " + "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.

    " + "This function will automatically set you to start taking a course at a university. If you are already " + "in the middle of some 'working' action (such as working at a company, for a faction, or on a program), " + @@ -814,7 +844,7 @@ let CONSTANTS = { "The cost and experience gains for all of these universities and classes are the same as if you were to manually " + "visit and take these classes.

    " + "This function will return true if you successfully start taking the course, and false otherwise.

    " + - "gymWorkout(gymName, stat)
    " + + "gymWorkout(gymName, stat)
    " + "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.

    " + "This function will automatically set you to start working out at a gym to train a particular stat. If you are " + "already in the middle of some 'working' action (such as working at a company, for a faction, or on a program), then " + @@ -826,18 +856,18 @@ let CONSTANTS = { "The valid stats are:

    strength OR str
    defense OR def
    dexterity OR dex
    agility OR agi

    " + "The cost and experience gains for all of these gyms are the same as if you were to manually visit these gyms and train " + "This function will return true if you successfully start working out at the gym, and false otherwise.

    " + - "travelToCity(cityname)
    " + + "travelToCity(cityname)
    " + "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.

    " + "This function allows the player to travel to any city. The cost for using this function is the same as the cost for traveling through the Travel Agency.

    " + "The argument passed into this must be a string with the name of the city to travel to. Note that this argument IS CASE SENSITIVE. The valid cities are:

    " + "Aevum
    Chongqing
    Sector-12
    New Tokyo
    Ishima
    Volhaven

    " + "This function will return true if you successfully travel to the specified city and false otherwise.

    " + - "purchaseTor()
    " + + "purchaseTor()
    " + "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.

    " + "This function allows you to automatically purchase a TOR router. The cost for purchasing a TOR router using this " + "function is the same as if you were to manually purchase one.

    " + "This function will return true if it successfully purchase a TOR router and false otherwise.

    " + - "purchaseProgram(programName)
    " + + "purchaseProgram(programName)
    " + "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.

    " + "This function allows you to automatically purchase programs. You MUST have a TOR router in order to use this function.

    " + "The argument passed in must be a string with the name of the program (including the '.exe' extension). This argument is " + @@ -846,29 +876,29 @@ let CONSTANTS = { "The cost of purchasing programs using this function is the same as if you were purchasing them through the Dark Web (using " + "the buy Terminal command).

    " + "This function will return true if the specified program is purchased, and false otherwise.

    " + - "getStats()
    If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to run this " + + "getStats()
    If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to run this " + "function.

    Returns an object with the Player's stats. The object has the following properties:

    " + "Player.hacking
    Player.strength
    Player.defense
    Player.dexterity
    Player.agility
    Player.charisma
    Player.intelligence

    " + "Example:

    " + "res = getStats();
    print('My charisma level is: ' + res.charisma);

    " + - "isBusy()
    If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to run this " + + "isBusy()
    If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to run this " + "function.

    Returns a boolean indicating whether or not the player is currently performing an 'action'. " + "These actions include working for a company/faction, studying at a univeristy, working out at a gym, " + "creating a program, or committing a crime.

    " + - "upgradeHomeRam()
    " + + "upgradeHomeRam()
    " + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

    " + "This function will upgrade amount of RAM on the player's home computer. The cost is the same as if you were to do it manually.

    " + "This function will return true if the player's home computer RAM is successfully upgraded, and false otherwise.

    " + - "getUpgradeHomeRamCost()
    " + + "getUpgradeHomeRamCost()
    " + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

    " + "Returns the cost of upgrading the player's home computer RAM.

    " + - "workForCompany()
    " + + "workForCompany()
    " + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

    " + "This function will automatically set you to start working at the company at which you are employed. If you are already " + "in the middle of some 'working' action (such as working for a faction, training at a gym, or creating a program), then " + "running this function will automatically cancel that action and give you your earnings.

    " + "This function will return true if the player starts working, and false otherwise.

    " + - "applyToCompany(companyName, field)
    " + + "applyToCompany(companyName, field)
    " + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

    " + "This function will automatically try to apply to the specified company for a position in the specified field. This " + "function can also be used to apply for promotions by specifying the company and field you are already employed at.

    " + @@ -879,19 +909,19 @@ let CONSTANTS = { "security
    agent
    employee
    part-time employee
    waiter
    part-time waiter

    " + "This function will return true if you successfully get a job/promotion, and false otherwise. Note " + "that if you are trying to use this function to apply for a promotion and you don't get one, it will return false.

    " + - "getCompanyRep(companyName)
    " + + "getCompanyRep(companyName)
    " + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

    " + "This function will return the amount of reputation you have at the specified company. If the company passed in as " + "an argument is invalid, -1 will be returned.

    " + "The argument passed in must be a string with the name of the company. This argument IS CASE-SENSITIVE.

    " + - "checkFactionInvitations()
    " + + "checkFactionInvitations()
    " + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

    " + "Returns an array with the name of all Factions you currently have oustanding invitations from.

    " + - "joinFaction(name)
    " + + "joinFaction(name)
    " + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

    " + "This function will automatically accept an invitation from a faction and join it.

    " + "The argument must be a string with the name of the faction. This name IS CASE-SENSITIVE.

    " + - "workForFaction(factionName, workType)
    " + + "workForFaction(factionName, workType)
    " + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

    " + "This function will automatically set you to start working for the specified Faction. Obviously, you " + "must be a member of the Faction or else this function will fail. If you are already in the middle of " + @@ -901,11 +931,11 @@ let CONSTANTS = { "must be a string with the type of work you want to perform for the faction. The valid values for this argument are:

    " + "
    hacking/hacking contracts/hackingcontracts
    field/fieldwork/field work
    security/securitywork/security work

    " + "This function will return true if you successfully start working for the specified faction, and false otherwise.

    " + - "getFactionRep(factionName)
    " + + "getFactionRep(factionName)
    " + "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.

    " + "This function returns the amount of reputation you have for the specified Faction. The argument must be a " + "string with the name of the Faction. The argument IS CASE-SENSITIVE.

    " + - "createProgram(programName)
    " + + "createProgram(programName)
    " + "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.

    " + "This function will automatically set you to start working on creating the specified program. If you are already in " + "the middle of some 'working' action (such as working for a company, training at a gym, or taking a course), then " + @@ -916,7 +946,7 @@ let CONSTANTS = { "BruteSSH.exe: 50
    FTPCrack.exe: 100
    relaySMTP.exe: 250
    HTTPWorm.exe: 500
    SQLInject.exe: 750
    " + "DeepscanV1.exe: 75
    DeepscanV2.exe: 400
    ServerProfiler.exe: 75
    AutoLink.exe: 25

    " + "This function returns true if you successfully start working on the specified program, and false otherwise.

    " + - "commitCrime(crime)
    " + + "commitCrime(crime)
    " + "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.

    " + "This function is used to automatically attempt to commit crimes. If you are already in the middle of some 'working' " + "action (such as working for a company or training at a gym), then running this function will automatically cancel " + @@ -925,40 +955,41 @@ let CONSTANTS = { "lenient in terms of what inputs it accepts. Here is a list of valid inputs for all of the crimes:

    " + "shoplift, rob store, mug, larceny, deal drugs, bond forgery, traffick arms, homicide, grand theft auto, " + "kidnap, assassinate, heist

    " + + "Crimes committed using this function will have all of their earnings halved (this applies for both money and experience!)

    " + "This function returns the number of seconds it takes to attempt the specified crime (e.g It takes 60 seconds to attempt " + "the 'Rob Store' crime, so running commitCrime('rob store') will return 60). Warning: I do not recommend using the time " + "returned from this function to try and schedule your crime attempts. Instead, I would use the isBusy() Singularity function " + "to check whether you have finished attempting a crime. This is because although the game sets a certain crime to be X amount of seconds, " + "there is no guarantee that your browser will follow that time limit.

    " + - "getCrimeChance(crime)
    If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to " + + "getCrimeChance(crime)
    If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to " + "use this function.

    " + "This function returns your chance of success at commiting the specified crime. The chance is returned as a decimal " + "(i.e. 60% would be returned as 0.6). The argument for this function is a string. It is not case-sensitive and is fairly " + "lenient in terms of what inputs it accepts. Check the documentation for the commitCrime() Singularity Function to see " + "examples of valid inputs.

    " + - "getOwnedAugmentations(purchased=false)
    " + + "getOwnedAugmentations(purchased=false)
    " + "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.

    " + "This function returns an array of the names of all Augmentations you own as strings. It takes a single optional " + "boolean argument that specifies whether the returned array should include Augmentations you have purchased " + "but not yet installed. If it is true, then the returned array will include these Augmentations. By default, " + "this argument is false.

    " + - "getAugmentationsFromFaction(facName)
    " + + "getAugmentationsFromFaction(facName)
    " + "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.

    " + "Returns an array containing the names (as strings) of all Augmentations that are available from the specified faction. " + "The argument must be a string with the faction's name. This argument is case-sensitive.

    " + - "getAugmentationCost(augName)
    " + + "getAugmentationCost(augName)
    " + "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.

    " + "This function returns an array with two elements that gives the cost for the specified Augmentation" + ". The first element in the returned array is the reputation requirement of the Augmentation, and the second element " + "is the money cost.

    " + "The argument passed in must be a string with the name of the Augmentation. This argument IS CASE-SENSITIVE. " + "If an invalid Augmentation name is passed in, this function will return the array [-1, -1].

    " + - "purchaseAugmentation(factionName, augName)
    " + + "purchaseAugmentation(factionName, augName)
    " + "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.

    " + "This function will try to purchase the specified Augmentation through the given Faction.

    " + "The two arguments must be strings specifying the name of the Faction and Augmentation, respectively. These arguments are both CASE-SENSITIVE.

    " + "This function will return true if the Augmentation is successfully purchased, and false otherwise.

    " + - "installAugmentations(cbScript)
    " + + "installAugmentations(cbScript)
    " + "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.

    " + "This function will automatically install your Augmentations, resetting the game as usual.

    " + "It will return true if successful, and false otherwise.

    " + @@ -1065,27 +1096,10 @@ let CONSTANTS = { "World Stock Exchange account and TIX API Access
    ", LatestUpdate: - "v0.31.0
    " + - "-Game now saves to IndexedDb (if your browser supports it). This means you should " + - "no longer have trouble saving the game when your save file gets too big (from running " + - "too many scripts). " + - "The game will still be saved to localStorage as well
    " + - "-New file type: text files (.txt). You can read or write to text files using the read()/write() Netscript commands. " + - "You can view text files in Terminal using 'cat'. Eventually I will make it so you can edit them in the editor " + - "but that's not available yet. You can also download files to your real computer using the 'download' Terminal command
    " + - "-Added a new Crime: Bond Forgery. This crime takes 5 minutes to attempt " + - "and gives $4,500,000 if successful. It is meant for mid game.
    " + - "-Added commitCrime(), getCrimeChance(), isBusy(), and getStats() Singularity Functions.
    " + - "-Removed getIntelligence() Netscript function
    " + - "-Added sprintf and vsprintf to Netscript. See this Github page for details
    " + - "-Increased the amount of money gained from Infiltration by 20%, and the amount of faction reputation by 12%
    " + - "-Rebalanced BitNode-2 so that Crime and Infiltration are more profitable but hacking is less profitable. Infiltration also gives more faction rep
    " + - "-Rebalanced BitNode-4 so that hacking is slightly less profitable
    " + - "-Rebalanced BitNode-5 so that Infiltration is more profitable and gives more faction rep
    " + - "-Rebalanced BitNode-11 so that Crime and Infiltration are more profitable. Infiltration also gives more faction rep.
    " + - "-Fixed an annoying issue in Hacking Missions where sometimes you would click a Node but it wouldnt actually get selected
    " + - "-Made the Hacking Mission gameplay a bit slower by lowering the effect of Scan and reducing Attack damage
    " + - "-Slightly increased the base reputation gain rate for factions when doing Field Work and Security Work
    " + "v0.32.0
    " + + "-Released BitNode-8: Ghost of Wall Street
    " + + "-Re-designed Stock Market UI
    " + + "-Minor bugfixes
    " } export {CONSTANTS}; diff --git a/src/Faction.js b/src/Faction.js index fa89f170d..f024779a2 100644 --- a/src/Faction.js +++ b/src/Faction.js @@ -605,7 +605,7 @@ function displayFactionContent(factionName) { } if (faction.isMember) { - if (faction.favor >= 150) { + if (faction.favor >= (150 * BitNodeMultipliers.RepToDonateToFaction)) { donateDiv.style.display = "inline"; } else { donateDiv.style.display = "none"; diff --git a/src/Infiltration.js b/src/Infiltration.js index 1e07e184d..3052f474d 100644 --- a/src/Infiltration.js +++ b/src/Infiltration.js @@ -48,6 +48,7 @@ function InfiltrationInstance(companyName, startLevel, val, maxClearance, diff) this.dexExpGained = 0; this.agiExpGained = 0; this.chaExpGained = 0; + this.intExpGained = 0; } InfiltrationInstance.prototype.gainHackingExp = function(amt) { @@ -80,6 +81,11 @@ InfiltrationInstance.prototype.gainCharismaExp = function(amt) { this.chaExpGained += amt; } +InfiltrationInstance.prototype.gainIntelligenceExp = function(amt) { + if (isNaN(amt)) {return;} + this.intExpGained += amt; +} + function beginInfiltration(companyName, startLevel, val, maxClearance, diff) { var inst = new InfiltrationInstance(companyName, startLevel, val, maxClearance, diff); clearInfiltrationStatusText(); @@ -87,9 +93,7 @@ function beginInfiltration(companyName, startLevel, val, maxClearance, diff) { } function endInfiltration(inst, success) { - if (success) { - infiltrationBoxCreate(inst); - } + if (success) {infiltrationBoxCreate(inst);} clearEventListeners("infiltration-kill"); clearEventListeners("infiltration-knockout"); @@ -588,10 +592,10 @@ let intWgt = CONSTANTS.IntelligenceInfiltrationWeight; //Success: 5%, Failure 10%, -Karma function attemptInfiltrationKill(inst) { var chance = getInfiltrationKillChance(inst); - inst.gainStrengthExp(inst.securityLevel / 100) * Player.strength_exp_mult; - inst.gainDefenseExp(inst.securityLevel / 100) * Player.defense_exp_mult; - inst.gainDexterityExp(inst.securityLevel / 100) * Player.dexterity_exp_mult; - inst.gainAgilityExp(inst.securityLevel / 100) * Player.agility_exp_mult; + inst.gainStrengthExp(inst.securityLevel / 90) * Player.strength_exp_mult; + inst.gainDefenseExp(inst.securityLevel / 90) * Player.defense_exp_mult; + inst.gainDexterityExp(inst.securityLevel / 90) * Player.dexterity_exp_mult; + inst.gainAgilityExp(inst.securityLevel / 90) * Player.agility_exp_mult; if (Math.random() <= chance) { inst.securityLevel *= 1.05; return [true, 1.05]; @@ -614,10 +618,10 @@ function getInfiltrationKillChance(inst) { //Success: 3%, Failure: 10% function attemptInfiltrationKnockout(inst) { var chance = getInfiltrationKnockoutChance(inst); - inst.gainStrengthExp(inst.securityLevel / 100) * Player.strength_exp_mult; - inst.gainDefenseExp(inst.securityLevel / 100) * Player.defense_exp_mult; - inst.gainDexterityExp(inst.securityLevel / 100) * Player.dexterity_exp_mult; - inst.gainAgilityExp(inst.securityLevel / 100) * Player.agility_exp_mult; + inst.gainStrengthExp(inst.securityLevel / 85) * Player.strength_exp_mult; + inst.gainDefenseExp(inst.securityLevel / 85) * Player.defense_exp_mult; + inst.gainDexterityExp(inst.securityLevel / 85) * Player.dexterity_exp_mult; + inst.gainAgilityExp(inst.securityLevel / 85) * Player.agility_exp_mult; if (Math.random() <= chance) { inst.securityLevel *= 1.03; return [true, 1.03]; @@ -639,9 +643,9 @@ function getInfiltrationKnockoutChance(inst) { //Success: 0%, Failure: 10% function attemptInfiltrationStealthKnockout(inst) { var chance = getInfiltrationStealthKnockoutChance(inst); - inst.gainStrengthExp(inst.securityLevel / 100) * Player.strength_exp_mult; - inst.gainDexterityExp(inst.securityLevel / 75) * Player.dexterity_exp_mult; - inst.gainAgilityExp(inst.securityLevel / 75) * Player.agility_exp_mult; + inst.gainStrengthExp(inst.securityLevel / 90) * Player.strength_exp_mult; + inst.gainDexterityExp(inst.securityLevel / 70) * Player.dexterity_exp_mult; + inst.gainAgilityExp(inst.securityLevel / 70) * Player.agility_exp_mult; if (Math.random() <= chance) { return [true, 1]; } else { @@ -663,9 +667,9 @@ function getInfiltrationStealthKnockoutChance(inst) { //Success: 0%, Failure: 5%, -Karma function attemptInfiltrationAssassinate(inst) { var chance = getInfiltrationAssassinateChance(inst); - inst.gainStrengthExp(inst.securityLevel / 100) * Player.strength_exp_mult; - inst.gainDexterityExp(inst.securityLevel / 75) * Player.dexterity_exp_mult; - inst.gainAgilityExp(inst.securityLevel / 75) * Player.agility_exp_mult; + inst.gainStrengthExp(inst.securityLevel / 90) * Player.strength_exp_mult; + inst.gainDexterityExp(inst.securityLevel / 70) * Player.dexterity_exp_mult; + inst.gainAgilityExp(inst.securityLevel / 70) * Player.agility_exp_mult; if (Math.random() <= chance) { return [true, 1]; } else { @@ -687,10 +691,10 @@ function getInfiltrationAssassinateChance(inst) { //Success: 5%, Failure: 10% function attemptInfiltrationDestroySecurity(inst) { var chance = getInfiltrationDestroySecurityChance(inst); - inst.gainStrengthExp(inst.securityLevel / 100) * Player.strength_exp_mult; - inst.gainDefenseExp(inst.securityLevel / 100) * Player.defense_exp_mult; - inst.gainDexterityExp(inst.securityLevel / 100) * Player.dexterity_exp_mult; - inst.gainAgilityExp(inst.securityLevel / 100) * Player.agility_exp_mult; + inst.gainStrengthExp(inst.securityLevel / 90) * Player.strength_exp_mult; + inst.gainDefenseExp(inst.securityLevel / 90) * Player.defense_exp_mult; + inst.gainDexterityExp(inst.securityLevel / 90) * Player.dexterity_exp_mult; + inst.gainAgilityExp(inst.securityLevel / 90) * Player.agility_exp_mult; if (Math.random() <= chance) { inst.securityLevel *= 1.05; return [true, 1.05]; @@ -714,7 +718,8 @@ function getInfiltrationDestroySecurityChance(inst) { //Success: 1%, Failure: 5% function attemptInfiltrationHack(inst) { var chance = getInfiltrationHackChance(inst); - inst.gainHackingExp(inst.securityLevel / 75) * Player.hacking_exp_mult; + inst.gainHackingExp(inst.securityLevel / 50) * Player.hacking_exp_mult; + inst.gainIntelligenceExp(inst.securityLevel / 700); if (Math.random() <= chance) { inst.securityLevel *= 1.03; return [true, 1.03]; @@ -736,7 +741,7 @@ function getInfiltrationHackChance(inst) { //Success: 0%, Failure: 8% function attemptInfiltrationSneak(inst) { var chance = getInfiltrationSneakChance(inst); - inst.gainAgilityExp(inst.securityLevel / 75) * Player.agility_exp_mult; + inst.gainAgilityExp(inst.securityLevel / 50) * Player.agility_exp_mult; if (Math.random() <= chance) { return [true, 1]; } else { @@ -757,7 +762,7 @@ function getInfiltrationSneakChance(inst) { //Success: 1%, Failure: 3% function attemptInfiltrationPickLockedDoor(inst) { var chance = getInfiltrationPickLockedDoorChance(inst); - inst.gainDexterityExp(inst.securityLevel / 75) * Player.dexterity_exp_mult; + inst.gainDexterityExp(inst.securityLevel / 40) * Player.dexterity_exp_mult; if (Math.random() <= chance) { inst.securityLevel *= 1.01; return [true, 1.01]; @@ -778,7 +783,7 @@ function getInfiltrationPickLockedDoorChance(inst) { //Success: 0%, Failure: 15%, function attemptInfiltrationBribe(inst) { var chance = getInfiltrationBribeChance(inst); - inst.gainCharismaExp(inst.securityLevel / 50) * Player.charisma_exp_mult; + inst.gainCharismaExp(inst.securityLevel / 10) * Player.charisma_exp_mult; if (Math.random() <= chance) { return [true, 1]; } else { @@ -797,8 +802,8 @@ function getInfiltrationBribeChance(inst) { //Failure: 5% function attemptInfiltrationEscape(inst) { var chance = getInfiltrationEscapeChance(inst); - inst.gainAgilityExp(inst.securityLevel / 50) * Player.agility_exp_mult; - inst.gainDexterityExp(inst.securityLevel / 50) * Player.dexterity_exp_mult; + inst.gainAgilityExp(inst.securityLevel / 40) * Player.agility_exp_mult; + inst.gainDexterityExp(inst.securityLevel / 40) * Player.dexterity_exp_mult; if (Math.random() <= chance) { return [true, 1]; } else { diff --git a/src/NetscriptFunctions.js b/src/NetscriptFunctions.js index b6bed4b6a..8176ae913 100644 --- a/src/NetscriptFunctions.js +++ b/src/NetscriptFunctions.js @@ -41,7 +41,8 @@ import {StockMarket, StockSymbols, SymbolToStockMap, initStockSymbols, initStockMarket, initSymbolToStockMap, stockMarketCycle, buyStock, sellStock, updateStockPrices, displayStockMarketContent, updateStockTicker, updateStockPlayerPosition, - Stock} from "./StockMarket.js"; + Stock, shortStock, sellShort, OrderTypes, + PositionTypes, placeOrder, cancelOrder} from "./StockMarket.js"; import {post} from "./Terminal.js"; import {TextFile, getTextFile, createTextFile} from "./TextFile.js"; @@ -849,7 +850,7 @@ function NetscriptFunctions(workerScript) { if (stock == null) { throw makeRuntimeRejectMsg(workerScript, "Invalid stock symbol passed into getStockPrice()"); } - return [stock.playerShares, stock.playerAvgPx]; + return [stock.playerShares, stock.playerAvgPx, stock.playerShortShares, stock.playerAvgShortPx]; }, buyStock : function(symbol, shares) { if (!Player.hasTixApiAccess) { @@ -857,9 +858,9 @@ function NetscriptFunctions(workerScript) { } var stock = SymbolToStockMap[symbol]; if (stock == null) { - throw makeRuntimeRejectMsg(workerScript, "Invalid stock symbol passed into getStockPrice()"); + throw makeRuntimeRejectMsg(workerScript, "Invalid stock symbol passed into buyStock()"); } - if (stock == null || shares < 0 || isNaN(shares)) { + if (shares < 0 || isNaN(shares)) { workerScript.scriptRef.log("Error: Invalid 'shares' argument passed to buyStock()"); return false; } @@ -892,10 +893,9 @@ function NetscriptFunctions(workerScript) { } var stock = SymbolToStockMap[symbol]; if (stock == null) { - throw makeRuntimeRejectMsg(workerScript, "Invalid stock symbol passed into getStockPrice()"); + throw makeRuntimeRejectMsg(workerScript, "Invalid stock symbol passed into sellStock()"); } - - if (stock == null || shares < 0 || isNaN(shares)) { + if (shares < 0 || isNaN(shares)) { workerScript.scriptRef.log("Error: Invalid 'shares' argument passed to sellStock()"); return false; } @@ -923,6 +923,121 @@ function NetscriptFunctions(workerScript) { "$" + formatNumber(gains, 2)); return true; }, + shortStock(symbol, shares) { + if (!Player.hasTixApiAccess) { + throw makeRuntimeRejectMsg(workerScript, "You don't have TIX API Access! Cannot use shortStock()"); + } + if (Player.bitNodeN !== 8) { + if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) { + throw makeRuntimeRejectMsg(workerScript, "ERROR: Cannot use shortStock(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8"); + } + } + var stock = SymbolToStockMap[symbol]; + if (stock == null) { + throw makeRuntimeRejectMsg(workerScript, "ERROR: Invalid stock symbol passed into shortStock()"); + } + return shortStock(stock, shares, workerScript); + }, + sellShort(symbol, shares) { + if (!Player.hasTixApiAccess) { + throw makeRuntimeRejectMsg(workerScript, "You don't have TIX API Access! Cannot use sellShort()"); + } + if (Player.bitNodeN !== 8) { + if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) { + throw makeRuntimeRejectMsg(workerScript, "ERROR: Cannot use sellShort(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8"); + } + } + var stock = SymbolToStockMap[symbol]; + if (stock == null) { + throw makeRuntimeRejectMsg(workerScript, "ERROR: Invalid stock symbol passed into sellShort()"); + } + return sellShort(stock, shares, workerScript); + }, + placeOrder(symbol, shares, price, type, pos) { + if (!Player.hasTixApiAccess) { + throw makeRuntimeRejectMsg(workerScript, "You don't have TIX API Access! Cannot use placeOrder()"); + } + if (Player.bitNodeN !== 8) { + if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) { + throw makeRuntimeRejectMsg(workerScript, "ERROR: Cannot use placeOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8"); + } + } + var stock = SymbolToStockMap[symbol]; + if (stock == null) { + throw makeRuntimeRejectMsg(workerScript, "ERROR: Invalid stock symbol passed into placeOrder()"); + } + var orderType, orderPos; + type = type.toLowerCase(); + if (type.includes("limit") && type.includes("buy")) { + orderType = OrderTypes.LimitBuy; + } else if (type.includes("limit") && type.includes("sell")) { + orderType = OrderTypes.LimitSell; + } else if (type.includes("stop") && type.includes("buy")) { + orderType = OrderTypes.StopBuy; + } else if (type.includes("stop") && type.includes("sell")) { + orderType = OrderTypes.StopSell; + } else { + throw makeRuntimeRejectMsg(workerScript, "ERROR: Invalid Order Type passed into placeOrder()"); + } + + pos = pos.toLowerCase(); + if (pos.includes("l")) { + orderPos = PositionTypes.Long; + } else if (pos.includes('s')) { + orderPos = PositionTypes.Short; + } else { + throw makeRuntimeRejectMsg(workerScript, "ERROR: Invalid Position Type passed into placeOrder()"); + } + + return placeOrder(stock, shares, price, orderType, orderPos, workerScript); + }, + cancelOrder(symbol, shares, price, type, pos) { + if (!Player.hasTixApiAccess) { + throw makeRuntimeRejectMsg(workerScript, "You don't have TIX API Access! Cannot use cancelOrder()"); + } + if (Player.bitNodeN !== 8) { + if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) { + throw makeRuntimeRejectMsg(workerScript, "ERROR: Cannot use cancelOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8"); + } + } + var stock = SymbolToStockMap[symbol]; + if (stock == null) { + throw makeRuntimeRejectMsg(workerScript, "ERROR: Invalid stock symbol passed into cancelOrder()"); + } + if (isNaN(shares) || isNaN(price)) { + throw makeRuntimeRejectMsg(workerScript, "ERROR: Invalid shares or price argument passed into cancelOrder(). Must be numeric"); + } + var orderType, orderPos; + type = type.toLowerCase(); + if (type.includes("limit") && type.includes("buy")) { + orderType = OrderTypes.LimitBuy; + } else if (type.includes("limit") && type.includes("sell")) { + orderType = OrderTypes.LimitSell; + } else if (type.includes("stop") && type.includes("buy")) { + orderType = OrderTypes.StopBuy; + } else if (type.includes("stop") && type.includes("sell")) { + orderType = OrderType.StopSell; + } else { + throw makeRuntimeRejectMsg(workerScript, "ERROR: Invalid Order Type passed into placeOrder()"); + } + + pos = pos.toLowerCase(); + if (pos.includes("l")) { + orderPos = PositionTypes.Long; + } else if (pos.includes('s')) { + orderPos = PositionTypes.Short; + } else { + throw makeRuntimeRejectMsg(workerScript, "ERROR: Invalid Position Type passed into placeOrder()"); + } + params = { + stock: stock, + shares: shares, + price: price, + type: orderType, + pos: orderPos + }; + return cancelOrder(params, workerScript); + }, purchaseServer : function(hostname, ram) { var hostnameStr = String(hostname); hostnameStr = hostnameStr.replace(/\s\s+/g, ''); diff --git a/src/Player.js b/src/Player.js index aa86935fb..4e9d5de06 100644 --- a/src/Player.js +++ b/src/Player.js @@ -13,7 +13,7 @@ import {Factions, Faction, displayFactionContent} from "./Faction.js"; import {Gang, resetGangs} from "./Gang.js"; import {Locations} from "./Location.js"; -import {hasBn11SF} from "./NetscriptFunctions.js"; +import {hasBn11SF, hasWallStreetSF} from "./NetscriptFunctions.js"; import {AllServers, Server, AddToAllServers} from "./Server.js"; import {SpecialServerIps, SpecialServerNames} from "./SpecialServerIps.js"; import {SourceFiles, applySourceFile} from "./SourceFile.js"; @@ -367,6 +367,13 @@ PlayerObject.prototype.prestigeSourceFile = function() { this.hasWseAccount = false; this.hasTixApiAccess = false; + //BitNode 8: Ghost of Wall Street + if (this.bitNodeN === 8) {this.money = new Decimal(100000000);} + if (this.bitNodeN === 8 || hasWallStreetSF) { + this.hasWseAccount = true; + this.hasTixApiAccess = true; + } + this.playtimeSinceLastAug = 0; this.scriptProdSinceLastAug = 0; } diff --git a/src/Prestige.js b/src/Prestige.js index b132c0312..65c8f907f 100644 --- a/src/Prestige.js +++ b/src/Prestige.js @@ -9,7 +9,7 @@ import {Factions, Faction, initFactions, joinFaction} from "./Faction.js"; import {Locations} from "./Location.js"; import {initMessages, Messages, Message} from "./Message.js"; -import {initSingularitySFFlags} from "./NetscriptFunctions.js"; +import {initSingularitySFFlags, hasWallStreetSF}from "./NetscriptFunctions.js"; import {WorkerScript, workerScripts, prestigeWorkerScripts} from "./NetscriptWorker.js"; import {Player} from "./Player.js"; @@ -116,6 +116,13 @@ function prestigeAugmentation() { } } + //BitNode 8: Ghost of Wall Street + if (Player.bitNodeN === 8) {Player.money = new Decimal(100000000);} + if (Player.bitNodeN === 8 || hasWallStreetSF) { + Player.hasWseAccount = true; + Player.hasTixApiAccess = true; + } + var mainMenu = document.getElementById("mainmenu-container"); mainMenu.style.visibility = "visible"; Terminal.resetTerminalInput(); diff --git a/src/RedPill.js b/src/RedPill.js index 3ce2e5cc5..d084d06c3 100644 --- a/src/RedPill.js +++ b/src/RedPill.js @@ -209,7 +209,7 @@ function loadBitVerse(destroyedBitNodeNum) { var elemId = "bitnode-" + i.toString(); var elem = clearEventListeners(elemId); if (elem == null) {return;} - if (i === 1 || i === 2 || i === 4 || i === 5 || i === 11) { + if (i === 1 || i === 2 || i === 4 || i === 5 || i === 8 || i === 11) { elem.addEventListener("click", function() { var bitNodeKey = "BitNode" + i; var bitNode = BitNodes[bitNodeKey]; diff --git a/src/SaveObject.js b/src/SaveObject.js index d43ec3d16..0acf8586c 100644 --- a/src/SaveObject.js +++ b/src/SaveObject.js @@ -82,11 +82,12 @@ BitburnerSaveObject.prototype.saveGame = function(db) { } request.onsuccess = function(e) { - console.log("Successfully saved game to IndexedDB!"); + console.log("Saved game to IndexedDB!"); } try { window.localStorage.setItem("bitburnerSave", saveString); + console.log("Saved game to LocalStorage!"); } catch(e) { if (e.code == 22) { Engine.createStatusText("Save failed for localStorage! Check console(F12)"); @@ -98,7 +99,6 @@ BitburnerSaveObject.prototype.saveGame = function(db) { } } - console.log("Game saved!"); Engine.createStatusText("Game saved!"); } diff --git a/src/Script.js b/src/Script.js index 308fcdb46..31b9ff757 100644 --- a/src/Script.js +++ b/src/Script.js @@ -286,7 +286,11 @@ function calculateRamUsage(codeCopy) { var scriptGetStockCount = numOccurrences(codeCopy, "getStockPrice(") + numOccurrences(codeCopy, "getStockPosition("); var scriptBuySellStockCount = numOccurrences(codeCopy, "buyStock(") + - numOccurrences(codeCopy, "sellStock("); + numOccurrences(codeCopy, "sellStock(") + + numOccurrences(codeCopy, "shortStock(") + + numOccurrences(codeCopy, "sellShort(") + + numOccurrences(codeCopy, "placeOrder(") + + numOccurrences(codeCopy, "cancelOrder("); var scriptPurchaseServerCount = numOccurrences(codeCopy, "purchaseServer(") + numOccurrences(codeCopy, "deleteServer(") + numOccurrences(codeCopy, "getPurchasedServers("); @@ -307,7 +311,8 @@ function calculateRamUsage(codeCopy) { numOccurrences(codeCopy, "travelToCity(") + numOccurrences(codeCopy, "purchaseTor(") + numOccurrences(codeCopy, "purchaseProgram(") + - numOccurrences(codeCopy, "getStats("); + numOccurrences(codeCopy, "getStats(") + + numOccurrences(codeCopy, "isBusy("); var singFn2Count = numOccurrences(codeCopy, "upgradeHomeRam(") + numOccurrences(codeCopy, "getUpgradeHomeRamCost(") + numOccurrences(codeCopy, "workForCompany(") + @@ -319,6 +324,7 @@ function calculateRamUsage(codeCopy) { numOccurrences(codeCopy, "getFactionRep("); var singFn3Count = numOccurrences(codeCopy, "createProgram(") + numOccurrences(codeCopy, "commitCrime(") + + numOccurrences(codeCopy, "getCrimeChance(") + numOccurrences(codeCopy, "getOwnedAugmentations(") + numOccurrences(codeCopy, "getAugmentationsFromFaction(") + numOccurrences(codeCopy, "getAugmentationCost(") + diff --git a/src/SourceFile.js b/src/SourceFile.js index 9997aa6eb..2ae3ad9eb 100644 --- a/src/SourceFile.js +++ b/src/SourceFile.js @@ -44,7 +44,12 @@ function initSourceFiles() { "Level 3: 7%"); SourceFiles["SourceFile6"] = new SourceFile(6); SourceFiles["SourceFile7"] = new SourceFile(7); - SourceFiles["SourceFile8"] = new SourceFile(8); + SourceFiles["SourceFile8"] = new SourceFile(8, "This Source-File grants the following benefits:

    " + + "Level 1: Permanent access to WSE and TIX API
    " + + "Level 2: Ability to short stocks in other BitNodes
    " + + "Level 3: Ability to use limit/stop orders in other BitNodes

    " + + "This Source-File also increases your hacking growth multipliers by: " + + "
    Level 1: 8%
    Level 2: 12%
    Level 3: 14%"); SourceFiles["SourceFile9"] = new SourceFile(9); SourceFiles["SourceFile10"] = new SourceFile(10); SourceFiles["SourceFile11"] = new SourceFile(11, "This Source-File makes it so that company favor increases BOTH the player's salary and reputation gain rate " + @@ -131,6 +136,14 @@ function applySourceFile(srcFile) { Player.hacking_mult *= incMult; Player.hacking_exp_mult *= incMult; break; + case 8: //Ghost of Wall Street + var mult = 0; + for (var i = 0; i < srcFile.lvl; ++i) { + mult += (8 / (Math.pow(2, i))); + } + var incMult = 1 + (mult / 100); + Player.hacking_grow_mult *= incMult; + break; case 11: //The Big Crash var mult = 0; for (var i = 0; i < srcFile.lvl; ++i) { diff --git a/src/StockMarket.js b/src/StockMarket.js index 511af0ca3..44a29fa42 100644 --- a/src/StockMarket.js +++ b/src/StockMarket.js @@ -30,6 +30,8 @@ function Stock(name, symbol, mv, b, otlkMag, initPrice=10000) { this.mv = mv; this.b = b; this.otlkMag = otlkMag; + + this.posTxtEl = null; } Stock.prototype.toJSON = function() { @@ -57,8 +59,12 @@ var PositionTypes = { function placeOrder(stock, shares, price, type, position, workerScript=null) { var tixApi = (workerScript instanceof WorkerScript); var order = new Order(stock, shares, price, type, position); - if (isNaN(shares)) { - dialogBoxCreate("ERROR: Invalid number of shares specifies for order"); + if (isNaN(shares) || isNaN(price)) { + if (tixApi) { + workerScript.scriptRef.log("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument"); + } else { + dialogBoxCreate("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument"); + } return false; } if (StockMarket["Orders"] === null) { @@ -72,24 +78,71 @@ function placeOrder(stock, shares, price, type, position, workerScript=null) { } StockMarket["Orders"] = orders; } - StockMarket["Orders"].push(order); + StockMarket["Orders"][stock.symbol].push(order); //Process to see if it should be executed immediately processOrders(order.stock, order.type, order.pos); + updateStockOrderList(order.stock); return true; } +//Returns true if successfully cancels an order, false otherwise +function cancelOrder(params, workerScript=null) { + var tixApi = (workerScript instanceof WorkerScript); + if (StockMarket["Orders"] === null) {return false;} + if (params.order && params.order instanceof Order) { + var order = params.order; + //An 'Order' object is passed in + var stockOrders = StockMarket["Orders"][order.stock.symbol]; + for (var i = 0; i < stockOrders.length; ++i) { + if (order == stockOrders[i]) { + stockOrders.splice(i, 1); + updateStockOrderList(order.stock); + return true; + } + } + return false; + } else if (params.stock && params.shares && params.price && params.type && + params.pos && params.stock instanceof Stock) { + //Order properties are passed in. Need to look for the order + var stockOrders = StockMarket["Orders"][params.stock.symbol]; + var orderTxt = params.stock.symbol + " - " + params.shares + " @ " + + numeral(params.price).format('$0.000a'); + for (var i = 0; i < stockOrders.length; ++i) { + var order = stockOrders[i]; + if (params.shares === order.shares && + params.price === order.price && + params.type === order.type && + params.pos === order.pos) { + stockOrders.splice(i, 1); + updateStockOrderList(order.stock); + if (tixApi) { + workerScript.scriptRef.log("Successfully cancelled order: " + orderTxt); + } + return true; + } + } + if (tixApi) { + workerScript.scriptRef.log("Failed to cancel order: " + orderTxt); + } + return false; + } + return false; +} + function executeOrder(order) { var stock = order.stock; var orderBook = StockMarket["Orders"]; var stockOrders = orderBook[stock.symbol]; var res = true; + console.log("Executing the following order:"); + console.log(order); switch (order.type) { case OrderTypes.LimitBuy: case OrderTypes.StopBuy: if (order.pos === PositionTypes.Long) { res = buyStock(order.stock, order.shares) && res; } else if (order.pos === PositionTypes.Short) { - res = shortStock(oder.stock, order.shares) && res; + res = shortStock(order.stock, order.shares) && res; } break; case OrderTypes.LimitSell: @@ -106,15 +159,18 @@ function executeOrder(order) { for (var i = 0; i < stockOrders.length; ++i) { if (order == stockOrders[i]) { stockOrders.splice(i, 1); + updateStockOrderList(order.stock); return; } } console.log("ERROR: Could not find the following Order in Order Book: "); console.log(order); + } else { + console.log("Order failed to execute"); } } -function Order(stock, price, type, position) { +function Order(stock, shares, price, type, position) { this.stock = stock; this.shares = shares; this.price = price; @@ -271,7 +327,7 @@ function initStockMarket() { StockMarket[watchdog] = watchdogStk; var lexocorp = Locations.VolhavenLexoCorp; - var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 3, getRandomInt(5000, 7500)); + var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 6, getRandomInt(5000, 7500)); StockMarket[lexocorp] = lexocorpStk; var rho = Locations.AevumRhoConstruction; @@ -279,15 +335,15 @@ function initStockMarket() { StockMarket[rho] = rhoStk; var alpha = Locations.Sector12AlphaEnterprises; - var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.05, true, 2, getRandomInt(5000, 7500)); + var alphaStk = new Stock(alpha, StockSymbols[alpha], 2, true, 10, getRandomInt(5000, 7500)); StockMarket[alpha] = alphaStk; var syscore = Locations.VolhavenSysCoreSecurities; - var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.25, true, 0, getRandomInt(4000, 7000)) + var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.25, true, 2, getRandomInt(4000, 7000)) StockMarket[syscore] = syscoreStk; var computek = Locations.VolhavenCompuTek; - var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 0, getRandomInt(2000, 5000)); + var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 2, getRandomInt(2000, 5000)); StockMarket[computek] = computekStk; var netlink = Locations.AevumNetLinkTechnologies; @@ -303,15 +359,15 @@ function initStockMarket() { StockMarket[fns] = fnsStk; var sigmacosm = "Sigma Cosmetics"; - var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 0.9, true, 0, getRandomInt(2000, 3000)); + var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 3, true, 0, getRandomInt(2000, 3000)); StockMarket[sigmacosm] = sigmacosmStk; var joesguns = "Joes Guns"; - var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 1, true, 1, getRandomInt(500, 1000)); + var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 4, true, 1, getRandomInt(500, 1000)); StockMarket[joesguns] = joesgunsStk; var catalyst = "Catalyst Ventures"; - var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.25, true, 0, getRandomInt(1000, 1500)); + var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.6, true, 20, getRandomInt(500, 1000)); StockMarket[catalyst] = catalystStk; var microdyne = "Microdyne Technologies"; @@ -352,8 +408,8 @@ function stockMarketCycle() { for (var name in StockMarket) { if (StockMarket.hasOwnProperty(name)) { var stock = StockMarket[name]; - var thresh = 0.62; - if (stock.b) {thresh = 0.38;} + var thresh = 0.6; + if (stock.b) {thresh = 0.4;} if (Math.random() < thresh) { stock.b = !stock.b; } @@ -510,8 +566,8 @@ function updateStockPrices() { var v = Math.random(); for (var name in StockMarket) { if (StockMarket.hasOwnProperty(name)) { - if (!(stock instanceof Stock)) {continue;} var stock = StockMarket[name]; + if (!(stock instanceof Stock)) {continue;} var av = (v * stock.mv) / 100; if (isNaN(av)) {av = .02;} @@ -666,6 +722,51 @@ function displayStockMarketContent() { return false; }); + var investopediaButton = clearEventListeners("stock-market-investopedia"); + investopediaButton.addEventListener("click", function() { + var txt = "When making a transaction on the stock market, there are two " + + "types of positions: Long and Short. A Long position is the typical " + + "scenario where you buy a stock and earn a profit if the price of that " + + "stock increases. Meanwhile, a Short position is the exact opposite. " + + "In a Short position you purchase shares of a stock and earn a profit " + + "if the price of that stock decreases. This is also called 'shorting' a stock.

    " + + "NOTE: Shorting stocks is not available immediately, and must be unlocked later on in the game.

    " + + "There are three different types of orders you can make to buy or sell " + + "stocks on the exchange: Market Order, Limit Order, and Stop Order. " + + "Note that Limit Orders and Stop Orders are not available immediately, and must be unlocked " + + "later on in the game.

    " + + "When you place a Market Order to buy or sell a stock, the order executes " + + "immediately at whatever the current price of the stock is. For example " + + "if you choose to short a stock with 5000 shares using a Market Order, " + + "you immediately purchase those 5000 shares in a Short position at whatever " + + "the current market price is for that stock.

    " + + "A Limit Order is an order that only executes under certain conditions. " + + "A Limit Order is used to buy or sell a stock at a specified price or better. " + + "For example, lets say you purchased a Long position of 100 shares of some stock " + + "at a price of $10 per share. You can place a Limit Order to sell those 100 shares " + + "at $50 or better. The Limit Order will execute when the price of the stock reaches a " + + "value of $50 or higher.

    " + + "A Stop Order is the opposite of a Limit Order. It is used to buy or sell a stock " + + "at a specified price (before the price gets 'worse'). For example, lets say you purchased " + + "a Short position of 100 shares of some stock at a price of $100 per share. " + + "The current price of the stock is $80 (a profit of $20 per share). You can place a " + + "Stop Order to sell the Short position if the stock's price reaches $90 or higher. " + + "This can be used to lock in your profits and limit any losses.

    " + + "Here is a summary of how each order works and when they execute:

    " + + "In a LONG Position:

    " + + "A Limit Order to buy will execute if the stock's price <= order's price
    " + + "A Limit Order to sell will execute if the stock's price >= order's price
    " + + "A Stop Order to buy will execute if the stock's price >= order's price
    " + + "A Stop Order to sell will execute if the stock's price <= order's price

    " + + "In a SHORT Position:

    " + + "A Limit Order to buy will execute if the stock's price >= order's price
    " + + "A Limit Order to sell will execute if the stock's price <= order's price
    " + + "A Stop Order to buy will execute if the stock's price <= order's price
    " + + "A Stop Order to sell will execute if the stock's price >= order's price."; + dialogBoxCreate(txt); + return false; + }); + var stockList = document.getElementById("stock-market-list"); if (stockList == null) {return;} @@ -702,8 +803,9 @@ function displayStockMarketContent() { for (var name in StockMarket) { if (StockMarket.hasOwnProperty(name)) { var stock = StockMarket[name]; - updateStockTicker(stock, true); + updateStockTicker(stock, null); updateStockPlayerPosition(stock); + updateStockOrderList(stock); } } } @@ -734,6 +836,7 @@ function createStockTicker(stock) { orderList = document.createElement("ul"); qtyInput.classList.add("stock-market-input"); + qtyInput.placeholder = "Quantity (Shares)"; qtyInput.setAttribute("id", tickerId + "-qty-input"); qtyInput.setAttribute("onkeydown", "return ( event.ctrlKey || event.altKey " + " || (47{ var pos = longShortSelect.options[longShortSelect.selectedIndex].text; @@ -777,13 +881,13 @@ function createStockTicker(stock) { if (isNaN(shares)) {return false;} switch (ordType) { case "Market Order": - buyStock(stock, shares); + pos === PositionTypes.Long ? buyStock(stock, shares) : shortStock(stock, shares, null); break; case "Limit Order": case "Stop Order": var yesBtn = yesNoTxtInpBoxGetYesButton(), noBtn = yesNoTxtInpBoxGetNoButton(); - yesBtn.innerText = "Place Buy" + ordType; + yesBtn.innerText = "Place Buy " + ordType; noBtn.innerText = "Cancel Order"; yesBtn.addEventListener("click", ()=>{ var price = Number(yesNoTxtInpBoxGetInput()), type; @@ -793,6 +897,7 @@ function createStockTicker(stock) { type = OrderTypes.StopBuy; } placeOrder(stock, shares, price, type, pos); + yesNoTxtInpBoxClose(); }); noBtn.addEventListener("click", ()=>{ yesNoTxtInpBoxClose(); @@ -807,6 +912,7 @@ function createStockTicker(stock) { }); sellButton.classList.add("stock-market-input"); + sellButton.classList.add("a-link-button"); sellButton.innerHTML = "Sell"; sellButton.addEventListener("click", ()=>{ var pos = longShortSelect.options[longShortSelect.selectedIndex].text; @@ -816,13 +922,13 @@ function createStockTicker(stock) { if (isNaN(shares)) {return false;} switch (ordType) { case "Market Order": - buyStock(stock, shares); + pos === PositionTypes.Long ? sellStock(stock, shares) : sellShort(stock, shares, null); break; case "Limit Order": case "Stop Order": var yesBtn = yesNoTxtInpBoxGetYesButton(), noBtn = yesNoTxtInpBoxGetNoButton(); - yesBtn.innerText = "Place Sell" + ordType; + yesBtn.innerText = "Place Sell " + ordType; noBtn.innerText = "Cancel Order"; yesBtn.addEventListener("click", ()=>{ var price = Number(yesNoTxtInpBoxGetInput()), type; @@ -831,11 +937,13 @@ function createStockTicker(stock) { } else { type = OrderTypes.StopSell; } + yesNoTxtInpBoxClose(); placeOrder(stock, shares, price, type, pos); }); noBtn.addEventListener("click", ()=>{ yesNoTxtInpBoxClose(); }); + yesNoTxtInpBoxCreate("Enter the price for your " + ordType); break; default: console.log("ERROR: Invalid order type"); @@ -846,6 +954,7 @@ function createStockTicker(stock) { positionTxt.setAttribute("id", tickerId + "-position-text"); positionTxt.classList.add("stock-market-position-text"); + stock.posTxtEl = positionTxt; orderList.setAttribute("id", tickerId + "-order-list"); orderList.classList.add("stock-market-order-list"); @@ -863,6 +972,7 @@ function createStockTicker(stock) { document.getElementById("stock-market-list").appendChild(li); updateStockTicker(stock, true); + updateStockOrderList(stock); } function setStockTickerClickHandlers() { @@ -888,8 +998,10 @@ function setStockTickerClickHandlers() { //'increase' argument is a boolean indicating whether the price increased or decreased function updateStockTicker(stock, increase) { + if (Engine.currentPage !== Engine.Page.StockMarket) {return;} if (!(stock instanceof Stock)) { - console.log("Invalid stock in updateStockTicker()"); + console.log("Invalid stock in updateStockTicker():"); + console.log(stock); return; } var tickerId = "stock-market-ticker-" + stock.symbol; @@ -899,8 +1011,10 @@ function updateStockTicker(stock, increase) { console.log("ERROR: Couldn't find ticker element for stock: " + stock.symbol); return; } - hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + stock.price; - increase ? hdr.style.color = "#66ff33" : hdr.style.color = "red"; + hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + formatNumber(stock.price, 2); + if (increase !== null) { + increase ? hdr.style.color = "#66ff33" : hdr.style.color = "red"; + } if (stock.playerShares > 0 || stock.playerShortShares > 0) { updateStockPlayerPosition(stock); @@ -908,13 +1022,17 @@ function updateStockTicker(stock, increase) { } function updateStockPlayerPosition(stock) { + if (Engine.currentPage !== Engine.Page.StockMarket) {return;} if (!(stock instanceof Stock)) { - console.log("Invalid stock in updateStockTicker()"); + console.log("Invalid stock in updateStockPlayerPosition():"); + console.log(stock); return; } - var tickerId = "stock-market-ticker-" + stock.symbol, - positionTxt = document.getElementById(tickerId + "-position-text"); - if (positionTxt === null) { + var tickerId = "stock-market-ticker-" + stock.symbol; + if (!(stock.posTxtEl instanceof Element)) { + stock.posTxtEl = document.getElementById(tickerId + "-position-text"); + } + if (stock.posTxtEl === null) { console.log("ERROR: Could not find stock position element for: " + stock.symbol); return; } @@ -923,29 +1041,39 @@ function updateStockPlayerPosition(stock) { var totalCost = stock.playerShares * stock.playerAvgPx, gains = (stock.price - stock.playerAvgPx) * stock.playerShares, percentageGains = gains / totalCost; + if (isNaN(percentageGains)) {percentageGains = 0;} var shortTotalCost = stock.playerShortShares * stock.playerAvgShortPx, shortGains = (stock.playerAvgShortPx - stock.price) * stock.playerShortShares, shortPercentageGains = shortGains/ shortTotalCost; + if (isNaN(shortPercentageGains)) {shortPercentageGains = 0;} - positionTxt.innerHTML = + stock.posTxtEl.innerHTML = "

    Long Position: " + "Shares in the long position will increase " + "in value if the price of the corresponding stock increases

    " + "
    Shares: " + formatNumber(stock.playerShares, 0) + "
    Average Price: " + numeral(stock.playerAvgPx).format('$0.000a') + + " (Total Cost: " + numeral(totalCost).format('$0.000a') + ")" + "
    Profit: " + numeral(gains).format('$0.000a') + - " (" + formatNumber(percentageGains, 2) + "%)

    " + - "

    Short Position: " + - "Shares in short position will increase " + - "in value if the price of the corresponding stock decreases

    " + - "
    Shares: " + formatNumber(stock.playerShortShares, 0) + - "
    Average Price: " + numeral(stock.playerAvgShortPx).format('$0.000a') + - "
    Profit: " + numeral(shortGains).format('$0.000a') + - " (" + formatNumber(shortPercentageGains, 2) + "%)"; + " (" + formatNumber(percentageGains*100, 2) + "%)

    "; + if (Player.bitNodeN === 8 || (hasWallStreetSF && wallStreetSFLvl >= 2)) { + stock.posTxtEl.innerHTML += + "

    Short Position: " + + "Shares in short position will increase " + + "in value if the price of the corresponding stock decreases

    " + + "
    Shares: " + formatNumber(stock.playerShortShares, 0) + + "
    Average Price: " + numeral(stock.playerAvgShortPx).format('$0.000a') + + " (Total Cost: " + numeral(shortTotalCost).format('$0.000a') + ")" + + "
    Profit: " + numeral(shortGains).format('$0.000a') + + " (" + formatNumber(shortPercentageGains*100, 2) + "%)" + + "

    Orders:

    "; + } + } function updateStockOrderList(stock) { + if (Engine.currentPage !== Engine.Page.StockMarket) {return;} var tickerId = "stock-market-ticker-" + stock.symbol; var orderList = document.getElementById(tickerId + "-order-list"); if (orderList === null) { @@ -960,7 +1088,7 @@ function updateStockOrderList(stock) { } var stockOrders = orderBook[stock.symbol]; if (stockOrders === null) { - console.log("ERROR: Could nto find orders for: " + stock.symbol); + console.log("ERROR: Could not find orders for: " + stock.symbol); return; } @@ -970,17 +1098,32 @@ function updateStockOrderList(stock) { } for (var i = 0; i < stockOrders.length; ++i) { - var order = stockOrders[i]; - var li = document.createElement("li"); - var posText = (order.pos === PositionTypes.Long ? "Long Position" : "Short Position"); - li.innerText = order.type + " - " + posText + " - " + - order.shares + " @ $" + formatNumber(order.price, 2); - orderList.appendChild(li); + (function() { + var order = stockOrders[i]; + var li = document.createElement("li"); + li.style.padding = "4px"; + var posText = (order.pos === PositionTypes.Long ? "Long Position" : "Short Position"); + li.style.color = "white"; + li.innerText = order.type + " - " + posText + " - " + + order.shares + " @ $" + formatNumber(order.price, 2); + + var cancelButton = document.createElement("span"); + cancelButton.classList.add("stock-market-order-cancel-btn"); + cancelButton.classList.add("a-link-button"); + cancelButton.innerHTML = "Cancel Order"; + cancelButton.addEventListener("click", function() { + cancelOrder({order: order}, null); + return false; + }); + li.appendChild(cancelButton); + orderList.appendChild(li); + }()); + } } export {StockMarket, StockSymbols, SymbolToStockMap, initStockSymbols, initStockMarket, initSymbolToStockMap, stockMarketCycle, buyStock, - sellStock, updateStockPrices, displayStockMarketContent, + sellStock, shortStock, sellShort, updateStockPrices, displayStockMarketContent, updateStockTicker, updateStockPlayerPosition, loadStockMarket, - setStockMarketContentCreated, placeOrder, Order, OrderTypes}; + setStockMarketContentCreated, placeOrder, cancelOrder, Order, OrderTypes, PositionTypes}; diff --git a/src/TextFile.js b/src/TextFile.js index 753c44b9c..7a0596f39 100644 --- a/src/TextFile.js +++ b/src/TextFile.js @@ -54,6 +54,7 @@ TextFile.fromJSON = function(value) { Reviver.constructors.TextFile = TextFile; function getTextFile(fn, server) { + if (!fn.endsWith(".txt")) {fn += ".txt";} for (var i = 0; i < server.textFiles.length; ++i) { if (server.textFiles[i].fn === fn) { return server.textFiles[i]; diff --git a/src/engine.js b/src/engine.js index 890ab45a2..839229ab3 100644 --- a/src/engine.js +++ b/src/engine.js @@ -376,8 +376,8 @@ let Engine = { loadStockMarketContent: function() { Engine.hideAllContent(); Engine.Display.stockMarketContent.style.visibility = "visible"; - displayStockMarketContent(); Engine.currentPage = Engine.Page.StockMarket; + displayStockMarketContent(); }, loadGangContent: function() { @@ -988,7 +988,6 @@ let Engine = { } if (Engine.Counters.sCr <= 0) { - //Assume 4Sig will always indicate state of market if (Player.hasWseAccount) { stockMarketCycle(); } diff --git a/utils/InfiltrationBox.js b/utils/InfiltrationBox.js index f008c0d6d..26199f6ac 100644 --- a/utils/InfiltrationBox.js +++ b/utils/InfiltrationBox.js @@ -31,6 +31,7 @@ function infiltrationBoxCreate(inst) { Player.gainDexterityExp(inst.dexExpGained); Player.gainAgilityExp(inst.agiExpGained); Player.gainCharismaExp(inst.chaExpGained); + Player.gainIntelligenceExp(inst.intExpGained); var totalValue = 0; for (var i = 0; i < inst.secretsStolen.length; ++i) {