" +
- "You have been working for " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_37__["convertTimeMsToTimeElapsedString"])(this.timeWorked) + "
" +
- "You will automatically finish after working for 8 hours. You can cancel earlier if you wish, " +
- "but you will only gain half of the reputation you've earned so far."
-}
-
-PlayerObject.prototype.finishWork = function(cancelled, sing=false) {
- //Since the work was cancelled early, player only gains half of what they've earned so far
- if (cancelled) {
- this.workRepGained /= 2;
- }
-
- var company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.companyName];
- company.playerReputation += (this.workRepGained);
-
- this.updateSkillLevels();
-
- var txt = "You earned a total of: " +
- "$" + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workMoneyGained, '0,0.00') + " " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workRepGained, '0,0.0000') + " reputation for the company " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workHackExpGained, '0,0.0000') + " hacking exp " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workStrExpGained, '0,0.0000') + " strength exp " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workDefExpGained, '0,0.0000') + " defense exp " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workDexExpGained, '0,0.0000') + " dexterity exp " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workAgiExpGained, '0,0.0000') + " agility exp " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workChaExpGained, '0,0.0000') + " charisma exp ";
-
- if (cancelled) {
- txt = "You worked a short shift of " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_37__["convertTimeMsToTimeElapsedString"])(this.timeWorked) + "
" +
- "Since you cancelled your work early, you only gained half of the reputation you earned.
" + txt;
- } else {
- txt = "You worked a full shift of 8 hours!
" + txt;
- }
- if (!sing) {Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])(txt);}
-
- var mainMenu = document.getElementById("mainmenu-container");
- mainMenu.style.visibility = "visible";
- this.isWorking = false;
- _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"].loadLocationContent();
-
- if (sing) {
- var res = "You worked a short shift of " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_37__["convertTimeMsToTimeElapsedString"])(this.timeWorked) + " and " +
- "earned $" + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workMoneyGained, '0,0.00') + ", " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workRepGained, '0,0.0000') + " reputation, " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workHackExpGained, '0,0.0000') + " hacking exp, " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workStrExpGained, '0,0.0000') + " strength exp, " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workDefExpGained, '0,0.0000') + " defense exp, " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workDexExpGained, '0,0.0000') + " dexterity exp, " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workAgiExpGained, '0,0.0000') + " agility exp, and " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workChaExpGained, '0,0.0000') + " charisma exp.";
- this.resetWorkStatus();
- return res;
- }
- this.resetWorkStatus();
-}
-
-PlayerObject.prototype.startWorkPartTime = function(companyName) {
- this.resetWorkStatus();
- this.isWorking = true;
- this.companyName = companyName;
- this.workType = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCompanyPartTime;
-
- this.workHackExpGainRate = this.getWorkHackExpGain();
- this.workStrExpGainRate = this.getWorkStrExpGain();
- this.workDefExpGainRate = this.getWorkDefExpGain();
- this.workDexExpGainRate = this.getWorkDexExpGain();
- this.workAgiExpGainRate = this.getWorkAgiExpGain();
- this.workChaExpGainRate = this.getWorkChaExpGain();
- this.workRepGainRate = this.getWorkRepGain();
- this.workMoneyGainRate = this.getWorkMoneyGain();
-
- this.timeNeededToCompleteWork = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MillisecondsPer8Hours;
-
- var newCancelButton = Object(_utils_uiHelpers_clearEventListeners__WEBPACK_IMPORTED_MODULE_34__["clearEventListeners"])("work-in-progress-cancel-button");
- newCancelButton.innerHTML = "Stop Working";
- newCancelButton.addEventListener("click", function() {
- Player.finishWorkPartTime();
- return false;
- });
-
- //Display Work In Progress Screen
- _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"].loadWorkInProgressContent();
-}
-
-PlayerObject.prototype.workPartTime = function(numCycles) {
- //Cap the number of cycles being processed to whatever would put you at the
- //work time limit (8 hours)
- var overMax = false;
- if (this.timeWorked + (_engine__WEBPACK_IMPORTED_MODULE_18__["Engine"]._idleSpeed * numCycles) >= _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MillisecondsPer8Hours) {
- overMax = true;
- numCycles = Math.round((_Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MillisecondsPer8Hours - this.timeWorked) / _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"]._idleSpeed);
- }
- this.timeWorked += _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"]._idleSpeed * numCycles;
-
- this.workRepGainRate = this.getWorkRepGain();
- this.processWorkEarnings(numCycles);
-
- //If timeWorked == 8 hours, then finish. You can only gain 8 hours worth of exp and money
- if (overMax || this.timeWorked >= _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MillisecondsPer8Hours) {
- return this.finishWorkPartTime();
- }
-
- var comp = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.companyName], companyRep = "0";
- if (comp == null || !(comp instanceof _Company_Company__WEBPACK_IMPORTED_MODULE_7__["Company"])) {
- console.log("ERROR: Could not find Company: " + this.companyName);
- } else {
- companyRep = comp.playerReputation;
- }
-
- const position = this.jobs[this.companyName];
-
- var txt = document.getElementById("work-in-progress-text");
- txt.innerHTML = "You are currently working as a " + position +
- " at " + this.companyName + " (Current Company Reputation: " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(companyRep, '0,0') + ")
" +
- "You have been working for " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_37__["convertTimeMsToTimeElapsedString"])(this.timeWorked) + "
" +
-
- "You will automatically finish after working for 20 hours. You can cancel earlier if you wish. " +
- "There is no penalty for cancelling earlier.";
-}
-
-PlayerObject.prototype.finishFactionWork = function(cancelled, sing=false) {
- var faction = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"][this.currentWorkFactionName];
- faction.playerReputation += (this.workRepGained);
-
- this.updateSkillLevels();
-
- var txt = "You worked for your faction " + faction.name + " for a total of " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_37__["convertTimeMsToTimeElapsedString"])(this.timeWorked) + "
" +
- "You earned a total of: " +
- "$" + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workMoneyGained, '0,0.00') + " " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workRepGained, '0,0.0000') + " reputation for the faction " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workHackExpGained, '0,0.0000') + " hacking exp " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workStrExpGained, '0,0.0000') + " strength exp " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workDefExpGained, '0,0.0000') + " defense exp " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workDexExpGained, '0,0.0000') + " dexterity exp " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workAgiExpGained, '0,0.0000') + " agility exp " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workChaExpGained, '0,0.0000') + " charisma exp ";
- if (!sing) {Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])(txt);}
-
- var mainMenu = document.getElementById("mainmenu-container");
- mainMenu.style.visibility = "visible";
-
- this.isWorking = false;
-
- _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"].loadFactionContent();
- Object(_Faction_FactionHelpers__WEBPACK_IMPORTED_MODULE_21__[/* displayFactionContent */ "a"])(faction.name);
- if (sing) {
- var res="You worked for your faction " + faction.name + " for a total of " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_37__["convertTimeMsToTimeElapsedString"])(this.timeWorked) + ". " +
- "You earned " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workRepGained, '0,0.0000') + " rep, " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workHackExpGained, '0,0.0000') + " hacking exp, " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workStrExpGained, '0,0.0000') + " str exp, " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workDefExpGained, '0,0.0000') + " def exp, " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workDexExpGained, '0,0.0000') + " dex exp, " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workAgiExpGained, '0,0.0000') + " agi exp, and " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workChaExpGained, '0,0.0000') + " cha exp.";
- this.resetWorkStatus();
- return res;
- }
- this.resetWorkStatus();
-}
-
-//Money gained per game cycle
-PlayerObject.prototype.getWorkMoneyGain = function() {
- // If player has SF-11, calculate salary multiplier from favor
- let bn11Mult = 1;
- const company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.companyName];
- if (_NetscriptFunctions__WEBPACK_IMPORTED_MODULE_24__[/* hasBn11SF */ "d"]) { bn11Mult = 1 + (company.favor / 100); }
-
- // Get base salary
- const companyPositionName = this.jobs[this.companyName];
- const companyPosition = _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][companyPositionName];
- if (companyPosition == null) {
- console.error(`Could not find CompanyPosition object for ${companyPositionName}. Work salary will be 0`);
- return 0;
- }
-
- return companyPosition.baseSalary * company.salaryMultiplier * this.work_money_mult * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_4__["BitNodeMultipliers"].CompanyWorkMoney * bn11Mult;
-}
-
-//Hack exp gained per game cycle
-PlayerObject.prototype.getWorkHackExpGain = function() {
- const company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.companyName];
- const companyPositionName = this.jobs[this.companyName];
- const companyPosition = _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][companyPositionName];
- if (company == null || companyPosition == null) {
- console.error([`Could not find Company object for ${this.companyName}`,
- `or CompanyPosition object for ${companyPositionName}.`,
- `Work hack exp gain will be 0`].join(" "));
- return 0;
- }
-
- return companyPosition.hackingExpGain * company.expMultiplier * this.hacking_exp_mult * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_4__["BitNodeMultipliers"].CompanyWorkExpGain;
-}
-
-//Str exp gained per game cycle
-PlayerObject.prototype.getWorkStrExpGain = function() {
- const company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.companyName];
- const companyPositionName = this.jobs[this.companyName];
- const companyPosition = _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][companyPositionName];
- if (company == null || companyPosition == null) {
- console.error([`Could not find Company object for ${this.companyName}`,
- `or CompanyPosition object for ${companyPositionName}.`,
- `Work str exp gain will be 0`].join(" "));
- return 0;
- }
-
- return companyPosition.strengthExpGain * company.expMultiplier * this.strength_exp_mult * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_4__["BitNodeMultipliers"].CompanyWorkExpGain;
-}
-
-//Def exp gained per game cycle
-PlayerObject.prototype.getWorkDefExpGain = function() {
- const company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.companyName];
- const companyPositionName = this.jobs[this.companyName];
- const companyPosition = _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][companyPositionName];
- if (company == null || companyPosition == null) {
- console.error([`Could not find Company object for ${this.companyName}`,
- `or CompanyPosition object for ${companyPositionName}.`,
- `Work def exp gain will be 0`].join(" "));
- return 0;
- }
-
- return companyPosition.defenseExpGain * company.expMultiplier * this.defense_exp_mult * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_4__["BitNodeMultipliers"].CompanyWorkExpGain;
-}
-
-//Dex exp gained per game cycle
-PlayerObject.prototype.getWorkDexExpGain = function() {
- const company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.companyName];
- const companyPositionName = this.jobs[this.companyName];
- const companyPosition = _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][companyPositionName];
- if (company == null || companyPosition == null) {
- console.error([`Could not find Company object for ${this.companyName}`,
- `or CompanyPosition object for ${companyPositionName}.`,
- `Work dex exp gain will be 0`].join(" "));
- return 0;
- }
-
- return companyPosition.dexterityExpGain * company.expMultiplier * this.dexterity_exp_mult * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_4__["BitNodeMultipliers"].CompanyWorkExpGain;
-}
-
-//Agi exp gained per game cycle
-PlayerObject.prototype.getWorkAgiExpGain = function() {
- const company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.companyName];
- const companyPositionName = this.jobs[this.companyName];
- const companyPosition = _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][companyPositionName];
- if (company == null || companyPosition == null) {
- console.error([`Could not find Company object for ${this.companyName}`,
- `or CompanyPosition object for ${companyPositionName}.`,
- `Work agi exp gain will be 0`].join(" "));
- return 0;
- }
-
- return companyPosition.agilityExpGain * company.expMultiplier * this.agility_exp_mult * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_4__["BitNodeMultipliers"].CompanyWorkExpGain;
-}
-
-//Charisma exp gained per game cycle
-PlayerObject.prototype.getWorkChaExpGain = function() {
- const company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.companyName];
- const companyPositionName = this.jobs[this.companyName];
- const companyPosition = _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][companyPositionName];
- if (company == null || companyPosition == null) {
- console.error([`Could not find Company object for ${this.companyName}`,
- `or CompanyPosition object for ${companyPositionName}.`,
- `Work cha exp gain will be 0`].join(" "));
- return 0;
- }
-
- return companyPosition.charismaExpGain * company.expMultiplier * this.charisma_exp_mult * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_4__["BitNodeMultipliers"].CompanyWorkExpGain;
-}
-
-//Reputation gained per game cycle
-PlayerObject.prototype.getWorkRepGain = function() {
- const company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.companyName];
- const companyPositionName = this.jobs[this.companyName];
- const companyPosition = _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][companyPositionName];
- if (company == null || companyPosition == null) {
- console.error([`Could not find Company object for ${this.companyName}`,
- `or CompanyPosition object for ${companyPositionName}.`,
- `Work rep gain will be 0`].join(" "));
- return 0;
- }
-
- var jobPerformance = companyPosition.calculateJobPerformance(this.hacking_skill, this.strength,
- this.defense, this.dexterity,
- this.agility, this.charisma);
-
- //Intelligence provides a flat bonus to job performance
- jobPerformance += (this.intelligence / _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MaxSkillLevel);
-
- //Update reputation gain rate to account for company favor
- var favorMult = 1 + (company.favor / 100);
- if (isNaN(favorMult)) { favorMult = 1; }
- return jobPerformance * this.company_rep_mult * favorMult;
-}
-
-PlayerObject.prototype.getFactionSecurityWorkRepGain = function() {
- var t = 0.9 * (this.hacking_skill / _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MaxSkillLevel +
- this.strength / _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MaxSkillLevel +
- this.defense / _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MaxSkillLevel +
- this.dexterity / _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MaxSkillLevel +
- this.agility / _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MaxSkillLevel) / 4.5;
- return t * this.faction_rep_mult;
-}
-
-PlayerObject.prototype.getFactionFieldWorkRepGain = function() {
- var t = 0.9 * (this.hacking_skill / _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MaxSkillLevel +
- this.strength / _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MaxSkillLevel +
- this.defense / _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MaxSkillLevel +
- this.dexterity / _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MaxSkillLevel +
- this.agility / _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MaxSkillLevel +
- this.charisma / _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MaxSkillLevel +
- this.intelligence / _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].MaxSkillLevel) / 5.5;
- return t * this.faction_rep_mult;
-}
-
-/* Creating a Program */
-PlayerObject.prototype.startCreateProgramWork = function(programName, time, reqLevel) {
- this.resetWorkStatus();
- this.isWorking = true;
- this.workType = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCreateProgram;
-
- //Time needed to complete work affected by hacking skill (linearly based on
- //ratio of (your skill - required level) to MAX skill)
- //var timeMultiplier = (CONSTANTS.MaxSkillLevel - (this.hacking_skill - reqLevel)) / CONSTANTS.MaxSkillLevel;
- //if (timeMultiplier > 1) {timeMultiplier = 1;}
- //if (timeMultiplier < 0.01) {timeMultiplier = 0.01;}
- this.createProgramReqLvl = reqLevel;
-
- this.timeNeededToCompleteWork = time;
- //Check for incomplete program
- for (var i = 0; i < this.getHomeComputer().programs.length; ++i) {
- var programFile = this.getHomeComputer().programs[i];
- if (programFile.startsWith(programName) && programFile.endsWith("%-INC")) {
- var res = programFile.split("-");
- if (res.length != 3) {break;}
- var percComplete = Number(res[1].slice(0, -1));
- if (isNaN(percComplete) || percComplete < 0 || percComplete >= 100) {break;}
- this.timeWorkedCreateProgram = percComplete / 100 * this.timeNeededToCompleteWork;
- this.getHomeComputer().programs.splice(i, 1);
- }
- }
-
- this.createProgramName = programName;
-
- var cancelButton = Object(_utils_uiHelpers_clearEventListeners__WEBPACK_IMPORTED_MODULE_34__["clearEventListeners"])("work-in-progress-cancel-button");
- cancelButton.innerHTML = "Cancel work on creating program";
- cancelButton.addEventListener("click", function() {
- Player.finishCreateProgramWork(true);
- return false;
- });
-
- //Display Work In Progress Screen
- _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"].loadWorkInProgressContent();
-}
-
-PlayerObject.prototype.createProgramWork = function(numCycles) {
- //Higher hacking skill will allow you to create programs faster
- var reqLvl = this.createProgramReqLvl;
- var skillMult = (this.hacking_skill / reqLvl); //This should always be greater than 1;
- skillMult = 1 + ((skillMult - 1) / 5); //The divider constant can be adjusted as necessary
-
- //Skill multiplier directly applied to "time worked"
- this.timeWorked += (_engine__WEBPACK_IMPORTED_MODULE_18__["Engine"]._idleSpeed * numCycles);
- this.timeWorkedCreateProgram += (_engine__WEBPACK_IMPORTED_MODULE_18__["Engine"]._idleSpeed * numCycles * skillMult);
- var programName = this.createProgramName;
-
- if (this.timeWorkedCreateProgram >= this.timeNeededToCompleteWork) {
- this.finishCreateProgramWork(false);
- }
-
- var txt = document.getElementById("work-in-progress-text");
- txt.innerHTML = "You are currently working on coding " + programName + ".
" +
- "You have been working for " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_37__["convertTimeMsToTimeElapsedString"])(this.timeWorked) + "
" +
- "The program is " + (this.timeWorkedCreateProgram / this.timeNeededToCompleteWork * 100).toFixed(2) + "% complete. " +
- "If you cancel, your work will be saved and you can come back to complete the program later.";
-}
-
-PlayerObject.prototype.finishCreateProgramWork = function(cancelled, sing=false) {
- var programName = this.createProgramName;
- if (cancelled === false) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("You've finished creating " + programName + "! " +
- "The new program can be found on your home computer.");
-
- this.getHomeComputer().programs.push(programName);
- } else {
- var perc = (Math.floor(this.timeWorkedCreateProgram / this.timeNeededToCompleteWork * 10000)/100).toString();
- var incompleteName = programName + "-" + perc + "%-INC";
- this.getHomeComputer().programs.push(incompleteName);
- }
-
- if (!cancelled) {
- this.gainIntelligenceExp(this.createProgramReqLvl / _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].IntelligenceProgramBaseExpGain);
- }
-
- var mainMenu = document.getElementById("mainmenu-container");
- mainMenu.style.visibility = "visible";
-
- this.isWorking = false;
-
- _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"].loadTerminalContent();
- this.resetWorkStatus();
-}
-
-/* Studying/Taking Classes */
-PlayerObject.prototype.startClass = function(costMult, expMult, className) {
- this.resetWorkStatus();
- this.isWorking = true;
- this.workType = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeStudyClass;
-
- this.className = className;
-
- var gameCPS = 1000 / _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"]._idleSpeed;
-
- //Base exp gains per second
- var baseStudyComputerScienceExp = 0.5;
- var baseDataStructuresExp = 1;
- var baseNetworksExp = 2;
- var baseAlgorithmsExp = 4;
- var baseManagementExp = 2;
- var baseLeadershipExp = 4;
- var baseGymExp = 1;
-
- //Find cost and exp gain per game cycle
- var cost = 0;
- var hackExp = 0, strExp = 0, defExp = 0, dexExp = 0, agiExp = 0, chaExp = 0;
- switch (className) {
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassStudyComputerScience:
- hackExp = baseStudyComputerScienceExp * expMult / gameCPS;
- break;
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassDataStructures:
- cost = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassDataStructuresBaseCost * costMult / gameCPS;
- hackExp = baseDataStructuresExp * expMult / gameCPS;
- break;
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassNetworks:
- cost = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassNetworksBaseCost * costMult / gameCPS;
- hackExp = baseNetworksExp * expMult / gameCPS;
- break;
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassAlgorithms:
- cost = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassAlgorithmsBaseCost * costMult / gameCPS;
- hackExp = baseAlgorithmsExp * expMult / gameCPS;
- break;
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassManagement:
- cost = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassManagementBaseCost * costMult / gameCPS;
- chaExp = baseManagementExp * expMult / gameCPS;
- break;
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassLeadership:
- cost = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassLeadershipBaseCost * costMult / gameCPS;
- chaExp = baseLeadershipExp * expMult / gameCPS;
- break;
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassGymStrength:
- cost = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassGymBaseCost * costMult / gameCPS;
- strExp = baseGymExp * expMult / gameCPS;
- break;
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassGymDefense:
- cost = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassGymBaseCost * costMult / gameCPS;
- defExp = baseGymExp * expMult / gameCPS;
- break;
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassGymDexterity:
- cost = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassGymBaseCost * costMult / gameCPS;
- dexExp = baseGymExp * expMult / gameCPS;
- break;
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassGymAgility:
- cost = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassGymBaseCost * costMult / gameCPS;
- agiExp = baseGymExp * expMult / gameCPS;
- break;
- default:
- throw new Error("ERR: Invalid/unrecognized class name");
- return;
- }
-
- this.workMoneyLossRate = cost;
- this.workHackExpGainRate = hackExp * this.hacking_exp_mult * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_4__["BitNodeMultipliers"].ClassGymExpGain;
- this.workStrExpGainRate = strExp * this.strength_exp_mult * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_4__["BitNodeMultipliers"].ClassGymExpGain;;
- this.workDefExpGainRate = defExp * this.defense_exp_mult * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_4__["BitNodeMultipliers"].ClassGymExpGain;;
- this.workDexExpGainRate = dexExp * this.dexterity_exp_mult * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_4__["BitNodeMultipliers"].ClassGymExpGain;;
- this.workAgiExpGainRate = agiExp * this.agility_exp_mult * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_4__["BitNodeMultipliers"].ClassGymExpGain;;
- this.workChaExpGainRate = chaExp * this.charisma_exp_mult * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_4__["BitNodeMultipliers"].ClassGymExpGain;;
-
- var cancelButton = Object(_utils_uiHelpers_clearEventListeners__WEBPACK_IMPORTED_MODULE_34__["clearEventListeners"])("work-in-progress-cancel-button");
- if (className == _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassGymStrength ||
- className == _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassGymDefense ||
- className == _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassGymDexterity ||
- className == _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].ClassGymAgility) {
- cancelButton.innerHTML = "Stop training at gym";
- } else {
- cancelButton.innerHTML = "Stop taking course";
- }
- cancelButton.addEventListener("click", function() {
- Player.finishClass();
- return false;
- });
-
- //Display Work In Progress Screen
- _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"].loadWorkInProgressContent();
-}
-
-PlayerObject.prototype.takeClass = function(numCycles) {
- this.timeWorked += _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"]._idleSpeed * numCycles;
- var className = this.className;
-
- this.processWorkEarnings(numCycles);
-
- var txt = document.getElementById("work-in-progress-text");
- txt.innerHTML = "You have been " + className + " for " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_37__["convertTimeMsToTimeElapsedString"])(this.timeWorked) + "
" +
- "You gained: "+
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workHackExpGained, '0,0.0000') + " hacking experience " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workStrExpGained, '0,0.0000') + " strength experience " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workDefExpGained, '0,0.0000') + " defense experience " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workDexExpGained, '0,0.0000') + " dexterity experience " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workAgiExpGained, '0,0.0000') + " agility experience " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.workChaExpGained, '0,0.0000') + " charisma experience");
- }
- }
-
- this.gainHackingExp(this.workHackExpGained);
- this.gainStrengthExp(this.workStrExpGained);
- this.gainDefenseExp(this.workDefExpGained);
- this.gainDexterityExp(this.workDexExpGained);
- this.gainAgilityExp(this.workAgiExpGained);
- this.gainCharismaExp(this.workChaExpGained);
- }
- this.committingCrimeThruSingFn = false;
- this.singFnCrimeWorkerScript = null;
- var mainMenu = document.getElementById("mainmenu-container");
- mainMenu.style.visibility = "visible";
- this.isWorking = false;
- this.resetWorkStatus();
- _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"].loadLocationContent();
-}
-
-//Cancels the player's current "work" assignment and gives the proper rewards
-//Used only for Singularity functions, so no popups are created
-PlayerObject.prototype.singularityStopWork = function() {
- if (!this.isWorking) {return "";}
- var res; //Earnings text for work
- switch (this.workType) {
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeStudyClass:
- res = this.finishClass(true);
- break;
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCompany:
- res = this.finishWork(true, true);
- break;
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCompanyPartTime:
- res = this.finishWorkPartTime(true);
- break;
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeFaction:
- res = this.finishFactionWork(true, true);
- break;
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCreateProgram:
- res = this.finishCreateProgramWork(true, true);
- break;
- case _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCrime:
- res = this.finishCrime(true);
- break;
- default:
- console.log("ERROR: Unrecognized work type");
- return "";
- }
- return res;
-}
-
-
-//Returns true if hospitalized, false otherwise
-PlayerObject.prototype.takeDamage = function(amt) {
- this.hp -= amt;
- if (this.hp <= 0) {
- this.hospitalize();
- return true;
- } else {
- return false;
- }
-}
-
-PlayerObject.prototype.hospitalize = function() {
- if (_Settings_Settings__WEBPACK_IMPORTED_MODULE_27__["Settings"].SuppressHospitalizationPopup === false) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])(
- "You were in critical condition! You were taken to the hospital where " +
- "luckily they were able to save your life. You were charged " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(this.max_hp * _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].HospitalCostPerHp, '$0.000a')
- );
- }
-
- this.loseMoney(this.max_hp * _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].HospitalCostPerHp);
- this.hp = this.max_hp;
-}
-
-/********* Company job application **********/
-//Determines the job that the Player should get (if any) at the current company
-//The 'sing' argument designates whether or not this is being called from
-//the applyToCompany() Netscript Singularity function
-PlayerObject.prototype.applyForJob = function(entryPosType, sing=false) {
- // Get current company and job
- let currCompany = null;
- if (this.companyName !== "") {
- currCompany = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.companyName];
- }
- const currPositionName = this.jobs[this.companyName];
-
- // Get company that's being applied to
- const company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.location]; //Company being applied to
- if (!(company instanceof _Company_Company__WEBPACK_IMPORTED_MODULE_7__["Company"])) {
- if (sing) {
- return "ERROR: Invalid company name: " + this.location + ". applyToCompany() failed";
- } else {
- console.error(`Could not find company that matches the location: ${this.location}. Player.applyToCompany() failed`);
- return;
- }
- }
-
- let pos = entryPosType;
-
- if (!this.isQualified(company, pos)) {
- var reqText = Object(_Company_GetJobRequirementText__WEBPACK_IMPORTED_MODULE_10__["getJobRequirementText"])(company, pos);
- if (sing) {return false;}
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("Unforunately, you do not qualify for this position " + reqText);
- return;
- }
-
- while (true) {
- let newPos = Object(_Company_GetNextCompanyPosition__WEBPACK_IMPORTED_MODULE_9__["getNextCompanyPosition"])(pos);
- if (newPos == null) {break;}
-
- //Check if this company has this position
- if (company.hasPosition(newPos)) {
- if (!this.isQualified(company, newPos)) {
- //If player not qualified for next job, break loop so player will be given current job
- break;
- }
- pos = newPos;
- } else {
- break;
- }
- }
-
- //Check if the determined job is the same as the player's current job
- if (currCompany != null) {
- if (currCompany.name == company.name && pos.name == currPositionName) {
- var nextPos = Object(_Company_GetNextCompanyPosition__WEBPACK_IMPORTED_MODULE_9__["getNextCompanyPosition"])(pos);
- if (nextPos == null) {
- if (sing) {return false;}
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("You are already at the highest position for your field! No promotion available");
- } else if (company.hasPosition(nextPos)) {
- if (sing) {return false;}
- var reqText = Object(_Company_GetJobRequirementText__WEBPACK_IMPORTED_MODULE_10__["getJobRequirementText"])(company, nextPos);
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("Unfortunately, you do not qualify for a promotion " + reqText);
- } else {
- if (sing) {return false;}
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("You are already at the highest position for your field! No promotion available");
- }
- return; //Same job, do nothing
- }
- }
-
- this.companyName = company.name;
- this.jobs[company.name] = pos.name;
-
- document.getElementById("world-menu-header").click();
- document.getElementById("world-menu-header").click();
-
- if (sing) { return true; }
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("Congratulations! You were offered a new job at " + this.companyName + " as a " + pos.name + "!");
-
- _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"].loadLocationContent();
-}
-
-//Returns your next position at a company given the field (software, business, etc.)
-PlayerObject.prototype.getNextCompanyPosition = function(company, entryPosType) {
- var currCompany = null;
- if (this.companyName !== "") {
- currCompany = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.companyName];
- }
-
- //Not employed at this company, so return the entry position
- if (currCompany == null || (currCompany.name != company.name)) {
- return entryPosType;
- }
-
- //If the entry pos type and the player's current position have the same type,
- //return the player's "nextCompanyPosition". Otherwise return the entryposType
- //Employed at this company, so just return the next position if it exists.
- const currentPositionName = this.jobs[this.companyName];
- const currentPosition = _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][currentPositionName];
- if ((currentPosition.isSoftwareJob() && entryPosType.isSoftwareJob()) ||
- (currentPosition.isITJob() && entryPosType.isITJob()) ||
- (currentPosition.isBusinessJob() && entryPosType.isBusinessJob()) ||
- (currentPosition.isSecurityEngineerJob() && entryPosType.isSecurityEngineerJob()) ||
- (currentPosition.isNetworkEngineerJob() && entryPosType.isNetworkEngineerJob()) ||
- (currentPosition.isSecurityJob() && entryPosType.isSecurityJob()) ||
- (currentPosition.isAgentJob() && entryPosType.isAgentJob()) ||
- (currentPosition.isSoftwareConsultantJob() && entryPosType.isSoftwareConsultantJob()) ||
- (currentPosition.isBusinessConsultantJob() && entryPosType.isBusinessConsultantJob()) ||
- (currentPosition.isPartTimeJob() && entryPosType.isPartTimeJob())) {
- return Object(_Company_GetNextCompanyPosition__WEBPACK_IMPORTED_MODULE_9__["getNextCompanyPosition"])(currentPosition);
- }
-
- return entryPosType;
-}
-
-PlayerObject.prototype.applyForSoftwareJob = function(sing=false) {
- return this.applyForJob(_Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["SoftwareCompanyPositions"][0]], sing);
-}
-
-PlayerObject.prototype.applyForSoftwareConsultantJob = function(sing=false) {
- return this.applyForJob(_Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["SoftwareConsultantCompanyPositions"][0]], sing);
-}
-
-PlayerObject.prototype.applyForItJob = function(sing=false) {
- return this.applyForJob(_Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["ITCompanyPositions"][0]], sing);
-}
-
-PlayerObject.prototype.applyForSecurityEngineerJob = function(sing=false) {
- var company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.location]; //Company being applied to
- if (this.isQualified(company, _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["SecurityEngineerCompanyPositions"][0]])) {
- return this.applyForJob(_Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["SecurityEngineerCompanyPositions"][0]], sing);
- } else {
- if (sing) {return false;}
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("Unforunately, you do not qualify for this position");
- }
-}
-
-PlayerObject.prototype.applyForNetworkEngineerJob = function(sing=false) {
- var company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.location]; //Company being applied to
- if (this.isQualified(company, _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["NetworkEngineerCompanyPositions"][0]])) {
- return this.applyForJob(_Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["NetworkEngineerCompanyPositions"][0]], sing);
- } else {
- if (sing) {return false;}
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("Unforunately, you do not qualify for this position");
- }
-}
-
-PlayerObject.prototype.applyForBusinessJob = function(sing=false) {
- return this.applyForJob(_Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["BusinessCompanyPositions"][0]], sing);
-}
-
-PlayerObject.prototype.applyForBusinessConsultantJob = function(sing=false) {
- return this.applyForJob(_Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["BusinessConsultantCompanyPositions"][0]], sing);
-}
-
-PlayerObject.prototype.applyForSecurityJob = function(sing=false) {
- // TODO Police Jobs
- // Indexing starts at 2 because 0 is for police officer
- return this.applyForJob(_Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["SecurityCompanyPositions"][2]], sing);
-}
-
-PlayerObject.prototype.applyForAgentJob = function(sing=false) {
- var company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.location]; //Company being applied to
- if (this.isQualified(company, _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["AgentCompanyPositions"][0]])) {
- return this.applyForJob(_Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["AgentCompanyPositions"][0]], sing);
- } else {
- if (sing) {return false;}
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("Unforunately, you do not qualify for this position");
- }
-}
-
-PlayerObject.prototype.applyForEmployeeJob = function(sing=false) {
- var company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.location]; //Company being applied to
- if (this.isQualified(company, _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["MiscCompanyPositions"][1]])) {
- this.companyName = company.name;
- this.jobs[company.name] = _Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["MiscCompanyPositions"][1];
- document.getElementById("world-menu-header").click();
- document.getElementById("world-menu-header").click();
- if (sing) {return true;}
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("Congratulations, you are now employed at " + this.companyName);
- _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"].loadLocationContent();
- } else {
- if (sing) {return false;}
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("Unforunately, you do not qualify for this position");
- }
-}
-
-PlayerObject.prototype.applyForPartTimeEmployeeJob = function(sing=false) {
- var company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.location]; //Company being applied to
- if (this.isQualified(company, _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["PartTimeCompanyPositions"][1]])) {
- this.companyName = company.name;
- this.jobs[company.name] = _Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["PartTimeCompanyPositions"][1];
- document.getElementById("world-menu-header").click();
- document.getElementById("world-menu-header").click();
- if (sing) {return true;}
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("Congratulations, you are now employed part-time at " + this.companyName);
- _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"].loadLocationContent();
- } else {
- if (sing) {return false;}
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("Unforunately, you do not qualify for this position");
- }
-}
-
-PlayerObject.prototype.applyForWaiterJob = function(sing=false) {
- var company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.location]; //Company being applied to
- if (this.isQualified(company, _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["MiscCompanyPositions"][0]])) {
- this.companyName = company.name;
- this.jobs[company.name] = _Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["MiscCompanyPositions"][0];
- document.getElementById("world-menu-header").click();
- document.getElementById("world-menu-header").click();
- if (sing) {return true;}
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("Congratulations, you are now employed as a waiter at " + this.companyName);
- _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"].loadLocationContent();
- } else {
- if (sing) {return false;}
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("Unforunately, you do not qualify for this position");
- }
-}
-
-PlayerObject.prototype.applyForPartTimeWaiterJob = function(sing=false) {
- var company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.location]; //Company being applied to
- if (this.isQualified(company, _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][_Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["PartTimeCompanyPositions"][0]])) {
- this.companyName = company.name;
- this.jobs[company.name] = _Company_data_CompanyPositionNames__WEBPACK_IMPORTED_MODULE_12__["PartTimeCompanyPositions"][0];
- document.getElementById("world-menu-header").click();
- document.getElementById("world-menu-header").click();
- if (sing) {return true;}
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("Congratulations, you are now employed as a part-time waiter at " + this.companyName);
- _engine__WEBPACK_IMPORTED_MODULE_18__["Engine"].loadLocationContent();
- } else {
- if (sing) {return false;}
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_33__["dialogBoxCreate"])("Unforunately, you do not qualify for this position");
- }
-}
-
-//Checks if the Player is qualified for a certain position
-PlayerObject.prototype.isQualified = function(company, position) {
- var offset = company.jobStatReqOffset;
- var reqHacking = position.requiredHacking > 0 ? position.requiredHacking+offset : 0;
- var reqStrength = position.requiredStrength > 0 ? position.requiredStrength+offset : 0;
- var reqDefense = position.requiredDefense > 0 ? position.requiredDefense+offset : 0;
- var reqDexterity = position.requiredDexterity > 0 ? position.requiredDexterity+offset : 0;
- var reqAgility = position.requiredDexterity > 0 ? position.requiredDexterity+offset : 0;
- var reqCharisma = position.requiredCharisma > 0 ? position.requiredCharisma+offset : 0;
-
- if (this.hacking_skill >= reqHacking &&
- this.strength >= reqStrength &&
- this.defense >= reqDefense &&
- this.dexterity >= reqDexterity &&
- this.agility >= reqAgility &&
- this.charisma >= reqCharisma &&
- company.playerReputation >= position.requiredReputation) {
- return true;
- }
- return false;
-}
-
-/********** Reapplying Augmentations and Source File ***********/
-PlayerObject.prototype.reapplyAllAugmentations = function(resetMultipliers=true) {
- console.log("Re-applying augmentations");
- if (resetMultipliers) {
- this.resetMultipliers();
- }
-
- for (let i = 0; i < this.augmentations.length; ++i) {
- //Compatibility with new version
- if (this.augmentations[i].name === "HacknetNode NIC Architecture Neural-Upload") {
- this.augmentations[i].name = "Hacknet Node NIC Architecture Neural-Upload";
- }
-
- const augName = this.augmentations[i].name;
- var aug = _Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augName];
- if (aug == null) {
- console.log(`WARNING: Invalid augmentation name in Player.reapplyAllAugmentations(). Aug ${augName} will be skipped`);
- continue;
- }
- aug.owned = true;
- if (aug.name == _Augmentation_data_AugmentationNames__WEBPACK_IMPORTED_MODULE_3__["AugmentationNames"].NeuroFluxGovernor) {
- for (let j = 0; j < aug.level; ++j) {
- Object(_Augmentation_AugmentationHelpers__WEBPACK_IMPORTED_MODULE_1__[/* applyAugmentation */ "a"])(this.augmentations[i], true);
- }
- continue;
- }
- Object(_Augmentation_AugmentationHelpers__WEBPACK_IMPORTED_MODULE_1__[/* applyAugmentation */ "a"])(this.augmentations[i], true);
- }
-}
-
-PlayerObject.prototype.reapplyAllSourceFiles = function() {
- console.log("Re-applying source files");
- //Will always be called after reapplyAllAugmentations() so multipliers do not have to be reset
- //this.resetMultipliers();
-
- for (let i = 0; i < this.sourceFiles.length; ++i) {
- var srcFileKey = "SourceFile" + this.sourceFiles[i].n;
- var sourceFileObject = _SourceFile__WEBPACK_IMPORTED_MODULE_29__[/* SourceFiles */ "a"][srcFileKey];
- if (sourceFileObject == null) {
- console.log("ERROR: Invalid source file number: " + this.sourceFiles[i].n);
- continue;
- }
- Object(_SourceFile__WEBPACK_IMPORTED_MODULE_29__[/* applySourceFile */ "b"])(this.sourceFiles[i]);
- }
-}
-
-/*************** Check for Faction Invitations *************/
-//This function sets the requirements to join a Faction. It checks whether the Player meets
-//those requirements and will return an array of all factions that the Player should
-//receive an invitation to
-PlayerObject.prototype.checkForFactionInvitations = function() {
- let invitedFactions = []; //Array which will hold all Factions the player should be invited to
-
- var numAugmentations = this.augmentations.length;
-
- var company = _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][this.companyName];
- var companyRep = 0;
- if (company != null) {
- companyRep = company.playerReputation;
- }
-
- const allCompanies = Object.keys(this.jobs);
- const allPositions = Object.values(this.jobs);
-
- //Illuminati
- var illuminatiFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Illuminati"];
- if (!illuminatiFac.isBanned && !illuminatiFac.isMember && !illuminatiFac.alreadyInvited &&
- numAugmentations >= 30 &&
- this.money.gte(150000000000) &&
- this.hacking_skill >= 1500 &&
- this.strength >= 1200 && this.defense >= 1200 &&
- this.dexterity >= 1200 && this.agility >= 1200) {
- invitedFactions.push(illuminatiFac);
- }
-
- //Daedalus
- var daedalusFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Daedalus"];
- if (!daedalusFac.isBanned && !daedalusFac.isMember && !daedalusFac.alreadyInvited &&
- numAugmentations >= 30 &&
- this.money.gte(100000000000) &&
- (this.hacking_skill >= 2500 ||
- (this.strength >= 1500 && this.defense >= 1500 &&
- this.dexterity >= 1500 && this.agility >= 1500))) {
- invitedFactions.push(daedalusFac);
- }
-
- //The Covenant
- var covenantFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["The Covenant"];
- if (!covenantFac.isBanned && !covenantFac.isMember && !covenantFac.alreadyInvited &&
- numAugmentations >= 30 &&
- this.money.gte(75000000000) &&
- this.hacking_skill >= 850 &&
- this.strength >= 850 &&
- this.defense >= 850 &&
- this.dexterity >= 850 &&
- this.agility >= 850) {
- invitedFactions.push(covenantFac);
- }
-
- //ECorp
- var ecorpFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["ECorp"];
- if (!ecorpFac.isBanned && !ecorpFac.isMember && !ecorpFac.alreadyInvited &&
- allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].AevumECorp) && companyRep >= _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].CorpFactionRepRequirement) {
- invitedFactions.push(ecorpFac);
- }
-
- //MegaCorp
- var megacorpFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["MegaCorp"];
- if (!megacorpFac.isBanned && !megacorpFac.isMember && !megacorpFac.alreadyInvited &&
- allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Sector12MegaCorp) && companyRep >= _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].CorpFactionRepRequirement) {
- invitedFactions.push(megacorpFac);
- }
-
- //Bachman & Associates
- var bachmanandassociatesFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Bachman & Associates"];
- if (!bachmanandassociatesFac.isBanned && !bachmanandassociatesFac.isMember &&
- !bachmanandassociatesFac.alreadyInvited &&
- allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].AevumBachmanAndAssociates) && companyRep >= _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].CorpFactionRepRequirement) {
- invitedFactions.push(bachmanandassociatesFac);
- }
-
- //Blade Industries
- var bladeindustriesFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Blade Industries"];
- if (!bladeindustriesFac.isBanned && !bladeindustriesFac.isMember && !bladeindustriesFac.alreadyInvited &&
- allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Sector12BladeIndustries) && companyRep >= _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].CorpFactionRepRequirement) {
- invitedFactions.push(bladeindustriesFac);
- }
-
- //NWO
- var nwoFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["NWO"];
- if (!nwoFac.isBanned && !nwoFac.isMember && !nwoFac.alreadyInvited &&
- allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].VolhavenNWO) && companyRep >= _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].CorpFactionRepRequirement) {
- invitedFactions.push(nwoFac);
- }
-
- //Clarke Incorporated
- var clarkeincorporatedFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Clarke Incorporated"];
- if (!clarkeincorporatedFac.isBanned && !clarkeincorporatedFac.isMember && !clarkeincorporatedFac.alreadyInvited &&
- allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].AevumClarkeIncorporated) && companyRep >= _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].CorpFactionRepRequirement) {
- invitedFactions.push(clarkeincorporatedFac);
- }
-
- //OmniTek Incorporated
- var omnitekincorporatedFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["OmniTek Incorporated"];
- if (!omnitekincorporatedFac.isBanned && !omnitekincorporatedFac.isMember && !omnitekincorporatedFac.alreadyInvited &&
- allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].VolhavenOmniTekIncorporated) && companyRep >= _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].CorpFactionRepRequirement) {
- invitedFactions.push(omnitekincorporatedFac);
- }
-
- //Four Sigma
- var foursigmaFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Four Sigma"];
- if (!foursigmaFac.isBanned && !foursigmaFac.isMember && !foursigmaFac.alreadyInvited &&
- allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Sector12FourSigma) && companyRep >= _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].CorpFactionRepRequirement) {
- invitedFactions.push(foursigmaFac);
- }
-
- //KuaiGong International
- var kuaigonginternationalFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["KuaiGong International"];
- if (!kuaigonginternationalFac.isBanned && !kuaigonginternationalFac.isMember &&
- !kuaigonginternationalFac.alreadyInvited &&
- allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].ChongqingKuaiGongInternational) && companyRep >= _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].CorpFactionRepRequirement) {
- invitedFactions.push(kuaigonginternationalFac);
- }
-
- //Fulcrum Secret Technologies - If u've unlocked fulcrum secret technolgoies server and have a high rep with the company
- var fulcrumsecrettechonologiesFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Fulcrum Secret Technologies"];
- var fulcrumSecretServer = _Server__WEBPACK_IMPORTED_MODULE_26__[/* AllServers */ "b"][_SpecialServerIps__WEBPACK_IMPORTED_MODULE_28__[/* SpecialServerIps */ "a"][_SpecialServerIps__WEBPACK_IMPORTED_MODULE_28__[/* SpecialServerNames */ "b"].FulcrumSecretTechnologies]];
- if (fulcrumSecretServer == null) {
- console.log("ERROR: Could not find Fulcrum Secret Technologies Server");
- } else {
- if (!fulcrumsecrettechonologiesFac.isBanned && !fulcrumsecrettechonologiesFac.isMember &&
- !fulcrumsecrettechonologiesFac.alreadyInvited &&
- fulcrumSecretServer.manuallyHacked &&
- allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].AevumFulcrumTechnologies) && companyRep >= 250000) {
- invitedFactions.push(fulcrumsecrettechonologiesFac);
- }
- }
-
- //BitRunners
- var bitrunnersFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["BitRunners"];
- var homeComp = this.getHomeComputer();
- var bitrunnersServer = _Server__WEBPACK_IMPORTED_MODULE_26__[/* AllServers */ "b"][_SpecialServerIps__WEBPACK_IMPORTED_MODULE_28__[/* SpecialServerIps */ "a"][_SpecialServerIps__WEBPACK_IMPORTED_MODULE_28__[/* SpecialServerNames */ "b"].BitRunnersServer]];
- if (bitrunnersServer == null) {
- console.log("ERROR: Could not find BitRunners Server");
- } else if (!bitrunnersFac.isBanned && !bitrunnersFac.isMember && bitrunnersServer.manuallyHacked &&
- !bitrunnersFac.alreadyInvited && this.hacking_skill >= 500 && homeComp.maxRam >= 128) {
- invitedFactions.push(bitrunnersFac);
- }
-
- //The Black Hand
- var theblackhandFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["The Black Hand"];
- var blackhandServer = _Server__WEBPACK_IMPORTED_MODULE_26__[/* AllServers */ "b"][_SpecialServerIps__WEBPACK_IMPORTED_MODULE_28__[/* SpecialServerIps */ "a"][_SpecialServerIps__WEBPACK_IMPORTED_MODULE_28__[/* SpecialServerNames */ "b"].TheBlackHandServer]];
- if (blackhandServer == null) {
- console.log("ERROR: Could not find The Black Hand Server");
- } else if (!theblackhandFac.isBanned && !theblackhandFac.isMember && blackhandServer.manuallyHacked &&
- !theblackhandFac.alreadyInvited && this.hacking_skill >= 350 && homeComp.maxRam >= 64) {
- invitedFactions.push(theblackhandFac);
- }
-
- //NiteSec
- var nitesecFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["NiteSec"];
- var nitesecServer = _Server__WEBPACK_IMPORTED_MODULE_26__[/* AllServers */ "b"][_SpecialServerIps__WEBPACK_IMPORTED_MODULE_28__[/* SpecialServerIps */ "a"][_SpecialServerIps__WEBPACK_IMPORTED_MODULE_28__[/* SpecialServerNames */ "b"].NiteSecServer]];
- if (nitesecServer == null) {
- console.log("ERROR: Could not find NiteSec Server");
- } else if (!nitesecFac.isBanned && !nitesecFac.isMember && nitesecServer.manuallyHacked &&
- !nitesecFac.alreadyInvited && this.hacking_skill >= 200 && homeComp.maxRam >= 32) {
- invitedFactions.push(nitesecFac);
- }
-
- //Chongqing
- var chongqingFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Chongqing"];
- if (!chongqingFac.isBanned && !chongqingFac.isMember && !chongqingFac.alreadyInvited &&
- this.money.gte(20000000) && this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Chongqing) {
- invitedFactions.push(chongqingFac);
- }
-
- //Sector-12
- var sector12Fac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Sector-12"];
- if (!sector12Fac.isBanned && !sector12Fac.isMember && !sector12Fac.alreadyInvited &&
- this.money.gte(15000000) && this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Sector12) {
- invitedFactions.push(sector12Fac);
- }
-
- //New Tokyo
- var newtokyoFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["New Tokyo"];
- if (!newtokyoFac.isBanned && !newtokyoFac.isMember && !newtokyoFac.alreadyInvited &&
- this.money.gte(20000000) && this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].NewTokyo) {
- invitedFactions.push(newtokyoFac);
- }
-
- //Aevum
- var aevumFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Aevum"];
- if (!aevumFac.isBanned && !aevumFac.isMember && !aevumFac.alreadyInvited &&
- this.money.gte(40000000) && this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Aevum) {
- invitedFactions.push(aevumFac);
- }
-
- //Ishima
- var ishimaFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Ishima"];
- if (!ishimaFac.isBanned && !ishimaFac.isMember && !ishimaFac.alreadyInvited &&
- this.money.gte(30000000) && this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Ishima) {
- invitedFactions.push(ishimaFac);
- }
-
- //Volhaven
- var volhavenFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Volhaven"];
- if (!volhavenFac.isBanned && !volhavenFac.isMember && !volhavenFac.alreadyInvited &&
- this.money.gte(50000000) && this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Volhaven) {
- invitedFactions.push(volhavenFac);
- }
-
- //Speakers for the Dead
- var speakersforthedeadFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Speakers for the Dead"];
- if (!speakersforthedeadFac.isBanned && !speakersforthedeadFac.isMember && !speakersforthedeadFac.alreadyInvited &&
- this.hacking_skill >= 100 && this.strength >= 300 && this.defense >= 300 &&
- this.dexterity >= 300 && this.agility >= 300 && this.numPeopleKilled >= 30 &&
- this.karma <= -45 && !allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Sector12CIA) &&
- !allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Sector12NSA)) {
- invitedFactions.push(speakersforthedeadFac);
- }
-
- //The Dark Army
- var thedarkarmyFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["The Dark Army"];
- if (!thedarkarmyFac.isBanned && !thedarkarmyFac.isMember && !thedarkarmyFac.alreadyInvited &&
- this.hacking_skill >= 300 && this.strength >= 300 && this.defense >= 300 &&
- this.dexterity >= 300 && this.agility >= 300 && this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Chongqing &&
- this.numPeopleKilled >= 5 && this.karma <= -45 && !allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Sector12CIA) &&
- !allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Sector12NSA)) {
- invitedFactions.push(thedarkarmyFac);
- }
-
- //The Syndicate
- var thesyndicateFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["The Syndicate"];
- if (!thesyndicateFac.isBanned && !thesyndicateFac.isMember && !thesyndicateFac.alreadyInvited &&
- this.hacking_skill >= 200 && this.strength >= 200 && this.defense >= 200 &&
- this.dexterity >= 200 && this.agility >= 200 &&
- (this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Aevum || this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Sector12) &&
- this.money.gte(10000000) && this.karma <= -90 &&
- !allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Sector12CIA) && !allCompanies.includes(_Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Sector12NSA)) {
- invitedFactions.push(thesyndicateFac);
- }
-
- //Silhouette
- var silhouetteFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Silhouette"];
- if (!silhouetteFac.isBanned && !silhouetteFac.isMember && !silhouetteFac.alreadyInvited &&
- (allPositions.includes("Chief Technology Officer") ||
- allPositions.includes("Chief Financial Officer") ||
- allPositions.includes("Chief Executive Officer")) &&
- this.money.gte(15000000) && this.karma <= -22) {
- invitedFactions.push(silhouetteFac);
- }
-
- //Tetrads
- var tetradsFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Tetrads"];
- if (!tetradsFac.isBanned && !tetradsFac.isMember && !tetradsFac.alreadyInvited &&
- (this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Chongqing || this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].NewTokyo ||
- this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Ishima) && this.strength >= 75 && this.defense >= 75 &&
- this.dexterity >= 75 && this.agility >= 75 && this.karma <= -18) {
- invitedFactions.push(tetradsFac);
- }
-
- //SlumSnakes
- var slumsnakesFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Slum Snakes"];
- if (!slumsnakesFac.isBanned && !slumsnakesFac.isMember && !slumsnakesFac.alreadyInvited &&
- this.strength >= 30 && this.defense >= 30 && this.dexterity >= 30 &&
- this.agility >= 30 && this.karma <= -9 && this.money.gte(1000000)) {
- invitedFactions.push(slumsnakesFac);
- }
-
- //Netburners
- var netburnersFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Netburners"];
- var totalHacknetRam = 0;
- var totalHacknetCores = 0;
- var totalHacknetLevels = 0;
- for (var i = 0; i < this.hacknetNodes.length; ++i) {
- totalHacknetLevels += this.hacknetNodes[i].level;
- totalHacknetRam += this.hacknetNodes[i].ram;
- totalHacknetCores += this.hacknetNodes[i].cores;
- }
- if (!netburnersFac.isBanned && !netburnersFac.isMember && !netburnersFac.alreadyInvited &&
- this.hacking_skill >= 80 && totalHacknetRam >= 8 &&
- totalHacknetCores >= 4 && totalHacknetLevels >= 100) {
- invitedFactions.push(netburnersFac);
- }
-
- //Tian Di Hui
- var tiandihuiFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["Tian Di Hui"];
- if (!tiandihuiFac.isBanned && !tiandihuiFac.isMember && !tiandihuiFac.alreadyInvited &&
- this.money.gte(1000000) && this.hacking_skill >= 50 &&
- (this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Chongqing || this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].NewTokyo ||
- this.city == _Locations__WEBPACK_IMPORTED_MODULE_23__["Locations"].Ishima)) {
- invitedFactions.push(tiandihuiFac);
- }
-
- //CyberSec
- var cybersecFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"]["CyberSec"];
- var cybersecServer = _Server__WEBPACK_IMPORTED_MODULE_26__[/* AllServers */ "b"][_SpecialServerIps__WEBPACK_IMPORTED_MODULE_28__[/* SpecialServerIps */ "a"][_SpecialServerIps__WEBPACK_IMPORTED_MODULE_28__[/* SpecialServerNames */ "b"].CyberSecServer]];
- if (cybersecServer == null) {
- console.log("ERROR: Could not find CyberSec Server");
- } else if (!cybersecFac.isBanned && !cybersecFac.isMember && cybersecServer.manuallyHacked &&
- !cybersecFac.alreadyInvited && this.hacking_skill >= 50) {
- invitedFactions.push(cybersecFac);
- }
-
- return invitedFactions;
-}
-
-
-/*************** Gang ****************/
-//Returns true if Player is in a gang and false otherwise
-PlayerObject.prototype.inGang = function() {
- if (this.gang == null || this.gang == undefined) {return false;}
- return (this.gang instanceof _Gang__WEBPACK_IMPORTED_MODULE_22__[/* Gang */ "b"]);
-}
-
-PlayerObject.prototype.startGang = function(factionName, hacking) {
- this.gang = new _Gang__WEBPACK_IMPORTED_MODULE_22__[/* Gang */ "b"](factionName, hacking);
-}
-
-/*************** Corporation ****************/
-PlayerObject.prototype.hasCorporation = function() {
- if (this.corporation == null) { return false; }
- return (this.corporation instanceof _Corporation_Corporation__WEBPACK_IMPORTED_MODULE_14__[/* Corporation */ "a"]);
-}
-
-/*************** Bladeburner ****************/
-PlayerObject.prototype.inBladeburner = function() {
- if (this.bladeburner == null) { return false; }
- return (this.bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_5__[/* Bladeburner */ "a"]);
-}
-
-/************* BitNodes **************/
-PlayerObject.prototype.setBitNodeNumber = function(n) {
- this.bitNodeN = n;
-}
-
-PlayerObject.prototype.queueAugmentation = function(name) {
- for(const i in this.queuedAugmentations) {
- if(this.queuedAugmentations[i].name == name) {
- console.log('tried to queue '+name+' twice, this may be a bug');
- return;
- }
- }
-
- for(const i in this.augmentations) {
- if(this.augmentations[i].name == name) {
- console.log('tried to queue '+name+' but we already have that aug');
- return;
- }
- }
-
- this.firstAugPurchased = true;
- this.queuedAugmentations.push(new _Augmentation_PlayerOwnedAugmentation__WEBPACK_IMPORTED_MODULE_2__["PlayerOwnedAugmentation"](name));
-}
-
-/************* Coding Contracts **************/
-PlayerObject.prototype.gainCodingContractReward = function(reward, difficulty=1) {
- if (reward == null || reward.type == null || reward == null) {
- return `No reward for this contract`;
- }
-
- /* eslint-disable no-case-declarations */
- switch (reward.type) {
- case _CodingContracts__WEBPACK_IMPORTED_MODULE_6__["CodingContractRewardType"].FactionReputation:
- if (reward.name == null || !(_Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"][reward.name] instanceof _Faction_Faction__WEBPACK_IMPORTED_MODULE_19__["Faction"])) {
- // If no/invalid faction was designated, just give rewards to all factions
- reward.type = _CodingContracts__WEBPACK_IMPORTED_MODULE_6__["CodingContractRewardType"].FactionReputationAll;
- return this.gainCodingContractReward(reward);
- }
- var repGain = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].CodingContractBaseFactionRepGain * difficulty;
- _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"][reward.name].playerReputation += repGain;
- return `Gained ${repGain} faction reputation for ${reward.name}`;
- case _CodingContracts__WEBPACK_IMPORTED_MODULE_6__["CodingContractRewardType"].FactionReputationAll:
- const totalGain = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].CodingContractBaseFactionRepGain * difficulty;
-
- // Ignore Bladeburners and other special factions for this calculation
- const specialFactions = ["Bladeburners"];
- var factions = this.factions.slice();
- factions = factions.filter((f) => {
- return !specialFactions.includes(f);
- });
-
- // If the player was only part of the special factions, we'll just give money
- if (factions.length == 0) {
- reward.type = _CodingContracts__WEBPACK_IMPORTED_MODULE_6__["CodingContractRewardType"].Money;
- return this.gainCodingContractReward(reward, difficulty);
- }
-
- const gainPerFaction = Math.floor(totalGain / factions.length);
- for (const facName of factions) {
- if (!(_Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"][facName] instanceof _Faction_Faction__WEBPACK_IMPORTED_MODULE_19__["Faction"])) { continue; }
- _Faction_Factions__WEBPACK_IMPORTED_MODULE_20__["Factions"][facName].playerReputation += gainPerFaction;
- }
- return `Gained ${gainPerFaction} reputation for each of the following factions: ${factions.toString()}`;
- break;
- case _CodingContracts__WEBPACK_IMPORTED_MODULE_6__["CodingContractRewardType"].CompanyReputation:
- if (reward.name == null || !(_Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][reward.name] instanceof _Company_Company__WEBPACK_IMPORTED_MODULE_7__["Company"])) {
- //If no/invalid company was designated, just give rewards to all factions
- reward.type = _CodingContracts__WEBPACK_IMPORTED_MODULE_6__["CodingContractRewardType"].FactionReputationAll;
- return this.gainCodingContractReward(reward);
- }
- var repGain = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].CodingContractBaseCompanyRepGain * difficulty;
- _Company_Companies__WEBPACK_IMPORTED_MODULE_8__["Companies"][reward.name].playerReputation += repGain;
- return `Gained ${repGain} company reputation for ${reward.name}`;
- break;
- case _CodingContracts__WEBPACK_IMPORTED_MODULE_6__["CodingContractRewardType"].Money:
- default:
- var moneyGain = _Constants__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].CodingContractBaseMoneyGain * difficulty * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_4__["BitNodeMultipliers"].CodingContractMoney;
- this.gainMoney(moneyGain);
- return `Gained ${_ui_numeralFormat__WEBPACK_IMPORTED_MODULE_32__["numeralWrapper"].format(moneyGain, '$0.000a')}`;
- break;
- }
- /* eslint-enable no-case-declarations */
-}
-
-/* Functions for saving and loading the Player data */
-function loadPlayer(saveString) {
- Player = JSON.parse(saveString, _utils_JSONReviver__WEBPACK_IMPORTED_MODULE_36__["Reviver"]);
-
- //Parse Decimal.js objects
- Player.money = new decimal_js__WEBPACK_IMPORTED_MODULE_31__[/* default */ "a"](Player.money);
- Player.total_money = new decimal_js__WEBPACK_IMPORTED_MODULE_31__[/* default */ "a"](Player.total_money);
- Player.lifetime_money = new decimal_js__WEBPACK_IMPORTED_MODULE_31__[/* default */ "a"](Player.lifetime_money);
-
- if (Player.corporation instanceof _Corporation_Corporation__WEBPACK_IMPORTED_MODULE_14__[/* Corporation */ "a"]) {
- Player.corporation.funds = new decimal_js__WEBPACK_IMPORTED_MODULE_31__[/* default */ "a"](Player.corporation.funds);
- Player.corporation.revenue = new decimal_js__WEBPACK_IMPORTED_MODULE_31__[/* default */ "a"](Player.corporation.revenue);
- Player.corporation.expenses = new decimal_js__WEBPACK_IMPORTED_MODULE_31__[/* default */ "a"](Player.corporation.expenses);
-
- for (var i = 0; i < Player.corporation.divisions.length; ++i) {
- var ind = Player.corporation.divisions[i];
- ind.lastCycleRevenue = new decimal_js__WEBPACK_IMPORTED_MODULE_31__[/* default */ "a"](ind.lastCycleRevenue);
- ind.lastCycleExpenses = new decimal_js__WEBPACK_IMPORTED_MODULE_31__[/* default */ "a"](ind.lastCycleExpenses);
- ind.thisCycleRevenue = new decimal_js__WEBPACK_IMPORTED_MODULE_31__[/* default */ "a"](ind.thisCycleRevenue);
- ind.thisCycleExpenses = new decimal_js__WEBPACK_IMPORTED_MODULE_31__[/* default */ "a"](ind.thisCycleExpenses);
- }
- }
-}
-
-PlayerObject.prototype.toJSON = function() {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_36__["Generic_toJSON"])("PlayerObject", this);
-}
-
-PlayerObject.fromJSON = function(value) {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_36__["Generic_fromJSON"])(PlayerObject, value.data);
-}
-
-_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_36__["Reviver"].constructors.PlayerObject = PlayerObject;
-
-let Player = new PlayerObject();
-
-
-
-/***/ }),
-/* 1 */
-/*!**************************!*\
- !*** ./src/Constants.ts ***!
- \**************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.CONSTANTS = {
- Version: "0.42.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
- //the player will have this level assuming no multipliers. Multipliers can cause skills to go above this.
- MaxSkillLevel: 975,
- //Milliseconds per game cycle
- MilliPerCycle: 200,
- //How much reputation is needed to join a megacorporation's faction
- CorpFactionRepRequirement: 200e3,
- /* Base costs */
- BaseCostFor1GBOfRamHome: 32000,
- BaseCostFor1GBOfRamServer: 55000,
- BaseCostFor1GBOfRamHacknetNode: 30000,
- TravelCost: 200e3,
- BaseCostForHacknetNode: 1000,
- BaseCostForHacknetNodeCore: 500000,
- /* Hacknet Node constants */
- HacknetNodeMoneyGainPerLevel: 1.6,
- HacknetNodePurchaseNextMult: 1.85,
- HacknetNodeUpgradeLevelMult: 1.04,
- HacknetNodeUpgradeRamMult: 1.28,
- HacknetNodeUpgradeCoreMult: 1.48,
- HacknetNodeMaxLevel: 200,
- HacknetNodeMaxRam: 64,
- HacknetNodeMaxCores: 16,
- /* Faction and Company favor */
- BaseFavorToDonate: 150,
- DonateMoneyToRepDivisor: 1e6,
- FactionReputationToFavorBase: 500,
- FactionReputationToFavorMult: 1.02,
- CompanyReputationToFavorBase: 500,
- CompanyReputationToFavorMult: 1.02,
- /* Augmentation */
- //NeuroFlux Governor cost multiplier as you level up
- NeuroFluxGovernorLevelMult: 1.14,
- /* Netscript Constants */
- //RAM Costs for different commands
- ScriptBaseRamCost: 1.6,
- ScriptDomRamCost: 25,
- ScriptWhileRamCost: 0,
- ScriptForRamCost: 0,
- ScriptIfRamCost: 0,
- ScriptHackRamCost: 0.1,
- ScriptHackAnalyzeRamCost: 1,
- ScriptGrowRamCost: 0.15,
- ScriptGrowthAnalyzeRamCost: 1,
- ScriptWeakenRamCost: 0.15,
- ScriptScanRamCost: 0.2,
- ScriptPortProgramRamCost: 0.05,
- ScriptRunRamCost: 1.0,
- ScriptExecRamCost: 1.3,
- ScriptSpawnRamCost: 2.0,
- ScriptScpRamCost: 0.6,
- ScriptKillRamCost: 0.5,
- ScriptHasRootAccessRamCost: 0.05,
- ScriptGetHostnameRamCost: 0.05,
- ScriptGetHackingLevelRamCost: 0.05,
- ScriptGetMultipliersRamCost: 4.0,
- ScriptGetServerRamCost: 0.1,
- ScriptFileExistsRamCost: 0.1,
- ScriptIsRunningRamCost: 0.1,
- ScriptHacknetNodesRamCost: 4.0,
- ScriptHNUpgLevelRamCost: 0.4,
- ScriptHNUpgRamRamCost: 0.6,
- ScriptHNUpgCoreRamCost: 0.8,
- ScriptGetStockRamCost: 2.0,
- ScriptBuySellStockRamCost: 2.5,
- ScriptGetPurchaseServerRamCost: 0.25,
- ScriptPurchaseServerRamCost: 2.25,
- ScriptGetPurchasedServerLimit: 0.05,
- ScriptGetPurchasedServerMaxRam: 0.05,
- ScriptRoundRamCost: 0.05,
- ScriptReadWriteRamCost: 1.0,
- ScriptArbScriptRamCost: 1.0,
- ScriptGetScriptRamCost: 0.1,
- ScriptGetHackTimeRamCost: 0.05,
- ScriptGetFavorToDonate: 0.10,
- ScriptCodingContractBaseRamCost: 10,
- ScriptSingularityFn1RamCost: 1,
- ScriptSingularityFn2RamCost: 2,
- ScriptSingularityFn3RamCost: 3,
- ScriptSingularityFnRamMult: 2,
- ScriptGangApiBaseRamCost: 4,
- ScriptBladeburnerApiBaseRamCost: 4,
- NumNetscriptPorts: 20,
- //Server constants
- HomeComputerMaxRam: 1073741824,
- ServerBaseGrowthRate: 1.03,
- ServerMaxGrowthRate: 1.0035,
- ServerFortifyAmount: 0.002,
- ServerWeakenAmount: 0.05,
- PurchasedServerLimit: 25,
- PurchasedServerMaxRam: 1048576,
- //Augmentation Constants
- AugmentationCostMultiplier: 5,
- AugmentationRepMultiplier: 2.5,
- MultipleAugMultiplier: 1.9,
- //How much a TOR router costs
- TorRouterCost: 200000,
- //Infiltration constants
- InfiltrationBribeBaseAmount: 100e3,
- InfiltrationMoneyValue: 5e3,
- InfiltrationRepValue: 1.4,
- //Stock market constants
- WSEAccountCost: 200e6,
- TIXAPICost: 5e9,
- MarketData4SCost: 1e9,
- MarketDataTixApi4SCost: 25e9,
- StockMarketCommission: 100e3,
- //Hospital/Health
- HospitalCostPerHp: 100e3,
- //Intelligence-related constants
- IntelligenceCrimeWeight: 0.05,
- IntelligenceInfiltrationWeight: 0.1,
- IntelligenceCrimeBaseExpGain: 0.001,
- IntelligenceProgramBaseExpGain: 500,
- IntelligenceTerminalHackBaseExpGain: 200,
- IntelligenceSingFnBaseExpGain: 0.002,
- IntelligenceClassBaseExpGain: 0.000001,
- IntelligenceHackingMissionBaseExpGain: 0.03,
- //Hacking Missions
- HackingMissionRepToDiffConversion: 10000,
- HackingMissionRepToRewardConversion: 7,
- HackingMissionSpamTimeIncrease: 25000,
- HackingMissionTransferAttackIncrease: 1.05,
- HackingMissionMiscDefenseIncrease: 1.05,
- HackingMissionDifficultyToHacking: 135,
- HackingMissionHowToPlay: "Hacking missions are a minigame that, if won, will reward you with faction reputation.
" +
- "In this game you control a set of Nodes and use them to try and defeat an enemy. Your Nodes " +
- "are colored blue, while the enemy's are red. There are also other nodes on the map colored gray " +
- "that initially belong to neither you nor the enemy. The goal of the game is " +
- "to capture all of the enemy's Database nodes within the time limit. " +
- "If you fail to do this, you will lose.
" +
- "Each Node has three stats: Attack, Defense, and HP. There are five different actions that " +
- "a Node can take:
" +
- "Attack - Targets an enemy Node and lowers its HP. The effectiveness is determined by the owner's Attack, the Player's " +
- "hacking level, and the enemy's defense.
" +
- "Scan - Targets an enemy Node and lowers its Defense. The effectiveness is determined by the owner's Attack, the Player's hacking level, and the " +
- "enemy's defense.
" +
- "Weaken - Targets an enemy Node and lowers its Attack. The effectiveness is determined by the owner's Attack, the Player's hacking level, and the enemy's " +
- "defense.
" +
- "Fortify - Raises the Node's Defense. The effectiveness is determined by your hacking level.
" +
- "Overflow - Raises the Node's Attack but lowers its Defense. The effectiveness is determined by your hacking level.
" +
- "Note that when determining the effectiveness of the above actions, the TOTAL Attack or Defense of the team is used, not just the " +
- "Attack/Defense of the individual Node that is performing the action.
" +
- "To capture a Node, you must lower its HP down to 0.
" +
- "There are six different types of Nodes:
" +
- "CPU Core - These are your main Nodes that are used to perform actions. Capable of performing every action
" +
- "Firewall - Nodes with high defense. These Nodes can 'Fortify'
" +
- "Database - A special type of Node. The player's objective is to conquer all of the enemy's Database Nodes within " +
- "the time limit. These Nodes cannot perform any actions
" +
- "Spam - Conquering one of these Nodes will slow the enemy's trace, giving the player additional time to complete " +
- "the mission. These Nodes cannot perform any actions
" +
- "Transfer - Conquering one of these nodes will increase the Attack of all of your CPU Cores by a small fixed percentage. " +
- "These Nodes are capable of performing every action except the 'Attack' action
" +
- "Shield - Nodes with high defense. These Nodes can 'Fortify'
" +
- "To assign an action to a Node, you must first select one of your Nodes. This can be done by simply clicking on it. Double-clicking " +
- "a node will select all of your Nodes of the same type (e.g. select all CPU Core Nodes or all Transfer Nodes). Note that only Nodes " +
- "that can perform actions (CPU Core, Transfer, Shield, Firewall) can be selected. Selected Nodes will be denoted with a white highlight. After selecting a Node or multiple Nodes, " +
- "select its action using the Action Buttons near the top of the screen. Every action also has a corresponding keyboard " +
- "shortcut.
" +
- "For certain actions such as attacking, scanning, and weakening, the Node performing the action must have a target. To target " +
- "another node, simply click-and-drag from the 'source' Node to a target. A Node can only have one target, and you can target " +
- "any Node that is adjacent to one of your Nodes (immediately above, below, or to the side. NOT diagonal). Furthermore, only CPU Cores and Transfer Nodes " +
- "can target, since they are the only ones that can perform the related actions. To remove a target, you can simply click on the line that represents " +
- "the connection between one of your Nodes and its target. Alternatively, you can select the 'source' Node and click the 'Drop Connection' button, " +
- "or press 'd'.
" +
- "Other Notes:
" +
- "-Whenever a miscellenaous Node (not owned by the player or enemy) is conquered, the defense of all remaining miscellaneous Nodes that " +
- "are not actively being targeted will increase by a fixed percentage.
" +
- "-Whenever a Node is conquered, its stats are significantly reduced
" +
- "-Miscellaneous Nodes slowly raise their defense over time
" +
- "-Nodes slowly regenerate health over time.",
- /* Time Constants */
- MillisecondsPer20Hours: 72000000,
- GameCyclesPer20Hours: 72000000 / 200,
- MillisecondsPer10Hours: 36000000,
- GameCyclesPer10Hours: 36000000 / 200,
- MillisecondsPer8Hours: 28800000,
- GameCyclesPer8Hours: 28800000 / 200,
- MillisecondsPer4Hours: 14400000,
- GameCyclesPer4Hours: 14400000 / 200,
- MillisecondsPer2Hours: 7200000,
- GameCyclesPer2Hours: 7200000 / 200,
- MillisecondsPerHour: 3600000,
- GameCyclesPerHour: 3600000 / 200,
- MillisecondsPerHalfHour: 1800000,
- GameCyclesPerHalfHour: 1800000 / 200,
- MillisecondsPerQuarterHour: 900000,
- GameCyclesPerQuarterHour: 900000 / 200,
- MillisecondsPerFiveMinutes: 300000,
- GameCyclesPerFiveMinutes: 300000 / 200,
- /* Player Work / Action related Constants */
- FactionWorkHacking: "Faction Hacking Work",
- FactionWorkField: "Faction Field Work",
- FactionWorkSecurity: "Faction Security Work",
- WorkTypeCompany: "Working for Company",
- WorkTypeCompanyPartTime: "Working for Company part-time",
- WorkTypeFaction: "Working for Faction",
- WorkTypeCreateProgram: "Working on Create a Program",
- WorkTypeStudyClass: "Studying or Taking a class at university",
- WorkTypeCrime: "Committing a crime",
- ClassStudyComputerScience: "studying Computer Science",
- ClassDataStructures: "taking a Data Structures course",
- ClassNetworks: "taking a Networks course",
- ClassAlgorithms: "taking an Algorithms course",
- ClassManagement: "taking a Management course",
- ClassLeadership: "taking a Leadership course",
- ClassGymStrength: "training your strength at a gym",
- ClassGymDefense: "training your defense at a gym",
- ClassGymDexterity: "training your dexterity at a gym",
- ClassGymAgility: "training your agility at a gym",
- ClassDataStructuresBaseCost: 40,
- ClassNetworksBaseCost: 80,
- ClassAlgorithmsBaseCost: 320,
- ClassManagementBaseCost: 160,
- ClassLeadershipBaseCost: 320,
- ClassGymBaseCost: 120,
- CrimeShoplift: "shoplift",
- CrimeRobStore: "rob a store",
- CrimeMug: "mug someone",
- CrimeLarceny: "commit larceny",
- CrimeDrugs: "deal drugs",
- CrimeBondForgery: "forge corporate bonds",
- CrimeTraffickArms: "traffick illegal arms",
- CrimeHomicide: "commit homicide",
- CrimeGrandTheftAuto: "commit grand theft auto",
- CrimeKidnap: "kidnap someone for ransom",
- CrimeAssassination: "assassinate a high-profile target",
- CrimeHeist: "pull off the ultimate heist",
- /* Coding Contract Constants */
- CodingContractBaseFactionRepGain: 2500,
- CodingContractBaseCompanyRepGain: 4000,
- CodingContractBaseMoneyGain: 50e6,
- // BitNode/Source-File related stuff
- TotalNumBitNodes: 24,
- /* Tutorial related things */
- TutorialNetworkingText: "Servers are a central part of the game. You start with a single personal server (your home computer) " +
- "and you can purchase additional servers as you progress through the game. Connecting to other servers " +
- "and hacking them can be a major source of income and experience. Servers can also be used to run " +
- "scripts which can automatically hack servers for you.
" +
- "In order to navigate between machines, use the 'scan' or 'scan-analyze' Terminal command to see all servers " +
- "that are reachable from your current server. Then, you can use the 'connect [hostname/ip]' " +
- "command to connect to one of the available machines.
" +
- "The 'hostname' and 'ifconfig' commands can be used to display the hostname/IP of the " +
- "server you are currently connected to.",
- TutorialHackingText: "In the year 2077, currency has become digital and decentralized. People and corporations " +
- "store their money on servers. By hacking these servers, you can steal their money and gain " +
- "experience.
" +
- "
Gaining root access
" +
- "The key to hacking a server is to gain root access to that server. This can be done using " +
- "the NUKE virus (NUKE.exe). You start the game with a copy of the NUKE virus on your home " +
- "computer. The NUKE virus attacks the target server's open ports using buffer overflow " +
- "exploits. When successful, you are granted root administrative access to the machine.
" +
- "Typically, in order for the NUKE virus to succeed, the target server needs to have at least " +
- "one of its ports opened. Some servers have no security and will not need any ports opened. Some " +
- "will have very high security and will need many ports opened. In order to open ports on another " +
- "server, you will need to run programs that attack the server to open specific ports. These programs " +
- "can be coded once your hacking skill gets high enough, or they can be purchased if you can find " +
- "a seller.
" +
- "In order to determine how many ports need to be opened to successfully NUKE a server, connect to " +
- "that server and run the 'analyze' command. This will also show you which ports have already been " +
- "opened.
" +
- "Once you have enough ports opened and have ran the NUKE virus to gain root access, the server " +
- "can then be hacked by simply calling the 'hack' command through terminal, or by using a script.
" +
- "
Hacking mechanics
" +
- "When you execute the hack command, either manually through the terminal or automatically through " +
- "a script, you attempt to hack the server. This action takes time. The more advanced a server's " +
- "security is, the more time it will take. Your hacking skill level also affects the hacking time, " +
- "with a higher hacking skill leading to shorter hacking times. Also, running the hack command " +
- "manually through terminal is faster than hacking from a script.
" +
- "Your attempt to hack a server will not always succeed. The chance you have to successfully hack a " +
- "server is also determined by the server's security and your hacking skill level. Even if your " +
- "hacking attempt is unsuccessful, you will still gain experience points.
" +
- "When you successfully hack a server. You steal a certain percentage of that server's total money. This " +
- "percentage is determined by the server's security and your hacking skill level. The amount of money " +
- "on a server is not limitless. So, if you constantly hack a server and deplete its money, then you will " +
- "encounter diminishing returns in your hacking (since you are only hacking a certain percentage). You can " +
- "increase the amount of money on a server using a script and the grow() function in Netscript.
" +
- "
Server Security
" +
- "Each server has a security level, typically between 1 and 100. A higher number means the server has stronger security. " +
- "It is possible for a server to have a security level of 100 or higher, in which case hacking that server " +
- "will become impossible (0% chance to hack).
" +
- "As mentioned above, a server's security level is an important factor " +
- "to consider when hacking. You can check a server's security level using the 'analyze' command, although this " +
- "only gives an estimate (with 5% uncertainty). You can also check a server's security in a script, using the " +
- "getServerSecurityLevel(server) function in Netscript. See the Netscript documentation for more details. " +
- "This function will give you an exact value for a server's security.
" +
- "Whenever a server is hacked manually or through a script, its security level increases by a small amount. Calling " +
- "the grow() command in a script will also increase security level of the target server. These actions will " +
- "make it harder for you to hack the server, and decrease the amount of money you can steal. You can lower a " +
- "server's security level in a script using the weaken(server) function in Netscript. See the Netscript " +
- "documentation for more details.
" +
- "A server has a minimum security level that is equal to one third of its starting security, rounded to the " +
- "nearest integer. To be more precise:
" +
- "This means that a server's security will not fall below this value if you are trying to weaken it.",
- TutorialScriptsText: "Scripts can be used to automate the hacking process. Scripts must be written in the Netscript language. " +
- "Documentation about the Netscript language can be found in the 'Netscript Programming Language' " +
- "section of this 'Tutorial' page.
" +
- "It is highly recommended that you have a basic background in programming to start writing scripts. " +
- "You by no means need to be an expert. All you need is some familiarity with basic programming " +
- "constructs like for/while loops, if statements, " +
- "functions, variables, etc. The Netscript programming language most resembles the Javascript language. " +
- "Therefore, a good beginner's programming tutorial to read might be " +
- "this one. Note that while the Netscript language is similar to Javascript, it is not the exact same, so the " +
- "syntax will vary a little bit.
" +
- "Running a script requires RAM. The more complex a script is, the more RAM " +
- "it requires to run. Scripts can be run on any server you have root access to.
" +
- "Here are some Terminal commands that are useful when working with scripts:
" +
- "check [script] [args...] Prints the logs of the script specified by the name and arguments to Terminal. Arguments should be separated " +
- "by a space. Note that scripts are uniquely " +
- "identified by their arguments as well as their name. For example, if you ran a script 'foo.script' with the argument 'foodnstuff' then in order to 'check' it you must " +
- "also add the 'foodnstuff' argument to the check command as so: check foo.script foodnstuff
" +
- "free Shows the current server's RAM usage and availability
" +
- "kill [script] [args...] Stops a script that is running with the specified script name and arguments. " +
- "Arguments should be separated by a space. Note that " +
- "scripts are uniquely identified by their arguments as well as their name. For example, if you ran a script 'foo.script' with the " +
- "argument 1 and 2, then just typing 'kill foo.script' will not work. You have to use 'kill foo.script 1 2'.
" +
- "mem [script] [-t] [n] Check how much RAM a script requires to run with n threads
" +
- "nano [script] Create/Edit a script. The name of the script must end with the '.script' extension
" +
- "ps Displays all scripts that are actively running on the current server
" +
- "rm [script] Delete a script
" +
- "run [script] [-t] [n] [args...] Run a script with n threads and the specified arguments. Each argument should be separated by a space. " +
- "Both the arguments and thread specification are optional. If neither are specified, then the script will be run single-threaded with no arguments. " +
- "Examples: run foo.script The command above will run 'foo.script' single-threaded with no arguments." +
- " run foo.script -t 10 The command above will run 'foo.script' with 10 threads and no arguments." +
- " run foo.script foodnstuff sigma-cosmetics 10 The command above will run 'foo.script' single-threaded with three arguments: [foodnstuff, sigma-cosmetics, 10]" +
- " run foo.script -t 50 foodnstuff The command above will run 'foo.script' with 50 threads and a single argument: [foodnstuff]
" +
- "tail [script] [args...] Displays the logs of the script specified by the name and arguments. Note that scripts are uniquely " +
- "identified by their arguments as well as their name. For example, if you ran a script 'foo.script' with the argument 'foodnstuff' then in order to 'tail' it you must " +
- "also add the 'foodnstuff' argument to the tail command as so: tail foo.script foodnstuff
" +
- "top Displays all active scripts and their RAM usage
" +
- "
Multithreading scripts
" +
- "Scripts can be multithreaded. A multithreaded script runs the script's code once in each thread. The result is that " +
- "every call to the hack(), grow(), and weaken() Netscript functions will have its effect multiplied by the number of threads. " +
- "For example, if a normal single-threaded script is able to hack $10,000, then running the same script with 5 threads would " +
- "yield $50,000.
" +
- "When multithreading a script, the total RAM cost can be calculated by simply multiplying the base RAM cost of the script " +
- "with the number of threads, where the base cost refers to the amount of RAM required to run the script single-threaded. " +
- "In the terminal, you can run the " +
- "'mem [scriptname] -t n' command to see how much RAM a script requires with n threads.
" +
- "Every method for running a script has an option for making it multihreaded. To run a script with " +
- "n threads from a Terminal: " +
- "run [scriptname] -t n
" +
- " The scripts that you write and execute are interpreted in Javascript. For this " +
- "reason, it is not possible for these scripts to run while offline (when the game is closed). " +
- "It is important to note that for this reason, conditionals such as if/else statements and certain " +
- "commands such as purchaseHacknetNode() or nuke() will not work while the game is offline.
" +
- "However, Scripts WILL continue to generate money and hacking exp for you while the game is offline. This " +
- "offline production is based off of the scripts' production while the game is online.
" +
- "grow() and weaken() are two Netscript commands that will also be applied when the game is offline, although at a slower rate " +
- "compared to if the game was open. This is done by having each script keep track of the " +
- "rate at which the grow() and weaken() commands are called when the game is online. These calculated rates are used to determine how many times " +
- "these function calls would be made while the game is offline.
" +
- "Also, note that because of the way the Netscript interpreter is implemented, " +
- "whenever you reload or re-open the game all of the scripts that you are running will " +
- "start running from the BEGINNING of the code. The game does not keep track of where exactly " +
- "the execution of a script is when it saves/loads.
",
- TutorialNetscriptText: "Netscript is a programming language implemented for this game. There are two versions of Netscript: " +
- "Netscript 1.0 and Netscript 2.0 (NetscriptJS).
" +
- "To travel between cities, visit your current city's travel agency through the 'World' page. " +
- "From the travel agency you can travel to any other city. Doing so costs money.
" +
- "Each city has its own set of companies and unique locations. Also, certain content is only available to you " +
- "if you are in certain cities, so get exploring!",
- TutorialCompaniesText: "Hacking is not the only way to gain money and experience! Located around the world are many " +
- "different companies which you can work for. By working for a company you can earn money, " +
- "train your various labor skills, and unlock powerful passive perks.
" +
- "To apply for a job, visit the company you want to work for through the 'World' menu. The company " +
- "page will have options that let you apply to positions in the company. There might be several different " +
- "positions you can apply for, ranging from software engineer to business analyst to security officer.
" +
- "When you apply for a job, you will get the offer if your stats are high enough. Your first position at " +
- "a company will be an entry-level position such as 'intern'. Once you get the job, an button will appear on " +
- "the company page that allows you to work for the company. Click this button to start working.
" +
- "Working occurs in 8 hour shifts. Once you start working, you will begin earning money, experience, " +
- "and reputation. The rate at which you money and experience depends on the company and your position. " +
- "The amount of reputation you gain for your company is based on your job performance, which is affected by " +
- "your stats. Different positions value different stats. When you are working, you are unable to perform any " +
- "other actions such as using your terminal or visiting other locations (However, note that any scripts you have " +
- "running on servers will continue to run as you work!). It is possible to cancel your work shift before the " +
- "8 hours is up. However, if you have a full-time job, then cancelling a shift early will result in you gaining " +
- "only half of the reputation " +
- "that you had earned up to that point. There are also part-time/consultant jobs available where you will not " +
- " be penalized if you cancel a work shift early. However, these positions pay less than full-time positions.
" +
- "As you continue to work at a company, you will gain more and more reputation at that company. When your stats " +
- "and reputation are high enough, you can get a promotion. You can apply for a promotion on the company page, just like " +
- "you applied for the job originally. Higher positions at a company provide better salaries and stat gains.
" +
- "
Infiltrating Companies
" +
- "Many companies have facilities that you can attempt to infiltrate. By infiltrating, you can steal classified company secrets " +
- "and then sell these for money or for faction reputation. To try and infiltrate a company, visit a company through the " +
- "'World' menu. There will be an option that says 'Infiltrate Company'.
" +
- "When infiltrating a company, you must progress through clearance levels in the facility. Every clearance level " +
- "has some form of security that you must get past. There are several forms of security, ranging from high-tech security systems to " +
- "armed guards. For each form of security, there are a variety of options that you can choose to try and bypass the security. Examples " +
- "include hacking the security, engaging in combat, assassination, or sneaking past the security. The chance to succeed for each option " +
- "is determined in part by your stats. So, for example, trying to hack the security system relies on your hacking skill, whereas trying to " +
- "sneak past the security relies on your agility level.
" +
- "The facility has a 'security level' that affects your chance of success when trying to get past a clearance level. " +
- "Every time you advance to the next clearance level, the facility's security level will increase by a fixed amount. Furthermore " +
- "the options you choose and whether you succeed or fail will affect the security level as well. For example, " +
- "if you try to kill a security guard and fail, the security level will increase by a lot. If you choose to sneak past " +
- "security and succeed, the security level will not increase at all.
" +
- "Every 5 clearance levels, you will steal classified company secrets that can be sold for money or faction reputation. However, " +
- "in order to sell these secrets you must successfully escape the facility using the 'Escape' option. Furthermore, companies have " +
- "a max clearance level. If you reach the max clearance level you will automatically escape the facility with all of your " +
- "stolen secrets.
",
- TutorialFactionsText: "Throughout the game you may receive invitations from factions. There are many different factions, and each faction " +
- "has different criteria for determining its potential members. Joining a faction and furthering its cause is crucial " +
- "to progressing in the game and unlocking endgame content.
" +
- "It is possible to join multiple factions if you receive invitations from them. However, note that joining a faction " +
- "may prevent you from joining other rival factions.
" +
- "The 'Factions' link on the menu brings up a list of all factions that you have joined. " +
- "You can select a Faction on this list to go to that Faction page. This page displays general " +
- "information about the Faction and also lets you perform work for the faction. " +
- "Working for a Faction is similar to working for a company except that you don't get paid a salary. " +
- "You will only earn reputation in your Faction and train your stats. Also, cancelling work early " +
- "when working for a Faction does NOT result in reduced experience/reputation earnings.
" +
- "Earning reputation for a Faction unlocks powerful Augmentations. Purchasing and installing these Augmentations will " +
- "upgrade your abilities. The Augmentations that are available to unlock vary from faction to faction.",
- TutorialAugmentationsText: "Advances in science and medicine have lead to powerful new technologies that allow people to augment themselves " +
- "beyond normal human capabilities. There are many different types of Augmentations, ranging from cybernetic to " +
- "genetic to biological. Acquiring these Augmentations enhances the user's physical and mental faculties.
" +
- "Because of how powerful these Augmentations are, the technology behind them is kept private and secret by the " +
- "corporations and organizations that create them. Therefore, the only way for the player to obtain Augmentations is " +
- "through Factions. After joining a Faction and earning enough reputation in it, you will be able to purchase " +
- "its Augmentations. Different Factions offer different Augmentations. Augmentations must be purchased in order to be installed, " +
- "and they are fairly expensive.
" +
- "When you purchase an Augmentation, the price of purchasing another Augmentation increases by 90%. This multiplier stacks for " +
- "each Augmentation you purchase. You will not gain the benefits of your purchased Augmentations until you install them. You can " +
- "choose to install Augmentations through the 'Augmentations' menu tab. Once you install your purchased Augmentations, " +
- "their costs are reset back to the original price.
" +
- "Unfortunately, installing Augmentations has side effects. You will lose most of the progress you've made, including your " +
- "skills, stats, and money. You will have to start over, but you will have all of the Augmentations you have installed to " +
- "help you progress.
" +
- "To summarize, here is a list of everything you will LOSE when you install an Augmentation:
' +
- `Employer at which you last worked: ${_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].companyName} ` +
- `Job you last worked: ${companyPosition} ` +
- `All Employers: ${Object.keys(_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].jobs).join(", ")}
' +
- 'Servers owned: ' + _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].purchasedServers.length + ' ' +
- 'Hacknet Nodes owned: ' + _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].hacknetNodes.length + ' ' +
- 'Augmentations installed: ' + _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].augmentations.length + ' ' +
- 'Time played since last Augmentation: ' + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_0__["convertTimeMsToTimeElapsedString"])(_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].playtimeSinceLastAug) + ' ' +
- bitNodeTimeText +
- 'Time played: ' + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_0__["convertTimeMsToTimeElapsedString"])(_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].totalPlaytime),
- }));
-
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].sourceFiles.length !== 0) {
- var index = "BitNode" + _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bitNodeN;
-
- Engine.Display.characterInfo.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("p", {
- width:"60%",
- innerHTML:
- " Current BitNode: " + _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bitNodeN + " (" + _BitNode_BitNode__WEBPACK_IMPORTED_MODULE_6__[/* BitNodes */ "a"][index].name + ")
",
- }));
-
- Engine.Display.characterInfo.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("p", {
- width:"60%", fontSize: "13px", marginLeft:"4%",
- innerHTML:_BitNode_BitNode__WEBPACK_IMPORTED_MODULE_6__[/* BitNodes */ "a"][index].info,
- }))
- }
- },
-
- /* Display locations in the world*/
- aevumLocationsList: null,
- chongqingLocationsList: null,
- sector12LocationsList: null,
- newTokyoLocationsList: null,
- ishimaLocationsList: null,
- volhavenLocationsList: null,
-
- displayWorldInfo: function() {
- Engine.aevumLocationsList.style.display = "none";
- Engine.chongqingLocationsList.style.display = "none";
- Engine.sector12LocationsList.style.display = "none";
- Engine.newTokyoLocationsList.style.display = "none";
- Engine.ishimaLocationsList.style.display = "none";
- Engine.volhavenLocationsList.style.display = "none";
-
- document.getElementById("world-city-name").innerHTML = _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].city;
- var cityDesc = document.getElementById("world-city-desc"); //TODO
- switch(_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].city) {
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Aevum:
- Engine.aevumLocationsList.style.display = "inline";
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Chongqing:
- Engine.chongqingLocationsList.style.display = "inline";
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Sector12:
- Engine.sector12LocationsList.style.display = "inline";
-
- //City hall only in BitNode-3/with Source-File 3
- if ((_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bitNodeN === 3 || _NetscriptFunctions__WEBPACK_IMPORTED_MODULE_26__[/* hasCorporationSF */ "e"]) && _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bitNodeN !== 8) {
- document.getElementById("sector12-cityhall-li").style.display = "block";
- } else {
- document.getElementById("sector12-cityhall-li").style.display = "none";
- }
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].NewTokyo:
- Engine.newTokyoLocationsList.style.display = "inline";
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Ishima:
- Engine.ishimaLocationsList.style.display = "inline";
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Volhaven:
- Engine.volhavenLocationsList.style.display = "inline";
- break;
- default:
- console.log("Invalid city value in Player object!");
- break;
- }
-
- //Generic Locations (common to every city):
- // World Stock Exchange
- // Corporation (if applicable)
- // Bladeburner HQ (if applicable);
- var genericLocationsList = document.getElementById("generic-locations-list");
- genericLocationsList.style.display = "inline";
- Object(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_54__["removeChildrenFromElement"])(genericLocationsList);
- var li = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("li");
- li.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("a", {
- innerText:"World Stock Exchange", class:"a-link-button",
- clickListener:()=>{
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].WorldStockExchange;
- Engine.loadStockMarketContent();
- return false;
- }
- }));
- genericLocationsList.appendChild(li);
-
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].corporation instanceof _Corporation_Corporation__WEBPACK_IMPORTED_MODULE_13__[/* Corporation */ "a"] && document.getElementById("location-corporation-button") == null) {
- var li = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("li");
- li.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("a", {
- innerText:_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].corporation.name, id:"location-corporation-button",
- class:"a-link-button",
- clickListener:()=>{
- Engine.loadCorporationContent();
- return false;
- }
- }));
- genericLocationsList.appendChild(li);
- }
-
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"]) {
- var li = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("li");
- li.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("a", {
- innerText:"Bladeburner Headquarters", class:"a-link-button",
- clickListener:()=>{
- Engine.loadBladeburnerContent();
- return false;
- }
- }));
- genericLocationsList.appendChild(li);
- }
- },
-
- displayFactionsInfo: function() {
- Object(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_54__["removeChildrenFromElement"])(Engine.Display.factionsContent);
-
- //Factions
- Engine.Display.factionsContent.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("h1", {
- innerText:"Factions"
- }));
- Engine.Display.factionsContent.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("p", {
- innerText:"Lists all factions you have joined"
- }));
- var factionsList = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("ul");
- Engine.Display.factionsContent.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("br"));
-
- //Add a button for each faction you are a member of
- for (var i = 0; i < _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].factions.length; ++i) {
- (function () {
- var factionName = _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].factions[i];
-
- factionsList.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("a", {
- class:"a-link-button", innerText:factionName, padding:"4px", margin:"4px",
- display:"inline-block",
- clickListener:()=>{
- Engine.loadFactionContent();
- Object(_Faction_FactionHelpers__WEBPACK_IMPORTED_MODULE_17__[/* displayFactionContent */ "a"])(factionName);
- return false;
- }
- }));
- factionsList.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("br"));
- }()); //Immediate invocation
- }
- Engine.Display.factionsContent.appendChild(factionsList);
- Engine.Display.factionsContent.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("br"));
-
- //Invited Factions
- Engine.Display.factionsContent.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("h1", {
- innerText:"Outstanding Faction Invitations"
- }));
- Engine.Display.factionsContent.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("p", {
- width:"70%",
- innerText:"Lists factions you have been invited to, as well as " +
- "factions you have previously rejected. You can accept " +
- "these faction invitations at any time."
- }));
- var invitationsList = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("ul");
-
- //Add a button to accept for each faction you have invitiations for
- for (var i = 0; i < _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].factionInvitations.length; ++i) {
- (function () {
- var factionName = _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].factionInvitations[i];
-
- var item = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("li", {padding:"6px", margin:"6px"});
- item.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("p", {
- innerText:factionName, display:"inline", margin:"4px", padding:"4px"
- }));
- item.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_56__["createElement"])("a", {
- innerText:"Accept Faction Invitation",
- class:"a-link-button", display:"inline", margin:"4px", padding:"4px",
- clickListener:()=>{
- Object(_Faction_FactionHelpers__WEBPACK_IMPORTED_MODULE_17__[/* joinFaction */ "c"])(_Faction_Factions__WEBPACK_IMPORTED_MODULE_16__["Factions"][factionName]);
- for (var i = 0; i < _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].factionInvitations.length; ++i) {
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].factionInvitations[i] == factionName || _Faction_Factions__WEBPACK_IMPORTED_MODULE_16__["Factions"][_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].factionInvitations[i]].isBanned) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].factionInvitations.splice(i, 1);
- i--;
- }
- }
- Engine.displayFactionsInfo();
- return false;
- }
- }));
-
- invitationsList.appendChild(item);
- }());
- }
-
- Engine.Display.factionsContent.appendChild(invitationsList);
- },
-
- displayTutorialContent: function() {
- document.getElementById("tutorial-getting-started-link").style.display = "block";
- Engine.Clickables.tutorialNetworkingButton.style.display = "block";
- Engine.Clickables.tutorialHackingButton.style.display = "block";
- Engine.Clickables.tutorialScriptsButton.style.display = "block";
- Engine.Clickables.tutorialNetscriptButton.style.display = "block";
- Engine.Clickables.tutorialTravelingButton.style.display = "block";
- Engine.Clickables.tutorialCompaniesButton.style.display = "block";
- Engine.Clickables.tutorialFactionsButton.style.display = "block";
- Engine.Clickables.tutorialAugmentationsButton.style.display = "block";
- document.getElementById("tutorial-shortcuts-link").style.display = "block";
-
- Engine.Clickables.tutorialBackButton.style.display = "none";
- document.getElementById("tutorial-text").style.display = "none";
- },
-
- //Displays the text when a section of the Tutorial is opened
- displayTutorialPage: function(text) {
- document.getElementById("tutorial-getting-started-link").style.display = "none";
- Engine.Clickables.tutorialNetworkingButton.style.display = "none";
- Engine.Clickables.tutorialHackingButton.style.display = "none";
- Engine.Clickables.tutorialScriptsButton.style.display = "none";
- Engine.Clickables.tutorialNetscriptButton.style.display = "none";
- Engine.Clickables.tutorialTravelingButton.style.display = "none";
- Engine.Clickables.tutorialCompaniesButton.style.display = "none";
- Engine.Clickables.tutorialFactionsButton.style.display = "none";
- Engine.Clickables.tutorialAugmentationsButton.style.display = "none";
- document.getElementById("tutorial-shortcuts-link").style.display = "none";
-
- Engine.Clickables.tutorialBackButton.style.display = "inline-block";
- document.getElementById("tutorial-text").style.display = "block";
- document.getElementById("tutorial-text").innerHTML = text;
- },
-
- /* Main Event Loop */
- idleTimer: function() {
- //Get time difference
- var _thisUpdate = new Date().getTime();
- var diff = _thisUpdate - Engine._lastUpdate;
- var offset = diff % Engine._idleSpeed;
-
- //Divide this by cycle time to determine how many cycles have elapsed since last update
- diff = Math.floor(diff / Engine._idleSpeed);
-
- if (diff > 0) {
- //Update the game engine by the calculated number of cycles
- Engine._lastUpdate = _thisUpdate - offset;
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].lastUpdate = _thisUpdate - offset;
- Engine.updateGame(diff);
- }
-
- window.requestAnimationFrame(Engine.idleTimer);
- },
-
- updateGame: function(numCycles = 1) {
- var time = numCycles * Engine._idleSpeed;
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].totalPlaytime == null) {_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].totalPlaytime = 0;}
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].playtimeSinceLastAug == null) {_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].playtimeSinceLastAug = 0;}
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].playtimeSinceLastBitnode == null) {_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].playtimeSinceLastBitnode = 0;}
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].totalPlaytime += time;
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].playtimeSinceLastAug += time;
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].playtimeSinceLastBitnode += time;
-
- //Start Manual hack
- if (_Terminal__WEBPACK_IMPORTED_MODULE_41__[/* Terminal */ "a"].actionStarted === true) {
- Engine._totalActionTime = _Terminal__WEBPACK_IMPORTED_MODULE_41__[/* Terminal */ "a"].actionTime;
- Engine._actionTimeLeft = _Terminal__WEBPACK_IMPORTED_MODULE_41__[/* Terminal */ "a"].actionTime;
- Engine._actionInProgress = true;
- Engine._actionProgressBarCount = 1;
- Engine._actionProgressStr = "[ ]";
- Engine._actionTimeStr = "Time left: ";
- _Terminal__WEBPACK_IMPORTED_MODULE_41__[/* Terminal */ "a"].actionStarted = false;
- }
-
- //Working
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].isWorking) {
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeFaction) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workForFaction(numCycles);
- } else if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeCreateProgram) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].createProgramWork(numCycles);
- } else if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeStudyClass) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].takeClass(numCycles);
- } else if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeCrime) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].commitCrime(numCycles);
- } else if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeCompanyPartTime) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workPartTime(numCycles);
- } else {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].work(numCycles);
- }
- }
-
- // Update stock prices
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].hasWseAccount) {
- Object(_StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_40__[/* processStockPrices */ "m"])(numCycles);
- }
-
- //Gang, if applicable
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bitNodeN == 2 && _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].inGang()) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].gang.process(numCycles, _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"]);
- }
-
- //Mission
- if (_Missions__WEBPACK_IMPORTED_MODULE_25__[/* inMission */ "c"] && _Missions__WEBPACK_IMPORTED_MODULE_25__[/* currMission */ "b"]) {
- _Missions__WEBPACK_IMPORTED_MODULE_25__[/* currMission */ "b"].process(numCycles);
- }
-
- //Corporation
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].corporation instanceof _Corporation_Corporation__WEBPACK_IMPORTED_MODULE_13__[/* Corporation */ "a"]) {
- //Stores cycles in a "buffer". Processed separately using Engine Counters
- //This is to avoid constant DOM redraws when Corporation is catching up
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].corporation.storeCycles(numCycles);
- }
-
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"]) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bladeburner.storeCycles(numCycles);
- }
-
- // Sleeves
- for (let i = 0; i < _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].sleeves.length; ++i) {
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].sleeves[i] instanceof _PersonObjects_Sleeve_Sleeve__WEBPACK_IMPORTED_MODULE_42__["Sleeve"]) {
- const expForOtherSleeves = _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].sleeves[i].process(_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"], numCycles);
-
- // This sleeve earns experience for other sleeves
- if (expForOtherSleeves == null) { continue; }
- for (let j = 0; j < _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].sleeves.length; ++j) {
- if (j === i) { continue; }
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].sleeves[j].gainExperience(_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"], expForOtherSleeves, numCycles, true);
- }
- }
- }
-
- //Counters
- Engine.decrementAllCounters(numCycles);
- Engine.checkCounters();
-
- //Manual hacks
- if (Engine._actionInProgress == true) {
- Engine.updateHackProgress(numCycles);
- }
-
- //Update the running time of all active scripts
- Object(_NetscriptWorker__WEBPACK_IMPORTED_MODULE_27__[/* updateOnlineScriptTimes */ "g"])(numCycles);
-
- //Hacknet Nodes
- Object(_HacknetNode__WEBPACK_IMPORTED_MODULE_21__[/* processAllHacknetNodeEarnings */ "d"])(numCycles);
- },
-
- //Counters for the main event loop. Represent the number of game cycles are required
- //for something to happen.
- Counters: {
- autoSaveCounter: 300, //Autosave every minute
- updateSkillLevelsCounter: 10, //Only update skill levels every 2 seconds. Might improve performance
- updateDisplays: 3,
- updateDisplaysMed: 9,
- updateDisplaysLong: 15,
- updateActiveScriptsDisplay: 5,
- createProgramNotifications: 10, //Checks whether any programs can be created and notifies
- checkFactionInvitations: 100, //Check whether you qualify for any faction invitations
- passiveFactionGrowth: 600,
- messages: 150,
- sCr: 1500,
- mechanicProcess: 5, //Processes certain mechanics (Corporation, Bladeburner)
- contractGeneration: 3000 //Generate Coding Contracts
- },
-
- decrementAllCounters: function(numCycles = 1) {
- for (var counter in Engine.Counters) {
- if (Engine.Counters.hasOwnProperty(counter)) {
- Engine.Counters[counter] = Engine.Counters[counter] - numCycles;
- }
- }
- },
-
- //Checks if any counters are 0 and if they are, executes whatever
- //is necessary and then resets the counter
- checkCounters: function() {
- if (Engine.Counters.autoSaveCounter <= 0) {
- _SaveObject__WEBPACK_IMPORTED_MODULE_33__[/* saveObject */ "b"].saveGame(indexedDb);
- if (_Settings_Settings__WEBPACK_IMPORTED_MODULE_36__["Settings"].AutosaveInterval == null) {
- _Settings_Settings__WEBPACK_IMPORTED_MODULE_36__["Settings"].AutosaveInterval = 60;
- }
- if (_Settings_Settings__WEBPACK_IMPORTED_MODULE_36__["Settings"].AutosaveInterval === 0) {
- Engine.Counters.autoSaveCounter = Infinity;
- } else {
- Engine.Counters.autoSaveCounter = _Settings_Settings__WEBPACK_IMPORTED_MODULE_36__["Settings"].AutosaveInterval * 5;
- }
- }
-
- if (Engine.Counters.updateSkillLevelsCounter <= 0) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].updateSkillLevels();
- Engine.Counters.updateSkillLevelsCounter = 10;
- }
-
- if (Engine.Counters.updateActiveScriptsDisplay <= 0) {
- //Always update, but make the interval longer if the page isn't active
- Object(_ActiveScriptsUI__WEBPACK_IMPORTED_MODULE_2__[/* updateActiveScriptsItems */ "c"])();
- if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["Page"].ActiveScripts)) {
- Engine.Counters.updateActiveScriptsDisplay = 5;
- } else {
- Engine.Counters.updateActiveScriptsDisplay = 10;
- }
- }
-
- if (Engine.Counters.updateDisplays <= 0) {
- Engine.displayCharacterOverviewInfo();
- if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["Page"].CharacterInfo)) {
- Engine.displayCharacterInfo();
- } else if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["Page"].HacknetNodes)) {
- Object(_HacknetNode__WEBPACK_IMPORTED_MODULE_21__[/* updateHacknetNodesContent */ "f"])();
- } else if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["Page"].CreateProgram)) {
- Object(_Programs_ProgramHelpers__WEBPACK_IMPORTED_MODULE_31__[/* displayCreateProgramContent */ "a"])();
- } else if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["Page"].Sleeves)) {
- Object(_PersonObjects_Sleeve_SleeveUI__WEBPACK_IMPORTED_MODULE_43__["updateSleevesPage"])();
- }
-
- if (_utils_LogBox__WEBPACK_IMPORTED_MODULE_1__[/* logBoxOpened */ "b"]) {
- Object(_utils_LogBox__WEBPACK_IMPORTED_MODULE_1__[/* logBoxUpdateText */ "c"])();
- }
-
- Engine.Counters.updateDisplays = 3;
- }
-
- if (Engine.Counters.updateDisplaysMed <= 0) {
- if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["Page"].Corporation)) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].corporation.updateUIContent();
- }
- Engine.Counters.updateDisplaysMed = 9;
- }
-
- if (Engine.Counters.updateDisplaysLong <= 0) {
- if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["Page"].Gang) && _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].inGang()) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].gang.updateGangContent();
- } else if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["Page"].ScriptEditor)) {
- Object(_Script__WEBPACK_IMPORTED_MODULE_34__[/* updateScriptEditorContent */ "i"])();
- }
- Engine.Counters.updateDisplaysLong = 15;
- }
-
- if (Engine.Counters.createProgramNotifications <= 0) {
- var num = Object(_Programs_ProgramHelpers__WEBPACK_IMPORTED_MODULE_31__[/* getNumAvailableCreateProgram */ "b"])();
- var elem = document.getElementById("create-program-notification");
- if (num > 0) {
- elem.innerHTML = num;
- elem.setAttribute("class", "notification-on");
- } else {
- elem.innerHTML = "";
- elem.setAttribute("class", "notification-off");
- }
- Engine.Counters.createProgramNotifications = 10;
- }
-
- if (Engine.Counters.checkFactionInvitations <= 0) {
- var invitedFactions = _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].checkForFactionInvitations();
- if (invitedFactions.length > 0) {
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].firstFacInvRecvd === false) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].firstFacInvRecvd = true;
- document.getElementById("factions-tab").style.display = "list-item";
- document.getElementById("character-menu-header").click();
- document.getElementById("character-menu-header").click();
- }
-
- var randFaction = invitedFactions[Math.floor(Math.random() * invitedFactions.length)];
- Object(_Faction_FactionHelpers__WEBPACK_IMPORTED_MODULE_17__[/* inviteToFaction */ "b"])(randFaction);
- }
- Engine.Counters.checkFactionInvitations = 100;
- }
-
- if (Engine.Counters.passiveFactionGrowth <= 0) {
- var adjustedCycles = Math.floor((600 - Engine.Counters.passiveFactionGrowth));
- Object(_Faction_FactionHelpers__WEBPACK_IMPORTED_MODULE_17__[/* processPassiveFactionRepGain */ "d"])(adjustedCycles);
- Engine.Counters.passiveFactionGrowth = 600;
- }
-
- if (Engine.Counters.messages <= 0) {
- Object(_Message__WEBPACK_IMPORTED_MODULE_24__[/* checkForMessagesToSend */ "c"])();
- if (_Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_3__["Augmentations"][_Augmentation_data_AugmentationNames__WEBPACK_IMPORTED_MODULE_5__["AugmentationNames"].TheRedPill].owned) {
- Engine.Counters.messages = 4500; //15 minutes for Red pill message
- } else {
- Engine.Counters.messages = 150;
- }
- }
-
- if (Engine.Counters.sCr <= 0) {
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].hasWseAccount) {
- Object(_StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_40__[/* stockMarketCycle */ "q"])();
- }
- Engine.Counters.sCr = 1500;
- }
-
- if (Engine.Counters.mechanicProcess <= 0) {
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].corporation instanceof _Corporation_Corporation__WEBPACK_IMPORTED_MODULE_13__[/* Corporation */ "a"]) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].corporation.process();
- }
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"]) {
- try {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bladeburner.process();
- } catch(e) {
- Object(_utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_57__["exceptionAlert"])("Exception caught in Bladeburner.process(): " + e);
- }
-
- }
- Engine.Counters.mechanicProcess = 5;
- }
-
- if (Engine.Counters.contractGeneration <= 0) {
- // X% chance of a contract being generated
- if (Math.random() <= 0.25) {
- Object(_CodingContractGenerator__WEBPACK_IMPORTED_MODULE_10__[/* generateRandomContract */ "a"])();
- }
- Engine.Counters.contractGeneration = 3000;
- }
- },
-
- /* Calculates the hack progress for a manual (non-scripted) hack and updates the progress bar/time accordingly */
- _totalActionTime: 0,
- _actionTimeLeft: 0,
- _actionTimeStr: "Time left: ",
- _actionProgressStr: "[ ]",
- _actionProgressBarCount: 1,
- _actionInProgress: false,
- updateHackProgress: function(numCycles = 1) {
- var timeElapsedMilli = numCycles * Engine._idleSpeed;
- Engine._actionTimeLeft -= (timeElapsedMilli/ 1000); //Substract idle speed (ms)
- Engine._actionTimeLeft = Math.max(Engine._actionTimeLeft, 0);
-
- //Calculate percent filled
- var percent = Math.round((1 - Engine._actionTimeLeft / Engine._totalActionTime) * 100);
-
- //Update progress bar
- while (Engine._actionProgressBarCount * 2 <= percent) {
- Engine._actionProgressStr = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_0__["replaceAt"])(Engine._actionProgressStr, Engine._actionProgressBarCount, "|");
- Engine._actionProgressBarCount += 1;
- }
-
- //Update hack time remaining
- Engine._actionTimeStr = "Time left: " + Math.max(0, Math.round(Engine._actionTimeLeft)).toString() + "s";
- document.getElementById("hack-progress").innerHTML = Engine._actionTimeStr;
-
- //Dynamically update progress bar
- document.getElementById("hack-progress-bar").innerHTML = Engine._actionProgressStr.replace( / /g, " " );
-
- //Once percent is 100, the hack is completed
- if (percent >= 100) {
- Engine._actionInProgress = false;
- _Terminal__WEBPACK_IMPORTED_MODULE_41__[/* Terminal */ "a"].finishAction();
- }
- },
-
- //Used when initializing a game
- //elems should be an array of all DOM elements under the header
- closeMainMenuHeader: function(elems) {
- for (var i = 0; i < elems.length; ++i) {
- elems[i].style.maxHeight = null;
- elems[i].style.opacity = 0;
- elems[i].style.pointerEvents = "none";
- }
- },
-
- //Used when initializing the game
- //elems should be an array of all DOM elements under the header
- openMainMenuHeader: function(elems) {
- for (var i = 0; i < elems.length; ++i) {
- elems[i].style.maxHeight = elems[i].scrollHeight + "px";
- elems[i].style.display = "block";
- }
- },
-
- //Used in game when clicking on a main menu header (NOT FOR INITIALIZATION)
- //open is a boolean specifying whether its being opened or closed
- //elems is an array of DOM elements for main menu tabs (li)
- //links is an array of DOM elements for main menu links (a)
- toggleMainMenuHeader: function(open, elems, links) {
- for (var i = 0; i < elems.length; ++i) {
- if (open) {
- elems[i].style.opacity = 1;
- elems[i].style.maxHeight = elems[i].scrollHeight + "px";
- } else {
- elems[i].style.opacity = 0;
- elems[i].style.maxHeight = null;
- }
- }
-
- for (var i = 0; i < links.length; ++i) {
- if (open) {
- links[i].style.opacity = 1;
- links[i].style.maxHeight = links[i].scrollHeight + "px";
- links[i].style.pointerEvents = "auto";
- } else {
- links[i].style.opacity = 0;
- links[i].style.maxHeight = null;
- links[i].style.pointerEvents = "none";
- }
- }
- },
-
- load: function(saveString) {
- //Initialize main menu accordion panels to all start as "open"
- var terminal = document.getElementById("terminal-tab");
- var createScript = document.getElementById("create-script-tab");
- var activeScripts = document.getElementById("active-scripts-tab");
- var createProgram = document.getElementById("create-program-tab");
- var stats = document.getElementById("stats-tab");
- var factions = document.getElementById("factions-tab");
- var augmentations = document.getElementById("augmentations-tab");
- var hacknetnodes = document.getElementById("hacknet-nodes-tab");
- var city = document.getElementById("city-tab");
- var travel = document.getElementById("travel-tab");
- var job = document.getElementById("job-tab");
- var stockmarket = document.getElementById("stock-market-tab");
- var bladeburner = document.getElementById("bladeburner-tab");
- var corp = document.getElementById("corporation-tab");
- var gang = document.getElementById("gang-tab");
- var tutorial = document.getElementById("tutorial-tab");
- var options = document.getElementById("options-tab");
- var dev = document.getElementById("dev-tab");
-
- //Load game from save or create new game
- if (Object(_SaveObject__WEBPACK_IMPORTED_MODULE_33__[/* loadGame */ "a"])(saveString)) {
- console.log("Loaded game from save");
- Object(_BitNode_BitNode__WEBPACK_IMPORTED_MODULE_6__[/* initBitNodes */ "c"])();
- Object(_BitNode_BitNode__WEBPACK_IMPORTED_MODULE_6__[/* initBitNodeMultipliers */ "b"])();
- Object(_SourceFile__WEBPACK_IMPORTED_MODULE_37__[/* initSourceFiles */ "c"])();
- Engine.setDisplayElements(); //Sets variables for important DOM elements
- Engine.init(); //Initialize buttons, work, etc.
- Object(_Augmentation_AugmentationHelpers__WEBPACK_IMPORTED_MODULE_4__[/* initAugmentations */ "d"])(); //Also calls Player.reapplyAllAugmentations()
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].reapplyAllSourceFiles();
- Object(_StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_40__[/* initStockSymbols */ "i"])();
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].hasWseAccount) {
- Object(_StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_40__[/* initSymbolToStockMap */ "j"])();
- }
- Object(_Literature__WEBPACK_IMPORTED_MODULE_23__[/* initLiterature */ "a"])();
- Object(_NetscriptFunctions__WEBPACK_IMPORTED_MODULE_26__[/* initSingularitySFFlags */ "g"])();
- Object(_SourceFile_SourceFileFlags__WEBPACK_IMPORTED_MODULE_38__["updateSourceFileFlags"])(_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"]);
-
- //Calculate the number of cycles have elapsed while offline
- Engine._lastUpdate = new Date().getTime();
- var lastUpdate = _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].lastUpdate;
- var numCyclesOffline = Math.floor((Engine._lastUpdate - lastUpdate) / Engine._idleSpeed);
-
- /* Process offline progress */
- var offlineProductionFromScripts = Object(_Script__WEBPACK_IMPORTED_MODULE_34__[/* loadAllRunningScripts */ "g"])(); //This also takes care of offline production for those scripts
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].isWorking) {
- console.log("work() called in load() for " + numCyclesOffline * Engine._idleSpeed + " milliseconds");
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeFaction) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workForFaction(numCyclesOffline);
- } else if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeCreateProgram) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].createProgramWork(numCyclesOffline);
- } else if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeStudyClass) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].takeClass(numCyclesOffline);
- } else if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeCrime) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].commitCrime(numCyclesOffline);
- } else if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeCompanyPartTime) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workPartTime(numCyclesOffline);
- } else {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].work(numCyclesOffline);
- }
- }
-
- //Hacknet Nodes offline progress
- var offlineProductionFromHacknetNodes = Object(_HacknetNode__WEBPACK_IMPORTED_MODULE_21__[/* processAllHacknetNodeEarnings */ "d"])(numCyclesOffline);
-
- //Passive faction rep gain offline
- Object(_Faction_FactionHelpers__WEBPACK_IMPORTED_MODULE_17__[/* processPassiveFactionRepGain */ "d"])(numCyclesOffline);
-
- // Stock Market offline progress
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].hasWseAccount) {
- Object(_StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_40__[/* processStockPrices */ "m"])(numCyclesOffline);
- }
-
- // Gang progress for BitNode 2
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bitNodeN != null && _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bitNodeN === 2 && _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].inGang()) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].gang.process(numCyclesOffline, _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"]);
- }
-
- // Corporation offline progress
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].corporation instanceof _Corporation_Corporation__WEBPACK_IMPORTED_MODULE_13__[/* Corporation */ "a"]) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].corporation.storeCycles(numCyclesOffline);
- }
-
- // Bladeburner offline progress
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"]) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bladeburner.storeCycles(numCyclesOffline);
- }
-
- // Sleeves offline progress
- for (let i = 0; i < _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].sleeves.length; ++i) {
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].sleeves[i] instanceof _PersonObjects_Sleeve_Sleeve__WEBPACK_IMPORTED_MODULE_42__["Sleeve"]) {
- const expForOtherSleeves = _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].sleeves[i].process(_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"], numCyclesOffline);
-
- // This sleeve earns experience for other sleeves
- if (expForOtherSleeves == null) { continue; }
- for (let j = 0; j < _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].sleeves.length; ++j) {
- if (j === i) { continue; }
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].sleeves[j].gainExperience(_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"], expForOtherSleeves, numCyclesOffline, true);
- }
- }
- }
-
- //Update total playtime
- var time = numCyclesOffline * Engine._idleSpeed;
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].totalPlaytime == null) {_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].totalPlaytime = 0;}
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].playtimeSinceLastAug == null) {_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].playtimeSinceLastAug = 0;}
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].playtimeSinceLastBitnode == null) {_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].playtimeSinceLastBitnode = 0;}
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].totalPlaytime += time;
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].playtimeSinceLastAug += time;
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].playtimeSinceLastBitnode += time;
-
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].lastUpdate = Engine._lastUpdate;
- Engine.start(); //Run main game loop and Scripts loop
- Object(_utils_uiHelpers_removeLoadingScreen__WEBPACK_IMPORTED_MODULE_58__["removeLoadingScreen"])();
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_51__["dialogBoxCreate"])("While you were offline, your scripts generated $" +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_0__["formatNumber"])(offlineProductionFromScripts, 2) + " and your Hacknet Nodes generated $" +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_0__["formatNumber"])(offlineProductionFromHacknetNodes, 2) + "");
- //Close main menu accordions for loaded game
- var visibleMenuTabs = [terminal, createScript, activeScripts, stats,
- hacknetnodes, city, tutorial, options, dev];
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].firstFacInvRecvd) {visibleMenuTabs.push(factions);}
- else {factions.style.display = "none";}
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].firstAugPurchased) {visibleMenuTabs.push(augmentations);}
- else {augmentations.style.display = "none";}
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].companyName !== "") {visibleMenuTabs.push(job);}
- else {job.style.display = "none";}
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].firstTimeTraveled) {visibleMenuTabs.push(travel);}
- else {travel.style.display = "none";}
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].firstProgramAvailable) {visibleMenuTabs.push(createProgram);}
- else {createProgram.style.display = "none";}
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].hasWseAccount) {visibleMenuTabs.push(stockmarket);}
- else {stockmarket.style.display = "none";}
- if(_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"]) {visibleMenuTabs.push(bladeburner);}
- else {bladeburner.style.display = "none";}
- if(_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].corporation instanceof _Corporation_Corporation__WEBPACK_IMPORTED_MODULE_13__[/* Corporation */ "a"]) {visibleMenuTabs.push(corp);}
- else {corp.style.display = "none";}
- if(_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].inGang()) {visibleMenuTabs.push(gang);}
- else {gang.style.display = "none";}
-
- Engine.closeMainMenuHeader(visibleMenuTabs);
- } else {
- //No save found, start new game
- console.log("Initializing new game");
- Object(_BitNode_BitNode__WEBPACK_IMPORTED_MODULE_6__[/* initBitNodes */ "c"])();
- Object(_BitNode_BitNode__WEBPACK_IMPORTED_MODULE_6__[/* initBitNodeMultipliers */ "b"])();
- Object(_SourceFile__WEBPACK_IMPORTED_MODULE_37__[/* initSourceFiles */ "c"])();
- Object(_SpecialServerIps__WEBPACK_IMPORTED_MODULE_39__[/* initSpecialServerIps */ "c"])();
- Engine.setDisplayElements(); //Sets variables for important DOM elements
- Engine.start(); //Run main game loop and Scripts loop
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].init();
- Object(_Server__WEBPACK_IMPORTED_MODULE_35__[/* initForeignServers */ "f"])();
- Object(_Company_Companies__WEBPACK_IMPORTED_MODULE_12__["initCompanies"])();
- Object(_Faction_Factions__WEBPACK_IMPORTED_MODULE_16__["initFactions"])();
- Object(_Augmentation_AugmentationHelpers__WEBPACK_IMPORTED_MODULE_4__[/* initAugmentations */ "d"])();
- Object(_Message__WEBPACK_IMPORTED_MODULE_24__[/* initMessages */ "d"])();
- Object(_StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_40__[/* initStockSymbols */ "i"])();
- Object(_Literature__WEBPACK_IMPORTED_MODULE_23__[/* initLiterature */ "a"])();
- Object(_NetscriptFunctions__WEBPACK_IMPORTED_MODULE_26__[/* initSingularitySFFlags */ "g"])();
-
- //Open main menu accordions for new game
- //Main menu accordions
- var hackingHdr = document.getElementById("hacking-menu-header");
- hackingHdr.classList.toggle("opened");
- var characterHdr = document.getElementById("character-menu-header");
- characterHdr.classList.toggle("opened");
- var worldHdr = document.getElementById("world-menu-header");
- worldHdr.classList.toggle("opened");
- var helpHdr = document.getElementById("help-menu-header");
- helpHdr.classList.toggle("opened");
-
- //Hide tabs that wont be revealed until later
- factions.style.display = "none";
- augmentations.style.display = "none";
- job.style.display = "none";
- stockmarket.style.display = "none";
- travel.style.display = "none";
- createProgram.style.display = "none";
- bladeburner.style.display = "none";
- corp.style.display = "none";
- gang.style.display = "none";
- dev.style.display = "none";
-
- Engine.openMainMenuHeader(
- [terminal, createScript, activeScripts, stats,
- hacknetnodes, city,
- tutorial, options]
- );
-
- //Start interactive tutorial
- Object(_InteractiveTutorial__WEBPACK_IMPORTED_MODULE_22__[/* iTutorialStart */ "c"])();
- Object(_utils_uiHelpers_removeLoadingScreen__WEBPACK_IMPORTED_MODULE_58__["removeLoadingScreen"])();
- }
- //Initialize labels on game settings
- Object(_ui_setSettingsLabels__WEBPACK_IMPORTED_MODULE_48__[/* setSettingsLabels */ "a"])();
- Object(_Script__WEBPACK_IMPORTED_MODULE_34__[/* scriptEditorInit */ "h"])();
- _Terminal__WEBPACK_IMPORTED_MODULE_41__[/* Terminal */ "a"].resetTerminalInput();
- },
-
- setDisplayElements: function() {
- //Content elements
- Engine.Display.terminalContent = document.getElementById("terminal-container");
- _ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["routing"].navigateTo(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_46__["Page"].Terminal);
-
- Engine.Display.characterContent = document.getElementById("character-container");
- Engine.Display.characterContent.style.display = "none";
-
- Engine.Display.scriptEditorContent = document.getElementById("script-editor-container");
- Engine.Display.scriptEditorContent.style.display = "none";
-
- Engine.Display.activeScriptsContent = document.getElementById("active-scripts-container");
- Engine.Display.activeScriptsContent.style.display = "none";
-
- Engine.Display.hacknetNodesContent = document.getElementById("hacknet-nodes-container");
- Engine.Display.hacknetNodesContent.style.display = "none";
-
- Engine.Display.worldContent = document.getElementById("world-container");
- Engine.Display.worldContent.style.display = "none";
-
- Engine.Display.createProgramContent = document.getElementById("create-program-container");
- Engine.Display.createProgramContent.style.display = "none";
-
- Engine.Display.factionsContent = document.getElementById("factions-container");
- Engine.Display.factionsContent.style.display = "none";
-
-
- Engine.Display.factionContent = document.getElementById("faction-container");
- Engine.Display.factionContent.style.display = "none";
-
- Engine.Display.factionAugmentationsContent = document.getElementById("faction-augmentations-container");
- Engine.Display.factionAugmentationsContent.style.display = "none";
-
- Engine.Display.augmentationsContent = document.getElementById("augmentations-container");
- Engine.Display.augmentationsContent.style.display = "none";
-
-
- Engine.Display.tutorialContent = document.getElementById("tutorial-container");
- Engine.Display.tutorialContent.style.display = "none";
-
- Engine.Display.infiltrationContent = document.getElementById("infiltration-container");
- Engine.Display.infiltrationContent.style.display = "none";
-
- Engine.Display.stockMarketContent = document.getElementById("stock-market-container");
- Engine.Display.stockMarketContent.style.display = "none";
-
- Engine.Display.missionContent = document.getElementById("mission-container");
- Engine.Display.missionContent.style.display = "none";
-
- //Character info
- Engine.Display.characterInfo = document.getElementById("character-content");
-
- //Location lists
- Engine.aevumLocationsList = document.getElementById("aevum-locations-list");
- Engine.chongqingLocationsList = document.getElementById("chongqing-locations-list");
- Engine.sector12LocationsList = document.getElementById("sector12-locations-list");
- Engine.newTokyoLocationsList = document.getElementById("newtokyo-locations-list");
- Engine.ishimaLocationsList = document.getElementById("ishima-locations-list");
- Engine.volhavenLocationsList = document.getElementById("volhaven-locations-list");
-
- //Location page (page that shows up when you visit a specific location in World)
- Engine.Display.locationContent = document.getElementById("location-container");
- //Engine.Display.locationContent.style.visibility = "hidden";
- Engine.Display.locationContent.style.display = "none";
-
- //Work In Progress
- Engine.Display.workInProgressContent = document.getElementById("work-in-progress-container");
- //Engine.Display.workInProgressContent.style.visibility = "hidden";
- Engine.Display.workInProgressContent.style.display = "none";
-
- //Red Pill / Hack World Daemon
- Engine.Display.redPillContent = document.getElementById("red-pill-container");
- Engine.Display.redPillContent.style.display = "none";
-
- //Cinematic Text
- Engine.Display.cinematicTextContent = document.getElementById("cinematic-text-container");
- Engine.Display.cinematicTextContent.style.display = "none";
-
- //Init Location buttons
- Object(_Location__WEBPACK_IMPORTED_MODULE_19__[/* initLocationButtons */ "b"])();
-
- //Tutorial buttons
- Engine.Clickables.tutorialNetworkingButton = document.getElementById("tutorial-networking-link");
- Engine.Clickables.tutorialNetworkingButton.addEventListener("click", function() {
- Engine.displayTutorialPage(_Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].TutorialNetworkingText);
- });
-
- Engine.Clickables.tutorialHackingButton = document.getElementById("tutorial-hacking-link");
- Engine.Clickables.tutorialHackingButton.addEventListener("click", function() {
- Engine.displayTutorialPage(_Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].TutorialHackingText);
- });
-
- Engine.Clickables.tutorialScriptsButton = document.getElementById("tutorial-scripts-link");
- Engine.Clickables.tutorialScriptsButton.addEventListener("click", function() {
- Engine.displayTutorialPage(_Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].TutorialScriptsText);
- });
-
- Engine.Clickables.tutorialNetscriptButton = document.getElementById("tutorial-netscript-link");
- Engine.Clickables.tutorialNetscriptButton.addEventListener("click", function() {
- Engine.displayTutorialPage(_Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].TutorialNetscriptText);
- });
-
- Engine.Clickables.tutorialTravelingButton = document.getElementById("tutorial-traveling-link");
- Engine.Clickables.tutorialTravelingButton.addEventListener("click", function() {
- Engine.displayTutorialPage(_Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].TutorialTravelingText);
- });
-
- Engine.Clickables.tutorialCompaniesButton = document.getElementById("tutorial-jobs-link");
- Engine.Clickables.tutorialCompaniesButton.addEventListener("click", function() {
- Engine.displayTutorialPage(_Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].TutorialCompaniesText);
- });
-
- Engine.Clickables.tutorialFactionsButton = document.getElementById("tutorial-factions-link");
- Engine.Clickables.tutorialFactionsButton.addEventListener("click", function() {
- Engine.displayTutorialPage(_Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].TutorialFactionsText);
- });
-
- Engine.Clickables.tutorialAugmentationsButton = document.getElementById("tutorial-augmentations-link");
- Engine.Clickables.tutorialAugmentationsButton.addEventListener("click", function() {
- Engine.displayTutorialPage(_Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].TutorialAugmentationsText);
- });
-
- Engine.Clickables.tutorialBackButton = document.getElementById("tutorial-back-button");
- Engine.Clickables.tutorialBackButton.addEventListener("click", function() {
- Engine.displayTutorialContent();
- });
-
- // Initialize references to main menu links
- if (!Object(_ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["initializeMainMenuLinks"])()) {
- const errorMsg = "Failed to initialize Main Menu Links. Please try refreshing the page. " +
- "If that doesn't work, report the issue to the developer";
- Object(_utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_57__["exceptionAlert"])(new Error(errorMsg));
- console.error(errorMsg);
- return;
- }
- },
-
- /* Initialization */
- init: function() {
- //Import game link
- document.getElementById("import-game-link").onclick = function() {
- _SaveObject__WEBPACK_IMPORTED_MODULE_33__[/* saveObject */ "b"].importGame();
- };
-
- // Initialize Main Menu Headers (this must be done after initializing the links)
- if (!Object(_ui_MainMenu_Headers__WEBPACK_IMPORTED_MODULE_49__["initializeMainMenuHeaders"])(_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"], "development" === "development")) {
- const errorMsg = "Failed to initialize Main Menu Headers. Please try refreshing the page. " +
- "If that doesn't work, report the issue to the developer";
- Object(_utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_57__["exceptionAlert"])(new Error(errorMsg));
- console.error(errorMsg);
- return;
- }
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Terminal.addEventListener("click", function() {
- Engine.loadTerminalContent();
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].ScriptEditor.addEventListener("click", function() {
- Engine.loadScriptEditorContent();
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].ActiveScripts.addEventListener("click", function() {
- Engine.loadActiveScriptsContent();
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].CreateProgram.addEventListener("click", function() {
- Engine.loadCreateProgramContent();
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Stats.addEventListener("click", function() {
- Engine.loadCharacterContent();
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Factions.addEventListener("click", function() {
- Engine.loadFactionsContent();
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Augmentations.addEventListener("click", function() {
- Engine.loadAugmentationsContent();
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].HacknetNodes.addEventListener("click", function() {
- Engine.loadHacknetNodesContent();
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Sleeves.addEventListener("click", function() {
- Engine.loadSleevesContent();
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Sleeves.classList.add("active");
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].City.addEventListener("click", function() {
- Engine.loadWorldContent();
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Travel.addEventListener("click", function() {
- Engine.loadTravelContent();
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Travel.classList.add("active");
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Job.addEventListener("click", function() {
- Engine.loadJobContent();
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Job.classList.add("active");
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].StockMarket.addEventListener("click", function() {
- Engine.loadStockMarketContent();
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].StockMarket.classList.add("active");
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Bladeburner.addEventListener("click", function() {
- Engine.loadBladeburnerContent();
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Corporation.addEventListener("click", function() {
- Engine.loadCorporationContent();
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Corporation.classList.add("active");
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Gang.addEventListener("click", function() {
- Engine.loadGangContent();
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].Tutorial.addEventListener("click", function() {
- Engine.loadTutorialContent();
- return false;
- });
-
- _ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_50__["MainMenuLinks"].DevMenu.addEventListener("click", function() {
- if (true) {
- Engine.loadDevMenuContent();
- }
- return false;
- });
-
- //Active scripts list
- Engine.ActiveScriptsList = document.getElementById("active-scripts-list");
-
- //Save, Delete, Import/Export buttons
- Engine.Clickables.saveMainMenuButton = document.getElementById("save-game-link");
- Engine.Clickables.saveMainMenuButton.addEventListener("click", function() {
- _SaveObject__WEBPACK_IMPORTED_MODULE_33__[/* saveObject */ "b"].saveGame(indexedDb);
- return false;
- });
-
- Engine.Clickables.deleteMainMenuButton = document.getElementById("delete-game-link");
- Engine.Clickables.deleteMainMenuButton.addEventListener("click", function() {
- _SaveObject__WEBPACK_IMPORTED_MODULE_33__[/* saveObject */ "b"].deleteGame(indexedDb);
- return false;
- });
-
- document.getElementById("export-game-link").addEventListener("click", function() {
- _SaveObject__WEBPACK_IMPORTED_MODULE_33__[/* saveObject */ "b"].exportGame();
- return false;
- });
-
- //Character Overview buttons
- document.getElementById("character-overview-save-button").addEventListener("click", function() {
- _SaveObject__WEBPACK_IMPORTED_MODULE_33__[/* saveObject */ "b"].saveGame(indexedDb);
- return false;
- });
-
- document.getElementById("character-overview-options-button").addEventListener("click", function() {
- Object(_utils_GameOptions__WEBPACK_IMPORTED_MODULE_52__[/* gameOptionsBoxOpen */ "b"])();
- return false;
- });
-
- //Create Program buttons
- Object(_Programs_ProgramHelpers__WEBPACK_IMPORTED_MODULE_31__[/* initCreateProgramButtons */ "c"])();
-
- //Message at the top of terminal
- Object(_Terminal__WEBPACK_IMPORTED_MODULE_41__[/* postNetburnerText */ "b"])();
-
- //Player was working cancel button
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].isWorking) {
- var cancelButton = document.getElementById("work-in-progress-cancel-button");
- cancelButton.addEventListener("click", function() {
- if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeFaction) {
- var fac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_16__["Factions"][_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].currentWorkFactionName];
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].finishFactionWork(true);
- } else if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeCreateProgram) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].finishCreateProgramWork(true);
- } else if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeStudyClass) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].finishClass();
- } else if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeCrime) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].finishCrime(true);
- } else if (_Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].workType == _Constants__WEBPACK_IMPORTED_MODULE_14__["CONSTANTS"].WorkTypeCompanyPartTime) {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].finishWorkPartTime();
- } else {
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].finishWork(true);
- }
- });
- Engine.loadWorkInProgressContent();
- }
-
- //character overview screen
- document.getElementById("character-overview-container").style.display = "block";
-
- //Remove classes from links (they might be set from tutorial)
- document.getElementById("terminal-menu-link").removeAttribute("class");
- document.getElementById("stats-menu-link").removeAttribute("class");
- document.getElementById("create-script-menu-link").removeAttribute("class");
- document.getElementById("active-scripts-menu-link").removeAttribute("class");
- document.getElementById("hacknet-nodes-menu-link").removeAttribute("class");
- document.getElementById("city-menu-link").removeAttribute("class");
- document.getElementById("tutorial-menu-link").removeAttribute("class");
-
- // Copy Save Data to Clipboard
- document.getElementById("copy-save-to-clipboard-link").addEventListener("click", function() {
- const saveString = _SaveObject__WEBPACK_IMPORTED_MODULE_33__[/* saveObject */ "b"].getSaveString();
- if (!navigator.clipboard) {
- // Async Clipboard API not supported, so we'll use this using the
- // textarea and document.execCommand('copy') trick
- const textArea = document.createElement("textarea");
- textArea.value = saveString;
- textArea.setAttribute("readonly", '');
- textArea.style.position = 'absolute';
- textArea.left = '-9999px';
- document.body.appendChild(textArea);
- textArea.focus();
- textArea.select();
- try {
- const successful = document.execCommand("copy");
- if (successful) {
- Object(_ui_createStatusText__WEBPACK_IMPORTED_MODULE_45__["createStatusText"])("Copied save to clipboard");
- } else {
- Object(_ui_createStatusText__WEBPACK_IMPORTED_MODULE_45__["createStatusText"])("Failed to copy save");
- }
- } catch(e) {
- console.error("Unable to copy save data to clipboard using document.execCommand('copy')");
- Object(_ui_createStatusText__WEBPACK_IMPORTED_MODULE_45__["createStatusText"])("Failed to copy save");
- }
- document.body.removeChild(textArea);
- } else {
- // Use the Async Clipboard API
- navigator.clipboard.writeText(saveString).then(function() {
- Object(_ui_createStatusText__WEBPACK_IMPORTED_MODULE_45__["createStatusText"])("Copied save to clipboard");
- }, function(e) {
- console.error("Unable to copy save data to clipboard using Async API");
- Object(_ui_createStatusText__WEBPACK_IMPORTED_MODULE_45__["createStatusText"])("Failed to copy save");
- })
- }
- });
-
- //DEBUG Delete active Scripts on home
- document.getElementById("debug-delete-scripts-link").addEventListener("click", function() {
- console.log("Deleting running scripts on home computer");
- _Player__WEBPACK_IMPORTED_MODULE_28__[/* Player */ "a"].getHomeComputer().runningScripts = [];
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_51__["dialogBoxCreate"])("Forcefully deleted all running scripts on home computer. Please save and refresh page");
- Object(_utils_GameOptions__WEBPACK_IMPORTED_MODULE_52__[/* gameOptionsBoxClose */ "a"])();
- return false;
- });
-
- //DEBUG Soft Reset
- document.getElementById("debug-soft-reset").addEventListener("click", function() {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_51__["dialogBoxCreate"])("Soft Reset!");
- Object(_Prestige__WEBPACK_IMPORTED_MODULE_29__[/* prestigeAugmentation */ "a"])();
- Object(_utils_GameOptions__WEBPACK_IMPORTED_MODULE_52__[/* gameOptionsBoxClose */ "a"])();
- return false;
- });
- },
-
- start: function() {
- //Run main loop
- Engine.idleTimer();
-
- //Scripts
- Object(_NetscriptWorker__WEBPACK_IMPORTED_MODULE_27__[/* runScriptsLoop */ "f"])();
- }
-};
-
-var indexedDb, indexedDbRequest;
-window.onload = function() {
- if (!window.indexedDB) {
- return Engine.load(null); //Will try to load from localstorage
- }
-
- //DB is called bitburnerSave
- //Object store is called savestring
- //key for the Object store is called save
- indexedDbRequest = window.indexedDB.open("bitburnerSave", 1);
-
- indexedDbRequest.onerror = function(e) {
- console.log("Error opening indexedDB: ");
- console.log(e);
- return Engine.load(null); //Try to load from localstorage
- };
-
- indexedDbRequest.onsuccess = function(e) {
- console.log("Opening bitburnerSave database successful!");
- indexedDb = e.target.result;
- var transaction = indexedDb.transaction(["savestring"]);
- var objectStore = transaction.objectStore("savestring");
- var request = objectStore.get("save");
- request.onerror = function(e) {
- console.log("Error in Database request to get savestring: " + e);
- return Engine.load(null); //Try to load from localstorage
- }
-
- request.onsuccess = function(e) {
- Engine.load(request.result); //Is this right?
- }
- };
-
- indexedDbRequest.onupgradeneeded = function(e) {
- var db = e.target.result;
- var objectStore = db.createObjectStore("savestring");
- }
-};
-
-
-
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 72)))
-
-/***/ }),
-/* 12 */
-/*!***********************!*\
- !*** ./src/Server.js ***!
- \***********************/
-/*! exports provided: initForeignServers, numCycleForGrowth, processSingleServerGrowth, prestigeHomeComputer, prestigeAllServers, loadAllServers, AddToAllServers, GetServerByHostname, getServer, Server, AllServers */
-/*! exports used: AddToAllServers, AllServers, GetServerByHostname, Server, getServer, initForeignServers, loadAllServers, numCycleForGrowth, prestigeAllServers, prestigeHomeComputer, processSingleServerGrowth */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return initForeignServers; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return numCycleForGrowth; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return processSingleServerGrowth; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return prestigeHomeComputer; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return prestigeAllServers; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return loadAllServers; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AddToAllServers; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return GetServerByHostname; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return getServer; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return Server; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return AllServers; });
-/* harmony import */ var _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode/BitNodeMultipliers */ 10);
-/* harmony import */ var _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_0__);
-/* harmony import */ var _CodingContracts__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./CodingContracts */ 48);
-/* harmony import */ var _CodingContracts__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_CodingContracts__WEBPACK_IMPORTED_MODULE_1__);
-/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Constants */ 1);
-/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_Constants__WEBPACK_IMPORTED_MODULE_2__);
-/* harmony import */ var _Script__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Script */ 33);
-/* harmony import */ var _Player__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Player */ 0);
-/* harmony import */ var _Programs_Programs__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Programs/Programs */ 28);
-/* harmony import */ var _Programs_Programs__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_Programs_Programs__WEBPACK_IMPORTED_MODULE_5__);
-/* harmony import */ var _SpecialServerIps__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./SpecialServerIps */ 37);
-/* harmony import */ var _TextFile__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./TextFile */ 73);
-/* harmony import */ var _TextFile__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_TextFile__WEBPACK_IMPORTED_MODULE_7__);
-/* harmony import */ var _utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/helpers/getRandomInt */ 17);
-/* harmony import */ var _utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_8__);
-/* harmony import */ var _utils_IPAddress__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/IPAddress */ 70);
-/* harmony import */ var _data_servers__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./data/servers */ 161);
-/* harmony import */ var _data_servers__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_data_servers__WEBPACK_IMPORTED_MODULE_10__);
-/* harmony import */ var _utils_JSONReviver__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/JSONReviver */ 15);
-/* harmony import */ var _utils_helpers_isValidIPAddress__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/helpers/isValidIPAddress */ 102);
-/* harmony import */ var _utils_helpers_isValidIPAddress__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_isValidIPAddress__WEBPACK_IMPORTED_MODULE_12__);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-function Server(params={ip:Object(_utils_IPAddress__WEBPACK_IMPORTED_MODULE_9__[/* createRandomIp */ "a"])(), hostname:""}) {
- /* Properties */
- //Connection information
- this.ip = params.ip ? params.ip : Object(_utils_IPAddress__WEBPACK_IMPORTED_MODULE_9__[/* createRandomIp */ "a"])();
-
- var hostname = params.hostname;
- var i = 0;
- var suffix = "";
- while (GetServerByHostname(hostname+suffix) != null) {
- //Server already exists
- suffix = "-" + i;
- ++i;
- }
- this.hostname = hostname + suffix;
- this.organizationName = params.organizationName != null ? params.organizationName : "";
- this.isConnectedTo = params.isConnectedTo != null ? params.isConnectedTo : false;
-
- //Access information
- this.hasAdminRights = params.adminRights != null ? params.adminRights : false;
- this.purchasedByPlayer = params.purchasedByPlayer != null ? params.purchasedByPlayer : false;
- this.manuallyHacked = false; //Flag that tracks whether or not the server has been hacked at least once
-
- //RAM, CPU speed and Scripts
- this.maxRam = params.maxRam != null ? params.maxRam : 0; //GB
- this.ramUsed = 0;
- this.cpuCores = 1; //Max of 8, affects hacking times and Hacking Mission starting Cores
-
- this.scripts = [];
- this.runningScripts = []; //Stores RunningScript objects
- this.programs = [];
- this.messages = [];
- this.textFiles = [];
- this.contracts = [];
- this.dir = 0; //new Directory(this, null, ""); TODO
-
- /* Hacking information (only valid for "foreign" aka non-purchased servers) */
- this.requiredHackingSkill = params.requiredHackingSkill != null ? params.requiredHackingSkill : 1;
- this.moneyAvailable = params.moneyAvailable != null ? params.moneyAvailable * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerStartingMoney : 0;
- this.moneyMax = 25 * this.moneyAvailable * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerMaxMoney;
-
- //Hack Difficulty is synonymous with server security. Base Difficulty = Starting difficulty
- this.hackDifficulty = params.hackDifficulty != null ? params.hackDifficulty * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerStartingSecurity : 1;
- this.baseDifficulty = this.hackDifficulty;
- this.minDifficulty = Math.max(1, Math.round(this.hackDifficulty / 3));
- this.serverGrowth = params.serverGrowth != null ? params.serverGrowth : 1; //Integer from 0 to 100. Affects money increase from grow()
-
- //The IP's of all servers reachable from this one (what shows up if you run scan/netstat)
- // NOTE: Only contains IP and not the Server objects themselves
- this.serversOnNetwork = [];
-
- //Port information, required for porthacking servers to get admin rights
- this.numOpenPortsRequired = params.numOpenPortsRequired != null ? params.numOpenPortsRequired : 5;
- this.sshPortOpen = false; //Port 22
- this.ftpPortOpen = false; //Port 21
- this.smtpPortOpen = false; //Port 25
- this.httpPortOpen = false; //Port 80
- this.sqlPortOpen = false; //Port 1433
- this.openPortCount = 0;
-};
-
-Server.prototype.setMaxRam = function(ram) {
- this.maxRam = ram;
-}
-
-//The serverOnNetwork array holds the IP of all the servers. This function
-//returns the actual Server objects
-Server.prototype.getServerOnNetwork = function(i) {
- if (i > this.serversOnNetwork.length) {
- console.log("Tried to get server on network that was out of range");
- return;
- }
- return AllServers[this.serversOnNetwork[i]];
-}
-
-//Given the name of the script, returns the corresponding
-//script object on the server (if it exists)
-Server.prototype.getScript = function(scriptName) {
- for (var i = 0; i < this.scripts.length; i++) {
- if (this.scripts[i].filename == scriptName) {
- return this.scripts[i];
- }
- }
- return null;
-}
-
-Server.prototype.capDifficulty = function() {
- if (this.hackDifficulty < this.minDifficulty) {this.hackDifficulty = this.minDifficulty;}
- if (this.hackDifficulty < 1) {this.hackDifficulty = 1;}
- //Place some arbitrarily limit that realistically should never happen unless someone is
- //screwing around with the game
- if (this.hackDifficulty > 1000000) {this.hackDifficulty = 1000000;}
-}
-
-//Strengthens a server's security level (difficulty) by the specified amount
-Server.prototype.fortify = function(amt) {
- this.hackDifficulty += amt;
- this.capDifficulty();
-}
-
-Server.prototype.weaken = function(amt) {
- this.hackDifficulty -= (amt * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerWeakenRate);
- this.capDifficulty();
-}
-
-// Write to a script file
-// Overwrites existing files. Creates new files if the script does not eixst
-Server.prototype.writeToScriptFile = function(fn, code) {
- var ret = {success: false, overwritten: false};
- if (!Object(_Script__WEBPACK_IMPORTED_MODULE_3__[/* isScriptFilename */ "f"])(fn)) { return ret; }
-
- //Check if the script already exists, and overwrite it if it does
- for (let i = 0; i < this.scripts.length; ++i) {
- if (fn === this.scripts[i].filename) {
- let script = this.scripts[i];
- script.code = code;
- script.updateRamUsage();
- script.module = "";
- ret.overwritten = true;
- ret.success = true;
- return ret;
- }
- }
-
- //Otherwise, create a new script
- var newScript = new _Script__WEBPACK_IMPORTED_MODULE_3__[/* Script */ "c"]();
- newScript.filename = fn;
- newScript.code = code;
- newScript.updateRamUsage();
- newScript.server = this.ip;
- this.scripts.push(newScript);
- ret.success = true;
- return ret;
-}
-
-// Write to a text file
-// Overwrites existing files. Creates new files if the text file does not exist
-Server.prototype.writeToTextFile = function(fn, txt) {
- var ret = {success: false, overwritten: false};
- if (!fn.endsWith("txt")) { return ret; }
-
- //Check if the text file already exists, and overwrite if it does
- for (let i = 0; i < this.textFiles.length; ++i) {
- if (this.textFiles[i].fn === fn) {
- ret.overwritten = true;
- this.textFiles[i].text = txt;
- ret.success = true;
- return ret;
- }
- }
-
- //Otherwise create a new text file
- var newFile = new _TextFile__WEBPACK_IMPORTED_MODULE_7__["TextFile"](fn, txt);
- this.textFiles.push(newFile);
- ret.success = true;
- return ret;
-}
-
-Server.prototype.addContract = function(contract) {
- this.contracts.push(contract);
-}
-
-Server.prototype.removeContract = function(contract) {
- if (contract instanceof _CodingContracts__WEBPACK_IMPORTED_MODULE_1__["CodingContract"]) {
- this.contracts = this.contracts.filter((c) => {
- return c.fn !== contract.fn;
- });
- } else {
- this.contracts = this.contracts.filter((c) => {
- return c.fn !== contract;
- });
- }
-}
-
-Server.prototype.getContract = function(contractName) {
- for (const contract of this.contracts) {
- if (contract.fn === contractName) {
- return contract;
- }
- }
- return null;
-}
-
-//Functions for loading and saving a Server
-Server.prototype.toJSON = function() {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_11__["Generic_toJSON"])("Server", this);
-}
-
-Server.fromJSON = function(value) {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_11__["Generic_fromJSON"])(Server, value.data);
-}
-
-_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_11__["Reviver"].constructors.Server = Server;
-
-function initForeignServers() {
- /* Create a randomized network for all the foreign servers */
- //Groupings for creating a randomized network
- const networkLayers = [];
- for (let i = 0; i < 15; i++) {
- networkLayers.push([]);
- }
-
- // Essentially any property that is of type 'number | IMinMaxRange'
- const propertiesToPatternMatch = [
- "hackDifficulty",
- "moneyAvailable",
- "requiredHackingSkill",
- "serverGrowth"
- ];
-
- const toNumber = (value) => {
- switch (typeof value) {
- case 'number':
- return value;
- case 'object':
- return Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_8__["getRandomInt"])(value.min, value.max);
- default:
- throw Error(`Do not know how to convert the type '${typeof value}' to a number`);
- }
- }
-
- for (const metadata of _data_servers__WEBPACK_IMPORTED_MODULE_10__["serverMetadata"]) {
- const serverParams = {
- hostname: metadata.hostname,
- ip: Object(_utils_IPAddress__WEBPACK_IMPORTED_MODULE_9__[/* createRandomIp */ "a"])(),
- numOpenPortsRequired: metadata.numOpenPortsRequired,
- organizationName: metadata.organizationName
- };
-
- if (metadata.maxRamExponent !== undefined) {
- serverParams.maxRam = Math.pow(2, toNumber(metadata.maxRamExponent));
- }
-
- for (const prop of propertiesToPatternMatch) {
- if (metadata[prop] !== undefined) {
- serverParams[prop] = toNumber(metadata[prop]);
- }
- }
-
- const server = new Server(serverParams);
- for (const filename of (metadata.literature || [])) {
- server.messages.push(filename);
- }
-
- if (metadata.specialName !== undefined) {
- _SpecialServerIps__WEBPACK_IMPORTED_MODULE_6__[/* SpecialServerIps */ "a"].addIp(metadata.specialName, server.ip);
- }
-
- AddToAllServers(server);
- if (metadata.networkLayer !== undefined) {
- networkLayers[toNumber(metadata.networkLayer) - 1].push(server);
- }
- }
-
- /* Create a randomized network for all the foreign servers */
- const linkComputers = (server1, server2) => {
- server1.serversOnNetwork.push(server2.ip);
- server2.serversOnNetwork.push(server1.ip);
- };
-
- const getRandomArrayItem = (arr) => arr[Math.floor(Math.random() * arr.length)];
-
- const linkNetworkLayers = (network1, selectServer) => {
- for (const server of network1) {
- linkComputers(server, selectServer());
- }
- };
-
- // Connect the first tier of servers to the player's home computer
- linkNetworkLayers(networkLayers[0], () => _Player__WEBPACK_IMPORTED_MODULE_4__[/* Player */ "a"].getHomeComputer());
- for (let i = 1; i < networkLayers.length; i++) {
- linkNetworkLayers(networkLayers[i], () => getRandomArrayItem(networkLayers[i - 1]));
- }
-}
-
-// Returns the number of cycles needed to grow the specified server by the
-// specified amount. 'growth' parameter is in decimal form, not percentage
-function numCycleForGrowth(server, growth) {
- let ajdGrowthRate = 1 + (_Constants__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].ServerBaseGrowthRate - 1) / server.hackDifficulty;
- if(ajdGrowthRate > _Constants__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].ServerMaxGrowthRate) {
- ajdGrowthRate = _Constants__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].ServerMaxGrowthRate;
- }
-
- const serverGrowthPercentage = server.serverGrowth / 100;
-
- const cycles = Math.log(growth)/(Math.log(ajdGrowthRate)*_Player__WEBPACK_IMPORTED_MODULE_4__[/* Player */ "a"].hacking_grow_mult*serverGrowthPercentage);
- return cycles;
-}
-
-//Applied server growth for a single server. Returns the percentage growth
-function processSingleServerGrowth(server, numCycles) {
- //Server growth processed once every 450 game cycles
- const numServerGrowthCycles = Math.max(Math.floor(numCycles / 450), 0);
-
- //Get adjusted growth rate, which accounts for server security
- const growthRate = _Constants__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].ServerBaseGrowthRate;
- var adjGrowthRate = 1 + (growthRate - 1) / server.hackDifficulty;
- if (adjGrowthRate > _Constants__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].ServerMaxGrowthRate) {adjGrowthRate = _Constants__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].ServerMaxGrowthRate;}
-
- //Calculate adjusted server growth rate based on parameters
- const serverGrowthPercentage = server.serverGrowth / 100;
- const numServerGrowthCyclesAdjusted = numServerGrowthCycles * serverGrowthPercentage * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerGrowthRate;
-
- //Apply serverGrowth for the calculated number of growth cycles
- var serverGrowth = Math.pow(adjGrowthRate, numServerGrowthCyclesAdjusted * _Player__WEBPACK_IMPORTED_MODULE_4__[/* Player */ "a"].hacking_grow_mult);
- if (serverGrowth < 1) {
- console.log("WARN: serverGrowth calculated to be less than 1");
- serverGrowth = 1;
- }
-
- const oldMoneyAvailable = server.moneyAvailable;
- server.moneyAvailable *= serverGrowth;
-
- // in case of data corruption
- if (server.moneyMax && isNaN(server.moneyAvailable)) {
- server.moneyAvailable = server.moneyMax;
- }
-
- // cap at max
- if (server.moneyMax && server.moneyAvailable > server.moneyMax) {
- server.moneyAvailable = server.moneyMax;
- }
-
- // if there was any growth at all, increase security
- if (oldMoneyAvailable !== server.moneyAvailable) {
- //Growing increases server security twice as much as hacking
- let usedCycles = numCycleForGrowth(server, server.moneyAvailable / oldMoneyAvailable);
- usedCycles = Math.max(0, usedCycles);
- server.fortify(2 * _Constants__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].ServerFortifyAmount * Math.ceil(usedCycles));
- }
- return server.moneyAvailable / oldMoneyAvailable;
-}
-
-function prestigeHomeComputer(homeComp) {
- const hasBitflume = homeComp.programs.includes(_Programs_Programs__WEBPACK_IMPORTED_MODULE_5__["Programs"].BitFlume.name);
-
- homeComp.programs.length = 0; //Remove programs
- homeComp.runningScripts = [];
- homeComp.serversOnNetwork = [];
- homeComp.isConnectedTo = true;
- homeComp.ramUsed = 0;
- homeComp.programs.push(_Programs_Programs__WEBPACK_IMPORTED_MODULE_5__["Programs"].NukeProgram.name);
- if (hasBitflume) { homeComp.programs.push(_Programs_Programs__WEBPACK_IMPORTED_MODULE_5__["Programs"].BitFlume.name); }
-
- //Update RAM usage on all scripts
- homeComp.scripts.forEach(function(script) {
- script.updateRamUsage();
- });
-
- homeComp.messages.length = 0; //Remove .lit and .msg files
- homeComp.messages.push("hackers-starting-handbook.lit");
-}
-
-//List of all servers that exist in the game, indexed by their ip
-let AllServers = {};
-
-function prestigeAllServers() {
- for (var member in AllServers) {
- delete AllServers[member];
- }
- AllServers = {};
-}
-
-function loadAllServers(saveString) {
- AllServers = JSON.parse(saveString, _utils_JSONReviver__WEBPACK_IMPORTED_MODULE_11__["Reviver"]);
-}
-
-function SizeOfAllServers() {
- var size = 0, key;
- for (key in AllServers) {
- if (AllServers.hasOwnProperty(key)) size++;
- }
- return size;
-}
-
-//Add a server onto the map of all servers in the game
-function AddToAllServers(server) {
- var serverIp = server.ip;
- if (Object(_utils_IPAddress__WEBPACK_IMPORTED_MODULE_9__[/* ipExists */ "b"])(serverIp)) {
- console.log("IP of server that's being added: " + serverIp);
- console.log("Hostname of the server thats being added: " + server.hostname);
- console.log("The server that already has this IP is: " + AllServers[serverIp].hostname);
- throw new Error("Error: Trying to add a server with an existing IP");
- return;
- }
- AllServers[serverIp] = server;
-}
-
-//Returns server object with corresponding hostname
-// Relatively slow, would rather not use this a lot
-function GetServerByHostname(hostname) {
- for (var ip in AllServers) {
- if (AllServers.hasOwnProperty(ip)) {
- if (AllServers[ip].hostname == hostname) {
- return AllServers[ip];
- }
- }
- }
- return null;
-}
-
-//Get server by IP or hostname. Returns null if invalid
-function getServer(s) {
- if (!Object(_utils_helpers_isValidIPAddress__WEBPACK_IMPORTED_MODULE_12__["isValidIPAddress"])(s)) {
- return GetServerByHostname(s);
- }
- if(AllServers[s] !== undefined) {
- return AllServers[s];
- }
- return null;
-}
-
-//Debugging tool
-function PrintAllServers() {
- for (var ip in AllServers) {
- if (AllServers.hasOwnProperty(ip)) {
- console.log("Ip: " + ip + ", hostname: " + AllServers[ip].hostname);
- }
- }
-}
-
-// Directory object (folders)
-function Directory(server, parent, name) {
- this.s = server; //Ref to server
- this.p = parent; //Ref to parent directory
- this.c = []; //Subdirs
- this.n = name;
- this.d = parent.d + 1; //We'll only have a maximum depth of 3 or something
- this.scrs = []; //Holds references to the scripts in server.scripts
- this.pgms = [];
- this.msgs = [];
-}
-
-Directory.prototype.createSubdir = function(name) {
- var subdir = new Directory(this.s, this, name);
-
-}
-
-Directory.prototype.getPath = function(name) {
- var res = [];
- var i = this;
- while (i !== null) {
- res.unshift(i.n, "/");
- i = i.parent;
- }
- res.unshift("/");
- return res.join("");
-}
-
-
-
-
-/***/ }),
-/* 13 */
-/*!**************************************!*\
- !*** ./src/ui/navigationTracking.ts ***!
- \**************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-/**
- * The full-screen page the player is currently be on.
- * These pages are mutually exclusive.
- */
-var Page;
-(function (Page) {
- /**
- * (Default) The terminal is where the player issues all commands, executes scripts, etc.
- */
- Page["Terminal"] = "Terminal";
- /**
- * Displays most of the statistics about the player.
- */
- Page["CharacterInfo"] = "CharacterInfo";
- /**
- * The console for editing Netscript files.
- */
- Page["ScriptEditor"] = "ScriptEditor";
- /**
- * Monitor the scripts currently executing across the servers.
- */
- Page["ActiveScripts"] = "ActiveScripts";
- /**
- * View, purchase, and upgrade Hacknet nodes.
- */
- Page["HacknetNodes"] = "HacknetNodes";
- /**
- * View the city the player is currently in.
- */
- Page["World"] = "World";
- /**
- * The list of programs the player could potentially build.
- */
- Page["CreateProgram"] = "CreateProgram";
- /**
- * The list of all factions, and invites, available to the player.
- */
- Page["Factions"] = "Factions";
- /**
- * Information about a specific faction.
- */
- Page["Faction"] = "Faction";
- /**
- * The list of installed, and yet-to-be installed, augmentations the player has purchased.
- */
- Page["Augmentations"] = "Augmentations";
- /**
- * A collection of in-game material to learn about the game.
- */
- Page["Tutorial"] = "Tutorial";
- /**
- * A collection of items to manipulate the state of the game. Useful for development.
- */
- Page["DevMenu"] = "Dev Menu";
- /**
- * Information about the specific location the player at (job, company, etc.);
- */
- Page["Location"] = "Location";
- /**
- * A blocking page to show the player they are currently doing some action (building a program, working, etc.).
- */
- Page["workInProgress"] = "WorkInProgress";
- /**
- * A special screen to show the player they've reached a certain point in the game.
- */
- Page["RedPill"] = "RedPill";
- /**
- * A special screen to show the player they've reached a certain point in the game.
- */
- Page["CinematicText"] = "CinematicText";
- /**
- * Mini-game to infiltrate a company, gaining experience from successful progress.
- */
- Page["Infiltration"] = "Infiltration";
- /**
- * View the in-game stock market.
- */
- Page["StockMarket"] = "StockMarket";
- /**
- * Manage gang actions and members.
- */
- Page["Gang"] = "Gang";
- /**
- * Perform missions for a Faction.
- */
- Page["Mission"] = "Mission";
- /**
- * Manage a corporation.
- */
- Page["Corporation"] = "Corporation";
- /**
- * Manage special Bladeburner activities.
- */
- Page["Bladeburner"] = "Bladeburner";
- /**
- * Manage your Sleeves
- */
- Page["Sleeves"] = "Sleeves";
- /**
- * Purchase Resleeves
- */
- Page["Resleeves"] = "Re-sleeving";
-})(Page = exports.Page || (exports.Page = {}));
-/**
- * This class keeps track of player navigation/routing within the game.
- */
-class Routing {
- constructor() {
- /**
- * Tracking the what page the user is currently on.
- */
- this.currentPage = null;
- }
- /**
- * Determines if the player is currently on the specified page.
- * @param page The page to compare against the current state.
- */
- isOn(page) {
- return this.currentPage === page;
- }
- /**
- * Routes the player to the appropriate page.
- * @param page The page to navigate to.
- */
- navigateTo(page) {
- this.currentPage = page;
- }
-}
-/**
- * The routing instance for tracking page navigation.
- */
-exports.routing = new Routing();
-
-
-/***/ }),
-/* 14 */
-/*!*******************************************!*\
- !*** ./src/Augmentation/Augmentations.ts ***!
- \*******************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.Augmentations = {};
-
-
-/***/ }),
-/* 15 */
-/*!******************************!*\
- !*** ./utils/JSONReviver.js ***!
- \******************************/
-/*! exports provided: Reviver, Generic_toJSON, Generic_fromJSON */
-/*! all exports used */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-__webpack_require__.r(__webpack_exports__);
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Reviver", function() { return Reviver; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Generic_toJSON", function() { return Generic_toJSON; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Generic_fromJSON", function() { return Generic_fromJSON; });
-/* Generic Reviver, toJSON, and fromJSON functions used for saving and loading objects */
-
-// A generic "smart reviver" function.
-// Looks for object values with a `ctor` property and
-// a `data` property. If it finds them, and finds a matching
-// constructor that has a `fromJSON` property on it, it hands
-// off to that `fromJSON` fuunction, passing in the value.
-function Reviver(key, value) {
- var ctor;
- if (value == null) {
- console.log("Reviver WRONGLY called with key: " + key + ", and value: " + value);
- return 0;
- }
-
- if (typeof value === "object" &&
- typeof value.ctor === "string" &&
- typeof value.data !== "undefined") {
- ctor = Reviver.constructors[value.ctor] || window[value.ctor];
- if (typeof ctor === "function" &&
- typeof ctor.fromJSON === "function") {
-
- return ctor.fromJSON(value);
- }
- }
- return value;
-}
-Reviver.constructors = {}; // A list of constructors the smart reviver should know about
-
-// A generic "toJSON" function that creates the data expected
-// by Reviver.
-// `ctorName` The name of the constructor to use to revive it
-// `obj` The object being serialized
-// `keys` (Optional) Array of the properties to serialize,
-// if not given then all of the objects "own" properties
-// that don't have function values will be serialized.
-// (Note: If you list a property in `keys`, it will be serialized
-// regardless of whether it's an "own" property.)
-// Returns: The structure (which will then be turned into a string
-// as part of the JSON.stringify algorithm)
-function Generic_toJSON(ctorName, obj, keys) {
- var data, index, key;
-
- if (!keys) {
- keys = Object.keys(obj); // Only "own" properties are included
- }
-
- data = {};
- for (index = 0; index < keys.length; ++index) {
- key = keys[index];
- data[key] = obj[key];
- }
- return {ctor: ctorName, data: data};
-}
-
-// A generic "fromJSON" function for use with Reviver: Just calls the
-// constructor function with no arguments, then applies all of the
-// key/value pairs from the raw data to the instance. Only useful for
-// constructors that can be reasonably called without arguments!
-// `ctor` The constructor to call
-// `data` The data to apply
-// Returns: The object
-function Generic_fromJSON(ctor, data) {
- var obj, name;
-
- obj = new ctor();
- for (name in data) {
- obj[name] = data[name];
- }
- return obj;
-}
-
-
-
-
-/***/ }),
-/* 16 */
-/*!*********************************!*\
- !*** ./src/Faction/Factions.ts ***!
- \*********************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-/**
- * Initialization and manipulation of the Factions object, which stores data
- * about all Factions in the game
- */
-const Faction_1 = __webpack_require__(/*! ./Faction */ 62);
-const FactionInfo_1 = __webpack_require__(/*! ./FactionInfo */ 133);
-const JSONReviver_1 = __webpack_require__(/*! ../../utils/JSONReviver */ 15);
-exports.Factions = {};
-function loadFactions(saveString) {
- exports.Factions = JSON.parse(saveString, JSONReviver_1.Reviver);
-}
-exports.loadFactions = loadFactions;
-function AddToFactions(faction) {
- const name = faction.name;
- exports.Factions[name] = faction;
-}
-exports.AddToFactions = AddToFactions;
-function factionExists(name) {
- return exports.Factions.hasOwnProperty(name);
-}
-exports.factionExists = factionExists;
-function initFactions(bitNode = 1) {
- for (const name in FactionInfo_1.FactionInfos) {
- resetFaction(new Faction_1.Faction(name));
- }
-}
-exports.initFactions = initFactions;
-//Resets a faction during (re-)initialization. Saves the favor in the new
-//Faction object and deletes the old Faction Object from "Factions". Then
-//reinserts the new Faction object
-function resetFaction(newFactionObject) {
- if (!(newFactionObject instanceof Faction_1.Faction)) {
- throw new Error("Invalid argument 'newFactionObject' passed into resetFaction()");
- }
- const factionName = newFactionObject.name;
- if (factionExists(factionName)) {
- newFactionObject.favor = exports.Factions[factionName].favor;
- delete exports.Factions[factionName];
- }
- AddToFactions(newFactionObject);
-}
-exports.resetFaction = resetFaction;
-
-
-/***/ }),
-/* 17 */
-/*!***************************************!*\
- !*** ./utils/helpers/getRandomInt.ts ***!
- \***************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-/**
- * Gets a random integer bounded by the values passed in.
- * @param min The minimum value in the range.
- * @param max The maximum value in the range.
- */
-function getRandomInt(min, max) {
- const lower = Math.min(min, max);
- const upper = Math.max(min, max);
- return Math.floor(Math.random() * (upper - lower + 1)) + lower;
-}
-exports.getRandomInt = getRandomInt;
-
-
-/***/ }),
-/* 18 */
-/*!******************************************!*\
- !*** ./src/Augmentation/Augmentation.ts ***!
- \******************************************/
-/*! no static exports found */
-/*! exports used: Augmentation */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-// Class definition for a single Augmentation object
-const Constants_1 = __webpack_require__(/*! ../Constants */ 1);
-const BitNodeMultipliers_1 = __webpack_require__(/*! ../BitNode/BitNodeMultipliers */ 10);
-const Factions_1 = __webpack_require__(/*! ../Faction/Factions */ 16);
-const JSONReviver_1 = __webpack_require__(/*! ../../utils/JSONReviver */ 15);
-class Augmentation {
- constructor(params = { info: "", moneyCost: 0, name: "", repCost: 0 }) {
- // How much money this costs to buy
- this.baseCost = 0;
- // How much faction reputation is required to unlock this
- this.baseRepRequirement = 0;
- // Description of what this Aug is and what it does
- this.info = "";
- // Augmentation level - for repeatable Augs like NeuroFlux Governor
- this.level = 0;
- // Name of Augmentation
- this.name = "";
- // Whether the player owns this Augmentation
- this.owned = false;
- // Array of names of all prerequisites
- this.prereqs = [];
- // Multipliers given by this Augmentation. Must match the property name in
- // The Player/Person classes
- this.mults = {};
- this.name = params.name;
- this.info = params.info;
- this.prereqs = params.prereqs ? params.prereqs : [];
- this.baseRepRequirement = params.repCost * Constants_1.CONSTANTS.AugmentationRepMultiplier * BitNodeMultipliers_1.BitNodeMultipliers.AugmentationRepCost;
- this.baseCost = params.moneyCost * Constants_1.CONSTANTS.AugmentationCostMultiplier * BitNodeMultipliers_1.BitNodeMultipliers.AugmentationMoneyCost;
- this.level = 0;
- // Set multipliers
- if (params.hacking_mult) {
- this.mults.hacking_mult = params.hacking_mult;
- }
- if (params.strength_mult) {
- this.mults.strength_mult = params.strength_mult;
- }
- if (params.defense_mult) {
- this.mults.defense_mult = params.defense_mult;
- }
- if (params.dexterity_mult) {
- this.mults.dexterity_mult = params.dexterity_mult;
- }
- if (params.agility_mult) {
- this.mults.agility_mult = params.agility_mult;
- }
- if (params.charisma_mult) {
- this.mults.charisma_mult = params.charisma_mult;
- }
- if (params.hacking_exp_mult) {
- this.mults.hacking_exp_mult = params.hacking_exp_mult;
- }
- if (params.strength_exp_mult) {
- this.mults.strength_exp_mult = params.strength_exp_mult;
- }
- if (params.defense_exp_mult) {
- this.mults.defense_exp_mult = params.defense_exp_mult;
- }
- if (params.dexterity_exp_mult) {
- this.mults.dexterity_exp_mult = params.dexterity_exp_mult;
- }
- if (params.agility_exp_mult) {
- this.mults.agility_exp_mult = params.agility_exp_mult;
- }
- if (params.charisma_exp_mult) {
- this.mults.charisma_exp_mult = params.charisma_exp_mult;
- }
- if (params.hacking_chance_mult) {
- this.mults.hacking_chance_mult = params.hacking_chance_mult;
- }
- if (params.hacking_speed_mult) {
- this.mults.hacking_speed_mult = params.hacking_speed_mult;
- }
- if (params.hacking_money_mult) {
- this.mults.hacking_money_mult = params.hacking_money_mult;
- }
- if (params.hacking_grow_mult) {
- this.mults.hacking_grow_mult = params.hacking_grow_mult;
- }
- if (params.company_rep_mult) {
- this.mults.company_rep_mult = params.company_rep_mult;
- }
- if (params.faction_rep_mult) {
- this.mults.faction_rep_mult = params.faction_rep_mult;
- }
- if (params.crime_money_mult) {
- this.mults.crime_money_mult = params.crime_money_mult;
- }
- if (params.crime_success_mult) {
- this.mults.crime_success_mult = params.crime_success_mult;
- }
- if (params.work_money_mult) {
- this.mults.work_money_mult = params.work_money_mult;
- }
- if (params.hacknet_node_money_mult) {
- this.mults.hacknet_node_money_mult = params.hacknet_node_money_mult;
- }
- if (params.hacknet_node_purchase_cost_mult) {
- this.mults.hacknet_node_purchase_cost_mult = params.hacknet_node_purchase_cost_mult;
- }
- if (params.hacknet_node_ram_cost_mult) {
- this.mults.hacknet_node_ram_cost_mult = params.hacknet_node_ram_cost_mult;
- }
- if (params.hacknet_node_core_cost_mult) {
- this.mults.hacknet_node_core_cost_mult = params.hacknet_node_core_cost_mult;
- }
- if (params.hacknet_node_level_cost_mult) {
- this.mults.hacknet_node_level_cost_mult = params.hacknet_node_level_cost_mult;
- }
- if (params.bladeburner_max_stamina_mult) {
- this.mults.bladeburner_max_stamina_mult = params.bladeburner_max_stamina_mult;
- }
- if (params.bladeburner_stamina_gain_mult) {
- this.mults.bladeburner_stamina_gain_mult = params.bladeburner_stamina_gain_mult;
- }
- if (params.bladeburner_analysis_mult) {
- this.mults.bladeburner_analysis_mult = params.bladeburner_analysis_mult;
- }
- if (params.bladeburner_success_chance_mult) {
- this.mults.bladeburner_success_chance_mult = params.bladeburner_success_chance_mult;
- }
- }
- // Initiatizes a Augmentation object from a JSON save state.
- static fromJSON(value) {
- return JSONReviver_1.Generic_fromJSON(Augmentation, value.data);
- }
- // Adds this Augmentation to the specified Factions
- addToFactions(factionList) {
- for (let i = 0; i < factionList.length; ++i) {
- const faction = Factions_1.Factions[factionList[i]];
- if (faction == null) {
- console.warn(`In Augmentation.addToFactions(), could not find faction with this name: ${factionList[i]}`);
- continue;
- }
- faction.augmentations.push(this.name);
- }
- }
- // Adds this Augmentation to all Factions
- addToAllFactions() {
- for (const fac in Factions_1.Factions) {
- if (Factions_1.Factions.hasOwnProperty(fac)) {
- const facObj = Factions_1.Factions[fac];
- if (facObj == null) {
- console.warn(`Invalid Faction object in addToAllFactions(). Key value: ${fac}`);
- continue;
- }
- facObj.augmentations.push(this.name);
- }
- }
- }
- // Serialize the current object to a JSON save state.
- toJSON() {
- return JSONReviver_1.Generic_toJSON("Augmentation", this);
- }
-}
-exports.Augmentation = Augmentation;
-JSONReviver_1.Reviver.constructors.Augmentation = Augmentation;
-
-
-/***/ }),
-/* 19 */
-/*!**********************************!*\
- !*** ./src/Settings/Settings.ts ***!
- \**********************************/
-/*! no static exports found */
-/*! exports used: Settings */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-const SettingEnums_1 = __webpack_require__(/*! ./SettingEnums */ 45);
-const defaultSettings = {
- AutosaveInterval: 60,
- CodeInstructionRunTime: 50,
- DisableHotkeys: false,
- Locale: "en",
- MaxLogCapacity: 50,
- MaxPortCapacity: 50,
- SuppressBuyAugmentationConfirmation: false,
- SuppressFactionInvites: false,
- SuppressHospitalizationPopup: false,
- SuppressMessages: false,
- SuppressTravelConfirmation: false,
-};
-/**
- * The current options the player has customized to their play style.
- */
-// tslint:disable-next-line:variable-name
-exports.Settings = {
- AutosaveInterval: defaultSettings.AutosaveInterval,
- CodeInstructionRunTime: 25,
- DisableHotkeys: defaultSettings.DisableHotkeys,
- Editor: SettingEnums_1.EditorSetting.Ace,
- EditorKeybinding: SettingEnums_1.AceKeybindingSetting.Ace,
- EditorTheme: "Monokai",
- Locale: "en",
- MaxLogCapacity: defaultSettings.MaxLogCapacity,
- MaxPortCapacity: defaultSettings.MaxPortCapacity,
- OwnedAugmentationsOrder: SettingEnums_1.OwnedAugmentationsOrderSetting.AcquirementTime,
- PurchaseAugmentationsOrder: SettingEnums_1.PurchaseAugmentationsOrderSetting.Default,
- SuppressBuyAugmentationConfirmation: defaultSettings.SuppressBuyAugmentationConfirmation,
- SuppressFactionInvites: defaultSettings.SuppressFactionInvites,
- SuppressHospitalizationPopup: defaultSettings.SuppressHospitalizationPopup,
- SuppressMessages: defaultSettings.SuppressMessages,
- SuppressTravelConfirmation: defaultSettings.SuppressTravelConfirmation,
- init() {
- Object.assign(exports.Settings, defaultSettings);
- },
- load(saveString) {
- Object.assign(exports.Settings, JSON.parse(saveString));
- },
-};
-
-
-/***/ }),
-/* 20 */
-/*!**********************************!*\
- !*** ./src/Company/Companies.ts ***!
- \**********************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-// Constructs all CompanyPosition objects using the metadata in data/companypositions.ts
-const CompaniesMetadata_1 = __webpack_require__(/*! ./data/CompaniesMetadata */ 256);
-const Company_1 = __webpack_require__(/*! ./Company */ 76);
-const JSONReviver_1 = __webpack_require__(/*! ../../utils/JSONReviver */ 15);
-exports.Companies = {};
-function addCompany(params) {
- if (exports.Companies[params.name] != null) {
- console.warn(`Duplicate Company Position being defined: ${params.name}`);
- }
- exports.Companies[params.name] = new Company_1.Company(params);
-}
-// Used to initialize new Company objects for the Companies map
-// Called when creating new game or after a prestige/reset
-function initCompanies() {
- // Save Old Company data for 'favor'
- const oldCompanies = exports.Companies;
- // Re-construct all Companies
- exports.Companies = {};
- CompaniesMetadata_1.companiesMetadata.forEach((e) => {
- addCompany(e);
- });
- // Reset data
- for (const companyName in exports.Companies) {
- const company = exports.Companies[companyName];
- const oldCompany = oldCompanies[companyName];
- if (!(oldCompany instanceof Company_1.Company)) {
- // New game, so no OldCompanies data
- company.favor = 0;
- }
- else {
- company.favor = oldCompanies[companyName].favor;
- if (isNaN(company.favor)) {
- company.favor = 0;
- }
- }
- }
-}
-exports.initCompanies = initCompanies;
-// Used to load Companies map from a save
-function loadCompanies(saveString) {
- exports.Companies = JSON.parse(saveString, JSONReviver_1.Reviver);
-}
-exports.loadCompanies = loadCompanies;
-// Utility function to check if a string is valid company name
-function companyExists(name) {
- return exports.Companies.hasOwnProperty(name);
-}
-exports.companyExists = companyExists;
-
-
-/***/ }),
-/* 21 */
-/*!************************************************!*\
- !*** ./utils/uiHelpers/clearEventListeners.ts ***!
- \************************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-const getElementById_1 = __webpack_require__(/*! ./getElementById */ 61);
-/**
- * Given an element by its ID, removes all event listeners from that element by cloning and
- * replacing. Then returns the new cloned element.
- * @param elemId The HTML ID to retrieve the element by.
- */
-function clearEventListeners(elemId) {
- try {
- let elem;
- if (typeof elemId === "string") {
- elem = getElementById_1.getElementById(elemId);
- }
- else {
- elem = elemId;
- }
- const newElem = elem.cloneNode(true);
- if (elem.parentNode !== null) {
- elem.parentNode.replaceChild(newElem, elem);
- }
- return newElem;
- }
- catch (e) {
- // tslint:disable-next-line:no-console
- console.error(e);
- return null;
- }
-}
-exports.clearEventListeners = clearEventListeners;
-
-
-/***/ }),
-/* 22 */
-/*!***************************!*\
- !*** ./utils/YesNoBox.ts ***!
- \***************************/
-/*! no static exports found */
-/*! exports used: yesNoBoxClose, yesNoBoxCreate, yesNoBoxGetNoButton, yesNoBoxGetYesButton, yesNoBoxOpen, yesNoTxtInpBoxClose, yesNoTxtInpBoxCreate, yesNoTxtInpBoxGetInput, yesNoTxtInpBoxGetNoButton, yesNoTxtInpBoxGetYesButton */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-/**
- * Generic Yes-No Pop-up box
- * Used to create pop-up boxes that require a yes/no response from player
- *
- * There are two types of pop ups:
- * 1. Just a Yes/No response from player
- * 2. Popup also includes a text input field in addition to the Yes/No response
- */
-const clearEventListeners_1 = __webpack_require__(/*! ./uiHelpers/clearEventListeners */ 21);
-exports.yesNoBoxOpen = false;
-const yesNoBoxContainer = document.getElementById("yes-no-box-container");
-const yesNoBoxTextElement = document.getElementById("yes-no-box-text");
-function yesNoBoxHotkeyHandler(e) {
- if (e.keyCode === 27) {
- yesNoBoxClose();
- }
- else if (e.keyCode === 13) {
- const yesBtn = document.getElementById("yes-no-box-yes");
- if (yesBtn) {
- yesBtn.click();
- }
- else {
- console.error(`Could not find YesNoBox Yes button DOM element`);
- }
- }
-}
-exports.yesNoBoxHotkeyHandler = yesNoBoxHotkeyHandler;
-function yesNoBoxClose() {
- if (yesNoBoxContainer) {
- yesNoBoxContainer.style.display = "none";
- }
- else {
- console.error("Container not found for YesNoBox");
- }
- exports.yesNoBoxOpen = false;
- // Remove hotkey handler
- document.removeEventListener("keydown", yesNoBoxHotkeyHandler);
- return false; //So that 'return yesNoBoxClose()' is return false in event listeners
-}
-exports.yesNoBoxClose = yesNoBoxClose;
-function yesNoBoxGetYesButton() {
- return clearEventListeners_1.clearEventListeners("yes-no-box-yes");
-}
-exports.yesNoBoxGetYesButton = yesNoBoxGetYesButton;
-function yesNoBoxGetNoButton() {
- return clearEventListeners_1.clearEventListeners("yes-no-box-no");
-}
-exports.yesNoBoxGetNoButton = yesNoBoxGetNoButton;
-function yesNoBoxCreate(txt) {
- if (exports.yesNoBoxOpen) {
- return false;
- } //Already open
- exports.yesNoBoxOpen = true;
- if (yesNoBoxTextElement) {
- yesNoBoxTextElement.innerHTML = txt;
- }
- else {
- console.error(`Text element not found for YesNoBox`);
- }
- if (yesNoBoxContainer) {
- yesNoBoxContainer.style.display = "flex";
- }
- else {
- console.error("Container not found for YesNoBox");
- }
- // Add event listener for Esc and Enter hotkeys
- document.addEventListener("keydown", yesNoBoxHotkeyHandler);
- return true;
-}
-exports.yesNoBoxCreate = yesNoBoxCreate;
-/**
- * Yes-No pop up box with text input field
- */
-const yesNoTextInputBoxContainer = document.getElementById("yes-no-text-input-box-container");
-const yesNoTextInputBoxInput = document.getElementById("yes-no-text-input-box-input");
-const yesNoTextInputBoxTextElement = document.getElementById("yes-no-text-input-box-text");
-function yesNoTxtInpBoxHotkeyHandler(e) {
- if (e.keyCode === 27) {
- yesNoTxtInpBoxClose();
- }
- else if (e.keyCode === 13) {
- const yesBtn = document.getElementById("yes-no-text-input-box-yes");
- if (yesBtn) {
- yesBtn.click();
- }
- else {
- console.error(`Could not find YesNoTxtInputBox Yes button DOM element`);
- }
- }
-}
-exports.yesNoTxtInpBoxHotkeyHandler = yesNoTxtInpBoxHotkeyHandler;
-function yesNoTxtInpBoxClose() {
- if (yesNoTextInputBoxContainer != null) {
- yesNoTextInputBoxContainer.style.display = "none";
- }
- else {
- console.error("Container not found for YesNoTextInputBox");
- return false;
- }
- exports.yesNoBoxOpen = false;
- yesNoTextInputBoxInput.value = "";
- // Remove hotkey handler
- document.removeEventListener("keydown", yesNoTxtInpBoxHotkeyHandler);
- return false;
-}
-exports.yesNoTxtInpBoxClose = yesNoTxtInpBoxClose;
-function yesNoTxtInpBoxGetYesButton() {
- return clearEventListeners_1.clearEventListeners("yes-no-text-input-box-yes");
-}
-exports.yesNoTxtInpBoxGetYesButton = yesNoTxtInpBoxGetYesButton;
-function yesNoTxtInpBoxGetNoButton() {
- return clearEventListeners_1.clearEventListeners("yes-no-text-input-box-no");
-}
-exports.yesNoTxtInpBoxGetNoButton = yesNoTxtInpBoxGetNoButton;
-function yesNoTxtInpBoxGetInput() {
- if (yesNoTextInputBoxInput == null) {
- console.error("Could not find YesNoTextInputBox input element");
- return "";
- }
- let val = yesNoTextInputBoxInput.value;
- val = val.replace(/\s+/g, '');
- return val;
-}
-exports.yesNoTxtInpBoxGetInput = yesNoTxtInpBoxGetInput;
-function yesNoTxtInpBoxCreate(txt) {
- exports.yesNoBoxOpen = true;
- if (yesNoTextInputBoxTextElement) {
- yesNoTextInputBoxTextElement.innerHTML = txt;
- }
- if (yesNoTextInputBoxContainer) {
- yesNoTextInputBoxContainer.style.display = "flex";
- }
- else {
- console.error("Container not found for YesNoTextInputBox");
- }
- // Add event listener for Esc and Enter hotkeys
- document.addEventListener("keydown", yesNoTxtInpBoxHotkeyHandler);
- yesNoTextInputBoxInput.focus();
-}
-exports.yesNoTxtInpBoxCreate = yesNoTxtInpBoxCreate;
-
-
-/***/ }),
-/* 23 */
-/*!**********************************************!*\
- !*** ./utils/uiHelpers/removeElementById.ts ***!
- \**********************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-const getElementById_1 = __webpack_require__(/*! ./getElementById */ 61);
-const removeElement_1 = __webpack_require__(/*! ./removeElement */ 66);
-/**
- * Given its id, this function removes an element AND its children
- * @param id The HTML identifier to search for and remove.
- */
-function removeElementById(id) {
- try {
- const elem = getElementById_1.getElementById(id);
- removeElement_1.removeElement(elem);
- }
- catch (e) {
- // Probably should log this as we're trying to remove elements that don't exist.
- }
-}
-exports.removeElementById = removeElementById;
-
-
-/***/ }),
-/* 24 */
-/*!****************************************!*\
- !*** ./src/StockMarket/StockMarket.js ***!
- \****************************************/
-/*! exports provided: StockMarket, StockSymbols, SymbolToStockMap, initStockSymbols, initStockMarket, initSymbolToStockMap, stockMarketCycle, buyStock, sellStock, shortStock, sellShort, processStockPrices, displayStockMarketContent, updateStockTicker, updateStockPlayerPosition, loadStockMarket, setStockMarketContentCreated, placeOrder, cancelOrder, Order, OrderTypes, PositionTypes */
-/*! exports used: OrderTypes, PositionTypes, StockMarket, StockSymbols, SymbolToStockMap, cancelOrder, displayStockMarketContent, initStockMarket, initStockSymbols, initSymbolToStockMap, loadStockMarket, placeOrder, processStockPrices, sellShort, setStockMarketContentCreated, shortStock, stockMarketCycle, updateStockPlayerPosition */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return StockMarket; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return StockSymbols; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return SymbolToStockMap; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return initStockSymbols; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return initStockMarket; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "j", function() { return initSymbolToStockMap; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "q", function() { return stockMarketCycle; });
-/* unused harmony export buyStock */
-/* unused harmony export sellStock */
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "p", function() { return shortStock; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "n", function() { return sellShort; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "m", function() { return processStockPrices; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return displayStockMarketContent; });
-/* unused harmony export updateStockTicker */
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "r", function() { return updateStockPlayerPosition; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "k", function() { return loadStockMarket; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "o", function() { return setStockMarketContentCreated; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "l", function() { return placeOrder; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return cancelOrder; });
-/* unused harmony export Order */
-/* 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 _Stock__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Stock */ 32);
-/* harmony import */ var _Stock__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_Stock__WEBPACK_IMPORTED_MODULE_0__);
-/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Constants */ 1);
-/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_Constants__WEBPACK_IMPORTED_MODULE_1__);
-/* harmony import */ var _Locations__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Locations */ 5);
-/* harmony import */ var _Locations__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_Locations__WEBPACK_IMPORTED_MODULE_2__);
-/* harmony import */ var _NetscriptFunctions__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../NetscriptFunctions */ 47);
-/* harmony import */ var _NetscriptWorker__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../NetscriptWorker */ 30);
-/* harmony import */ var _Player__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../Player */ 0);
-/* harmony import */ var _ui_navigationTracking__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! .././ui/navigationTracking */ 13);
-/* harmony import */ var _ui_navigationTracking__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_6__);
-/* harmony import */ var _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! .././ui/numeralFormat */ 4);
-/* harmony import */ var _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__);
-/* harmony import */ var _utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../../utils/DialogBox */ 9);
-/* harmony import */ var _utils_uiHelpers_clearEventListeners__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../../utils/uiHelpers/clearEventListeners */ 21);
-/* harmony import */ var _utils_uiHelpers_clearEventListeners__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_utils_uiHelpers_clearEventListeners__WEBPACK_IMPORTED_MODULE_9__);
-/* harmony import */ var _utils_JSONReviver__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../../utils/JSONReviver */ 15);
-/* harmony import */ var _utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../../utils/helpers/exceptionAlert */ 42);
-/* harmony import */ var _utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_11__);
-/* harmony import */ var _utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../../utils/helpers/getRandomInt */ 17);
-/* harmony import */ var _utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_12__);
-/* harmony import */ var _utils_helpers_keyCodes__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../../utils/helpers/keyCodes */ 29);
-/* harmony import */ var _utils_helpers_keyCodes__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_keyCodes__WEBPACK_IMPORTED_MODULE_13__);
-/* harmony import */ var _utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../../utils/uiHelpers/createElement */ 2);
-/* harmony import */ var _utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_14__);
-/* harmony import */ var _utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../../utils/uiHelpers/removeChildrenFromElement */ 27);
-/* harmony import */ var _utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_15__);
-/* harmony import */ var _utils_uiHelpers_removeElementById__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../utils/uiHelpers/removeElementById */ 23);
-/* harmony import */ var _utils_uiHelpers_removeElementById__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(_utils_uiHelpers_removeElementById__WEBPACK_IMPORTED_MODULE_16__);
-/* harmony import */ var _utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../utils/YesNoBox */ 22);
-/* harmony import */ var _utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-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 _NetscriptWorker__WEBPACK_IMPORTED_MODULE_4__[/* WorkerScript */ "b"]);
- var order = new Order(stock, shares, price, type, position);
- if (isNaN(shares) || isNaN(price)) {
- if (tixApi) {
- workerScript.scriptRef.log("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument");
- } else {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["dialogBoxCreate"])("ERROR: Invalid numeric value provided for either 'shares' or 'price' argument");
- }
- 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__WEBPACK_IMPORTED_MODULE_0__["Stock"])) {continue;}
- orders[stock.symbol] = [];
- }
- }
- StockMarket["Orders"] = orders;
- }
- 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 _NetscriptWorker__WEBPACK_IMPORTED_MODULE_4__[/* WorkerScript */ "b"]);
- 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__WEBPACK_IMPORTED_MODULE_0__["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 + " @ " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(params.price, '$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(order.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);
- 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, shares, price, type, position) {
- this.stock = stock;
- this.shares = shares;
- this.price = price;
- this.type = type;
- this.pos = position;
-}
-
-Order.prototype.toJSON = function() {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_10__["Generic_toJSON"])("Order", this);
-}
-
-Order.fromJSON = function(value) {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_10__["Generic_fromJSON"])(Order, value.data);
-}
-
-_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_10__["Reviver"].constructors.Order = Order;
-
-let StockMarket = {} //Full name to stock object
-let StockSymbols = {} //Full name to symbol
-let SymbolToStockMap = {}; //Symbol to Stock object
-
-function loadStockMarket(saveString) {
- if (saveString === "") {
- StockMarket = {};
- } else {
- StockMarket = JSON.parse(saveString, _utils_JSONReviver__WEBPACK_IMPORTED_MODULE_10__["Reviver"]);
- }
-}
-
-function initStockSymbols() {
- //Stocks for companies at which you can work
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumECorp] = "ECP";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12MegaCorp] = "MGCP";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12BladeIndustries] = "BLD";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumClarkeIncorporated] = "CLRK";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniTekIncorporated] = "OMTK";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FourSigma] = "FSIG";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingKuaiGongInternational] = "KGI";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumFulcrumTechnologies] = "FLCM";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaStormTechnologies] = "STM";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoDefComm] = "DCOMM";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenHeliosLabs] = "HLS";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoVitaLife] = "VITA";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12IcarusMicrosystems] = "ICRS";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12UniversalEnergy] = "UNV";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumAeroCorp] = "AERO";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniaCybersystems] = "OMN";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingSolarisSpaceSystems] = "SLRS";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoGlobalPharmaceuticals] = "GPH";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaNovaMedical] = "NVMD";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumWatchdogSecurity] = "WDS";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenLexoCorp] = "LXO";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumRhoConstruction] = "RHOC";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12AlphaEnterprises] = "APHE";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenSysCoreSecurities] = "SYSC";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenCompuTek] = "CTK";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumNetLinkTechnologies] = "NTLK";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaOmegaSoftware] = "OMGA";
- StockSymbols[_Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FoodNStuff] = "FNS";
-
- //Stocks for other companies
- StockSymbols["Sigma Cosmetics"] = "SGC";
- StockSymbols["Joes Guns"] = "JGN";
- StockSymbols["Catalyst Ventures"] = "CTYS";
- StockSymbols["Microdyne Technologies"] = "MDYN";
- StockSymbols["Titan Laboratories"] = "TITN";
-}
-
-function initStockMarket() {
- for (var stk in StockMarket) {
- if (StockMarket.hasOwnProperty(stk)) {
- delete StockMarket[stk];
- }
- }
-
- const randInt = _utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_12__["getRandomInt"];
-
- var ecorp = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumECorp;
- var ecorpStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](ecorp, StockSymbols[ecorp], randInt(40, 50) / 100, true, 19, randInt(17e3, 28e3), 2.4e12);
- StockMarket[ecorp] = ecorpStk;
-
- var megacorp = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12MegaCorp;
- var megacorpStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](megacorp, StockSymbols[megacorp], randInt(40,50)/100, true, 19, randInt(24e3, 34e3), 2.4e12);
- StockMarket[megacorp] = megacorpStk;
-
- var blade = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12BladeIndustries;
- var bladeStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](blade, StockSymbols[blade], randInt(70, 80)/100, true, 13, randInt(12e3, 25e3), 1.6e12);
- StockMarket[blade] = bladeStk;
-
- var clarke = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumClarkeIncorporated;
- var clarkeStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](clarke, StockSymbols[clarke], randInt(65, 75)/100, true, 12, randInt(10e3, 25e3), 1.5e12);
- StockMarket[clarke] = clarkeStk;
-
- var omnitek = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniTekIncorporated;
- var omnitekStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](omnitek, StockSymbols[omnitek], randInt(60, 70)/100, true, 12, randInt(32e3, 43e3), 1.8e12);
- StockMarket[omnitek] = omnitekStk;
-
- var foursigma = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FourSigma;
- var foursigmaStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](foursigma, StockSymbols[foursigma], randInt(100, 110)/100, true, 17, randInt(50e3, 80e3), 2e12);
- StockMarket[foursigma] = foursigmaStk;
-
- var kuaigong = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingKuaiGongInternational;
- var kuaigongStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](kuaigong, StockSymbols[kuaigong], randInt(75, 85)/100, true, 10, randInt(16e3, 28e3), 1.9e12);
- StockMarket[kuaigong] = kuaigongStk;
-
- var fulcrum = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumFulcrumTechnologies;
- var fulcrumStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](fulcrum, StockSymbols[fulcrum], randInt(120, 130)/100, true, 16, randInt(29e3, 36e3), 2e12);
- StockMarket[fulcrum] = fulcrumStk;
-
- var storm = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaStormTechnologies;
- var stormStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](storm, StockSymbols[storm], randInt(80, 90)/100, true, 7, randInt(20e3, 25e3), 1.2e12);
- StockMarket[storm] = stormStk;
-
- var defcomm = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoDefComm;
- var defcommStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](defcomm, StockSymbols[defcomm], randInt(60, 70)/100, true, 10, randInt(6e3, 19e3), 900e9);
- StockMarket[defcomm] = defcommStk;
-
- var helios = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenHeliosLabs;
- var heliosStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](helios, StockSymbols[helios], randInt(55, 65)/100, true, 9, randInt(10e3, 18e3), 825e9);
- StockMarket[helios] = heliosStk;
-
- var vitalife = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoVitaLife;
- var vitalifeStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](vitalife, StockSymbols[vitalife], randInt(70, 80)/100, true, 7, randInt(8e3, 14e3), 1e12);
- StockMarket[vitalife] = vitalifeStk;
-
- var icarus = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12IcarusMicrosystems;
- var icarusStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](icarus, StockSymbols[icarus], randInt(60, 70)/100, true, 7.5, randInt(12e3, 24e3), 800e9);
- StockMarket[icarus] = icarusStk;
-
- var universalenergy = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12UniversalEnergy;
- var universalenergyStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](universalenergy, StockSymbols[universalenergy], randInt(50, 60)/100, true, 10, randInt(16e3, 29e3), 900e9);
- StockMarket[universalenergy] = universalenergyStk;
-
- var aerocorp = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumAeroCorp;
- var aerocorpStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](aerocorp, StockSymbols[aerocorp], randInt(55, 65)/100, true, 6, randInt(8e3, 17e3), 640e9);
- StockMarket[aerocorp] = aerocorpStk;
-
- var omnia = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniaCybersystems;
- var omniaStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](omnia, StockSymbols[omnia], randInt(65, 75)/100, true, 4.5, randInt(6e3, 15e3), 600e9);
- StockMarket[omnia] = omniaStk;
-
- var solaris = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingSolarisSpaceSystems;
- var solarisStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](solaris, StockSymbols[solaris], randInt(70, 80)/100, true, 8.5, randInt(14e3, 28e3), 705e9);
- StockMarket[solaris] = solarisStk;
-
- var globalpharm = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoGlobalPharmaceuticals;
- var globalpharmStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](globalpharm, StockSymbols[globalpharm], randInt(55, 65)/100, true, 10.5, randInt(12e3, 30e3), 695e9);
- StockMarket[globalpharm] = globalpharmStk;
-
- var nova = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaNovaMedical;
- var novaStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](nova, StockSymbols[nova], randInt(70, 80)/100, true, 5, randInt(15e3, 27e3), 600e9);
- StockMarket[nova] = novaStk;
-
- var watchdog = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumWatchdogSecurity;
- var watchdogStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](watchdog, StockSymbols[watchdog], randInt(240, 260)/100, true, 1.5, randInt(4e3, 8.5e3), 450e9);
- StockMarket[watchdog] = watchdogStk;
-
- var lexocorp = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenLexoCorp;
- var lexocorpStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](lexocorp, StockSymbols[lexocorp], randInt(115, 135)/100, true, 6, randInt(4.5e3, 8e3), 300e9);
- StockMarket[lexocorp] = lexocorpStk;
-
- var rho = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumRhoConstruction;
- var rhoStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](rho, StockSymbols[rho], randInt(50, 70)/100, true, 1, randInt(2e3, 7e3), 180e9);
- StockMarket[rho] = rhoStk;
-
- var alpha = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12AlphaEnterprises;
- var alphaStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](alpha, StockSymbols[alpha], randInt(175, 205)/100, true, 10, randInt(4e3, 8.5e3), 240e9);
- StockMarket[alpha] = alphaStk;
-
- var syscore = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenSysCoreSecurities;
- var syscoreStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](syscore, StockSymbols[syscore], randInt(150, 170)/100, true, 3, randInt(3e3, 8e3), 200e9);
- StockMarket[syscore] = syscoreStk;
-
- var computek = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenCompuTek;
- var computekStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](computek, StockSymbols[computek], randInt(80, 100)/100, true, 4, randInt(1e3, 6e3), 185e9);
- StockMarket[computek] = computekStk;
-
- var netlink = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumNetLinkTechnologies;
- var netlinkStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](netlink, StockSymbols[netlink], randInt(400, 430)/100, true, 1, randInt(1e3, 5e3), 58e9);
- StockMarket[netlink] = netlinkStk;
-
- var omega = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaOmegaSoftware;
- var omegaStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](omega, StockSymbols[omega], randInt(90, 110)/100, true, 0.5, randInt(1e3, 8e3), 60e9);
- StockMarket[omega] = omegaStk;
-
- var fns = _Locations__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FoodNStuff;
- var fnsStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](fns, StockSymbols[fns], randInt(70, 80)/100, false, 1, randInt(500, 4.5e3), 45e9);
- StockMarket[fns] = fnsStk;
-
- var sigmacosm = "Sigma Cosmetics";
- var sigmacosmStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](sigmacosm, StockSymbols[sigmacosm], randInt(260, 300)/100, true, 0, randInt(1.5e3, 3.5e3), 30e9);
- StockMarket[sigmacosm] = sigmacosmStk;
-
- var joesguns = "Joes Guns";
- var joesgunsStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](joesguns, StockSymbols[joesguns], randInt(360, 400)/100, true, 1, randInt(250, 1.5e3), 42e9);
- StockMarket[joesguns] = joesgunsStk;
-
- var catalyst = "Catalyst Ventures";
- var catalystStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](catalyst, StockSymbols[catalyst], randInt(120, 175)/100, true, 13.5, randInt(250, 1.5e3), 100e9);
- StockMarket[catalyst] = catalystStk;
-
- var microdyne = "Microdyne Technologies";
- var microdyneStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](microdyne, StockSymbols[microdyne], randInt(70, 80)/100, true, 8, randInt(15e3, 30e3), 360e9);
- StockMarket[microdyne] = microdyneStk;
-
- var titanlabs = "Titan Laboratories";
- var titanlabsStk = new _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"](titanlabs, StockSymbols[titanlabs], randInt(50, 70)/100, true, 11, randInt(12e3, 24e3), 420e9);
- StockMarket[titanlabs] = titanlabsStk;
-
- var orders = {};
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"])) {continue;}
- orders[stock.symbol] = [];
- }
- }
- StockMarket["Orders"] = orders;
-
- StockMarket.storedCycles = 0;
- StockMarket.lastUpdate = 0;
-}
-
-function initSymbolToStockMap() {
- for (var name in StockSymbols) {
- if (StockSymbols.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (stock == null) {
- console.error(`Could not find Stock for ${name}`);
- continue;
- }
- var symbol = StockSymbols[name];
- SymbolToStockMap[symbol] = stock;
- }
- }
-}
-
-function stockMarketCycle() {
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"])) {continue;}
- var thresh = 0.6;
- if (stock.b) {thresh = 0.4;}
- if (Math.random() < thresh) {
- stock.b = !stock.b;
- }
- }
- }
-}
-
-//Returns true if successful, false otherwise
-function buyStock(stock, shares) {
- // Validate arguments
- shares = Math.round(shares);
- if (shares == 0 || shares < 0) { return false; }
- if (stock == null || isNaN(shares)) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["dialogBoxCreate"])("Failed to buy stock. This may be a bug, contact developer");
- return false;
- }
-
- // Does player have enough money?
- var totalPrice = stock.price * shares;
- if (_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].money.lt(totalPrice + _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].StockMarketCommission)) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["dialogBoxCreate"])("You do not have enough money to purchase this. You need " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(totalPrice + _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].StockMarketCommission, '($0.000a)') + ".");
- return false;
- }
-
- // Would this purchase exceed the maximum number of shares?
- if (shares + stock.playerShares + stock.playerShortShares > stock.maxShares) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["dialogBoxCreate"])(`You cannot purchase this many shares. ${stock.symbol} has a maximum of ` +
- `${_ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].formatBigNumber(stock.maxShares)} shares.`);
- return false;
- }
-
- var origTotal = stock.playerShares * stock.playerAvgPx;
- _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].loseMoney(totalPrice + _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].StockMarketCommission);
- var newTotal = origTotal + totalPrice;
- stock.playerShares = Math.round(stock.playerShares + shares);
- stock.playerAvgPx = newTotal / stock.playerShares;
- updateStockPlayerPosition(stock);
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["dialogBoxCreate"])("Bought " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(shares, '0,0') + " shares of " + stock.symbol + " at " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(stock.price, '($0.000a)') + " per share. Paid " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(_Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].StockMarketCommission, '($0.000a)') + " in commission fees.");
- return true;
-}
-
-//Returns true if successful and false otherwise
-function sellStock(stock, shares) {
- if (shares == 0) {return false;}
- if (stock == null || shares < 0 || isNaN(shares)) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["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 - _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].StockMarketCommission;
- _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].gainMoney(gains);
- stock.playerShares = Math.round(stock.playerShares - shares);
- if (stock.playerShares == 0) {
- stock.playerAvgPx = 0;
- }
- updateStockPlayerPosition(stock);
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["dialogBoxCreate"])("Sold " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(shares, '0,0') + " shares of " + stock.symbol + " at " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(stock.price, '($0.000a)') + " per share. After commissions, you gained " +
- "a total of " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(gains, '($0.000a)') + ".");
- return true;
-}
-
-//Returns true if successful and false otherwise
-function shortStock(stock, shares, workerScript=null) {
- var tixApi = (workerScript instanceof _NetscriptWorker__WEBPACK_IMPORTED_MODULE_4__[/* WorkerScript */ "b"]);
-
- // Validate arguments
- shares = Math.round(shares);
- if (shares === 0 || shares < 0) { return false; }
- if (stock == null || isNaN(shares)) {
- if (tixApi) {
- workerScript.scriptRef.log("ERROR: shortStock() failed because of invalid arguments.");
- } else {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["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;
- }
-
- // Does the player have enough money?
- var totalPrice = stock.price * shares;
- if (_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].money.lt(totalPrice + _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].StockMarketCommission)) {
- if (tixApi) {
- workerScript.scriptRef.log("ERROR: shortStock() failed because you do not have enough " +
- "money to purchase this short position. You need " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(totalPrice + _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].StockMarketCommission, '($0.000a)') + ".");
- } else {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["dialogBoxCreate"])("You do not have enough money to purchase this short position. You need " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(totalPrice + _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].StockMarketCommission, '($0.000a)') + ".");
- }
-
- return false;
- }
-
- // Would this purchase exceed the maximum number of shares?
- if (shares + stock.playerShares + stock.playerShortShares > stock.maxShares) {
- if (tixApi) {
- workerScript.scriptRef.log("ERROR: shortStock() failed because purchasing this many short shares would exceed " +
- `${stock.symbol}'s maximum number of shares.`);
- } else {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["dialogBoxCreate"])(`You cannot purchase this many shares. ${stock.symbol} has a maximum of ` +
- `${stock.maxShares} shares.`);
- }
-
- return false;
- }
-
- var origTotal = stock.playerShortShares * stock.playerAvgShortPx;
- _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].loseMoney(totalPrice + _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].StockMarketCommission);
- var newTotal = origTotal + totalPrice;
- stock.playerShortShares = Math.round(stock.playerShortShares + shares);
- stock.playerAvgShortPx = newTotal / stock.playerShortShares;
- updateStockPlayerPosition(stock);
- if (tixApi) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.shortStock == null) {
- workerScript.scriptRef.log("Bought a short position of " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(shares, '0,0') + " shares of " + stock.symbol + " at " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(stock.price, '($0.000a)') + " per share. Paid " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(_Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].StockMarketCommission, '($0.000a)') + " in commission fees.");
- }
- } else {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["dialogBoxCreate"])("Bought a short position of " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(shares, '0,0') + " shares of " + stock.symbol + " at " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(stock.price, '($0.000a)') + " per share. Paid " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(_Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].StockMarketCommission, '($0.000a)') + " in commission fees.");
- }
- return true;
-}
-
-//Returns true if successful and false otherwise
-function sellShort(stock, shares, workerScript=null) {
- var tixApi = (workerScript instanceof _NetscriptWorker__WEBPACK_IMPORTED_MODULE_4__[/* WorkerScript */ "b"]);
- if (stock == null || isNaN(shares) || shares < 0) {
- if (tixApi) {
- workerScript.scriptRef.log("ERROR: sellShort() failed because of invalid arguments.");
- } else {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["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;
- }
- shares = Math.round(shares);
- if (shares > stock.playerShortShares) {shares = stock.playerShortShares;}
- if (shares === 0) {return false;}
-
- var origCost = shares * stock.playerAvgShortPx;
- var profit = ((stock.playerAvgShortPx - stock.price) * shares) - _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].StockMarketCommission;
- if (isNaN(profit)) {profit = 0;}
- _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].gainMoney(origCost + profit);
- if (tixApi) {
- workerScript.scriptRef.onlineMoneyMade += profit;
- _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].scriptProdSinceLastAug += profit;
- }
-
- stock.playerShortShares = Math.round(stock.playerShortShares - shares);
- if (stock.playerShortShares === 0) {
- stock.playerAvgShortPx = 0;
- }
- updateStockPlayerPosition(stock);
- if (tixApi) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellShort == null) {
- workerScript.scriptRef.log("Sold your short position of " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(shares, '0,0') + " shares of " + stock.symbol + " at " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(stock.price, '($0.000a)') + " per share. After commissions, you gained " +
- "a total of " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(origCost + profit, '($0.000a)') + ".");
- }
- } else {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["dialogBoxCreate"])("Sold your short position of " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(shares, '0,0') + " shares of " + stock.symbol + " at " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(stock.price, '($0.000a)') + " per share. After commissions, you gained " +
- "a total of " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(origCost + profit, '($0.000a)') + ".");
- }
-
- return true;
-}
-
-function processStockPrices(numCycles=1) {
- if (StockMarket.storedCycles == null || isNaN(StockMarket.storedCycles)) { StockMarket.storedCycles = 0; }
- StockMarket.storedCycles += numCycles;
-
- // Stock Prices updated every 6 seconds on average. But if there are stored
- // cycles they update 50% faster, so every 4 seconds
- const msPerStockUpdate = 6e3;
- const cyclesPerStockUpdate = msPerStockUpdate / _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MilliPerCycle;
- if (StockMarket.storedCycles < cyclesPerStockUpdate) { return; }
-
- const timeNow = new Date().getTime();
- if (timeNow - StockMarket.lastUpdate < 4e3) { return; }
-
- StockMarket.lastUpdate = timeNow;
- StockMarket.storedCycles -= cyclesPerStockUpdate;
-
- var v = Math.random();
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"])) { continue; }
- var av = (v * stock.mv) / 100;
- if (isNaN(av)) {av = .02;}
-
- var chc = 50;
- if (stock.b) {
- chc = (chc + stock.otlkMag) / 100;
- if (isNaN(chc)) {chc = 0.5;}
- } else {
- chc = (chc - stock.otlkMag) / 100;
- if (isNaN(chc)) {chc = 0.5;}
- }
- if (stock.price >= stock.cap) {
- chc = 0.1; // "Soft Limit" on stock price. It could still go up but its unlikely
- stock.b = false;
- }
-
- 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 (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_6__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_6__["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 (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_6__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_6__["Page"].StockMarket)) {
- updateStockTicker(stock, false);
- }
- }
-
- var otlkMagChange = stock.otlkMag * av;
- if (stock.otlkMag <= 0.1) {
- otlkMagChange = 1;
- }
- if (c < 0.5) {
- stock.otlkMag += otlkMagChange;
- } else {
- stock.otlkMag -= otlkMagChange;
- }
- if (stock.otlkMag < 0) {
- 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__WEBPACK_IMPORTED_MODULE_0__["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;
- }
- }
- }
-}
-
-function setStockMarketContentCreated(b) {
- stockMarketContentCreated = b;
-}
-
-var stockMarketContentCreated = false;
-var stockMarketPortfolioMode = false;
-var COMM = _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].StockMarketCommission;
-function displayStockMarketContent() {
- if (_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hasWseAccount == null) {_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hasWseAccount = false;}
- if (_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hasTixApiAccess == null) {_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hasTixApiAccess = false;}
- if (_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].has4SData == null) {_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].has4SData = false;}
- if (_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].has4SDataTixApi == null) {_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].has4SDataTixApi = false;}
-
- function stylePurchaseButton(btn, cost, flag, initMsg, purchasedMsg) {
- btn.innerText = initMsg;
- btn.classList.remove("a-link-button");
- btn.classList.remove("a-link-button-bought");
- btn.classList.remove("a-link-button-inactive");
- if (!flag && _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].money.gte(cost)) {
- btn.classList.add("a-link-button");
- } else if (flag) {
- btn.innerText = purchasedMsg;
- btn.classList.add("a-link-button-bought");
- } else {
- btn.classList.add("a-link-button-inactive");
- }
- }
-
- //Purchase WSE Account button
- var wseAccountButton = Object(_utils_uiHelpers_clearEventListeners__WEBPACK_IMPORTED_MODULE_9__["clearEventListeners"])("stock-market-buy-account");
- stylePurchaseButton(wseAccountButton, _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].WSEAccountCost, _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hasWseAccount,
- "Buy WSE Account - " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(_Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].WSEAccountCost, '($0.000a)'),
- "WSE Account - Purchased");
- wseAccountButton.addEventListener("click", function() {
- _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hasWseAccount = true;
- initStockMarket();
- initSymbolToStockMap();
- _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].loseMoney(_Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].WSEAccountCost);
- displayStockMarketContent();
- return false;
- });
-
- //Purchase TIX API Access account
- var tixApiAccessButton = Object(_utils_uiHelpers_clearEventListeners__WEBPACK_IMPORTED_MODULE_9__["clearEventListeners"])("stock-market-buy-tix-api");
- stylePurchaseButton(tixApiAccessButton, _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].TIXAPICost, _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hasTixApiAccess,
- "Buy Trade Information eXchange (TIX) API Access - " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(_Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].TIXAPICost, '($0.000a)'),
- "TIX API Access - Purchased");
- tixApiAccessButton.addEventListener("click", function() {
- _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hasTixApiAccess = true;
- _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].loseMoney(_Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].TIXAPICost);
- displayStockMarketContent();
- return false;
- });
-
- //Purchase Four Sigma Market Data Feed
- var marketDataButton = Object(_utils_uiHelpers_clearEventListeners__WEBPACK_IMPORTED_MODULE_9__["clearEventListeners"])("stock-market-buy-4s-data");
- stylePurchaseButton(marketDataButton, _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MarketData4SCost, _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].has4SData,
- "Buy 4S Market Data Access - " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(_Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MarketData4SCost, '($0.000a)'),
- "4S Market Data - Purchased");
- marketDataButton.addEventListener("click", function() {
- if (_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].money.lt(_Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MarketData4SCost)) { return false; }
- _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].has4SData = true;
- _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].loseMoney(_Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MarketData4SCost);
- displayStockMarketContent();
- return false;
- });
- marketDataButton.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_14__["createElement"])("span", {
- class:"tooltiptext",
- innerText:"Lets you view additional pricing and volatility information about stocks"
- }));
- marketDataButton.style.marginRight = "2px"; //Adjusts following help tip to be slightly closer
-
- //4S Market Data Help Tip
- var marketDataHelpTip = Object(_utils_uiHelpers_clearEventListeners__WEBPACK_IMPORTED_MODULE_9__["clearEventListeners"])("stock-market-4s-data-help-tip");
- marketDataHelpTip.style.marginTop = "10px";
- marketDataHelpTip.addEventListener("click", ()=>{
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["dialogBoxCreate"])("Access to the 4S Market Data feed will display two additional pieces " +
- "of information about each stock: Price Forecast & Volatility
" +
- "Price Forecast indicates the probability the stock has of increasing or " +
- "decreasing. A '+' forecast means the stock has a higher chance of increasing " +
- "than decreasing, and a '-' means the opposite. The number of '+/-' symbols " +
- "is used to illustrate the magnitude of these probabilities. For example, " +
- "'+++' means that the stock has a significantly higher chance of increasing " +
- "than decreasing, while '+' means that the stock only has a slightly higher chance " +
- "of increasing than decreasing.
" +
- "Volatility represents the maximum percentage by which a stock's price " +
- "can change every tick (a tick occurs every few seconds while the game " +
- "is running).
" +
- "A stock's price forecast can change over time. This is also affected by volatility. " +
- "The more volatile a stock is, the more its price forecast will change.");
- return false;
- });
-
- //Purchase Four Sigma Market Data TIX API (Requires TIX API Access)
- var marketDataTixButton = Object(_utils_uiHelpers_clearEventListeners__WEBPACK_IMPORTED_MODULE_9__["clearEventListeners"])("stock-market-buy-4s-tix-api");
- stylePurchaseButton(marketDataTixButton, _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MarketDataTixApi4SCost, _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].has4SDataTixApi,
- "Buy 4S Market Data TIX API Access - " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(_Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MarketDataTixApi4SCost, '($0.000a)'),
- "4S Market Data TIX API - Purchased");
- if (_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hasTixApiAccess) {
- marketDataTixButton.addEventListener("click", function() {
- if (_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].money.lt(_Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MarketDataTixApi4SCost)) { return false; }
- _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].has4SDataTixApi = true;
- _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].loseMoney(_Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MarketDataTixApi4SCost);
- displayStockMarketContent();
- return false;
- });
- marketDataTixButton.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_14__["createElement"])("span", {
- class:"tooltiptext",
- innerText:"Lets you access 4S Market Data through Netscript"
- }));
- } else {
- marketDataTixButton.classList.remove("a-link-button");
- marketDataTixButton.classList.remove("a-link-button-bought");
- marketDataTixButton.classList.remove("a-link-button-inactive");
- marketDataTixButton.classList.add("a-link-button-inactive");
- marketDataTixButton.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_14__["createElement"])("span", {
- class:"tooltiptext",
- innerText:"Requires TIX API Access"
- }));
- }
-
-
- var stockList = document.getElementById("stock-market-list");
- if (stockList == null) {return;}
-
- //UI Elements that should only appear if you have WSE account access
- var commissionText = document.getElementById("stock-market-commission");
- var modeBtn = document.getElementById("stock-market-mode");
- var expandBtn = document.getElementById("stock-market-expand-tickers");
- var collapseBtn = document.getElementById("stock-market-collapse-tickers");
- var watchlistFilter = document.getElementById("stock-market-watchlist-filter");
- var watchlistUpdateBtn = document.getElementById("stock-market-watchlist-filter-update");
-
- //If Player doesn't have account, clear stocks UI and return
- if (!_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hasWseAccount) {
- stockMarketContentCreated = false;
- while (stockList.firstChild) {
- stockList.removeChild(stockList.firstChild);
- }
- commissionText.style.visibility = "hidden";
- modeBtn.style.visibility = "hidden";
- expandBtn.style.visibility = "hidden";
- collapseBtn.style.visibility = "hidden";
- watchlistFilter.style.visibility = "hidden";
- watchlistUpdateBtn.style.visibility = "hidden";
- return;
- } else {
- commissionText.style.visibility = "visible";
- modeBtn.style.visibility = "visible";
- expandBtn.style.visibility = "visible";
- collapseBtn.style.visibility = "visible";
- watchlistFilter.style.visibility = "visible";
- watchlistUpdateBtn.style.visibility = "visible";
- }
-
- //Create stock market content if you have an account
- if (!stockMarketContentCreated && _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hasWseAccount) {
- console.log("Creating Stock Market UI");
- commissionText.innerHTML =
- "Commission Fees: Every transaction you make has a " +
- _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(_Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].StockMarketCommission, '($0.000a)') + " 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 investopediaButton = Object(_utils_uiHelpers_clearEventListeners__WEBPACK_IMPORTED_MODULE_9__["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(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["dialogBoxCreate"])(txt);
- return false;
- });
-
- //Switch to Portfolio Mode Button
- if (modeBtn) {
- stockMarketPortfolioMode = false;
- modeBtn.innerHTML = "Switch to 'Portfolio' Mode" +
- "Displays only the stocks for which you have shares or orders";
- modeBtn.addEventListener("click", switchToPortfolioMode);
- }
-
- //Expand/Collapse tickers buttons
- var stockList = document.getElementById("stock-market-list");
- if (expandBtn) {
- expandBtn.addEventListener("click", ()=>{
- var tickerHdrs = stockList.getElementsByClassName("accordion-header");
- for (var i = 0; i < tickerHdrs.length; ++i) {
- if (!tickerHdrs[i].classList.contains("active")) {
- tickerHdrs[i].click();
- }
- }
- });
- }
- if (collapseBtn) {
- collapseBtn.addEventListener("click",()=>{
- var tickerHdrs = stockList.getElementsByClassName("accordion-header");
- for (var i = 0; i < tickerHdrs.length; ++i) {
- if (tickerHdrs[i].classList.contains("active")) {
- tickerHdrs[i].click();
- }
- }
- });
- }
-
- //Watchlish filter
- if (watchlistFilter && watchlistUpdateBtn) {
- //Initialize value in watchlist
- if (StockMarket.watchlistFilter) {
- watchlistFilter.value = StockMarket.watchlistFilter; //Remove whitespace
- }
- watchlistUpdateBtn.addEventListener("click", ()=> {
- let filterValue = watchlistFilter.value.toString();
- StockMarket.watchlistFilter = filterValue.replace(/\s/g, '');
- if (stockMarketPortfolioMode) {
- switchToPortfolioMode();
- } else {
- switchToDisplayAllMode();
- }
- });
- watchlistFilter.addEventListener("keyup", (e)=>{
- e.preventDefault();
- if (e.keyCode === _utils_helpers_keyCodes__WEBPACK_IMPORTED_MODULE_13__["KEY"].ENTER) {watchlistUpdateBtn.click();}
- })
- } else {
- console.warn("Stock Market Watchlist DOM elements could not be found");
- }
-
- createAllStockTickers();
- stockMarketContentCreated = true;
- }
-
- if (_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hasWseAccount) {
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (stock instanceof _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"]) {
- updateStockTicker(stock, null);
- updateStockOrderList(stock);
- }
- }
- }
- }
-}
-
-//Displays only stocks you have position/order in
-function switchToPortfolioMode() {
- stockMarketPortfolioMode = true;
- var modeBtn = Object(_utils_uiHelpers_clearEventListeners__WEBPACK_IMPORTED_MODULE_9__["clearEventListeners"])("stock-market-mode");
- if (modeBtn) {
- modeBtn.innerHTML = "Switch to 'All stocks' Mode" +
- "Displays all stocks on the WSE";
- modeBtn.addEventListener("click", switchToDisplayAllMode);
- }
- createAllStockTickers();
-}
-
-//Displays all stocks
-function switchToDisplayAllMode() {
- stockMarketPortfolioMode = false;
- var modeBtn = Object(_utils_uiHelpers_clearEventListeners__WEBPACK_IMPORTED_MODULE_9__["clearEventListeners"])("stock-market-mode");
- if (modeBtn) {
- modeBtn.innerHTML = "Switch to 'Portfolio' Mode" +
- "Displays only the stocks for which you have shares or orders";
- modeBtn.addEventListener("click", switchToPortfolioMode);
- }
- createAllStockTickers();
-}
-
-function createAllStockTickers() {
- var stockList = document.getElementById("stock-market-list");
- if (stockList == null) {
- Object(_utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_11__["exceptionAlert"])("Error creating Stock Tickers UI. DOM element with ID 'stock-market-list' could not be found");
- }
- Object(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_15__["removeChildrenFromElement"])(stockList);
-
- 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__WEBPACK_IMPORTED_MODULE_0__["Stock"])) {continue;}
- orders[stock.symbol] = [];
- }
- }
- StockMarket["Orders"] = orders;
- orderBook = StockMarket["Orders"];
- }
-
- let watchlist = null;
- if (StockMarket.watchlistFilter != null && StockMarket.watchlistFilter !== "") {
- let filter = StockMarket.watchlistFilter.replace(/\s/g, '');
- watchlist = filter.split(",");
- }
-
- for (var name in StockMarket) {
- if (StockMarket.hasOwnProperty(name)) {
- var stock = StockMarket[name];
- if (!(stock instanceof _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"])) {continue;} //orders property is an array
- if (watchlist && !watchlist.includes(stock.symbol)) {continue;} //Watchlist filtering
-
- let stockOrders = orderBook[stock.symbol];
- if (stockMarketPortfolioMode) {
- if (stock.playerShares === 0 && stock.playerShortShares === 0 &&
- stockOrders.length === 0) {continue;}
- }
- createStockTicker(stock);
- }
- }
- setStockTickerClickHandlers(); //Clicking headers opens/closes panels
-}
-
-function createStockTicker(stock) {
- if (!(stock instanceof _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"])) {
- console.log("Invalid stock in createStockSticker()");
- return;
- }
- 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 + " - " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(stock.price, '($0.000a)');
-
- //Div for entire panel
- var stockDiv = document.createElement("div");
- stockDiv.classList.add("accordion-panel");
- stockDiv.setAttribute("id", tickerId + "-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"),
- buyMaxButton = document.createElement("span"),
- sellAllButton = document.createElement("span"),
- positionTxt = document.createElement("p"),
- 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 " +
- " || (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__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].bitNodeN === 8 || (_NetscriptFunctions__WEBPACK_IMPORTED_MODULE_3__[/* hasWallStreetSF */ "f"] && _NetscriptFunctions__WEBPACK_IMPORTED_MODULE_3__[/* wallStreetSFLvl */ "h"] >= 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__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].bitNodeN === 8 || (_NetscriptFunctions__WEBPACK_IMPORTED_MODULE_3__[/* hasWallStreetSF */ "f"] && _NetscriptFunctions__WEBPACK_IMPORTED_MODULE_3__[/* wallStreetSFLvl */ "h"] >= 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);
- }
-
- buyButton.classList.add("stock-market-input");
- buyButton.classList.add("a-link-button");
- 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":
- pos === PositionTypes.Long ? buyStock(stock, shares) : shortStock(stock, shares, null);
- break;
- case "Limit Order":
- case "Stop Order":
- var yesBtn = Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxGetYesButton"])(),
- noBtn = Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxGetNoButton"])();
- yesBtn.innerText = "Place Buy " + ordType;
- noBtn.innerText = "Cancel Order";
- yesBtn.addEventListener("click", ()=>{
- var price = Number(Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxGetInput"])()), type;
- if (ordType === "Limit Order") {
- type = OrderTypes.LimitBuy;
- } else {
- type = OrderTypes.StopBuy;
- }
- placeOrder(stock, shares, price, type, pos);
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxClose"])();
- });
- noBtn.addEventListener("click", ()=>{
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxClose"])();
- });
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["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.classList.add("a-link-button");
- 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":
- pos === PositionTypes.Long ? sellStock(stock, shares) : sellShort(stock, shares, null);
- break;
- case "Limit Order":
- case "Stop Order":
- var yesBtn = Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxGetYesButton"])(),
- noBtn = Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxGetNoButton"])();
- yesBtn.innerText = "Place Sell " + ordType;
- noBtn.innerText = "Cancel Order";
- yesBtn.addEventListener("click", ()=>{
- var price = Number(Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxGetInput"])()), type;
- if (ordType === "Limit Order") {
- type = OrderTypes.LimitSell;
- } else {
- type = OrderTypes.StopSell;
- }
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxClose"])();
- placeOrder(stock, shares, price, type, pos);
- });
- noBtn.addEventListener("click", ()=>{
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxClose"])();
- });
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxCreate"])("Enter the price for your " + ordType);
- break;
- default:
- console.log("ERROR: Invalid order type");
- break;
- }
- return false;
- });
-
- buyMaxButton.classList.add("stock-market-input");
- buyMaxButton.classList.add("a-link-button");
- buyMaxButton.innerHTML = "Buy MAX";
- buyMaxButton.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 money = _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].money.toNumber();
- switch (ordType) {
- case "Market Order":
- var shares = Math.floor((money - COMM) / stock.price);
- shares = Math.min(shares, Math.round(stock.maxShares - stock.playerShares - stock.playerShortShares));
- pos === PositionTypes.Long ? buyStock(stock, shares) : shortStock(stock, shares, null);
- break;
- case "Limit Order":
- case "Stop Order":
- var yesBtn = Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxGetYesButton"])(),
- noBtn = Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxGetNoButton"])();
- yesBtn.innerText = "Place Buy " + ordType;
- noBtn.innerText = "Cancel Order";
- yesBtn.addEventListener("click", ()=>{
- var price = Number(Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxGetInput"])()), type;
- if (ordType === "Limit Order") {
- type = OrderTypes.LimitBuy;
- } else {
- type = OrderTypes.StopBuy;
- }
- var shares = Math.floor((money-COMM) / price);
- shares = Math.min(shares, Math.round(stock.maxShares - stock.playerShares - stock.playerShortShares));
- placeOrder(stock, shares, price, type, pos);
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxClose"])();
- });
- noBtn.addEventListener("click", ()=>{
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxClose"])();
- });
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_17__["yesNoTxtInpBoxCreate"])("Enter the price for your " + ordType);
- break;
- default:
- console.log("ERROR: Invalid order type");
- break;
- }
- return false;
- });
-
- sellAllButton.classList.add("stock-market-input");
- sellAllButton.classList.add("a-link-button");
- sellAllButton.innerHTML = "Sell ALL";
- sellAllButton.addEventListener("click", ()=>{
- var pos = longShortSelect.options[longShortSelect.selectedIndex].text;
- pos === "Long" ? pos = PositionTypes.Long : pos = PositionTypes.Short;
- var ordType = orderTypeSelect.options[orderTypeSelect.selectedIndex].text;
- switch (ordType) {
- case "Market Order":
- if (pos === PositionTypes.Long) {
- var shares = stock.playerShares;
- sellStock(stock, shares);
- } else {
- var shares = stock.playerShortShares;
- sellShort(stock, shares, null);
- }
- break;
- case "Limit Order":
- case "Stop Order":
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_8__["dialogBoxCreate"])("ERROR: 'Sell All' only works for Market Orders")
- break;
- default:
- console.log("ERROR: Invalid order type");
- break;
- }
- return false;
- });
-
- 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");
-
- stockDiv.appendChild(qtyInput);
- stockDiv.appendChild(longShortSelect);
- stockDiv.appendChild(orderTypeSelect);
- stockDiv.appendChild(buyButton);
- stockDiv.appendChild(sellButton);
- stockDiv.appendChild(buyMaxButton);
- stockDiv.appendChild(sellAllButton);
- stockDiv.appendChild(positionTxt);
- stockDiv.appendChild(orderList);
-
- li.appendChild(hdr);
- li.appendChild(stockDiv);
- document.getElementById("stock-market-list").appendChild(li);
-
- updateStockTicker(stock, true);
- updateStockPlayerPosition(stock);
- updateStockOrderList(stock);
-}
-
-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 (!_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_6__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_6__["Page"].StockMarket)) {return;}
- if (!(stock instanceof _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"])) {
- console.log("Invalid stock in updateStockTicker():");
- console.log(stock);
- return;
- }
- var tickerId = "stock-market-ticker-" + stock.symbol;
-
- if (stock.playerShares > 0 || stock.playerShortShares > 0) {
- updateStockPlayerPosition(stock);
- }
-
- var hdr = document.getElementById(tickerId + "-hdr");
-
- if (hdr == null) {
- if (!stockMarketPortfolioMode) {
- let watchlist = StockMarket.watchlistFilter;
- if (watchlist !== "" && watchlist.includes(stock.symbol)) {
- console.log("ERROR: Couldn't find ticker element for stock: " + stock.symbol);
- }
- }
- return;
- }
- let hdrText = stock.name + " (" + stock.symbol + ") - " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(stock.price, '($0.000a)');
- if (_Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].has4SData) {
- hdrText += " - Volatility: " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(stock.mv, '0,0.00') + "%" +
- " - Price Forecast: ";
- if (stock.b) {
- hdrText += "+".repeat(Math.floor(stock.otlkMag/10) + 1);
- } else {
- hdrText += "-".repeat(Math.floor(stock.otlkMag/10) + 1);
- }
- }
- hdr.innerText = hdrText;
- if (increase != null) {
- increase ? hdr.style.color = "#66ff33" : hdr.style.color = "red";
- }
-}
-
-function updateStockPlayerPosition(stock) {
- if (!_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_6__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_6__["Page"].StockMarket)) {return;}
- if (!(stock instanceof _Stock__WEBPACK_IMPORTED_MODULE_0__["Stock"])) {
- console.log("Invalid stock in updateStockPlayerPosition():");
- console.log(stock);
- return;
- }
- var tickerId = "stock-market-ticker-" + stock.symbol;
-
- if (stockMarketPortfolioMode) {
- if (stock.playerShares === 0 && stock.playerShortShares === 0 &&
- StockMarket["Orders"] && StockMarket["Orders"][stock.symbol] &&
- StockMarket["Orders"][stock.symbol].length === 0) {
- Object(_utils_uiHelpers_removeElementById__WEBPACK_IMPORTED_MODULE_16__["removeElementById"])(tickerId + "-hdr");
- Object(_utils_uiHelpers_removeElementById__WEBPACK_IMPORTED_MODULE_16__["removeElementById"])(tickerId + "-panel");
- return;
- } else {
- //If the ticker hasn't been created, create it (handles updating)
- //If it has been created, continue normally
- if (document.getElementById(tickerId + "-hdr") == null) {
- createStockTicker(stock);
- setStockTickerClickHandlers();
- return;
- }
- }
- }
-
- 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;
- }
-
- //Calculate returns
- const totalCost = stock.playerShares * stock.playerAvgPx;
- let gains = (stock.price - stock.playerAvgPx) * stock.playerShares;
- let percentageGains = gains / totalCost;
- if (isNaN(percentageGains)) { percentageGains = 0; }
-
- const shortTotalCost = stock.playerShortShares * stock.playerAvgShortPx;
- let shortGains = (stock.playerAvgShortPx - stock.price) * stock.playerShortShares;
- let shortPercentageGains = shortGains/ shortTotalCost;
- if (isNaN(shortPercentageGains)) { shortPercentageGains = 0; }
-
- stock.posTxtEl.innerHTML =
- `Max Shares: ${_ui_numeralFormat__WEBPACK_IMPORTED_MODULE_7__["numeralWrapper"].format(stock.maxShares, "0.000a")} ` +
- "
Long Position: " +
- "Shares in the long position will increase " +
- "in value if the price of the corresponding stock increases
" +
- "Starting cost: " + numeralFormat_1.numeralWrapper.format(exports.IndustryStartingCosts.Utilities, "$0.000a") + " " +
- "Recommended starting Industry: NO",
- Agriculture: "Cultive crops and breed livestock to produce food.
" +
- "Starting cost: " + numeralFormat_1.numeralWrapper.format(exports.IndustryStartingCosts.Agriculture, "$0.000a") + " " +
- "Recommended starting Industry: YES",
- Fishing: "Produce food through the breeding and processing of fish and fish products
" +
- "Starting cost: " + numeralFormat_1.numeralWrapper.format(exports.IndustryStartingCosts.Fishing, "$0.000a") + " " +
- "Recommended starting Industry: NO",
- Mining: "Extract and process metals from the earth.
" +
- "Starting cost: " + numeralFormat_1.numeralWrapper.format(exports.IndustryStartingCosts.Mining, "$0.000a") + " " +
- "Recommended starting Industry: NO",
- Food: "Create your own restaurants all around the world.
" +
- "Starting cost: " + numeralFormat_1.numeralWrapper.format(exports.IndustryStartingCosts.RealEstate, "$0.000a") + " " +
- "Recommended starting Industry: NO",
-};
-// Map of available Research for each Industry. This data is held in a
-// ResearchTree object
-exports.IndustryResearchTrees = {
- Energy: BaseResearchTree_1.getBaseResearchTreeCopy(),
- Utilities: BaseResearchTree_1.getBaseResearchTreeCopy(),
- Agriculture: BaseResearchTree_1.getBaseResearchTreeCopy(),
- Fishing: BaseResearchTree_1.getBaseResearchTreeCopy(),
- Mining: BaseResearchTree_1.getBaseResearchTreeCopy(),
- Food: BaseResearchTree_1.getBaseResearchTreeCopy(),
- Tobacco: BaseResearchTree_1.getBaseResearchTreeCopy(),
- Chemical: BaseResearchTree_1.getBaseResearchTreeCopy(),
- Pharmaceutical: BaseResearchTree_1.getBaseResearchTreeCopy(),
- Computer: BaseResearchTree_1.getBaseResearchTreeCopy(),
- Robotics: BaseResearchTree_1.getBaseResearchTreeCopy(),
- Software: BaseResearchTree_1.getBaseResearchTreeCopy(),
- Healthcare: BaseResearchTree_1.getBaseResearchTreeCopy(),
- RealEstate: BaseResearchTree_1.getBaseResearchTreeCopy(),
-};
-function resetIndustryResearchTrees() {
- exports.IndustryResearchTrees.Energy = BaseResearchTree_1.getBaseResearchTreeCopy();
- exports.IndustryResearchTrees.Utilities = BaseResearchTree_1.getBaseResearchTreeCopy();
- exports.IndustryResearchTrees.Agriculture = BaseResearchTree_1.getBaseResearchTreeCopy();
- exports.IndustryResearchTrees.Fishing = BaseResearchTree_1.getBaseResearchTreeCopy();
- exports.IndustryResearchTrees.Mining = BaseResearchTree_1.getBaseResearchTreeCopy();
- exports.IndustryResearchTrees.Food = BaseResearchTree_1.getBaseResearchTreeCopy();
- exports.IndustryResearchTrees.Tobacco = BaseResearchTree_1.getBaseResearchTreeCopy();
- exports.IndustryResearchTrees.Chemical = BaseResearchTree_1.getBaseResearchTreeCopy();
- exports.IndustryResearchTrees.Pharmaceutical = BaseResearchTree_1.getBaseResearchTreeCopy();
- exports.IndustryResearchTrees.Computer = BaseResearchTree_1.getBaseResearchTreeCopy();
- exports.IndustryResearchTrees.Robotics = BaseResearchTree_1.getBaseResearchTreeCopy();
- exports.IndustryResearchTrees.Software = BaseResearchTree_1.getBaseResearchTreeCopy();
- exports.IndustryResearchTrees.Healthcare = BaseResearchTree_1.getBaseResearchTreeCopy();
- exports.IndustryResearchTrees.RealEstate = BaseResearchTree_1.getBaseResearchTreeCopy();
-}
-exports.resetIndustryResearchTrees = resetIndustryResearchTrees;
-
-
-/***/ }),
-/* 26 */
-/*!**********************************!*\
- !*** ./src/ui/MainMenu/Links.ts ***!
- \**********************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-// Get references to the Main Menu link DOM elements
-// Does NOT include collapsible headers for the links
-const clearEventListeners_1 = __webpack_require__(/*! ../../../utils/uiHelpers/clearEventListeners */ 21);
-exports.MainMenuLinks = {
- Terminal: null,
- ScriptEditor: null,
- ActiveScripts: null,
- CreateProgram: null,
- Stats: null,
- Factions: null,
- Augmentations: null,
- HacknetNodes: null,
- Sleeves: null,
- City: null,
- Travel: null,
- Job: null,
- StockMarket: null,
- Bladeburner: null,
- Corporation: null,
- Gang: null,
- Tutorial: null,
- Options: null,
- DevMenu: null,
-};
-function initializeMainMenuLinks() {
- try {
- function safeGetLink(id) {
- const elem = clearEventListeners_1.clearEventListeners(id);
- if (elem == null) {
- throw new Error(`clearEventListeners() failed for element with id: ${id}`);
- }
- return elem;
- }
- exports.MainMenuLinks.Terminal = safeGetLink("terminal-menu-link");
- exports.MainMenuLinks.ScriptEditor = safeGetLink("create-script-menu-link");
- exports.MainMenuLinks.ActiveScripts = safeGetLink("active-scripts-menu-link");
- exports.MainMenuLinks.CreateProgram = safeGetLink("create-program-menu-link");
- exports.MainMenuLinks.Stats = safeGetLink("stats-menu-link");
- exports.MainMenuLinks.Factions = safeGetLink("factions-menu-link");
- exports.MainMenuLinks.Augmentations = safeGetLink("augmentations-menu-link");
- exports.MainMenuLinks.HacknetNodes = safeGetLink("hacknet-nodes-menu-link");
- exports.MainMenuLinks.Sleeves = safeGetLink("sleeves-menu-link");
- exports.MainMenuLinks.City = safeGetLink("city-menu-link");
- exports.MainMenuLinks.Travel = safeGetLink("travel-menu-link");
- exports.MainMenuLinks.Job = safeGetLink("job-menu-link");
- exports.MainMenuLinks.StockMarket = safeGetLink("stock-market-menu-link");
- exports.MainMenuLinks.Bladeburner = safeGetLink("bladeburner-menu-link");
- exports.MainMenuLinks.Corporation = safeGetLink("corporation-menu-link");
- exports.MainMenuLinks.Gang = safeGetLink("gang-menu-link");
- exports.MainMenuLinks.Tutorial = safeGetLink("tutorial-menu-link");
- exports.MainMenuLinks.Options = document.getElementById("options-menu-link"); // This click listener is already set, so don't clear it
- exports.MainMenuLinks.DevMenu = safeGetLink("dev-menu-link");
- return true;
- }
- catch (e) {
- console.error(`Failed to initialize Main Menu Links: ${e}`);
- return false;
- }
-}
-exports.initializeMainMenuLinks = initializeMainMenuLinks;
-
-
-/***/ }),
-/* 27 */
-/*!******************************************************!*\
- !*** ./utils/uiHelpers/removeChildrenFromElement.ts ***!
- \******************************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-const isString_1 = __webpack_require__(/*! ../helpers/isString */ 44);
-const getElementById_1 = __webpack_require__(/*! ./getElementById */ 61);
-/**
- * Clears out all children from the provided element.
- * If a string is passed in, it will treat it as an ID and search for the element to delete all children from.
- * @param el The element or ID of an element to remove all children from.
- */
-function removeChildrenFromElement(el) {
- if (el === null) {
- return;
- }
- try {
- const elem = (isString_1.isString(el) ? getElementById_1.getElementById(el) : el);
- if (elem instanceof Element) {
- while (elem.firstChild !== null) {
- elem.removeChild(elem.firstChild);
- }
- }
- }
- catch (e) {
- // tslint:disable-next-line:no-console
- console.debug(e);
- return;
- }
-}
-exports.removeChildrenFromElement = removeChildrenFromElement;
-
-
-/***/ }),
-/* 28 */
-/*!**********************************!*\
- !*** ./src/Programs/Programs.ts ***!
- \**********************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-const Program_1 = __webpack_require__(/*! ./Program */ 237);
-const programsMetadata_1 = __webpack_require__(/*! ./data/programsMetadata */ 236);
-exports.Programs = {};
-for (const params of programsMetadata_1.programsMetadata) {
- exports.Programs[params.key] = new Program_1.Program(params.name, params.create);
-}
-
-
-/***/ }),
-/* 29 */
-/*!***********************************!*\
- !*** ./utils/helpers/keyCodes.ts ***!
- \***********************************/
-/*! no static exports found */
-/*! exports used: KEY */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-/**
- * Keyboard key codes
- */
-exports.KEY = {
- A: 65,
- B: 66,
- C: 67,
- CTRL: 17,
- D: 68,
- DOWNARROW: 40,
- E: 69,
- ENTER: 13,
- F: 70,
- H: 72,
- J: 74,
- K: 75,
- L: 76,
- M: 77,
- N: 78,
- O: 79,
- P: 80,
- R: 82,
- S: 83,
- TAB: 9,
- U: 85,
- UPARROW: 38,
- W: 87,
- "1": 49,
- "2": 50,
-};
-
-
-/***/ }),
-/* 30 */
-/*!********************************!*\
- !*** ./src/NetscriptWorker.js ***!
- \********************************/
-/*! exports provided: WorkerScript, workerScripts, NetscriptPorts, runScriptsLoop, killWorkerScript, addWorkerScript, updateOnlineScriptTimes, prestigeWorkerScripts */
-/*! exports used: NetscriptPorts, WorkerScript, addWorkerScript, killWorkerScript, prestigeWorkerScripts, runScriptsLoop, updateOnlineScriptTimes, workerScripts */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return WorkerScript; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return workerScripts; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return NetscriptPorts; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return runScriptsLoop; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return killWorkerScript; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return addWorkerScript; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return updateOnlineScriptTimes; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return prestigeWorkerScripts; });
-/* harmony import */ var _ActiveScriptsUI__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ActiveScriptsUI */ 77);
-/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants */ 1);
-/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_Constants__WEBPACK_IMPORTED_MODULE_1__);
-/* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engine */ 11);
-/* harmony import */ var _JSInterpreter__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./JSInterpreter */ 156);
-/* harmony import */ var _NetscriptEnvironment__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptEnvironment */ 135);
-/* harmony import */ var _NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptEvaluator */ 7);
-/* harmony import */ var _NetscriptFunctions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptFunctions */ 47);
-/* harmony import */ var _NetscriptJSEvaluator__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./NetscriptJSEvaluator */ 136);
-/* harmony import */ var _NetscriptPort__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./NetscriptPort */ 81);
-/* harmony import */ var _Server__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Server */ 12);
-/* harmony import */ var _Settings_Settings__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Settings/Settings */ 19);
-/* harmony import */ var _Settings_Settings__WEBPACK_IMPORTED_MODULE_10___default = /*#__PURE__*/__webpack_require__.n(_Settings_Settings__WEBPACK_IMPORTED_MODULE_10__);
-/* harmony import */ var escodegen__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! escodegen */ 127);
-/* harmony import */ var escodegen__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(escodegen__WEBPACK_IMPORTED_MODULE_11__);
-/* harmony import */ var _utils_acorn__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/acorn */ 54);
-/* harmony import */ var _utils_acorn__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn__WEBPACK_IMPORTED_MODULE_12__);
-/* harmony import */ var _utils_DialogBox__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../utils/DialogBox */ 9);
-/* harmony import */ var _utils_helpers_compareArrays__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../utils/helpers/compareArrays */ 107);
-/* harmony import */ var _utils_helpers_compareArrays__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_compareArrays__WEBPACK_IMPORTED_MODULE_14__);
-/* harmony import */ var _utils_helpers_arrayToString__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/helpers/arrayToString */ 63);
-/* harmony import */ var _utils_helpers_arrayToString__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_arrayToString__WEBPACK_IMPORTED_MODULE_15__);
-/* harmony import */ var _utils_helpers_roundToTwo__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../utils/helpers/roundToTwo */ 95);
-/* harmony import */ var _utils_helpers_roundToTwo__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_roundToTwo__WEBPACK_IMPORTED_MODULE_16__);
-/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 3);
-/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_17__);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-const walk = __webpack_require__(/*! acorn/dist/walk */ 175);
-
-function WorkerScript(runningScriptObj) {
- this.name = runningScriptObj.filename;
- this.running = false;
- this.serverIp = null;
- this.code = runningScriptObj.scriptRef.code;
- this.env = new _NetscriptEnvironment__WEBPACK_IMPORTED_MODULE_4__[/* Environment */ "a"](this);
- this.env.set("args", runningScriptObj.args.slice());
- this.output = "";
- this.ramUsage = 0;
- this.scriptRef = runningScriptObj;
- this.errorMessage = "";
- this.args = runningScriptObj.args.slice();
- this.delay = null;
- this.fnWorker = null; //Workerscript for a function call
- this.checkingRam = false;
- this.loadedFns = {}; //Stores names of fns that are "loaded" by this script, thus using RAM. Used for static RAM evaluation
- this.disableLogs = {}; //Stores names of fns that should have logs disabled
-
- //Properties used for dynamic RAM evaluation
- this.dynamicRamUsage = _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].ScriptBaseRamCost;
- this.dynamicLoadedFns = {};
-}
-
-//Returns the server on which the workerScript is running
-WorkerScript.prototype.getServer = function() {
- return _Server__WEBPACK_IMPORTED_MODULE_9__[/* AllServers */ "b"][this.serverIp];
-}
-
-//Returns the Script object for the underlying script
-WorkerScript.prototype.getScript = function() {
- let server = this.getServer();
- for (let i = 0; i < server.scripts.length; ++i) {
- if (server.scripts[i].filename === this.name) {
- return server.scripts[i];
- }
- }
- console.log("ERROR: Failed to find underlying Script object in WorkerScript.getScript(). This probably means somethings wrong");
- return null;
-}
-
-//Returns the Script object for the specified script
-WorkerScript.prototype.getScriptOnServer = function(fn, server) {
- if (server == null) {
- server = this.getServer();
- }
- for (let i = 0; i < server.scripts.length; ++i) {
- if (server.scripts[i].filename === fn) {
- return server.scripts[i];
- }
- }
- return null;
-}
-
-WorkerScript.prototype.shouldLog = function(fn) {
- return (this.disableLogs.ALL == null && this.disableLogs[fn] == null);
-}
-
-WorkerScript.prototype.log = function(txt) {
- this.scriptRef.log(txt);
-}
-
-//Array containing all scripts that are running across all servers, to easily run them all
-let workerScripts = [];
-
-var NetscriptPorts = [];
-for (var i = 0; i < _Constants__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].NumNetscriptPorts; ++i) {
- NetscriptPorts.push(new _NetscriptPort__WEBPACK_IMPORTED_MODULE_8__[/* NetscriptPort */ "a"]());
-}
-
-function prestigeWorkerScripts() {
- for (var i = 0; i < workerScripts.length; ++i) {
- Object(_ActiveScriptsUI__WEBPACK_IMPORTED_MODULE_0__[/* deleteActiveScriptsItem */ "b"])(workerScripts[i]);
- workerScripts[i].env.stopFlag = true;
- }
- Object(_ActiveScriptsUI__WEBPACK_IMPORTED_MODULE_0__[/* updateActiveScriptsItems */ "c"])(5000); //Force UI to update
- workerScripts.length = 0;
-}
-
-// JS script promises need a little massaging to have the same guarantees as netscript
-// promises. This does said massaging and kicks the script off. It returns a promise
-// that resolves or rejects when the corresponding worker script is done.
-function startNetscript2Script(workerScript) {
- workerScript.running = true;
-
- // The name of the currently running netscript function, to prevent concurrent
- // calls to hack, grow, etc.
- let runningFn = null;
-
- // We need to go through the environment and wrap each function in such a way that it
- // can be called at most once at a time. This will prevent situations where multiple
- // hack promises are outstanding, for example.
- function wrap(propName, f) {
- // This function unfortunately cannot be an async function, because we don't
- // know if the original one was, and there's no way to tell.
- return function (...args) {
- // Wrap every netscript function with a check for the stop flag.
- // This prevents cases where we never stop because we are only calling
- // netscript functions that don't check this.
- // This is not a problem for legacy Netscript because it also checks the
- // stop flag in the evaluator.
- if (workerScript.env.stopFlag) {throw workerScript;}
-
- if (propName === "sleep") return f(...args); // OK for multiple simultaneous calls to sleep.
-
- const msg = "Concurrent calls to Netscript functions not allowed! " +
- "Did you forget to await hack(), grow(), or some other " +
- "promise-returning function? (Currently running: %s tried to run: %s)"
- if (runningFn) {
- workerScript.errorMessage = Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_5__[/* makeRuntimeRejectMsg */ "d"])(workerScript, sprintf(msg, runningFn, propName), null)
- throw workerScript;
- }
- runningFn = propName;
-
- // If the function throws an error, clear the runningFn flag first, and then re-throw it
- // This allows people to properly catch errors thrown by NS functions without getting
- // the concurrent call error above
- let result;
- try {
- result = f(...args);
- } catch(e) {
- runningFn = null;
- throw(e);
- }
-
- if (result && result.finally !== undefined) {
- return result.finally(function () {
- runningFn = null;
- });
- } else {
- runningFn = null;
- return result;
- }
- }
- };
-
- for (let prop in workerScript.env.vars) {
- if (typeof workerScript.env.vars[prop] !== "function") continue;
- workerScript.env.vars[prop] = wrap(prop, workerScript.env.vars[prop]);
- }
-
- // Note: the environment that we pass to the JS script only needs to contain the functions visible
- // to that script, which env.vars does at this point.
- return Object(_NetscriptJSEvaluator__WEBPACK_IMPORTED_MODULE_7__[/* executeJSScript */ "a"])(workerScript.getServer().scripts,
- workerScript).then(function (mainReturnValue) {
- if (mainReturnValue === undefined) return workerScript;
- return [mainReturnValue, workerScript];
- }).catch(e => {
- if (e instanceof Error) {
- workerScript.errorMessage = Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_5__[/* makeRuntimeRejectMsg */ "d"])(
- workerScript, e.message + (e.stack && ("\nstack:\n" + e.stack.toString()) || ""));
- throw workerScript;
- } else if (Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_5__[/* isScriptErrorMessage */ "b"])(e)) {
- workerScript.errorMessage = e;
- throw workerScript;
- }
- throw e; // Don't know what to do with it, let's rethrow.
- });
-}
-
-function startNetscript1Script(workerScript) {
- var code = workerScript.code;
- workerScript.running = true;
-
- //Process imports
- var codeWithImports, codeLineOffset;
- try {
- let importProcessingRes = processNetscript1Imports(code, workerScript);
- codeWithImports = importProcessingRes.code;
- codeLineOffset = importProcessingRes.lineOffset;
- } catch(e) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_13__["dialogBoxCreate"])("Error processing Imports in " + workerScript.name + ": " + e);
- workerScript.env.stopFlag = true;
- workerScript.running = false;
- return;
- }
-
- var interpreterInitialization = function(int, scope) {
- //Add the Netscript environment
- var ns = Object(_NetscriptFunctions__WEBPACK_IMPORTED_MODULE_6__[/* NetscriptFunctions */ "a"])(workerScript);
- for (let name in ns) {
- let entry = ns[name];
- if (typeof entry === "function") {
- //Async functions need to be wrapped. See JS-Interpreter documentation
- if (name === "hack" || name === "grow" || name === "weaken" || name === "sleep" ||
- name === "prompt" || name === "run" || name === "exec") {
- let tempWrapper = function() {
- let fnArgs = [];
- for (let i = 0; i < arguments.length-1; ++i) {
- fnArgs.push(arguments[i]);
- }
- let cb = arguments[arguments.length-1];
- let fnPromise = entry.apply(null, fnArgs);
- fnPromise.then(function(res) {
- cb(res);
- });
- }
- int.setProperty(scope, name, int.createAsyncFunction(tempWrapper));
- } else if (name === "sprintf" || name === "vsprintf" || name === "scp" ||
- name == "write" || name === "read" || name === "tryWrite") {
- let tempWrapper = function() {
- let fnArgs = [];
-
- //All of the Object/array elements are in JSInterpreter format, so
- //we have to convert them back to native format to pass them to these fns
- for (let i = 0; i < arguments.length; ++i) {
- if (typeof arguments[i] === 'object' || arguments[i].constructor === Array) {
- fnArgs.push(int.pseudoToNative(arguments[i]));
- } else {
- fnArgs.push(arguments[i]);
- }
- }
-
- return entry.apply(null, fnArgs);
- }
- int.setProperty(scope, name, int.createNativeFunction(tempWrapper));
- } else {
- let tempWrapper = function() {
- let res = entry.apply(null, arguments);
-
- if (res == null) {
- return res;
- } else if (res.constructor === Array || (res === Object(res))) {
- //Objects and Arrays must be converted to the interpreter's format
- return int.nativeToPseudo(res);
- } else {
- return res;
- }
- }
- int.setProperty(scope, name, int.createNativeFunction(tempWrapper));
- }
- } else {
- //bladeburner, or anything else
- int.setProperty(scope, name, int.nativeToPseudo(entry));
- }
- }
-
- //Add the arguments
- int.setProperty(scope, "args", int.nativeToPseudo(workerScript.args));
- }
-
- var interpreter;
- try {
- interpreter = new _JSInterpreter__WEBPACK_IMPORTED_MODULE_3__[/* Interpreter */ "a"](codeWithImports, interpreterInitialization, codeLineOffset);
- } catch(e) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_13__["dialogBoxCreate"])("Syntax ERROR in " + workerScript.name + ": " + e);
- workerScript.env.stopFlag = true;
- workerScript.running = false;
- return;
- }
-
- return new Promise(function(resolve, reject) {
- function runInterpreter() {
- try {
- if (workerScript.env.stopFlag) {return reject(workerScript);}
-
- if (interpreter.step()) {
- window.setTimeout(runInterpreter, _Settings_Settings__WEBPACK_IMPORTED_MODULE_10__["Settings"].CodeInstructionRunTime);
- } else {
- resolve(workerScript);
- }
- } catch(e) {
- e = e.toString();
- if (!Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_5__[/* isScriptErrorMessage */ "b"])(e)) {
- e = Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_5__[/* makeRuntimeRejectMsg */ "d"])(workerScript, e);
- }
- workerScript.errorMessage = e;
- return reject(workerScript);
- }
- }
-
- try {
- runInterpreter();
- } catch(e) {
- if (Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_17__["isString"])(e)) {
- workerScript.errorMessage = e;
- return reject(workerScript);
- } else if (e instanceof WorkerScript) {
- return reject(e);
- } else {
- return reject(workerScript);
- }
- }
- });
-}
-
-/* Since the JS Interpreter used for Netscript 1.0 only supports ES5, the keyword
- 'import' throws an error. However, since we want to support import funtionality
- we'll implement it ourselves by parsing the Nodes in the AST out.
-
- @param code - The script's code
- @returns {Object} {
- code: Newly-generated code with imported functions
- lineOffset: Net number of lines of code added/removed due to imported functions
- Should typically be positive
- }
-*/
-function processNetscript1Imports(code, workerScript) {
- //allowReserved prevents 'import' from throwing error in ES5
- var ast = Object(_utils_acorn__WEBPACK_IMPORTED_MODULE_12__["parse"])(code, {ecmaVersion:6, allowReserved:true, sourceType:"module"});
-
- var server = workerScript.getServer();
- if (server == null) {
- throw new Error("Failed to find underlying Server object for script");
- }
-
- function getScript(scriptName) {
- for (let i = 0; i < server.scripts.length; ++i) {
- if (server.scripts[i].filename === scriptName) {
- return server.scripts[i];
- }
- }
- return null;
- }
-
- var generatedCode = ""; //Generated Javascript Code
- var hasImports = false;
-
- //Walk over the tree and process ImportDeclaration nodes
- walk.simple(ast, {
- ImportDeclaration: (node) => {
- hasImports = true;
- let scriptName = node.source.value;
- if (scriptName.startsWith("./")) {
- scriptName = scriptName.slice(2);
- }
- let script = getScript(scriptName);
- if (script == null) {
- throw new Error("'Import' failed due to invalid script: " + scriptName);
- }
- let scriptAst = Object(_utils_acorn__WEBPACK_IMPORTED_MODULE_12__["parse"])(script.code, {ecmaVersion:5, allowReserved:true, sourceType:"module"});
-
- if (node.specifiers.length === 1 && node.specifiers[0].type === "ImportNamespaceSpecifier") {
- //import * as namespace from script
- let namespace = node.specifiers[0].local.name;
- let fnNames = []; //Names only
- let fnDeclarations = []; //FunctionDeclaration Node objects
- walk.simple(scriptAst, {
- FunctionDeclaration: (node) => {
- fnNames.push(node.id.name);
- fnDeclarations.push(node);
- }
- });
-
- //Now we have to generate the code that would create the namespace
- generatedCode =
- "var " + namespace + ";\n" +
- "(function (namespace) {\n";
-
- //Add the function declarations
- fnDeclarations.forEach((fn) => {
- generatedCode += Object(escodegen__WEBPACK_IMPORTED_MODULE_11__["generate"])(fn);
- generatedCode += "\n";
- });
-
- //Add functions to namespace
- fnNames.forEach((fnName) => {
- generatedCode += ("namespace." + fnName + " = " + fnName);
- generatedCode += "\n";
- });
-
- //Finish
- generatedCode += (
- "})(" + namespace + " || " + "(" + namespace + " = {}));\n"
- )
- } else {
- //import {...} from script
-
- //Get array of all fns to import
- let fnsToImport = [];
- node.specifiers.forEach((e) => {
- fnsToImport.push(e.local.name);
- });
-
- //Walk through script and get FunctionDeclaration code for all specified fns
- let fnDeclarations = [];
- walk.simple(scriptAst, {
- FunctionDeclaration: (node) => {
- if (fnsToImport.includes(node.id.name)) {
- fnDeclarations.push(node);
- }
- }
- });
-
- //Convert FunctionDeclarations into code
- fnDeclarations.forEach((fn) => {
- generatedCode += Object(escodegen__WEBPACK_IMPORTED_MODULE_11__["generate"])(fn);
- generatedCode += "\n";
- });
- }
- }
- });
-
- //If there are no imports, just return the original code
- if (!hasImports) {return {code:code, lineOffset:0};}
-
- //Remove ImportDeclarations from AST. These ImportDeclarations must be in top-level
- var linesRemoved = 0;
- if (ast.type !== "Program" || ast.body == null) {
- throw new Error("Code could not be properly parsed");
- }
- for (let i = ast.body.length-1; i >= 0; --i) {
- if (ast.body[i].type === "ImportDeclaration") {
- ast.body.splice(i, 1);
- ++linesRemoved;
- }
- }
-
- //Calculated line offset
- var lineOffset = (generatedCode.match(/\n/g) || []).length - linesRemoved;
-
- //Convert the AST back into code
- code = Object(escodegen__WEBPACK_IMPORTED_MODULE_11__["generate"])(ast);
-
- //Add the imported code and re-generate in ES5 (JS Interpreter for NS1 only supports ES5);
- code = generatedCode + code;
- var res = {
- code: code,
- lineOffset: lineOffset
- }
- return res;
-}
-
-//Loop through workerScripts and run every script that is not currently running
-function runScriptsLoop() {
- var scriptDeleted = false;
-
- //Delete any scripts that finished or have been killed. Loop backwards bc removing items screws up indexing
- for (var i = workerScripts.length - 1; i >= 0; i--) {
- if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == true) {
- scriptDeleted = true;
- //Delete script from the runningScripts array on its host serverIp
- var ip = workerScripts[i].serverIp;
- var name = workerScripts[i].name;
-
- //recalculate ram used
- _Server__WEBPACK_IMPORTED_MODULE_9__[/* AllServers */ "b"][ip].ramUsed = 0;
- for(let j = 0; j < workerScripts.length; j++) {
- if(workerScripts[j].serverIp !== ip) {
- continue
- }
- if(j === i) { // not this one
- continue
- }
- _Server__WEBPACK_IMPORTED_MODULE_9__[/* AllServers */ "b"][ip].ramUsed += workerScripts[j].ramUsage;
- }
-
- //Delete script from Active Scripts
- Object(_ActiveScriptsUI__WEBPACK_IMPORTED_MODULE_0__[/* deleteActiveScriptsItem */ "b"])(workerScripts[i]);
-
- for (var j = 0; j < _Server__WEBPACK_IMPORTED_MODULE_9__[/* AllServers */ "b"][ip].runningScripts.length; j++) {
- if (_Server__WEBPACK_IMPORTED_MODULE_9__[/* AllServers */ "b"][ip].runningScripts[j].filename == name &&
- Object(_utils_helpers_compareArrays__WEBPACK_IMPORTED_MODULE_14__["compareArrays"])(_Server__WEBPACK_IMPORTED_MODULE_9__[/* AllServers */ "b"][ip].runningScripts[j].args, workerScripts[i].args)) {
- _Server__WEBPACK_IMPORTED_MODULE_9__[/* AllServers */ "b"][ip].runningScripts.splice(j, 1);
- break;
- }
- }
-
- //Delete script from workerScripts
- workerScripts.splice(i, 1);
- }
- }
- if (scriptDeleted) {Object(_ActiveScriptsUI__WEBPACK_IMPORTED_MODULE_0__[/* updateActiveScriptsItems */ "c"])();} //Force Update
-
-
- //Run any scripts that haven't been started
- for (var i = 0; i < workerScripts.length; i++) {
- //If it isn't running, start the script
- if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == false) {
- let p = null; // p is the script's result promise.
- if (workerScripts[i].name.endsWith(".js") || workerScripts[i].name.endsWith(".ns")) {
- p = startNetscript2Script(workerScripts[i]);
- } else {
- p = startNetscript1Script(workerScripts[i]);
- if (!(p instanceof Promise)) {continue;}
- /*
- try {
- var ast = parse(workerScripts[i].code, {sourceType:"module"});
- //console.log(ast);
- } catch (e) {
- console.log("Error parsing script: " + workerScripts[i].name);
- dialogBoxCreate("Syntax ERROR in " + workerScripts[i].name + ": " + e);
- workerScripts[i].env.stopFlag = true;
- continue;
- }
- workerScripts[i].running = true;
- p = evaluate(ast, workerScripts[i]);
- */
- }
-
- //Once the code finishes (either resolved or rejected, doesnt matter), set its
- //running status to false
- p.then(function(w) {
- console.log("Stopping script " + w.name + " because it finished running naturally");
- w.running = false;
- w.env.stopFlag = true;
- w.scriptRef.log("Script finished running");
- }).catch(function(w) {
- if (w instanceof Error) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_13__["dialogBoxCreate"])("Script runtime unknown error. This is a bug please contact game developer");
- console.log("ERROR: Evaluating workerscript returns an Error. THIS SHOULDN'T HAPPEN: " + w.toString());
- return;
- } else if (w.constructor === Array && w.length === 2 && w[0] === "RETURNSTATEMENT") {
- //Script ends with a return statement
- console.log("Script returning with value: " + w[1]);
- //TODO maybe do something with this in the future
- return;
- } else if (w instanceof WorkerScript) {
- if (Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_5__[/* isScriptErrorMessage */ "b"])(w.errorMessage)) {
- var errorTextArray = w.errorMessage.split("|");
- if (errorTextArray.length != 4) {
- console.log("ERROR: Something wrong with Error text in evaluator...");
- console.log("Error text: " + errorText);
- return;
- }
- var serverIp = errorTextArray[1];
- var scriptName = errorTextArray[2];
- var errorMsg = errorTextArray[3];
-
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_13__["dialogBoxCreate"])("Script runtime error: Server Ip: " + serverIp +
- " Script name: " + scriptName +
- " Args:" + Object(_utils_helpers_arrayToString__WEBPACK_IMPORTED_MODULE_15__["arrayToString"])(w.args) + " " + errorMsg);
- w.scriptRef.log("Script crashed with runtime error");
- } else {
- w.scriptRef.log("Script killed");
- }
- w.running = false;
- w.env.stopFlag = true;
-
- } else if (Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_5__[/* isScriptErrorMessage */ "b"])(w)) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_13__["dialogBoxCreate"])("Script runtime unknown error. This is a bug please contact game developer");
- console.log("ERROR: Evaluating workerscript returns only error message rather than WorkerScript object. THIS SHOULDN'T HAPPEN: " + w.toString());
- return;
- } else {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_13__["dialogBoxCreate"])("An unknown script died for an unknown reason. This is a bug please contact game dev");
- console.log(w);
- }
- });
- }
- }
-
- setTimeout(runScriptsLoop, 6000);
-}
-
-//Queues a script to be killed by settings its stop flag to true. Then, the code will reject
-//all of its promises recursively, and when it does so it will no longer be running.
-//The runScriptsLoop() will then delete the script from worker scripts
-function killWorkerScript(runningScriptObj, serverIp) {
- for (var i = 0; i < workerScripts.length; i++) {
- if (workerScripts[i].name == runningScriptObj.filename && workerScripts[i].serverIp == serverIp &&
- Object(_utils_helpers_compareArrays__WEBPACK_IMPORTED_MODULE_14__["compareArrays"])(workerScripts[i].args, runningScriptObj.args)) {
- workerScripts[i].env.stopFlag = true;
- Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_5__[/* killNetscriptDelay */ "c"])(workerScripts[i]);
- //Recursively kill all functions
- var curr = workerScripts[i];
- while (curr.fnWorker) {
- curr.fnWorker.env.stopFlag = true;
- Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_5__[/* killNetscriptDelay */ "c"])(curr.fnWorker);
- curr = curr.fnWorker;
- }
- return true;
- }
- }
- return false;
-}
-
-//Queues a script to be run
-function addWorkerScript(runningScriptObj, server) {
- var filename = runningScriptObj.filename;
-
- //Update server's ram usage
- var threads = 1;
- if (runningScriptObj.threads && !isNaN(runningScriptObj.threads)) {
- threads = runningScriptObj.threads;
- } else {
- runningScriptObj.threads = 1;
- }
- var ramUsage = Object(_utils_helpers_roundToTwo__WEBPACK_IMPORTED_MODULE_16__["roundToTwo"])(runningScriptObj.scriptRef.ramUsage * threads);
- var ramAvailable = server.maxRam - server.ramUsed;
- if (ramUsage > ramAvailable) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_13__["dialogBoxCreate"])("Not enough RAM to run script " + runningScriptObj.filename + " with args " +
- Object(_utils_helpers_arrayToString__WEBPACK_IMPORTED_MODULE_15__["arrayToString"])(runningScriptObj.args) + ". This likely occurred because you re-loaded " +
- "the game and the script's RAM usage increased (either because of an update to the game or " +
- "your changes to the script.)");
- return;
- }
- server.ramUsed = Object(_utils_helpers_roundToTwo__WEBPACK_IMPORTED_MODULE_16__["roundToTwo"])(server.ramUsed + ramUsage);
-
- //Create the WorkerScript
- var s = new WorkerScript(runningScriptObj);
- s.serverIp = server.ip;
- s.ramUsage = ramUsage;
-
- //Add the WorkerScript to the Active Scripts list
- Object(_ActiveScriptsUI__WEBPACK_IMPORTED_MODULE_0__[/* addActiveScriptsItem */ "a"])(s);
-
- //Add the WorkerScript
- workerScripts.push(s);
- return;
-}
-
-//Updates the online running time stat of all running scripts
-function updateOnlineScriptTimes(numCycles = 1) {
- var time = (numCycles * _engine__WEBPACK_IMPORTED_MODULE_2__["Engine"]._idleSpeed) / 1000; //seconds
- for (var i = 0; i < workerScripts.length; ++i) {
- workerScripts[i].scriptRef.onlineRunningTime += time;
- }
-}
-
-
-
-
-/***/ }),
-/* 31 */
-/*!**********************************************!*\
- !*** ./src/Corporation/EmployeePositions.ts ***!
- \**********************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.EmployeePositions = {
- Operations: "Operations",
- Engineer: "Engineer",
- Business: "Business",
- Management: "Management",
- RandD: "Research & Development",
- Training: "Training",
- Unassigned: "Unassigned",
-};
-
-
-/***/ }),
-/* 32 */
-/*!**********************************!*\
- !*** ./src/StockMarket/Stock.ts ***!
- \**********************************/
-/*! no static exports found */
-/*! exports used: Stock */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-const JSONReviver_1 = __webpack_require__(/*! ../../utils/JSONReviver */ 15);
-const getRandomInt_1 = __webpack_require__(/*! ../../utils/helpers/getRandomInt */ 17);
-/**
- * Represents the valuation of a company in the World Stock Exchange.
- */
-class Stock {
- /**
- * Initializes a Stock from a JSON save state
- */
- static fromJSON(value) {
- return JSONReviver_1.Generic_fromJSON(Stock, value.data);
- }
- constructor(name = "", symbol = "", mv = 1, b = true, otlkMag = 0, initPrice = 10e3, marketCap = 1e12) {
- this.name = name;
- this.symbol = symbol;
- this.price = initPrice;
- this.playerShares = 0;
- this.playerAvgPx = 0;
- this.playerShortShares = 0;
- this.playerAvgShortPx = 0;
- this.mv = mv;
- this.b = b;
- this.otlkMag = otlkMag;
- this.cap = getRandomInt_1.getRandomInt(initPrice * 1e3, initPrice * 25e3);
- // Total shares is determined by market cap, and is rounded to nearest 100k
- let totalSharesUnrounded = (marketCap / initPrice);
- this.totalShares = Math.round(totalSharesUnrounded / 1e5) * 1e5;
- // Max Shares (Outstanding shares) is a percentage of total shares
- const outstandingSharePercentage = 0.2;
- this.maxShares = Math.round((this.totalShares * outstandingSharePercentage) / 1e5) * 1e5;
- this.posTxtEl = null;
- }
- /**
- * Serialize the Stock to a JSON save state.
- */
- toJSON() {
- return JSONReviver_1.Generic_toJSON("Stock", this);
- }
-}
-exports.Stock = Stock;
-JSONReviver_1.Reviver.constructors.Stock = Stock;
-
-
-/***/ }),
-/* 33 */
-/*!***********************!*\
- !*** ./src/Script.js ***!
- \***********************/
-/*! exports provided: getCurrentEditor, updateScriptEditorContent, loadAllRunningScripts, findRunningScript, RunningScript, Script, AllServersMap, scriptEditorInit, isScriptFilename */
-/*! exports used: AllServersMap, RunningScript, Script, findRunningScript, getCurrentEditor, isScriptFilename, loadAllRunningScripts, scriptEditorInit, updateScriptEditorContent */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return getCurrentEditor; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "i", function() { return updateScriptEditorContent; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return loadAllRunningScripts; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return findRunningScript; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return RunningScript; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return Script; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return AllServersMap; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "h", function() { return scriptEditorInit; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return isScriptFilename; });
-/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants */ 1);
-/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_Constants__WEBPACK_IMPORTED_MODULE_0__);
-/* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine */ 11);
-/* harmony import */ var _Fconf__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Fconf */ 52);
-/* harmony import */ var _InteractiveTutorial__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./InteractiveTutorial */ 38);
-/* harmony import */ var _NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptEvaluator */ 7);
-/* harmony import */ var _NetscriptFunctions__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptFunctions */ 47);
-/* harmony import */ var _NetscriptWorker__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptWorker */ 30);
-/* harmony import */ var _Player__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Player */ 0);
-/* harmony import */ var _ScriptEditor_Ace__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./ScriptEditor/Ace */ 93);
-/* harmony import */ var _ScriptEditor_CodeMirror__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./ScriptEditor/CodeMirror */ 92);
-/* harmony import */ var _Server__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Server */ 12);
-/* harmony import */ var _Settings_Settings__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Settings/Settings */ 19);
-/* harmony import */ var _Settings_Settings__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(_Settings_Settings__WEBPACK_IMPORTED_MODULE_11__);
-/* harmony import */ var _Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Settings/SettingEnums */ 45);
-/* harmony import */ var _Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12__);
-/* harmony import */ var _ui_postToTerminal__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./ui/postToTerminal */ 8);
-/* harmony import */ var _ui_postToTerminal__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(_ui_postToTerminal__WEBPACK_IMPORTED_MODULE_13__);
-/* harmony import */ var _TextFile__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./TextFile */ 73);
-/* harmony import */ var _TextFile__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(_TextFile__WEBPACK_IMPORTED_MODULE_14__);
-/* harmony import */ var _utils_acorn__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/acorn */ 54);
-/* harmony import */ var _utils_acorn__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn__WEBPACK_IMPORTED_MODULE_15__);
-/* harmony import */ var _ui_navigationTracking__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./ui/navigationTracking */ 13);
-/* harmony import */ var _ui_navigationTracking__WEBPACK_IMPORTED_MODULE_16___default = /*#__PURE__*/__webpack_require__.n(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_16__);
-/* harmony import */ var _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./ui/numeralFormat */ 4);
-/* harmony import */ var _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(_ui_numeralFormat__WEBPACK_IMPORTED_MODULE_17__);
-/* harmony import */ var _utils_DialogBox__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../utils/DialogBox */ 9);
-/* harmony import */ var _utils_JSONReviver__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utils/JSONReviver */ 15);
-/* harmony import */ var _utils_helpers_compareArrays__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/helpers/compareArrays */ 107);
-/* harmony import */ var _utils_helpers_compareArrays__WEBPACK_IMPORTED_MODULE_20___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_compareArrays__WEBPACK_IMPORTED_MODULE_20__);
-/* harmony import */ var _utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../utils/uiHelpers/createElement */ 2);
-/* harmony import */ var _utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_21___default = /*#__PURE__*/__webpack_require__.n(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_21__);
-/* harmony import */ var _utils_helpers_getTimestamp__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../utils/helpers/getTimestamp */ 101);
-/* harmony import */ var _utils_helpers_getTimestamp__WEBPACK_IMPORTED_MODULE_22___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_getTimestamp__WEBPACK_IMPORTED_MODULE_22__);
-/* harmony import */ var _utils_helpers_roundToTwo__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../utils/helpers/roundToTwo */ 95);
-/* harmony import */ var _utils_helpers_roundToTwo__WEBPACK_IMPORTED_MODULE_23___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_roundToTwo__WEBPACK_IMPORTED_MODULE_23__);
-// Importing this doesn't work for some reason.
-const walk = __webpack_require__(/*! acorn/dist/walk */ 175);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-function isScriptFilename(f) {
- return f.endsWith(".js") || f.endsWith(".script") || f.endsWith(".ns");
-}
-
-var scriptEditorRamCheck = null, scriptEditorRamText = null;
-function scriptEditorInit() {
- // Wrapper container that holds all the buttons below the script editor
- const wrapper = document.getElementById("script-editor-buttons-wrapper");
- if (wrapper == null) {
- console.error("Could not find 'script-editor-buttons-wrapper'");
- return false;
- }
-
- // Beautify button
- const beautifyButton = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_21__["createElement"])("button", {
- class: "std-button",
- display: "inline-block",
- innerText: "Beautify",
- clickListener:()=>{
- let editor = getCurrentEditor();
- if (editor != null) {
- editor.beautifyScript();
- }
- return false;
- }
- });
-
- // Text that displays RAM calculation
- scriptEditorRamText = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_21__["createElement"])("p", {
- display:"inline-block", margin:"10px", id:"script-editor-status-text"
- });
-
- // Label for checkbox (defined below)
- const checkboxLabel = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_21__["createElement"])("label", {
- for:"script-editor-ram-check", margin:"4px", marginTop: "8px",
- innerText:"Dynamic RAM Usage Checker", color:"white",
- tooltip:"Enable/Disable the dynamic RAM Usage display. You may " +
- "want to disable it for very long scripts because there may be " +
- "performance issues"
- });
-
- // Checkbox for enabling/disabling dynamic RAM calculation
- scriptEditorRamCheck = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_21__["createElement"])("input", {
- type:"checkbox", name:"script-editor-ram-check", id:"script-editor-ram-check",
- margin:"4px", marginTop: "8px",
- });
- scriptEditorRamCheck.checked = true;
-
- // Link to Netscript documentation
- const documentationButton = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_21__["createElement"])("a", {
- class: "std-button",
- display: "inline-block",
- href:"https://bitburner.readthedocs.io/en/latest/index.html",
- innerText:"Netscript Documentation",
- target:"_blank",
- });
-
- // Save and Close button
- const closeButton = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_21__["createElement"])("button", {
- class: "std-button",
- display: "inline-block",
- innerText: "Save & Close (Ctrl/Cmd + b)",
- clickListener:()=>{
- saveAndCloseScriptEditor();
- return false;
- }
- });
-
- // Add all buttons to the UI
- wrapper.appendChild(beautifyButton);
- wrapper.appendChild(closeButton);
- wrapper.appendChild(scriptEditorRamText);
- wrapper.appendChild(scriptEditorRamCheck);
- wrapper.appendChild(checkboxLabel);
- wrapper.appendChild(documentationButton);
-
- // Initialize editors
- const initParams = {
- saveAndCloseFn: saveAndCloseScriptEditor,
- quitFn: _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadTerminalContent,
- }
-
- _ScriptEditor_Ace__WEBPACK_IMPORTED_MODULE_8__[/* AceEditor */ "a"].init(initParams);
- _ScriptEditor_CodeMirror__WEBPACK_IMPORTED_MODULE_9__[/* CodeMirrorEditor */ "a"].init(initParams);
-
- // Setup the selector for which Editor to use
- const editorSelector = document.getElementById("script-editor-option-editor");
- if (editorSelector == null) {
- console.error(`Could not find DOM Element for editor selector (id=script-editor-option-editor)`);
- return false;
- }
-
- for (let i = 0; i < editorSelector.options.length; ++i) {
- if (editorSelector.options[i].value === _Settings_Settings__WEBPACK_IMPORTED_MODULE_11__["Settings"].Editor) {
- editorSelector.selectedIndex = i;
- break;
- }
- }
-
- editorSelector.onchange = () => {
- const opt = editorSelector.value;
- switch (opt) {
- case _Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12__["EditorSetting"].Ace:
- const codeMirrorCode = _ScriptEditor_CodeMirror__WEBPACK_IMPORTED_MODULE_9__[/* CodeMirrorEditor */ "a"].getCode();
- const codeMirrorFn = _ScriptEditor_CodeMirror__WEBPACK_IMPORTED_MODULE_9__[/* CodeMirrorEditor */ "a"].getFilename();
- _ScriptEditor_Ace__WEBPACK_IMPORTED_MODULE_8__[/* AceEditor */ "a"].create();
- _ScriptEditor_CodeMirror__WEBPACK_IMPORTED_MODULE_9__[/* CodeMirrorEditor */ "a"].setInvisible();
- _ScriptEditor_Ace__WEBPACK_IMPORTED_MODULE_8__[/* AceEditor */ "a"].openScript(codeMirrorFn, codeMirrorCode);
- break;
- case _Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12__["EditorSetting"].CodeMirror:
- const aceCode = _ScriptEditor_Ace__WEBPACK_IMPORTED_MODULE_8__[/* AceEditor */ "a"].getCode();
- const aceFn = _ScriptEditor_Ace__WEBPACK_IMPORTED_MODULE_8__[/* AceEditor */ "a"].getFilename();
- _ScriptEditor_CodeMirror__WEBPACK_IMPORTED_MODULE_9__[/* CodeMirrorEditor */ "a"].create();
- _ScriptEditor_Ace__WEBPACK_IMPORTED_MODULE_8__[/* AceEditor */ "a"].setInvisible();
- _ScriptEditor_CodeMirror__WEBPACK_IMPORTED_MODULE_9__[/* CodeMirrorEditor */ "a"].openScript(aceFn, aceCode);
- break;
- default:
- console.error(`Unrecognized Editor Setting: ${opt}`);
- return;
- }
-
- _Settings_Settings__WEBPACK_IMPORTED_MODULE_11__["Settings"].Editor = opt;
- }
-
- editorSelector.onchange(); // Trigger the onchange event handler
-}
-
-function getCurrentEditor() {
- switch (_Settings_Settings__WEBPACK_IMPORTED_MODULE_11__["Settings"].Editor) {
- case _Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12__["EditorSetting"].Ace:
- return _ScriptEditor_Ace__WEBPACK_IMPORTED_MODULE_8__[/* AceEditor */ "a"];
- case _Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12__["EditorSetting"].CodeMirror:
- return _ScriptEditor_CodeMirror__WEBPACK_IMPORTED_MODULE_9__[/* CodeMirrorEditor */ "a"];
- default:
- console.log(`Invalid Editor Setting: ${_Settings_Settings__WEBPACK_IMPORTED_MODULE_11__["Settings"].Editor}`);
- throw new Error(`Invalid Editor Setting: ${_Settings_Settings__WEBPACK_IMPORTED_MODULE_11__["Settings"].Editor}`);
- return null;
- }
-}
-
-//Updates RAM usage in script
-async function updateScriptEditorContent() {
- var filename = document.getElementById("script-editor-filename").value;
- if (scriptEditorRamCheck == null || !scriptEditorRamCheck.checked || !isScriptFilename(filename)) {
- scriptEditorRamText.innerText = "N/A";
- return;
- }
-
- let code;
- try {
- code = getCurrentEditor().getCode();
- } catch(e) {
- scriptEditorRamText.innerText = "RAM: ERROR";
- return;
- }
-
- var codeCopy = code.repeat(1);
- var ramUsage = await calculateRamUsage(codeCopy);
- if (ramUsage !== -1) {
- scriptEditorRamText.innerText = "RAM: " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_17__["numeralWrapper"].format(ramUsage, '0.00') + " GB";
- } else {
- scriptEditorRamText.innerText = "RAM: Syntax Error";
- }
-}
-
-//Define key commands in script editor (ctrl o to save + close, etc.)
-$(document).keydown(function(e) {
- if (_Settings_Settings__WEBPACK_IMPORTED_MODULE_11__["Settings"].DisableHotkeys === true) {return;}
- if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_16__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_16__["Page"].ScriptEditor)) {
- //Ctrl + b
- if (e.keyCode == 66 && (e.ctrlKey || e.metaKey)) {
- e.preventDefault();
- saveAndCloseScriptEditor();
- }
- }
-});
-
-function saveAndCloseScriptEditor() {
- var filename = document.getElementById("script-editor-filename").value;
-
- let code;
- try {
- code = getCurrentEditor().getCode();
- } catch(e) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_18__["dialogBoxCreate"])("Something went wrong when trying to save (getCurrentEditor().getCode()). Please report to game developer with details");
- return;
- }
-
- if (_InteractiveTutorial__WEBPACK_IMPORTED_MODULE_3__[/* ITutorial */ "a"].isRunning && _InteractiveTutorial__WEBPACK_IMPORTED_MODULE_3__[/* ITutorial */ "a"].currStep === _InteractiveTutorial__WEBPACK_IMPORTED_MODULE_3__[/* iTutorialSteps */ "d"].TerminalTypeScript) {
- //Make sure filename + code properly follow tutorial
- if (filename !== "foodnstuff.script") {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_18__["dialogBoxCreate"])("Leave the script name as 'foodnstuff'!");
- return;
- }
- code = code.replace(/\s/g, "");
- if (code.indexOf("while(true){hack('foodnstuff');}") == -1) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_18__["dialogBoxCreate"])("Please copy and paste the code from the tutorial!");
- return;
- }
-
- //Save the script
- let s = _Player__WEBPACK_IMPORTED_MODULE_7__[/* Player */ "a"].getCurrentServer();
- for (var i = 0; i < s.scripts.length; i++) {
- if (filename == s.scripts[i].filename) {
- s.scripts[i].saveScript();
- _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadTerminalContent();
- return Object(_InteractiveTutorial__WEBPACK_IMPORTED_MODULE_3__[/* iTutorialNextStep */ "b"])();
- }
- }
-
- //If the current script does NOT exist, create a new one
- let script = new Script();
- script.saveScript();
- s.scripts.push(script);
-
- return Object(_InteractiveTutorial__WEBPACK_IMPORTED_MODULE_3__[/* iTutorialNextStep */ "b"])();
- }
-
- if (filename == "") {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_18__["dialogBoxCreate"])("You must specify a filename!");
- return;
- }
-
- if (checkValidFilename(filename) == false) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_18__["dialogBoxCreate"])("Script filename can contain only alphanumerics, hyphens, and underscores");
- return;
- }
-
- var s = _Player__WEBPACK_IMPORTED_MODULE_7__[/* Player */ "a"].getCurrentServer();
- if (filename === ".fconf") {
- try {
- Object(_Fconf__WEBPACK_IMPORTED_MODULE_2__[/* parseFconfSettings */ "d"])(code);
- } catch(e) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_18__["dialogBoxCreate"])(`Invalid .fconf file: ${e}`);
- return;
- }
- } else if (isScriptFilename(filename)) {
- //If the current script already exists on the server, overwrite it
- for (var i = 0; i < s.scripts.length; i++) {
- if (filename == s.scripts[i].filename) {
- s.scripts[i].saveScript();
- _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadTerminalContent();
- return;
- }
- }
-
- //If the current script does NOT exist, create a new one
- var script = new Script();
- script.saveScript();
- s.scripts.push(script);
- } else if (filename.endsWith(".txt")) {
- for (var i = 0; i < s.textFiles.length; ++i) {
- if (s.textFiles[i].fn === filename) {
- s.textFiles[i].write(code);
- _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadTerminalContent();
- return;
- }
- }
- var textFile = new _TextFile__WEBPACK_IMPORTED_MODULE_14__["TextFile"](filename, code);
- s.textFiles.push(textFile);
- } else {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_18__["dialogBoxCreate"])("Invalid filename. Must be either a script (.script) or " +
- " or text file (.txt)")
- return;
- }
- _engine__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadTerminalContent();
-}
-
-//Checks that the string contains only valid characters for a filename, which are alphanumeric,
-// underscores, hyphens, and dots
-function checkValidFilename(filename) {
- var regex = /^[.a-zA-Z0-9_-]+$/;
-
- if (filename.match(regex)) {
- return true;
- }
- return false;
-}
-
-function Script(fn = "", code = "", server = "") {
- this.filename = fn;
- this.code = code;
- this.ramUsage = 0;
- this.server = server; //IP of server this script is on
- this.module = "";
- if (this.code !== "") {this.updateRamUsage();}
-};
-
-//Get the script data from the Script Editor and save it to the object
-Script.prototype.saveScript = function() {
- if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_16__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_16__["Page"].ScriptEditor)) {
- //Update code and filename
- const code = getCurrentEditor().getCode();
- this.code = code.replace(/^\s+|\s+$/g, '');
-
- var filename = document.getElementById("script-editor-filename").value;
- this.filename = filename;
-
- //Server
- this.server = _Player__WEBPACK_IMPORTED_MODULE_7__[/* Player */ "a"].currentServer;
-
- //Calculate/update ram usage, execution time, etc.
- this.updateRamUsage();
-
- this.module = "";
- }
-}
-
-//Updates how much RAM the script uses when it is running.
-Script.prototype.updateRamUsage = async function() {
- var codeCopy = this.code.repeat(1);
- var res = await calculateRamUsage(codeCopy);
- if (res !== -1) {
- this.ramUsage = Object(_utils_helpers_roundToTwo__WEBPACK_IMPORTED_MODULE_23__["roundToTwo"])(res);
- }
-}
-
-// These special strings are used to reference the presence of a given logical
-// construct within a user script.
-const specialReferenceIF = "__SPECIAL_referenceIf";
-const specialReferenceFOR = "__SPECIAL_referenceFor";
-const specialReferenceWHILE = "__SPECIAL_referenceWhile";
-
-// The global scope of a script is registered under this key during parsing.
-const memCheckGlobalKey = ".__GLOBAL__";
-
-// Calcluates the amount of RAM a script uses. Uses parsing and AST walking only,
-// rather than NetscriptEvaluator. This is useful because NetscriptJS code does
-// not work under NetscriptEvaluator.
-async function parseOnlyRamCalculate(server, code, workerScript) {
- try {
- // Maps dependent identifiers to their dependencies.
- //
- // The initial identifier is __SPECIAL_INITIAL_MODULE__.__GLOBAL__.
- // It depends on all the functions declared in the module, all the global scopes
- // of its imports, and any identifiers referenced in this global scope. Each
- // function depends on all the identifiers referenced internally.
- // We walk the dependency graph to calculate RAM usage, given that some identifiers
- // reference Netscript functions which have a RAM cost.
- let dependencyMap = {};
-
- // Scripts we've parsed.
- const completedParses = new Set();
-
- // Scripts we've discovered that need to be parsed.
- const parseQueue = [];
-
- // Parses a chunk of code with a given module name, and updates parseQueue and dependencyMap.
- function parseCode(code, moduleName) {
- const result = parseOnlyCalculateDeps(code, moduleName);
- completedParses.add(moduleName);
-
- // Add any additional modules to the parse queue;
- for (let i = 0; i < result.additionalModules.length; ++i) {
- if (!completedParses.has(result.additionalModules[i])) {
- parseQueue.push(result.additionalModules[i]);
- }
- }
-
- // Splice all the references in.
- //Spread syntax not supported in edge, use Object.assign instead
- //dependencyMap = {...dependencyMap, ...result.dependencyMap};
- dependencyMap = Object.assign(dependencyMap, result.dependencyMap);
- }
-
- const initialModule = "__SPECIAL_INITIAL_MODULE__";
- parseCode(code, initialModule);
-
- while (parseQueue.length > 0) {
- // Get the code from the server.
- const nextModule = parseQueue.shift();
-
- let code;
- if (nextModule.startsWith("https://") || nextModule.startsWith("http://")) {
- try {
- const module = await eval('import(nextModule)');
- code = "";
- for (const prop in module) {
- if (typeof module[prop] === 'function') {
- code += module[prop].toString() + ";\n";
- }
- }
- } catch(e) {
- console.error(`Error dynamically importing module from ${nextModule} for RAM calculations: ${e}`);
- return -1;
- }
- } else {
- const script = server.getScript(nextModule.startsWith("./") ? nextModule.slice(2) : nextModule);
- if (!script) {
- console.warn("Invalid script");
- return -1; // No such script on the server.
- }
- code = script.code;
- }
-
- parseCode(code, nextModule);
- }
-
- // Finally, walk the reference map and generate a ram cost. The initial set of keys to scan
- // are those that start with __SPECIAL_INITIAL_MODULE__.
- let ram = _Constants__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptBaseRamCost;
- const unresolvedRefs = Object.keys(dependencyMap).filter(s => s.startsWith(initialModule));
- const resolvedRefs = new Set();
- while (unresolvedRefs.length > 0) {
- const ref = unresolvedRefs.shift();
-
- // Check if this is one of the special keys, and add the appropriate ram cost if so.
- if (ref === "hacknet" && !resolvedRefs.has("hacknet")) {
- ram += _Constants__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptHacknetNodesRamCost;
- }
- if (ref === "document" && !resolvedRefs.has("document")) {
- ram += _Constants__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptDomRamCost;
- }
- if (ref === "window" && !resolvedRefs.has("window")) {
- ram += _Constants__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptDomRamCost;
- }
-
- resolvedRefs.add(ref);
-
- if (ref.endsWith(".*")) {
- // A prefix reference. We need to find all matching identifiers.
- const prefix = ref.slice(0, ref.length - 2);
- for (let ident of Object.keys(dependencyMap).filter(k => k.startsWith(prefix))) {
- for (let dep of dependencyMap[ident] || []) {
- if (!resolvedRefs.has(dep)) unresolvedRefs.push(dep);
- }
- }
- } else {
- // An exact reference. Add all dependencies of this ref.
- for (let dep of dependencyMap[ref] || []) {
- if (!resolvedRefs.has(dep)) unresolvedRefs.push(dep);
- }
- }
-
- // Check if this ident is a function in the workerscript env. If it is, then we need to
- // get its RAM cost. We do this by calling it, which works because the running script
- // is in checkingRam mode.
- //
- // TODO it would be simpler to just reference a dictionary.
- try {
- function applyFuncRam(func) {
- if (typeof func === "function") {
- try {
- let res;
- if (func.constructor.name === "AsyncFunction") {
- res = 0; // Async functions will always be 0 RAM
- } else {
- res = func.apply(null, []);
- }
- if (typeof res === "number") {
- return res;
- }
- return 0;
- } catch(e) {
- console.log("ERROR applying function: " + e);
- return 0;
- }
- } else {
- return 0;
- }
- }
-
- //Special logic for namespaces (Bladeburner, CodingCOntract)
- var func;
- if (ref in workerScript.env.vars.bladeburner) {
- func = workerScript.env.vars.bladeburner[ref];
- } else if (ref in workerScript.env.vars.codingcontract) {
- func = workerScript.env.vars.codingcontract[ref];
- } else if (ref in workerScript.env.vars.gang) {
- func = workerScript.env.vars.gang[ref];
- } else {
- func = workerScript.env.get(ref);
- }
- ram += applyFuncRam(func);
- } catch (error) {continue;}
- }
- return ram;
-
- } catch (error) {
- // console.info("parse or eval error: ", error);
- // This is not unexpected. The user may be editing a script, and it may be in
- // a transitory invalid state.
- return -1;
- }
-}
-
-// Parses one script and calculates its ram usage, for the global scope and each function.
-// Returns a cost map and a dependencyMap for the module. Returns a reference map to be joined
-// onto the main reference map, and a list of modules that need to be parsed.
-function parseOnlyCalculateDeps(code, currentModule) {
- const ast = Object(_utils_acorn__WEBPACK_IMPORTED_MODULE_15__["parse"])(code, {sourceType:"module", ecmaVersion: 8});
-
- // Everything from the global scope goes in ".". Everything else goes in ".function", where only
- // the outermost layer of functions counts.
- const globalKey = currentModule + memCheckGlobalKey;
- const dependencyMap = {};
- dependencyMap[globalKey] = new Set();
-
- // If we reference this internal name, we're really referencing that external name.
- // Filled when we import names from other modules.
- let internalToExternal = {};
-
- var additionalModules = [];
-
- // References get added pessimistically. They are added for thisModule.name, name, and for
- // any aliases.
- function addRef(key, name) {
- const s = dependencyMap[key] || (dependencyMap[key] = new Set());
- if (name in internalToExternal) {
- s.add(internalToExternal[name]);
- }
- s.add(currentModule + "." + name);
- s.add(name); // For builtins like hack.
- }
-
- //A list of identifiers that resolve to "native Javascript code"
- const objectPrototypeProperties = Object.getOwnPropertyNames(Object.prototype);
-
- // If we discover a dependency identifier, state.key is the dependent identifier.
- // walkDeeper is for doing recursive walks of expressions in composites that we handle.
- function commonVisitors() {
- return {
- Identifier: (node, st, walkDeeper) => {
- if (objectPrototypeProperties.includes(node.name)) {return;}
- addRef(st.key, node.name);
- },
- WhileStatement: (node, st, walkDeeper) => {
- addRef(st.key, specialReferenceWHILE);
- node.test && walkDeeper(node.test, st);
- node.body && walkDeeper(node.body, st);
- },
- DoWhileStatement: (node, st, walkDeeper) => {
- addRef(st.key, specialReferenceWHILE);
- node.test && walkDeeper(node.test, st);
- node.body && walkDeeper(node.body, st);
- },
- ForStatement: (node, st, walkDeeper) => {
- addRef(st.key, specialReferenceFOR);
- node.init && walkDeeper(node.init, st);
- node.test && walkDeeper(node.test, st);
- node.update && walkDeeper(node.update, st);
- node.body && walkDeeper(node.body, st);
- },
- IfStatement: (node, st, walkDeeper) => {
- addRef(st.key, specialReferenceIF);
- node.test && walkDeeper(node.test, st);
- node.consequent && walkDeeper(node.consequent, st);
- node.alternate && walkDeeper(node.alternate, st);
- },
- MemberExpression: (node, st, walkDeeper) => {
- node.object && walkDeeper(node.object, st);
- node.property && walkDeeper(node.property, st);
- },
- }
- }
-
- //Spread syntax not supported in Edge yet, use Object.assign
- /*
- walk.recursive(ast, {key: globalKey}, {
- ImportDeclaration: (node, st, walkDeeper) => {
- const importModuleName = node.source.value;
- additionalModules.push(importModuleName);
-
- // This module's global scope refers to that module's global scope, no matter how we
- // import it.
- dependencyMap[st.key].add(importModuleName + memCheckGlobalKey);
-
- for (let i = 0; i < node.specifiers.length; ++i) {
- const spec = node.specifiers[i];
- if (spec.imported !== undefined && spec.local !== undefined) {
- // We depend on specific things.
- internalToExternal[spec.local.name] = importModuleName + "." + spec.imported.name;
- } else {
- // We depend on everything.
- dependencyMap[st.key].add(importModuleName + ".*");
- }
- }
- },
- FunctionDeclaration: (node, st, walkDeeper) => {
- // Don't use walkDeeper, because we are changing the visitor set.
- const key = currentModule + "." + node.id.name;
- walk.recursive(node, {key: key}, commonVisitors());
- },
- ...commonVisitors()
- });
- */
- walk.recursive(ast, {key: globalKey}, Object.assign({
- ImportDeclaration: (node, st, walkDeeper) => {
- const importModuleName = node.source.value;
- additionalModules.push(importModuleName);
-
- // This module's global scope refers to that module's global scope, no matter how we
- // import it.
- dependencyMap[st.key].add(importModuleName + memCheckGlobalKey);
-
- for (let i = 0; i < node.specifiers.length; ++i) {
- const spec = node.specifiers[i];
- if (spec.imported !== undefined && spec.local !== undefined) {
- // We depend on specific things.
- internalToExternal[spec.local.name] = importModuleName + "." + spec.imported.name;
- } else {
- // We depend on everything.
- dependencyMap[st.key].add(importModuleName + ".*");
- }
- }
- },
- FunctionDeclaration: (node, st, walkDeeper) => {
- // Don't use walkDeeper, because we are changing the visitor set.
- const key = currentModule + "." + node.id.name;
- walk.recursive(node, {key: key}, commonVisitors());
- },
- }, commonVisitors()));
-
- return {dependencyMap: dependencyMap, additionalModules: additionalModules};
-}
-
-async function calculateRamUsage(codeCopy) {
- //Create a temporary/mock WorkerScript and an AST from the code
- var currServ = _Player__WEBPACK_IMPORTED_MODULE_7__[/* Player */ "a"].getCurrentServer();
- var workerScript = new _NetscriptWorker__WEBPACK_IMPORTED_MODULE_6__[/* WorkerScript */ "b"]({
- filename:"foo",
- scriptRef: {code:""},
- args:[]
- });
- workerScript.checkingRam = true; //Netscript functions will return RAM usage
- workerScript.serverIp = currServ.ip;
-
- try {
- return await parseOnlyRamCalculate(currServ, codeCopy, workerScript);
- } catch (e) {
- console.log("Failed to parse ram using new method. Falling back.", e);
- }
-
- // Try the old way.
-
- try {
- var ast = Object(_utils_acorn__WEBPACK_IMPORTED_MODULE_15__["parse"])(codeCopy, {sourceType:"module"});
- } catch(e) {
- return -1;
- }
-
- //Search through AST, scanning for any 'Identifier' nodes for functions, or While/For/If nodes
- var queue = [], ramUsage = _Constants__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptBaseRamCost;
- var whileUsed = false, forUsed = false, ifUsed = false;
- queue.push(ast);
- while (queue.length != 0) {
- var exp = queue.shift();
- switch (exp.type) {
- case "ImportDeclaration":
- //Gets an array of all imported functions as AST expressions
- //and pushes them on the queue.
- var res = Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_4__[/* evaluateImport */ "a"])(exp, workerScript, true);
- for (var i = 0; i < res.length; ++i) {
- queue.push(res[i]);
- }
- break;
- case "BlockStatement":
- case "Program":
- for (var i = 0; i < exp.body.length; ++i) {
- if (exp.body[i] instanceof _utils_acorn__WEBPACK_IMPORTED_MODULE_15__["Node"]) {
- queue.push(exp.body[i]);
- }
- }
- break;
- case "WhileStatement":
- if (!whileUsed) {
- ramUsage += _Constants__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptWhileRamCost;
- whileUsed = true;
- }
- break;
- case "ForStatement":
- if (!forUsed) {
- ramUsage += _Constants__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptForRamCost;
- forUsed = true;
- }
- break;
- case "IfStatement":
- if (!ifUsed) {
- ramUsage += _Constants__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptIfRamCost;
- ifUsed = true;
- }
- break;
- case "Identifier":
- if (exp.name in workerScript.env.vars) {
- var func = workerScript.env.get(exp.name);
- if (typeof func === "function") {
- try {
- var res = func.apply(null, []);
- if (typeof res === "number") {
- ramUsage += res;
- }
- } catch(e) {
- console.log("ERROR applying function: " + e);
- }
- }
- }
- break;
- default:
- break;
- }
-
- for (var prop in exp) {
- if (exp.hasOwnProperty(prop)) {
- if (exp[prop] instanceof _utils_acorn__WEBPACK_IMPORTED_MODULE_15__["Node"]) {
- queue.push(exp[prop]);
- }
- }
- }
- }
-
- //Special case: hacknetnodes array
- if (codeCopy.includes("hacknet")) {
- ramUsage += _Constants__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptHacknetNodesRamCost;
- }
- return ramUsage;
-}
-
-Script.prototype.download = function() {
- var filename = this.filename + ".js";
- var file = new Blob([this.code], {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 = filename;
- document.body.appendChild(a);
- a.click();
- setTimeout(function() {
- document.body.removeChild(a);
- window.URL.revokeObjectURL(url);
- }, 0);
- }
-}
-
-Script.prototype.toJSON = function() {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_19__["Generic_toJSON"])("Script", this);
-}
-
-
-Script.fromJSON = function(value) {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_19__["Generic_fromJSON"])(Script, value.data);
-}
-
-_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_19__["Reviver"].constructors.Script = Script;
-
-//Called when the game is loaded. Loads all running scripts (from all servers)
-//into worker scripts so that they will start running
-function loadAllRunningScripts() {
- var count = 0;
- var total = 0;
- let skipScriptLoad = (window.location.href.toLowerCase().indexOf("?noscripts") !== -1);
- if (skipScriptLoad) {console.log("Skipping the load of any scripts during startup");}
- for (var property in _Server__WEBPACK_IMPORTED_MODULE_10__[/* AllServers */ "b"]) {
- if (_Server__WEBPACK_IMPORTED_MODULE_10__[/* AllServers */ "b"].hasOwnProperty(property)) {
- var server = _Server__WEBPACK_IMPORTED_MODULE_10__[/* AllServers */ "b"][property];
-
- //Reset each server's RAM usage to 0
- server.ramUsed = 0;
-
- //Reset modules on all scripts
- for (var i = 0; i < server.scripts.length; ++i) {
- server.scripts[i].module = "";
- }
-
- if (skipScriptLoad) {
- //Start game with no scripts
- server.runningScripts.length = 0;
- } else {
- for (var j = 0; j < server.runningScripts.length; ++j) {
- count++;
- server.runningScripts[j].scriptRef.module = "";
- Object(_NetscriptWorker__WEBPACK_IMPORTED_MODULE_6__[/* addWorkerScript */ "c"])(server.runningScripts[j], server);
-
- //Offline production
- total += scriptCalculateOfflineProduction(server.runningScripts[j]);
- }
- }
- }
- }
- return total;
- console.log("Loaded " + count.toString() + " running scripts");
-}
-
-function scriptCalculateOfflineProduction(runningScriptObj) {
- //The Player object stores the last update time from when we were online
- var thisUpdate = new Date().getTime();
- var lastUpdate = _Player__WEBPACK_IMPORTED_MODULE_7__[/* Player */ "a"].lastUpdate;
- var timePassed = (thisUpdate - lastUpdate) / 1000; //Seconds
-
- //Calculate the "confidence" rating of the script's true production. This is based
- //entirely off of time. We will arbitrarily say that if a script has been running for
- //4 hours (14400 sec) then we are completely confident in its ability
- var confidence = (runningScriptObj.onlineRunningTime) / 14400;
- if (confidence >= 1) {confidence = 1;}
-
- //Data map: [MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
-
- //Grow
- for (var ip in runningScriptObj.dataMap) {
- if (runningScriptObj.dataMap.hasOwnProperty(ip)) {
- if (runningScriptObj.dataMap[ip][2] == 0 || runningScriptObj.dataMap[ip][2] == null) {continue;}
- var serv = _Server__WEBPACK_IMPORTED_MODULE_10__[/* AllServers */ "b"][ip];
- if (serv == null) {continue;}
- var timesGrown = Math.round(0.5 * runningScriptObj.dataMap[ip][2] / runningScriptObj.onlineRunningTime * timePassed);
- console.log(runningScriptObj.filename + " called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
- runningScriptObj.log("Called grow() on " + serv.hostname + " " + timesGrown + " times while offline");
- var growth = Object(_Server__WEBPACK_IMPORTED_MODULE_10__[/* processSingleServerGrowth */ "k"])(serv, timesGrown * 450);
- runningScriptObj.log(serv.hostname + " grown by " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_17__["numeralWrapper"].format(growth * 100 - 100, '0.000000%') + " from grow() calls made while offline");
- }
- }
-
- var totalOfflineProduction = 0;
- for (var ip in runningScriptObj.dataMap) {
- if (runningScriptObj.dataMap.hasOwnProperty(ip)) {
- if (runningScriptObj.dataMap[ip][0] == 0 || runningScriptObj.dataMap[ip][0] == null) {continue;}
- var serv = _Server__WEBPACK_IMPORTED_MODULE_10__[/* AllServers */ "b"][ip];
- if (serv == null) {continue;}
- var production = 0.5 * runningScriptObj.dataMap[ip][0] / runningScriptObj.onlineRunningTime * timePassed;
- production *= confidence;
- if (production > serv.moneyAvailable) {
- production = serv.moneyAvailable;
- }
- totalOfflineProduction += production;
- _Player__WEBPACK_IMPORTED_MODULE_7__[/* Player */ "a"].gainMoney(production);
- console.log(runningScriptObj.filename + " generated $" + production + " while offline by hacking " + serv.hostname);
- runningScriptObj.log(runningScriptObj.filename + " generated $" + production + " while offline by hacking " + serv.hostname);
- serv.moneyAvailable -= production;
- if (serv.moneyAvailable < 0) {serv.moneyAvailable = 0;}
- if (isNaN(serv.moneyAvailable)) {serv.moneyAvailable = 0;}
- }
- }
-
- //Offline EXP gain
- //A script's offline production will always be at most half of its online production.
- var expGain = 0.5 * (runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime) * timePassed;
- expGain *= confidence;
-
- _Player__WEBPACK_IMPORTED_MODULE_7__[/* Player */ "a"].gainHackingExp(expGain);
-
- //Update script stats
- runningScriptObj.offlineMoneyMade += totalOfflineProduction;
- runningScriptObj.offlineRunningTime += timePassed;
- runningScriptObj.offlineExpGained += expGain;
-
- //Fortify a server's security based on how many times it was hacked
- for (var ip in runningScriptObj.dataMap) {
- if (runningScriptObj.dataMap.hasOwnProperty(ip)) {
- if (runningScriptObj.dataMap[ip][1] == 0 || runningScriptObj.dataMap[ip][1] == null) {continue;}
- var serv = _Server__WEBPACK_IMPORTED_MODULE_10__[/* AllServers */ "b"][ip];
- if (serv == null) {continue;}
- var timesHacked = Math.round(0.5 * runningScriptObj.dataMap[ip][1] / runningScriptObj.onlineRunningTime * timePassed);
- console.log(runningScriptObj.filename + " hacked " + serv.hostname + " " + timesHacked + " times while offline");
- runningScriptObj.log("Hacked " + serv.hostname + " " + timesHacked + " times while offline");
- serv.fortify(_Constants__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ServerFortifyAmount * timesHacked);
- }
- }
-
- //Weaken
- for (var ip in runningScriptObj.dataMap) {
- if (runningScriptObj.dataMap.hasOwnProperty(ip)) {
- if (runningScriptObj.dataMap[ip][3] == 0 || runningScriptObj.dataMap[ip][3] == null) {continue;}
- var serv = _Server__WEBPACK_IMPORTED_MODULE_10__[/* AllServers */ "b"][ip];
- if (serv == null) {continue;}
- var timesWeakened = Math.round(0.5 * runningScriptObj.dataMap[ip][3] / runningScriptObj.onlineRunningTime * timePassed);
- console.log(runningScriptObj.filename + " called weaken() on " + serv.hostname + " " + timesWeakened + " times while offline");
- runningScriptObj.log("Called weaken() on " + serv.hostname + " " + timesWeakened + " times while offline");
- serv.weaken(_Constants__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ServerWeakenAmount * timesWeakened);
- }
- }
-
- return totalOfflineProduction;
-}
-
-//Returns a RunningScript object matching the filename and arguments on the
-//designated server, and false otherwise
-function findRunningScript(filename, args, server) {
- for (var i = 0; i < server.runningScripts.length; ++i) {
- if (server.runningScripts[i].filename == filename &&
- Object(_utils_helpers_compareArrays__WEBPACK_IMPORTED_MODULE_20__["compareArrays"])(server.runningScripts[i].args, args)) {
- return server.runningScripts[i];
- }
- }
- return null;
-}
-
-function RunningScript(script, args) {
- if (script == null || script == undefined) {return;}
- this.filename = script.filename;
- this.args = args;
- this.scriptRef = script;
- this.server = script.server; //IP Address only
-
- this.logs = []; //Script logging. Array of strings, with each element being a log entry
- this.logUpd = false;
-
- //Stats to display on the Scripts menu, and used to determine offline progress
- this.offlineRunningTime = 0.01; //Seconds
- this.offlineMoneyMade = 0;
- this.offlineExpGained = 0;
- this.onlineRunningTime = 0.01; //Seconds
- this.onlineMoneyMade = 0;
- this.onlineExpGained = 0;
-
- this.threads = 1;
-
- //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
- this.dataMap = new AllServersMap([0, 0, 0, 0], true);
-}
-
-RunningScript.prototype.log = function(txt) {
- if (this.logs.length > _Settings_Settings__WEBPACK_IMPORTED_MODULE_11__["Settings"].MaxLogCapacity) {
- //Delete first element and add new log entry to the end.
- //TODO Eventually it might be better to replace this with circular array
- //to improve performance
- this.logs.shift();
- }
- let logEntry = txt;
- if (_Fconf__WEBPACK_IMPORTED_MODULE_2__[/* FconfSettings */ "a"].ENABLE_TIMESTAMPS) {
- logEntry = "[" + Object(_utils_helpers_getTimestamp__WEBPACK_IMPORTED_MODULE_22__["getTimestamp"])() + "] " + logEntry;
- }
- this.logs.push(logEntry);
- this.logUpd = true;
-}
-
-RunningScript.prototype.displayLog = function() {
- for (var i = 0; i < this.logs.length; ++i) {
- Object(_ui_postToTerminal__WEBPACK_IMPORTED_MODULE_13__["post"])(this.logs[i]);
- }
-}
-
-RunningScript.prototype.clearLog = function() {
- this.logs.length = 0;
-}
-
-//Update the moneyStolen and numTimesHack maps when hacking
-RunningScript.prototype.recordHack = function(serverIp, moneyGained, n=1) {
- if (this.dataMap == null) {
- //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
- this.dataMap = new AllServersMap([0, 0, 0, 0], true);
- }
- this.dataMap[serverIp][0] += moneyGained;
- this.dataMap[serverIp][1] += n;
-}
-
-//Update the grow map when calling grow()
-RunningScript.prototype.recordGrow = function(serverIp, n=1) {
- if (this.dataMap == null) {
- //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
- this.dataMap = new AllServersMap([0, 0, 0, 0], true);
- }
- this.dataMap[serverIp][2] += n;
-}
-
-//Update the weaken map when calling weaken() {
-RunningScript.prototype.recordWeaken = function(serverIp, n=1) {
- if (this.dataMap == null) {
- //[MoneyStolen, NumTimesHacked, NumTimesGrown, NumTimesWeaken]
- this.dataMap = new AllServersMap([0, 0, 0, 0], true);
- }
- this.dataMap[serverIp][3] += n;
-}
-
-RunningScript.prototype.toJSON = function() {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_19__["Generic_toJSON"])("RunningScript", this);
-}
-
-
-RunningScript.fromJSON = function(value) {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_19__["Generic_fromJSON"])(RunningScript, value.data);
-}
-
-_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_19__["Reviver"].constructors.RunningScript = RunningScript;
-
-//Creates an object that creates a map/dictionary with the IP of each existing server as
-//a key. Initializes every key with a specified value that can either by a number or an array
-function AllServersMap(arr=false, filterOwned=false) {
- for (var ip in _Server__WEBPACK_IMPORTED_MODULE_10__[/* AllServers */ "b"]) {
- if (_Server__WEBPACK_IMPORTED_MODULE_10__[/* AllServers */ "b"].hasOwnProperty(ip)) {
- if (filterOwned && (_Server__WEBPACK_IMPORTED_MODULE_10__[/* AllServers */ "b"][ip].purchasedByPlayer || _Server__WEBPACK_IMPORTED_MODULE_10__[/* AllServers */ "b"][ip].hostname === "home")) {
- continue;
- }
- if (arr) {
- this[ip] = [0, 0, 0, 0];
- } else {
- this[ip] = 0;
- }
- }
- }
-}
-
-AllServersMap.prototype.toJSON = function() {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_19__["Generic_toJSON"])("AllServersMap", this);
-}
-
-
-AllServersMap.fromJSON = function(value) {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_19__["Generic_fromJSON"])(AllServersMap, value.data);
-}
-
-_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_19__["Reviver"].constructors.AllServersMap = AllServersMap;
-
-
-
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 72)))
-
-/***/ }),
-/* 34 */
-/*!*****************************************!*\
- !*** ./src/Company/CompanyPositions.ts ***!
- \*****************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-// Constructs all CompanyPosition objects using the metadata in data/companypositions.ts
-const CompanyPositionsMetadata_1 = __webpack_require__(/*! ./data/CompanyPositionsMetadata */ 257);
-const CompanyPosition_1 = __webpack_require__(/*! ./CompanyPosition */ 105);
-exports.CompanyPositions = {};
-function addCompanyPosition(params) {
- if (exports.CompanyPositions[params.name] != null) {
- console.warn(`Duplicate Company Position being defined: ${params.name}`);
- }
- exports.CompanyPositions[params.name] = new CompanyPosition_1.CompanyPosition(params);
-}
-CompanyPositionsMetadata_1.companyPositionMetadata.forEach((e) => {
- addCompanyPosition(e);
-});
-
-
-/***/ }),
-/* 35 */
-/*!****************************!*\
- !*** ./src/Bladeburner.js ***!
- \****************************/
-/*! exports provided: Bladeburner */
-/*! exports used: Bladeburner */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Bladeburner; });
-/* harmony import */ var _Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentation/Augmentations */ 14);
-/* harmony import */ var _Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_0__);
-/* harmony import */ var _Augmentation_data_AugmentationNames__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Augmentation/data/AugmentationNames */ 6);
-/* harmony import */ var _Augmentation_data_AugmentationNames__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_Augmentation_data_AugmentationNames__WEBPACK_IMPORTED_MODULE_1__);
-/* harmony import */ var _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./BitNode/BitNodeMultipliers */ 10);
-/* harmony import */ var _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_2__);
-/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Constants */ 1);
-/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_Constants__WEBPACK_IMPORTED_MODULE_3__);
-/* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./engine */ 11);
-/* harmony import */ var _Faction_Faction__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Faction/Faction */ 62);
-/* harmony import */ var _Faction_Faction__WEBPACK_IMPORTED_MODULE_5___default = /*#__PURE__*/__webpack_require__.n(_Faction_Faction__WEBPACK_IMPORTED_MODULE_5__);
-/* harmony import */ var _Faction_Factions__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Faction/Factions */ 16);
-/* harmony import */ var _Faction_Factions__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_Faction_Factions__WEBPACK_IMPORTED_MODULE_6__);
-/* harmony import */ var _Faction_FactionHelpers__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Faction/FactionHelpers */ 51);
-/* harmony import */ var _Locations__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Locations */ 5);
-/* harmony import */ var _Locations__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_Locations__WEBPACK_IMPORTED_MODULE_8__);
-/* harmony import */ var _Player__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Player */ 0);
-/* harmony import */ var _RedPill__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./RedPill */ 67);
-/* harmony import */ var _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./ui/numeralFormat */ 4);
-/* harmony import */ var _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_11___default = /*#__PURE__*/__webpack_require__.n(_ui_numeralFormat__WEBPACK_IMPORTED_MODULE_11__);
-/* harmony import */ var _utils_helpers_keyCodes__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/helpers/keyCodes */ 29);
-/* harmony import */ var _utils_helpers_keyCodes__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_keyCodes__WEBPACK_IMPORTED_MODULE_12__);
-/* harmony import */ var _utils_helpers_createProgressBarText__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../utils/helpers/createProgressBarText */ 90);
-/* harmony import */ var _utils_helpers_createProgressBarText__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_createProgressBarText__WEBPACK_IMPORTED_MODULE_13__);
-/* harmony import */ var _utils_DialogBox__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../utils/DialogBox */ 9);
-/* harmony import */ var _utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/uiHelpers/removeChildrenFromElement */ 27);
-/* harmony import */ var _utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_15__);
-/* harmony import */ var _utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../utils/JSONReviver */ 15);
-/* harmony import */ var _utils_helpers_addOffset__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../utils/helpers/addOffset */ 74);
-/* harmony import */ var _utils_helpers_addOffset__WEBPACK_IMPORTED_MODULE_17___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_addOffset__WEBPACK_IMPORTED_MODULE_17__);
-/* harmony import */ var _utils_uiHelpers_appendLineBreaks__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../utils/uiHelpers/appendLineBreaks */ 59);
-/* harmony import */ var _utils_uiHelpers_appendLineBreaks__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(_utils_uiHelpers_appendLineBreaks__WEBPACK_IMPORTED_MODULE_18__);
-/* harmony import */ var _utils_helpers_clearObject__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utils/helpers/clearObject */ 87);
-/* harmony import */ var _utils_helpers_clearObject__WEBPACK_IMPORTED_MODULE_19___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_clearObject__WEBPACK_IMPORTED_MODULE_19__);
-/* harmony import */ var _utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/uiHelpers/createElement */ 2);
-/* harmony import */ var _utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20___default = /*#__PURE__*/__webpack_require__.n(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__);
-/* harmony import */ var _utils_uiHelpers_createPopup__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../utils/uiHelpers/createPopup */ 40);
-/* harmony import */ var _utils_uiHelpers_createPopup__WEBPACK_IMPORTED_MODULE_21___default = /*#__PURE__*/__webpack_require__.n(_utils_uiHelpers_createPopup__WEBPACK_IMPORTED_MODULE_21__);
-/* harmony import */ var _ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./ui/navigationTracking */ 13);
-/* harmony import */ var _ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22___default = /*#__PURE__*/__webpack_require__.n(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22__);
-/* harmony import */ var _utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ../utils/helpers/exceptionAlert */ 42);
-/* harmony import */ var _utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_23___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_23__);
-/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ../utils/StringHelperFunctions */ 3);
-/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__);
-/* harmony import */ var _utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ../utils/helpers/getRandomInt */ 17);
-/* harmony import */ var _utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__);
-/* harmony import */ var _utils_helpers_getTimestamp__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../utils/helpers/getTimestamp */ 101);
-/* harmony import */ var _utils_helpers_getTimestamp__WEBPACK_IMPORTED_MODULE_26___default = /*#__PURE__*/__webpack_require__.n(_utils_helpers_getTimestamp__WEBPACK_IMPORTED_MODULE_26__);
-/* harmony import */ var _utils_uiHelpers_removeElement__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../utils/uiHelpers/removeElement */ 66);
-/* harmony import */ var _utils_uiHelpers_removeElement__WEBPACK_IMPORTED_MODULE_27___default = /*#__PURE__*/__webpack_require__.n(_utils_uiHelpers_removeElement__WEBPACK_IMPORTED_MODULE_27__);
-/* harmony import */ var _utils_uiHelpers_removeElementById__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ../utils/uiHelpers/removeElementById */ 23);
-/* harmony import */ var _utils_uiHelpers_removeElementById__WEBPACK_IMPORTED_MODULE_28___default = /*#__PURE__*/__webpack_require__.n(_utils_uiHelpers_removeElementById__WEBPACK_IMPORTED_MODULE_28__);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-var CityNames = ["Aevum", "Chongqing", "Sector-12", "New Tokyo", "Ishima", "Volhaven"];
-
-var CyclesPerSecond = 5; //Game cycle is 200 ms
-
-var StaminaGainPerSecond = 0.0085;
-var BaseStaminaLoss = 0.285; //Base stamina loss per action. Increased based on difficulty
-var MaxStaminaToGainFactor = 70000; //Max Stamina is divided by this to get bonus stamina gain
-
-var DifficultyToTimeFactor = 10; //Action Difficulty divided by this to get base action time
-
-//The difficulty multiplier affects stamina loss and hp loss of an action. Also affects
-//experience gain. Its formula is:
-//difficulty ^ exponentialFactor + difficulty / linearFactor
-var DiffMultExponentialFactor = 0.28;
-var DiffMultLinearFactor = 650;
-
-var EffAgiLinearFactor = 40e3;
-var EffDexLinearFactor = 40e3;
-var EffAgiExponentialFactor = 0.032;
-var EffDexExponentialFactor = 0.03;
-
-var BaseRecruitmentTimeNeeded = 300; //Base time needed (s) to complete a Recruitment action
-
-var PopulationThreshold = 1e9; //Population at which success rates start being affected
-var ChaosThreshold = 50; //City chaos level after which it starts making tasks harder
-
-var BaseStatGain = 1; //Base stat gain per second
-var BaseIntGain = 0.001; //Base intelligence stat gain
-
-var ActionCountGrowthPeriod = 300; //Time (s) it takes for action count to grow by its specified value
-
-var RankToFactionRepFactor = 2; //Delta Faction Rep = this * Delta Rank
-var RankNeededForFaction = 25;
-
-var ContractSuccessesPerLevel = 3.5; //How many successes you need to level up a contract
-var OperationSuccessesPerLevel = 3; //How many successes you need to level up an op
-
-var RanksPerSkillPoint = 4; //How many ranks needed to get 1 Skill Point
-
-var ContractBaseMoneyGain = 50e3; //Base Money Gained per contract
-
-//DOM related variables
-var ActiveActionCssClass = "bladeburner-active-action";
-
-//Console related stuff
-var consoleHistoryIndex = 0;
-var consoleHelpText = {
- helpList:"Use 'help [command]' to get more information about a particular Bladeburner console command.
" +
- "automate [var] [val] [hi/low] Configure simple automation for Bladeburner tasks " +
- "clear/cls Clear the console " +
- "help [cmd] Display this help text, or help text for a specific command " +
- "log [en/dis] [type] Enable or disable logging for events and actions " +
- "skill [action] [name] Level or display info about your Bladeburner skills " +
- "start [type] [name] Start a Bladeburner action/task " +
- "stop Stops your current Bladeburner action/task ",
- automate:"automate [var] [val] [hi/low]
" +
- "A simple way to automate your Bladeburner actions. This console command can be used " +
- "to automatically start an action when your stamina rises above a certain threshold, and " +
- "automatically switch to another action when your stamina drops below another threshold.
" +
- "automate status - Check the current status of your automation and get a brief description of what it'll do " +
- "automate en - Enable the automation feature " +
- "automate dis - Disable the automation feature
" +
- "There are four properties that must be set for this automation to work properly. Here is how to set them:
" +
- "automate stamina 100 high " +
- "automate contract Tracking high " +
- "automate stamina 50 low " +
- 'automate general "Field Analysis" low
' +
- "Using the four console commands above will set the automation to perform Tracking contracts " +
- "if your stamina is 100 or higher, and then switch to Field Analysis if your stamina drops below " +
- "50. Note that when setting the action, the name of the action is CASE-SENSITIVE. It must " +
- "exactly match whatever the name is in the UI.",
- clear:"clear
Clears the console",
- cls:"cls
Clears the console",
- help:"help [command]
" +
- "Running 'help' with no arguments displays the general help text, which lists all console commands " +
- "and a brief description of what they do. A command can be specified to get more specific help text " +
- "about that particular command. For example:
" +
- "help automate
" +
- "will display specific information about using the automate console command",
- log:"log [en/dis] [type]
" +
- "Enable or disable logging. By default, the results of completing actions such as contracts/operations are logged " +
- "in the console. There are also random events that are logged in the console as well. The five categories of " +
- "things that get logged are:
" +
- "The logging for these categories can be enabled or disabled like so:
" +
- "log dis contracts - Disables logging that occurs when contracts are completed " +
- "log en contracts - Enables logging that occurs when contracts are completed " +
- "log dis events - Disables logging for Bladeburner random events
" +
- "Logging can be universally enabled/disabled using the 'all' keyword:
" +
- "log dis all " +
- "log en all",
- skill:"skill [action] [name]
" +
- "Level or display information about your skills.
" +
- "To display information about all of your skills and your multipliers, use:
" +
- "skill list
" +
- "To display information about a specific skill, specify the name of the skill afterwards. " +
- "Note that the name of the skill is case-sensitive. Enter it exactly as seen in the UI. If " +
- "the name of the skill has whitespace, enclose the name of the skill in double quotation marks:
" +
- "skill list Reaper " +
- 'skill list "Digital Observer"
' +
- "This console command can also be used to level up skills:
" +
- "Start an action. An action is specified by its type and its name. The " +
- "name is case-sensitive. It must appear exactly as it does in the UI. If " +
- "the name of the action has whitespace, enclose it in double quotation marks. " +
- "Valid action types include:
" +
- "Stop your current action and go idle",
-}
-
-//Keypresses for Console
-$(document).keydown(function(event) {
- if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22__["Page"].Bladeburner)) {
- //if (DomElems.consoleInput && !event.ctrlKey && !event.shiftKey && !event.altKey) {
- // DomElems.consoleInput.focus();
- //}
-
- if (!(_Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].bladeburner instanceof Bladeburner)) {return;}
- let consoleHistory = _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].bladeburner.consoleHistory;
-
- //NOTE: Keycodes imported from Terminal.js
- if (event.keyCode === _utils_helpers_keyCodes__WEBPACK_IMPORTED_MODULE_12__["KEY"].ENTER) {
- event.preventDefault();
- var command = DomElems.consoleInput.value;
- if (command.length > 0) {
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].bladeburner.postToConsole("> " + command);
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].bladeburner.resetConsoleInput();
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].bladeburner.executeConsoleCommands(command);
- }
- }
-
- if (event.keyCode === _utils_helpers_keyCodes__WEBPACK_IMPORTED_MODULE_12__["KEY"].UPARROW) {
- if (DomElems.consoleInput == null) {return;}
- var i = consoleHistoryIndex;
- var len = consoleHistory.length;
-
- if (len === 0) {return;}
- if (i < 0 || i > len) {
- consoleHistoryIndex = len;
- }
-
- if (i !== 0) {
- --consoleHistoryIndex;
- }
-
- var prevCommand = consoleHistory[consoleHistoryIndex];
- DomElems.consoleInput.value = prevCommand;
- setTimeout(function(){DomElems.consoleInput.selectionStart = DomElems.consoleInput.selectionEnd = 10000; }, 0);
- }
-
- if (event.keyCode === _utils_helpers_keyCodes__WEBPACK_IMPORTED_MODULE_12__["KEY"].DOWNARROW) {
- if (DomElems.consoleInput == null) {return;}
- var i = consoleHistoryIndex;
- var len = consoleHistory.length;
-
- if (len == 0) {return;}
- if (i < 0 || i > len) {
- consoleHistoryIndex = len;
- }
-
- //Latest command, put nothing
- if (i == len || i == len-1) {
- consoleHistoryIndex = len;
- DomElems.consoleInput.value = "";
- } else {
- ++consoleHistoryIndex;
- var prevCommand = consoleHistory[consoleHistoryIndex];
- DomElems.consoleInput.value = prevCommand;
- }
- }
- }
-});
-
-function City(params={}) {
- this.name = params.name ? params.name : _Locations__WEBPACK_IMPORTED_MODULE_8__["Locations"].Sector12;
-
- //Synthoid population and estimate
- this.pop = params.pop ? params.pop : Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(800e6, 1.2*PopulationThreshold);
- this.popEst = this.pop * (Math.random() + 0.5);
-
- //Number of Synthoid communities population and estimate
- this.comms = params.comms ? params.comms : Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(5, 100);
- this.commsEst = this.comms + Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(-5, 5);
- if (this.commsEst < 0) {this.commsEst = 0;}
- this.chaos = 0;
-}
-
-City.prototype.improvePopulationEstimateByCount = function(n) {
- if (isNaN(n)) {throw new Error("NaN passeed into City.improvePopulationEstimateByCount()");}
- if (this.popEst < this.pop) {
- this.popEst += n;
- if (this.popEst > this.pop) {this.popEst = this.pop;}
- } else if (this.popEst > this.pop) {
- this.popEst -= n;
- if (this.popEst < this.pop) {this.popEst = this.pop;}
- }
-}
-
-//@p is the percentage, not the multiplier. e.g. pass in p = 5 for 5%
-City.prototype.improvePopulationEstimateByPercentage = function(p, skillMult=1) {
- p = p*skillMult;
- if (isNaN(p)) {throw new Error("NaN passed into City.improvePopulationEstimateByPercentage()");}
- if (this.popEst < this.pop) {
- ++this.popEst; //In case estimate is 0
- this.popEst *= (1 + (p/100));
- if (this.popEst > this.pop) {this.popEst = this.pop;}
- } else if (this.popEst > this.pop) {
- this.popEst *= (1 - (p/100));
- if (this.popEst < this.pop) {this.popEst = this.pop;}
- }
-}
-
-City.prototype.improveCommunityEstimate = function(n=1) {
- if (isNaN(n)) {throw new Error("NaN passed into City.improveCommunityEstimate()");}
- if (this.commsEst < this.comms) {
- this.commsEst += n;
- if (this.commsEst > this.comms) {this.commsEst = this.comms;}
- } else if (this.commsEst > this.comms) {
- this.commsEst -= n;
- if (this.commsEst < this.comms) {this.commsEst = this.comms;}
- }
-}
-
-//@params options:
-// estChange(int): How much the estimate should change by
-// estOffset(int): Add offset to estimate (offset by percentage)
-City.prototype.changePopulationByCount = function(n, params={}) {
- if (isNaN(n)) {throw new Error("NaN passed into City.changePopulationByCount()");}
- this.pop += n;
- if (params.estChange && !isNaN(params.estChange)) {this.popEst += params.estChange;}
- if (params.estOffset) {
- this.popEst = Object(_utils_helpers_addOffset__WEBPACK_IMPORTED_MODULE_17__["addOffset"])(this.popEst, params.estOffset);
- }
- this.popEst = Math.max(this.popEst, 0);
-}
-
-//@p is the percentage, not the multiplier. e.g. pass in p = 5 for 5%
-//@params options:
-// changeEstEqually(bool) - Change the population estimate by an equal amount
-// nonZero (bool) - Set to true to ensure that population always changes by at least 1
-City.prototype.changePopulationByPercentage = function(p, params={}) {
- if (isNaN(p)) {throw new Error("NaN passed into City.changePopulationByPercentage()");}
- if (p === 0) {return;}
- var change = Math.round(this.pop * (p/100));
-
- //Population always changes by at least 1
- if (params.nonZero && change === 0) {
- p > 0 ? change = 1 : change = -1;
- }
-
- this.pop += change;
- if (params.changeEstEqually) {
- this.popEst += change;
- if (this.popEst < 0) {this.popEst = 0;}
- }
- return change;
-}
-
-City.prototype.changeChaosByCount = function(n) {
- if (isNaN(n)) {throw new Error("NaN passed into City.changeChaosByCount()");}
- if (n === 0) {return;}
- this.chaos += n;
- if (this.chaos < 0) {this.chaos = 0;}
-}
-
-//@p is the percentage, not the multiplier (e.g. pass in p = 5 for 5%)
-City.prototype.changeChaosByPercentage = function(p) {
- if (isNaN(p)) {throw new Error("NaN passed into City.chaosChaosByPercentage()");}
- if (p === 0) {return;}
- var change = this.chaos * (p/100);
- this.chaos += change;
- if (this.chaos < 0) {this.chaos = 0;}
-}
-
-City.prototype.toJSON = function() {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Generic_toJSON"])("City", this);
-}
-City.fromJSON = function(value) {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Generic_fromJSON"])(City, value.data);
-}
-_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Reviver"].constructors.City = City;
-
-function Skill(params={name:"foo", desc:"foo"}) {
- if (params.name) {
- this.name = params.name;
- } else {
- throw new Error("Failed to initialize Bladeburner Skill. No name was specified in ctor");
- }
- if (params.desc) {
- this.desc = params.desc;
- } else {
- throw new Error("Failed to initialize Bladeburner Skills. No desc was specified in ctor");
- }
- this.baseCost = params.baseCost ? params.baseCost : 1; //Cost is in Skill Points
- this.costInc = params.costInc ? params.costInc : 1; //Additive cost increase per level
-
- if (params.maxLvl) {this.maxLvl = params.maxLvl;}
-
- //These benefits are additive. So total multiplier will be level (handled externally) times the
- //effects below
- if (params.successChanceAll) {this.successChanceAll = params.successChanceAll;}
- if (params.successChanceStealth) {this.successChanceStealth = params.successChanceStealth;}
- if (params.successChanceKill) {this.successChanceKill = params.successChanceKill;}
- if (params.successChanceContract) {this.successChanceContract = params.successChanceContract;}
- if (params.successChanceOperation) {this.successChanceOperation = params.successChanceOperation;}
-
- //This multiplier affects everything that increases synthoid population/community estimate
- //e.g. Field analysis, Investigation Op, Undercover Op
- if (params.successChanceEstimate) {this.successChanceEstimate = params.successChanceEstimate;}
-
- if (params.actionTime) {this.actionTime = params.actionTime;}
- if (params.effHack) {this.effHack = params.effHack;}
- if (params.effStr) {this.effStr = params.effStr;}
- if (params.effDef) {this.effDef = params.effDef;}
- if (params.effDex) {this.effDex = params.effDex;}
- if (params.effAgi) {this.effAgi = params.effAgi;}
- if (params.effCha) {this.effCha = params.effCha;}
-
- if (params.stamina) {this.stamina = params.stamina;}
-
- //Equipment
- if (params.weaponAbility) {this.weaponAbility = params.weaponAbility;}
- if (params.gunAbility) {this.gunAbility = params.gunAbility;}
-}
-
-Skill.prototype.calculateCost = function(currentLevel) {
- return Math.floor((this.baseCost + (currentLevel * this.costInc)) * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_2__["BitNodeMultipliers"].BladeburnerSkillCost);
-}
-var Skills = {};
-var SkillNames = {
- BladesIntuition: "Blade's Intuition",
- Reaper: "Reaper",
- Cloak: "Cloak",
- Marksman: "Marksman",
- WeaponProficiency: "Weapon Proficiency",
- Overclock: "Overclock",
- EvasiveSystem: "Evasive System",
- ShortCircuit: "Short-Circuit",
- DigitalObserver: "Digital Observer",
- Datamancer: "Datamancer",
- Tracer: "Tracer",
- CybersEdge: "Cyber's Edge"
-}
-
-//Base Class for Contracts, Operations, and BlackOps
-function Action(params={}) {
- this.name = params.name ? params.name : "";
- this.desc = params.desc ? params.desc : "";
-
- //Difficulty scales with level
- //Exact formula is not set in stone
- //Initial design: baseDifficulty * (difficultyFac ^ level)?
- //difficulty Fac is slightly greater than 1
- this.level = 1;
- this.maxLevel = 1;
- this.autoLevel = true;
- this.baseDifficulty = params.baseDifficulty ? Object(_utils_helpers_addOffset__WEBPACK_IMPORTED_MODULE_17__["addOffset"])(params.baseDifficulty, 10) : 100;
- this.difficultyFac = params.difficultyFac ? params.difficultyFac : 1.01;
-
- //Rank increase/decrease is affected by this exponent
- this.rewardFac = params.rewardFac ? params.rewardFac : 1.02;
-
- this.successes = 0;
- this.failures = 0;
-
- //All of these scale with level/difficulty
- this.rankGain = params.rankGain ? params.rankGain : 0;
- if (params.rankLoss) {this.rankLoss = params.rankLoss;}
- if (params.hpLoss) {
- this.hpLoss = params.hpLoss;
- this.hpLost = 0;
- }
-
- //Action Category. Current categories are stealth and kill
- this.isStealth = params.isStealth ? true : false;
- this.isKill = params.isKill ? true : false;
-
- //Number of this contract remaining, and its growth rate
- //Growth rate is an integer and the count will increase by that integer every "cycle"
- this.count = params.count ? params.count : Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(1e3, 25e3);
- this.countGrowth = params.countGrowth ? params.countGrowth : Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(1, 5);
-
- //Weighting of each stat in determining action success rate
- var defaultWeights = {hack:1/7,str:1/7,def:1/7,dex:1/7,agi:1/7,cha:1/7,int:1/7};
- this.weights = params.weights ? params.weights : defaultWeights;
-
- //Check to make sure weights are summed properly
- var sum = 0;
- for (var weight in this.weights) {
- if (this.weights.hasOwnProperty(weight)) {
- sum += this.weights[weight];
- }
- }
- if (sum - 1 >= 10 * Number.EPSILON) {
- throw new Error("Invalid weights when constructing Action " + this.name +
- ". The weights should sum up to 1. They sum up to :" + 1);
- }
-
- //Diminishing returns of stats (stat ^ decay where 0 <= decay <= 1)
- var defaultDecays = {hack:0.9,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.9,int:0.9};
- this.decays = params.decays ? params.decays : defaultDecays;
- for (var decay in this.decays) {
- if (this.decays.hasOwnProperty(decay)) {
- if (this.decays[decay] > 1) {
- throw new Error("Invalid decays when constructing " +
- "Action " + this.name + ". " +
- "Decay value cannot be greater than 1");
- }
- }
- }
-}
-
-Action.prototype.getDifficulty = function() {
- var difficulty = this.baseDifficulty * Math.pow(this.difficultyFac, this.level-1);
- if (isNaN(difficulty)) {throw new Error("Calculated NaN in Action.getDifficulty()");}
- return difficulty;
-}
-
-//@inst - Bladeburner Object
-//@params - options:
-// est (bool): Get success chance estimate instead of real success chance
-Action.prototype.getSuccessChance = function(inst, params={}) {
- if (inst == null) {throw new Error("Invalid Bladeburner instance passed into Action.getSuccessChance");}
- var difficulty = this.getDifficulty();
- var competence = 0;
- for (var stat in this.weights) {
- if (this.weights.hasOwnProperty(stat)) {
- var playerStatLvl = _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].queryStatFromString(stat);
- var key = "eff" + stat.charAt(0).toUpperCase() + stat.slice(1);
- var effMultiplier = inst.skillMultipliers[key];
- if (effMultiplier == null) {
- console.log("ERROR: Failed to find Bladeburner Skill multiplier for: " + stat);
- effMultiplier = 1;
- }
- competence += (this.weights[stat] * Math.pow(effMultiplier*playerStatLvl, this.decays[stat]));
- }
- }
- competence *= inst.calculateStaminaPenalty();
-
- //For Operations, factor in team members
- if (this instanceof Operation || this instanceof BlackOperation) {
- if (this.teamCount && this.teamCount > 0) {
- this.teamCount = Math.min(this.teamCount, inst.teamSize);
- var teamMultiplier = Math.pow(this.teamCount, 0.05);
- competence *= teamMultiplier;
- }
- }
-
- //Lower city population results in lower chances
- if (!(this instanceof BlackOperation)) {
- var city = inst.getCurrentCity();
- if (params.est) {
- competence *= (city.popEst / PopulationThreshold);
- } else {
- competence *= (city.pop / PopulationThreshold);
- }
-
- //Too high of a chaos results in lower chances
- if (city.chaos > ChaosThreshold) {
- var diff = 1 + (city.chaos - ChaosThreshold);
- var mult = Math.pow(diff, 0.1);
- difficulty *= mult;
- }
-
- //For Raid Operations, no communities = fail
- if (this instanceof Operation && this.name === "Raid") {
- if (city.comms <= 0) {return 0;}
- }
- }
-
- //Factor skill multipliers into success chance
- competence *= inst.skillMultipliers.successChanceAll;
- if (this instanceof Operation || this instanceof BlackOperation) {
- competence *= inst.skillMultipliers.successChanceOperation;
- }
- if (this instanceof Contract) {
- competence *= inst.skillMultipliers.successChanceContract;
- }
- if (this.isStealth) {
- competence *= inst.skillMultipliers.successChanceStealth;
- }
- if (this.isKill) {
- competence *= inst.skillMultipliers.successChanceKill;
- }
-
- //Augmentation multiplier
- competence *= _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].bladeburner_success_chance_mult;
-
- if (isNaN(competence)) {throw new Error("Competence calculated as NaN in Action.getSuccessChance()");}
- return Math.min(1, competence / difficulty);
-}
-
-//Tests for success. Should be called when an action has completed
-// @inst - Bladeburner Object
-Action.prototype.attempt = function(inst) {
- return (Math.random() < this.getSuccessChance(inst));
-}
-
-Action.prototype.getActionTime = function(inst) {
- var difficulty = this.getDifficulty();
- var baseTime = difficulty / DifficultyToTimeFactor;
- var skillFac = inst.skillMultipliers.actionTime; //Always < 1
-
- var effAgility = _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].agility * inst.skillMultipliers.effAgi;
- var effDexterity = _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].dexterity * inst.skillMultipliers.effDex;
- var statFac = 0.5 * (Math.pow(effAgility, EffAgiExponentialFactor) +
- Math.pow(effDexterity, EffDexExponentialFactor) +
- (effAgility / EffAgiLinearFactor) +
- (effDexterity / EffDexLinearFactor)); //Always > 1
-
- baseTime = Math.max(1, baseTime * skillFac / statFac);
-
- if (this instanceof Contract) {
- return Math.ceil(baseTime);
- } else if (this instanceof Operation) {
- return Math.ceil(baseTime);
- } else if (this instanceof BlackOperation) {
- return Math.ceil(baseTime * 1.5);
- } else {
- throw new Error("Unrecognized Action Type in Action.getActionTime(this). Must be either Contract, Operation, or BlackOperation");
- }
-}
-
-Action.prototype.getSuccessesNeededForNextLevel = function(baseSuccessesPerLevel) {
- return Math.ceil((0.5) * (this.maxLevel) * (2 * baseSuccessesPerLevel + (this.maxLevel-1)));
-}
-
-Action.prototype.setMaxLevel = function(baseSuccessesPerLevel) {
- if (this.successes >= this.getSuccessesNeededForNextLevel(baseSuccessesPerLevel)) {
- ++this.maxLevel;
- }
-}
-
-Action.prototype.toJSON = function() {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Generic_toJSON"])("Action", this);
-}
-Action.fromJSON = function(value) {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Generic_fromJSON"])(Action, value.data);
-}
-_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Reviver"].constructors.Action = Action;
-var GeneralActions = {}; //Training, Field Analysis, Recruitment, etc.
-
-//Action Identifier
-var ActionTypes = Object.freeze({
- "Idle": 1,
- "Contract": 2,
- "Operation": 3,
- "BlackOp": 4,
- "BlackOperation": 4,
- "Training": 5,
- "Recruitment": 6,
- "FieldAnalysis": 7,
- "Field Analysis": 7
-});
-function ActionIdentifier(params={}) {
- if (params.name) {this.name = params.name;}
- if (params.type) {this.type = params.type;}
-}
-ActionIdentifier.prototype.toJSON = function() {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Generic_toJSON"])("ActionIdentifier", this);
-}
-ActionIdentifier.fromJSON = function(value) {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Generic_fromJSON"])(ActionIdentifier, value.data);
-}
-_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Reviver"].constructors.ActionIdentifier = ActionIdentifier;
-
-//Contracts
-function Contract(params={}) {
- Action.call(this, params);
-}
-Contract.prototype = Object.create(Action.prototype);
-Contract.prototype.toJSON = function() {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Generic_toJSON"])("Contract", this);
-}
-Contract.fromJSON = function(value) {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Generic_fromJSON"])(Contract, value.data);
-}
-_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Reviver"].constructors.Contract = Contract;
-
-//Operations
-function Operation(params={}) {
- Action.call(this, params);
- this.reqdRank = params.reqdRank ? params.reqdRank : 100;
- this.teamCount = params.teamCount ? params.teamCount : 0; //# of team members to use
-}
-Operation.prototype = Object.create(Action.prototype);
-Operation.prototype.toJSON = function() {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Generic_toJSON"])("Operation", this);
-}
-Operation.fromJSON = function(value) {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Generic_fromJSON"])(Operation, value.data);
-}
-_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Reviver"].constructors.Operation = Operation;
-
-//Black Operations
-function BlackOperation(params={}) {
- Operation.call(this, params);
-
- //Black ops are one time missions
- this.count = 1;
- this.countGrowth = 0;
-}
-BlackOperation.prototype = Object.create(Action.prototype);
-BlackOperation.prototype.toJSON = function() {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Generic_toJSON"])("BlackOperation", this);
-}
-BlackOperation.fromJSON = function(value) {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Generic_fromJSON"])(BlackOperation, value.data);
-}
-_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Reviver"].constructors.BlackOperation = BlackOperation;
-var BlackOperations = {};
-
-function Bladeburner(params={}) {
- this.numHosp = 0; //Number of hospitalizations
- this.moneyLost = 0; //Money lost due to hospitalizations
- this.rank = 0;
- this.maxRank = 0; //Used to determine skill points
-
- this.skillPoints = 0;
- this.totalSkillPoints = 0;
-
- this.teamSize = 0; //Number of team members
- this.teamLost = 0; //Number of team members lost
-
- this.storedCycles = 0;
-
- this.randomEventCounter = Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(240, 600); //4-10 minutes
-
- //These times are in seconds
- this.actionTimeToComplete = 0; //0 or -1 is an infinite running action (like training)
- this.actionTimeCurrent = 0;
-
- //ActionIdentifier Object
- var idleActionType = ActionTypes["Idle"];
- this.action = new ActionIdentifier({type:idleActionType});
-
- this.cities = {};
- for (var i = 0; i < CityNames.length; ++i) {
- this.cities[CityNames[i]] = new City({name:CityNames[i]});
- }
- this.city = _Locations__WEBPACK_IMPORTED_MODULE_8__["Locations"].Sector12;
-
- //Map of SkillNames -> level
- this.skills = {};
- this.skillMultipliers = {};
- this.updateSkillMultipliers(); //Calls resetSkillMultipliers()
-
- //Max Stamina is based on stats and Bladeburner-specific bonuses
- this.staminaBonus = 0; //Gained from training
- this.maxStamina = 0;
- this.calculateMaxStamina();
- this.stamina = this.maxStamina;
-
- //Contracts and Operations objects. These objects have unique
- //properties because they are randomized in each instance and have stats like
- //successes/failures, so they need to be saved/loaded by the game.
- this.contracts = {};
- this.operations = {};
-
- //Object that contains name of all Black Operations that have been completed
- this.blackops = {};
-
- //Flags for whether these actions should be logged to console
- this.logging = {
- general:true,
- contracts:true,
- ops:true,
- blackops:true,
- events:true,
- }
-
- //Simple automation values
- this.automateEnabled = false;
- this.automateActionHigh = 0;
- this.automateThreshHigh = 0; //Stamina Threshold
- this.automateActionLow = 0;
- this.automateThreshLow = 0; //Stamina Threshold
-
- //Console command history
- this.consoleHistory = [];
- this.consoleLogs = [];
-
- //Initialization
- initBladeburner();
- this.initializeDomElementRefs();
- if (params.new) {this.create();}
-}
-
-Bladeburner.prototype.prestige = function() {
- this.resetAction();
- var bladeburnerFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_6__["Factions"]["Bladeburners"];
- if (this.rank >= RankNeededForFaction) {
- Object(_Faction_FactionHelpers__WEBPACK_IMPORTED_MODULE_7__[/* joinFaction */ "c"])(bladeburnerFac);
- }
-}
-
-Bladeburner.prototype.create = function() {
- this.contracts["Tracking"] = new Contract({
- name:"Tracking",
- desc:"Identify and locate Synthoids. This contract involves reconnaissance " +
- "and information-gathering ONLY. Do NOT engage. Stealth is of the utmost importance.
" +
- "Successfully completing Tracking contracts will slightly improve your Synthoid population estimate for " +
- "whatever city you are currently in.",
- baseDifficulty:125,difficultyFac:1.02,rewardFac:1.041,
- rankGain:0.3, hpLoss:0.5,
- count:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(25, 500), countGrowth:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(5, 75)/10,
- weights:{hack:0,str:0.05,def:0.05,dex:0.35,agi:0.35,cha:0.1, int:0.05},
- decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.9, int:1},
- isStealth:true
- });
- this.contracts["Bounty Hunter"] = new Contract({
- name:"Bounty Hunter",
- desc:"Hunt down and capture fugitive Synthoids. These Synthoids are wanted alive.
" +
- "Successfully completing a Bounty Hunter contract will lower the population in your " +
- "current city, and will also increase its chaos level.",
- baseDifficulty:250, difficultyFac:1.04,rewardFac:1.085,
- rankGain:0.9, hpLoss:1,
- count:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(5, 500), countGrowth:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(5, 75)/10,
- weights:{hack:0,str:0.15,def:0.15,dex:0.25,agi:0.25,cha:0.1, int:0.1},
- decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.8, int:0.9},
- isKill:true
- });
- this.contracts["Retirement"] = new Contract({
- name:"Retirement",
- desc:"Hunt down and retire (kill) rogue Synthoids.
" +
- "Successfully copmleting a Retirement contract will lower the population in your current " +
- "city, and will also increase its chaos level.",
- baseDifficulty:200, difficultyFac:1.03, rewardFac:1.065,
- rankGain:0.6, hpLoss:1,
- count:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(5, 500), countGrowth:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(5,75)/10,
- weights:{hack:0,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0.1, int:0.1},
- decays:{hack:0,str:0.91,def:0.91,dex:0.91,agi:0.91,cha:0.8, int:0.9},
- isKill:true
- });
-
- this.operations["Investigation"] = new Operation({
- name:"Investigation",
- desc:"As a field agent, investigate and identify Synthoid " +
- "populations, movements, and operations.
Successful " +
- "Investigation ops will increase the accuracy of your " +
- "synthoid data.
" +
- "You will NOT lose HP from failed Investigation ops.",
- baseDifficulty:400, difficultyFac:1.03,rewardFac:1.07,reqdRank:25,
- rankGain:2.2, rankLoss:0.2,
- count:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(1, 250), countGrowth:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(10, 40)/10,
- weights:{hack:0.25,str:0.05,def:0.05,dex:0.2,agi:0.1,cha:0.25, int:0.1},
- decays:{hack:0.85,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.7, int:0.9},
- isStealth:true
- });
- this.operations["Undercover Operation"] = new Operation({
- name:"Undercover Operation",
- desc:"Conduct undercover operations to identify hidden " +
- "and underground Synthoid communities and organizations.
" +
- "Successful Undercover ops will increase the accuracy of your synthoid " +
- "data.",
- baseDifficulty:500, difficultyFac:1.04, rewardFac:1.09, reqdRank:100,
- rankGain:4.4, rankLoss:0.4, hpLoss:2,
- count:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(1, 250), countGrowth:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(10, 40)/10,
- weights:{hack:0.2,str:0.05,def:0.05,dex:0.2,agi:0.2,cha:0.2, int:0.1},
- decays:{hack:0.8,str:0.9,def:0.9,dex:0.9,agi:0.9,cha:0.7, int:0.9},
- isStealth:true
- });
- this.operations["Sting Operation"] = new Operation({
- name:"Sting Operation",
- desc:"Conduct a sting operation to bait and capture particularly " +
- "notorious Synthoid criminals.",
- baseDifficulty:650, difficultyFac:1.04, rewardFac:1.095, reqdRank:500,
- rankGain:5.5, rankLoss:0.5, hpLoss:2.5,
- count:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(1, 300), countGrowth:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(3, 40)/10,
- weights:{hack:0.25,str:0.05,def:0.05,dex:0.25,agi:0.1,cha:0.2, int:0.1},
- decays:{hack:0.8,str:0.85,def:0.85,dex:0.85,agi:0.85,cha:0.7, int:0.9},
- isStealth:true
- });
- this.operations["Raid"] = new Operation({
- name:"Raid",
- desc:"Lead an assault on a known Synthoid community. Note that " +
- "there must be an existing Synthoid community in your current city " +
- "in order for this Operation to be successful",
- baseDifficulty:800, difficultyFac:1.045, rewardFac:1.1, reqdRank:3000,
- rankGain:55,rankLoss:2.5,hpLoss:50,
- count:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(1, 200), countGrowth:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(2, 40)/10,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.7,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.9},
- isKill:true
- });
- this.operations["Stealth Retirement Operation"] = new Operation({
- name:"Stealth Retirement Operation",
- desc:"Lead a covert operation to retire Synthoids. The " +
- "objective is to complete the task without " +
- "drawing any attention. Stealth and discretion are key.",
- baseDifficulty:1000, difficultyFac:1.05, rewardFac:1.11, reqdRank:20e3,
- rankGain:22, rankLoss:2, hpLoss:10,
- count:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(1, 250), countGrowth:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(1, 20)/10,
- weights:{hack:0.1,str:0.1,def:0.1,dex:0.3,agi:0.3,cha:0, int:0.1},
- decays:{hack:0.7,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.9},
- isStealth:true, isKill:true
- });
- this.operations["Assassination"] = new Operation({
- name:"Assassination",
- desc:"Assassinate Synthoids that have been identified as " +
- "important, high-profile social and political leaders " +
- "in the Synthoid communities.",
- baseDifficulty:1500, difficultyFac:1.06, rewardFac:1.14, reqdRank:50e3,
- rankGain:44, rankLoss:4, hpLoss:5,
- count:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(1, 200), countGrowth:Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(1, 20)/10,
- weights:{hack:0.1,str:0.1,def:0.1,dex:0.3,agi:0.3,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.8},
- isStealth:true, isKill:true
- });
-}
-
-Bladeburner.prototype.storeCycles = function(numCycles=1) {
- this.storedCycles += numCycles;
-}
-
-Bladeburner.prototype.process = function() {
- //Extreme condition...if Operation Daedalus is complete trigger the BitNode
- if (_RedPill__WEBPACK_IMPORTED_MODULE_10__[/* redPillFlag */ "b"] === false && this.blackops.hasOwnProperty("Operation Daedalus")) {
- return Object(_RedPill__WEBPACK_IMPORTED_MODULE_10__[/* hackWorldDaemon */ "a"])(_Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].bitNodeN);
- }
-
- //If the Player starts doing some other actions, set action to idle and alert
- if (_Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][_Augmentation_data_AugmentationNames__WEBPACK_IMPORTED_MODULE_1__["AugmentationNames"].BladesSimulacrum].owned === false && _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].isWorking) {
- if (this.action.type !== ActionTypes["Idle"]) {
- let msg = "Your Bladeburner action was cancelled because you started doing something else.";
- if (this.automateEnabled) {
- msg += `
Your automation was disabled as well. You will have to re-enable it through the Bladeburner console`
- this.automateEnabled = false;
- }
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_14__["dialogBoxCreate"])(msg);
- }
- this.resetAction();
- }
-
- // If the Player has no Stamina, set action to idle
- if (this.stamina <= 0) {
- this.log("Your Bladeburner action was cancelled because your stamina hit 0");
- this.resetAction();
- }
-
- //A 'tick' for this mechanic is one second (= 5 game cycles)
- if (this.storedCycles >= CyclesPerSecond) {
- var seconds = Math.floor(this.storedCycles / CyclesPerSecond);
- seconds = Math.min(seconds, 5); //Max of 5 'ticks'
- this.storedCycles -= seconds * CyclesPerSecond;
-
- //Stamina
- this.calculateMaxStamina();
- this.stamina += (this.calculateStaminaGainPerSecond() * seconds);
- this.stamina = Math.min(this.maxStamina, this.stamina);
-
- //Count increase for contracts/operations
- for (var contractName in this.contracts) {
- if (this.contracts.hasOwnProperty(contractName)) {
- var contract = this.contracts[contractName];
- contract.count += (seconds * contract.countGrowth/ActionCountGrowthPeriod);
- }
- }
- for (var operationName in this.operations) {
- if (this.operations.hasOwnProperty(operationName)) {
- var op = this.operations[operationName];
- op.count += (seconds * op.countGrowth/ActionCountGrowthPeriod);
- }
- }
-
- //Chaos goes down very slowly
- for (var i = 0; i < CityNames.length; ++i) {
- var city = this.cities[CityNames[i]];
- if (!(city instanceof City)) {throw new Error("Invalid City object when processing passive chaos reduction in Bladeburner.process");}
- city.chaos -= (0.0001 * seconds);
- city.chaos = Math.max(0, city.chaos);
- }
-
- //Random Events
- this.randomEventCounter -= seconds;
- if (this.randomEventCounter <= 0) {
- this.randomEvent();
- this.randomEventCounter = Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(240, 600);
- }
-
- this.processAction(seconds);
-
- //Automation
- if (this.automateEnabled) {
- // Note: Do NOT set this.action = this.automateActionHigh/Low since it creates a reference
- if (this.stamina <= this.automateThreshLow) {
- if (this.action.name !== this.automateActionLow.name || this.action.type !== this.automateActionLow.type) {
- this.action = new ActionIdentifier({type: this.automateActionLow.type, name: this.automateActionLow.name});
- this.startAction(this.action);
- }
- } else if (this.stamina >= this.automateThreshHigh) {
- if (this.action.name !== this.automateActionHigh.name || this.action.type !== this.automateActionHigh.type) {
- this.action = new ActionIdentifier({type: this.automateActionHigh.type, name: this.automateActionHigh.name});
- this.startAction(this.action);
- }
- }
- }
-
- if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22__["Page"].Bladeburner)) {
- this.updateContent();
- }
- }
-}
-
-Bladeburner.prototype.calculateMaxStamina = function() {
- var effAgility = _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].agility * this.skillMultipliers.effAgi;
- var maxStamina = (Math.pow(effAgility, 0.8) + this.staminaBonus);
- maxStamina *= this.skillMultipliers.stamina;
- maxStamina *= _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].bladeburner_max_stamina_mult;
- if (isNaN(maxStamina)) {throw new Error("Max Stamina calculated to be NaN in Bladeburner.calculateMaxStamina()");}
- this.maxStamina = maxStamina;
-}
-
-Bladeburner.prototype.calculateStaminaGainPerSecond = function() {
- var effAgility = _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].agility * this.skillMultipliers.effAgi;
- var maxStaminaBonus = this.maxStamina / MaxStaminaToGainFactor;
- var gain = (StaminaGainPerSecond + maxStaminaBonus) * Math.pow(effAgility, 0.17);
- return gain * (this.skillMultipliers.stamina * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].bladeburner_stamina_gain_mult);
-}
-
-Bladeburner.prototype.calculateStaminaPenalty = function() {
- return Math.min(1, this.stamina / (0.5 * this.maxStamina));
-}
-
-Bladeburner.prototype.changeRank = function(change) {
- if (isNaN(change)) {throw new Error("NaN passed into Bladeburner.changeRank()");}
- this.rank += change;
- if (this.rank < 0) {this.rank = 0;}
- this.maxRank = Math.max(this.rank, this.maxRank);
-
- var bladeburnersFactionName = "Bladeburners";
- if (Object(_Faction_Factions__WEBPACK_IMPORTED_MODULE_6__["factionExists"])(bladeburnersFactionName)) {
- var bladeburnerFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_6__["Factions"][bladeburnersFactionName];
- if (!(bladeburnerFac instanceof _Faction_Faction__WEBPACK_IMPORTED_MODULE_5__["Faction"])) {
- throw new Error("Could not properly get Bladeburner Faction object in Bladeburner UI Overview Faction button");
- }
- if (bladeburnerFac.isMember) {
- var favorBonus = 1 + (bladeburnerFac.favor / 100);
- bladeburnerFac.playerReputation += (RankToFactionRepFactor * change * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].faction_rep_mult * favorBonus);
- }
- }
-
- //Gain skill points. You get 1 every 4 ranks
- var rankNeededForSp = (this.totalSkillPoints+1) * RanksPerSkillPoint;
- if (this.maxRank >= rankNeededForSp) {
- //Calculate how many skill points to gain
- var gainedSkillPoints = Math.floor((this.maxRank - rankNeededForSp) / RanksPerSkillPoint + 1);
- this.skillPoints += gainedSkillPoints;
- this.totalSkillPoints += gainedSkillPoints;
- }
-}
-
-Bladeburner.prototype.getCurrentCity = function() {
- var city = this.cities[this.city];
- if (!(city instanceof City)) {
- throw new Error("Bladeburner.getCurrentCity() did not properly return a City object");
- }
- return city;
-}
-
-Bladeburner.prototype.resetSkillMultipliers = function() {
- this.skillMultipliers = {
- successChanceAll:1,
- successChanceStealth:1,
- successChanceKill:1,
- successChanceContract:1,
- successChanceOperation:1,
- successChanceEstimate:1,
- actionTime:1,
- effHack:1,
- effStr:1,
- effDef:1,
- effDex:1,
- effAgi:1,
- effCha:1,
- effInt:1,
- stamina:1,
- weaponAbility:1,
- gunAbility:1,
- };
-}
-
-Bladeburner.prototype.updateSkillMultipliers = function() {
- this.resetSkillMultipliers();
- for (var skillName in this.skills) {
- if (this.skills.hasOwnProperty(skillName)) {
- var skill = Skills[skillName];
- if (skill == null) {
- throw new Error("Could not find Skill Object for: " + skillName);
- }
- var level = this.skills[skillName];
- if (level == null || level <= 0) {continue;} //Not upgraded
-
- var multiplierNames = Object.keys(this.skillMultipliers);
- for (var i = 0; i < multiplierNames.length; ++i) {
- var multiplierName = multiplierNames[i];
- if (skill[multiplierName] != null && !isNaN(skill[multiplierName])) {
- var value = skill[multiplierName] * level;
- var multiplierValue = 1 + (value / 100);
- if (multiplierName === "actionTime") {
- multiplierValue = 1 - (value / 100);
- }
- this.skillMultipliers[multiplierName] *= multiplierValue;
- }
- }
- }
- }
-}
-
-Bladeburner.prototype.upgradeSkill = function(skill) {
- //This does NOT handle deduction of skill points
- var skillName = skill.name;
- if (this.skills[skillName]) {
- ++this.skills[skillName];
- } else {
- this.skills[skillName] = 1;
- }
- if (isNaN(this.skills[skillName]) || this.skills[skillName] < 0) {
- throw new Error("Level of Skill " + skillName + " is invalid: " + this.skills[skillName]);
- }
- this.updateSkillMultipliers();
-}
-
-Bladeburner.prototype.getActionObject = function(actionId) {
- //Given an ActionIdentifier object, returns the corresponding
- //GeneralAction, Contract, Operation, or BlackOperation object
- switch (actionId.type) {
- case ActionTypes["Contract"]:
- return this.contracts[actionId.name];
- case ActionTypes["Operation"]:
- return this.operations[actionId.name];
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- return BlackOperations[actionId.name];
- case ActionTypes["Training"]:
- return GeneralActions["Training"];
- case ActionTypes["Field Analysis"]:
- return GeneralActions["Field Analysis"];
- case ActionTypes["Recruitment"]:
- return GeneralActions["Recruitment"];
- default:
- return null;
- }
-}
-
-//Sets the player to the "IDLE" action
-Bladeburner.prototype.resetAction = function() {
- this.action = new ActionIdentifier({type:ActionTypes.Idle});
-}
-
-Bladeburner.prototype.startAction = function(actionId) {
- if (actionId == null) {return;}
- this.action = actionId;
- this.actionTimeCurrent = 0;
- switch (actionId.type) {
- case ActionTypes["Idle"]:
- this.actionTimeToComplete = 0;
- break;
- case ActionTypes["Contract"]:
- try {
- var action = this.getActionObject(actionId);
- if (action == null) {
- throw new Error("Failed to get Contract Object for: " + actionId.name);
- }
- if (action.count < 1) {return this.resetAction();}
- this.actionTimeToComplete = action.getActionTime(this);
- } catch(e) {
- Object(_utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_23__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["Operation"]:
- try {
- var action = this.getActionObject(actionId);
- if (action == null) {
- throw new Error ("Failed to get Operation Object for: " + actionId.name);
- }
- if (action.count < 1) {return this.resetAction();}
- if (actionId.name === "Raid" && this.getCurrentCity().commsEst === 0) {return this.resetAction();}
- this.actionTimeToComplete = action.getActionTime(this);
- } catch(e) {
- Object(_utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_23__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- try {
- // Safety measure - don't repeat BlackOps that are already done
- if (this.blackops[actionId.name] != null) {
- this.resetAction();
- this.log("Error: Tried to start a Black Operation that had already been completed");
- break;
- }
-
- var action = this.getActionObject(actionId);
- if (action == null) {
- throw new Error("Failed to get BlackOperation object for: " + actionId.name);
- }
- this.actionTimeToComplete = action.getActionTime(this);
- } catch(e) {
- Object(_utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_23__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["Training"]:
- this.actionTimeToComplete = 30;
- break;
- case ActionTypes["Recruitment"]:
- this.actionTimeToComplete = this.getRecruitmentTime();
- break;
- case ActionTypes["FieldAnalysis"]:
- case ActionTypes["Field Analysis"]:
- this.actionTimeToComplete = 30;
- break;
- default:
- throw new Error("Invalid Action Type in Bladeburner.startAction(): " + actionId.type);
- break;
- }
-}
-
-Bladeburner.prototype.processAction = function(seconds) {
- if (this.action.type === ActionTypes["Idle"]) {return;}
- if (this.actionTimeToComplete <= 0) {
- console.log("action.type: " + this.action.type);
- throw new Error("Invalid actionTimeToComplete value: " + this.actionTimeToComplete);
- }
- if (!(this.action instanceof ActionIdentifier)) {
- throw new Error("Bladeburner.action is not an ActionIdentifier Object");
- }
-
- this.actionTimeCurrent += seconds;
- if (this.actionTimeCurrent >= this.actionTimeToComplete) {
- return this.completeAction();
- }
-}
-
-Bladeburner.prototype.completeAction = function() {
- switch (this.action.type) {
- case ActionTypes["Contract"]:
- case ActionTypes["Operation"]:
- try {
- var isOperation = (this.action.type === ActionTypes["Operation"]);
- var action = this.getActionObject(this.action);
- if (action == null) {
- throw new Error("Failed to get Contract/Operation Object for: " + this.action.name);
- }
- var difficulty = action.getDifficulty();
- var difficultyMultiplier = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;
- var rewardMultiplier = Math.pow(action.rewardFac, action.level-1);
-
- //Stamina loss is based on difficulty
- this.stamina -= (BaseStaminaLoss * difficultyMultiplier);
- if (this.stamina < 0) {this.stamina = 0;}
-
- //Process Contract/Operation success/failure
- if (action.attempt(this)) {
- this.gainActionStats(action, true);
- ++action.successes;
- --action.count;
-
- //Earn money for contracts
- var moneyGain = 0;
- if (!isOperation) {
- moneyGain = ContractBaseMoneyGain * rewardMultiplier;
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainMoney(moneyGain);
- }
-
- if (isOperation) {
- action.setMaxLevel(OperationSuccessesPerLevel);
- } else {
- action.setMaxLevel(ContractSuccessesPerLevel);
- }
- if (action.rankGain) {
- var gain = Object(_utils_helpers_addOffset__WEBPACK_IMPORTED_MODULE_17__["addOffset"])(action.rankGain * rewardMultiplier * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_2__["BitNodeMultipliers"].BladeburnerRank, 10);
- this.changeRank(gain);
- if (isOperation && this.logging.ops) {
- this.log(action.name + " successfully completed! Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(gain, 3) + " rank");
- } else if (!isOperation && this.logging.contracts) {
- this.log(action.name + " contract successfully completed! Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(gain, 3) + " rank and " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_11__["numeralWrapper"].format(moneyGain, "$0.000a"));
- }
- }
- isOperation ? this.completeOperation(true) : this.completeContract(true);
- } else {
- this.gainActionStats(action, false);
- ++action.failures;
- var loss = 0, damage = 0;
- if (action.rankLoss) {
- loss = Object(_utils_helpers_addOffset__WEBPACK_IMPORTED_MODULE_17__["addOffset"])(action.rankLoss * rewardMultiplier, 10);
- this.changeRank(-1 * loss);
- }
- if (action.hpLoss) {
- damage = action.hpLoss * difficultyMultiplier;
- damage = Math.ceil(Object(_utils_helpers_addOffset__WEBPACK_IMPORTED_MODULE_17__["addOffset"])(damage, 10));
- this.hpLost += damage;
- if (_Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].takeDamage(damage)) {
- ++this.numHosp;
- this.moneyLost += (_Constants__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].HospitalCostPerHp * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].max_hp);
- }
- }
- var logLossText = "";
- if (loss > 0) {logLossText += "Lost " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(loss, 3) + " rank.";}
- if (damage > 0) {logLossText += "Took " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(damage, 0) + " damage.";}
- if (isOperation && this.logging.ops) {
- this.log(action.name + " failed! " + logLossText);
- } else if (!isOperation && this.logging.contracts) {
- this.log(action.name + " contract failed! " + logLossText);
- }
- isOperation ? this.completeOperation(false) : this.completeContract(false);
- }
- if (action.autoLevel) {action.level = action.maxLevel;} //Autolevel
- this.startAction(this.action); //Repeat action
- } catch(e) {
- Object(_utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_23__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- try {
- var action = this.getActionObject(this.action);
- if (action == null || !(action instanceof BlackOperation)) {
- throw new Error("Failed to get BlackOperation Object for: " + this.action.name);
- }
- var difficulty = action.getDifficulty();
- var difficultyMultiplier = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;
-
- //Stamina loss is based on difficulty
- this.stamina -= (BaseStaminaLoss * difficultyMultiplier);
- if (this.stamina < 0) {this.stamina = 0;}
-
- //Team loss variables
- var teamCount = action.teamCount, teamLossMax;
-
- if (action.attempt(this)) {
- this.gainActionStats(action, true);
- action.count = 0;
- this.blackops[action.name] = true;
- var rankGain = 0;
- if (action.rankGain) {
- rankGain = Object(_utils_helpers_addOffset__WEBPACK_IMPORTED_MODULE_17__["addOffset"])(action.rankGain * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_2__["BitNodeMultipliers"].BladeburnerRank, 10);
- this.changeRank(rankGain);
- }
- teamLossMax = Math.ceil(teamCount/2);
-
- //Operation Daedalus
- if (action.name === "Operation Daedalus") {
- this.resetAction();
- return Object(_RedPill__WEBPACK_IMPORTED_MODULE_10__[/* hackWorldDaemon */ "a"])(_Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].bitNodeN);
- }
-
- if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22__["Page"].Bladeburner)) {
- this.createActionAndSkillsContent();
- }
-
- if (this.logging.blackops) {
- this.log(action.name + " successful! Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(rankGain, 1) + " rank");
- }
- } else {
- this.gainActionStats(action, false);
- var rankLoss = 0, damage = 0;
- if (action.rankLoss) {
- rankLoss = Object(_utils_helpers_addOffset__WEBPACK_IMPORTED_MODULE_17__["addOffset"])(action.rankLoss, 10);
- this.changeRank(-1 * rankLoss);
- }
- if (action.hpLoss) {
- damage = action.hpLoss * difficultyMultiplier;
- damage = Math.ceil(Object(_utils_helpers_addOffset__WEBPACK_IMPORTED_MODULE_17__["addOffset"])(damage, 10));
- if (_Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].takeDamage(damage)) {
- ++this.numHosp;
- this.moneyLost += (_Constants__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].HospitalCostPerHp * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].max_hp);
- }
- }
- teamLossMax = Math.floor(teamCount);
-
- if (this.logging.blackops) {
- this.log(action.name + " failed! Lost " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(rankLoss, 1) + " rank and took " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(damage, 0) + " damage");
- }
- }
-
- this.resetAction(); //Stop regardless of success or fail
-
- //Calculate team lossses
- if (teamCount >= 1) {
- var losses = Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(1, teamLossMax);
- this.teamSize -= losses;
- this.teamLost += losses;
- if (this.logging.blackops) {
- this.log("You lost " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(losses, 0) + " team members during " + action.name);
- }
- }
- } catch(e) {
- Object(_utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_23__["exceptionAlert"])(e);
- }
- break;
- case ActionTypes["Training"]:
- this.stamina -= (0.5 * BaseStaminaLoss);
- var strExpGain = 30 * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].strength_exp_mult,
- defExpGain = 30 * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].defense_exp_mult,
- dexExpGain = 30 * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].dexterity_exp_mult,
- agiExpGain = 30 * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].agility_exp_mult,
- staminaGain = 0.04 * this.skillMultipliers.stamina;
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainStrengthExp(strExpGain);
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainDefenseExp(defExpGain);
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainDexterityExp(dexExpGain);
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainAgilityExp(agiExpGain);
- this.staminaBonus += (staminaGain);
- if (this.logging.general) {
- this.log("Training completed. Gained: " +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(strExpGain, 1) + " str exp, " +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(defExpGain, 1) + " def exp, " +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(dexExpGain, 1) + " dex exp, " +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(agiExpGain, 1) + " agi exp, " +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(staminaGain, 3) + " max stamina");
- }
- this.startAction(this.action); //Repeat action
- break;
- case ActionTypes["FieldAnalysis"]:
- case ActionTypes["Field Analysis"]:
- //Does not use stamina. Effectiveness depends on hacking, int, and cha
- var eff = 0.04 * Math.pow(_Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].hacking_skill, 0.3) +
- 0.04 * Math.pow(_Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].intelligence, 0.9) +
- 0.02 * Math.pow(_Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].charisma, 0.3);
- eff *= _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].bladeburner_analysis_mult;
- if (isNaN(eff) || eff < 0) {
- throw new Error("Field Analysis Effectiveness calculated to be NaN or negative");
- }
- var hackingExpGain = 20 * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].hacking_exp_mult,
- charismaExpGain = 20 * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].charisma_exp_mult;
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainHackingExp(hackingExpGain);
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainIntelligenceExp(BaseIntGain);
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainCharismaExp(charismaExpGain);
- this.changeRank(0.1 * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_2__["BitNodeMultipliers"].BladeburnerRank);
- this.getCurrentCity().improvePopulationEstimateByPercentage(eff * this.skillMultipliers.successChanceEstimate);
- if (this.logging.general) {
- this.log("Field analysis completed. Gained 0.1 rank, " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(hackingExpGain, 1) + " hacking exp, and " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(charismaExpGain, 1) + " charisma exp");
- }
- this.startAction(this.action); //Repeat action
- break;
- case ActionTypes["Recruitment"]:
- var successChance = this.getRecruitmentSuccessChance();
- console.log("Bladeburner recruitment success chance: " + successChance);
- if (Math.random() < successChance) {
- var expGain = 2 * BaseStatGain * this.actionTimeToComplete;
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainCharismaExp(expGain);
- ++this.teamSize;
- if (this.logging.general) {
- this.log("Successfully recruited a team member! Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(expGain, 1) + " charisma exp");
- }
- } else {
- var expGain = BaseStatGain * this.actionTimeToComplete;
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainCharismaExp(expGain);
- if (this.logging.general) {
- this.log("Failed to recruit a team member. Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(expGain, 1) + " charisma exp");
- }
- }
- this.startAction(this.action); //Repeat action
- break;
- default:
- break;
- }
-}
-
-Bladeburner.prototype.completeContract = function(success) {
- if (this.action.type !== ActionTypes.Contract) {
- throw new Error("completeContract() called even though current action is not a Contract");
- }
- var city = this.getCurrentCity();
- if (success) {
- switch (this.action.name) {
- case "Tracking":
- //Increase estimate accuracy by a relatively small amount
- city.improvePopulationEstimateByCount(Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(100, 1e3));
- break;
- case "Bounty Hunter":
- city.changePopulationByCount(-1, {estChange:-1});
- city.changeChaosByCount(0.02);
- break;
- case "Retirement":
- city.changePopulationByCount(-1, {estChange:-1});
- city.changeChaosByCount(0.04);
- break;
- default:
- throw new Error("Invalid Action name in completeContract: " + this.action.name);
- }
- }
-}
-
-Bladeburner.prototype.completeOperation = function(success) {
- if (this.action.type !== ActionTypes.Operation) {
- throw new Error("completeOperation() called even though current action is not an Operation");
- }
- var action = this.getActionObject(this.action);
- if (action == null) {
- throw new Error("Failed to get Contract/Operation Object for: " + this.action.name);
- }
-
- //Calculate team losses
- var teamCount = action.teamCount, max;
- if (teamCount >= 1) {
- if (success) {
- max = Math.ceil(teamCount/2);
- } else {
- max = Math.floor(teamCount)
- }
- var losses = Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(0, max);
- this.teamSize -= losses;
- this.teamLost += losses;
- if (this.logging.ops && losses > 0) {
- this.log("Lost " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(losses, 0) + " team members during this " + action.name);
- }
- }
-
- var city = this.getCurrentCity();
- switch (action.name) {
- case "Investigation":
- if (success) {
- city.improvePopulationEstimateByPercentage(0.4 * this.skillMultipliers.successChanceEstimate);
- if (Math.random() < (0.02 * this.skillMultipliers.successChanceEstimate)) {
- city.improveCommunityEstimate(1);
- }
- } else {
- this.triggerPotentialMigration(this.city, 0.1);
- }
- break;
- case "Undercover Operation":
- if (success) {
- city.improvePopulationEstimateByPercentage(0.8 * this.skillMultipliers.successChanceEstimate);
- if (Math.random() < (0.02 * this.skillMultipliers.successChanceEstimate)) {
- city.improveCommunityEstimate(1);
- }
- } else {
- this.triggerPotentialMigration(this.city, 0.15);
- }
- break;
- case "Sting Operation":
- if (success) {
- city.changePopulationByPercentage(-0.1, {changeEstEqually:true, nonZero:true});
- }
- city.changeChaosByCount(0.1);
- break;
- case "Raid":
- if (success) {
- city.changePopulationByPercentage(-1, {changeEstEqually:true, nonZero:true});
- --city.comms;
- --city.commsEst;
- } else {
- var change = Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(-3, -1);
- city.changePopulationByPercentage(change, {nonZero:true});
- }
- city.changeChaosByPercentage(Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(1, 5));
- break;
- case "Stealth Retirement Operation":
- if (success) {
- city.changePopulationByPercentage(-0.5, {changeEstEqually:true,nonZero:true});
- }
- city.changeChaosByPercentage(Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(-3, -1));
- break;
- case "Assassination":
- if (success) {
- city.changePopulationByCount(-1, {estChange:-1});
- }
- city.changeChaosByPercentage(Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(-5, 5));
- break;
- default:
- throw new Error("Invalid Action name in completeOperation: " + this.action.name);
- }
-}
-
-Bladeburner.prototype.getRecruitmentTime = function() {
- var effCharisma = _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].charisma * this.skillMultipliers.effCha;
- var charismaFactor = Math.pow(effCharisma, 0.81) + effCharisma / 90;
- return Math.max(10, Math.round(BaseRecruitmentTimeNeeded - charismaFactor));
-}
-
-Bladeburner.prototype.getRecruitmentSuccessChance = function() {
- return Math.pow(_Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].charisma, 0.45) / (this.teamSize + 1);
-}
-
-//Process stat gains from Contracts, Operations, and Black Operations
-//@action(Action obj) - Derived action class
-//@success(bool) - Whether action was successful
-Bladeburner.prototype.gainActionStats = function(action, success) {
- var difficulty = action.getDifficulty();
-
- //Gain multiplier based on difficulty. If this changes then the
- //same variable calculated in completeAction() needs to change too
- var difficultyMult = Math.pow(difficulty, DiffMultExponentialFactor) + difficulty / DiffMultLinearFactor;
-
- var time = this.actionTimeToComplete;
- var successMult = success ? 1 : 0.5;
-
- var unweightedGain = time * BaseStatGain * successMult * difficultyMult;
- var unweightedIntGain = time * BaseIntGain * successMult * difficultyMult;
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainHackingExp(unweightedGain * action.weights.hack * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].hacking_exp_mult);
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainStrengthExp(unweightedGain * action.weights.str * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].strength_exp_mult);
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainDefenseExp(unweightedGain * action.weights.def * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].defense_exp_mult);
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainDexterityExp(unweightedGain * action.weights.dex * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].dexterity_exp_mult);
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainAgilityExp(unweightedGain * action.weights.agi * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].agility_exp_mult);
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainCharismaExp(unweightedGain * action.weights.cha * _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].charisma_exp_mult);
- _Player__WEBPACK_IMPORTED_MODULE_9__[/* Player */ "a"].gainIntelligenceExp(unweightedIntGain * action.weights.int);
-}
-
-Bladeburner.prototype.randomEvent = function() {
- var chance = Math.random();
-
- //Choose random source/destination city for events
- var sourceCityName = CityNames[Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(0, 5)];
- var sourceCity = this.cities[sourceCityName];
- if (!(sourceCity instanceof City)) {
- throw new Error("sourceCity was not a City object in Bladeburner.randomEvent()");
- }
-
- var destCityName = CityNames[Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(0, 5)];
- while (destCityName === sourceCityName) {
- destCityName = CityNames[Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(0, 5)];
- }
- var destCity = this.cities[destCityName];
-
- if (!(sourceCity instanceof City) || !(destCity instanceof City)) {
- throw new Error("sourceCity/destCity was not a City object in Bladeburner.randomEvent()");
- }
-
- if (chance <= 0.05) {
- //New Synthoid Community, 5%
- ++sourceCity.comms;
- var percentage = Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(10, 20) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop += count;
- if (this.logging.events) {
- this.log("Intelligence indicates that a new Synthoid community was formed in a city");
- }
- } else if (chance <= 0.1) {
- //Synthoid Community Migration, 5%
- if (sourceCity.comms <= 0) {
- //If no comms in source city, then instead trigger a new Synthoid community event
- ++sourceCity.comms;
- var percentage = Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(10, 20) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop += count;
- if (this.logging.events) {
- this.log("Intelligence indicates that a new Synthoid community was formed in a city");
- }
- } else {
- --sourceCity.comms;
- ++destCity.comms;
-
- //Change pop
- var percentage = Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(10, 20) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop -= count;
- destCity.pop += count;
-
- if (this.logging.events) {
- this.log("Intelligence indicates that a Synthoid community migrated from " + sourceCityName + " to some other city");
- }
- }
- } else if (chance <= 0.3) {
- //New Synthoids (non community), 20%
- var percentage = Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(8, 24) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop += count;
- if (this.logging.events) {
- this.log("Intelligence indicates that the Synthoid population of " + sourceCityName + " just changed significantly");
- }
- } else if (chance <= 0.5) {
- //Synthoid migration (non community) 20%
- this.triggerMigration(sourceCityName);
- if (this.logging.events) {
- this.log("Intelligence indicates that a large number of Synthoids migrated from " + sourceCityName + " to some other city");
- }
- } else if (chance <= 0.7) {
- //Synthoid Riots (+chaos), 20%
- sourceCity.chaos += 1;
- sourceCity.chaos *= (1 + Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(5, 10) / 100);
- if (this.logging.events) {
- this.log("Tensions between Synthoids and humans lead to riots in " + sourceCityName + "! Chaos increased");
- }
- } else if (chance <= 0.9) {
- //Less Synthoids, 20%
- var percentage = Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(5, 20) / 100;
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop -= count;
- if (this.logging.events) {
- this.log("Intelligence indicates that the Synthoid population of " + sourceCityName + " just changed significantly");
- }
- }
- //20% chance of nothing happening
-}
-
-Bladeburner.prototype.triggerPotentialMigration = function(sourceCityName, chance) {
- if (chance == null || isNaN(chance)) {
- console.log("ERROR: Invalid 'chance' parameter passed into Bladeburner.triggerPotentialMigration()");
- }
- if (chance > 1) {chance /= 100;}
- if (Math.random() < chance) {this.triggerMigration(sourceCityName);}
-}
-
-Bladeburner.prototype.triggerMigration = function(sourceCityName) {
- var destCityName = CityNames[Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(0, 5)];
- while (destCityName === sourceCityName) {
- destCityName = CityNames[Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(0, 5)];
- }
- var destCity = this.cities[destCityName];
- var sourceCity = this.cities[sourceCityName];
- if (destCity == null || sourceCity == null) {
- throw new Error("Failed to find City with name: " + destCityName);
- }
- var rand = Math.random(), percentage = Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(3, 15) / 100;
-
- if (rand < 0.05 && sourceCity.comms > 0) { //5% chance for community migration
- percentage *= Object(_utils_helpers_getRandomInt__WEBPACK_IMPORTED_MODULE_25__["getRandomInt"])(2, 4); //Migration increases population change
- --sourceCity.comms;
- ++destCity.comms;
- }
- var count = Math.round(sourceCity.pop * percentage);
- sourceCity.pop -= count;
- destCity.pop += count;
-}
-
-var DomElems = {};
-
-Bladeburner.prototype.initializeDomElementRefs = function() {
- DomElems = {
- bladeburnerDiv: null,
-
- //Main Divs
- overviewConsoleParentDiv: null,
-
- overviewDiv: null, //Overview of stats that stays fixed on left
- actionAndSkillsDiv: null, //Panel for different sections (contracts, ops, skills)
- currentTab: null, //Contracts, Operations, Black Ops, Skills
-
- consoleDiv: null,
- consoleTable: null,
- consoleInputRow: null, //tr
- consoleInputCell: null, //td
- consoleInputHeader: null, //"> "
- consoleInput: null, //Actual input element
-
- //Overview Content
- overviewRank: null,
- overviewStamina: null,
- overviewStaminaHelpTip: null,
- overviewGen1: null, //Stamina Penalty, Team, Hospitalized stats, current city
- overviewEstPop: null,
- overviewEstPopHelpTip: null,
- overviewEstComms: null,
- overviewChaos: null,
- overviewSkillPoints: null,
- overviewBonusTime: null,
- overviewAugSuccessMult: null,
- overviewAugMaxStaminaMult: null,
- overviewAugStaminaGainMult: null,
- overviewAugAnalysisMult: null,
-
- //Actions and Skills Content
- actionsAndSkillsDesc: null,
- actionsAndSkillsList: null, //ul element of all UI elements in this panel
- generalActions: {},
- contracts: {},
- operations: {},
- blackops: {},
- skills: {},
- skillPointsDisplay: null,
- };
-}
-
-Bladeburner.prototype.createContent = function() {
- DomElems.bladeburnerDiv = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("div", {
- id:"bladeburner-container", position:"fixed", class:"generic-menupage-container",
- });
-
- //Parent Div for Overview and Console
- DomElems.overviewConsoleParentDiv = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("div", {
- height:"60%", display:"block", position:"relative",
- });
-
- //Overview and Action/Skill pane
- DomElems.overviewDiv = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("div", {
- width:"30%", display:"inline-block", border:"1px solid white",
- });
-
- DomElems.actionAndSkillsDiv = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("div", {
- height:"60%", width:"70%", display:"block",
- border:"1px solid white", margin:"6px", padding:"6px",
- });
-
- DomElems.currentTab = "general";
-
- this.createOverviewContent();
- this.createActionAndSkillsContent();
-
- //Console
- DomElems.consoleDiv = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("div", {
- class:"bladeburner-console-div",
- clickListener:()=>{
- if (DomElems.consoleInput instanceof Element) {
- DomElems.consoleInput.focus();
- }
- return false;
- }
- });
- DomElems.consoleTable = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("table", {class:"bladeburner-console-table"});
- DomElems.consoleInputRow = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("tr", {class:"bladeburner-console-input-row", id:"bladeubrner-console-input-row"});
- DomElems.consoleInputCell = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("td", {class:"bladeburner-console-input-cell"});
- DomElems.consoleInputHeader = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("pre", {innerText:"> "});
- DomElems.consoleInput = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("input", {
- type:"text", class:"bladeburner-console-input", tabIndex:1,
- onfocus:()=>{DomElems.consoleInput.value = DomElems.consoleInput.value}
- });
-
- DomElems.consoleInputCell.appendChild(DomElems.consoleInputHeader);
- DomElems.consoleInputCell.appendChild(DomElems.consoleInput);
- DomElems.consoleInputRow.appendChild(DomElems.consoleInputCell);
- DomElems.consoleTable.appendChild(DomElems.consoleInputRow);
- DomElems.consoleDiv.appendChild(DomElems.consoleTable);
-
- DomElems.overviewConsoleParentDiv.appendChild(DomElems.overviewDiv);
- DomElems.overviewConsoleParentDiv.appendChild(DomElems.consoleDiv);
- DomElems.bladeburnerDiv.appendChild(DomElems.overviewConsoleParentDiv);
- DomElems.bladeburnerDiv.appendChild(DomElems.actionAndSkillsDiv);
-
- document.getElementById("entire-game-container").appendChild(DomElems.bladeburnerDiv);
-
- if (this.consoleLogs.length === 0) {
- this.postToConsole("Bladeburner Console BETA");
- this.postToConsole("Type 'help' to see console commands");
- } else {
- for (let i = 0; i < this.consoleLogs.length; ++i) {
- this.postToConsole(this.consoleLogs[i], false);
- }
- }
-
- DomElems.consoleInput.focus();
-}
-
-Bladeburner.prototype.clearContent = function() {
- if (DomElems.bladeburnerDiv instanceof Element) {
- Object(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_15__["removeChildrenFromElement"])(DomElems.bladeburnerDiv);
- Object(_utils_uiHelpers_removeElement__WEBPACK_IMPORTED_MODULE_27__["removeElement"])(DomElems.bladeburnerDiv);
- }
- Object(_utils_helpers_clearObject__WEBPACK_IMPORTED_MODULE_19__["clearObject"])(DomElems);
- this.initializeDomElementRefs();
-}
-
-Bladeburner.prototype.createOverviewContent = function() {
- if (DomElems.overviewDiv == null) {
- throw new Error("Bladeburner.createOverviewContent() called with DomElems.overviewDiv = null");
- }
-
- DomElems.overviewRank = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", {
- innerText:"Rank: ",
- display:"inline-block",
- tooltip:"Your rank within the Bladeburner division",
- });
-
- DomElems.overviewStamina = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", {
- display:"inline-block",
- });
-
- DomElems.overviewStaminaHelpTip = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("div", {
- class:"help-tip",
- innerText:"?",
- clickListener: ()=> {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_14__["dialogBoxCreate"])("Performing actions will use up your stamina.
" +
- "Your max stamina is determined primarily by your agility stat.
" +
- "Your stamina gain rate is determined by both your agility and your " +
- "max stamina. Higher max stamina leads to a higher gain rate.
" +
- "Once your " +
- "stamina falls below 50% of its max value, it begins to negatively " +
- "affect the success rate of your contracts/operations. This penalty " +
- "is shown in the overview panel. If the penalty is 15%, then this means " +
- "your success rate would be multipled by 85% (100 - 15).
" +
- "Your max stamina and stamina gain rate can also be increased by " +
- "training, or through skills and Augmentation upgrades.");
- },
- });
-
- DomElems.overviewGen1 = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", {
- display:"block",
- });
-
- DomElems.overviewEstPop = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", {
- innerText:"Est. Synthoid Population: ",
- display:"inline-block",
- tooltip:"This is your Bladeburner division's estimate of how many Synthoids exist " +
- "in your current city."
- });
-
- DomElems.overviewEstPopHelpTip = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("div", {
- innerText:"?", class:"help-tip",
- clickListener:()=>{
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_14__["dialogBoxCreate"])("The success rate of your contracts/operations depends on " +
- "the population of Synthoids in your current city. " +
- "The success rate that is shown to you is only an estimate, " +
- "and it is based on your Synthoid population estimate.
" +
- "Therefore, it is important that this Synthoid population estimate " +
- "is accurate so that you have a better idea of your " +
- "success rate for contracts/operations. Certain " +
- "actions will increase the accuracy of your population " +
- "estimate.
" +
- "The Synthoid populations of cities can change due to your " +
- "actions or random events. If random events occur, they will " +
- "be logged in the Bladeburner Console.");
- }
- });
-
- DomElems.overviewEstComms = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", {
- innerText:"Est. Synthoid Communities: ",
- display:"inline-block",
- tooltip:"This is your Bladeburner divison's estimate of how many Synthoid " +
- "communities exist in your current city.",
- });
-
- DomElems.overviewChaos = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", {
- innerText:"City Chaos: ",
- display:"inline-block",
- tooltip:"The city's chaos level due to tensions and conflicts between humans and Synthoids. " +
- "Having too high of a chaos level can make contracts and operations harder."
- });
-
- DomElems.overviewBonusTime = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", {
- innerText: "Bonus time: ",
- display: "inline-block",
- tooltip: "You gain bonus time while offline or when the game is inactive (e.g. when the tab is throttled by browser). " +
- "Bonus time makes the Bladeburner mechanic progress faster, up to 5x the normal speed."
- });
- DomElems.overviewSkillPoints = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", {display:"block"});
-
-
- DomElems.overviewAugSuccessMult = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", {display:"block"});
- DomElems.overviewAugMaxStaminaMult = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", {display:"block"});
- DomElems.overviewAugStaminaGainMult = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", {display:"block"});
- DomElems.overviewAugAnalysisMult = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", {display:"block"});
-
-
- DomElems.overviewDiv.appendChild(DomElems.overviewRank);
- Object(_utils_uiHelpers_appendLineBreaks__WEBPACK_IMPORTED_MODULE_18__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(DomElems.overviewStamina);
- DomElems.overviewDiv.appendChild(DomElems.overviewStaminaHelpTip);
- DomElems.overviewDiv.appendChild(DomElems.overviewGen1);
- DomElems.overviewDiv.appendChild(DomElems.overviewEstPop);
- DomElems.overviewDiv.appendChild(DomElems.overviewEstPopHelpTip);
- Object(_utils_uiHelpers_appendLineBreaks__WEBPACK_IMPORTED_MODULE_18__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(DomElems.overviewEstComms);
- Object(_utils_uiHelpers_appendLineBreaks__WEBPACK_IMPORTED_MODULE_18__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(DomElems.overviewChaos);
- Object(_utils_uiHelpers_appendLineBreaks__WEBPACK_IMPORTED_MODULE_18__["appendLineBreaks"])(DomElems.overviewDiv, 2);
- DomElems.overviewDiv.appendChild(DomElems.overviewBonusTime);
- DomElems.overviewDiv.appendChild(DomElems.overviewSkillPoints);
- Object(_utils_uiHelpers_appendLineBreaks__WEBPACK_IMPORTED_MODULE_18__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(DomElems.overviewAugSuccessMult);
- DomElems.overviewDiv.appendChild(DomElems.overviewAugMaxStaminaMult);
- DomElems.overviewDiv.appendChild(DomElems.overviewAugStaminaGainMult);
- DomElems.overviewDiv.appendChild(DomElems.overviewAugAnalysisMult);
-
- //Travel to new city button
- Object(_utils_uiHelpers_appendLineBreaks__WEBPACK_IMPORTED_MODULE_18__["appendLineBreaks"])(DomElems.overviewDiv, 1);
- DomElems.overviewDiv.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("a", {
- innerHTML:"Travel", class:"a-link-button", display:"inline-block",
- clickListener:()=>{
- var popupId = "bladeburner-travel-popup-cancel-btn";
- var popupArguments = [];
- popupArguments.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("a", { //Cancel Button
- innerText:"Cancel", class:"a-link-button",
- clickListener:()=>{
- Object(_utils_uiHelpers_removeElementById__WEBPACK_IMPORTED_MODULE_28__["removeElementById"])(popupId); return false;
- }
- }))
- popupArguments.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", { //Info Text
- innerText:"Travel to a different city for your Bladeburner " +
- "activities. This does not cost any money. The city you are " +
- "in for your Bladeburner duties does not affect " +
- "your location in the game otherwise",
- }));
- for (var i = 0; i < CityNames.length; ++i) {
- (function(inst, i) {
- popupArguments.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("div", {
- //Reusing this css class...it adds a border and makes it
- //so that background color changes when you hover
- class:"cmpy-mgmt-find-employee-option",
- innerText:CityNames[i],
- clickListener:()=>{
- inst.city = CityNames[i];
- Object(_utils_uiHelpers_removeElementById__WEBPACK_IMPORTED_MODULE_28__["removeElementById"])(popupId);
- inst.updateOverviewContent();
- return false;
- }
- }));
- })(this, i);
- }
- Object(_utils_uiHelpers_createPopup__WEBPACK_IMPORTED_MODULE_21__["createPopup"])(popupId, popupArguments);
- }
- }));
-
- //Faction button
- const bladeburnersFactionName = "Bladeburners";
- if (Object(_Faction_Factions__WEBPACK_IMPORTED_MODULE_6__["factionExists"])(bladeburnersFactionName)) {
- var bladeburnerFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_6__["Factions"][bladeburnersFactionName];
- if (!(bladeburnerFac instanceof _Faction_Faction__WEBPACK_IMPORTED_MODULE_5__["Faction"])) {
- throw new Error("Could not properly get Bladeburner Faction object in Bladeburner UI Overview Faction button");
- }
- DomElems.overviewDiv.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("a", {
- innerText:"Faction", class:"a-link-button", display:"inline-block",
- tooltip:"Apply to the Bladeburner Faction, or go to the faction page if you are already a member",
- clickListener:()=>{
- if (bladeburnerFac.isMember) {
- _engine__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadFactionContent();
- Object(_Faction_FactionHelpers__WEBPACK_IMPORTED_MODULE_7__[/* displayFactionContent */ "a"])(bladeburnersFactionName);
- } else {
- if (this.rank >= RankNeededForFaction) {
- Object(_Faction_FactionHelpers__WEBPACK_IMPORTED_MODULE_7__[/* joinFaction */ "c"])(bladeburnerFac);
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_14__["dialogBoxCreate"])("Congratulations! You were accepted into the Bladeburners faction");
- Object(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_15__["removeChildrenFromElement"])(DomElems.overviewDiv);
- this.createOverviewContent();
- } else {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_14__["dialogBoxCreate"])("You need a rank of 25 to join the Bladeburners Faction!")
- }
- }
- return false;
- }
- }));
- }
-
- DomElems.overviewDiv.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("br"));
- DomElems.overviewDiv.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("br"));
-
- this.updateOverviewContent();
-}
-
-Bladeburner.prototype.createActionAndSkillsContent = function() {
- if (DomElems.currentTab == null) {DomElems.currentTab = "general";}
-
- Object(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_15__["removeChildrenFromElement"])(DomElems.actionAndSkillsDiv);
- Object(_utils_helpers_clearObject__WEBPACK_IMPORTED_MODULE_19__["clearObject"])(DomElems.generalActions);
- Object(_utils_helpers_clearObject__WEBPACK_IMPORTED_MODULE_19__["clearObject"])(DomElems.contracts);
- Object(_utils_helpers_clearObject__WEBPACK_IMPORTED_MODULE_19__["clearObject"])(DomElems.operations);
- Object(_utils_helpers_clearObject__WEBPACK_IMPORTED_MODULE_19__["clearObject"])(DomElems.blackops);
- Object(_utils_helpers_clearObject__WEBPACK_IMPORTED_MODULE_19__["clearObject"])(DomElems.skills);
-
- //Navigation buttons
- var currTab = DomElems.currentTab.toLowerCase();
- var buttons = ["General", "Contracts", "Operations", "BlackOps", "Skills"];
- for (var i = 0; i < buttons.length; ++i) {
- (function(buttons, i, inst, currTab) {
-
- DomElems.actionAndSkillsDiv.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("a", {
- innerText:buttons[i],
- class:currTab === buttons[i].toLowerCase() ? "bladeburner-nav-button-inactive" : "bladeburner-nav-button",
- clickListener:()=>{
- DomElems.currentTab = buttons[i].toLowerCase();
- inst.createActionAndSkillsContent();
- return false;
- }
- }));
- }) (buttons, i, this, currTab);
- }
-
- //General info/description for each action
- DomElems.actionsAndSkillsDesc = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", {
- display:"block", margin:"4px", padding:"4px"
- });
-
- //List for actions/skills
- Object(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_15__["removeChildrenFromElement"])(DomElems.actionsAndSkillsList);
- DomElems.actionsAndSkillsList = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("ul");
-
- switch(currTab) {
- case "general":
- this.createGeneralActionsContent();
- break;
- case "contracts":
- this.createContractsContent();
- break;
- case "operations":
- this.createOperationsContent();
- break;
- case "blackops":
- this.createBlackOpsContent();
- break;
- case "skills":
- this.createSkillsContent();
- break;
- default:
- throw new Error("Invalid value for DomElems.currentTab in Bladeburner.createActionAndSkillsContent");
- }
- this.updateContent();
-
- DomElems.actionAndSkillsDiv.appendChild(DomElems.actionsAndSkillsDesc);
- DomElems.actionAndSkillsDiv.appendChild(DomElems.actionsAndSkillsList);
-}
-
-Bladeburner.prototype.createGeneralActionsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createGeneralActionsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- DomElems.actionsAndSkillsDesc.innerText =
- "These are generic actions that will assist you in your Bladeburner " +
- "duties. They will not affect your Bladeburner rank in any way."
-
- for (var actionName in GeneralActions) {
- if (GeneralActions.hasOwnProperty(actionName)) {
- DomElems.generalActions[actionName] = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("div", {
- class:"bladeburner-action", name:actionName
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.generalActions[actionName]);
- }
- }
-}
-
-Bladeburner.prototype.createContractsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createContractsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- DomElems.actionsAndSkillsDesc.innerHTML =
- "Complete contracts in order to increase your Bladeburner rank and earn money. " +
- "Failing a contract will cause you to lose HP, which can lead to hospitalization.
" +
- "You can unlock higher-level contracts by successfully completing them. " +
- "Higher-level contracts are more difficult, but grant more rank, experience, and money.";
-
- for (var contractName in this.contracts) {
- if (this.contracts.hasOwnProperty(contractName)) {
- DomElems.contracts[contractName] = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("div", {
- class:"bladeburner-action", name:contractName
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.contracts[contractName]);
- }
- }
-}
-
-Bladeburner.prototype.createOperationsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createOperationsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- DomElems.actionsAndSkillsDesc.innerHTML =
- "Carry out operations for the Bladeburner division. " +
- "Failing an operation will reduce your Bladeburner rank. It will also " +
- "cause you to lose HP, which can lead to hospitalization. In general, " +
- "operations are harder and more punishing than contracts, " +
- "but are also more rewarding.
" +
- "Operations can affect the chaos level and Synthoid population of your " +
- "current city. The exact effects vary between different Operations.
" +
- "For operations, you can use a team. You must first recruit team members. " +
- "Having a larger team will improves your chances of success.
" +
- "You can unlock higher-level operations by successfully completing them. " +
- "Higher-level operations are more difficult, but grant more rank and experience.";
-
- for (var operationName in this.operations) {
- if (this.operations.hasOwnProperty(operationName)) {
- DomElems.operations[operationName] = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("div", {
- class:"bladeburner-action", name:operationName
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.operations[operationName]);
- }
- }
-}
-
-Bladeburner.prototype.createBlackOpsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createBlackOpsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- DomElems.actionsAndSkillsDesc.innerHTML =
- "Black Operations (Black Ops) are special, one-time covert operations. " +
- "Each Black Op must be unlocked successively by completing " +
- "the one before it.
" +
- "Your ultimate goal to climb through the ranks of Bladeburners is to complete " +
- "all of the Black Ops.
" +
- "Like normal operations, you may use a team for Black Ops. Failing " +
- "a black op will incur heavy HP and rank losses.";
-
- //Put Black Operations in sequence of required rank
- var blackops = [];
- for (var blackopName in BlackOperations) {
- if (BlackOperations.hasOwnProperty(blackopName)) {
- blackops.push(BlackOperations[blackopName]);
- }
- }
- blackops.sort(function(a, b) {
- return (a.reqdRank - b.reqdRank);
- });
-
- for (var i = 0; i < blackops.length; ++i) {
- DomElems.blackops[blackops[i].name] = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("div", {
- class:"bladeburner-action", name:blackops[i].name
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.blackops[blackops[i].name]);
- if (this.blackops[[blackops[i].name]] == null) {break;} //Can't be found in completed blackops
- }
-}
-
-Bladeburner.prototype.createSkillsContent = function() {
- if (DomElems.actionsAndSkillsList == null || DomElems.actionsAndSkillsDesc == null) {
- throw new Error("Bladeburner.createSkillsContent called with either " +
- "DomElems.actionsAndSkillsList or DomElems.actionsAndSkillsDesc = null");
- }
-
- //Display Current multipliers
- DomElems.actionsAndSkillsDesc.innerHTML =
- "You will gain one skill point every " + RanksPerSkillPoint + " ranks.
" +
- "Note that when upgrading a skill, the benefit for that skill is additive. " +
- "However, the effects of different skills with each other is multiplicative.
"
- var multKeys = Object.keys(this.skillMultipliers);
- for (var i = 0; i < multKeys.length; ++i) {
- var mult = this.skillMultipliers[multKeys[i]];
- if (mult && mult !== 1) {
- mult = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(mult, 3);
- switch(multKeys[i]) {
- case "successChanceAll":
- DomElems.actionsAndSkillsDesc.innerHTML += "Total Success Chance: x" + mult + " ";
- break;
- case "successChanceStealth":
- DomElems.actionsAndSkillsDesc.innerHTML += "Stealth Success Chance: x" + mult + " ";
- break;
- case "successChanceKill":
- DomElems.actionsAndSkillsDesc.innerHTML += "Retirement Success Chance: x" + mult + " ";
- break;
- case "successChanceContract":
- DomElems.actionsAndSkillsDesc.innerHTML += "Contract Success Chance: x" + mult + " ";
- break;
- case "successChanceOperation":
- DomElems.actionsAndSkillsDesc.innerHTML += "Operation Success Chance: x" + mult + " ";
- break;
- case "successChanceEstimate":
- DomElems.actionsAndSkillsDesc.innerHTML += "Synthoid Data Estimate: x" + mult + " ";
- break;
- case "actionTime":
- DomElems.actionsAndSkillsDesc.innerHTML += "Action Time: x" + mult + " ";
- break;
- case "effHack":
- DomElems.actionsAndSkillsDesc.innerHTML += "Hacking Skill: x" + mult + " ";
- break;
- case "effStr":
- DomElems.actionsAndSkillsDesc.innerHTML += "Strength: x" + mult + " ";
- break;
- case "effDef":
- DomElems.actionsAndSkillsDesc.innerHTML += "Defense: x" + mult + " ";
- break;
- case "effDex":
- DomElems.actionsAndSkillsDesc.innerHTML += "Dexterity: x" + mult + " ";
- break;
- case "effAgi":
- DomElems.actionsAndSkillsDesc.innerHTML += "Agility: x" + mult + " ";
- break;
- case "effCha":
- DomElems.actionsAndSkillsDesc.innerHTML += "Charisma: x" + mult + " ";
- break;
- case "effInt":
- DomElems.actionsAndSkillsDesc.innerHTML += "Intelligence: x" + mult + " ";
- break;
- case "stamina":
- DomElems.actionsAndSkillsDesc.innerHTML += "Stamina: x" + mult + " ";
- break;
- case "weaponAbility":
- //DomElems.actionsAndSkillsDesc.innerHTML +=
- break;
- case "gunAbility":
- //DomElems.actionsAndSkillsDesc.innerHTML
- break;
- default:
- console.log("Warning: Unrecognized SkillMult Key: " + multKeys[i]);
- break;
- }
- }
- }
-
- //Skill Points
- DomElems.skillPointsDisplay = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("p", {
- innerHTML:" Skill Points: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(this.skillPoints, 0) + ""
- });
- DomElems.actionAndSkillsDiv.appendChild(DomElems.skillPointsDisplay);
-
- //UI Element for each skill
- for (var skillName in Skills) {
- if (Skills.hasOwnProperty(skillName)) {
- DomElems.skills[skillName] = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_20__["createElement"])("div", {
- class:"bladeburner-action", name:skillName
- });
- DomElems.actionsAndSkillsList.appendChild(DomElems.skills[skillName]);
- }
- }
-}
-
-Bladeburner.prototype.updateContent = function() {
- this.updateOverviewContent();
- this.updateActionAndSkillsContent();
-}
-
-Bladeburner.prototype.updateOverviewContent = function() {
- if (!_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22__["Page"].Bladeburner)) {return;}
- DomElems.overviewRank.childNodes[0].nodeValue = "Rank: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(this.rank, 2);
- DomElems.overviewStamina.innerText = "Stamina: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(this.stamina, 3) + " / " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(this.maxStamina, 3);
- DomElems.overviewGen1.innerHTML =
- "Stamina Penalty: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])((1-this.calculateStaminaPenalty())*100, 1) + "%
');
-
- if (DomElems.consoleTable.childNodes.length > MaxConsoleEntries) {
- DomElems.consoleTable.removeChild(DomElems.consoleTable.firstChild);
- }
-
- this.updateConsoleScroll();
-}
-
-Bladeburner.prototype.updateConsoleScroll = function() {
- DomElems.consoleDiv.scrollTop = DomElems.consoleDiv.scrollHeight;
-}
-
-Bladeburner.prototype.resetConsoleInput = function() {
- DomElems.consoleInput.value = "";
-}
-
-Bladeburner.prototype.clearConsole = function() {
- while (DomElems.consoleTable.childNodes.length > 1) {
- DomElems.consoleTable.removeChild(DomElems.consoleTable.firstChild);
- }
-
- this.consoleLogs.length = 0;
-}
-
-Bladeburner.prototype.log = function(input) {
- //Adds a timestamp and then just calls postToConsole
- this.postToConsole(`[${Object(_utils_helpers_getTimestamp__WEBPACK_IMPORTED_MODULE_26__["getTimestamp"])()}] ${input}`);
-}
-
-//Handles a potential series of commands (comm1; comm2; comm3;)
-Bladeburner.prototype.executeConsoleCommands = function(commands) {
- try {
- //Console History
- if (this.consoleHistory[this.consoleHistory.length-1] != commands) {
- this.consoleHistory.push(commands);
- if (this.consoleHistory.length > 50) {
- this.consoleHistory.splice(0, 1);
- }
- }
- consoleHistoryIndex = this.consoleHistory.length;
-
- var arrayOfCommands = commands.split(";");
- for (var i = 0; i < arrayOfCommands.length; ++i) {
- this.executeConsoleCommand(arrayOfCommands[i]);
- }
- } catch(e) {
- Object(_utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_23__["exceptionAlert"])(e);
- }
-}
-
-//A single command
-Bladeburner.prototype.executeConsoleCommand = function(command) {
- command = command.trim();
- command = command.replace(/\s\s+/g, ' '); //Replace all whitespace w/ a single space
-
- var args = this.parseCommandArguments(command);
- if (args.length <= 0) {return;} //Log an error?
-
- switch(args[0].toLowerCase()) {
- case "automate":
- this.executeAutomateConsoleCommand(args);
- break;
- case "clear":
- case "cls":
- this.clearConsole();
- break;
- case "help":
- this.executeHelpConsoleCommand(args);
- break;
- case "log":
- this.executeLogConsoleCommand(args);
- break;
- case "skill":
- this.executeSkillConsoleCommand(args);
- break;
- case "start":
- this.executeStartConsoleCommand(args);
- break;
- case "stop":
- this.resetAction();
- break;
- default:
- this.postToConsole("Invalid console command");
- break;
- }
-}
-
-Bladeburner.prototype.parseCommandArguments = function(command) {
- //Returns an array with command and its arguments in each index.
- //e.g. skill "blade's intuition" foo returns [skill, blade's intuition, foo]
- //The input to this fn will be trimmed and will have all whitespace replaced w/ a single space
- var args = [];
- var start = 0, i = 0;
- while (i < command.length) {
- var c = command.charAt(i);
- if (c === '"') {
- var endQuote = command.indexOf('"', i+1);
- if (endQuote !== -1 && (endQuote === command.length-1 || command.charAt(endQuote+1) === " ")) {
- args.push(command.substr(i+1, (endQuote - i - 1)));
- if (endQuote === command.length-1) {
- start = i = endQuote+1;
- } else {
- start = i = endQuote+2; //Skip the space
- }
- continue;
- }
- } else if (c === " ") {
- args.push(command.substr(start, i-start));
- start = i+1;
- }
- ++i;
- }
- if (start !== i) {args.push(command.substr(start, i-start));}
- console.log("Bladeburner.parseCommandArguments returned: " + args);
- return args;
-}
-
-Bladeburner.prototype.executeAutomateConsoleCommand = function(args) {
- if (args.length !== 2 && args.length !== 4) {
- this.postToConsole("Invalid use of 'automate' command: automate [var] [val] [hi/low]. Use 'help automate' for more info");
- return;
- }
-
- //Enable/Disable
- if (args.length === 2) {
- var flag = args[1];
- if (flag.toLowerCase() === "status") {
- this.postToConsole("Automation: " + (this.automateEnabled ? "enabled" : "disabled"));
- if (this.automateEnabled) {
- this.postToConsole("When your stamina drops to " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(this.automateThreshLow, 0) +
- ", you will automatically switch to " + this.automateActionLow.name +
- ". When your stamina recovers to " +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(this.automateThreshHigh, 0) + ", you will automatically " +
- "switch to " + this.automateActionHigh.name + ".");
- }
-
- } else if (flag.toLowerCase().includes("en")) {
- if (!(this.automateActionLow instanceof ActionIdentifier) ||
- !(this.automateActionHigh instanceof ActionIdentifier)) {
- return this.log("Failed to enable automation. Actions were not set");
- }
- this.automateEnabled = true;
- this.log("Bladeburner automation enabled");
- } else if (flag.toLowerCase().includes("d")) {
- this.automateEnabled = false;
- this.log("Bladeburner automation disabled");
- } else {
- this.log("Invalid argument for 'automate' console command: " + args[1]);
- }
- return;
- }
-
- //Set variables
- if (args.length === 4) {
- var variable = args[1], val = args[2];
-
- var highLow = false; //True for high, false for low
- if (args[3].toLowerCase().includes("hi")) {highLow = true;}
-
- switch (variable) {
- case "general":
- case "gen":
- if (GeneralActions[val] != null) {
- var action = new ActionIdentifier({
- type:ActionTypes[val], name:val
- });
- if (highLow) {
- this.automateActionHigh = action;
- } else {
- this.automateActionLow = action;
- }
- this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
- } else {
- this.postToConsole("Invalid action name specified: " + val);
- }
- break;
- case "contract":
- case "contracts":
- if (this.contracts[val] != null) {
- var action = new ActionIdentifier({
- type:ActionTypes.Contract, name:val
- });
- if (highLow) {
- this.automateActionHigh = action;
- } else {
- this.automateActionLow = action;
- }
- this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
- } else {
- this.postToConsole("Invalid contract name specified: " + val);
- }
- break;
- case "ops":
- case "op":
- case "operations":
- case "operation":
- if (this.operations[val] != null) {
- var action = new ActionIdentifier({
- type:ActionTypes.Operation, name:val
- });
- if (highLow) {
- this.automateActionHigh = action;
- } else {
- this.automateActionLow = action;
- }
- this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") action set to " + val);
- } else {
- this.postToConsole("Invalid Operation name specified: " + val);
- }
- break;
- case "stamina":
- if (isNaN(val)) {
- this.postToConsole("Invalid value specified for stamina threshold (must be numeric): " + val);
- } else {
- if (highLow) {
- this.automateThreshHigh = Number(val);
- } else {
- this.automateThreshLow = Number(val);
- }
- this.log("Automate (" + (highLow ? "HIGH" : "LOW") + ") stamina threshold set to " + val);
- }
- break;
- default:
- break;
- }
-
- return;
- }
-}
-
-Bladeburner.prototype.executeHelpConsoleCommand = function(args) {
- if (args.length === 1) {
- this.postToConsole(consoleHelpText.helpList);
- } else {
- for (var i = 1; i < args.length; ++i) {
- var commandText = consoleHelpText[args[i]];
- if (commandText != null) {
- this.postToConsole(commandText);
- this.postToConsole(" ");
- }
- }
- }
-}
-
-Bladeburner.prototype.executeLogConsoleCommand = function(args) {
- if (args.length < 3) {
- this.postToConsole("Invalid usage of log command: log [enable/disable] [action/event]");
- this.postToConsole("Use 'help log' for more details and examples");
- return;
- }
-
- var flag = true;
- if (args[1].toLowerCase().includes("d")) {flag = false;} //d for disable
-
- switch (args[2].toLowerCase()) {
- case "general":
- case "gen":
- this.logging.general = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for general actions");
- break;
- case "contract":
- case "contracts":
- this.logging.contracts = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for Contracts");
- break;
- case "ops":
- case "op":
- case "operations":
- case "operation":
- this.logging.ops = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for Operations");
- break;
- case "blackops":
- case "blackop":
- case "black operations":
- case "black operation":
- this.logging.blackops = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for BlackOps");
- break;
- case "event":
- case "events":
- this.logging.events = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for events");
- break;
- case "all":
- this.logging.general = flag;
- this.logging.contracts = flag;
- this.logging.ops = flag;
- this.logging.blackops = flag;
- this.logging.events = flag;
- this.log("Logging " + (flag ? "enabled" : "disabled") + " for everything");
- break;
- default:
- this.postToConsole("Invalid action/event type specified: " + args[2]);
- this.postToConsole("Examples of valid action/event identifiers are: [general, contracts, ops, blackops, events]");
- break;
- }
-}
-
-Bladeburner.prototype.executeSkillConsoleCommand = function(args) {
- switch (args.length) {
- case 1:
- //Display Skill Help Command
- this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
- this.postToConsole("Use 'help skill' for more info");
- break;
- case 2:
- if (args[1].toLowerCase() === "list") {
- //List all skills and their level
- this.postToConsole("Skills: ");
- var skillNames = Object.keys(Skills);
- for(var i = 0; i < skillNames.length; ++i) {
- var skill = Skills[skillNames[i]];
- var level = 0;
- if (this.skills[skill.name] != null) {level = this.skills[skill.name];}
- this.postToConsole(skill.name + ": Level " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(level, 0));
- }
- this.postToConsole(" ");
- this.postToConsole("Effects: ");
- var multKeys = Object.keys(this.skillMultipliers);
- for (var i = 0; i < multKeys.length; ++i) {
- var mult = this.skillMultipliers[multKeys[i]];
- if (mult && mult !== 1) {
- mult = Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(mult, 3);
- switch(multKeys[i]) {
- case "successChanceAll":
- this.postToConsole("Total Success Chance: x" + mult);
- break;
- case "successChanceStealth":
- this.postToConsole("Stealth Success Chance: x" + mult);
- break;
- case "successChanceKill":
- this.postToConsole("Retirement Success Chance: x" + mult);
- break;
- case "successChanceContract":
- this.postToConsole("Contract Success Chance: x" + mult);
- break;
- case "successChanceOperation":
- this.postToConsole("Operation Success Chance: x" + mult);
- break;
- case "successChanceEstimate":
- this.postToConsole("Synthoid Data Estimate: x" + mult);
- break;
- case "actionTime":
- this.postToConsole("Action Time: x" + mult);
- break;
- case "effHack":
- this.postToConsole("Hacking Skill: x" + mult);
- break;
- case "effStr":
- this.postToConsole("Strength: x" + mult);
- break;
- case "effDef":
- this.postToConsole("Defense: x" + mult);
- break;
- case "effDex":
- this.postToConsole("Dexterity: x" + mult);
- break;
- case "effAgi":
- this.postToConsole("Agility: x" + mult);
- break;
- case "effCha":
- this.postToConsole("Charisma: x" + mult);
- break;
- case "effInt":
- this.postToConsole("Intelligence: x" + mult);
- break;
- case "stamina":
- this.postToConsole("Stamina: x" + mult);
- break;
- case "weaponAbility":
- //DomElems.actionsAndSkillsDesc.innerHTML +=
- break;
- case "gunAbility":
- //DomElems.actionsAndSkillsDesc.innerHTML
- break;
- default:
- console.log("Warning: Unrecognized SkillMult Key: " + multKeys[i]);
- break;
- }
- }
- }
- } else {
- this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
- this.postToConsole("Use 'help skill' for more info");
- }
- break;
- case 3:
- var skillName = args[2];
- var skill = Skills[skillName];
- if (skill == null || !(skill instanceof Skill)) {
- return this.postToConsole("Invalid skill name (Note that this is case-sensitive): " + skillName);
- }
- if (args[1].toLowerCase() === "list") {
- this.postToConsole(skill.name + ": Level " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(this.skills[skill.name]), 0);
- } else if (args[1].toLowerCase() === "level") {
- var currentLevel = 0;
- if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
- currentLevel = this.skills[skillName];
- }
- var pointCost = skill.calculateCost(currentLevel);
- if (this.skillPoints >= pointCost) {
- this.skillPoints -= pointCost;
- this.upgradeSkill(skill);
- this.log(skill.name + " upgraded to Level " + this.skills[skillName]);
- this.createActionAndSkillsContent();
- } else {
- this.postToConsole("You do not have enough Skill Points to upgrade this. You need " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_24__["formatNumber"])(pointCost, 0));
- }
-
- } else {
- this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
- this.postToConsole("Use 'help skill' for more info");
- }
- break;
- default:
- this.postToConsole("Invalid usage of 'skill' console command: skill [action] [name]");
- this.postToConsole("Use 'help skill' for more info");
- break;
- }
-}
-
-Bladeburner.prototype.executeStartConsoleCommand = function(args) {
- if (args.length !== 3) {
- this.postToConsole("Invalid usage of 'start' console command: start [type] [name]");
- this.postToConsole("Use 'help start' for more info");
- return;
- }
- var name = args[2];
- switch (args[1].toLowerCase()) {
- case "general":
- case "gen":
- if (GeneralActions[name] != null) {
- this.action.type = ActionTypes[name];
- this.action.name = name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- } else {
- this.postToConsole("Invalid action name specified: " + args[2]);
- }
- break;
- case "contract":
- case "contracts":
- if (this.contracts[name] != null) {
- this.action.type = ActionTypes.Contract;
- this.action.name = name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- } else {
- this.postToConsole("Invalid contract name specified: " + args[2]);
- }
- break;
- case "ops":
- case "op":
- case "operations":
- case "operation":
- if (this.operations[name] != null) {
- this.action.type = ActionTypes.Operation;
- this.action.name = name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- } else {
- this.postToConsole("Invalid Operation name specified: " + args[2]);
- }
- break;
- case "blackops":
- case "blackop":
- case "black operations":
- case "black operation":
- if (BlackOperations[name] != null) {
- this.action.type = ActionTypes.BlackOperation;
- this.action.name = name;
- this.startAction(this.action);
- this.updateActionAndSkillsContent();
- } else {
- this.postToConsole("Invalid BlackOp name specified: " + args[2]);
- }
- break;
- default:
- this.postToConsole("Invalid action/event type specified: " + args[1]);
- this.postToConsole("Examples of valid action/event identifiers are: [general, contract, op, blackop]");
- break;
- }
-}
-
-Bladeburner.prototype.getActionIdFromTypeAndName = function(type="", name="") {
- if (type === "" || name === "") {return null;}
- var action = new ActionIdentifier();
- var convertedType = type.toLowerCase().trim();
- var convertedName = name.toLowerCase().trim();
- switch (convertedType) {
- case "contract":
- case "contracts":
- case "contr":
- action.type = ActionTypes["Contract"];
- if (this.contracts.hasOwnProperty(name)) {
- action.name = name;
- return action;
- } else {
- return null;
- }
- break;
- case "operation":
- case "operations":
- case "op":
- case "ops":
- action.type = ActionTypes["Operation"];
- if (this.operations.hasOwnProperty(name)) {
- action.name = name;
- return action;
- } else {
- return null;
- }
- break;
- case "blackoperation":
- case "black operation":
- case "black operations":
- case "black op":
- case "black ops":
- case "blackop":
- case "blackops":
- action.type = ActionTypes["BlackOp"];
- if (BlackOperations.hasOwnProperty(name)) {
- action.name = name;
- return action;
- } else {
- return null;
- }
- break;
- case "general":
- case "general action":
- case "gen":
- break;
- default:
- return null;
- }
-
- if (convertedType.startsWith("gen")) {
- switch (convertedName) {
- case "training":
- action.type = ActionTypes["Training"];
- action.name = "Training";
- break;
- case "recruitment":
- case "recruit":
- action.type = ActionTypes["Recruitment"];
- action.name = "Recruitment";
- break;
- case "field analysis":
- case "fieldanalysis":
- action.type = ActionTypes["Field Analysis"];
- action.name = "Field Analysis";
- break;
- default:
- return null;
- }
- return action;
- }
-}
-
-Bladeburner.prototype.getTypeAndNameFromActionId = function(actionId) {
- var res = {};
- let types = Object.keys(ActionTypes);
- for (let i = 0; i < types.length; ++i) {
- if (actionId.type === ActionTypes[types[i]]) {
- res.type = types[i];
- break;
- }
- }
- if (res.type == null) {res.type = "Idle";}
-
- res.name = actionId.name != null ? actionId.name : "Idle";
- return res;
-}
-
-Bladeburner.prototype.getContractNamesNetscriptFn = function() {
- return Object.keys(this.contracts);
-}
-
-Bladeburner.prototype.getOperationNamesNetscriptFn = function() {
- return Object.keys(this.operations);
-}
-
-Bladeburner.prototype.getBlackOpNamesNetscriptFn = function() {
- return Object.keys(BlackOperations);
-}
-
-Bladeburner.prototype.getGeneralActionNamesNetscriptFn = function() {
- return Object.keys(GeneralActions);
-}
-
-Bladeburner.prototype.getSkillNamesNetscriptFn = function() {
- return Object.keys(Skills);
-}
-
-Bladeburner.prototype.startActionNetscriptFn = function(type, name, workerScript) {
- var errorLogText = "ERROR: bladeburner.startAction() failed due to an invalid action specified. " +
- "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
- "name of the operation is case-sensitive.";
- var actionId = this.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return false;
- }
-
- // Special logic for Black Ops
- if (actionId.type === ActionTypes["BlackOp"]) {
- // Can't start a BlackOp if you don't have the required rank
- let action = this.getActionObject(actionId);
- if (action.reqdRank > this.rank) {
- workerScript.log(`Failed to start Black Op ${actionId.name} due to insufficient rank`);
- return false;
- }
-
- // Can't start a BlackOp if its already been done
- if (this.blackops[actionId.name] != null) {
- workerScript.log(`Failed to start Black Op ${actionId.name} because its already been completed`);
- return false;
- }
-
- // Can't start a BlackOp if you haven't done the one before it
- var blackops = [];
- for (const nm in BlackOperations) {
- if (BlackOperations.hasOwnProperty(nm)) {
- blackops.push(nm);
- }
- }
- blackops.sort(function(a, b) {
- return (BlackOperations[a].reqdRank - BlackOperations[b].reqdRank); // Sort black ops in intended order
- });
-
- let i = blackops.indexOf(actionId.name);
- if (i === -1) {
- workerScript.log("ERROR: Invalid Black Operation name passed into bladeburner.startAction(). Note that this name is case-sensitive & whitespace-sensitive");
- return false;
- }
-
- if (i > 0 && this.blackops[blackops[i-1]] == null) {
- workerScript.log(`ERROR: Cannot attempt Black Operation ${actionId.name} because you have not done the preceding one`);
- return false;
- }
- }
-
- try {
- this.startAction(actionId);
- if (workerScript.shouldLog("startAction")) {
- workerScript.scriptRef.log("Starting bladeburner action with type " + type + " and name " + name);
- }
- return true;
- } catch(e) {
- this.resetAction();
- workerScript.scriptRef.log("ERROR: bladeburner.startAction() failed to start action of type " + type + " due to invalid name: " + name +
- "Note that this name is case-sensitive and whitespace-sensitive");
- return false;
- }
-}
-
-Bladeburner.prototype.getActionTimeNetscriptFn = function(type, name, workerScript) {
- var errorLogText = "ERROR: bladeburner.getActionTime() failed due to an invalid action specified. " +
- "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
- "name of the operation is case-sensitive.";
- var actionId = this.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- var actionObj = this.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- switch (actionId.type) {
- case ActionTypes["Contract"]:
- case ActionTypes["Operation"]:
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- return actionObj.getActionTime(this);
- case ActionTypes["Training"]:
- case ActionTypes["Field Analysis"]:
- case ActionTypes["FieldAnalysis"]:
- return 30;
- case ActionTypes["Recruitment"]:
- return this.getRecruitmentTime();
- default:
- workerScript.log(errorLogText);
- return -1;
- }
-}
-
-Bladeburner.prototype.getActionEstimatedSuccessChanceNetscriptFn = function(type, name, workerScript) {
- var errorLogText = "ERROR: bladeburner.getActionEstimatedSuccessChance() failed due to an invalid action specified. " +
- "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
- "name of the operation is case-sensitive.";
- var actionId = this.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- var actionObj = this.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- switch (actionId.type) {
- case ActionTypes["Contract"]:
- case ActionTypes["Operation"]:
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- return actionObj.getSuccessChance(this, {est:true});
- case ActionTypes["Training"]:
- case ActionTypes["Field Analysis"]:
- case ActionTypes["FieldAnalysis"]:
- return 1;
- case ActionTypes["Recruitment"]:
- return this.getRecruitmentSuccessChance();
- default:
- workerScript.log(errorLogText);
- return -1;
- }
-}
-
-Bladeburner.prototype.getActionCountRemainingNetscriptFn = function(type, name, workerScript) {
- var errorLogText = "ERROR: bladeburner.getActionCountRemaining() failed due to an invalid action specified. " +
- "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
- "name of the operation is case-sensitive.";
- var actionId = this.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- var actionObj = this.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- switch (actionId.type) {
- case ActionTypes["Contract"]:
- case ActionTypes["Operation"]:
- return Math.floor( actionObj.count );
- case ActionTypes["BlackOp"]:
- case ActionTypes["BlackOperation"]:
- if (this.blackops[name] != null) {
- return 0;
- } else {
- return 1;
- }
- case ActionTypes["Training"]:
- case ActionTypes["Field Analysis"]:
- case ActionTypes["FieldAnalysis"]:
- return Infinity;
- default:
- workerScript.log(errorLogText);
- return -1;
- }
-}
-
-Bladeburner.prototype.getSkillLevelNetscriptFn = function(skillName, workerScript) {
- var errorLogText = "ERROR: bladeburner.getSkillLevel() failed due to an invalid skill specified: " +
- skillName + ". Note that the name of the skill is case-sensitive";
-
- if (skillName === "") {
- return -1;
- }
-
- if (!Skills.hasOwnProperty(skillName)) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- if (this.skills[skillName] == null) {
- return 0;
- } else {
- return this.skills[skillName];
- }
-}
-
-Bladeburner.prototype.getSkillUpgradeCostNetscriptFn = function(skillName, workerScript) {
- var errorLogText = "ERROR: bladeburner.getSkillUpgradeCostNetscriptFn() failed due to an invalid skill specified: " +
- skillName + ". Note that the name of the skill is case-sensitive";
-
- if (skillName === "") {
- return -1;
- }
-
- if (!Skills.hasOwnProperty(skillName)) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- var skill = Skills[skillName];
- if (this.skills[skillName] == null) {
- return skill.calculateCost(0);
- } else {
- return skill.calculateCost(this.skills[skillName]);
- }
-}
-
-Bladeburner.prototype.upgradeSkillNetscriptFn = function(skillName, workerScript) {
- var errorLogText = "ERROR: bladeburner.upgradeSkill() failed due to an invalid skill specified: " +
- skillName + ". Note that the name of the skill is case-sensitive";
- if (!Skills.hasOwnProperty(skillName)) {
- workerScript.log(errorLogText);
- return false;
- }
-
- var skill = Skills[skillName];
- var currentLevel = 0;
- if (this.skills[skillName] && !isNaN(this.skills[skillName])) {
- currentLevel = this.skills[skillName];
- }
- var cost = skill.calculateCost(currentLevel);
-
- if(skill.maxLvl && currentLevel >= skill.maxLvl) {
- if (workerScript.shouldLog("upgradeSkill")) {
- workerScript.log(`bladeburner.upgradeSkill() failed because ${skillName} is already maxed`);
- }
- return false;
- }
-
- if (this.skillPoints < cost) {
- if (workerScript.shouldLog("upgradeSkill")) {
- workerScript.log("bladeburner.upgradeSkill() failed because you do not have enough " +
- "skill points to upgrade " + skillName + " (You have " +
- this.skillPoints + ", you need " + cost + ")");
- }
- return false;
- }
-
- this.skillPoints -= cost;
- this.upgradeSkill(skill);
- if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22__["Page"].Bladeburner) && DomElems.currentTab.toLowerCase() === "skills") {
- this.createActionAndSkillsContent();
- }
- if (workerScript.shouldLog("upgradeSkill")) {
- workerScript.log(skillName + " successfully upgraded to level " + this.skills[skillName]);
- }
- return true;
-}
-
-Bladeburner.prototype.getTeamSizeNetscriptFn = function(type, name, workerScript) {
- if (type === "" && name === "") {
- return this.teamSize;
- }
-
- var errorLogText = "ERROR: bladeburner.getTeamSize() failed due to an invalid action specified. " +
- "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
- "name of the operation is case-sensitive.";
-
- var actionId = this.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- var actionObj = this.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- if (actionId.type === ActionTypes["Operation"] ||
- actionId.type === ActionTypes["BlackOp"] ||
- actionId.type === ActionTypes["BlackOperation"]) {
- return actionObj.teamCount;
- } else {
- return 0;
- }
-}
-
-Bladeburner.prototype.setTeamSizeNetscriptFn = function(type, name, size, workerScript) {
- var errorLogText = "ERROR: bladeburner.setTeamSize() failed due to an invalid action specified. " +
- "Type: " + type + ", Name: " + name + ". Note that for contracts and operations, the " +
- "name of the operation is case-sensitive.";
- var actionId = this.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- if (actionId.type !== ActionTypes["Operation"] &&
- actionId.type !== ActionTypes["BlackOp"] &&
- actionId.type !== ActionTypes["BlackOperation"]) {
- workerScript.log("ERROR: bladeburner.setTeamSize() failed. This function " +
- "only works for Operations and BlackOps");
- return -1;
- }
-
- var actionObj = this.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return -1;
- }
-
- var sanitizedSize = Math.round(size);
- if (isNaN(sanitizedSize)) {
- workerScript.log("ERROR: bladeburner.setTeamSize() failed due to an invalid 'size' argument: " + size);
- return -1;
- }
- if (this.teamSize < sanitizedSize) {sanitizedSize = this.teamSize;}
- actionObj.teamCount = sanitizedSize;
- if (workerScript.shouldLog("setTeamSize")) {
- workerScript.log("Team size for " + name + " set to " + sanitizedSize);
- }
- return sanitizedSize;
-}
-
-Bladeburner.prototype.getCityEstimatedPopulationNetscriptFn = function(cityName, workerScript) {
- if (!this.cities.hasOwnProperty(cityName)) {
- workerScript.log("ERROR: bladeburner.getCityEstimatedPopulation() failed because the specified " +
- "city was invalid: " + cityName + ". Note that this city argument is case-sensitive");
- return -1;
- }
- return this.cities[cityName].popEst;
-}
-
-Bladeburner.prototype.getCityEstimatedCommunitiesNetscriptFn = function(cityName, workerScript) {
- if (!this.cities.hasOwnProperty(cityName)) {
- workerScript.log("ERROR: bladeburner.getCityEstimatedCommunities() failed because the specified " +
- "city was invalid: " + cityName + ". Note that this city argument is case-sensitive");
- return -1;
- }
- return this.cities[cityName].commsEst;
-}
-
-Bladeburner.prototype.getCityChaosNetscriptFn = function(cityName, workerScript) {
- if (!this.cities.hasOwnProperty(cityName)) {
- workerScript.log("ERROR: bladeburner.getCityChaos() failed because the specified " +
- "city was invalid: " + cityName + ". Note that this city argument is case-sensitive");
- return -1;
- }
- return this.cities[cityName].chaos;
-}
-
-Bladeburner.prototype.switchCityNetscriptFn = function(cityName, workerScript) {
- if (!this.cities.hasOwnProperty(cityName)) {
- workerScript.log("ERROR: bladeburner.switchCity() failed because the specified " +
- "city was invalid: " + cityName + ". Note that this city argument is case-sensitive");
- return false;
- }
- this.city = cityName;
- return true;
-}
-
-Bladeburner.prototype.joinBladeburnerFactionNetscriptFn = function(workerScript) {
- var bladeburnerFac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_6__["Factions"]["Bladeburners"];
- if (bladeburnerFac.isMember) {
- return true;
- } else if (this.rank >= RankNeededForFaction) {
- Object(_Faction_FactionHelpers__WEBPACK_IMPORTED_MODULE_7__[/* joinFaction */ "c"])(bladeburnerFac);
- if (workerScript.shouldLog("joinBladeburnerFaction")) {
- workerScript.log("Joined Bladeburners Faction");
- }
- if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_22__["Page"].Bladeburner)) {
- Object(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_15__["removeChildrenFromElement"])(DomElems.overviewDiv);
- this.createOverviewContent();
- }
- return true;
- } else {
- if (workerScript.shouldLog("joinBladeburnerFaction")) {
- workerScript.log("Failed to join Bladeburners Faction because " +
- "you do not have the required " + RankNeededForFaction + " rank");
- }
- return false;
- }
-}
-
-Bladeburner.prototype.toJSON = function() {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Generic_toJSON"])("Bladeburner", this);
-}
-Bladeburner.fromJSON = function(value) {
- return Object(_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Generic_fromJSON"])(Bladeburner, value.data);
-}
-_utils_JSONReviver__WEBPACK_IMPORTED_MODULE_16__["Reviver"].constructors.Bladeburner = Bladeburner;
-
-//This initialized Bladeburner-related data that is NOT saved/loaded
-// eg: Skill Objects, BLack Operations
-//Any data that is saved/loaded should go in Bladeburner object
-// eg: contracts, operations
-function initBladeburner() {
- //Skills
- Skills[SkillNames.BladesIntuition] = new Skill({
- name:SkillNames.BladesIntuition,
- desc:"Each level of this skill increases your success chance " +
- "for all Contracts, Operations, and BlackOps by 3%",
- baseCost:5, costInc:2,
- successChanceAll:3
- });
- Skills[SkillNames.Reaper] = new Skill({
- name:SkillNames.Reaper,
- desc:"Each level of this skill increases your " +
- "effective combat stats for Bladeburner actions by 3%",
- baseCost:3, costInc:2,
- effStr:3, effDef:3, effDex:3, effAgi:3
- });
- Skills[SkillNames.Cloak] = new Skill({
- name:SkillNames.Cloak,
- desc:"Each level of this skill increases your " +
- "success chance in stealth-related Contracts, Operations, and BlackOps by 5.5%",
- baseCost:3, costInc:1,
- successChanceStealth:5.5
- });
-
- //TODO Marksman
- //TODO Weapon Proficiency
-
- Skills[SkillNames.Overclock] = new Skill({
- name:SkillNames.Overclock,
- desc:"Each level of this skill decreases the time it takes " +
- "to attempt a Contract, Operation, and BlackOp by 1% (Max Level: 95)",
- baseCost:5, costInc:1.1, maxLvl:95,
- actionTime:1
- });
- Skills[SkillNames.EvasiveSystem] = new Skill({
- name:SkillNames.EvasiveSystem,
- desc:"Each level of this skill increases your effective " +
- "dexterity and agility for Bladeburner actions by 5%",
- baseCost:2, costInc: 1,
- effDex:5, effAgi:5
- });
- Skills[SkillNames.ShortCircuit] = new Skill({
- name:SkillNames.ShortCircuit,
- desc:"Each level of this skill increases your success chance " +
- "in Contracts, Operations, and BlackOps that involve retirement by 5.5%",
- baseCost:3, costInc:2,
- successChanceKill:5.5
- });
- Skills[SkillNames.DigitalObserver] = new Skill({
- name:SkillNames.DigitalObserver,
- desc:"Each level of this skill increases your success chance in " +
- "all Operations and BlackOps by 4%",
- baseCost:5, costInc:2,
- successChanceOperation:4
- });
- Skills[SkillNames.Datamancer] = new Skill({
- name:SkillNames.Datamancer,
- desc:"Each level of this skill increases your effectiveness in " +
- "synthoid population analysis and investigation by 5%. " +
- "This affects all actions that can potentially increase " +
- "the accuracy of your synthoid population/community estimates.",
- baseCost:3,costInc:1,
- successChanceEstimate:5
- });
- Skills[SkillNames.Tracer] = new Skill({
- name:SkillNames.Tracer,
- desc:"Each level of this skill increases your success chance in " +
- "all Contracts by 4%",
- baseCost:3, costInc:2,
- successChanceContract:4
- });
- Skills[SkillNames.CybersEdge] = new Skill({
- name:SkillNames.CybersEdge,
- desc:"Each level of this skill increases your max " +
- "stamina by 2%",
- baseCost:1, costInc:3,
- stamina:2
- });
-
- //General Actions
- var actionName = "Training";
- GeneralActions[actionName] = new Action({
- name:actionName,
- desc:"Improve your abilities at the Bladeburner unit's specialized training " +
- "center. Doing this gives experience for all combat stats and also " +
- "increases your max stamina."
- });
-
- var actionName = "Field Analysis";
- GeneralActions[actionName] = new Action({
- name:actionName,
- desc:"Mine and analyze Synthoid-related data. This improve the " +
- "Bladeburner's unit intelligence on Synthoid locations and " +
- "activities. Completing this action will improve the accuracy " +
- "of your Synthoid population estimated in the current city.
" +
- "Does NOT require stamina."
- });
-
- var actionName = "Recruitment";
- GeneralActions[actionName] = new Action({
- name:actionName,
- desc:"Attempt to recruit members for your Bladeburner team. These members " +
- "can help you conduct operations.
" +
- "Does NOT require stamina."
- });
-
- //Black Operations
- BlackOperations["Operation Typhoon"] = new BlackOperation({
- name:"Operation Typhoon",
- desc:"Obadiah Zenyatta is the leader of a RedWater PMC. It has long " +
- "been known among the intelligence community that Zenyatta, along " +
- "with the rest of the PMC, is a Synthoid.
" +
- "The goal of Operation Typhoon is to find and eliminate " +
- "Zenyatta and RedWater by any means necessary. After the task " +
- "is completed, the actions must be covered up from the general public.",
- baseDifficulty:2000, reqdRank:2.5e3,
- rankGain:50, rankLoss:10, hpLoss:100,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Zero"] = new BlackOperation({
- name:"Operation Zero",
- desc:"AeroCorp is one of the world's largest defense contractors. " +
- "It's leader, Steve Watataki, is thought to be a supporter of " +
- "Synthoid rights. He must be removed.
" +
- "The goal of Operation Zero is to covertly infiltrate AeroCorp and " +
- "uncover any incriminating evidence or " +
- "information against Watataki that will cause him to be removed " +
- "from his position at AeroCorp. Incriminating evidence can be " +
- "fabricated as a last resort. Be warned that AeroCorp has some of " +
- "the most advanced security measures in the world.",
- baseDifficulty:2500, reqdRank:5e3,
- rankGain:60, rankLoss:15, hpLoss:50,
- weights:{hack:0.2,str:0.15,def:0.15,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isStealth:true
- });
- BlackOperations["Operation X"] = new BlackOperation({
- name:"Operation X",
- desc:"We have recently discovered an underground publication " +
- "group called Samizdat. Even though most of their publications " +
- "are nonsensical conspiracy theories, the average human is " +
- "gullible enough to believe them. Many of their works discuss " +
- "Synthoids and pose a threat to society. The publications are spreading " +
- "rapidly in China and other Eastern countries.
" +
- "Samizdat has done a good job of keeping hidden and anonymous. " +
- "However, we've just received intelligence that their base of " +
- "operations is in Ishima's underground sewer systems. Your task is to " +
- "investigate the sewer systems, and eliminate Samizdat. They must " +
- "never publish anything again.",
- baseDifficulty:3000, reqdRank:7.5e3,
- rankGain:75, rankLoss:15, hpLoss:100,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Titan"] = new BlackOperation({
- name:"Operation Titan",
- desc:"Several months ago Titan Laboratories' Bioengineering department " +
- "was infiltrated by Synthoids. As far as we know, Titan Laboratories' " +
- "management has no knowledge about this. We don't know what the " +
- "Synthoids are up to, but the research that they could " +
- "be conducting using Titan Laboraties' vast resources is potentially " +
- "very dangerous.
" +
- "Your goal is to enter and destroy the Bioengineering department's " +
- "facility in Aevum. The task is not just to retire the Synthoids there, but " +
- "also to destroy any information or research at the facility that " +
- "is relevant to the Synthoids and their goals.",
- baseDifficulty:4000, reqdRank:10e3,
- rankGain:100, rankLoss:20, hpLoss:100,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Ares"] = new BlackOperation({
- name:"Operation Ares",
- desc:"One of our undercover agents, Agent Carter, has informed us of a " +
- "massive weapons deal going down in Dubai between rogue Russian " +
- "militants and a radical Synthoid community. These weapons are next-gen " +
- "plasma and energy weapons. It is critical for the safety of humanity " +
- "that this deal does not happen.
" +
- "Your task is to intercept the deal. Leave no survivors.",
- baseDifficulty:5000, reqdRank:12.5e3,
- rankGain:125, rankLoss:20, hpLoss:200,
- weights:{hack:0,str:0.25,def:0.25,dex:0.25,agi:0.25,cha:0, int:0},
- decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Archangel"] = new BlackOperation({
- name:"Operation Archangel",
- desc:"Our analysts have discovered that the popular Red Rabbit brothel in " +
- "Amsterdam is run and 'staffed' by MK-VI Synthoids. Intelligence " +
- "suggests that the profit from this brothel is used to fund a large " +
- "black market arms trafficking operation.
" +
- "The goal of this operation is to take out the leaders that are running " +
- "the Red Rabbit brothel. Try to limit the number of other casualties, " +
- "but do what you must to complete the mission.",
- baseDifficulty:7500, reqdRank:15e3,
- rankGain:200, rankLoss:20, hpLoss:25,
- weights:{hack:0,str:0.2,def:0.2,dex:0.3,agi:0.3,cha:0, int:0},
- decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation Juggernaut"] = new BlackOperation({
- name:"Operation Juggernaut",
- desc:"The CIA has just encountered a new security threat. A new " +
- "criminal group, lead by a shadowy operative who calls himself " +
- "Juggernaut, has been smuggling drugs and weapons (including " +
- "suspected bioweapons) into Sector-12. We also have reason " +
- "to believe the tried to break into one of Universal Energy's " +
- "facilities in order to cause a city-wide blackout. The CIA " +
- "suspects that Juggernaut is a heavily-augmented Synthoid, and " +
- "have thus enlisted our help.
" +
- "Your mission is to eradicate Juggernaut and his followers.",
- baseDifficulty:10e3, reqdRank:20e3,
- rankGain:300, rankLoss:40, hpLoss:300,
- weights:{hack:0,str:0.25,def:0.25,dex:0.25,agi:0.25,cha:0, int:0},
- decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation Red Dragon"] = new BlackOperation({
- name:"Operation Red Dragon",
- desc:"The Tetrads criminal organization is suspected of " +
- "reverse-engineering the MK-VI Synthoid design. We believe " +
- "they altered and possibly improved the design and began " +
- "manufacturing their own Synthoid models in order to bolster " +
- "their criminal activities.
" +
- "Your task is to infiltrate and destroy the Tetrads' base of operations " +
- "in Los Angeles. Intelligence tells us that their base houses " +
- "one of their Synthoid manufacturing units.",
- baseDifficulty:12.5e3, reqdRank:25e3,
- rankGain:500, rankLoss:50, hpLoss:500,
- weights:{hack:0.05,str:0.2,def:0.2,dex:0.25,agi:0.25,cha:0, int:0.05},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation K"] = new BlackOperation({
- name:"Operation K",
- desc:"CODE RED SITUATION. Our intelligence tells us that VitaLife " +
- "has discovered a new android cloning technology. This technology " +
- "is supposedly capable of cloning Synthoid, not only physically " +
- "but also their advanced AI modules. We do not believe that " +
- "VitaLife is trying to use this technology illegally or " +
- "maliciously, but if any Synthoids were able to infiltrate the " +
- "corporation and take advantage of this technology then the " +
- "results would be catastrophic.
" +
- "We do not have the power or jurisdiction to shutdown this down " +
- "through legal or political means, so we must resort to a covert " +
- "operation. Your goal is to destroy this technology and eliminate" +
- "anyone who was involved in its creation.",
- baseDifficulty:15e3, reqdRank:30e3,
- rankGain:750, rankLoss:60, hpLoss:1000,
- weights:{hack:0.05,str:0.2,def:0.2,dex:0.25,agi:0.25,cha:0, int:0.05},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Deckard"] = new BlackOperation({
- name:"Operation Deckard",
- desc:"Despite your success in eliminating VitaLife's new android-replicating " +
- "technology in Operation K, we've discovered that a small group of " +
- "MK-VI Synthoids were able to make off with the schematics and design " +
- "of the technology before the Operation. It is almost a certainty that " +
- "these Synthoids are some of the rogue MK-VI ones from the Synthoid Uprising." +
- "The goal of Operation Deckard is to hunt down these Synthoids and retire " +
- "them. I don't need to tell you how critical this mission is.",
- baseDifficulty:20e3, reqdRank:40e3,
- rankGain:1e3, rankLoss:75, hpLoss:200,
- weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
- decays:{hack:0,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation Tyrell"] = new BlackOperation({
- name:"Operation Tyrell",
- desc:"A week ago Blade Industries reported a small break-in at one " +
- "of their Aevum Augmentation storage facitilities. We figured out " +
- "that The Dark Army was behind the heist, and didn't think any more " +
- "of it. However, we've just discovered that several known MK-VI Synthoids " +
- "were part of that break-in group.
" +
- "We cannot have Synthoids upgrading their already-enhanced abilities " +
- "with Augmentations. Your task is to hunt down the associated Dark Army " +
- "members and eliminate them.",
- baseDifficulty:25e3, reqdRank:50e3,
- rankGain:1.5e3, rankLoss:100, hpLoss:500,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true,
- });
- BlackOperations["Operation Wallace"] = new BlackOperation({
- name:"Operation Wallace",
- desc:"Based on information gathered from Operation Tyrell, we've discovered " +
- "that The Dark Army was well aware that there were Synthoids amongst " +
- "their ranks. Even worse, we believe that The Dark Army is working " +
- "together with other criminal organizations such as The Syndicate and " +
- "that they are planning some sort of large-scale takeover of multiple major " +
- "cities, most notably Aevum. We suspect that Synthoids have infiltrated " +
- "the ranks of these criminal factions and are trying to stage another " +
- "Synthoid uprising.
" +
- "The best way to deal with this is to prevent it before it even happens. " +
- "The goal of Operation Wallace is to destroy the Dark Army and " +
- "Syndicate factions in Aevum immediately. Leave no survivors.",
- baseDifficulty:30e3, reqdRank:75e3,
- rankGain:2e3, rankLoss:150, hpLoss:1500,
- weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Shoulder of Orion"] = new BlackOperation({
- name:"Operation Shoulder of Orion",
- desc:"China's Solaris Space Systems is secretly launching the first " +
- "manned spacecraft in over a decade using Synthoids. We believe " +
- "China is trying to establish the first off-world colonies.
" +
- "The mission is to prevent this launch without instigating an " +
- "international conflict. When you accept this mission you will be " +
- "officially disavowed by the NSA and the national government until after you " +
- "successfully return. In the event of failure, all of the operation's " +
- "team members must not let themselves be captured alive.",
- baseDifficulty:35e3, reqdRank:100e3,
- rankGain:2.5e3, rankLoss:500, hpLoss:1500,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isStealth:true
- });
- BlackOperations["Operation Hyron"] = new BlackOperation({
- name:"Operation Hyron",
- desc:"Our intelligence tells us that Fulcrum Technologies is developing " +
- "a quantum supercomputer using human brains as core " +
- "processors. This supercomputer " +
- "is rumored to be able to store vast amounts of data and " +
- "perform computations unmatched by any other supercomputer on the " +
- "planet. But more importantly, the use of organic human brains " +
- "means that the supercomputer may be able to reason abstractly " +
- "and become self-aware.
" +
- "I do not need to remind you why sentient-level AIs pose a serious " +
- "thread to all of mankind.
" +
- "The research for this project is being conducted at one of Fulcrum " +
- "Technologies secret facilities in Aevum, codenamed 'Alpha Ranch'. " +
- "Infiltrate the compound, delete and destroy the work, and then find and kill the " +
- "project lead.",
- baseDifficulty:40e3, reqdRank:125e3,
- rankGain:3e3, rankLoss:1e3, hpLoss:500,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Morpheus"] = new BlackOperation({
- name:"Operation Morpheus",
- desc:"DreamSense Technologies is an advertising company that uses " +
- "special technology to transmit their ads into the peoples " +
- "dreams and subconcious. They do this using broadcast transmitter " +
- "towers. Based on information from our agents and informants in " +
- "Chonqging, we have reason to believe that one of the broadcast " +
- "towers there has been compromised by Synthoids and is being used " +
- "to spread pro-Synthoid propaganda.
" +
- "The mission is to destroy this broadcast tower. Speed and " +
- "stealth are of the upmost important for this.",
- baseDifficulty:45e3, reqdRank:150e3,
- rankGain:4e3, rankLoss:1e3, hpLoss:100,
- weights:{hack:0.05,str:0.15,def:0.15,dex:0.3,agi:0.3,cha:0, int:0.05},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isStealth:true
- });
- BlackOperations["Operation Ion Storm"] = new BlackOperation({
- name:"Operation Ion Storm",
- desc:"Our analysts have uncovered a gathering of MK-VI Synthoids " +
- "that have taken up residence in the Sector-12 Slums. We " +
- "don't know if they are rogue Synthoids from the Uprising, " +
- "but we do know that they have been stockpiling " +
- "weapons, money, and other resources. This makes them dangerous.
" +
- "This is a full-scale assault operation to find and retire all of these " +
- "Synthoids in the Sector-12 Slums.",
- baseDifficulty:50e3, reqdRank:175e3,
- rankGain:5e3, rankLoss:1e3, hpLoss:5000,
- weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Annihilus"] = new BlackOperation({
- name:"Operation Annihilus",
- desc:"Our superiors have ordered us to eradicate everything and everyone " +
- "in an underground facility located in Aevum. They tell us " +
- "that the facility houses many dangerous Synthoids and " +
- "belongs to a terrorist organization called " +
- "'The Covenant'. We have no prior intelligence about this " +
- "organization, so you are going in blind.",
- baseDifficulty:55e3, reqdRank:200e3,
- rankGain:7.5e3, rankLoss:1e3, hpLoss:10e3,
- weights:{hack:0,str:0.24,def:0.24,dex:0.24,agi:0.24,cha:0, int:0.04},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Ultron"] = new BlackOperation({
- name:"Operation Ultron",
- desc:"OmniTek Incorporated, the original designer and manufacturer of Synthoids, " +
- "has notified us of a malfunction in their AI design. This malfunction, " +
- "when triggered, causes MK-VI Synthoids to become radicalized and seek out " +
- "the destruction of humanity. They say that this bug affects all MK-VI Synthoids, " +
- "not just the rogue ones from the Uprising.
" +
- "OmniTek has also told us they they believe someone has triggered this " +
- "malfunction in a large group of MK-VI Synthoids, and that these newly-radicalized Synthoids " +
- "are now amassing in Volhaven to form a terrorist group called Ultron.
" +
- "Intelligence suggests Ultron is heavily armed and that their members are " +
- "augmented. We believe Ultron is making moves to take control of " +
- "and weaponize DeltaOne's Tactical High-Energy Satellite Laser Array (THESLA).
" +
- "Your task is to find and destroy Ultron.",
- baseDifficulty:60e3, reqdRank:250e3,
- rankGain:10e3, rankLoss:2e3, hpLoss:10e3,
- weights:{hack:0.1,str:0.2,def:0.2,dex:0.2,agi:0.2,cha:0, int:0.1},
- decays:{hack:0.6,str:0.8,def:0.8,dex:0.8,agi:0.8,cha:0, int:0.75},
- isKill:true
- });
- BlackOperations["Operation Centurion"] = new BlackOperation({
- name:"Operation Centurion",
- desc:"D)@#)($M)C0293c40($*)@#D0JUMP3Rm0C<*@#)*$)#02c94830c(#$*D)
" +
- "Throughout all of humanity's history, we have relied on " +
- "technology to survive, conquer, and progress. Its advancement became our primary goal. " +
- "And at the peak of human civilization technology turned into " +
- "power. Global, absolute power.
" +
- "It seems that the universe is not without a sense of irony.
" +
- "This tutorial will show you the basics of the game. " +
- "You may skip the tutorial at any time.");
- nextBtn.style.display = "inline-block";
- break;
- case iTutorialSteps.GoToCharacterPage:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("Let's start by heading to the Stats page. Click the 'Stats' tab on " +
- "the main navigation menu (left-hand side of the screen)");
- nextBtn.style.display = "none";
-
- //Flash 'Stats' menu and set its tutorial click handler
- statsMainMenu.setAttribute("class", "flashing-button");
- statsMainMenu.addEventListener("click", function() {
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadCharacterContent();
- iTutorialNextStep(); //Opening the character page will go to the next step
- return false;
- });
- break;
- case iTutorialSteps.CharacterPage:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadCharacterContent();
- iTutorialSetText("The Stats page shows a lot of important information about your progress, " +
- "such as your skills, money, and bonuses/multipliers. ")
- nextBtn.style.display = "inline-block";
- break;
- case iTutorialSteps.CharacterGoToTerminalPage:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadCharacterContent();
- iTutorialSetText("Let's head to your computer's terminal by clicking the 'Terminal' tab on the " +
- "main navigation menu.");
- nextBtn.style.display = "none";
-
- //Flash 'Terminal' menu and set its tutorial click handler
- terminalMainMenu.setAttribute("class", "flashing-button");
- terminalMainMenu.addEventListener("click", function() {
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialNextStep();
- return false;
- });
- break;
- case iTutorialSteps.TerminalIntro:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("The Terminal is used to interface with your home computer as well as " +
- "all of the other machines around the world.");
- nextBtn.style.display = "inline-block";
- break;
- case iTutorialSteps.TerminalHelp:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("Let's try it out. Start by entering the 'help' command into the Terminal " +
- "(Don't forget to press Enter after typing the command)");
- nextBtn.style.display = "none"; //next step triggered by terminal command
- break;
- case iTutorialSteps.TerminalLs:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("The 'help' command displays a list of all available Terminal commands, how to use them, " +
- "and a description of what they do.
Let's try another command. Enter the 'ls' command");
- nextBtn.style.display = "none"; //next step triggered by terminal command
- break;
- case iTutorialSteps.TerminalScan:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("'ls' is a basic command that shows all of the contents (programs/scripts) " +
- "on the computer. Right now, it shows that you have a program called 'NUKE.exe' on your computer. " +
- "We'll get to what this does later.
Using your home computer's terminal, you can connect " +
- "to other machines throughout the world. Let's do that now by first entering " +
- "the 'scan' command.");
- nextBtn.style.display = "none"; //next step triggered by terminal command
- break;
- case iTutorialSteps.TerminalScanAnalyze1:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("The 'scan' command shows all available network connections. In other words, " +
- "it displays a list of all servers that can be connected to from your " +
- "current machine. A server is identified by either its IP or its hostname.
" +
- "That's great and all, but there's so many servers. Which one should you go to? " +
- "The 'scan-analyze' command gives some more detailed information about servers on the " +
- "network. Try it now");
- nextBtn.style.display = "none"; //next step triggered by terminal command
- break;
- case iTutorialSteps.TerminalScanAnalyze2:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("You just ran 'scan-analyze' with a depth of one. This command shows more detailed " +
- "information about each server that you can connect to (servers that are a distance of " +
- "one node away).
It is also possible to run 'scan-analyze' with " +
- "a higher depth. Let's try a depth of two with the following command: 'scan-analyze 2'.")
- nextBtn.style.display = "none"; //next step triggered by terminal command
- break;
- case iTutorialSteps.TerminalConnect:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("Now you can see information about all servers that are up to two nodes away, as well " +
- "as figure out how to navigate to those servers through the network. You can only connect to " +
- "a server that is one node away. To connect to a machine, use the 'connect [ip/hostname]' command. You can type in " +
- "the ip or the hostname, but dont use both.
" +
- "From the results of the 'scan-analyze' command, we can see that the 'foodnstuff' server is " +
- "only one node away. Let's connect so it now using: 'connect foodnstuff'");
- nextBtn.style.display = "none"; //next step triggered by terminal command
- break;
- case iTutorialSteps.TerminalAnalyze:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("You are now connected to another machine! What can you do now? You can hack it!
In the year 2077, currency has " +
- "become digital and decentralized. People and corporations store their money " +
- "on servers and computers. Using your hacking abilities, you can hack servers " +
- "to steal money and gain experience.
" +
- "Before you try to hack a server, you should run diagnostics using the 'analyze' command");
- nextBtn.style.display = "none"; //next step triggered by terminal command
- break;
- case iTutorialSteps.TerminalNuke:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("When the 'analyze' command finishes running it will show useful information " +
- "about hacking the server.
For this server, the required hacking skill is only 1, " +
- "which means you can hack it right now. However, in order to hack a server " +
- "you must first gain root access. The 'NUKE.exe' program that we saw earlier on your " +
- "home computer is a virus that will grant you root access to a machine if there are enough " +
- "open ports.
The 'analyze' results shows that there do not need to be any open ports " +
- "on this machine for the NUKE virus to work, so go ahead and run the virus using the " +
- "'run NUKE.exe' command.");
- nextBtn.style.display = "none"; //next step triggered by terminal command
- break;
- case iTutorialSteps.TerminalManualHack:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("You now have root access! You can hack the server using the 'hack' command. " +
- "Try doing that now.");
- nextBtn.style.display = "none"; //next step triggered by terminal command
- break;
- case iTutorialSteps.TerminalHackingMechanics:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("You are now attempting to hack the server. Note that performing a hack takes time and " +
- "only has a certain percentage chance " +
- "of success. This time and success chance is determined by a variety of factors, including " +
- "your hacking skill and the server's security level.
" +
- "If your attempt to hack the server is successful, you will steal a certain percentage " +
- "of the server's total money. This percentage is affected by your hacking skill and " +
- "the server's security level.
The amount of money on a server is not limitless. So, if " +
- "you constantly hack a server and deplete its money, then you will encounter " +
- "diminishing returns in your hacking.");
- nextBtn.style.display = "inline-block";
- break;
- case iTutorialSteps.TerminalCreateScript:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("Hacking is the core mechanic of the game and is necessary for progressing. However, " +
- "you don't want to be hacking manually the entire time. You can automate your hacking " +
- "by writing scripts!
To create a new script or edit an existing one, you can use the 'nano' " +
- "command. Scripts must end with the '.script' extension. Let's make a script now by " +
- "entering 'nano foodnstuff.script' after the hack command finishes running (Sidenote: Pressing ctrl + c" +
- " will end a command like hack early)");
- nextBtn.style.display = "none"; //next step triggered by terminal command
- break;
- case iTutorialSteps.TerminalTypeScript:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadScriptEditorContent("foodnstuff.script", "");
- iTutorialSetText("This is the script editor. You can use it to program your scripts. Scripts are " +
- "written in the Netscript language, a programming language created for " +
- "this game. There are details about the Netscript language in the documentation, which " +
- "can be accessed in the 'Tutorial' tab on the main navigation menu. I highly suggest you check " +
- "it out after this tutorial. For now, just copy " +
- "and paste the following code into the script editor:
" +
- "For anyone with basic programming experience, this code should be straightforward. " +
- "This script will continuously hack the 'foodnstuff' server.
" +
- "To save and close the script editor, press the button in the bottom left, or press ctrl + b.");
- nextBtn.style.display = "none"; //next step triggered in saveAndCloseScriptEditor() (Script.js)
- break;
- case iTutorialSteps.TerminalFree:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("Now we'll run the script. Scripts require a certain amount of RAM to run, and can be " +
- "run on any machine which you have root access to. Different servers have different " +
- "amounts of RAM. You can also purchase more RAM for your home server.
To check how much " +
- "RAM is available on this machine, enter the 'free' command.");
- nextBtn.style.display = "none"; //next step triggered by terminal commmand
- break;
- case iTutorialSteps.TerminalRunScript:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("We have 16GB of free RAM on this machine, which is enough to run our " +
- "script. Let's run our script using 'run foodnstuff.script'.");
- nextBtn.style.display = "none"; //next step triggered by terminal commmand
- break;
- case iTutorialSteps.TerminalGoToActiveScriptsPage:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("Your script is now running! The script might take a few seconds to 'fully start up'. " +
- "Your scripts will continuously run in the background and will automatically stop if " +
- "the code ever completes (the 'foodnstuff.script' will never complete because it " +
- "runs an infinite loop).
These scripts can passively earn you income and hacking experience. " +
- "Your scripts will also earn money and experience while you are offline, although at a " +
- "much slower rate.
" +
- "Let's check out some statistics for our running scripts by clicking the " +
- "'Active Scripts' link in the main navigation menu.");
- nextBtn.style.display = "none";
-
- //Flash 'Active Scripts' menu and set its tutorial click handler
- activeScriptsMainMenu.setAttribute("class", "flashing-button");
- activeScriptsMainMenu.addEventListener("click", function() {
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadActiveScriptsContent();
- iTutorialNextStep();
- return false;
- });
- break;
- case iTutorialSteps.ActiveScriptsPage:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadActiveScriptsContent();
- iTutorialSetText("This page displays stats/information about all of your scripts that are " +
- "running across every existing server. You can use this to gauge how well " +
- "your scripts are doing. Let's go back to the Terminal now using the 'Terminal'" +
- "link.");
- nextBtn.style.display = "none";
-
- //Flash 'Terminal' button and set its tutorial click handler
- terminalMainMenu.setAttribute("class", "flashing-button");
- terminalMainMenu.addEventListener("click", function() {
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialNextStep();
- return false;
- });
- break;
- case iTutorialSteps.ActiveScriptsToTerminal:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("One last thing about scripts, each active script contains logs that detail " +
- "what it's doing. We can check these logs using the 'tail' command. Do that " +
- "now for the script we just ran by typing 'tail foodnstuff.script'");
- nextBtn.style.display = "none"; //next step triggered by terminal command
- break;
- case iTutorialSteps.TerminalTailScript:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("The log for this script won't show much right now (it might show nothing at all) because it " +
- "just started running...but check back again in a few minutes!
" +
- "This pretty much covers the basics of hacking. To learn more about writing " +
- "scripts using the Netscript language, select the 'Tutorial' link in the " +
- "main navigation menu to look at the documentation. " +
- "If you are an experienced JavaScript " +
- "developer, I would highly suggest you check out the section on " +
- "NetscriptJS/Netscript 2.0.
For now, let's move on to something else!");
- nextBtn.style.display = "inline-block";
- break;
- case iTutorialSteps.GoToHacknetNodesPage:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
- iTutorialSetText("Hacking is not the only way to earn money. One other way to passively " +
- "earn money is by purchasing and upgrading Hacknet Nodes. Let's go to " +
- "the 'Hacknet Nodes' page through the main navigation menu now.");
- nextBtn.style.display = "none";
-
- //Flash 'Hacknet' menu and set its tutorial click handler
- hacknetMainMenu.setAttribute("class", "flashing-button");
- hacknetMainMenu.addEventListener("click", function() {
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadHacknetNodesContent();
- iTutorialNextStep();
- return false;
- });
- break;
- case iTutorialSteps.HacknetNodesIntroduction:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadHacknetNodesContent();
- iTutorialSetText("From this page you can purchase new Hacknet Nodes and upgrade your " +
- "existing ones. Let's purchase a new one now.");
- nextBtn.style.display = "none"; //Next step triggered by purchaseHacknet() (HacknetNode.js)
- break;
- case iTutorialSteps.HacknetNodesGoToWorldPage:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadHacknetNodesContent();
- iTutorialSetText("You just purchased a Hacknet Node! This Hacknet Node will passively " +
- "earn you money over time, both online and offline. When you get enough " +
- " money, you can upgrade " +
- "your newly-purchased Hacknet Node below.
" +
- "Let's go to the 'City' page through the main navigation menu.");
- nextBtn.style.display = "none";
-
- //Flash 'City' menu and set its tutorial click handler
- cityMainMenu.setAttribute("class", "flashing-button");
- cityMainMenu.addEventListener("click", function() {
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadWorldContent();
- iTutorialNextStep();
- return false;
- });
- break;
- case iTutorialSteps.WorldDescription:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadWorldContent();
- iTutorialSetText("This page lists all of the different locations you can currently " +
- "travel to. Each location has something that you can do. " +
- "There's a lot of content out in the world, make sure " +
- "you explore and discover!
" +
- "Lastly, click on the 'Tutorial' link in the main navigation menu.");
- nextBtn.style.display = "none";
-
- //Flash 'Tutorial' menu and set its tutorial click handler
- tutorialMainMenu.setAttribute("class", "flashing-button");
- tutorialMainMenu.addEventListener("click", function() {
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTutorialContent();
- iTutorialNextStep();
- return false;
- });
- break;
- case iTutorialSteps.TutorialPageInfo:
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTutorialContent();
- iTutorialSetText("This page contains a lot of different documentation about the game's " +
- "content and mechanics. I know it's a lot, but I highly suggest you read " +
- "(or at least skim) through this before you start playing. That's the end of the tutorial. " +
- "Hope you enjoy the game!");
- nextBtn.style.display = "inline-block";
- nextBtn.innerHTML = "Finish Tutorial";
- break;
- case iTutorialSteps.End:
- iTutorialEnd();
- break;
- default:
- throw new Error("Invalid tutorial step");
- }
-
- if (ITutorial.stepIsDone[ITutorial.currStep] === true) {
- nextBtn.style.display = "inline-block";
- }
-}
-
-//Go to the next step and evaluate it
-function iTutorialNextStep() {
- //Special behavior for certain steps
- if (ITutorial.currStep === iTutorialSteps.GoToCharacterPage) {
- document.getElementById("stats-menu-link").removeAttribute("class");
- }
- if (ITutorial.currStep === iTutorialSteps.CharacterGoToTerminalPage) {
- document.getElementById("terminal-menu-link").removeAttribute("class");
- }
- if (ITutorial.currStep === iTutorialSteps.TerminalGoToActiveScriptsPage) {
- document.getElementById("active-scripts-menu-link").removeAttribute("class");
- }
- if (ITutorial.currStep === iTutorialSteps.ActiveScriptsPage) {
- document.getElementById("terminal-menu-link").removeAttribute("class");
- }
- if (ITutorial.currStep === iTutorialSteps.GoToHacknetNodesPage) {
- document.getElementById("hacknet-nodes-menu-link").removeAttribute("class");
- }
- if (ITutorial.currStep === iTutorialSteps.HacknetNodesGoToWorldPage) {
- document.getElementById("city-menu-link").removeAttribute("class");
- }
- if (ITutorial.currStep === iTutorialSteps.WorldDescription) {
- document.getElementById("tutorial-menu-link").removeAttribute("class");
- }
-
- ITutorial.stepIsDone[ITutorial.currStep] = true;
- if (ITutorial.currStep < iTutorialSteps.End) {
- ITutorial.currStep += 1;
- }
- iTutorialEvaluateStep();
-}
-
-//Go to previous step and evaluate
-function iTutorialPrevStep() {
- if (ITutorial.currStep > iTutorialSteps.Start) {
- ITutorial.currStep -= 1;
- }
- iTutorialEvaluateStep();
-}
-
-function iTutorialEnd() {
- //Re-enable auto save
- if (_Settings_Settings__WEBPACK_IMPORTED_MODULE_2__["Settings"].AutosaveInterval === 0) {
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = Infinity;
- } else {
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = _Settings_Settings__WEBPACK_IMPORTED_MODULE_2__["Settings"].AutosaveInterval * 5;
- }
-
- console.log("Ending interactive tutorial");
-
- // Initialize references to main menu links
- // We have to call initializeMainMenuLinks() again because the Interactive Tutorial
- // re-creates Main menu links with clearEventListeners()
- if (!Object(_ui_MainMenu_Links__WEBPACK_IMPORTED_MODULE_3__["initializeMainMenuLinks"])()) {
- const errorMsg = "Failed to initialize Main Menu Links. Please try refreshing the page. " +
- "If that doesn't work, report the issue to the developer";
- Object(_utils_helpers_exceptionAlert__WEBPACK_IMPORTED_MODULE_4__["exceptionAlert"])(new Error(errorMsg));
- console.error(errorMsg);
- return;
- }
- _engine__WEBPACK_IMPORTED_MODULE_0__["Engine"].init();
-
- ITutorial.currStep = iTutorialSteps.End;
- ITutorial.isRunning = false;
- document.getElementById("interactive-tutorial-container").style.display = "none";
-
- //Create a popup with final introductory stuff
- var popupId = "interactive-tutorial-ending-popup";
- var txt = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {
- innerHTML:
- "If you are new to the game, the following links may be useful for you!
" +
- "The Beginner's Guide to Hacking was added to your home computer! It contains some tips/pointers for starting out with the game. " +
- "To read it, go to Terminal and enter
cat hackers-starting-handbook.lit"
- });
- var gotitBtn = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
- class:"a-link-button", float:"right", padding:"6px", innerText:"Got it!",
- clickListener:()=>{
- Object(_utils_uiHelpers_removeElementById__WEBPACK_IMPORTED_MODULE_8__["removeElementById"])(popupId);
- }
- });
- Object(_utils_uiHelpers_createPopup__WEBPACK_IMPORTED_MODULE_7__["createPopup"])(popupId, [txt, gotitBtn]);
-
- _Player__WEBPACK_IMPORTED_MODULE_1__[/* Player */ "a"].getHomeComputer().messages.push("hackers-starting-handbook.lit");
-}
-
-function iTutorialSetText(txt) {
- var textBox = document.getElementById("interactive-tutorial-text");
- if (textBox == null) {throw new Error("Could not find text box"); return;}
- textBox.innerHTML = txt;
- textBox.parentElement.scrollTop = 0; // this resets scroll position
-}
-
-
-
-
-/***/ }),
-/* 39 */,
-/* 40 */
-/*!****************************************!*\
- !*** ./utils/uiHelpers/createPopup.ts ***!
- \****************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-const createElement_1 = __webpack_require__(/*! ./createElement */ 2);
-const getElementById_1 = __webpack_require__(/*! ./getElementById */ 61);
-/**
- * Creates the necessary DOM elements to present an in-game popup to the player.
- * @param id The (hopefully) unique identifier for the popup container.
- * @param elems The collection of HTML Elements to show within the popup.
- */
-function createPopup(id, elems, options = {}) {
- const container = createElement_1.createElement("div", {
- class: "popup-box-container",
- display: "flex",
- id: id,
- });
- const content = createElement_1.createElement("div", {
- class: "popup-box-content",
- id: `${id}-content`,
- });
- for (const elem of elems) {
- content.appendChild(elem);
- }
- // Configurable Options
- if (options.backgroundColor) {
- content.style.backgroundColor = options.backgroundColor;
- }
- container.appendChild(content);
- getElementById_1.getElementById("entire-game-container").appendChild(container);
- return container;
-}
-exports.createPopup = createPopup;
-
-
-/***/ }),
-/* 41 */
-/*!**************************************************!*\
- !*** ./src/Company/data/CompanyPositionNames.ts ***!
- \**************************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-// Defs for job titles, stored in arrays and categorized by job "type"
-Object.defineProperty(exports, "__esModule", { value: true });
-exports.SoftwareCompanyPositions = [
- "Software Engineering Intern",
- "Junior Software Engineer",
- "Senior Software Engineer",
- "Lead Software Developer",
- "Head of Software",
- "Head of Engineering",
- "Vice President of Technology",
- "Chief Technology Officer"
-];
-exports.ITCompanyPositions = [
- "IT Intern",
- "IT Analyst",
- "IT Manager",
- "Systems Administrator"
-];
-exports.SecurityEngineerCompanyPositions = [
- "Security Engineer"
-];
-exports.NetworkEngineerCompanyPositions = [
- "Network Engineer",
- "Network Administrator"
-];
-exports.BusinessCompanyPositions = [
- "Business Intern",
- "Business Analyst",
- "Business Manager",
- "Operations Manager",
- "Chief Financial Officer",
- "Chief Executive Officer"
-];
-exports.SecurityCompanyPositions = [
- "Police Officer",
- "Police Chief",
- "Security Guard",
- "Security Officer",
- "Security Supervisor",
- "Head of Security"
-];
-exports.AgentCompanyPositions = [
- "Field Agent",
- "Secret Agent",
- "Special Operative"
-];
-exports.MiscCompanyPositions = [
- "Waiter",
- "Employee"
-];
-exports.SoftwareConsultantCompanyPositions = [
- "Software Consultant",
- "Senior Software Consultant"
-];
-exports.BusinessConsultantCompanyPositions = [
- "Business Consultant",
- "Senior Business Consultant"
-];
-exports.PartTimeCompanyPositions = [
- "Part-time Waiter",
- "Part-time Employee"
-];
-
-
-/***/ }),
-/* 42 */
-/*!*****************************************!*\
- !*** ./utils/helpers/exceptionAlert.ts ***!
- \*****************************************/
-/*! no static exports found */
-/*! all exports used */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-Object.defineProperty(exports, "__esModule", { value: true });
-const DialogBox_1 = __webpack_require__(/*! ../DialogBox */ 9);
-function exceptionAlert(e) {
- DialogBox_1.dialogBoxCreate("Caught an exception: " + e + "
" +
- "This message was saved as " + msg.filename + " onto your home computer.";
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])(txt);
-}
-
-//Adds a message to a server
-function addMessageToServer(msg, serverHostname) {
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_7__[/* GetServerByHostname */ "c"])(serverHostname);
- if (server == null) {
- console.log("WARNING: Did not locate " + serverHostname);
- return;
- }
- for (var i = 0; i < server.messages.length; ++i) {
- if (server.messages[i].filename === msg.filename) {
- return; //Already exists
- }
- }
- server.messages.push(msg);
-}
-
-//Checks if any of the 'timed' messages should be sent
-function checkForMessagesToSend() {
- var jumper0 = Messages[MessageFilenames.Jumper0];
- var jumper1 = Messages[MessageFilenames.Jumper1];
- var jumper2 = Messages[MessageFilenames.Jumper2];
- var jumper3 = Messages[MessageFilenames.Jumper3];
- var jumper4 = Messages[MessageFilenames.Jumper4];
- var cybersecTest = Messages[MessageFilenames.CyberSecTest];
- var nitesecTest = Messages[MessageFilenames.NiteSecTest];
- var bitrunnersTest = Messages[MessageFilenames.BitRunnersTest];
- var redpill = Messages[MessageFilenames.RedPill];
-
- var redpillOwned = false;
- if (_Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_1__["Augmentations"][_Augmentation_data_AugmentationNames__WEBPACK_IMPORTED_MODULE_2__["AugmentationNames"].TheRedPill].owned) {
- redpillOwned = true;
- }
-
- if (redpill && redpillOwned && _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].sourceFiles.length === 0 && !_RedPill__WEBPACK_IMPORTED_MODULE_6__[/* redPillFlag */ "b"] && !_Missions__WEBPACK_IMPORTED_MODULE_4__[/* inMission */ "c"]) {
- if (!_utils_DialogBox__WEBPACK_IMPORTED_MODULE_9__["dialogBoxOpened"]) {
- sendMessage(redpill, true);
- }
- } else if (redpill && redpillOwned) {
- //If player has already destroyed a BitNode, message is not forced
- if (!_RedPill__WEBPACK_IMPORTED_MODULE_6__[/* redPillFlag */ "b"] && !_Missions__WEBPACK_IMPORTED_MODULE_4__[/* inMission */ "c"] && !_utils_DialogBox__WEBPACK_IMPORTED_MODULE_9__["dialogBoxOpened"]) {
- sendMessage(redpill);
- }
- } else if (jumper0 && !jumper0.recvd && _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hacking_skill >= 25) {
- sendMessage(jumper0);
- _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].getHomeComputer().programs.push(_Programs_Programs__WEBPACK_IMPORTED_MODULE_3__["Programs"].Flight.name);
- } else if (jumper1 && !jumper1.recvd && _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hacking_skill >= 40) {
- sendMessage(jumper1);
- } else if (cybersecTest && !cybersecTest.recvd && _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hacking_skill >= 50) {
- sendMessage(cybersecTest);
- } else if (jumper2 && !jumper2.recvd && _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hacking_skill >= 175) {
- sendMessage(jumper2);
- } else if (nitesecTest && !nitesecTest.recvd && _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hacking_skill >= 200) {
- sendMessage(nitesecTest);
- } else if (jumper3 && !jumper3.recvd && _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hacking_skill >= 350) {
- sendMessage(jumper3);
- } else if (jumper4 && !jumper4.recvd && _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hacking_skill >= 490) {
- sendMessage(jumper4);
- } else if (bitrunnersTest && !bitrunnersTest.recvd && _Player__WEBPACK_IMPORTED_MODULE_5__[/* Player */ "a"].hacking_skill >= 500) {
- sendMessage(bitrunnersTest);
- }
-}
-
-function AddToAllMessages(msg) {
- Messages[msg.filename] = msg;
-}
-
-let Messages = {}
-
-function loadMessages(saveString) {
- Messages = JSON.parse(saveString, _utils_JSONReviver__WEBPACK_IMPORTED_MODULE_10__["Reviver"]);
-}
-
-let MessageFilenames = {
- Jumper0: "j0.msg",
- Jumper1: "j1.msg",
- Jumper2: "j2.msg",
- Jumper3: "j3.msg",
- Jumper4: "j4.msg",
- CyberSecTest: "csec-test.msg",
- NiteSecTest: "nitesec-test.msg",
- BitRunnersTest: "19dfj3l1nd.msg",
- RedPill: "icarus.msg",
-}
-
-function initMessages() {
- //Reset
- Messages = {};
-
- //jump3R Messages
- AddToAllMessages(new Message(MessageFilenames.Jumper0,
- "I know you can sense it. I know you're searching for it. " +
- "It's why you spend night after " +
- "night at your computer.
It's real, I've seen it. And I can " +
- "help you find it. But not right now. You're not ready yet.
" +
- "Use this program to track your progress
" +
- "The fl1ght.exe program was added to your home computer
" +
- "-jump3R"));
- AddToAllMessages(new Message(MessageFilenames.Jumper1,
- "Soon you will be contacted by a hacking group known as CyberSec. " +
- "They can help you with your search.
" +
- "You should join them, garner their favor, and " +
- "exploit them for their Augmentations. But do not trust them. " +
- "They are not what they seem. No one is.
" +
- "-jump3R"));
- AddToAllMessages(new Message(MessageFilenames.Jumper2,
- "Do not try to save the world. There is no world to save. If " +
- "you want to find the truth, worry only about yourself. Ethics and " +
- "morals will get you killed.
Watch out for a hacking group known as NiteSec." +
- "
-jump3R"));
- AddToAllMessages(new Message(MessageFilenames.Jumper3,
- "You must learn to walk before you can run. And you must " +
- "run before you can fly. Look for the black hand.
" +
- "I.I.I.I
-jump3R"));
- AddToAllMessages(new Message(MessageFilenames.Jumper4,
- "To find what you are searching for, you must understand the bits. " +
- "The bits are all around us. The runners will help you.
" +
- "-jump3R"));
-
- //Messages from hacking factions
- AddToAllMessages(new Message(MessageFilenames.CyberSecTest,
- "We've been watching you. Your skills are very impressive. But you're wasting " +
- "your talents. If you join us, you can put your skills to good use and change " +
- "the world for the better. If you join us, we can unlock your full potential.
" +
- "But first, you must pass our test. Find and hack our server using the Terminal.
" +
- "-CyberSec"));
- AddToAllMessages(new Message(MessageFilenames.NiteSecTest,
- "People say that the corrupted governments and corporations rule the world. " +
- "Yes, maybe they do. But do you know who everyone really fears? People " +
- "like us. Because they can't hide from us. Because they can't fight shadows " +
- "and ideas with bullets.
" +
- "Join us, and people will fear you, too.
" +
- "Find and hack our hidden server using the Terminal. Then, we will contact you again." +
- "
-NiteSec"));
- AddToAllMessages(new Message(MessageFilenames.BitRunnersTest,
- "We know what you are doing. We know what drives you. We know " +
- "what you are looking for.
" +
- "Dynamic RAM Usage: " + workerScript.dynamicRamUsage + " " +
- "Static RAM Usage: " + workerScript.ramUsage);
- }
- };
-
- var updateStaticRam = function(fnName, ramCost) {
- if (workerScript.loadedFns[fnName]) {
- return 0;
- } else {
- workerScript.loadedFns[fnName] = true;
- return ramCost;
- }
- };
-
- /**
- * Gets the Server for a specific hostname/ip, throwing an error
- * if the server doesn't exist.
- * @param {string} Hostname or IP of the server
- * @returns {Server} The specified Server
- */
- var safeGetServer = function(ip, callingFnName="") {
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, `Invalid IP or hostname passed into ${callingFnName}() function`);
- }
- return server;
- }
-
- // Utility function to get Hacknet Node object
- var getHacknetNode = function(i) {
- if (isNaN(i)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid index specified for Hacknet Node: " + i);
- }
- if (i < 0 || i >= _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacknetNodes.length) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Index specified for Hacknet Node is out-of-bounds: " + i);
- }
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacknetNodes[i];
- };
-
- var getCodingContract = function(fn, ip) {
- var server = safeGetServer(ip, "getCodingContract");
- return server.getContract(fn);
- }
-
- return {
- hacknet : {
- numNodes : function() {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacknetNodes.length;
- },
- purchaseNode : function() {
- return Object(_HacknetNode__WEBPACK_IMPORTED_MODULE_19__[/* purchaseHacknet */ "e"])();
- },
- getPurchaseNodeCost : function() {
- return Object(_HacknetNode__WEBPACK_IMPORTED_MODULE_19__[/* getCostOfNextHacknetNode */ "c"])();
- },
- getNodeStats : function(i) {
- var node = getHacknetNode(i);
- return {
- name: node.name,
- level: node.level,
- ram: node.ram,
- cores: node.cores,
- production: node.moneyGainRatePerSecond,
- timeOnline: node.onlineTimeSeconds,
- totalProduction: node.totalMoneyGenerated,
- };
- },
- upgradeLevel : function(i, n) {
- var node = getHacknetNode(i);
- return node.purchaseLevelUpgrade(n);
- },
- upgradeRam : function(i, n) {
- var node = getHacknetNode(i);
- return node.purchaseRamUpgrade(n);
- },
- upgradeCore : function(i, n) {
- var node = getHacknetNode(i);
- return node.purchaseCoreUpgrade(n);
- },
- getLevelUpgradeCost : function(i, n) {
- var node = getHacknetNode(i);
- return node.calculateLevelUpgradeCost(n);
- },
- getRamUpgradeCost : function(i, n) {
- var node = getHacknetNode(i);
- return node.calculateRamUpgradeCost(n);
- },
- getCoreUpgradeCost : function(i, n) {
- var node = getHacknetNode(i);
- return node.calculateCoreUpgradeCost(n);
- }
- },
- sprintf : sprintf,
- vsprintf: vsprintf,
- scan : function(ip=workerScript.serverIp, hostnames=true){
- if (workerScript.checkingRam) {
- return updateStaticRam("scan", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptScanRamCost);
- }
- updateDynamicRam("scan", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptScanRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scan == null) {
- workerScript.scriptRef.log('scan() returned ' + server.serversOnNetwork.length + ' connections for ' + server.hostname);
- }
- return out;
- },
- hack : function(ip){
- if (workerScript.checkingRam) {
- return updateStaticRam("hack", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptHackRamCost);
- }
- updateDynamicRam("hack", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptHackRamCost);
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping...");
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping...");
- }
-
- //Calculate the hacking time
- var hackingTime = Object(_Hacking__WEBPACK_IMPORTED_MODULE_14__[/* calculateHackingTime */ "d"])(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(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot hack this server (" + server.hostname + ") because user does not have root access");
- }
-
- if (server.requiredHackingSkill > _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacking_skill) {
- workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough");
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough");
- }
-
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
- workerScript.scriptRef.log("Attempting to hack " + ip + " in " + hackingTime.toFixed(3) + " seconds (t=" + threads + ")");
- }
- return Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* netscriptDelay */ "e"])(hackingTime * 1000, workerScript).then(function() {
- if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
- var hackChance = Object(_Hacking__WEBPACK_IMPORTED_MODULE_14__[/* calculateHackingChance */ "b"])(server);
- var rand = Math.random();
- var expGainedOnSuccess = Object(_Hacking__WEBPACK_IMPORTED_MODULE_14__[/* calculateHackingExpGain */ "c"])(server) * threads;
- var expGainedOnFailure = (expGainedOnSuccess / 4);
- if (rand < hackChance) { //Success!
- const percentHacked = Object(_Hacking__WEBPACK_IMPORTED_MODULE_14__[/* calculatePercentMoneyHacked */ "e"])(server);
- let maxThreadNeeded = Math.ceil(1/percentHacked*(server.moneyAvailable/server.moneyMax));
- if (isNaN(maxThreadNeeded)) {
- //Server has a 'max money' of 0 (probably).
- //We'll set this to an arbitrarily large value
- maxThreadNeeded = 1e6;
- }
-
- let moneyGained = Math.floor(server.moneyAvailable * percentHacked) * 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;}
-
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gainMoney(moneyGained);
- workerScript.scriptRef.onlineMoneyMade += moneyGained;
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].scriptProdSinceLastAug += moneyGained;
- workerScript.scriptRef.recordHack(server.ip, moneyGained, threads);
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gainHackingExp(expGainedOnSuccess);
- workerScript.scriptRef.onlineExpGained += expGainedOnSuccess;
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
- workerScript.scriptRef.log("Script SUCCESSFULLY hacked " + server.hostname + " for $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(moneyGained, 2) + " and " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(expGainedOnSuccess, 4) + " exp (t=" + threads + ")");
- }
- server.fortify(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ServerFortifyAmount * Math.min(threads, maxThreadNeeded));
- return Promise.resolve(moneyGained);
- } else {
- //Player only gains 25% exp for failure?
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gainHackingExp(expGainedOnFailure);
- workerScript.scriptRef.onlineExpGained += expGainedOnFailure;
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.hack == null) {
- workerScript.scriptRef.log("Script FAILED to hack " + server.hostname + ". Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(expGainedOnFailure, 4) + " exp (t=" + threads + ")");
- }
- return Promise.resolve(0);
- }
- });
- },
- hackAnalyzeThreads : function(ip, hackAmount) {
- if (workerScript.checkingRam) {
- return updateStaticRam("hackAnalyzeThreads", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptHackAnalyzeRamCost);
- }
- updateDynamicRam("hackAnalyzeThreads", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptHackAnalyzeRamCost);
-
- // Check argument validity
- const server = safeGetServer(ip, 'hackAnalyzeThreads');
- if (isNaN(hackAmount)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, `Invalid growth argument passed into hackAnalyzeThreads: ${hackAmount}. Must be numeric`);
- }
-
- if (hackAmount < 0 || hackAmount > server.moneyAvailable) {
- return -1;
- }
-
- const percentHacked = Object(_Hacking__WEBPACK_IMPORTED_MODULE_14__[/* calculatePercentMoneyHacked */ "e"])(server);
-
- return hackAmount / Math.floor(server.moneyAvailable * percentHacked);
- },
- hackAnalyzePercent : function(ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("hackAnalyzePercent", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptHackAnalyzeRamCost);
- }
- updateDynamicRam("hackAnalyzePercent", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptHackAnalyzeRamCost);
-
- const server = safeGetServer(ip, 'hackAnalyzePercent');
-
- return Object(_Hacking__WEBPACK_IMPORTED_MODULE_14__[/* calculatePercentMoneyHacked */ "e"])(server) * 100;
- },
- hackChance : function(ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("hackChance", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptHackAnalyzeRamCost);
- }
- updateDynamicRam("hackChance", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptHackAnalyzeRamCost);
-
- const server = safeGetServer(ip, 'hackChance');
-
- return Object(_Hacking__WEBPACK_IMPORTED_MODULE_14__[/* calculateHackingChance */ "b"])(server);
- },
- sleep : function(time){
- if (workerScript.checkingRam) {return 0;}
- if (time === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "sleep() call has incorrect number of arguments. Takes 1 argument");
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sleep == null) {
- workerScript.scriptRef.log("Sleeping for " + time + " milliseconds");
- }
- return Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* netscriptDelay */ "e"])(time, workerScript).then(function() {
- return Promise.resolve(true);
- });
- },
- grow : function(ip){
- if (workerScript.checkingRam) {
- return updateStaticRam("grow", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGrowRamCost);
- }
- updateDynamicRam("grow", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGrowRamCost);
- var threads = workerScript.scriptRef.threads;
- if (isNaN(threads) || threads < 1) {threads = 1;}
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "grow() call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot grow(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot grow this server (" + server.hostname + ") because user does not have root access");
- }
-
- var growTime = Object(_Hacking__WEBPACK_IMPORTED_MODULE_14__[/* calculateGrowTime */ "a"])(server);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
- workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(growTime, 3) + " seconds (t=" + threads + ")");
- }
- return Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* netscriptDelay */ "e"])(growTime * 1000, workerScript).then(function() {
- if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
- const moneyBefore = server.moneyAvailable <= 0 ? 1 : server.moneyAvailable;
- server.moneyAvailable += (1 * threads); //It can be grown even if it has no money
- var growthPercentage = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* processSingleServerGrowth */ "k"])(server, 450 * threads);
- const moneyAfter = server.moneyAvailable;
- workerScript.scriptRef.recordGrow(server.ip, threads);
- var expGain = Object(_Hacking__WEBPACK_IMPORTED_MODULE_14__[/* calculateHackingExpGain */ "c"])(server) * threads;
- if (growthPercentage == 1) {
- expGain = 0;
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
- workerScript.scriptRef.log("Available money on " + server.hostname + " grown by " +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])((moneyAfter/moneyBefore)*100 - 100, 6) + "%. Gained " +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(expGain, 4) + " hacking exp (t=" + threads +")");
- }
- workerScript.scriptRef.onlineExpGained += expGain;
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gainHackingExp(expGain);
- return Promise.resolve(moneyAfter/moneyBefore);
- });
- },
- growthAnalyze : function(ip, growth) {
- if (workerScript.checkingRam) {
- return updateStaticRam("growthAnalyze", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGrowthAnalyzeRamCost);
- }
- updateDynamicRam("growthAnalyze", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGrowthAnalyzeRamCost);
-
- // Check argument validity
- const server = safeGetServer(ip, 'growthAnalyze');
- if (isNaN(growth)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, `Invalid growth argument passed into growthAnalyze: ${growth}. Must be numeric`);
- }
-
- return Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* numCycleForGrowth */ "h"])(server, Number(growth));
- },
- weaken : function(ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("weaken", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptWeakenRamCost);
- }
- updateDynamicRam("weaken", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptWeakenRamCost);
- var threads = workerScript.scriptRef.threads;
- if (isNaN(threads) || threads < 1) {threads = 1;}
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "weaken() call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot weaken(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot weaken this server (" + server.hostname + ") because user does not have root access");
- }
-
- var weakenTime = Object(_Hacking__WEBPACK_IMPORTED_MODULE_14__[/* calculateWeakenTime */ "f"])(server);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
- workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(weakenTime, 3) + " seconds (t=" + threads + ")");
- }
- return Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* netscriptDelay */ "e"])(weakenTime * 1000, workerScript).then(function() {
- if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
- server.weaken(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ServerWeakenAmount * threads);
- workerScript.scriptRef.recordWeaken(server.ip, threads);
- var expGain = Object(_Hacking__WEBPACK_IMPORTED_MODULE_14__[/* calculateHackingExpGain */ "c"])(server) * threads;
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
- workerScript.scriptRef.log("Server security level on " + server.hostname + " weakened to " + server.hackDifficulty +
- ". Gained " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(expGain, 4) + " hacking exp (t=" + threads + ")");
- }
- workerScript.scriptRef.onlineExpGained += expGain;
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gainHackingExp(expGain);
- return Promise.resolve(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ServerWeakenAmount * threads);
- });
- },
- print : function(args){
- if (workerScript.checkingRam) {return 0;}
- if (args === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "print() call has incorrect number of arguments. Takes 1 argument");
- }
- workerScript.scriptRef.log(args.toString());
- },
- tprint : function(args) {
- if (workerScript.checkingRam) {return 0;}
- if (args === undefined || args == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "tprint() call has incorrect number of arguments. Takes 1 argument");
- }
- var x = args.toString();
- Object(_ui_postToTerminal__WEBPACK_IMPORTED_MODULE_32__["post"])(workerScript.scriptRef.filename + ": " + args.toString());
- },
- clearLog : function() {
- if (workerScript.checkingRam) {return 0;}
- workerScript.scriptRef.clearLog();
- },
- disableLog : function(fn) {
- if (workerScript.checkingRam) {return 0;}
- if(possibleLogs[fn]===undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid argument to disableLog: "+fn);
- }
- workerScript.disableLogs[fn] = true;
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.disableLog == null) {
- workerScript.scriptRef.log("Disabled logging for " + fn);
- }
- },
- enableLog : function(fn) {
- if (workerScript.checkingRam) {return 0;}
- if(possibleLogs[fn]===undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid argument to enableLog: "+fn);
- }
- delete workerScript.disableLogs[fn];
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.enableLog == null) {
- workerScript.scriptRef.log("Enabled logging for " + fn);
- }
- },
- isLogEnabled : function(fn) {
- if (workerScript.checkingRam) {return 0;}
- if (possibleLogs[fn] === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid argument to isLogEnabled: " + fn);
- }
- return workerScript.disableLogs[fn] ? false : true;
- },
- getScriptLogs : function(fn, ip) {
- if (workerScript.checkingRam) {return 0;}
-
- if (fn != null && typeof fn === 'string') {
- // Get Logs of another script
- if (ip == null) { ip = workerScript.serverIp; }
- const server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.log(`getScriptLogs() failed. Invalid IP or hostname passed in: ${ip}`);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, `getScriptLogs() failed. Invalid IP or hostname passed in: ${ip}`);
- }
-
- let argsForTarget = [];
- for (let i = 2; i < arguments.length; ++i) {
- argsForTarget.push(arguments[i]);
- }
- const runningScriptObj = Object(_Script__WEBPACK_IMPORTED_MODULE_25__[/* findRunningScript */ "d"])(fn, argsForTarget, server);
- if (runningScriptObj == null) {
- workerScript.scriptRef.log(`getScriptLogs() failed. No such script ${fn} on ${server.hostname} with args: ${Object(_utils_helpers_arrayToString__WEBPACK_IMPORTED_MODULE_43__["arrayToString"])(argsForTarget)}`);
- return "";
- }
- return runningScriptObj.logs.slice();
- }
-
- return workerScript.scriptRef.logs.slice();
- },
- nuke : function(ip){
- if (workerScript.checkingRam) {
- return updateStaticRam("nuke", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPortProgramRamCost);
- }
- updateDynamicRam("nuke", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPortProgramRamCost);
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot call nuke(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot call nuke(). Invalid IP or hostname passed in: " + ip);
- }
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasProgram(_Programs_Programs__WEBPACK_IMPORTED_MODULE_24__["Programs"].NukeProgram.name)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You do not have the NUKE.exe virus!");
- }
- if (server.openPortCount < server.numOpenPortsRequired) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Not enough ports opened to use NUKE.exe virus");
- }
- if (server.hasAdminRights) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.nuke == null) {
- workerScript.scriptRef.log("Already have root access to " + server.hostname);
- }
- } else {
- server.hasAdminRights = true;
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.nuke == null) {
- workerScript.scriptRef.log("Executed NUKE.exe virus on " + server.hostname + " to gain root access");
- }
- }
- return true;
- },
- brutessh : function(ip){
- if (workerScript.checkingRam) {
- return updateStaticRam("brutessh", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPortProgramRamCost);
- }
- updateDynamicRam("brutessh", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPortProgramRamCost);
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot call brutessh(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot call brutessh(). Invalid IP or hostname passed in: " + ip);
- }
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasProgram(_Programs_Programs__WEBPACK_IMPORTED_MODULE_24__["Programs"].BruteSSHProgram.name)) {
- workerScript.scriptRef.log("You do not have the BruteSSH.exe program!");
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You do not have the BruteSSH.exe program!");
- }
- if (!server.sshPortOpen) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.brutessh == null) {
- workerScript.scriptRef.log("Executed BruteSSH.exe on " + server.hostname + " to open SSH port (22)");
- }
- server.sshPortOpen = true;
- ++server.openPortCount;
- } else {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.brutessh == null) {
- workerScript.scriptRef.log("SSH Port (22) already opened on " + server.hostname);
- }
- }
- return true;
- },
- ftpcrack : function(ip){
- if (workerScript.checkingRam) {
- return updateStaticRam("ftpcrack", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPortProgramRamCost);
- }
- updateDynamicRam("ftpcrack", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPortProgramRamCost);
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip);
- }
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasProgram(_Programs_Programs__WEBPACK_IMPORTED_MODULE_24__["Programs"].FTPCrackProgram.name)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You do not have the FTPCrack.exe program!");
- }
- if (!server.ftpPortOpen) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.ftpcrack == null) {
- workerScript.scriptRef.log("Executed FTPCrack.exe on " + server.hostname + " to open FTP port (21)");
- }
- server.ftpPortOpen = true;
- ++server.openPortCount;
- } else {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.ftpcrack == null) {
- workerScript.scriptRef.log("FTP Port (21) already opened on " + server.hostname);
- }
- }
- return true;
- },
- relaysmtp : function(ip){
- if (workerScript.checkingRam) {
- return updateStaticRam("relaysmtp", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPortProgramRamCost);
- }
- updateDynamicRam("relaysmtp", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPortProgramRamCost);
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip);
- }
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasProgram(_Programs_Programs__WEBPACK_IMPORTED_MODULE_24__["Programs"].RelaySMTPProgram.name)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You do not have the relaySMTP.exe program!");
- }
- if (!server.smtpPortOpen) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.relaysmtp == null) {
- workerScript.scriptRef.log("Executed relaySMTP.exe on " + server.hostname + " to open SMTP port (25)");
- }
- server.smtpPortOpen = true;
- ++server.openPortCount;
- } else {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.relaysmtp == null) {
- workerScript.scriptRef.log("SMTP Port (25) already opened on " + server.hostname);
- }
- }
- return true;
- },
- httpworm : function(ip){
- if (workerScript.checkingRam) {
- return updateStaticRam("httpworm", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPortProgramRamCost);
- }
- updateDynamicRam("httpworm", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPortProgramRamCost);
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot call httpworm(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot call httpworm(). Invalid IP or hostname passed in: " + ip);
- }
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasProgram(_Programs_Programs__WEBPACK_IMPORTED_MODULE_24__["Programs"].HTTPWormProgram.name)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You do not have the HTTPWorm.exe program!");
- }
- if (!server.httpPortOpen) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.httpworm == null) {
- workerScript.scriptRef.log("Executed HTTPWorm.exe on " + server.hostname + " to open HTTP port (80)");
- }
- server.httpPortOpen = true;
- ++server.openPortCount;
- } else {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.httpworm == null) {
- workerScript.scriptRef.log("HTTP Port (80) already opened on " + server.hostname);
- }
- }
- return true;
- },
- sqlinject : function(ip){
- if (workerScript.checkingRam) {
- return updateStaticRam("sqlinject", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPortProgramRamCost);
- }
- updateDynamicRam("sqlinject", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPortProgramRamCost);
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip);
- }
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasProgram(_Programs_Programs__WEBPACK_IMPORTED_MODULE_24__["Programs"].SQLInjectProgram.name)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You do not have the SQLInject.exe program!");
- }
- if (!server.sqlPortOpen) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sqlinject == null) {
- workerScript.scriptRef.log("Executed SQLInject.exe on " + server.hostname + " to open SQL port (1433)");
- }
- server.sqlPortOpen = true;
- ++server.openPortCount;
- } else {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sqlinject == null) {
- workerScript.scriptRef.log("SQL Port (1433) already opened on " + server.hostname);
- }
- }
- return true;
- },
- run : function(scriptname,threads = 1){
- if (workerScript.checkingRam) {
- return updateStaticRam("run", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptRunRamCost);
- }
- updateDynamicRam("run", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptRunRamCost);
- if (scriptname === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "run() call has incorrect number of arguments. Usage: run(scriptname, [numThreads], [arg1], [arg2]...)");
- }
- if (isNaN(threads) || threads < 0) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(workerScript.serverIp);
- if (scriptServer == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Could not find server. This is a bug in the game. Report to game dev");
- }
-
- return Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* runScriptFromScript */ "f"])(scriptServer, scriptname, argsForNewScript, workerScript, threads);
- },
- exec : function(scriptname,ip,threads = 1) {
- if (workerScript.checkingRam) {
- return updateStaticRam("exec", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptExecRamCost);
- }
- updateDynamicRam("exec", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptExecRamCost);
- if (scriptname === undefined || ip === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "exec() call has incorrect number of arguments. Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)");
- }
- if (isNaN(threads) || threads < 0) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid hostname/ip passed into exec() command: " + ip);
- }
- return Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* runScriptFromScript */ "f"])(server, scriptname, argsForNewScript, workerScript, threads);
- },
- spawn : function(scriptname, threads) {
- if (workerScript.checkingRam) {
- return updateStaticRam("spawn", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSpawnRamCost);
- }
- updateDynamicRam("spawn", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSpawnRamCost);
- if (scriptname == null || threads == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid scriptname or numThreads argument passed to spawn()");
- }
- setTimeout(()=>{
- if (scriptname === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "spawn() call has incorrect number of arguments. Usage: spawn(scriptname, numThreads, [arg1], [arg2]...)");
- }
- if (isNaN(threads) || threads < 0) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(workerScript.serverIp);
- if (scriptServer == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Could not find server. This is a bug in the game. Report to game dev");
- }
-
- return Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* runScriptFromScript */ "f"])(scriptServer, scriptname, argsForNewScript, workerScript, threads);
- }, 20000);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.spawn == null) {
- workerScript.scriptRef.log("spawn() will execute " + scriptname + " in 20 seconds");
- }
- NetscriptFunctions(workerScript).exit();
- },
- kill : function(filename, ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("kill", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptKillRamCost);
- }
- updateDynamicRam("kill", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptKillRamCost);
- if (filename === undefined || ip === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "kill() call has incorrect number of arguments. Usage: kill(scriptname, server, [arg1], [arg2]...)");
- }
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("kill() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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(_Script__WEBPACK_IMPORTED_MODULE_25__[/* findRunningScript */ "d"])(filename, argsForKillTarget, server);
- if (runningScriptObj == null) {
- workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(_utils_helpers_arrayToString__WEBPACK_IMPORTED_MODULE_43__["arrayToString"])(argsForKillTarget));
- return false;
- }
- var res = Object(_NetscriptWorker__WEBPACK_IMPORTED_MODULE_36__[/* killWorkerScript */ "d"])(runningScriptObj, server.ip);
- if (res) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.kill == null) {
- workerScript.scriptRef.log("Killing " + filename + " on " + server.hostname + " with args: " + Object(_utils_helpers_arrayToString__WEBPACK_IMPORTED_MODULE_43__["arrayToString"])(argsForKillTarget) + ". May take up to a few minutes for the scripts to die...");
- }
- return true;
- } else {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.kill == null) {
- workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(_utils_helpers_arrayToString__WEBPACK_IMPORTED_MODULE_43__["arrayToString"])(argsForKillTarget));
- }
- return false;
- }
- },
- killall : function(ip=workerScript.serverIp){
- if (workerScript.checkingRam) {
- return updateStaticRam("killall", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptKillRamCost);
- }
- updateDynamicRam("killall", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptKillRamCost);
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "killall() call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("killall() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "killall() failed. Invalid IP or hostname passed in: " + ip);
- }
- var scriptsRunning = (server.runningScripts.length > 0);
- for (var i = server.runningScripts.length-1; i >= 0; --i) {
- Object(_NetscriptWorker__WEBPACK_IMPORTED_MODULE_36__[/* killWorkerScript */ "d"])(server.runningScripts[i], server.ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.killall == null) {
- workerScript.scriptRef.log("killall(): Killing all scripts on " + server.hostname + ". May take a few minutes for the scripts to die");
- }
- return scriptsRunning;
- },
- exit : function() {
- if (workerScript.checkingRam) {return 0;}
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(workerScript.serverIp);
- if (server == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Error getting Server for this script in exit(). This is a bug please contact game dev");
- }
- if (Object(_NetscriptWorker__WEBPACK_IMPORTED_MODULE_36__[/* killWorkerScript */ "d"])(workerScript.scriptRef, server.ip)) {
- workerScript.scriptRef.log("Exiting...");
- } else {
- workerScript.scriptRef.log("Exit failed(). This is a bug please contact game developer");
- }
- },
- scp : function(scriptname, ip1, ip2) {
- if (workerScript.checkingRam) {
- return updateStaticRam("scp", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptScpRamCost);
- }
- updateDynamicRam("scp", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptScpRamCost);
- if (arguments.length !== 2 && arguments.length !== 3) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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") && !Object(_Script__WEBPACK_IMPORTED_MODULE_25__[/* isScriptFilename */ "f"])(scriptname) &&
- !scriptname.endsWith("txt")) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: scp() does not work with this file type. It only works for .script, .lit, and .txt files");
- }
-
- var destServer, currServ;
-
- if (ip2 != null) { // 3 Argument version: scriptname, source, destination
- if (scriptname === undefined || ip1 === undefined || ip2 === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: scp() call has incorrect number of arguments. Takes 2 or 3 arguments");
- }
- destServer = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip2);
- if (destServer == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, `ERROR: Invalid hostname/ip passed into scp() command: ${ip2}`);
- }
-
- currServ = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip1);
- if (currServ == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, `ERROR: Invalid hostname/ip passed into scp() command: ${ip1}`);
- }
- } else if (ip1 != null) { // 2 Argument version: scriptname, destination
- if (scriptname === undefined || ip1 === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: scp() call has incorrect number of arguments. Takes 2 or 3 arguments");
- }
- destServer = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip1);
- if (destServer == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, `ERROR: Invalid hostname/ip passed into scp() command: ${ip1}`);
- }
-
- currServ = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(workerScript.serverIp);
- if (currServ == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer");
- }
- } else {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: scp() call has incorrect number of arguments. Takes 2 or 3 arguments");
- }
-
- //Scp for lit files
- if (scriptname.endsWith(".lit")) {
- var found = false;
- for (var i = 0; i < currServ.messages.length; ++i) {
- if (!(currServ.messages[i] instanceof _Message__WEBPACK_IMPORTED_MODULE_21__[/* Message */ "a"]) && currServ.messages[i] == scriptname) {
- found = true;
- break;
- }
- }
-
- 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) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
- workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
- }
- return true; //Already exists
- }
- }
- destServer.messages.push(scriptname);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
- workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
- }
- return true;
- }
-
- //Scp for text files
- if (scriptname.endsWith(".txt")) {
- var found = false, txtFile;
- for (var i = 0; i < currServ.textFiles.length; ++i) {
- if (currServ.textFiles[i].fn === scriptname) {
- found = true;
- txtFile = currServ.textFiles[i];
- break;
- }
- }
-
- if (!found) {
- workerScript.scriptRef.log(scriptname + " does not exist. scp() failed");
- return false;
- }
-
- for (var i = 0; i < destServer.textFiles.length; ++i) {
- if (destServer.textFiles[i].fn === scriptname) {
- //Overwrite
- destServer.textFiles[i].text = txtFile.text;
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
- workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
- }
- return true;
- }
- }
- var newFile = new _TextFile__WEBPACK_IMPORTED_MODULE_33__["TextFile"](txtFile.fn, txtFile.text);
- destServer.textFiles.push(newFile);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
- 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) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
- 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;
- oldScript.module = "";
- return true;
- }
- }
-
- //Create new script if it does not already exist
- var newScript = new _Script__WEBPACK_IMPORTED_MODULE_25__[/* Script */ "c"]();
- newScript.filename = scriptname;
- newScript.code = sourceScript.code;
- newScript.ramUsage = sourceScript.ramUsage;
- newScript.server = destServer.ip;
- destServer.scripts.push(newScript);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.scp == null) {
- workerScript.scriptRef.log(scriptname + " copied over to " + destServer.hostname);
- }
- return true;
- },
- ls : function(ip, grep) {
- if (workerScript.checkingRam) {
- return updateStaticRam("ls", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptScanRamCost);
- }
- updateDynamicRam("ls", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptScanRamCost);
- if (ip === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ls() failed because of invalid arguments. Usage: ls(ip/hostname, [grep filter])");
- }
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("ls() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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 _Message__WEBPACK_IMPORTED_MODULE_21__[/* Message */ "a"]) {
- 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 _Message__WEBPACK_IMPORTED_MODULE_21__[/* Message */ "a"]) {
- allFiles.push(server.messages[i].filename);
- } else {
- allFiles.push(server.messages[i]);
- }
- }
- }
-
- for (var i = 0; i < server.textFiles.length; i++) {
- if (filter) {
- if (server.textFiles[i].fn.includes(filter)) {
- allFiles.push(server.textFiles[i].fn);
- }
- } else {
- allFiles.push(server.textFiles[i].fn);
- }
- }
-
- for (var i = 0; i < server.contracts.length; ++i) {
- if (filter) {
- if (server.contracts[i].fn.includes(filter)) {
- allFiles.push(server.contracts[i].fn);
- }
- } else {
- allFiles.push(server.contracts[i].fn);
- }
- }
-
- //Sort the files alphabetically then print each
- allFiles.sort();
- return allFiles;
- },
- ps : function(ip=workerScript.serverIp) {
- if (workerScript.checkingRam) {
- return updateStaticRam("ps", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptScanRamCost);
- }
- updateDynamicRam("ps", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptScanRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null){
- workerScript.scriptRef.log("ps() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ps() failed. Invalid IP or hostname passed in: " + ip);
- }
- const processes = [];
- for (const i in server.runningScripts) {
- const script = server.runningScripts[i];
- processes.push({filename:script.filename, threads: script.threads, args: script.args.slice()})
- }
- return processes;
- },
- hasRootAccess : function(ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("hasRootAccess", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptHasRootAccessRamCost);
- }
- updateDynamicRam("hasRootAccess", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptHasRootAccessRamCost);
- if (ip===undefined){
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "hasRootAccess() call has incorrect number of arguments. Takes 1 argument");
- }
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null){
- workerScript.scriptRef.log("hasRootAccess() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "hasRootAccess() failed. Invalid IP or hostname passed in: " + ip);
- }
- return server.hasAdminRights;
- },
- getIp : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getIp", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetHostnameRamCost);
- }
- updateDynamicRam("getIp", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetHostnameRamCost);
- var scriptServer = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(workerScript.serverIp);
- if (scriptServer == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Could not find server. This is a bug in the game. Report to game dev");
- }
- return scriptServer.ip;
- },
- getHostname : function(){
- if (workerScript.checkingRam) {
- return updateStaticRam("getHostname", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetHostnameRamCost);
- }
- updateDynamicRam("getHostname", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetHostnameRamCost);
- var scriptServer = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(workerScript.serverIp);
- if (scriptServer == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Could not find server. This is a bug in the game. Report to game dev");
- }
- return scriptServer.hostname;
- },
- getHackingLevel : function(){
- if (workerScript.checkingRam) {
- return updateStaticRam("getHackingLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetHackingLevelRamCost);
- }
- updateDynamicRam("getHackingLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetHackingLevelRamCost);
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].updateSkillLevels();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getHackingLevel == null) {
- workerScript.scriptRef.log("getHackingLevel() returned " + _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacking_skill);
- }
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacking_skill;
- },
- getHackingMultipliers : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getHackingMultipliers", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetMultipliersRamCost);
- }
- updateDynamicRam("getHackingMultipliers", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetMultipliersRamCost);
- return {
- chance: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacking_chance_mult,
- speed: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacking_speed_mult,
- money: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacking_money_mult,
- growth: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacking_grow_mult,
- };
- },
- getHacknetMultipliers : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getHacknetMultipliers", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetMultipliersRamCost);
- }
- updateDynamicRam("getHacknetMultipliers", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetMultipliersRamCost);
- return {
- production: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacknet_node_money_mult,
- purchaseCost: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacknet_node_purchase_cost_mult,
- ramCost: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacknet_node_ram_cost_mult,
- coreCost: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacknet_node_core_cost_mult,
- levelCost: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacknet_node_level_cost_mult,
- };
- },
- getBitNodeMultipliers: function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getBitNodeMultipliers", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetMultipliersRamCost);
- }
- updateDynamicRam("getBitNodeMultipliers", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetMultipliersRamCost);
- if (!hasAISF) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getBitNodeMultipliers(). It requires Source-File 5 to run.");
- }
- let copy = Object.assign({}, _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_5__["BitNodeMultipliers"]);
- return copy;
- },
- getServerMoneyAvailable : function(ip){
- if (workerScript.checkingRam) {
- return updateStaticRam("getServerMoneyAvailable", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- }
- updateDynamicRam("getServerMoneyAvailable", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerMoneyAvailable() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getServerMoneyAvailable() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (server.hostname == "home") {
- //Return player's money
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {
- workerScript.scriptRef.log("getServerMoneyAvailable('home') returned player's money: $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].money.toNumber(), 2));
- }
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].money.toNumber();
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {
- workerScript.scriptRef.log("getServerMoneyAvailable() returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(server.moneyAvailable, 2) + " for " + server.hostname);
- }
- return server.moneyAvailable;
- },
- getServerSecurityLevel : function(ip){
- if (workerScript.checkingRam) {
- return updateStaticRam("getServerSecurityLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- }
- updateDynamicRam("getServerSecurityLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerSecurityLevel == null) {
- workerScript.scriptRef.log("getServerSecurityLevel() returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(server.hackDifficulty, 3) + " for " + server.hostname);
- }
- return server.hackDifficulty;
- },
- getServerBaseSecurityLevel : function(ip){
- if (workerScript.checkingRam) {
- return updateStaticRam("getServerBaseSecurityLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- }
- updateDynamicRam("getServerBaseSecurityLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerBaseSecurityLevel == null) {
- workerScript.scriptRef.log("getServerBaseSecurityLevel() returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(server.baseDifficulty, 3) + " for " + server.hostname);
- }
- return server.baseDifficulty;
- },
- getServerMinSecurityLevel : function(ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getServerMinSecurityLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- }
- updateDynamicRam("getServerMinSecurityLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMinSecurityLevel == null) {
- workerScript.scriptRef.log("getServerMinSecurityLevel() returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(server.minDifficulty, 3) + " for " + server.hostname);
- }
- return server.minDifficulty;
- },
- getServerRequiredHackingLevel : function(ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getServerRequiredHackingLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- }
- updateDynamicRam("getServerRequiredHackingLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerRequiredHackingLevel == null) {
- workerScript.scriptRef.log("getServerRequiredHackingLevel returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(server.requiredHackingSkill, 0) + " for " + server.hostname);
- }
- return server.requiredHackingSkill;
- },
- getServerMaxMoney : function(ip){
- if (workerScript.checkingRam) {
- return updateStaticRam("getServerMaxMoney", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- }
- updateDynamicRam("getServerMaxMoney", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMaxMoney == null) {
- workerScript.scriptRef.log("getServerMaxMoney() returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(server.moneyMax, 0) + " for " + server.hostname);
- }
- return server.moneyMax;
- },
- getServerGrowth : function(ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getServerGrowth", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- }
- updateDynamicRam("getServerGrowth", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerGrowth() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getServerGrowth() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerGrowth == null) {
- workerScript.scriptRef.log("getServerGrowth() returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(server.serverGrowth, 0) + " for " + server.hostname);
- }
- return server.serverGrowth;
- },
- getServerNumPortsRequired : function(ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getServerNumPortsRequired", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- }
- updateDynamicRam("getServerNumPortsRequired", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerNumPortsRequired == null) {
- workerScript.scriptRef.log("getServerNumPortsRequired() returned " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(server.numOpenPortsRequired, 0) + " for " + server.hostname);
- }
- return server.numOpenPortsRequired;
- },
- getServerRam : function(ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getServerRam", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- }
- updateDynamicRam("getServerRam", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getServerRam() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getServerRam() failed. Invalid IP or hostname passed in: " + ip);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerRam == null) {
- workerScript.scriptRef.log("getServerRam() returned [" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(server.maxRam, 2) + "GB, " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(server.ramUsed, 2) + "GB]");
- }
- return [server.maxRam, server.ramUsed];
- },
- serverExists : function(ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("serverExists", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- }
- updateDynamicRam("serverExists", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetServerRamCost);
- return (Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip) !== null);
- },
- fileExists : function(filename,ip=workerScript.serverIp) {
- if (workerScript.checkingRam) {
- return updateStaticRam("fileExists", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptFileExistsRamCost);
- }
- updateDynamicRam("fileExists", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptFileExistsRamCost);
- if (filename === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "fileExists() call has incorrect number of arguments. Usage: fileExists(scriptname, [server])");
- }
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("fileExists() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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 _Message__WEBPACK_IMPORTED_MODULE_21__[/* Message */ "a"]) &&
- filename.toLowerCase() === server.messages[i]) {
- return true;
- }
- }
- var txtFile = Object(_TextFile__WEBPACK_IMPORTED_MODULE_33__["getTextFile"])(filename, server);
- if (txtFile != null) {
- return true;
- }
- return false;
- },
- isRunning : function(filename,ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("isRunning", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptIsRunningRamCost);
- }
- updateDynamicRam("isRunning", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptIsRunningRamCost);
- if (filename === undefined || ip === undefined) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "isRunning() call has incorrect number of arguments. Usage: isRunning(scriptname, server, [arg1], [arg2]...)");
- }
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("isRunning() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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(_Script__WEBPACK_IMPORTED_MODULE_25__[/* findRunningScript */ "d"])(filename, argsForTargetScript, server) != null);
- },
- getStockSymbols : function(){
- if (workerScript.checkingRam) {
- return updateStaticRam("getStockSymbols", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetStockRamCost);
- }
- updateDynamicRam("getStockSymbols", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetStockRamCost);
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have TIX API Access! Cannot use getStockSymbols()");
- }
- return Object.values(_StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* StockSymbols */ "d"]);
- },
- getStockPrice : function(symbol) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getStockPrice", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetStockRamCost);
- }
- updateDynamicRam("getStockPrice", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetStockRamCost);
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have TIX API Access! Cannot use getStockPrice()");
- }
- var stock = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* SymbolToStockMap */ "e"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid stock symbol passed into getStockPrice()");
- }
- return parseFloat(stock.price.toFixed(3));
- },
- getStockPosition : function(symbol) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getStockPosition", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetStockRamCost);
- }
- updateDynamicRam("getStockPosition", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetStockRamCost);
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have TIX API Access! Cannot use getStockPosition()");
- }
- var stock = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* SymbolToStockMap */ "e"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid stock symbol passed into getStockPosition()");
- }
- return [stock.playerShares, stock.playerAvgPx, stock.playerShortShares, stock.playerAvgShortPx];
- },
- getStockMaxShares : function(symbol) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getStockMaxShares", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetStockRamCost);
- }
- updateDynamicRam("getStockMaxShares", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetStockRamCost);
-
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have TIX API Access! Cannot use getStockMaxShares()");
- }
- const stock = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* SymbolToStockMap */ "e"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid stock symbol passed into getStockMaxShares()");
- }
-
- return stock.maxShares;
- },
- buyStock : function(symbol, shares) {
- if (workerScript.checkingRam) {
- return updateStaticRam("buyStock", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- }
- updateDynamicRam("buyStock", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have TIX API Access! Cannot use buyStock()");
- }
- var stock = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* SymbolToStockMap */ "e"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid stock symbol passed into buyStock()");
- }
- if (shares < 0 || isNaN(shares)) {
- workerScript.scriptRef.log("ERROR: Invalid 'shares' argument passed to buyStock()");
- return 0;
- }
- shares = Math.round(shares);
- if (shares === 0) {return 0;}
-
- // Does player have enough money?
- var totalPrice = stock.price * shares;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].money.lt(totalPrice + _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].StockMarketCommission)) {
- workerScript.scriptRef.log("Not enough money to purchase " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(shares, 0) + " shares of " +
- symbol + ". Need $" +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(totalPrice + _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].StockMarketCommission, 2).toString());
- return 0;
- }
-
- // Would this purchase exceed the maximum number of shares?
- if (shares + stock.playerShares + stock.playerShortShares > stock.maxShares) {
- workerScript.scriptRef.log(`You cannot purchase this many shares. ${stock.symbol} has a maximum of ` +
- `${stock.maxShares} shares.`);
- return 0;
- }
-
- var origTotal = stock.playerShares * stock.playerAvgPx;
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].loseMoney(totalPrice + _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].StockMarketCommission);
- var newTotal = origTotal + totalPrice;
- stock.playerShares += shares;
- stock.playerAvgPx = newTotal / stock.playerShares;
- if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_40__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_40__["Page"].StockMarket)) {
- Object(_StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* updateStockPlayerPosition */ "r"])(stock);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.buyStock == null) {
- workerScript.scriptRef.log("Bought " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(stock.price, 2) + " per share");
- }
- return stock.price;
- },
- sellStock : function(symbol, shares) {
- if (workerScript.checkingRam) {
- return updateStaticRam("sellStock", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- }
- updateDynamicRam("sellStock", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have TIX API Access! Cannot use sellStock()");
- }
- var stock = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* SymbolToStockMap */ "e"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid stock symbol passed into sellStock()");
- }
- if (shares < 0 || isNaN(shares)) {
- workerScript.scriptRef.log("ERROR: Invalid 'shares' argument passed to sellStock()");
- return 0;
- }
- shares = Math.round(shares);
- if (shares > stock.playerShares) {shares = stock.playerShares;}
- if (shares === 0) {return 0;}
- var gains = stock.price * shares - _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].StockMarketCommission;
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gainMoney(gains);
-
- //Calculate net profit and add to script stats
- var netProfit = ((stock.price - stock.playerAvgPx) * shares) - _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].StockMarketCommission;
- if (isNaN(netProfit)) {netProfit = 0;}
- workerScript.scriptRef.onlineMoneyMade += netProfit;
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].scriptProdSinceLastAug += netProfit;
-
- stock.playerShares -= shares;
- if (stock.playerShares == 0) {
- stock.playerAvgPx = 0;
- }
- if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_40__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_40__["Page"].StockMarket)) {
- Object(_StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* updateStockPlayerPosition */ "r"])(stock);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellStock == null) {
- workerScript.scriptRef.log("Sold " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(stock.price, 2) + " per share. Gained " +
- "$" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(gains, 2));
- }
- return stock.price;
- },
- shortStock(symbol, shares) {
- if (workerScript.checkingRam) {
- return updateStaticRam("shortStock", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- }
- updateDynamicRam("shortStock", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have TIX API Access! Cannot use shortStock()");
- }
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 8) {
- if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Cannot use shortStock(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8");
- }
- }
- var stock = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* SymbolToStockMap */ "e"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Invalid stock symbol passed into shortStock()");
- }
- var res = Object(_StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* shortStock */ "p"])(stock, shares, workerScript);
- return res ? stock.price : 0;
- },
- sellShort(symbol, shares) {
- if (workerScript.checkingRam) {
- return updateStaticRam("sellShort", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- }
- updateDynamicRam("sellShort", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have TIX API Access! Cannot use sellShort()");
- }
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 8) {
- if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Cannot use sellShort(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8");
- }
- }
- var stock = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* SymbolToStockMap */ "e"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Invalid stock symbol passed into sellShort()");
- }
- var res = Object(_StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* sellShort */ "n"])(stock, shares, workerScript);
- return res ? stock.price : 0;
- },
- placeOrder(symbol, shares, price, type, pos) {
- if (workerScript.checkingRam) {
- return updateStaticRam("placeOrder", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- }
- updateDynamicRam("placeOrder", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have TIX API Access! Cannot use placeOrder()");
- }
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 8) {
- if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Cannot use placeOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8");
- }
- }
- var stock = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* SymbolToStockMap */ "e"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Invalid stock symbol passed into placeOrder()");
- }
- var orderType, orderPos;
- type = type.toLowerCase();
- if (type.includes("limit") && type.includes("buy")) {
- orderType = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* OrderTypes */ "a"].LimitBuy;
- } else if (type.includes("limit") && type.includes("sell")) {
- orderType = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* OrderTypes */ "a"].LimitSell;
- } else if (type.includes("stop") && type.includes("buy")) {
- orderType = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* OrderTypes */ "a"].StopBuy;
- } else if (type.includes("stop") && type.includes("sell")) {
- orderType = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* OrderTypes */ "a"].StopSell;
- } else {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Invalid Order Type passed into placeOrder()");
- }
-
- pos = pos.toLowerCase();
- if (pos.includes("l")) {
- orderPos = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* PositionTypes */ "b"].Long;
- } else if (pos.includes('s')) {
- orderPos = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* PositionTypes */ "b"].Short;
- } else {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Invalid Position Type passed into placeOrder()");
- }
-
- return Object(_StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* placeOrder */ "l"])(stock, shares, price, orderType, orderPos, workerScript);
- },
- cancelOrder(symbol, shares, price, type, pos) {
- if (workerScript.checkingRam) {
- return updateStaticRam("cancelOrder", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- }
- updateDynamicRam("cancelOrder", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have TIX API Access! Cannot use cancelOrder()");
- }
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 8) {
- if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Cannot use cancelOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8");
- }
- }
- var stock = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* SymbolToStockMap */ "e"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Invalid stock symbol passed into cancelOrder()");
- }
- if (isNaN(shares) || isNaN(price)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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 = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* OrderTypes */ "a"].LimitBuy;
- } else if (type.includes("limit") && type.includes("sell")) {
- orderType = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* OrderTypes */ "a"].LimitSell;
- } else if (type.includes("stop") && type.includes("buy")) {
- orderType = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* OrderTypes */ "a"].StopBuy;
- } else if (type.includes("stop") && type.includes("sell")) {
- orderType = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* OrderTypes */ "a"].StopSell;
- } else {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Invalid Order Type passed into placeOrder()");
- }
-
- pos = pos.toLowerCase();
- if (pos.includes("l")) {
- orderPos = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* PositionTypes */ "b"].Long;
- } else if (pos.includes('s')) {
- orderPos = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* PositionTypes */ "b"].Short;
- } else {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Invalid Position Type passed into placeOrder()");
- }
- var params = {
- stock: stock,
- shares: shares,
- price: price,
- type: orderType,
- pos: orderPos
- };
- return Object(_StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* cancelOrder */ "f"])(params, workerScript);
- },
- getOrders : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getOrders", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- }
- updateDynamicRam("getOrders", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have TIX API Access! Cannot use getOrders()");
- }
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 8) {
- if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Cannot use getOrders(). You must either be in BitNode-8 or have Level 3 of Source-File 8");
- }
- }
-
- const orders = {};
-
- const stockMarketOrders = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* StockMarket */ "c"]["Orders"];
- for (let symbol in stockMarketOrders) {
- const orderBook = stockMarketOrders[symbol];
- if (orderBook.constructor === Array && orderBook.length > 0) {
- orders[symbol] = [];
- for (let i = 0; i < orderBook.length; ++i) {
- orders[symbol].push({
- shares: orderBook[i].shares,
- price: orderBook[i].price,
- type: orderBook[i].type,
- position: orderBook[i].pos,
- });
- }
- }
- }
-
- return orders;
- },
- getStockVolatility : function(symbol) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getStockVolatility", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- }
- updateDynamicRam("getStockVolatility", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].has4SDataTixApi) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have 4S Market Data TIX API Access! Cannot use getStockVolatility()");
- }
- var stock = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* SymbolToStockMap */ "e"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Invalid stock symbol passed into getStockVolatility()");
- }
- return stock.mv / 100; //Convert from percentage to decimal
- },
- getStockForecast : function(symbol) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getStockForecast", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- }
- updateDynamicRam("getStockForecast", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].has4SDataTixApi) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have 4S Market Data TIX API Access! Cannot use getStockForecast()");
- }
- var stock = _StockMarket_StockMarket__WEBPACK_IMPORTED_MODULE_31__[/* SymbolToStockMap */ "e"][symbol];
- if (stock == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Invalid stock symbol passed into getStockForecast()");
- }
- var forecast = 50;
- stock.b ? forecast += stock.otlkMag : forecast -= stock.otlkMag;
- return forecast / 100; //Convert from percentage to decimal
- },
- purchase4SMarketData : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("purchase4SMarketData", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- }
- updateDynamicRam("purchase4SMarketData", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
-
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have TIX API Access! Cannot use purchase4SMarketData()");
- }
-
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].has4SData) {
- if (workerScript.shouldLog("purchase4SMarketData")) {
- workerScript.log("Already purchased 4S Market Data");
- }
- return true;
- }
-
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].money.lt(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].MarketData4SCost)) {
- if (workerScript.shouldLog("purchase4SMarketData")) {
- workerScript.log("Failed to purchase 4S Market Data - Not enough money");
- }
- return false;
- }
-
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].has4SData = true;
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].loseMoney(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].MarketData4SCost);
- if (workerScript.shouldLog("purchase4SMarketData")) {
- workerScript.log("Purchased 4S Market Data");
- }
- return true;
- },
- purchase4SMarketDataTixApi : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("purchase4SMarketDataTixApi", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
- }
- updateDynamicRam("purchase4SMarketDataTixApi", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBuySellStockRamCost);
-
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasTixApiAccess) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "You don't have TIX API Access! Cannot use purchase4SMarketDataTixApi()");
- }
-
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].has4SDataTixApi) {
- if (workerScript.shouldLog("purchase4SMarketDataTixApi")) {
- workerScript.log("Already purchased 4S Market Data TIX API");
- }
- return true;
- }
-
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].money.lt(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].MarketDataTixApi4SCost)) {
- if (workerScript.shouldLog("purchase4SMarketDataTixApi")) {
- workerScript.log("Failed to purchase 4S Market Data TIX API - Not enough money");
- }
- return false;
- }
-
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].has4SDataTixApi = true;
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].loseMoney(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].MarketDataTixApi4SCost);
- if (workerScript.shouldLog("purchase4SMarketDataTixApi")) {
- workerScript.log("Purchased 4S Market Data TIX API");
- }
- return true;
- },
- getPurchasedServerLimit : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getPurchasedServerLimit", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetPurchasedServerLimit);
- }
- updateDynamicRam("getPurchasedServerLimit", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetPurchasedServerLimit);
-
- return Object(_ServerPurchases__WEBPACK_IMPORTED_MODULE_27__[/* getPurchaseServerLimit */ "b"])();
- },
- getPurchasedServerMaxRam: function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getPurchasedServerMaxRam", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetPurchasedServerMaxRam);
- }
- updateDynamicRam("getPurchasedServerMaxRam", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetPurchasedServerMaxRam);
-
- return Object(_ServerPurchases__WEBPACK_IMPORTED_MODULE_27__[/* getPurchaseServerMaxRam */ "c"])();
- },
- getPurchasedServerCost: function(ram) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getPurchasedServerCost", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetPurchaseServerRamCost);
- }
- updateDynamicRam("getPurchasedServerCost", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetPurchaseServerRamCost);
-
- const cost = Object(_ServerPurchases__WEBPACK_IMPORTED_MODULE_27__[/* getPurchaseServerCost */ "a"])(ram);
- if (cost === Infinity) {
- workerScript.scriptRef.log("ERROR: 'getPurchasedServerCost()' failed due to an invalid 'ram' argument");
- return Infinity;
- }
-
- return cost;
- },
- purchaseServer : function(hostname, ram) {
- if (workerScript.checkingRam) {
- return updateStaticRam("purchaseServer", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPurchaseServerRamCost);
- }
- updateDynamicRam("purchaseServer", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPurchaseServerRamCost);
- var hostnameStr = String(hostname);
- hostnameStr = hostnameStr.replace(/\s+/g, '');
- if (hostnameStr == "") {
- workerScript.log("ERROR: Passed empty string for hostname argument of purchaseServer()");
- return "";
- }
-
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].purchasedServers.length >= Object(_ServerPurchases__WEBPACK_IMPORTED_MODULE_27__[/* getPurchaseServerLimit */ "b"])()) {
- workerScript.log(`ERROR: You have reached the maximum limit of ${Object(_ServerPurchases__WEBPACK_IMPORTED_MODULE_27__[/* getPurchaseServerLimit */ "b"])()} servers. You cannot purchase any more.`);
- return "";
- }
-
- const cost = Object(_ServerPurchases__WEBPACK_IMPORTED_MODULE_27__[/* getPurchaseServerCost */ "a"])(ram);
- if (cost === Infinity) {
- workerScript.log("ERROR: 'purchaseServer()' failed due to an invalid 'ram' argument");
- return Infinity;
- }
-
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].money.lt(cost)) {
- workerScript.log("ERROR: Not enough money to purchase server. Need $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(cost, 2));
- return "";
- }
- var newServ = new _Server__WEBPACK_IMPORTED_MODULE_26__[/* Server */ "d"]({
- ip: Object(_utils_IPAddress__WEBPACK_IMPORTED_MODULE_44__[/* createRandomIp */ "a"])(),
- hostname: hostnameStr,
- organizationName: "",
- isConnectedTo: false,
- adminRights: true,
- purchasedByPlayer: true,
- maxRam: ram,
- });
- Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* AddToAllServers */ "a"])(newServ);
-
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].purchasedServers.push(newServ.ip);
- var homeComputer = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].getHomeComputer();
- homeComputer.serversOnNetwork.push(newServ.ip);
- newServ.serversOnNetwork.push(homeComputer.ip);
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].loseMoney(cost);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseServer == null) {
- workerScript.scriptRef.log("Purchased new server with hostname " + newServ.hostname + " for $" + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_45__["formatNumber"])(cost, 2));
- }
- return newServ.hostname;
- },
- deleteServer : function(hostname) {
- if (workerScript.checkingRam) {
- return updateStaticRam("deleteServer", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPurchaseServerRamCost);
- }
- updateDynamicRam("deleteServer", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPurchaseServerRamCost);
- var hostnameStr = String(hostname);
- hostnameStr = hostnameStr.replace(/\s\s+/g, '');
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* GetServerByHostname */ "c"])(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;
-
- //Can't delete server you're currently connected to
- if (server.isConnectedTo) {
- workerScript.scriptRef.log("ERROR: deleteServer() failed because you are currently connected to the server you are trying to delete");
- return false;
- }
-
- //A server cannot delete itself
- if (ip === workerScript.serverIp) {
- workerScript.scriptRef.log("ERROR: Cannot call deleteServer() on self. deleteServer() 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 < _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].purchasedServers.length; ++i) {
- if (ip == _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].purchasedServers[i]) {
- found = true;
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].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 _Server__WEBPACK_IMPORTED_MODULE_26__[/* AllServers */ "b"][ip];
-
- //Delete from home computer
- found = false;
- var homeComputer = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].getHomeComputer();
- for (var i = 0; i < homeComputer.serversOnNetwork.length; ++i) {
- if (ip == homeComputer.serversOnNetwork[i]) {
- homeComputer.serversOnNetwork.splice(i, 1);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.deleteServer == null) {
- 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) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getPurchasedServers", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPurchaseServerRamCost);
- }
- updateDynamicRam("getPurchasedServers", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptPurchaseServerRamCost);
- var res = [];
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].purchasedServers.forEach(function(ip) {
- if (hostname) {
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: 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;
- },
- write : function(port, data="", mode="a") {
- if (workerScript.checkingRam) {
- return updateStaticRam("write", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptReadWriteRamCost);
- }
- updateDynamicRam("write", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptReadWriteRamCost);
- if (!isNaN(port)) { //Write to port
- //Port 1-10
- port = Math.round(port);
- if (port < 1 || port > _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].NumNetscriptPorts) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Trying to write to invalid port: " + port + ". Only ports 1-" + _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].NumNetscriptPorts + " are valid.");
- }
- var port = _NetscriptWorker__WEBPACK_IMPORTED_MODULE_36__[/* NetscriptPorts */ "a"][port-1];
- if (port == null || !(port instanceof _NetscriptPort__WEBPACK_IMPORTED_MODULE_38__[/* NetscriptPort */ "a"])) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer");
- }
- return port.write(data);
- } else if (Object(_utils_helpers_isString__WEBPACK_IMPORTED_MODULE_46__["isString"])(port)) { //Write to script or text file
- var fn = port;
- var server = workerScript.getServer();
- if (server == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Error getting Server for this script in write(). This is a bug please contact game dev");
- }
- if (Object(_Script__WEBPACK_IMPORTED_MODULE_25__[/* isScriptFilename */ "f"])(fn)) {
- //Write to script
- let script = workerScript.getScriptOnServer(fn);
- if (script == null) {
- //Create a new script
- script = new _Script__WEBPACK_IMPORTED_MODULE_25__[/* Script */ "c"](fn, data, server.ip);
- server.scripts.push(script);
- return true;
- }
- mode === "w" ? script.code = data : script.code += data;
- script.updateRamUsage();
- } else {
- //Write to text file
- let txtFile = Object(_TextFile__WEBPACK_IMPORTED_MODULE_33__["getTextFile"])(fn, server);
- if (txtFile == null) {
- txtFile = Object(_TextFile__WEBPACK_IMPORTED_MODULE_33__["createTextFile"])(fn, data, server);
- return true;
- }
- if (mode === "w") {
- txtFile.write(data);
- } else {
- txtFile.append(data);
- }
- }
- return true;
- } else {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid argument passed in for write: " + port);
- }
- },
- tryWrite : function(port, data="") {
- if (workerScript.checkingRam) {
- return updateStaticRam("tryWrite", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptReadWriteRamCost);
- }
- updateDynamicRam("tryWrite", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptReadWriteRamCost);
- if (!isNaN(port)) {
- port = Math.round(port);
- if (port < 1 || port > _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].NumNetscriptPorts) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: tryWrite() called on invalid port: " + port + ". Only ports 1-" + _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].NumNetscriptPorts + " are valid.");
- }
- var port = _NetscriptWorker__WEBPACK_IMPORTED_MODULE_36__[/* NetscriptPorts */ "a"][port-1];
- if (port == null || !(port instanceof _NetscriptPort__WEBPACK_IMPORTED_MODULE_38__[/* NetscriptPort */ "a"])) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer");
- }
- return port.tryWrite(data);
- } else {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid argument passed in for tryWrite: " + port);
- }
- },
- read : function(port) {
- if (workerScript.checkingRam) {
- return updateStaticRam("read", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptReadWriteRamCost);
- }
- updateDynamicRam("read", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptReadWriteRamCost);
- if (!isNaN(port)) { //Read from port
- //Port 1-10
- port = Math.round(port);
- if (port < 1 || port > _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].NumNetscriptPorts) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Trying to read from invalid port: " + port + ". Only ports 1-" + _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].NumNetscriptPorts + " are valid.");
- }
- var port = _NetscriptWorker__WEBPACK_IMPORTED_MODULE_36__[/* NetscriptPorts */ "a"][port-1];
- if (port == null || !(port instanceof _NetscriptPort__WEBPACK_IMPORTED_MODULE_38__[/* NetscriptPort */ "a"])) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Could not find port: " + port + ". This is a bug contact the game developer");
- }
- return port.read();
- } else if (Object(_utils_helpers_isString__WEBPACK_IMPORTED_MODULE_46__["isString"])(port)) { //Read from script or text file
- let fn = port;
- let server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(workerScript.serverIp);
- if (server == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Error getting Server for this script in read(). This is a bug please contact game dev");
- }
- if (Object(_Script__WEBPACK_IMPORTED_MODULE_25__[/* isScriptFilename */ "f"])(fn)) {
- //Read from script
- let script = workerScript.getScriptOnServer(fn);
- if (script == null) {
- return "";
- }
- return script.code;
- } else {
- //Read from text file
- let txtFile = Object(_TextFile__WEBPACK_IMPORTED_MODULE_33__["getTextFile"])(fn, server);
- if (txtFile !== null) {
- return txtFile.text;
- } else {
- return "";
- }
- }
- } else {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid argument passed in for read(): " + port);
- }
- },
- peek : function(port) {
- if (workerScript.checkingRam) {
- return updateStaticRam("peek", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptReadWriteRamCost);
- }
- updateDynamicRam("peek", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptReadWriteRamCost);
- if (isNaN(port)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: peek() called with invalid argument. Must be a port number between 1 and " + _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].NumNetscriptPorts);
- }
- port = Math.round(port);
- if (port < 1 || port > _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].NumNetscriptPorts) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: peek() called with invalid argument. Must be a port number between 1 and " + _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].NumNetscriptPorts);
- }
- var port = _NetscriptWorker__WEBPACK_IMPORTED_MODULE_36__[/* NetscriptPorts */ "a"][port-1];
- if (port == null || !(port instanceof _NetscriptPort__WEBPACK_IMPORTED_MODULE_38__[/* NetscriptPort */ "a"])) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Could not find port: " + port + ". This is a bug contact the game developer");
- }
- return port.peek();
- },
- clear : function(port) {
- if (workerScript.checkingRam) {
- return updateStaticRam("clear", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptReadWriteRamCost);
- }
- updateDynamicRam("clear", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptReadWriteRamCost);
- if (!isNaN(port)) { //Clear port
- port = Math.round(port);
- if (port < 1 || port > _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].NumNetscriptPorts) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Trying to clear invalid port: " + port + ". Only ports 1-" + _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].NumNetscriptPorts + " are valid");
- }
- var port = _NetscriptWorker__WEBPACK_IMPORTED_MODULE_36__[/* NetscriptPorts */ "a"][port-1];
- if (port == null || !(port instanceof _NetscriptPort__WEBPACK_IMPORTED_MODULE_38__[/* NetscriptPort */ "a"])) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Could not find port: " + port + ". This is a bug contact the game developer");
- }
- return port.clear();
- } else if (Object(_utils_helpers_isString__WEBPACK_IMPORTED_MODULE_46__["isString"])(port)) { //Clear text file
- var fn = port;
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(workerScript.serverIp);
- if (server == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Error getting Server for this script in clear(). This is a bug please contact game dev");
- }
- var txtFile = Object(_TextFile__WEBPACK_IMPORTED_MODULE_33__["getTextFile"])(fn, server);
- if (txtFile != null) {
- txtFile.write("");
- }
- } else {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid argument passed in for clear(): " + port);
- }
- return 0;
- },
- getPortHandle : function(port) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getPortHandle", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptReadWriteRamCost * 10);
- }
- updateDynamicRam("getPortHandle", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptReadWriteRamCost * 10);
- if (isNaN(port)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Invalid argument passed into getPortHandle(). Must be an integer between 1 and " + _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].NumNetscriptPorts);
- }
- port = Math.round(port);
- if (port < 1 || port > _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].NumNetscriptPorts) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: getPortHandle() called with invalid port number: " + port + ". Only ports 1-" + _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].NumNetscriptPorts + " are valid");
- }
- var port = _NetscriptWorker__WEBPACK_IMPORTED_MODULE_36__[/* NetscriptPorts */ "a"][port-1];
- if (port == null || !(port instanceof _NetscriptPort__WEBPACK_IMPORTED_MODULE_38__[/* NetscriptPort */ "a"])) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: Could not find port: " + port + ". This is a bug contact the game developer");
- }
- return port;
- },
- rm : function(fn, ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("rm", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptReadWriteRamCost);
- }
- updateDynamicRam("rm", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptReadWriteRamCost);
-
- if (ip == null || ip === "") {
- ip = workerScript.serverIp;
- }
- var s = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (s == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, `Invalid server specified for rm(): ${ip}`);
- }
-
- if (fn.includes(".exe")) {
- for (var i = 0; i < s.programs.length; ++i) {
- if (s.programs[i] === fn) {
- s.programs.splice(i, 1);
- return true;
- }
- }
- } else if (Object(_Script__WEBPACK_IMPORTED_MODULE_25__[/* isScriptFilename */ "f"])(fn)) {
- for (var i = 0; i < s.scripts.length; ++i) {
- if (s.scripts[i].filename === fn) {
- //Check that the script isnt currently running
- for (var j = 0; j < s.runningScripts.length; ++j) {
- if (s.runningScripts[j].filename === fn) {
- workerScript.scriptRef.log("Cannot delete a script that is currently running!");
- return false;
- }
- }
- s.scripts.splice(i, 1);
- return true;
- }
- }
- } else if (fn.endsWith(".lit")) {
- for (var i = 0; i < s.messages.length; ++i) {
- var f = s.messages[i];
- if (!(f instanceof _Message__WEBPACK_IMPORTED_MODULE_21__[/* Message */ "a"]) && Object(_utils_helpers_isString__WEBPACK_IMPORTED_MODULE_46__["isString"])(f) && f === fn) {
- s.messages.splice(i, 1);
- return true;
- }
- }
- } else if (fn.endsWith(".txt")) {
- for (var i = 0; i < s.textFiles.length; ++i) {
- if (s.textFiles[i].fn === fn) {
- s.textFiles.splice(i, 1);
- return true;
- }
- }
- } else if (fn.endsWith(".cct")) {
- for (var i = 0; i < s.contracts.length; ++i) {
- if (s.contracts[i].fn === fn) {
- s.contracts.splice(i, 1);
- return true;
- }
- }
- }
- return false;
- },
- scriptRunning : function(scriptname, ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("scriptRunning", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptArbScriptRamCost);
- }
- updateDynamicRam("scriptRunning", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptArbScriptRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("scriptRunning() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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) {
- if (workerScript.checkingRam) {
- return updateStaticRam("scriptKill", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptArbScriptRamCost);
- }
- updateDynamicRam("scriptKill", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptArbScriptRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("scriptKill() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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(_NetscriptWorker__WEBPACK_IMPORTED_MODULE_36__[/* killWorkerScript */ "d"])(server.runningScripts[i], server.ip);
- suc = true;
- }
- }
- return suc;
- },
- getScriptName : function() {
- if (workerScript.checkingRam) {return 0;}
- return workerScript.name;
- },
- getScriptRam : function (scriptname, ip=workerScript.serverIp) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getScriptRam", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetScriptRamCost);
- }
- updateDynamicRam("getScriptRam", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetScriptRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getScriptRam() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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, hack, int) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getHackTime", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetHackTimeRamCost);
- }
- updateDynamicRam("getHackTime", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetHackTimeRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getHackTime() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getHackTime() failed. Invalid IP or hostname passed in: " + ip);
- }
- return Object(_Hacking__WEBPACK_IMPORTED_MODULE_14__[/* calculateHackingTime */ "d"])(server, hack, int); //Returns seconds
- },
- getGrowTime : function(ip, hack, int) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getGrowTime", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetHackTimeRamCost);
- }
- updateDynamicRam("getGrowTime", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetHackTimeRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getGrowTime() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getGrowTime() failed. Invalid IP or hostname passed in: " + ip);
- }
- return Object(_Hacking__WEBPACK_IMPORTED_MODULE_14__[/* calculateGrowTime */ "a"])(server, hack, int); //Returns seconds
- },
- getWeakenTime : function(ip, hack, int) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getWeakenTime", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetHackTimeRamCost);
- }
- updateDynamicRam("getWeakenTime", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetHackTimeRamCost);
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
- }
- return Object(_Hacking__WEBPACK_IMPORTED_MODULE_14__[/* calculateWeakenTime */ "f"])(server, hack, int); //Returns seconds
- },
- getScriptIncome : function(scriptname, ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getScriptIncome", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetScriptRamCost);
- }
- updateDynamicRam("getScriptIncome", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetScriptRamCost);
- if (arguments.length === 0) {
- //Get total script income
- var res = [];
- res.push(Object(_ActiveScriptsUI__WEBPACK_IMPORTED_MODULE_0__[/* updateActiveScriptsItems */ "c"])());
- res.push(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].scriptProdSinceLastAug / (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].playtimeSinceLastAug/1000));
- return res;
- } else {
- //Get income for a particular script
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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(_Script__WEBPACK_IMPORTED_MODULE_25__[/* findRunningScript */ "d"])(scriptname, argsForScript, server);
- if (runningScriptObj == null) {
- workerScript.scriptRef.log("getScriptIncome() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(_utils_helpers_arrayToString__WEBPACK_IMPORTED_MODULE_43__["arrayToString"])(argsForScript));
- return -1;
- }
- return runningScriptObj.onlineMoneyMade / runningScriptObj.onlineRunningTime;
- }
- },
- getScriptExpGain : function(scriptname, ip) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getScriptExpGain", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetScriptRamCost);
- }
- updateDynamicRam("getScriptExpGain", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetScriptRamCost);
- if (arguments.length === 0) {
- var total = 0;
- for (var i = 0; i < _NetscriptWorker__WEBPACK_IMPORTED_MODULE_36__[/* workerScripts */ "h"].length; ++i) {
- total += (_NetscriptWorker__WEBPACK_IMPORTED_MODULE_36__[/* workerScripts */ "h"][i].scriptRef.onlineExpGained / _NetscriptWorker__WEBPACK_IMPORTED_MODULE_36__[/* workerScripts */ "h"][i].scriptRef.onlineRunningTime);
- }
- return total;
- } else {
- //Get income for a particular script
- var server = Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* getServer */ "e"])(ip);
- if (server == null) {
- workerScript.scriptRef.log("getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip);
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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(_Script__WEBPACK_IMPORTED_MODULE_25__[/* findRunningScript */ "d"])(scriptname, argsForScript, server);
- if (runningScriptObj == null) {
- workerScript.scriptRef.log("getScriptExpGain() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(_utils_helpers_arrayToString__WEBPACK_IMPORTED_MODULE_43__["arrayToString"])(argsForScript));
- return -1;
- }
- return runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime;
- }
- },
- getTimeSinceLastAug : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getTimeSinceLastAug", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetHackTimeRamCost);
- }
- updateDynamicRam("getTimeSinceLastAug", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetHackTimeRamCost);
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].playtimeSinceLastAug;
- },
- prompt : function(txt) {
- if (workerScript.checkingRam) {return 0;}
- if (_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_47__["yesNoBoxOpen"]) {
- workerScript.scriptRef.log("ERROR: confirm() failed because a pop-up dialog box is already open");
- return false;
- }
- if (!Object(_utils_helpers_isString__WEBPACK_IMPORTED_MODULE_46__["isString"])(txt)) {txt = String(txt);}
- var yesBtn = Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_47__["yesNoBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_47__["yesNoBoxGetNoButton"])();
- yesBtn.innerHTML = "Yes";
- noBtn.innerHTML = "No";
- return new Promise(function(resolve, reject) {
- yesBtn.addEventListener("click", ()=>{
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_47__["yesNoBoxClose"])();
- resolve(true);
- });
- noBtn.addEventListener("click", ()=>{
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_47__["yesNoBoxClose"])();
- resolve(false);
- });
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_47__["yesNoBoxCreate"])(txt);
- });
- },
- wget : async function(url, target, ip=workerScript.serverIp) {
- if (workerScript.checkingRam) { return 0; }
- if (!Object(_Script__WEBPACK_IMPORTED_MODULE_25__[/* isScriptFilename */ "f"])(target) && !target.endsWith(".txt")) {
- workerSript.log(`ERROR: wget() failed because of an invalid target file: ${target}. Target file must be a script or text file`);
- return Promise.resolve(false);
- }
- var s = safeGetServer(ip, "wget");
- return new Promise(function(resolve, reject) {
- $.get(url, function(data) {
- let res;
- if (Object(_Script__WEBPACK_IMPORTED_MODULE_25__[/* isScriptFilename */ "f"])(target)) {
- res = s.writeToScriptFile(target, data);
- } else {
- res = s.writeToTextFile(target, data);
- }
- if (!res.success) {
- workerScript.log("ERROR: wget() failed");
- return resolve(false);
- }
- if (res.overwritten) {
- workerScript.log(`wget() successfully retrieved content and overwrote ${target} on ${ip}`);
- return resolve(true);
- }
- workerScript.log(`wget successfully retrieved content to new file ${target} on ${ip}`);
- return resolve(true);
- }, 'text').fail(function(e) {
- workerScript.log(`ERROR: wget() failed: ${JSON.stringify(e)}`);
- return resolve(false)
- });
- });
- },
- getFavorToDonate: function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getFavorToDonate", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetFavorToDonate);
- }
- updateDynamicRam("getFavorToDonate", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGetFavorToDonate);
- return Math.floor(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].BaseFavorToDonate * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_5__["BitNodeMultipliers"].RepToDonateToFaction);
- },
-
- /* Singularity Functions */
- universityCourse : function(universityName, className) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn1RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("universityCourse", ramCost);
- }
- updateDynamicRam("universityCourse", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run universityCourse(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return false;
- }
- }
- if (_Missions__WEBPACK_IMPORTED_MODULE_22__[/* inMission */ "c"]) {
- workerScript.scriptRef.log("ERROR: universityCourse() failed because you are in the middle of a mission.");
- return;
- }
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].isWorking) {
- var txt = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].singularityStopWork();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.universityCourse == null) {
- workerScript.scriptRef.log(txt);
- }
- }
-
- var costMult, expMult;
- switch(universityName.toLowerCase()) {
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].AevumSummitUniversity.toLowerCase():
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].city != _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Aevum) {
- workerScript.scriptRef.log("ERROR: You cannot study at Summit University because you are not in Aevum. universityCourse() failed");
- return false;
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].AevumSummitUniversity;
- costMult = 4;
- expMult = 3;
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Sector12RothmanUniversity.toLowerCase():
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].city != _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Sector12) {
- workerScript.scriptRef.log("ERROR: You cannot study at Rothman University because you are not in Sector-12. universityCourse() failed");
- return false;
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Sector12RothmanUniversity;
- costMult = 3;
- expMult = 2;
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].VolhavenZBInstituteOfTechnology.toLowerCase():
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].city != _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Volhaven) {
- workerScript.scriptRef.log("ERROR: You cannot study at ZB Institute of Technology because you are not in Volhaven. universityCourse() failed");
- return false;
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["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 = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ClassStudyComputerScience;
- break;
- case "Data Structures".toLowerCase():
- task = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ClassDataStructures;
- break;
- case "Networks".toLowerCase():
- task = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ClassNetworks;
- break;
- case "Algorithms".toLowerCase():
- task = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ClassAlgorithms;
- break;
- case "Management".toLowerCase():
- task = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ClassManagement;
- break;
- case "Leadership".toLowerCase():
- task = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ClassLeadership;
- break;
- default:
- workerScript.scriptRef.log("Invalid class name: " + className + ". universityCourse() failed");
- return false;
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].startClass(costMult, expMult, task);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.universityCourse == null) {
- workerScript.scriptRef.log("Started " + task + " at " + universityName);
- }
- return true;
- },
-
- gymWorkout : function(gymName, stat) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn1RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("gymWorkout", ramCost);
- }
- updateDynamicRam("gymWorkout", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run gymWorkout(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return false;
- }
- }
- if (_Missions__WEBPACK_IMPORTED_MODULE_22__[/* inMission */ "c"]) {
- workerScript.scriptRef.log("ERROR: gymWorkout() failed because you are in the middle of a mission.");
- return;
- }
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].isWorking) {
- var txt = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].singularityStopWork();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.gymWorkout == null) {
- workerScript.scriptRef.log(txt);
- }
- }
- var costMult, expMult;
- switch(gymName.toLowerCase()) {
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].AevumCrushFitnessGym.toLowerCase():
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].city != _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Aevum) {
- workerScript.scriptRef.log("ERROR: You cannot workout at Crush Fitness because you are not in Aevum. gymWorkout() failed");
- return false;
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].AevumCrushFitnessGym;
- costMult = 3;
- expMult = 2;
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].AevumSnapFitnessGym.toLowerCase():
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].city != _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Aevum) {
- workerScript.scriptRef.log("ERROR: You cannot workout at Snap Fitness because you are not in Aevum. gymWorkout() failed");
- return false;
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].AevumSnapFitnessGym;
- costMult = 10;
- expMult = 5;
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Sector12IronGym.toLowerCase():
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].city != _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Sector12) {
- workerScript.scriptRef.log("ERROR: You cannot workout at Iron Gym because you are not in Sector-12. gymWorkout() failed");
- return false;
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Sector12IronGym;
- costMult = 1;
- expMult = 1;
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Sector12PowerhouseGym.toLowerCase():
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].city != _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Sector12) {
- workerScript.scriptRef.log("ERROR: You cannot workout at Powerhouse Gym because you are not in Sector-12. gymWorkout() failed");
- return false;
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Sector12PowerhouseGym;
- costMult = 20;
- expMult = 10;
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].VolhavenMilleniumFitnessGym.toLowerCase():
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].city != _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Volhaven) {
- workerScript.scriptRef.log("ERROR: You cannot workout at Millenium Fitness Gym because you are not in Volhaven. gymWorkout() failed");
- return false;
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].VolhavenMilleniumFitnessGym;
- costMult = 7;
- expMult = 4;
- break;
- default:
- workerScript.scriptRef.log("Invalid gym name: " + gymName + ". gymWorkout() failed");
- return false;
- }
-
- switch(stat.toLowerCase()) {
- case "strength".toLowerCase():
- case "str".toLowerCase():
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].startClass(costMult, expMult, _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ClassGymStrength);
- break;
- case "defense".toLowerCase():
- case "def".toLowerCase():
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].startClass(costMult, expMult, _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ClassGymDefense);
- break;
- case "dexterity".toLowerCase():
- case "dex".toLowerCase():
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].startClass(costMult, expMult, _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ClassGymDexterity);
- break;
- case "agility".toLowerCase():
- case "agi".toLowerCase():
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].startClass(costMult, expMult, _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ClassGymAgility);
- break;
- default:
- workerScript.scriptRef.log("Invalid stat: " + stat + ". gymWorkout() failed");
- return false;
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.gymWorkout == null) {
- workerScript.scriptRef.log("Started training " + stat + " at " + gymName);
- }
- return true;
- },
-
- travelToCity(cityname) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn1RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("travelToCity", ramCost);
- }
- updateDynamicRam("travelToCity", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run travelToCity(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return false;
- }
- }
-
- switch(cityname) {
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Aevum:
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Chongqing:
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Sector12:
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].NewTokyo:
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Ishima:
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Volhaven:
- if(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].money.lt(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].TravelCost)) {
- workerScript.scriptRef.log("ERROR: not enough money to travel with travelToCity().");
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "ERROR: not enough money to travel with travelToCity().");
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].loseMoney(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].TravelCost);
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].city = cityname;
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.travelToCity == null) {
- workerScript.scriptRef.log("Traveled to " + cityname);
- }
- return true;
- default:
- workerScript.scriptRef.log("ERROR: Invalid city name passed into travelToCity().");
- return false;
- }
- },
-
- purchaseTor() {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn1RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("purchaseTor", ramCost);
- }
- updateDynamicRam("purchaseTor", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run purchaseTor(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return false;
- }
- }
-
- if (_SpecialServerIps__WEBPACK_IMPORTED_MODULE_29__[/* SpecialServerIps */ "a"]["Darkweb Server"] != null) {
- workerScript.scriptRef.log("You already have a TOR router! purchaseTor() failed");
- return false;
- }
-
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].money.lt(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].TorRouterCost)) {
- workerScript.scriptRef.log("ERROR: You cannot afford to purchase a Tor router. purchaseTor() failed");
- return false;
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].loseMoney(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].TorRouterCost);
-
- var darkweb = new _Server__WEBPACK_IMPORTED_MODULE_26__[/* Server */ "d"]({
- ip:Object(_utils_IPAddress__WEBPACK_IMPORTED_MODULE_44__[/* createRandomIp */ "a"])(), hostname:"darkweb", organizationName:"",
- isConnectedTo:false, adminRights:false, purchasedByPlayer:false, maxRam:1
- });
- Object(_Server__WEBPACK_IMPORTED_MODULE_26__[/* AddToAllServers */ "a"])(darkweb);
- _SpecialServerIps__WEBPACK_IMPORTED_MODULE_29__[/* SpecialServerIps */ "a"].addIp("Darkweb Server", darkweb.ip);
-
- const purchaseTor = document.getElementById("location-purchase-tor");
- purchaseTor.setAttribute("class", "a-link-button-bought");
- purchaseTor.innerHTML = "TOR Router - Purchased";
-
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].getHomeComputer().serversOnNetwork.push(darkweb.ip);
- darkweb.serversOnNetwork.push(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].getHomeComputer().ip);
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gainIntelligenceExp(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseTor == null) {
- workerScript.scriptRef.log("You have purchased a Tor router!");
- }
- return true;
- },
- purchaseProgram(programName) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn1RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("purchaseProgram", ramCost);
- }
- updateDynamicRam("purchaseProgram", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run purchaseProgram(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return false;
- }
- }
-
- if (_SpecialServerIps__WEBPACK_IMPORTED_MODULE_29__[/* SpecialServerIps */ "a"]["Darkweb Server"] == null) {
- workerScript.scriptRef.log("ERROR: You do not have the TOR router. purchaseProgram() failed.");
- return false;
- }
-
- programName = programName.toLowerCase();
-
- let item = null;
- for(const key in _DarkWeb_DarkWebItems__WEBPACK_IMPORTED_MODULE_13__["DarkWebItems"]) {
- const i = _DarkWeb_DarkWebItems__WEBPACK_IMPORTED_MODULE_13__["DarkWebItems"][key];
- if(i.program.toLowerCase() == programName) {
- item = i;
- }
- }
-
- if(item == null) {
- workerScript.scriptRef.log("ERROR: Invalid program name passed into purchaseProgram().");
- return false;
- }
-
- if(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].money.lt(item.price)) {
- workerScript.scriptRef.log("Not enough money to purchase " + item.program);
- return false;
- }
-
-
- if(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasProgram(item.program)) {
- workerScript.scriptRef.log('You already have the '+item.program+' program');
- return true;
- }
-
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].loseMoney(item.price);
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].getHomeComputer().programs.push(item.program);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
- workerScript.scriptRef.log("You have purchased the "+item.program+" program. The new program can be found on your home computer.");
- }
- return true;
- },
- getStats : function() {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn1RamCost / 4;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getStats", ramCost);
- }
- updateDynamicRam("getStats", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getStats(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return {};
- }
- }
-
- return {
- hacking: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacking_skill,
- strength: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].strength,
- defense: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].defense,
- dexterity: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].dexterity,
- agility: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].agility,
- charisma: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].charisma,
- intelligence: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].intelligence
- }
- },
- getCharacterInformation : function() {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn1RamCost / 4;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getCharacterInformation", ramCost);
- }
- updateDynamicRam("getCharacterInformation", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getCharacterInformation(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return {};
- }
- }
-
- return {
- bitnode: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN,
- city: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].city,
- factions: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].factions.slice(),
- jobs: Object.keys(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].jobs),
- jobTitles: Object.values(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].jobs),
- mult: {
- agility: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].agility_mult,
- agilityExp: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].agility_exp_mult,
- companyRep: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].company_rep_mult,
- crimeMoney: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].crime_money_mult,
- crimeSuccess: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].crime_success_mult,
- defense: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].defense_mult,
- defenseExp: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].defense_exp_mult,
- dexterity: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].dexterity_mult,
- dexterityExp: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].dexterity_exp_mult,
- factionRep: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].faction_rep_mult,
- hacking: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacking_mult,
- hackingExp: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hacking_exp_mult,
- strength: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].strength_mult,
- strengthExp: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].strength_exp_mult,
- workMoney: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].work_money_mult,
- },
- timeWorked: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].timeWorked,
- tor: _SpecialServerIps__WEBPACK_IMPORTED_MODULE_29__[/* SpecialServerIps */ "a"].hasOwnProperty("Darkweb Server"),
- workHackExpGain: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].workHackExpGained,
- workStrExpGain: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].workStrExpGained,
- workDefExpGain: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].workDefExpGained,
- workDexExpGain: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].workDexExpGained,
- workAgiExpGain: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].workAgiExpGained,
- workChaExpGain: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].workChaExpGained,
- workRepGain: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].workRepGained,
- workMoneyGain: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].workMoneyGained,
- };
- },
- isBusy : function() {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn1RamCost / 4;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("isBusy", ramCost);
- }
- updateDynamicRam("isBusy", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run isBusy(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return;
- }
- }
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].isWorking;
- },
- stopAction : function() {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn1RamCost / 2;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("stopAction", ramCost);
- }
- updateDynamicRam("stopAction", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 1)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run stopAction(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
- return false;
- }
- }
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].isWorking) {
- var txt = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].singularityStopWork();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.stopAction == null) {
- workerScript.scriptRef.log(txt);
- }
- return true;
- }
- return false;
- },
- upgradeHomeRam : function() {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn2RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("upgradeHomeRam", ramCost);
- }
- updateDynamicRam("upgradeHomeRam", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run upgradeHomeRam(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- // Check if we're at max RAM
- const homeComputer = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].getHomeComputer();
- if (homeComputer.maxRam >= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].HomeComputerMaxRam) {
- workerScript.log(`ERROR: upgradeHomeRam() failed because your home computer is at max RAM`);
- return false;
- }
-
- const cost = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].getUpgradeHomeRamCost();
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].money.lt(cost)) {
- workerScript.scriptRef.log("ERROR: upgradeHomeRam() failed because you don't have enough money");
- return false;
- }
-
- homeComputer.maxRam *= 2;
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].loseMoney(cost);
-
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gainIntelligenceExp(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.upgradeHomeRam == null) {
- workerScript.scriptRef.log("Purchased additional RAM for home computer! It now has " + homeComputer.maxRam + "GB of RAM.");
- }
- return true;
- },
- getUpgradeHomeRamCost : function() {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn2RamCost / 2;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getUpgradeHomeRamCost", ramCost);
- }
- updateDynamicRam("getUpgradeHomeRamCost", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getUpgradeHomeRamCost(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].getUpgradeHomeRamCost();
- },
- workForCompany : function(companyName) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn2RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("workForCompany", ramCost);
- }
- updateDynamicRam("workForCompany", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run workForCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- // Sanitize input
- if (companyName == null) {
- companyName = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].companyName;
- }
-
- // Make sure its a valid company
- if (companyName == null || companyName === "" || !(_Company_Companies__WEBPACK_IMPORTED_MODULE_9__["Companies"][companyName] instanceof _Company_Company__WEBPACK_IMPORTED_MODULE_8__["Company"])) {
- workerScript.scriptRef.log(`ERROR: workForCompany() failed because of an invalid company specified: ${companyName}`);
- return false;
- }
-
- // Make sure player is actually employed at the comapny
- if (!Object.keys(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].jobs).includes(companyName)) {
- workerScript.scriptRef.log(`ERROR: workForCompany() failed because you do not have a job at ${companyName}`);
- return false;
- }
-
- // Cant work while in a mission
- if (_Missions__WEBPACK_IMPORTED_MODULE_22__[/* inMission */ "c"]) {
- workerScript.scriptRef.log("ERROR: workForCompany() failed because you are in the middle of a mission.");
- return false;
- }
-
- // Check to make sure company position data is valid
- const companyPositionName = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].jobs[companyName];
- const companyPosition = _Company_CompanyPositions__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"][companyPositionName];
- if (companyPositionName === "" || !(companyPosition instanceof _Company_CompanyPosition__WEBPACK_IMPORTED_MODULE_10__["CompanyPosition"])) {
- workerScript.scriptRef.log("ERROR: workForCompany() failed because you do not have a job");
- return false;
- }
-
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].isWorking) {
- var txt = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].singularityStopWork();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForCompany == null) {
- workerScript.scriptRef.log(txt);
- }
- }
-
- if (companyPosition.isPartTimeJob()) {
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].startWorkPartTime(companyName);
- } else {
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].startWork(companyName);
- }
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForCompany == null) {
- workerScript.log(`Began working at ${_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].companyName} as a ${companyPositionName}`);
- }
- return true;
- },
- applyToCompany : function(companyName, field) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn2RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("applyToCompany", ramCost);
- }
- updateDynamicRam("applyToCompany", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run applyToCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- if (!Object(_Company_Companies__WEBPACK_IMPORTED_MODULE_9__["companyExists"])(companyName)) {
- workerScript.scriptRef.log("ERROR: applyToCompany() failed because specified company " + companyName + " does not exist.");
- return false;
- }
-
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = companyName;
- var res;
- switch (field.toLowerCase()) {
- case "software":
- res = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].applyForSoftwareJob(true);
- break;
- case "software consultant":
- res = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].applyForSoftwareConsultantJob(true);
- break;
- case "it":
- res = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].applyForItJob(true);
- break;
- case "security engineer":
- res = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].applyForSecurityEngineerJob(true);
- break;
- case "network engineer":
- res = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].applyForNetworkEngineerJob(true);
- break;
- case "business":
- res = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].applyForBusinessJob(true);
- break;
- case "business consultant":
- res = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].applyForBusinessConsultantJob(true);
- break;
- case "security":
- res = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].applyForSecurityJob(true);
- break;
- case "agent":
- res = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].applyForAgentJob(true);
- break;
- case "employee":
- res = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].applyForEmployeeJob(true);
- break;
- case "part-time employee":
- res = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].applyForPartTimeEmployeeJob(true);
- break;
- case "waiter":
- res = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].applyForWaiterJob(true);
- break;
- case "part-time waiter":
- res = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].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(_utils_helpers_isString__WEBPACK_IMPORTED_MODULE_46__["isString"])(res)) {
- workerScript.scriptRef.log(res);
- return false;
- }
- if (res) {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.applyToCompany == null) {
- workerScript.log(`You were offered a new job at ${companyName} as a ${_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].jobs[companyName]}`);
- }
- } else {
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.applyToCompany == null) {
- workerScript.log(`You failed to get a new job/promotion at ${companyName} in the ${field} field.`);
- }
- }
- return res;
- },
- getCompanyRep : function(companyName) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn2RamCost / 2;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getCompanyRep", ramCost);
- }
- updateDynamicRam("getCompanyRep", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getCompanyRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- var company = _Company_Companies__WEBPACK_IMPORTED_MODULE_9__["Companies"][companyName];
- if (company == null || !(company instanceof _Company_Company__WEBPACK_IMPORTED_MODULE_8__["Company"])) {
- workerScript.scriptRef.log("ERROR: Invalid companyName passed into getCompanyRep(): " + companyName);
- return -1;
- }
- return company.playerReputation;
- },
- getCompanyFavor : function(companyName) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn2RamCost / 4;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getCompanyFavor", ramCost);
- }
- updateDynamicRam("getCompanyFavor", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getCompanyFavor(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- var company = _Company_Companies__WEBPACK_IMPORTED_MODULE_9__["Companies"][companyName];
- if (company == null || !(company instanceof _Company_Company__WEBPACK_IMPORTED_MODULE_8__["Company"])) {
- workerScript.scriptRef.log("ERROR: Invalid companyName passed into getCompanyFavor(): " + companyName);
- return -1;
- }
- return company.favor;
- },
- getCompanyFavorGain : function(companyName) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn2RamCost / 4;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getCompanyFavorGain", ramCost);
- }
- updateDynamicRam("getCompanyFavorGain", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getCompanyFavorGain(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return -1;
- }
- }
-
- var company = _Company_Companies__WEBPACK_IMPORTED_MODULE_9__["Companies"][companyName];
- if (company == null || !(company instanceof _Company_Company__WEBPACK_IMPORTED_MODULE_8__["Company"])) {
- workerScript.scriptRef.log("ERROR: Invalid companyName passed into getCompanyFavorGain(): " + companyName);
- return -1;
- }
- return company.getFavorGain()[0];
- },
- checkFactionInvitations : function() {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn2RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("checkFactionInvitations", ramCost);
- }
- updateDynamicRam("checkFactionInvitations", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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 _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].factionInvitations.slice();
- },
- joinFaction : function(name) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn2RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("joinFaction", ramCost);
- }
- updateDynamicRam("joinFaction", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run joinFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- if (!Object(_Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["factionExists"])(name)) {
- workerScript.scriptRef.log("ERROR: Faction specified in joinFaction() does not exist.");
- return false;
- }
-
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].factionInvitations.includes(name)) {
- workerScript.scriptRef.log("ERROR: Cannot join " + name + " Faction because you have not been invited. joinFaction() failed");
- return false;
- }
- var fac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["Factions"][name];
- Object(_Faction_FactionHelpers__WEBPACK_IMPORTED_MODULE_18__[/* joinFaction */ "c"])(fac);
-
- //Update Faction Invitation list to account for joined + banned factions
- for (var i = 0; i < _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].factionInvitations.length; ++i) {
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].factionInvitations[i] == name || _Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["Factions"][_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].factionInvitations[i]].isBanned) {
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].factionInvitations.splice(i, 1);
- i--;
- }
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gainIntelligenceExp(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.joinFaction == null) {
- workerScript.scriptRef.log("Joined the " + name + " faction.");
- }
- return true;
- },
- workForFaction : function(name, type) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn2RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("workForFaction", ramCost);
- }
- updateDynamicRam("workForFaction", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run workForFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return false;
- }
- }
-
- // if the player is in a gang and the target faction is any of the gang faction, fail
- if(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].inGang() && _Gang__WEBPACK_IMPORTED_MODULE_15__[/* AllGangs */ "a"][name] !== undefined) {
- workerScript.scriptRef.log("ERROR: Faction specified in workForFaction() does not offer work at the moment.");
- return;
- }
-
- if (_Missions__WEBPACK_IMPORTED_MODULE_22__[/* inMission */ "c"]) {
- workerScript.scriptRef.log("ERROR: workForFaction() failed because you are in the middle of a mission.");
- return;
- }
-
- if (!Object(_Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["factionExists"])(name)) {
- workerScript.scriptRef.log("ERROR: Faction specified in workForFaction() does not exist.");
- return false;
- }
-
- if (!_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].factions.includes(name)) {
- workerScript.scriptRef.log("ERROR: workForFaction() failed because you are not a member of " + name);
- return false;
- }
-
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].isWorking) {
- var txt = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].singularityStopWork();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForFaction == null) {
- workerScript.scriptRef.log(txt);
- }
- }
-
- var fac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["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;
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].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;
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].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;
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].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 : function(name) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn2RamCost / 4;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getFactionRep", ramCost);
- }
- updateDynamicRam("getFactionRep", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getFactionRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return -1;
- }
- }
-
- if (!Object(_Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["factionExists"])(name)) {
- workerScript.scriptRef.log("ERROR: Faction specified in getFactionRep() does not exist.");
- return -1;
- }
-
- return _Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["Factions"][name].playerReputation;
- },
- getFactionFavor : function(name) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn2RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getFactionFavor", ramCost);
- }
- updateDynamicRam("getFactionFavor", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getFactionFavor(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return -1;
- }
- }
-
- if (!Object(_Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["factionExists"])(name)) {
- workerScript.scriptRef.log("ERROR: Faction specified in getFactionFavor() does not exist.");
- return -1;
- }
-
- return _Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["Factions"][name].favor;
- },
- getFactionFavorGain: function(name) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn2RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getFactionFavorGain", ramCost);
- }
- updateDynamicRam("getFactionFavorGain", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 2)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getFactionFavorGain(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
- return -1;
- }
- }
-
- if (!Object(_Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["factionExists"])(name)) {
- workerScript.scriptRef.log("ERROR: Faction specified in getFactionFavorGain() does not exist.");
- return -1;
- }
-
- return _Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["Factions"][name].getFavorGain()[0];
- },
- donateToFaction : function(name, amt) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("donateToFaction", ramCost);
- }
- updateDynamicRam("donateToFaction", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run donateToFaction(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return;
- }
- }
-
- if (!Object(_Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["factionExists"])(name)) {
- workerScript.log(`ERROR: Faction specified in donateToFaction() does not exist: ${name}`);
- return false;
- }
- if (typeof amt !== 'number' || amt <= 0) {
- workerScript.log(`ERROR: Invalid donation amount specified in donateToFaction(): ${amt}. Must be numeric and positive`);
- return false;
- }
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].money.lt(amt)) {
- workerScript.log(`ERROR: You do not have enough money to donate $${amt} to ${name}`);
- return false;
- }
- var repNeededToDonate = Math.round(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].BaseFavorToDonate * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_5__["BitNodeMultipliers"].RepToDonateToFaction);
- if (_Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["Factions"][name].favor < repNeededToDonate) {
- workerScript.log(`ERROR: You do not have enough favor to donate to this faction. Have ${_Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["Factions"][name].favor}, need ${repNeededToDonate}`);
- return false;
- }
- var repGain = amt / _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].DonateMoneyToRepDivisor * _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].faction_rep_mult;
- _Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["Factions"][name].playerReputation += repGain;
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].loseMoney(amt);
- if (workerScript.shouldLog("donateToFaction")) {
- workerScript.log(`$${amt} donated to ${name} for ${repGain} reputation`);
- }
- return true;
- },
- createProgram : function(name) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("createProgram", ramCost);
- }
- updateDynamicRam("createProgram", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run createProgram(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return false;
- }
- }
- if (_Missions__WEBPACK_IMPORTED_MODULE_22__[/* inMission */ "c"]) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because you are in the middle of a mission.");
- return;
- }
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].isWorking) {
- var txt = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].singularityStopWork();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.createProgram == null) {
- workerScript.scriptRef.log(txt);
- }
- }
-
- name = name.toLowerCase();
-
- let p = null;
- for (const key in _Programs_Programs__WEBPACK_IMPORTED_MODULE_24__["Programs"]) {
- if(_Programs_Programs__WEBPACK_IMPORTED_MODULE_24__["Programs"][key].name.toLowerCase() == name) {
- p = _Programs_Programs__WEBPACK_IMPORTED_MODULE_24__["Programs"][key];
- }
- }
-
- if (p == null) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because the specified program does not exist: " + name);
- return false;
- }
-
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].hasProgram(p.name)) {
- workerScript.scriptRef.log('ERROR: createProgram() failed because you already have the ' + p.name + ' program');
- return false;
- }
-
- if (!p.create.req(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"])) {
- workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create " + p.name + " (level " + p.create.level + " req)");
- return false
- }
-
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].startCreateProgramWork(p.name, p.create.time, p.create.level);
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.createProgram == null) {
- workerScript.scriptRef.log("Began creating program: " + name);
- }
- return true;
- },
- commitCrime : function(crimeRoughName) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("commitCrime", ramCost);
- }
- updateDynamicRam("commitCrime", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run commitCrime(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return;
- }
- }
- if (_Missions__WEBPACK_IMPORTED_MODULE_22__[/* inMission */ "c"]) {
- workerScript.scriptRef.log("ERROR: commitCrime() failed because you are in the middle of a mission.");
- return;
- }
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].isWorking) {
- var txt = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].singularityStopWork();
- if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null) {
- workerScript.scriptRef.log(txt);
- }
- }
-
- //Set Location to slums
- switch(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].city) {
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Aevum:
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].AevumSlums;
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Chongqing:
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].ChongqingSlums;
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Sector12:
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Sector12Slums;
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].NewTokyo:
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].NewTokyoSlums;
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Ishima:
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].IshimaSlums;
- break;
- case _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].Volhaven:
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].location = _Locations__WEBPACK_IMPORTED_MODULE_20__["Locations"].VolhavenSlums;
- break;
- default:
- console.log("Invalid Player.city value");
- }
-
- const crime = Object(_Crime_CrimeHelpers__WEBPACK_IMPORTED_MODULE_6__[/* findCrime */ "b"])(crimeRoughName.toLowerCase());
- if(crime == null) { // couldn't find crime
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid crime passed into commitCrime(): " + crimeRoughName);
- }
- if(workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null) {
- workerScript.scriptRef.log("Attempting to commit crime: "+crime.name+"...");
- }
- return crime.commit(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"], 1, {workerscript: workerScript});
- },
- getCrimeChance : function(crimeRoughName) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getCrimeChance", ramCost);
- }
- updateDynamicRam("getCrimeChance", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getCrimeChance(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return;
- }
- }
-
- const crime = Object(_Crime_CrimeHelpers__WEBPACK_IMPORTED_MODULE_6__[/* findCrime */ "b"])(crimeRoughName.toLowerCase());
- if(crime == null) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Invalid crime passed into getCrimeChance(): " + crime);
- }
-
- return crime.successRate();
- },
- getOwnedAugmentations : function(purchased=false) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getOwnedAugmentations", ramCost);
- }
- updateDynamicRam("getOwnedAugmentations", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(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 < _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].augmentations.length; ++i) {
- res.push(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].augmentations[i].name);
- }
- if (purchased) {
- for (var i = 0; i < _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].queuedAugmentations.length; ++i) {
- res.push(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].queuedAugmentations[i].name);
- }
- }
- return res;
- },
- getOwnedSourceFiles : function() {
- let ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getOwnedSourceFiles", ramCost);
- }
- updateDynamicRam("getOwnedSourceFiles", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getOwnedSourceFiles(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return [];
- }
- }
- let res = [];
- for (let i = 0; i < _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].sourceFiles.length; ++i) {
- res.push({n: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].sourceFiles[i].n, lvl: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].sourceFiles[i].lvl});
- }
- return res;
- },
- getAugmentationsFromFaction : function(facname) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getAugmentationsFromFaction", ramCost);
- }
- updateDynamicRam("getAugmentationsFromFaction", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getAugmentationsFromFaction(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return [];
- }
- }
-
- if (!Object(_Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["factionExists"])(facname)) {
- workerScript.scriptRef.log("ERROR: getAugmentationsFromFaction() failed. Invalid faction name passed in (this is case-sensitive): " + facname);
- return [];
- }
-
- var fac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["Factions"][facname];
- var res = [];
- for (var i = 0; i < fac.augmentations.length; ++i) {
- res.push(fac.augmentations[i]);
- }
- return res;
- },
- getAugmentationPrereq : function(name) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getAugmentationPrereq", ramCost);
- }
- updateDynamicRam("getAugmentationPrereq", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getAugmentationPrereq(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return false;
- }
- }
-
- if (!Object(_Augmentation_AugmentationHelpers__WEBPACK_IMPORTED_MODULE_3__[/* augmentationExists */ "b"])(name)) {
- workerScript.scriptRef.log("ERROR: getAugmentationPrereq() failed. Invalid Augmentation name passed in (note: this is case-sensitive): " + name);
- return [];
- }
-
- var aug = _Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_2__["Augmentations"][name];
- return aug.prereqs.slice();
- },
- getAugmentationCost : function(name) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("getAugmentationCost", ramCost);
- }
- updateDynamicRam("getAugmentationCost", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run getAugmentationCost(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return false;
- }
- }
-
- if (!Object(_Augmentation_AugmentationHelpers__WEBPACK_IMPORTED_MODULE_3__[/* augmentationExists */ "b"])(name)) {
- workerScript.scriptRef.log("ERROR: getAugmentationCost() failed. Invalid Augmentation name passed in (note: this is case-sensitive): " + name);
- return [-1, -1];
- }
-
- var aug = _Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_2__["Augmentations"][name];
- return [aug.baseRepRequirement, aug.baseCost];
- },
- purchaseAugmentation : function(faction, name) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("purchaseAugmentation", ramCost);
- }
- updateDynamicRam("purchaseAugmentation", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run purchaseAugmentation(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return false;
- }
- }
-
- var fac = _Faction_Factions__WEBPACK_IMPORTED_MODULE_17__["Factions"][faction];
- if (fac == null || !(fac instanceof _Faction_Faction__WEBPACK_IMPORTED_MODULE_16__["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 = _Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_2__["Augmentations"][name];
- if (aug == null || !(aug instanceof _Augmentation_Augmentation__WEBPACK_IMPORTED_MODULE_1__["Augmentation"])) {
- workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because of invalid augmentation name: " + name);
- return false;
- }
-
- var isNeuroflux = false;
- if (aug.name === _Augmentation_data_AugmentationNames__WEBPACK_IMPORTED_MODULE_4__["AugmentationNames"].NeuroFluxGovernor) {
- isNeuroflux = true;
- }
-
- if (!isNeuroflux) {
- for (var j = 0; j < _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].queuedAugmentations.length; ++j) {
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].queuedAugmentations[j].name === aug.name) {
- workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name);
- return false;
- }
- }
- for (var j = 0; j < _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].augmentations.length; ++j) {
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].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(_Faction_FactionHelpers__WEBPACK_IMPORTED_MODULE_18__[/* purchaseAugmentation */ "e"])(aug, fac, true);
- workerScript.scriptRef.log(res);
- if (Object(_utils_helpers_isString__WEBPACK_IMPORTED_MODULE_46__["isString"])(res) && res.startsWith("You purchased")) {
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gainIntelligenceExp(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
- return true;
- } else {
- return false;
- }
- },
- installAugmentations : function(cbScript) {
- var ramCost = _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFn3RamCost;
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN !== 4) {ramCost *= _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptSingularityFnRamMult;}
- if (workerScript.checkingRam) {
- return updateStaticRam("installAugmentations", ramCost);
- }
- updateDynamicRam("installAugmentations", ramCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN != 4) {
- if (!(hasSingularitySF && singularitySFLvl >= 3)) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Cannot run installAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
- return false;
- }
- }
-
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].queuedAugmentations.length === 0) {
- workerScript.scriptRef.log("ERROR: installAugmentations() failed because you do not have any Augmentations to be installed");
- return false;
- }
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gainIntelligenceExp(_Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
- workerScript.scriptRef.log("Installing Augmentations. This will cause this script to be killed");
- Object(_Augmentation_AugmentationHelpers__WEBPACK_IMPORTED_MODULE_3__[/* installAugmentations */ "e"])(cbScript);
- return true;
- },
-
- // Gang API
- gang : {
- getMemberNames : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getMemberNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 4);
- }
- updateDynamicRam("getMemberNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 4);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "getMemberNames");
-
- try {
- const names = [];
- for (const member of _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.members) {
- names.push(member.name);
- }
- return names;
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("getMemberNames", e));
- }
- },
- getGangInformation : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getGangInformation", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- }
- updateDynamicRam("getGangInformation", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "getGangInformation");
-
- try {
- return {
- faction: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.facName,
- isHacking: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.isHackingGang,
- moneyGainRate: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.moneyGainRate,
- power: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.getPower(),
- respect: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.respect,
- respectGainRate: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.respectGainRate,
- territory: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.getTerritory(),
- territoryClashChance: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.territoryClashChance,
- territoryWarfareEngaged: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.territoryWarfareEngaged,
- wantedLevel: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.wanted,
- wantedLevelGainRate: _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.wantedGainRate,
- }
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("getGangInformation", e));
- }
- },
- getOtherGangInformation : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getOtherGangInformation", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- }
- updateDynamicRam("getOtherGangInformation", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "getOtherGangInformation");
-
- try {
- return Object.assign(_Gang__WEBPACK_IMPORTED_MODULE_15__[/* AllGangs */ "a"]);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("getOtherGangInformation", e));
- }
- },
- getMemberInformation : function(name) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getMemberInformation", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- }
- updateDynamicRam("getMemberInformation", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "getMemberInformation");
-
- try {
- for (const member of _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.members) {
- if (member.name === name) {
- return {
- agility: member.agi,
- agilityEquipMult: member.agi_mult,
- agilityAscensionMult: member.agi_asc_mult,
- augmentations: member.augmentations.slice(),
- charisma: member.cha,
- charismaEquipMult: member.cha_mult,
- charismaAscensionMult: member.cha_asc_mult,
- defense: member.def,
- defenseEquipMult: member.def_mult,
- defenseAscensionMult: member.def_asc_mult,
- dexterity: member.dex,
- dexterityEquipMult: member.dex_mult,
- dexterityAscensionMult: member.dex_asc_mult,
- equipment: member.upgrades.slice(),
- hacking: member.hack,
- hackingEquipMult: member.hack_mult,
- hackingAscensionMult: member.hack_asc_mult,
- strength: member.str,
- strengthEquipMult: member.str_mult,
- strengthAscensionMult: member.str_asc_mult,
- task: member.task,
- }
- }
- }
-
- workerScript.log(`Invalid argument passed to gang.getMemberInformation(). No gang member could be found with name ${name}`);
- return {}; // Member could not be found
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("getMemberInformation", e));
- }
- },
- canRecruitMember : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("canRecruitMember", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 4);
- }
- updateDynamicRam("canRecruitMember", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 4);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "canRecruitMember");
-
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.canRecruitMember();
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("canRecruitMember", e));
- }
- },
- recruitMember : function(name) {
- if (workerScript.checkingRam) {
- return updateStaticRam("recruitMember", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- }
- updateDynamicRam("recruitMember", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "recruitMember");
-
- try {
- const res = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.recruitMember(name);
- if (workerScript.shouldLog("recruitMember")) {
- if (res) {
- workerScript.log(`Successfully recruited Gang Member ${name}`);
- } else {
- workerScript.log(`Failed to recruit Gang Member ${name}`);
- }
- }
-
- return res;
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("recruitMember", e));
- }
- },
- getTaskNames : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getTaskNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 4);
- }
- updateDynamicRam("getTaskNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 4);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "getTaskNames");
-
- try {
- const tasks = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.getAllTaskNames();
- tasks.unshift("Unassigned");
- return tasks;
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("getTaskNames", e));
- }
- },
- setMemberTask : function(memberName, taskName) {
- if (workerScript.checkingRam) {
- return updateStaticRam("setMemberTask", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- }
- updateDynamicRam("setMemberTask", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "setMemberTask");
-
- try {
- for (const member of _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.members) {
- if (member.name === memberName) {
- const res = member.assignToTask(taskName);
- if (workerScript.shouldLog("setMemberTask")) {
- if (res) {
- workerScript.log(`Successfully assigned Gang Member ${memberName} to ${taskName} task`);
- } else {
- workerScript.log(`Failed to assign Gang Member ${memberName} to ${taskName} task. ${memberName} is now Unassigned`);
- }
- }
-
- return res;
- }
- }
-
- workerScript.log(`Invalid argument passed to gang.setMemberTask(). No gang member could be found with name ${memberName}`);
- return false;
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("setMemberTask", e));
- }
- },
- getEquipmentNames : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getEquipmentNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 4);
- }
- updateDynamicRam("getEquipmentNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 4);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "getEquipmentNames");
-
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.getAllUpgradeNames();
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("getEquipmentNames", e));
- }
- },
- getEquipmentCost : function(equipName) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getEquipmentCost", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- }
- updateDynamicRam("getEquipmentCost", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "getEquipmentCost");
-
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.getUpgradeCost(equipName);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("getEquipmentCost", e));
- }
- },
- getEquipmentType : function(equipName) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getEquipmentType", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- }
- updateDynamicRam("getEquipmentType", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "getEquipmentType");
-
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.getUpgradeType(equipName);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("getEquipmentType", e));
- }
- },
- purchaseEquipment : function(memberName, equipName) {
- if (workerScript.checkingRam) {
- return updateStaticRam("purchaseEquipment", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost);
- }
- updateDynamicRam("purchaseEquipment", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "purchaseEquipment");
-
- try {
- for (const member of _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.members) {
- if (member.name === memberName) {
- const res = member.buyUpgrade(equipName, _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"], _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang);
- if (workerScript.shouldLog("purchaseEquipment")) {
- if (res) {
- workerScript.log(`Purchased ${equipName} for Gang member ${memberName}`);
- } else {
- workerScript.log(`Failed to purchase ${equipName} for Gang member ${memberName}`);
- }
- }
-
- return res;
- }
- }
-
- workerScript.log(`Invalid argument passed to gang.purchaseEquipment(). No gang member could be found with name ${memberName}`);
- return false;
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("purchaseEquipment", e));
- }
- },
- ascendMember : function(name) {
- if (workerScript.checkingRam) {
- return updateStaticRam("ascendMember", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost);
- }
- updateDynamicRam("ascendMember", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "ascendMember");
-
- try {
- for (const member of _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.members) {
- if (member.name === name) {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.ascendMember(member, workerScript);
- }
- }
-
- workerScript.log(`Invalid argument passed to gang.ascendMember(). No gang member could be found with name ${name}`);
- return false;
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("ascendMember", e));
- }
- },
- setTerritoryWarfare : function(engage) {
- if (workerScript.checkingRam) {
- return updateStaticRam("setTerritoryWarfare", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- }
- updateDynamicRam("setTerritoryWarfare", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost / 2);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "setTerritoryWarfare");
-
- try {
- if (engage) {
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.territoryWarfareEngaged = true;
- if (workerScript.shouldLog("setTerritoryWarfare")) {
- workerScript.log("Engaging in Gang Territory Warfare");
- }
- } else {
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.territoryWarfareEngaged = false;
- if (workerScript.shouldLog("setTerritoryWarfare")) {
- workerScript.log("Disengaging in Gang Territory Warfare");
- }
- }
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("setTerritoryWarfare", e));
- }
- },
- getChanceToWinClash : function(otherGang) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getChanceToWinClash", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost);
- }
- updateDynamicRam("getChanceToWinClash", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptGangApiBaseRamCost);
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "getChanceToWinClash");
-
- try {
- if (_Gang__WEBPACK_IMPORTED_MODULE_15__[/* AllGangs */ "a"][otherGang] == null) {
- workerScript.log(`Invalid gang specified in gang.getChanceToWinClash() : ${otherGang}`);
- return 0;
- }
-
- const playerPower = _Gang__WEBPACK_IMPORTED_MODULE_15__[/* AllGangs */ "a"][_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.facName].power;
- const otherPower = _Gang__WEBPACK_IMPORTED_MODULE_15__[/* AllGangs */ "a"][otherGang].power;
-
- return playerPower / (otherPower + playerPower);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("getChanceToWinClash", e));
- }
- },
- getBonusTime : function() {
- if (workerScript.checkingRam) { return 0; }
- _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* checkGangApiAccess */ "a"](workerScript, "getBonusTime");
-
- try {
- return Math.round(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gang.storedCycles / 5);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, _NetscriptGang__WEBPACK_IMPORTED_MODULE_35__[/* unknownGangApiExceptionMessage */ "b"]("getBonusTime", e));
- }
- },
- }, // end gang namespace
-
- // Bladeburner API
- bladeburner : {
- getContractNames : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getContractNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost / 10);
- }
- updateDynamicRam("getContractNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost / 10);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getContractNamesNetscriptFn();
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getContractNames() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getOperationNames : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getOperationNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost / 10);
- }
- updateDynamicRam("getOperationNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost / 10);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getOperationNamesNetscriptFn();
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getOperationNames() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getBlackOpNames : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getBlackOpNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost / 10);
- }
- updateDynamicRam("getBlackOpNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost / 10);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getBlackOpNamesNetscriptFn();
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getBlackOpNames() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getGeneralActionNames : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getGeneralActionNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost / 10);
- }
- updateDynamicRam("getGeneralActionNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost / 10);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getGeneralActionNamesNetscriptFn();
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getGeneralActionNames() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getSkillNames : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getSkillNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost / 10);
- }
- updateDynamicRam("getSkillNames", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost / 10);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getSkillNamesNetscriptFn();
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getSkillNames() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- startAction : function(type="", name="") {
- if (workerScript.checkingRam) {
- return updateStaticRam("startAction", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("startAction", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.startActionNetscriptFn(type, name, workerScript);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Bladeburner.startAction() failed with exception: " + e);
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "startAction() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- stopBladeburnerAction : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("stopBladeburnerAction", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost / 2);
- }
- updateDynamicRam("stopBladeburnerAction", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost / 2);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.resetAction();
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "stopBladeburnerAction() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getCurrentAction : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getCurrentAction", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost / 4);
- }
- updateDynamicRam("getCurrentAction", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost / 4);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getTypeAndNameFromActionId(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.action);
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getCurrentAction() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getActionTime : function(type="", name="") {
- if (workerScript.checkingRam) {
- return updateStaticRam("getActionTime", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getActionTime", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionTimeNetscriptFn(type, name, workerScript);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Bladeburner.getActionTime() failed with exception: " + e);
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getActionTime() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getActionEstimatedSuccessChance : function(type="", name="") {
- if (workerScript.checkingRam) {
- return updateStaticRam("getActionEstimatedSuccessChance", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getActionEstimatedSuccessChance", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionEstimatedSuccessChanceNetscriptFn(type, name, workerScript);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Bladeburner.getActionEstimatedSuccessChance() failed with exception: " + e);
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getActionEstimatedSuccessChance() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getActionRepGain: function(type="", name="", level) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getActionRepGain", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getActionRepGain", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* checkBladeburnerAccess */ "a"])(workerScript, "getActionRepGain");
-
- try {
- var errorLogText = Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* unknownBladeburnerActionErrorMessage */ "b"])("getActionAutolevel", type, name);
- const actionId = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return -1;
- }
- const actionObj = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return -1;
- }
- var rewardMultiplier;
- if (level == null || isNaN(level)) {
- rewardMultiplier = Math.pow(actionObj.rewardFac, actionObj.level - 1);
- } else {
- rewardMultiplier = Math.pow(actionObj.rewardFac, level - 1);
- }
-
- return actionObj.rankGain * rewardMultiplier * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_5__["BitNodeMultipliers"].BladeburnerRank;
- } catch(err) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* unknownBladeburnerExceptionMessage */ "c"])("getActionAutolevel", err));
- }
- },
- getActionCountRemaining : function(type="", name="") {
- if (workerScript.checkingRam) {
- return updateStaticRam("getActionCountRemaining", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getActionCountRemaining", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionCountRemainingNetscriptFn(type, name, workerScript);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Bladeburner.getActionCountRemaining() failed with exception: " + e);
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getActionCountRemaining() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getActionMaxLevel: function(type="", name="") {
- if (workerScript.checkingRam) {
- return updateStaticRam("getActionMaxLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getActionMaxLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* checkBladeburnerAccess */ "a"])(workerScript, "getActionMaxLevel");
-
- try {
- var errorLogText = Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* unknownBladeburnerActionErrorMessage */ "b"])("getActionMaxLevel", type, name);
- const actionId = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return -1;
- }
- const actionObj = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return -1;
- }
- return actionObj.maxLevel;
- } catch(err) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* unknownBladeburnerExceptionMessage */ "c"])("getActionMaxLevel", err));
- }
- },
- getActionCurrentLevel: function(type="", name="") {
- if (workerScript.checkingRam) {
- return updateStaticRam("getActionCurrentLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getActionCurrentLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* checkBladeburnerAccess */ "a"])(workerScript, "getActionCurrentLevel");
-
- try {
- var errorLogText = Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* unknownBladeburnerActionErrorMessage */ "b"])("getActionCurrentLevel", type, name);
- const actionId = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return -1;
- }
- const actionObj = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return -1;
- }
- return actionObj.level;
- } catch(err) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* unknownBladeburnerExceptionMessage */ "c"])("getActionCurrentLevel", err));
- }
- },
- getActionAutolevel: function(type="", name="") {
- if (workerScript.checkingRam) {
- return updateStaticRam("getActionAutolevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getActionAutolevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* checkBladeburnerAccess */ "a"])(workerScript, "getActionAutolevel");
-
- try {
- var errorLogText = Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* unknownBladeburnerActionErrorMessage */ "b"])("getActionAutolevel", type, name);
- const actionId = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return false;
- }
- const actionObj = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return false;
- }
- return actionObj.autoLevel;
- } catch(err) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* unknownBladeburnerExceptionMessage */ "c"])("getActionAutolevel", err));
- }
- },
- setActionAutolevel: function(type="", name="", autoLevel=true) {
- if (workerScript.checkingRam) {
- return updateStaticRam("setActionAutolevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("setActionAutolevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* checkBladeburnerAccess */ "a"])(workerScript, "setActionAutolevel");
-
- try {
- var errorLogText = Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* unknownBladeburnerActionErrorMessage */ "b"])("setActionAutolevel", type, name);
- const actionId = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return;
- }
- const actionObj = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return;
- }
- actionObj.autoLevel = autoLevel;
- } catch(err) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* unknownBladeburnerExceptionMessage */ "c"])("setActionAutolevel", err));
- }
- },
- setActionLevel: function(type="", name="", level=1) {
- if (workerScript.checkingRam) {
- return updateStaticRam("setActionLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("setActionLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* checkBladeburnerAccess */ "a"])(workerScript, "setActionLevel");
-
- try {
- var errorLogText = Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* unknownBladeburnerActionErrorMessage */ "b"])("setActionLevel", type, name);
- const actionId = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionIdFromTypeAndName(type, name);
- if (actionId == null) {
- workerScript.log(errorLogText);
- return;
- }
- const actionObj = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getActionObject(actionId);
- if (actionObj == null) {
- workerScript.log(errorLogText);
- return;
- }
- if(level > actionObj.maxLevel) {
- workerScript.log(`ERROR: bladeburner.${setActionLevel}() failed because level exceeds max level for given action.`);
- return;
- }
- if(level < 1) {
- workerScript.log(`ERROR: bladeburner.${setActionLevel}() failed because level is below 1.`);
- return;
- }
- actionObj.level = level;
- } catch(err) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, Object(_NetscriptBladeburner__WEBPACK_IMPORTED_MODULE_34__[/* unknownBladeburnerExceptionMessage */ "c"])("setActionLevel", err));
- }
- },
- getRank : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getRank", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getRank", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.rank;
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getRank() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getSkillPoints : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getSkillPoints", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getSkillPoints", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.skillPoints;
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getSkillPoints() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getSkillLevel : function(skillName="") {
- if (workerScript.checkingRam) {
- return updateStaticRam("getSkillLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getSkillLevel", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getSkillLevelNetscriptFn(skillName, workerScript);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Bladeburner.getSkillLevel() failed with exception: " + e);
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getSkillLevel() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getSkillUpgradeCost : function(skillName="") {
- if (workerScript.checkingRam) {
- return updateStaticRam("getSkillUpgradeCost", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getSkillUpgradeCost", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getSkillUpgradeCostNetscriptFn(skillName, workerScript);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Bladeburner.getSkillUpgradeCost() failed with exception: " + e);
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getSkillUpgradeCost() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- upgradeSkill : function(skillName) {
- if (workerScript.checkingRam) {
- return updateStaticRam("upgradeSkill", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("upgradeSkill", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.upgradeSkillNetscriptFn(skillName, workerScript);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Bladeburner.upgradeSkill() failed with exception: " + e);
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "upgradeSkill() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getTeamSize : function(type="", name="") {
- if (workerScript.checkingRam) {
- return updateStaticRam("getTeamSize", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getTeamSize", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getTeamSizeNetscriptFn(type, name, workerScript);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Bladeburner.getTeamSize() failed with exception: " + e);
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getTeamSize() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- setTeamSize : function(type="", name="", size) {
- if (workerScript.checkingRam) {
- return updateStaticRam("setTeamSize", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("setTeamSize", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.setTeamSizeNetscriptFn(type, name, size, workerScript);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Bladeburner.setTeamSize() failed with exception: " + e);
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "setTeamSize() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getCityEstimatedPopulation : function(cityName) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getCityEstimatedPopulation", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getCityEstimatedPopulation", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getCityEstimatedPopulationNetscriptFn(cityName, workerScript);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Bladeburner.getCityEstimatedPopulation() failed with exception: " + e);
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getCityEstimatedPopulation() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getCityEstimatedCommunities : function(cityName) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getCityEstimatedCommunities", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getCityEstimatedCommunities", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getCityEstimatedCommunitiesNetscriptFn(cityName, workerScript);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Bladeburner.getCityEstimatedCommunities() failed with exception: " + e);
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getCityEstimatedCommunities() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getCityChaos : function(cityName) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getCityChaos", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getCityChaos", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.getCityChaosNetscriptFn(cityName, workerScript);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Bladeburner.getCityChaos() failed with exception: " + e);
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getCityChaos() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getCity : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getCity", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getCity", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.city;
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Bladeburner.getCity() failed with exception: " + e);
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getCity() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- switchCity : function(cityName) {
- if (workerScript.checkingRam) {
- return updateStaticRam("switchCity", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("switchCity", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- try {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.switchCityNetscriptFn(cityName, workerScript);
- } catch(e) {
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "Bladeburner.switchCity() failed with exception: " + e);
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "switchCity() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getStamina : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("getStamina", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("getStamina", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- return [_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.stamina, _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.maxStamina];
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getStamina() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- joinBladeburnerFaction : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("joinBladeburnerFaction", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("joinBladeburnerFaction", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"] && (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- return _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.joinBladeburnerFactionNetscriptFn(workerScript);
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "joinBladeburnerFaction() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- joinBladeburnerDivision : function() {
- if (workerScript.checkingRam) {
- return updateStaticRam("joinBladeburnerDivision", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- }
- updateDynamicRam("joinBladeburnerDivision", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptBladeburnerApiBaseRamCost);
- if ((_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner instanceof _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"]) {
- return true; //Already member
- } else if (_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].strength >= 100 && _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].defense >= 100 &&
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].dexterity >= 100 && _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].agility >= 100) {
- _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner = new _Bladeburner__WEBPACK_IMPORTED_MODULE_7__[/* Bladeburner */ "a"]({new:true});
- workerScript.log("You have been accepted into the Bladeburner division");
- return true;
- } else {
- workerScript.log("You do not meet the requirements for joining the Bladeburner division");
- return false;
- }
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "joinBladeburnerDivision() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- },
- getBonusTime : function() {
- if (workerScript.checkingRam) {return 0;}
- if ((_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bitNodeN === 7 || hasBladeburner2079SF)) {
- return Math.round(_Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].bladeburner.storedCycles / 5);
- }
- throw Object(_NetscriptEvaluator__WEBPACK_IMPORTED_MODULE_37__[/* makeRuntimeRejectMsg */ "d"])(workerScript, "getBonusTime() failed because you do not currently have access to the Bladeburner API. This is either because you are not currently employed " +
- "at the Bladeburner division or because you do not have Source-File 7");
- }
- }, // End Bladeburner
- codingcontract : {
- attempt : function(answer, fn, ip=workerScript.serverIp) {
- if (workerScript.checkingRam) {
- return updateStaticRam("attempt", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptCodingContractBaseRamCost);
- }
- updateDynamicRam("attempt", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptCodingContractBaseRamCost);
- const contract = getCodingContract(fn, ip);
- if (contract == null) {
- workerScript.log(`ERROR: codingcontract.getData() failed because it could find the specified contract ${fn} on server ${ip}`);
- return false;
- }
- answer = String(answer);
- const serv = safeGetServer(ip, "codingcontract.attempt()");
- if (contract.isSolution(answer)) {
- const reward = _Player__WEBPACK_IMPORTED_MODULE_23__[/* Player */ "a"].gainCodingContractReward(contract.reward, contract.getDifficulty());
- workerScript.log(`Successfully completed Coding Contract ${fn}. Reward: ${reward}`);
- serv.removeContract(fn);
- return true;
- } else {
- ++contract.tries;
- if (contract.tries >= contract.getMaxNumTries()) {
- workerScript.log(`Coding Contract ${fn} failed. Contract is now self-destructing`);
- serv.removeContract(fn);
- } else {
- workerScript.log(`Coding Contract ${fn} failed. ${contract.getMaxNumTries() - contract.tries} attempts remaining`);
- }
- return false;
- }
- },
- getContractType : function(fn, ip=workerScript.serverIp) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getContractType", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptCodingContractBaseRamCost / 2);
- }
- updateDynamicRam("getContractType", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptCodingContractBaseRamCost / 2);
- let contract = getCodingContract(fn, ip);
- if (contract == null) {
- workerScript.log(`ERROR: codingcontract.getData() failed because it could find the specified contract ${fn} on server ${ip}`);
- return null;
- }
- return contract.getType();
- },
- getData : function(fn, ip=workerScript.serverIp) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getData", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptCodingContractBaseRamCost / 2);
- }
- updateDynamicRam("getData", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptCodingContractBaseRamCost / 2);
- let contract = getCodingContract(fn, ip);
- if (contract == null) {
- workerScript.log(`ERROR: codingcontract.getData() failed because it could find the specified contract ${fn} on server ${ip}`);
- return null;
- }
- let data = contract.getData();
- if (data.constructor === Array) {
- // Pass a copy
- return data.slice();
- } else {
- return data;
- }
- },
- getDescription : function(fn, ip=workerScript.serverIp) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getDescription", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptCodingContractBaseRamCost / 2);
- }
- updateDynamicRam("getDescription", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptCodingContractBaseRamCost / 2);
- var contract = getCodingContract(fn, ip);
- if (contract == null) {
- workerScript.log(`ERROR: codingcontract.getDescription() failed because it could find the specified contract ${fn} on server ${ip}`);
- return "";
- }
- return contract.getDescription();
- },
- getNumTriesRemaining : function(fn, ip=workerScript.serverIp) {
- if (workerScript.checkingRam) {
- return updateStaticRam("getNumTriesRemaining", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptCodingContractBaseRamCost / 2);
- }
- updateDynamicRam("getNumTriesRemaining", _Constants__WEBPACK_IMPORTED_MODULE_12__["CONSTANTS"].ScriptCodingContractBaseRamCost / 2);
- var contract = getCodingContract(fn, ip);
- if (contract == null) {
- workerScript.log(`ERROR: codingcontract.getNumTriesRemaining() failed because it could find the specified contract ${fn} on server ${ip}`);
- return -1;
- }
- return contract.getMaxNumTries() - contract.tries;
- },
- }
- } //End return
-} //End NetscriptFunction()
-
-
-
-/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 72)))
-
-/***/ }),
-/* 48 */
-/*!********************************!*\
- !*** ./src/CodingContracts.ts ***!
- \********************************/
-/*! no static exports found */
-/*! exports used: CodingContract, CodingContractResult, CodingContractRewardType, CodingContractTypes */
-/***/ (function(module, exports, __webpack_require__) {
-
-"use strict";
-
-var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
- return new (P || (P = Promise))(function (resolve, reject) {
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
- function step(result) { result.done ? resolve(result.value) : new P(function (resolve) { resolve(result.value); }).then(fulfilled, rejected); }
- step((generator = generator.apply(thisArg, _arguments || [])).next());
- });
-};
-Object.defineProperty(exports, "__esModule", { value: true });
-const JSONReviver_1 = __webpack_require__(/*! ../utils/JSONReviver */ 15);
-const createElement_1 = __webpack_require__(/*! ../utils/uiHelpers/createElement */ 2);
-const createPopup_1 = __webpack_require__(/*! ../utils/uiHelpers/createPopup */ 40);
-const removeElementById_1 = __webpack_require__(/*! ../utils/uiHelpers/removeElementById */ 23);
-const codingcontracttypes_1 = __webpack_require__(/*! ./data/codingcontracttypes */ 250);
-/* tslint:disable:no-magic-numbers completed-docs max-classes-per-file no-console */
-/* Represents different types of problems that a Coding Contract can have */
-class CodingContractType {
- constructor(name, desc, gen, solver, diff, numTries) {
- this.name = name;
- this.desc = desc;
- this.generate = gen;
- this.solver = solver;
- this.difficulty = diff;
- this.numTries = numTries;
- }
-}
-exports.CodingContractType = CodingContractType;
-/* Contract Types */
-// tslint:disable-next-line
-exports.CodingContractTypes = {};
-for (const md of codingcontracttypes_1.codingContractTypesMetadata) {
- // tslint:disable-next-line
- exports.CodingContractTypes[md.name] = new CodingContractType(md.name, md.desc, md.gen, md.solver, md.difficulty, md.numTries);
-}
-console.info(`${Object.keys(exports.CodingContractTypes).length} Coding Contract Types loaded`);
-/**
- * Enum representing the different types of rewards a Coding Contract can give
- */
-var CodingContractRewardType;
-(function (CodingContractRewardType) {
- CodingContractRewardType[CodingContractRewardType["FactionReputation"] = 0] = "FactionReputation";
- CodingContractRewardType[CodingContractRewardType["FactionReputationAll"] = 1] = "FactionReputationAll";
- CodingContractRewardType[CodingContractRewardType["CompanyReputation"] = 2] = "CompanyReputation";
- CodingContractRewardType[CodingContractRewardType["Money"] = 3] = "Money";
-})(CodingContractRewardType = exports.CodingContractRewardType || (exports.CodingContractRewardType = {}));
-/**
- * Enum representing the result when trying to solve the Contract
- */
-var CodingContractResult;
-(function (CodingContractResult) {
- CodingContractResult[CodingContractResult["Success"] = 0] = "Success";
- CodingContractResult[CodingContractResult["Failure"] = 1] = "Failure";
- CodingContractResult[CodingContractResult["Cancelled"] = 2] = "Cancelled";
-})(CodingContractResult = exports.CodingContractResult || (exports.CodingContractResult = {}));
-/**
- * A Coding Contract is a file that poses a programming-related problem to the Player.
- * The player receives a reward if the problem is solved correctly
- */
-class CodingContract {
- constructor(fn = "", type = "Find Largest Prime Factor", reward = null) {
- /* Number of times the Contract has been attempted */
- this.tries = 0;
- this.fn = fn;
- if (!this.fn.endsWith(".cct")) {
- this.fn += ".cct";
- }
- // tslint:disable-next-line
- if (exports.CodingContractTypes[type] == null) {
- throw new Error(`Error: invalid contract type: ${type} please contact developer`);
- }
- this.type = type;
- this.data = exports.CodingContractTypes[type].generate();
- this.reward = reward;
- }
- /**
- * Initiatizes a CodingContract from a JSON save state.
- */
- static fromJSON(value) {
- return JSONReviver_1.Generic_fromJSON(CodingContract, value.data);
- }
- getData() {
- return this.data;
- }
- getDescription() {
- return exports.CodingContractTypes[this.type].desc(this.data);
- }
- getDifficulty() {
- return exports.CodingContractTypes[this.type].difficulty;
- }
- getMaxNumTries() {
- return exports.CodingContractTypes[this.type].numTries;
- }
- getType() {
- return exports.CodingContractTypes[this.type].name;
- }
- isSolution(solution) {
- return exports.CodingContractTypes[this.type].solver(this.data, solution);
- }
- /**
- * Creates a popup to prompt the player to solve the problem
- */
- prompt() {
- return __awaiter(this, void 0, void 0, function* () {
- // tslint:disable-next-line
- return new Promise((resolve, reject) => {
- const contractType = exports.CodingContractTypes[this.type];
- const popupId = `coding-contract-prompt-popup-${this.fn}`;
- const txt = createElement_1.createElement("p", {
- innerText: ["You are attempting to solve a Coding Contract. You have",
- `${this.getMaxNumTries() - this.tries} tries remaining,`,
- "after which the contract will self-destruct.\n\n",
- `${contractType.desc(this.data)}`].join(" "),
- });
- let answerInput;
- let solveBtn;
- answerInput = createElement_1.createElement("input", {
- onkeydown: (e) => {
- if (e.keyCode === 13 && answerInput.value !== "") {
- e.preventDefault();
- solveBtn.click();
- }
- },
- placeholder: "Enter Solution here",
- });
- solveBtn = createElement_1.createElement("a", {
- class: "a-link-button",
- clickListener: () => {
- const answer = answerInput.value;
- if (this.isSolution(answer)) {
- resolve(CodingContractResult.Success);
- }
- else {
- resolve(CodingContractResult.Failure);
- }
- removeElementById_1.removeElementById(popupId);
- },
- innerText: "Solve",
- });
- const cancelBtn = createElement_1.createElement("a", {
- class: "a-link-button",
- clickListener: () => {
- resolve(CodingContractResult.Cancelled);
- removeElementById_1.removeElementById(popupId);
- },
- innerText: "Cancel",
- });
- const lineBreak = createElement_1.createElement("br");
- createPopup_1.createPopup(popupId, [txt, lineBreak, lineBreak, answerInput, solveBtn, cancelBtn]);
- answerInput.focus();
- });
- });
- }
- /**
- * Serialize the current file to a JSON save state.
- */
- toJSON() {
- return JSONReviver_1.Generic_toJSON("CodingContract", this);
- }
-}
-exports.CodingContract = CodingContract;
-JSONReviver_1.Reviver.constructors.CodingContract = CodingContract;
-
-
-/***/ }),
-/* 49 */
-/*!**********************!*\
- !*** ./src/Alias.js ***!
- \**********************/
-/*! exports provided: Aliases, GlobalAliases, printAliases, parseAliasDeclaration, removeAlias, substituteAliases, loadAliases, loadGlobalAliases */
-/*! exports used: Aliases, GlobalAliases, loadAliases, loadGlobalAliases, parseAliasDeclaration, printAliases, removeAlias, substituteAliases */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return Aliases; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return GlobalAliases; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "f", function() { return printAliases; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return parseAliasDeclaration; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "g", function() { return removeAlias; });
-/* 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 _ui_postToTerminal__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ui/postToTerminal */ 8);
-/* harmony import */ var _ui_postToTerminal__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_ui_postToTerminal__WEBPACK_IMPORTED_MODULE_0__);
-
-
-let Aliases = {};
-let GlobalAliases = {};
-
-function loadAliases(saveString) {
- if (saveString === "") {
- Aliases = {};
- } else {
- Aliases = JSON.parse(saveString);
- }
-}
-
-function loadGlobalAliases(saveString) {
- if (saveString === "") {
- GlobalAliases = {};
- } else {
- GlobalAliases = JSON.parse(saveString);
- }
-}
-
-//Print all aliases to terminal
-function printAliases() {
- for (var name in Aliases) {
- if (Aliases.hasOwnProperty(name)) {
- Object(_ui_postToTerminal__WEBPACK_IMPORTED_MODULE_0__["post"])("alias " + name + "=" + Aliases[name]);
- }
- }
- for (var name in GlobalAliases) {
- if (GlobalAliases.hasOwnProperty(name)) {
- Object(_ui_postToTerminal__WEBPACK_IMPORTED_MODULE_0__["post"])("global alias " + name + "=" + GlobalAliases[name]);
- }
- }
-}
-
-//True if successful, false otherwise
-function parseAliasDeclaration(dec,global=false) {
- var re = /^([_|\w|!|%|,|@]+)="(.+)"$/;
- var matches = dec.match(re);
- if (matches == null || matches.length != 3) {return false;}
- if (global){
- addGlobalAlias(matches[1],matches[2]);
- } else {
- addAlias(matches[1], matches[2]);
- }
- return true;
-}
-
-function addAlias(name, value) {
- if (name in GlobalAliases){
- delete GlobalAliases[name];
- }
- Aliases[name] = value;
-}
-
-function addGlobalAlias(name, value) {
- if (name in Aliases){
- delete Aliases[name];
- }
- GlobalAliases[name] = value;
-}
-
-function getAlias(name) {
- if (Aliases.hasOwnProperty(name)) {
- return Aliases[name];
- }
- return null;
-}
-
-function getGlobalAlias(name) {
- if (GlobalAliases.hasOwnProperty(name)) {
- return GlobalAliases[name];
- }
- return null;
-}
-
-function removeAlias(name) {
- if (Aliases.hasOwnProperty(name)) {
- delete Aliases[name];
- return true;
- }
- if (GlobalAliases.hasOwnProperty(name)) {
- delete GlobalAliases[name];
- return true;
- }
- return false;
-}
-
-//Returns the original string with any aliases substituted in
-//Aliases only applied to "whole words", one level deep
-function substituteAliases(origCommand) {
- var commandArray = origCommand.split(" ");
- if (commandArray.length>0){
- var alias = getAlias(commandArray[0]);
- if (alias != null) {
- commandArray[0] = alias;
- } else {
- var alias = getGlobalAlias(commandArray[0]);
- if (alias != null) {
- commandArray[0] = alias;
- }
- }
- for (var i = 0; i < commandArray.length; ++i) {
- var alias = getGlobalAlias(commandArray[i]);
- if (alias != null) {
- commandArray[i] = alias;
- }
- }
- }
- return commandArray.join(" ");
-}
-
-
-
-
-/***/ }),
-/* 50 */,
-/* 51 */
-/*!***************************************!*\
- !*** ./src/Faction/FactionHelpers.js ***!
- \***************************************/
-/*! exports provided: getNextNeurofluxLevel, inviteToFaction, joinFaction, displayFactionContent, processPassiveFactionRepGain, purchaseAugmentation */
-/*! exports used: displayFactionContent, inviteToFaction, joinFaction, processPassiveFactionRepGain, purchaseAugmentation */
-/***/ (function(module, __webpack_exports__, __webpack_require__) {
-
-"use strict";
-/* unused harmony export getNextNeurofluxLevel */
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "b", function() { return inviteToFaction; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "c", function() { return joinFaction; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "a", function() { return displayFactionContent; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "d", function() { return processPassiveFactionRepGain; });
-/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "e", function() { return purchaseAugmentation; });
-/* harmony import */ var _Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../Augmentation/Augmentations */ 14);
-/* harmony import */ var _Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_0__);
-/* harmony import */ var _Augmentation_PlayerOwnedAugmentation__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ../Augmentation/PlayerOwnedAugmentation */ 89);
-/* harmony import */ var _Augmentation_PlayerOwnedAugmentation__WEBPACK_IMPORTED_MODULE_1___default = /*#__PURE__*/__webpack_require__.n(_Augmentation_PlayerOwnedAugmentation__WEBPACK_IMPORTED_MODULE_1__);
-/* harmony import */ var _Augmentation_data_AugmentationNames__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../Augmentation/data/AugmentationNames */ 6);
-/* harmony import */ var _Augmentation_data_AugmentationNames__WEBPACK_IMPORTED_MODULE_2___default = /*#__PURE__*/__webpack_require__.n(_Augmentation_data_AugmentationNames__WEBPACK_IMPORTED_MODULE_2__);
-/* harmony import */ var _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../BitNode/BitNodeMultipliers */ 10);
-/* harmony import */ var _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_3___default = /*#__PURE__*/__webpack_require__.n(_BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_3__);
-/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../Constants */ 1);
-/* harmony import */ var _Constants__WEBPACK_IMPORTED_MODULE_4___default = /*#__PURE__*/__webpack_require__.n(_Constants__WEBPACK_IMPORTED_MODULE_4__);
-/* harmony import */ var _engine__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../engine */ 11);
-/* harmony import */ var _Faction__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Faction */ 62);
-/* harmony import */ var _Faction__WEBPACK_IMPORTED_MODULE_6___default = /*#__PURE__*/__webpack_require__.n(_Faction__WEBPACK_IMPORTED_MODULE_6__);
-/* harmony import */ var _Factions__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Factions */ 16);
-/* harmony import */ var _Factions__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_Factions__WEBPACK_IMPORTED_MODULE_7__);
-/* harmony import */ var _FactionInfo__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./FactionInfo */ 133);
-/* harmony import */ var _FactionInfo__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_FactionInfo__WEBPACK_IMPORTED_MODULE_8__);
-/* harmony import */ var _Location__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../Location */ 106);
-/* harmony import */ var _Missions__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../Missions */ 64);
-/* harmony import */ var _Player__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../Player */ 0);
-/* harmony import */ var _Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../Settings/SettingEnums */ 45);
-/* harmony import */ var _Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12__);
-/* harmony import */ var _Settings_Settings__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../Settings/Settings */ 19);
-/* harmony import */ var _Settings_Settings__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(_Settings_Settings__WEBPACK_IMPORTED_MODULE_13__);
-/* harmony import */ var _ui_navigationTracking__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../ui/navigationTracking */ 13);
-/* harmony import */ var _ui_navigationTracking__WEBPACK_IMPORTED_MODULE_14___default = /*#__PURE__*/__webpack_require__.n(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_14__);
-/* harmony import */ var _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../ui/numeralFormat */ 4);
-/* harmony import */ var _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_15___default = /*#__PURE__*/__webpack_require__.n(_ui_numeralFormat__WEBPACK_IMPORTED_MODULE_15__);
-/* harmony import */ var _utils_DialogBox__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../../utils/DialogBox */ 9);
-/* harmony import */ var _utils_FactionInvitationBox__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ../../utils/FactionInvitationBox */ 160);
-/* harmony import */ var _utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ../../utils/uiHelpers/removeChildrenFromElement */ 27);
-/* harmony import */ var _utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_18___default = /*#__PURE__*/__webpack_require__.n(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_18__);
-/* harmony import */ var _utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../../utils/uiHelpers/createElement */ 2);
-/* harmony import */ var _utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19___default = /*#__PURE__*/__webpack_require__.n(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__);
-/* harmony import */ var _utils_JSONReviver__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../../utils/JSONReviver */ 15);
-/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../../utils/StringHelperFunctions */ 3);
-/* harmony import */ var _utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_21___default = /*#__PURE__*/__webpack_require__.n(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_21__);
-/* harmony import */ var _utils_YesNoBox__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../../utils/YesNoBox */ 22);
-/* harmony import */ var _utils_YesNoBox__WEBPACK_IMPORTED_MODULE_22___default = /*#__PURE__*/__webpack_require__.n(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_22__);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-function inviteToFaction(faction) {
- if (_Settings_Settings__WEBPACK_IMPORTED_MODULE_13__["Settings"].SuppressFactionInvites) {
- faction.alreadyInvited = true;
- _Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].factionInvitations.push(faction.name);
- if (_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_14__["routing"].isOn(_ui_navigationTracking__WEBPACK_IMPORTED_MODULE_14__["Page"].Factions)) {
- _engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].loadFactionsContent();
- }
- } else {
- Object(_utils_FactionInvitationBox__WEBPACK_IMPORTED_MODULE_17__[/* factionInvitationBoxCreate */ "a"])(faction);
- }
-}
-
-function joinFaction(faction) {
- faction.isMember = true;
- _Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].factions.push(faction.name);
- const factionInfo = faction.getInfo();
-
- //Determine what factions you are banned from now that you have joined this faction
- for(const i in factionInfo.enemies) {
- const enemy = factionInfo.enemies[i];
- if (_Factions__WEBPACK_IMPORTED_MODULE_7__["Factions"][enemy] instanceof _Faction__WEBPACK_IMPORTED_MODULE_6__["Faction"]) {
- _Factions__WEBPACK_IMPORTED_MODULE_7__["Factions"][enemy].isBanned = true;
- }
- }
-}
-
-//Displays the HTML content for a specific faction
-function displayFactionContent(factionName) {
- var faction = _Factions__WEBPACK_IMPORTED_MODULE_7__["Factions"][factionName];
- if (faction == null) {
- throw new Error("Invalid factionName passed into displayFactionContent: " + factionName);
- }
- var factionInfo = faction.getInfo();
-
- Object(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_18__["removeChildrenFromElement"])(_engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].Display.factionContent);
- var elements = [];
-
- //Header and faction info
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("h1", {
- innerText:factionName
- }));
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("pre", {
- innerHTML:"" + factionInfo.infoText + ""
- }));
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("p", {
- innerText:"---------------",
- }));
-
- //Faction reputation and favor
- var favorGain = faction.getFavorGain();
- if (favorGain.length != 2) {favorGain = 0;}
- favorGain = favorGain[0];
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("p", {
- innerText: "Reputation: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(faction.playerReputation, 4),
- tooltip:"You will earn " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(favorGain, 0) +
- " faction favor upon resetting after installing an Augmentation"
- }))
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("p", {
- innerText:"---------------",
- }));
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("p", {
- innerText:"Faction Favor: " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(faction.favor, 0),
- tooltip:"Faction favor increases the rate at which " +
- "you earn reputation for this faction by 1% per favor. Faction favor " +
- "is gained whenever you reset after installing an Augmentation. The amount of " +
- "favor you gain depends on how much reputation you have with the faction"
- }));
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("p", {
- innerText:"---------------",
- }));
-
- //Faction Work Description Text
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("pre", {
- id:"faction-work-description-text",
- innerText:"Perform work/carry out assignments for your faction to help further its cause! By doing so " +
- "you will earn reputation for your faction. You will also gain reputation passively over time, " +
- "although at a very slow rate. Earning reputation will allow you to purchase Augmentations " +
- "through this faction, which are powerful upgrades that enhance your abilities. Note that you cannot " +
- "use your terminal or create scripts when you are performing a task!"
- }));
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("br"));
-
- //Hacking Mission Option
- var hackMissionDiv = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("div", {
- id:"faction-hack-mission-div", class:"faction-work-div",
- });
- var hackMissionDivWrapper = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("div", {class:"faction-work-div-wrapper"});
- hackMissionDiv.appendChild(hackMissionDivWrapper);
- hackMissionDivWrapper.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("a", {
- class:"a-link-button", innerText:"Hacking Mission",
- clickListener:()=>{
- _engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].loadMissionContent();
- var mission = new _Missions__WEBPACK_IMPORTED_MODULE_10__[/* HackingMission */ "a"](faction.playerReputation, faction);
- Object(_Missions__WEBPACK_IMPORTED_MODULE_10__[/* setInMission */ "d"])(true, mission); //Sets inMission flag to true
- mission.init();
- return false;
- }
- }));
- hackMissionDivWrapper.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("p", {
- innerText:"Attempt a hacking mission for your faction. " +
- "A mission is a mini game that, if won, earns you " +
- "significant reputation with this faction. (Recommended hacking level: 200+)"
- }));
- elements.push(hackMissionDiv);
-
- //Hacking Contracts Option
- var hackDiv = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("div", {
- id:"faction-hack-div", class:"faction-work-div",
- });
- var hackDivWrapper = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("div", {class:"faction-work-div-wrapper"});
- hackDiv.appendChild(hackDivWrapper);
- hackDivWrapper.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("a", {
- class:"a-link-button", innerText:"Hacking Contracts",
- clickListener:()=>{
- _Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].startFactionHackWork(faction);
- return false;
- }
- }));
- hackDivWrapper.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("p", {
- innerText:"Complete hacking contracts for your faction. " +
- "Your effectiveness, which determines how much " +
- "reputation you gain for this faction, is based on your hacking skill. " +
- "You will gain hacking exp."
- }));
- elements.push(hackDiv);
-
- //Field Work Option
- var fieldWorkDiv = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("div", {
- id:"faction-fieldwork-div", class:"faction-work-div"
- });
- var fieldWorkDivWrapper = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("div", {class:"faction-work-div-wrapper"});
- fieldWorkDiv.appendChild(fieldWorkDivWrapper);
- fieldWorkDivWrapper.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("a", {
- class:"a-link-button", innerText:"Field Work",
- clickListener:()=>{
- _Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].startFactionFieldWork(faction);
- return false;
- }
- }));
- fieldWorkDivWrapper.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("p", {
- innerText:"Carry out field missions for your faction. " +
- "Your effectiveness, which determines how much " +
- "reputation you gain for this faction, is based on all of your stats. " +
- "You will gain exp for all stats."
- }));
- elements.push(fieldWorkDiv);
-
- //Security Work Option
- var securityWorkDiv = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("div", {
- id:"faction-securitywork-div", class:"faction-work-div"
- });
- var securityWorkDivWrapper = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("div", {class:"faction-work-div-wrapper"});
- securityWorkDiv.appendChild(securityWorkDivWrapper);
- securityWorkDivWrapper.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("a", {
- class:"a-link-button", innerText:"Security Work",
- clickListener:()=>{
- _Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].startFactionSecurityWork(faction);
- return false;
- }
- }));
- securityWorkDivWrapper.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("p", {
- innerText:"Serve in a security detail for your faction. " +
- "Your effectiveness, which determines how much " +
- "reputation you gain for this faction, is based on your combat stats. " +
- "You will gain exp for all combat stats."
- }));
- elements.push(securityWorkDiv);
-
- //Donate for reputation
- var donateDiv = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("div", {
- id:"faction-donate-div", class:"faction-work-div"
- });
- var donateDivWrapper = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("div", {class:"faction-work-div-wrapper"});
- donateDiv.appendChild(donateDivWrapper);
- var donateRepGain = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("p", {
- innerText:"This donation will result in 0.000 reputation gain"
- });
- var donateAmountInput = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("input", {
- placeholder:"Donation amount",
- inputListener:()=>{
- let amt = 0;
- if(donateAmountInput.value !== "") {
- amt = parseFloat(donateAmountInput.value);
- }
- if (isNaN(amt)) {
- donateRepGain.innerText = "Invalid donate amount entered!";
- } else {
- var repGain = amt / _Constants__WEBPACK_IMPORTED_MODULE_4__["CONSTANTS"].DonateMoneyToRepDivisor * _Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].faction_rep_mult;
- donateRepGain.innerText = "This donation will result in " +
- Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(repGain, 3) + " reputation gain";
- }
- },
- });
- donateDivWrapper.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("a", {
- class:"a-link-button", innerText:"Donate Money",
- clickListener:()=>{
- var amt = parseFloat(donateAmountInput.value);
- if (isNaN(amt) || amt < 0) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Invalid amount entered!");
- } else if (_Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].money.lt(amt)) {
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("You cannot afford to donate this much money!");
- } else {
- _Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].loseMoney(amt);
- var repGain = amt / _Constants__WEBPACK_IMPORTED_MODULE_4__["CONSTANTS"].DonateMoneyToRepDivisor * _Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].faction_rep_mult;
- faction.playerReputation += repGain;
- Object(_utils_DialogBox__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("You just donated " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_15__["numeralWrapper"].format(amt, "$0.000a") + " to " +
- faction.name + " to gain " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(repGain, 3) + " reputation");
- displayFactionContent(factionName);
- }
- }
- }));
- donateDivWrapper.appendChild(donateAmountInput);
- donateDivWrapper.appendChild(donateRepGain);
- elements.push(donateDiv);
-
- //Purchase Augmentations
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("pre", {
- innerHTML: " As your reputation with this faction rises, you will " +
- "unlock Augmentations, which you can purchase to enhance " +
- "your abilities.
"
- }));
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("a", {
- class:"a-link-button", innerText:"Purchase Augmentations",
- clickListener:()=>{
- _engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].hideAllContent();
- _engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].Display.factionAugmentationsContent.style.display = "block";
-
-
- displayFactionAugmentations(factionName);
- return false;
- }
- }));
-
- //Gang (BitNode-2)
- if (_Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].bitNodeN == 2 && (factionName == "Slum Snakes" || factionName == "Tetrads" ||
- factionName == "The Syndicate" || factionName == "The Dark Army" || factionName == "Speakers for the Dead" ||
- factionName == "NiteSec" || factionName == "The Black Hand")) {
- //Set everything else to invisible
- hackMissionDiv.style.display = "none";
- hackDiv.style.display = "none";
- fieldWorkDiv.style.display = "none";
- securityWorkDiv.style.display = "none";
- donateDiv.style.display = "none";
-
- //Create the 'Manage Gang' button
- var gangDiv = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("div", {
- id:"faction-gang-div", class:"faction-work-div", display:"inline"
- });
- var gangDivWrapper = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("div", {class:"faction-work-div-wrapper"});
- gangDiv.appendChild(gangDivWrapper);
- gangDivWrapper.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("a", {
- class:"a-link-button", innerText:"Manage Gang",
- clickListener: () => {
- if (!_Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].inGang()) {
- // Determine whether this is a hacking gang
- let hacking = false;
- if (factionName === "NiteSec" || factionName === "The Black Hand") { hacking = true; }
-
- // Configure Yes/No buttons for the pop-up
- var yesBtn = Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxGetNoButton"])();
- yesBtn.innerHTML = "Create Gang";
- noBtn.innerHTML = "Cancel";
- yesBtn.addEventListener("click", () => {
- _Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].startGang(factionName, hacking);
- document.getElementById("world-menu-header").click();
- document.getElementById("world-menu-header").click();
- _engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].loadGangContent();
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxClose"])();
- });
- noBtn.addEventListener("click", () => {
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxClose"])();
- });
-
- // Pop-up text
- let gangTypeText = "";
- if (hacking) {
- gangTypeText = "This is a HACKING gang. Members in this gang will have different tasks than COMBAT gangs. " +
- "Compared to combat gangs, progression with hacking gangs is more straightforward as territory warfare " +
- "is not as important.
";
- } else {
- gangTypeText = "This is a COMBAT gang. Members in this gang will have different tasks than HACKING gangs. " +
- "Compared to hacking gangs, progression with combat gangs can be more difficult as territory management " +
- "is more important. However, well-managed combat gangs can progress faster than hacking ones.
";
- }
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxCreate"])(`Would you like to create a new Gang with ${factionName}?
` +
- "Note that this will prevent you from creating a Gang with any other Faction until " +
- "this BitNode is destroyed.
" +
- gangTypeText +
- "Other than hacking vs combat, there are NO differences between the Factions you can " +
- "create a Gang with, and each of these Factions have all Augmentations available.");
- } else {
- _engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].loadGangContent();
- }
- }
- }));
- gangDivWrapper.appendChild(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("p", {
- innerText:"Create and manage a gang for this Faction. " +
- "Gangs will earn you money and faction reputation."
- }));
- //Manage Gang button goes before Faction work stuff
- elements.splice(7, 1, gangDiv);
-
- if (_Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].inGang() && _Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].gang.facName != factionName) {
- //If the player has a gang but its not for this faction
- gangDiv.style.display = "none";
- }
- //Display all elements
- for (var i = 0; i < elements.length; ++i) {
- _engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].Display.factionContent.appendChild(elements[i]);
- }
- return;
- }
-
- if (!faction.isMember) {
- throw new Error("Not a member of this faction, cannot display faction information");
- }
-
- donateDiv.style.display = faction.favor >= Math.floor(_Constants__WEBPACK_IMPORTED_MODULE_4__["CONSTANTS"].BaseFavorToDonate * _BitNode_BitNodeMultipliers__WEBPACK_IMPORTED_MODULE_3__["BitNodeMultipliers"].RepToDonateToFaction) ? "inline" : "none";
-
- hackMissionDiv.style.display = factionInfo.offerHackingMission ? "inline": "none";
- hackDiv.style.display = factionInfo.offerHackingWork ? "inline" : "none";
- fieldWorkDiv.style.display = factionInfo.offerFieldWork ? "inline" : "none";
- securityWorkDiv.style.display = factionInfo.offerSecurityWork ? "inline" : "none";
-
- //Display all elements
- for (var i = 0; i < elements.length; ++i) {
- _engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].Display.factionContent.appendChild(elements[i]);
- }
-}
-
-function displayFactionAugmentations(factionName) {
- var faction = _Factions__WEBPACK_IMPORTED_MODULE_7__["Factions"][factionName];
- if (faction == null) {
- throw new Error("Could not find faction " + factionName + " in displayFactionAugmentations");
- }
-
- Object(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_18__["removeChildrenFromElement"])(_engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].Display.factionAugmentationsContent);
- var elements = [];
-
- //Back button
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("a", {
- innerText:"Back", class:"a-link-button",
- clickListener:()=>{
- _engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].loadFactionContent();
- displayFactionContent(factionName);
- return false;
- }
- }));
-
- //Header text
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("h1", {innerText:"Faction Augmentations"}));
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("p", {
- id:"faction-augmentations-page-desc",
- innerHTML:"Lists all Augmentations that are available to purchase from " + factionName + "
" +
- "Augmentations are powerful upgrades that will enhance your abilities."
- }));
-
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("br"));
- elements.push(Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("br"));
-
- //Augmentations List
- var augmentationsList = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("ul");
-
- //Sort buttons
- const sortByCostBtn = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("a", {
- innerText:"Sort by Cost", class:"a-link-button",
- clickListener:()=>{
- _Settings_Settings__WEBPACK_IMPORTED_MODULE_13__["Settings"].PurchaseAugmentationsOrder = _Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12__["PurchaseAugmentationsOrderSetting"].Cost;
- var augs = faction.augmentations.slice();
- augs.sort((augName1, augName2)=>{
- var aug1 = _Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augName1], aug2 = _Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augName2];
- if (aug1 == null || aug2 == null) {
- throw new Error("Invalid Augmentation Names");
- }
- return aug1.baseCost - aug2.baseCost;
- });
- Object(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_18__["removeChildrenFromElement"])(augmentationsList);
- createFactionAugmentationDisplayElements(augmentationsList, augs, faction);
- }
- });
- const sortByRepBtn = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("a", {
- innerText:"Sort by Reputation", class:"a-link-button",
- clickListener:()=>{
- _Settings_Settings__WEBPACK_IMPORTED_MODULE_13__["Settings"].PurchaseAugmentationsOrder = _Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12__["PurchaseAugmentationsOrderSetting"].Reputation;
- var augs = faction.augmentations.slice();
- augs.sort((augName1, augName2)=>{
- var aug1 = _Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augName1], aug2 = _Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augName2];
- if (aug1 == null || aug2 == null) {
- throw new Error("Invalid Augmentation Names");
- }
- return aug1.baseRepRequirement - aug2.baseRepRequirement;
- });
- Object(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_18__["removeChildrenFromElement"])(augmentationsList);
- createFactionAugmentationDisplayElements(augmentationsList, augs, faction);
- }
- });
- const defaultSortBtn = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("a", {
- innerText:"Sort by Default Order", class:"a-link-button",
- clickListener:()=>{
- _Settings_Settings__WEBPACK_IMPORTED_MODULE_13__["Settings"].PurchaseAugmentationsOrder = _Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12__["PurchaseAugmentationsOrderSetting"].Default;
- Object(_utils_uiHelpers_removeChildrenFromElement__WEBPACK_IMPORTED_MODULE_18__["removeChildrenFromElement"])(augmentationsList);
- createFactionAugmentationDisplayElements(augmentationsList, faction.augmentations, faction);
- }
- });
- elements.push(sortByCostBtn);
- elements.push(sortByRepBtn);
- elements.push(defaultSortBtn);
- switch(_Settings_Settings__WEBPACK_IMPORTED_MODULE_13__["Settings"].PurchaseAugmentationsOrder) {
- case _Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12__["PurchaseAugmentationsOrderSetting"].Cost:
- sortByCostBtn.click();
- break;
- case _Settings_SettingEnums__WEBPACK_IMPORTED_MODULE_12__["PurchaseAugmentationsOrderSetting"].Reputation:
- sortByRepBtn.click();
- break;
- default:
- defaultSortBtn.click();
- break;
- }
-
- elements.push(augmentationsList);
-
- for (var i = 0; i < elements.length; ++i) {
- _engine__WEBPACK_IMPORTED_MODULE_5__["Engine"].Display.factionAugmentationsContent.appendChild(elements[i]);
- }
-}
-
-//Takes in an array of Augmentation Names, constructs DOM elements
-//to list them on the faction page, and appends them to the given
-//DOM element
-// @augmentationsList DOM List to append Aug DOM elements to
-// @augs Array of Aug names
-// @faction Faction for which to display Augmentations
-function createFactionAugmentationDisplayElements(augmentationsList, augs, faction) {
- const factionInfo = faction.getInfo();
-
- for (var i = 0; i < augs.length; ++i) {
- (function () {
- var aug = _Augmentation_Augmentations__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augs[i]];
- if (aug == null) {
- throw new Error("Invalid Augmentation when trying to create Augmentation display Elements");
- }
- var owned = false;
- for (var j = 0; j < _Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].queuedAugmentations.length; ++j) {
- if (_Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].queuedAugmentations[j].name == aug.name) {
- owned = true;
- break;
- }
- }
- for (var j = 0; j < _Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].augmentations.length; ++j) {
- if (_Player__WEBPACK_IMPORTED_MODULE_11__[/* Player */ "a"].augmentations[j].name == aug.name) {
- owned = true;
- break;
- }
- }
-
- var item = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("li");
- var span = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("span", { display:"inline-block", margin: "4px", padding: "4px" });
- var aDiv = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("div", {tooltip:aug.info});
- var aElem = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("a", {
- innerText:aug.name, display:"inline",
- clickListener:()=>{
- if (!_Settings_Settings__WEBPACK_IMPORTED_MODULE_13__["Settings"].SuppressBuyAugmentationConfirmation) {
- purchaseAugmentationBoxCreate(aug, faction);
- } else {
- purchaseAugmentation(aug, faction);
- }
- return false;
- }
- });
- if (aug.name == _Augmentation_data_AugmentationNames__WEBPACK_IMPORTED_MODULE_2__["AugmentationNames"].NeuroFluxGovernor) {
- aElem.innerText += " - Level " + (getNextNeurofluxLevel());
- }
- var pElem = Object(_utils_uiHelpers_createElement__WEBPACK_IMPORTED_MODULE_19__["createElement"])("p", {
- display:"inline",
- })
- var req = aug.baseRepRequirement * factionInfo.augmentationRepRequirementMult;
- var hasPrereqs = hasAugmentationPrereqs(aug);
- if (!hasPrereqs) {
- aElem.setAttribute("class", "a-link-button-inactive");
- pElem.innerHTML = "LOCKED (Requires " + aug.prereqs.join(",") + " as prerequisite(s))";
- pElem.style.color = "red";
- } else if (aug.name != _Augmentation_data_AugmentationNames__WEBPACK_IMPORTED_MODULE_2__["AugmentationNames"].NeuroFluxGovernor && (aug.owned || owned)) {
- aElem.setAttribute("class", "a-link-button-inactive");
- pElem.innerHTML = "ALREADY OWNED";
- } else if (faction.playerReputation >= req) {
- aElem.setAttribute("class", "a-link-button");
- pElem.innerHTML = "UNLOCKED - " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_15__["numeralWrapper"].format(aug.baseCost * factionInfo.augmentationPriceMult, "$0.000a");
- } else {
- aElem.setAttribute("class", "a-link-button-inactive");
- pElem.innerHTML = "LOCKED (Requires " + Object(_utils_StringHelperFunctions__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(req, 1) + " faction reputation) - " + _ui_numeralFormat__WEBPACK_IMPORTED_MODULE_15__["numeralWrapper"].format(aug.baseCost * factionInfo.augmentationPriceMult, "$0.000a");
- pElem.style.color = "red";
- }
- aDiv.appendChild(aElem);
- span.appendChild(aDiv);
- span.appendChild(pElem);
- item.appendChild(span);
- augmentationsList.appendChild(item);
- }()); //Immediate invocation closure
- }
-}
-
-function purchaseAugmentationBoxCreate(aug, fac) {
- const factionInfo = fac.getInfo();
- var yesBtn = Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxGetNoButton"])();
- yesBtn.innerHTML = "Purchase";
- noBtn.innerHTML = "Cancel";
- yesBtn.addEventListener("click", function() {
- purchaseAugmentation(aug, fac);
- });
- noBtn.addEventListener("click", function() {
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxClose"])();
- });
-
- Object(_utils_YesNoBox__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxCreate"])("