" +
+ "You have been working for " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["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.startWorkPartTime = function() {
+ this.resetWorkStatus();
+ this.isWorking = true;
+ this.workType = _Constants_js__WEBPACK_IMPORTED_MODULE_3__["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_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].MillisecondsPer8Hours;
+
+ var newCancelButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_17__["clearEventListeners"])("work-in-progress-cancel-button");
+ newCancelButton.innerHTML = "Stop Working";
+ newCancelButton.addEventListener("click", function() {
+ Player.finishWorkPartTime();
+ return false;
+ });
+
+ //Display Work In Progress Screen
+ _engine_js__WEBPACK_IMPORTED_MODULE_7__["Engine"].loadWorkInProgressContent();
+}
+
+PlayerObject.prototype.workPartTime = function(numCycles) {
+ this.workRepGainRate = this.getWorkRepGain();
+
+ this.workHackExpGained += this.workHackExpGainRate * numCycles;
+ this.workStrExpGained += this.workStrExpGainRate * numCycles;
+ this.workDefExpGained += this.workDefExpGainRate * numCycles;
+ this.workDexExpGained += this.workDexExpGainRate * numCycles;
+ this.workAgiExpGained += this.workAgiExpGainRate * numCycles;
+ this.workChaExpGained += this.workChaExpGainRate * numCycles;
+ this.workRepGained += this.workRepGainRate * numCycles;
+ this.workMoneyGained += this.workMoneyGainRate * numCycles;
+
+ var cyclesPerSec = 1000 / _engine_js__WEBPACK_IMPORTED_MODULE_7__["Engine"]._idleSpeed;
+
+ this.timeWorked += _engine_js__WEBPACK_IMPORTED_MODULE_7__["Engine"]._idleSpeed * numCycles;
+
+ //If timeWorked == 8 hours, then finish. You can only gain 8 hours worth of exp and money
+ if (this.timeWorked >= _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].MillisecondsPer8Hours) {
+ var maxCycles = _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].GameCyclesPer8Hours;
+ this.workHackExpGained = this.workHackExpGainRate * maxCycles;
+ this.workStrExpGained = this.workStrExpGainRate * maxCycles;
+ this.workDefExpGained = this.workDefExpGainRate * maxCycles;
+ this.workDexExpGained = this.workDexExpGainRate * maxCycles;
+ this.workAgiExpGained = this.workAgiExpGainRate * maxCycles;
+ this.workChaExpGained = this.workChaExpGainRate * maxCycles;
+ this.workRepGained = this.workRepGainRate * maxCycles;
+ this.workMoneyGained = this.workMoneyGainRate * maxCycles;
+ this.finishWorkPartTime();
+ return;
+ }
+
+ var txt = document.getElementById("work-in-progress-text");
+ txt.innerHTML = "You are currently working as a " + this.companyPosition.positionName +
+ " at " + Player.companyName + "
" +
+ "You have been working for " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["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.";
+}
+
+
+//Money gained per game cycle
+PlayerObject.prototype.getWorkMoneyGain = function() {
+ var bn11Mult = 1;
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.companyName];
+ if (_NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_11__["hasBn11SF"]) {
+ bn11Mult = 1 + (company.favor / 100);
+ }
+ return this.companyPosition.baseSalary * company.salaryMultiplier *
+ this.work_money_mult * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].CompanyWorkMoney * bn11Mult;
+}
+
+//Hack exp gained per game cycle
+PlayerObject.prototype.getWorkHackExpGain = function() {
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.companyName];
+ return this.companyPosition.hackingExpGain * company.expMultiplier *
+ this.hacking_exp_mult * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].CompanyWorkExpGain;
+}
+
+//Str exp gained per game cycle
+PlayerObject.prototype.getWorkStrExpGain = function() {
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.companyName];
+ return this.companyPosition.strengthExpGain * company.expMultiplier *
+ this.strength_exp_mult * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].CompanyWorkExpGain;
+}
+
+//Def exp gained per game cycle
+PlayerObject.prototype.getWorkDefExpGain = function() {
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.companyName];
+ return this.companyPosition.defenseExpGain * company.expMultiplier *
+ this.defense_exp_mult * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].CompanyWorkExpGain;
+}
+
+//Dex exp gained per game cycle
+PlayerObject.prototype.getWorkDexExpGain = function() {
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.companyName];
+ return this.companyPosition.dexterityExpGain * company.expMultiplier *
+ this.dexterity_exp_mult * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].CompanyWorkExpGain;
+}
+
+//Agi exp gained per game cycle
+PlayerObject.prototype.getWorkAgiExpGain = function() {
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.companyName];
+ return this.companyPosition.agilityExpGain * company.expMultiplier *
+ this.agility_exp_mult * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].CompanyWorkExpGain;
+}
+
+//Charisma exp gained per game cycle
+PlayerObject.prototype.getWorkChaExpGain = function() {
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.companyName];
+ return this.companyPosition.charismaExpGain * company.expMultiplier *
+ this.charisma_exp_mult * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].CompanyWorkExpGain;
+}
+
+//Reputation gained per game cycle
+PlayerObject.prototype.getWorkRepGain = function() {
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.companyName];
+ var jobPerformance = this.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_js__WEBPACK_IMPORTED_MODULE_3__["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_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].MaxSkillLevel +
+ this.strength / _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].MaxSkillLevel +
+ this.defense / _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].MaxSkillLevel +
+ this.dexterity / _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].MaxSkillLevel +
+ this.agility / _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].MaxSkillLevel) / 4.5;
+ return t * this.faction_rep_mult;
+}
+
+PlayerObject.prototype.getFactionFieldWorkRepGain = function() {
+ var t = 0.9 * (this.hacking_skill / _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].MaxSkillLevel +
+ this.strength / _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].MaxSkillLevel +
+ this.defense / _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].MaxSkillLevel +
+ this.dexterity / _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].MaxSkillLevel +
+ this.agility / _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].MaxSkillLevel +
+ this.charisma / _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].MaxSkillLevel +
+ this.intelligence / _Constants_js__WEBPACK_IMPORTED_MODULE_3__["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_js__WEBPACK_IMPORTED_MODULE_3__["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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_17__["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_js__WEBPACK_IMPORTED_MODULE_7__["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_js__WEBPACK_IMPORTED_MODULE_7__["Engine"]._idleSpeed * numCycles);
+ this.timeWorkedCreateProgram += (_engine_js__WEBPACK_IMPORTED_MODULE_7__["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_js__WEBPACK_IMPORTED_MODULE_21__["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_js__WEBPACK_IMPORTED_MODULE_16__["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 * 100).toString();
+ var incompleteName = programName + "-" + perc + "%-INC";
+ this.getHomeComputer().programs.push(incompleteName);
+ }
+
+ if (!cancelled) {
+ this.gainIntelligenceExp(this.createProgramReqLvl / _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].IntelligenceProgramBaseExpGain);
+ }
+
+ var mainMenu = document.getElementById("mainmenu-container");
+ mainMenu.style.visibility = "visible";
+
+ this.isWorking = false;
+
+ _engine_js__WEBPACK_IMPORTED_MODULE_7__["Engine"].loadTerminalContent();
+ this.resetWorkStatus();
+}
+
+/* Studying/Taking Classes */
+PlayerObject.prototype.startClass = function(costMult, expMult, className) {
+ this.resetWorkStatus();
+ this.isWorking = true;
+ this.workType = _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].WorkTypeStudyClass;
+
+ this.className = className;
+
+ var gameCPS = 1000 / _engine_js__WEBPACK_IMPORTED_MODULE_7__["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_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassStudyComputerScience:
+ hackExp = baseStudyComputerScienceExp * expMult / gameCPS;
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassDataStructures:
+ cost = _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassDataStructuresBaseCost * costMult / gameCPS;
+ hackExp = baseDataStructuresExp * expMult / gameCPS;
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassNetworks:
+ cost = _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassNetworksBaseCost * costMult / gameCPS;
+ hackExp = baseNetworksExp * expMult / gameCPS;
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassAlgorithms:
+ cost = _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassAlgorithmsBaseCost * costMult / gameCPS;
+ hackExp = baseAlgorithmsExp * expMult / gameCPS;
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassManagement:
+ cost = _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassManagementBaseCost * costMult / gameCPS;
+ chaExp = baseManagementExp * expMult / gameCPS;
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassLeadership:
+ cost = _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassLeadershipBaseCost * costMult / gameCPS;
+ chaExp = baseLeadershipExp * expMult / gameCPS;
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassGymStrength:
+ cost = _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassGymBaseCost * costMult / gameCPS;
+ strExp = baseGymExp * expMult / gameCPS;
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassGymDefense:
+ cost = _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassGymBaseCost * costMult / gameCPS;
+ defExp = baseGymExp * expMult / gameCPS;
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassGymDexterity:
+ cost = _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassGymBaseCost * costMult / gameCPS;
+ dexExp = baseGymExp * expMult / gameCPS;
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassGymAgility:
+ cost = _Constants_js__WEBPACK_IMPORTED_MODULE_3__["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_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].ClassGymExpGain;
+ this.workStrExpGainRate = strExp * this.strength_exp_mult * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].ClassGymExpGain;;
+ this.workDefExpGainRate = defExp * this.defense_exp_mult * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].ClassGymExpGain;;
+ this.workDexExpGainRate = dexExp * this.dexterity_exp_mult * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].ClassGymExpGain;;
+ this.workAgiExpGainRate = agiExp * this.agility_exp_mult * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].ClassGymExpGain;;
+ this.workChaExpGainRate = chaExp * this.charisma_exp_mult * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].ClassGymExpGain;;
+
+ var cancelButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_17__["clearEventListeners"])("work-in-progress-cancel-button");
+ if (className == _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassGymStrength ||
+ className == _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassGymDefense ||
+ className == _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].ClassGymDexterity ||
+ className == _Constants_js__WEBPACK_IMPORTED_MODULE_3__["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_js__WEBPACK_IMPORTED_MODULE_7__["Engine"].loadWorkInProgressContent();
+}
+
+PlayerObject.prototype.takeClass = function(numCycles) {
+ this.timeWorked += _engine_js__WEBPACK_IMPORTED_MODULE_7__["Engine"]._idleSpeed * numCycles;
+ var className = this.className;
+
+ this.workHackExpGained += this.workHackExpGainRate * numCycles;
+ this.workStrExpGained += this.workStrExpGainRate * numCycles;
+ this.workDefExpGained += this.workDefExpGainRate * numCycles;
+ this.workDexExpGained += this.workDexExpGainRate * numCycles;
+ this.workAgiExpGained += this.workAgiExpGainRate * numCycles;
+ this.workChaExpGained += this.workChaExpGainRate * numCycles;
+ this.workRepGained += this.workRepGainRate * numCycles;
+ this.workMoneyGained += this.workMoneyGainRate * numCycles;
+ this.workMoneyGained -= this.workMoneyLossRate * numCycles;
+
+ var cyclesPerSec = 1000 / _engine_js__WEBPACK_IMPORTED_MODULE_7__["Engine"]._idleSpeed;
+
+ var txt = document.getElementById("work-in-progress-text");
+ txt.innerHTML = "You have been " + className + " for " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["convertTimeMsToTimeElapsedString"])(this.timeWorked) + "
" +
+ "You gained: "+
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workHackExpGained, 4) + " hacking experience " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workStrExpGained, 4) + " strength experience " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDefExpGained, 4) + " defense experience " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workDexExpGained, 4) + " dexterity experience " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workAgiExpGained, 4) + " agility experience " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.workChaExpGained, 4) + " charisma experience");
+ }
+ }
+
+ this.gainWorkExp();
+ }
+ this.committingCrimeThruSingFn = false;
+ this.singFnCrimeWorkerScript = null;
+ var mainMenu = document.getElementById("mainmenu-container");
+ mainMenu.style.visibility = "visible";
+ this.isWorking = false;
+ this.resetWorkStatus();
+ _engine_js__WEBPACK_IMPORTED_MODULE_7__["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_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].WorkTypeStudyClass:
+ res = this.finishClass(true);
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].WorkTypeCompany:
+ res = this.finishWork(true, true);
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].WorkTypeCompanyPartTime:
+ res = this.finishWorkPartTime(true);
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].WorkTypeFaction:
+ res = this.finishFactionWork(true, true);
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].WorkTypeCreateProgram:
+ res = this.finishCreateProgramWork(true, true);
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_3__["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() {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("You were in critical condition! You were taken to the hospital where " +
+ "luckily they were able to save your life. You were charged $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_21__["formatNumber"])(this.max_hp * _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].HospitalCostPerHp, 2));
+ this.loseMoney(this.max_hp * _Constants_js__WEBPACK_IMPORTED_MODULE_3__["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) {
+ var currCompany = "";
+ if (this.companyName != "") {
+ currCompany = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.companyName];
+ }
+ var currPositionName = "";
+ if (this.companyPosition != "") {
+ currPositionName = this.companyPosition.positionName;
+ }
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.location]; //Company being applied to
+ if (sing && !(company instanceof _Company_js__WEBPACK_IMPORTED_MODULE_2__["Company"])) {
+ return "ERROR: Invalid company name: " + this.location + ". applyToCompany() failed";
+ }
+
+ var pos = entryPosType;
+
+ if (!this.isQualified(company, pos)) {
+ var reqText = Object(_Company_js__WEBPACK_IMPORTED_MODULE_2__["getJobRequirementText"])(company, pos);
+ if (sing) {return false;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Unforunately, you do not qualify for this position " + reqText);
+ return;
+ }
+
+ while (true) {
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_7__["Engine"].Debug) {console.log("Determining qualification for next Company Position");}
+ var newPos = Object(_Company_js__WEBPACK_IMPORTED_MODULE_2__["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 != "") {
+ if (currCompany.companyName == company.companyName &&
+ pos.positionName == currPositionName) {
+ var nextPos = Object(_Company_js__WEBPACK_IMPORTED_MODULE_2__["getNextCompanyPosition"])(pos);
+ if (nextPos == null) {
+ if (sing) {return false;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["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_js__WEBPACK_IMPORTED_MODULE_2__["getJobRequirementText"])(company, nextPos);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Unfortunately, you do not qualify for a promotion " + reqText);
+ } else {
+ if (sing) {return false;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("You are already at the highest position for your field! No promotion available");
+ }
+ return; //Same job, do nothing
+ }
+ }
+
+
+ //Lose reputation from a Company if you are leaving it for another job
+ var leaveCompany = false;
+ var oldCompanyName = "";
+ if (currCompany != "") {
+ if (currCompany.companyName != company.companyName) {
+ leaveCompany = true;
+ oldCompanyName = currCompany.companyName;
+ company.playerReputation -= 1000;
+ if (company.playerReputation < 0) {company.playerReputation = 0;}
+ }
+ }
+
+ this.companyName = company.companyName;
+ this.companyPosition = pos;
+
+ if (this.firstJobRecvd === false) {
+ this.firstJobRecvd = true;
+ document.getElementById("job-tab").style.display = "list-item";
+ document.getElementById("world-menu-header").click();
+ document.getElementById("world-menu-header").click();
+ }
+
+ if (leaveCompany) {
+ if (sing) {return true;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Congratulations! You were offered a new job at " + this.companyName + " as a " +
+ pos.positionName + "! " +
+ "You lost 1000 reputation at your old company " + oldCompanyName + " because you left.");
+ } else {
+ if (sing) {return true;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Congratulations! You were offered a new job at " + this.companyName + " as a " + pos.positionName + "!");
+ }
+
+ _engine_js__WEBPACK_IMPORTED_MODULE_7__["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_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.companyName];
+ }
+
+ //Not employed at this company, so return the entry position
+ if (currCompany == null || (currCompany.companyName != company.companyName)) {
+ 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.
+ if ((this.companyPosition.isSoftwareJob() && entryPosType.isSoftwareJob()) ||
+ (this.companyPosition.isITJob() && entryPosType.isITJob()) ||
+ (this.companyPosition.isBusinessJob() && entryPosType.isBusinessJob()) ||
+ (this.companyPosition.isSecurityEngineerJob() && entryPosType.isSecurityEngineerJob()) ||
+ (this.companyPosition.isNetworkEngineerJob() && entryPosType.isNetworkEngineerJob()) ||
+ (this.companyPosition.isSecurityJob() && entryPosType.isSecurityJob()) ||
+ (this.companyPosition.isAgentJob() && entryPosType.isAgentJob()) ||
+ (this.companyPosition.isSoftwareConsultantJob() && entryPosType.isSoftwareConsultantJob()) ||
+ (this.companyPosition.isBusinessConsultantJob() && entryPosType.isBusinessConsultantJob()) ||
+ (this.companyPosition.isPartTimeJob() && entryPosType.isPartTimeJob())) {
+ return Object(_Company_js__WEBPACK_IMPORTED_MODULE_2__["getNextCompanyPosition"])(this.companyPosition);
+ }
+
+
+ return entryPosType;
+}
+
+PlayerObject.prototype.applyForSoftwareJob = function(sing=false) {
+ return this.applyForJob(_Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].SoftwareIntern, sing);
+}
+
+PlayerObject.prototype.applyForSoftwareConsultantJob = function(sing=false) {
+ return this.applyForJob(_Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].SoftwareConsultant, sing);
+}
+
+PlayerObject.prototype.applyForItJob = function(sing=false) {
+ return this.applyForJob(_Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].ITIntern, sing);
+}
+
+PlayerObject.prototype.applyForSecurityEngineerJob = function(sing=false) {
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.location]; //Company being applied to
+ if (this.isQualified(company, _Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].SecurityEngineer)) {
+ return this.applyForJob(_Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].SecurityEngineer, sing);
+ } else {
+ if (sing) {return false;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Unforunately, you do not qualify for this position");
+ }
+}
+
+PlayerObject.prototype.applyForNetworkEngineerJob = function(sing=false) {
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.location]; //Company being applied to
+ if (this.isQualified(company, _Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].NetworkEngineer)) {
+ return this.applyForJob(_Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].NetworkEngineer, sing);
+ } else {
+ if (sing) {return false;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Unforunately, you do not qualify for this position");
+ }
+}
+
+PlayerObject.prototype.applyForBusinessJob = function(sing=false) {
+ return this.applyForJob(_Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].BusinessIntern, sing);
+}
+
+PlayerObject.prototype.applyForBusinessConsultantJob = function(sing=false) {
+ return this.applyForJob(_Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].BusinessConsultant, sing);
+}
+
+PlayerObject.prototype.applyForSecurityJob = function(sing=false) {
+ //TODO If case for POlice departments
+ return this.applyForJob(_Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].SecurityGuard, sing);
+}
+
+PlayerObject.prototype.applyForAgentJob = function(sing=false) {
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.location]; //Company being applied to
+ if (this.isQualified(company, _Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].FieldAgent)) {
+ return this.applyForJob(_Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].FieldAgent, sing);
+ } else {
+ if (sing) {return false;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Unforunately, you do not qualify for this position");
+ }
+}
+
+PlayerObject.prototype.applyForEmployeeJob = function(sing=false) {
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.location]; //Company being applied to
+ if (this.isQualified(company, _Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].Employee)) {
+ if (this.firstJobRecvd === false) {
+ this.firstJobRecvd = true;
+ document.getElementById("job-tab").style.display = "list-item";
+ document.getElementById("world-menu-header").click();
+ document.getElementById("world-menu-header").click();
+ }
+ this.companyName = company.companyName;
+ this.companyPosition = _Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].Employee;
+ if (sing) {return true;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Congratulations, you are now employed at " + this.companyName);
+ _engine_js__WEBPACK_IMPORTED_MODULE_7__["Engine"].loadLocationContent();
+ } else {
+ if (sing) {return false;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Unforunately, you do not qualify for this position");
+ }
+}
+
+PlayerObject.prototype.applyForPartTimeEmployeeJob = function(sing=false) {
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.location]; //Company being applied to
+ if (this.isQualified(company, _Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].PartTimeEmployee)) {
+ if (this.firstJobRecvd === false) {
+ this.firstJobRecvd = true;
+ document.getElementById("job-tab").style.display = "list-item";
+ document.getElementById("world-menu-header").click();
+ document.getElementById("world-menu-header").click();
+ }
+ this.companyName = company.companyName;
+ this.companyPosition = _Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].PartTimeEmployee;
+ if (sing) {return true;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Congratulations, you are now employed part-time at " + this.companyName);
+ _engine_js__WEBPACK_IMPORTED_MODULE_7__["Engine"].loadLocationContent();
+ } else {
+ if (sing) {return false;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Unforunately, you do not qualify for this position");
+ }
+}
+
+PlayerObject.prototype.applyForWaiterJob = function(sing=false) {
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.location]; //Company being applied to
+ if (this.isQualified(company, _Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].Waiter)) {
+ if (this.firstJobRecvd === false) {
+ this.firstJobRecvd = true;
+ document.getElementById("job-tab").style.display = "list-item";
+ document.getElementById("world-menu-header").click();
+ document.getElementById("world-menu-header").click();
+ }
+ this.companyName = company.companyName;
+ this.companyPosition = _Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].Waiter;
+ if (sing) {return true;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Congratulations, you are now employed as a waiter at " + this.companyName);
+ _engine_js__WEBPACK_IMPORTED_MODULE_7__["Engine"].loadLocationContent();
+ } else {
+ if (sing) {return false;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Unforunately, you do not qualify for this position");
+ }
+}
+
+PlayerObject.prototype.applyForPartTimeWaiterJob = function(sing=false) {
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.location]; //Company being applied to
+ if (this.isQualified(company, _Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].PartTimeWaiter)) {
+ if (this.firstJobRecvd === false) {
+ this.firstJobRecvd = true;
+ document.getElementById("job-tab").style.display = "list-item";
+ document.getElementById("world-menu-header").click();
+ document.getElementById("world-menu-header").click();
+ }
+ this.companyName = company.companyName;
+ this.companyPosition = _Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].PartTimeWaiter;
+ if (sing) {return true;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["dialogBoxCreate"])("Congratulations, you are now employed as a part-time waiter at " + this.companyName);
+ _engine_js__WEBPACK_IMPORTED_MODULE_7__["Engine"].loadLocationContent();
+ } else {
+ if (sing) {return false;}
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_16__["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";
+ }
+
+ var augName = this.augmentations[i].name;
+ var aug = _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augName];
+ if (aug == null) {
+ console.log("WARNING: Invalid augmentation name");
+ continue;
+ }
+ aug.owned = true;
+ if (aug.name == _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].NeuroFluxGovernor) {
+ for (let j = 0; j < aug.level; ++j) {
+ Object(_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["applyAugmentation"])(this.augmentations[i], true);
+ }
+ continue;
+ }
+ Object(_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["applyAugmentation"])(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_js__WEBPACK_IMPORTED_MODULE_14__["SourceFiles"][srcFileKey];
+ if (sourceFileObject == null) {
+ console.log("ERROR: Invalid source file number: " + this.sourceFiles[i].n);
+ continue;
+ }
+ Object(_SourceFile_js__WEBPACK_IMPORTED_MODULE_14__["applySourceFile"])(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 th eplayer should be invited to
+
+ var numAugmentations = this.augmentations.length;
+
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_2__["Companies"][this.companyName];
+ var companyRep = 0;
+ if (company != null) {
+ companyRep = company.playerReputation;
+ }
+
+ //Illuminati
+ var illuminatiFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["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_js__WEBPACK_IMPORTED_MODULE_8__["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_js__WEBPACK_IMPORTED_MODULE_8__["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_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["ECorp"];
+ if (!ecorpFac.isBanned && !ecorpFac.isMember && !ecorpFac.alreadyInvited &&
+ this.companyName == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].AevumECorp && companyRep >= _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].CorpFactionRepRequirement) {
+ invitedFactions.push(ecorpFac);
+ }
+
+ //MegaCorp
+ var megacorpFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["MegaCorp"];
+ if (!megacorpFac.isBanned && !megacorpFac.isMember && !megacorpFac.alreadyInvited &&
+ this.companyName == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Sector12MegaCorp && companyRep >= _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].CorpFactionRepRequirement) {
+ invitedFactions.push(megacorpFac);
+ }
+
+ //Bachman & Associates
+ var bachmanandassociatesFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["Bachman & Associates"];
+ if (!bachmanandassociatesFac.isBanned && !bachmanandassociatesFac.isMember &&
+ !bachmanandassociatesFac.alreadyInvited &&
+ this.companyName == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].AevumBachmanAndAssociates && companyRep >= _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].CorpFactionRepRequirement) {
+ invitedFactions.push(bachmanandassociatesFac);
+ }
+
+ //Blade Industries
+ var bladeindustriesFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["Blade Industries"];
+ if (!bladeindustriesFac.isBanned && !bladeindustriesFac.isMember && !bladeindustriesFac.alreadyInvited &&
+ this.companyName == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Sector12BladeIndustries && companyRep >= _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].CorpFactionRepRequirement) {
+ invitedFactions.push(bladeindustriesFac);
+ }
+
+ //NWO
+ var nwoFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["NWO"];
+ if (!nwoFac.isBanned && !nwoFac.isMember && !nwoFac.alreadyInvited &&
+ this.companyName == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].VolhavenNWO && companyRep >= _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].CorpFactionRepRequirement) {
+ invitedFactions.push(nwoFac);
+ }
+
+ //Clarke Incorporated
+ var clarkeincorporatedFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["Clarke Incorporated"];
+ if (!clarkeincorporatedFac.isBanned && !clarkeincorporatedFac.isMember && !clarkeincorporatedFac.alreadyInvited &&
+ this.companyName == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].AevumClarkeIncorporated && companyRep >= _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].CorpFactionRepRequirement) {
+ invitedFactions.push(clarkeincorporatedFac);
+ }
+
+ //OmniTek Incorporated
+ var omnitekincorporatedFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["OmniTek Incorporated"];
+ if (!omnitekincorporatedFac.isBanned && !omnitekincorporatedFac.isMember && !omnitekincorporatedFac.alreadyInvited &&
+ this.companyName == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].VolhavenOmniTekIncorporated && companyRep >= _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].CorpFactionRepRequirement) {
+ invitedFactions.push(omnitekincorporatedFac);
+ }
+
+ //Four Sigma
+ var foursigmaFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["Four Sigma"];
+ if (!foursigmaFac.isBanned && !foursigmaFac.isMember && !foursigmaFac.alreadyInvited &&
+ this.companyName == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Sector12FourSigma && companyRep >= _Constants_js__WEBPACK_IMPORTED_MODULE_3__["CONSTANTS"].CorpFactionRepRequirement) {
+ invitedFactions.push(foursigmaFac);
+ }
+
+ //KuaiGong International
+ var kuaigonginternationalFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["KuaiGong International"];
+ if (!kuaigonginternationalFac.isBanned && !kuaigonginternationalFac.isMember &&
+ !kuaigonginternationalFac.alreadyInvited &&
+ this.companyName == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].ChongqingKuaiGongInternational && companyRep >= _Constants_js__WEBPACK_IMPORTED_MODULE_3__["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_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["Fulcrum Secret Technologies"];
+ var fulcrumSecretServer = _Server_js__WEBPACK_IMPORTED_MODULE_12__["AllServers"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__["SpecialServerNames"].FulcrumSecretTechnologies]];
+ if (fulcrumSecretServer == null) {
+ console.log("ERROR: Could not find Fulcrum Secret Technologies Server");
+ } else {
+ if (!fulcrumsecrettechonologiesFac.isBanned && !fulcrumsecrettechonologiesFac.isMember &&
+ !fulcrumsecrettechonologiesFac.alreadyInvited &&
+ fulcrumSecretServer.manuallyHacked &&
+ this.companyName == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].AevumFulcrumTechnologies && companyRep >= 250000) {
+ invitedFactions.push(fulcrumsecrettechonologiesFac);
+ }
+ }
+
+ //BitRunners
+ var bitrunnersFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["BitRunners"];
+ var homeComp = this.getHomeComputer();
+ var bitrunnersServer = _Server_js__WEBPACK_IMPORTED_MODULE_12__["AllServers"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__["SpecialServerNames"].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_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["The Black Hand"];
+ var blackhandServer = _Server_js__WEBPACK_IMPORTED_MODULE_12__["AllServers"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__["SpecialServerNames"].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_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["NiteSec"];
+ var nitesecServer = _Server_js__WEBPACK_IMPORTED_MODULE_12__["AllServers"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__["SpecialServerNames"].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_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["Chongqing"];
+ if (!chongqingFac.isBanned && !chongqingFac.isMember && !chongqingFac.alreadyInvited &&
+ this.money.gte(20000000) && this.city == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Chongqing) {
+ invitedFactions.push(chongqingFac);
+ }
+
+ //Sector-12
+ var sector12Fac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["Sector-12"];
+ if (!sector12Fac.isBanned && !sector12Fac.isMember && !sector12Fac.alreadyInvited &&
+ this.money.gte(15000000) && this.city == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Sector12) {
+ invitedFactions.push(sector12Fac);
+ }
+
+ //New Tokyo
+ var newtokyoFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["New Tokyo"];
+ if (!newtokyoFac.isBanned && !newtokyoFac.isMember && !newtokyoFac.alreadyInvited &&
+ this.money.gte(20000000) && this.city == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].NewTokyo) {
+ invitedFactions.push(newtokyoFac);
+ }
+
+ //Aevum
+ var aevumFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["Aevum"];
+ if (!aevumFac.isBanned && !aevumFac.isMember && !aevumFac.alreadyInvited &&
+ this.money.gte(40000000) && this.city == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Aevum) {
+ invitedFactions.push(aevumFac);
+ }
+
+ //Ishima
+ var ishimaFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["Ishima"];
+ if (!ishimaFac.isBanned && !ishimaFac.isMember && !ishimaFac.alreadyInvited &&
+ this.money.gte(30000000) && this.city == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Ishima) {
+ invitedFactions.push(ishimaFac);
+ }
+
+ //Volhaven
+ var volhavenFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["Volhaven"];
+ if (!volhavenFac.isBanned && !volhavenFac.isMember && !volhavenFac.alreadyInvited &&
+ this.money.gte(50000000) && this.city == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Volhaven) {
+ invitedFactions.push(volhavenFac);
+ }
+
+ //Speakers for the Dead
+ var speakersforthedeadFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["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 && this.companyName != _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Sector12CIA &&
+ this.companyName != _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Sector12NSA) {
+ invitedFactions.push(speakersforthedeadFac);
+ }
+
+ //The Dark Army
+ var thedarkarmyFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["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 == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Chongqing &&
+ this.numPeopleKilled >= 5 && this.karma <= -45 && this.companyName != _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Sector12CIA &&
+ this.companyName != _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Sector12NSA) {
+ invitedFactions.push(thedarkarmyFac);
+ }
+
+ //The Syndicate
+ var thesyndicateFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["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 == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Aevum || this.city == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Sector12) &&
+ this.money.gte(10000000) && this.karma <= -90 &&
+ this.companyName != _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Sector12CIA && this.companyName != _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Sector12NSA) {
+ invitedFactions.push(thesyndicateFac);
+ }
+
+ //Silhouette
+ var silhouetteFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["Silhouette"];
+ if (!silhouetteFac.isBanned && !silhouetteFac.isMember && !silhouetteFac.alreadyInvited &&
+ (this.companyPosition.positionName == _Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].CTO.positionName ||
+ this.companyPosition.positionName == _Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].CFO.positionName ||
+ this.companyPosition.positionName == _Company_js__WEBPACK_IMPORTED_MODULE_2__["CompanyPositions"].CEO.positionName) &&
+ this.money.gte(15000000) && this.karma <= -22) {
+ invitedFactions.push(silhouetteFac);
+ }
+
+ //Tetrads
+ var tetradsFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["Tetrads"];
+ if (!tetradsFac.isBanned && !tetradsFac.isMember && !tetradsFac.alreadyInvited &&
+ (this.city == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Chongqing || this.city == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].NewTokyo ||
+ this.city == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Ishima) && this.strength >= 75 && this.defense >= 75 &&
+ this.dexterity >= 75 && this.agility >= 75 && this.karma <= -18) {
+ invitedFactions.push(tetradsFac);
+ }
+
+ //SlumSnakes
+ var slumsnakesFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["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_js__WEBPACK_IMPORTED_MODULE_8__["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_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["Tian Di Hui"];
+ if (!tiandihuiFac.isBanned && !tiandihuiFac.isMember && !tiandihuiFac.alreadyInvited &&
+ this.money.gte(1000000) && this.hacking_skill >= 50 &&
+ (this.city == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Chongqing || this.city == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].NewTokyo ||
+ this.city == _Location_js__WEBPACK_IMPORTED_MODULE_10__["Locations"].Ishima)) {
+ invitedFactions.push(tiandihuiFac);
+ }
+
+ //CyberSec
+ var cybersecFac = _Faction_js__WEBPACK_IMPORTED_MODULE_8__["Factions"]["CyberSec"];
+ var cybersecServer = _Server_js__WEBPACK_IMPORTED_MODULE_12__["AllServers"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_13__["SpecialServerNames"].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_js__WEBPACK_IMPORTED_MODULE_9__["Gang"]);
+}
+
+PlayerObject.prototype.startGang = function(factionName, hacking) {
+ this.gang = new _Gang_js__WEBPACK_IMPORTED_MODULE_9__["Gang"](factionName, hacking);
+}
+
+/************* BitNodes **************/
+PlayerObject.prototype.setBitNodeNumber = function(n) {
+ this.bitNodeN = n;
+}
+
+/* Functions for saving and loading the Player data */
+function loadPlayer(saveString) {
+ Player = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_19__["Reviver"]);
+
+ //Parse Decimal.js objects
+ Player.money = new _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15___default.a(Player.money);
+ Player.total_money = new _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15___default.a(Player.total_money);
+ Player.lifetime_money = new _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15___default.a(Player.lifetime_money);
+
+ if (Player.corporation instanceof _CompanyManagement_js__WEBPACK_IMPORTED_MODULE_4__["Corporation"]) {
+ Player.corporation.funds = new _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15___default.a(Player.corporation.funds);
+ Player.corporation.revenue = new _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15___default.a(Player.corporation.revenue);
+ Player.corporation.expenses = new _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15___default.a(Player.corporation.expenses);
+
+ for (var i = 0; i < Player.corporation.divisions.length; ++i) {
+ var ind = Player.corporation.divisions[i];
+ ind.lastCycleRevenue = new _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15___default.a(ind.lastCycleRevenue);
+ ind.lastCycleExpenses = new _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15___default.a(ind.lastCycleExpenses);
+ ind.thisCycleRevenue = new _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15___default.a(ind.thisCycleRevenue);
+ ind.thisCycleExpenses = new _utils_decimal_js__WEBPACK_IMPORTED_MODULE_15___default.a(ind.thisCycleExpenses);
+ }
+ }
+}
+
+PlayerObject.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_19__["Generic_toJSON"])("PlayerObject", this);
+}
+
+PlayerObject.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_19__["Generic_fromJSON"])(PlayerObject, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_19__["Reviver"].constructors.PlayerObject = PlayerObject;
+
+let Player = new PlayerObject();
+
+
+
+/***/ }),
+/* 1 */
+/*!**********************************!*\
+ !*** ./utils/HelperFunctions.js ***!
+ \**********************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sizeOfObject", function() { return sizeOfObject; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clearObject", function() { return clearObject; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addOffset", function() { return addOffset; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clearEventListeners", function() { return clearEventListeners; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getRandomInt", function() { return getRandomInt; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "compareArrays", function() { return compareArrays; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "printArray", function() { return printArray; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "powerOfTwo", function() { return powerOfTwo; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clearEventListenersEl", function() { return clearEventListenersEl; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeElementById", function() { return removeElementById; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeElement", function() { return removeElement; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createElement", function() { return createElement; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createAccordionElement", function() { return createAccordionElement; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "appendLineBreaks", function() { return appendLineBreaks; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeChildrenFromElement", function() { return removeChildrenFromElement; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createPopup", function() { return createPopup; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "clearSelector", function() { return clearSelector; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "exceptionAlert", function() { return exceptionAlert; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createProgressBarText", function() { return createProgressBarText; });
+/* harmony import */ var _StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./StringHelperFunctions.js */ 2);
+/* harmony import */ var _DialogBox_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./DialogBox.js */ 6);
+//General helper functions
+
+
+
+//Returns the size (number of keys) of an object
+function sizeOfObject(obj) {
+ var size = 0, key;
+ for (key in obj) {
+ if (obj.hasOwnProperty(key)) size++;
+ }
+ return size;
+}
+
+function clearObject(obj) {
+ for (var key in obj) {
+ if (obj.hasOwnProperty(key)) {
+ delete obj[key];
+ }
+ }
+}
+
+//Adds a random offset to a number within a certain percentage
+//e.g. addOffset(100, 5) will return anything from 95 to 105.
+//The percentage argument must be between 0 and 100;
+function addOffset(n, percentage) {
+ if (percentage < 0 || percentage > 100) {return n;}
+
+ var offset = n * (percentage / 100);
+
+ return n + ((Math.random() * (2 * offset)) - offset);
+}
+
+//Given an element by its Id(usually an 'a' element), removes all event listeners
+//from that element by cloning and replacing. Then returns the new cloned element
+function clearEventListeners(elemId) {
+ var elem = document.getElementById(elemId);
+ if (elem == null) {console.log("ERR: Could not find element for: " + elemId); return null;}
+ var newElem = elem.cloneNode(true);
+ elem.parentNode.replaceChild(newElem, elem);
+ return newElem;
+}
+
+//Same as clearEventListeners except it takes a DOM element object rather than an ID
+function clearEventListenersEl(el) {
+ if (el == null) {console.log("ERR: element passed into clearEventListenersEl is null"); return null;}
+ var newElem = el.cloneNode(true);
+ el.parentNode.replaceChild(newElem, el);
+ return newElem;
+}
+
+//Given its id, this function removes an element AND its children
+function removeElementById(id) {
+ var elem = document.getElementById(id);
+ if (elem == null) {return;}
+ while(elem.firstChild) {elem.removeChild(elem.firstChild);}
+ elem.parentNode.removeChild(elem);
+}
+
+function removeElement(elem) {
+ if (elem == null || !(elem instanceof Element)) {return;}
+ while(elem.firstChild) {elem.removeChild(elem.firstChild);}
+ elem.parentNode.removeChild(elem);
+}
+
+function removeChildrenFromElement(el) {
+ if (Object(_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_0__["isString"])(el)) {
+ el = document.getElementById(el);
+ }
+ if (el == null) {return;}
+ if (el instanceof Element) {
+ while(el.firstChild) {
+ el.removeChild(el.firstChild);
+ }
+ }
+}
+
+function createElement(type, params={}) {
+ var el = document.createElement(type);
+ if (params.id) {el.id = params.id;}
+ if (params.class) {el.className = params.class;}
+ if (params.name) {el.name = params.name;}
+ if (params.innerHTML) {el.innerHTML = params.innerHTML;}
+ if (params.innerText) {el.innerText = params.innerText;}
+ if (params.value) {el.value = params.value;}
+ if (params.text) {el.text = params.text;}
+ if (params.display) {el.style.display = params.display;}
+ if (params.visibility) {el.style.visibility = params.visibility;}
+ if (params.margin) {el.style.margin = params.margin;}
+ if (params.marginLeft) {el.style.marginLeft = params.marginLeft;}
+ if (params.marginTop) {el.style.marginTop = params.marginTop;}
+ if (params.padding) {el.style.padding = params.padding;}
+ if (params.color) {el.style.color = params.color;}
+ if (params.border) {el.style.border = params.border;}
+ if (params.float) {el.style.cssFloat = params.float;}
+ if (params.fontSize) {el.style.fontSize = params.fontSize;}
+ if (params.whiteSpace) {el.style.whiteSpace = params.whiteSpace;}
+ if (params.width) {el.style.width = params.width;}
+ if (params.backgroundColor) {
+ el.style.backgroundColor = params.backgroundColor
+ }
+ if (params.position) {el.style.position = params.position;}
+ if (params.type) {el.type = params.type;}
+ if (params.checked) {el.checked = params.checked;}
+ if (params.for) {el.htmlFor = params.for;}
+ if (params.pattern) {el.pattern = params.pattern;}
+ if (params.maxLength) {el.maxLength = params.maxLength;}
+ if (params.placeholder) {el.placeholder = params.placeholder;}
+ if (params.tooltip && params.tooltip !== "") {
+ el.className += " tooltip";
+ el.appendChild(createElement("span", {
+ class:"tooltiptext",
+ innerHTML:params.tooltip
+ }));
+ } else if (params.tooltipleft) {
+ el.className += " tooltip";
+ el.appendChild(createElement("span", {
+ class:"tooltiptextleft",
+ innerHTML:params.tooltipleft
+ }));
+ }
+ if (params.href) {el.href = params.href;}
+ if (params.target) {el.target = params.target;}
+ if (params.tabIndex) {el.tabIndex = params.tabIndex;}
+ if (params.clickListener) {
+ el.addEventListener("click", params.clickListener);
+ }
+ if (params.inputListener) {
+ el.addEventListener("input", params.inputListener);
+ }
+ if (params.changeListener) {
+ el.addEventListener("change", params.changeListener);
+ }
+ if (params.onkeyup) {
+ el.addEventListener("keyup", params.onkeyup);
+ }
+ if (params.onfocus) {
+ el.addEventListener("focus", params.onfocus);
+ }
+ return el;
+}
+
+function createPopup(id, elems) {
+ var container = createElement("div", {
+ class:"popup-box-container",
+ id:id,
+ display:"block"
+ }),
+ content = createElement("div", {
+ class:"popup-box-content",
+ id:id + "-content",
+ });
+
+ for (var i = 0; i < elems.length; ++i) {
+ content.appendChild(elems[i]);
+ }
+ container.appendChild(content);
+ document.getElementById("entire-game-container").appendChild(container);
+ return container;
+}
+
+//Creates both the header and panel element of an accordion and sets the click handler
+function createAccordionElement(params) {
+ var li = document.createElement("li"),
+ hdr = document.createElement("button"),
+ panel = document.createElement("div");
+ hdr.classList.add("accordion-header");
+ panel.classList.add("accordion-panel");
+
+ if (params.id) {
+ hdr.id = params.id + "-hdr";
+ panel.id = params.id + "-panel";
+ }
+ if (params.hdrText) {hdr.innerHTML = params.hdrText;}
+ if (params.panelText) {panel.innerHTML = params.panelText;}
+ li.appendChild(hdr);
+ li.appendChild(panel);
+ //Click handler
+ hdr.onclick = function() {
+ this.classList.toggle("active");
+ var tmpPanel = this.nextElementSibling;
+ if (tmpPanel.style.display === "block") {
+ tmpPanel.style.display = "none";
+ } else {
+ tmpPanel.style.display = "block";
+ }
+ }
+ return [li, hdr, panel];
+}
+
+//Appends n line breaks (as children) to the Element el
+function appendLineBreaks(el, n) {
+ for (var i = 0; i < n; ++i) {
+ el.appendChild(createElement("br"));
+ }
+}
+
+function clearSelector(selector) {
+ for (var i = selector.options.length - 1; i >= 0; --i) {
+ selector.remove(i);
+ }
+}
+
+function getRandomInt(min, max) {
+ if (min > max) {return getRandomInt(max, min);}
+ return Math.floor(Math.random() * (max - min + 1)) + min;
+}
+
+//Returns true if all elements are equal, and false otherwise
+//Assumes both arguments are arrays and that there are no nested arrays
+function compareArrays(a1, a2) {
+ if (a1.length != a2.length) {
+ return false;
+ }
+
+ for (var i = 0; i < a1.length; ++i) {
+ if (a1[i] != a2[i]) {return false;}
+ }
+ return true;
+}
+
+function printArray(a) {
+ return "[" + a.join(", ") + "]";
+}
+
+//Returns bool indicating whether or not its a power of 2
+function powerOfTwo(n) {
+ if (isNaN(n)) {return false;}
+ return n && (n & (n-1)) === 0;
+}
+
+function exceptionAlert(e) {
+ Object(_DialogBox_js__WEBPACK_IMPORTED_MODULE_1__["dialogBoxCreate"])("Caught an exception: " + e + "
" +
+ "Filename: " + e.fileName + "
" +
+ "Line Number: " + e.lineNumber + "
" +
+ "This is a bug, please report to game developer with this " +
+ "message as well as details about how to reproduce the bug.
" +
+ "If you want to be safe, I suggest refreshing the game WITHOUT saving so that your " +
+ "safe doesn't get corrupted");
+}
+
+/*Creates a graphical "progress bar"
+ * e.g.: [||||---------------]
+ * params:
+ * @totalTicks - Total number of ticks in progress bar. Preferably a factor of 100
+ * @progress - Current progress, taken as a decimal (i.e. 0.6 to represent 60%)
+ */
+function createProgressBarText(params={}) {
+ //Default values
+ var totalTicks = (params.totalTicks == null ? 20 : params.totalTicks);
+ var progress = (params.progress == null ? 0 : params.progress);
+
+ var percentPerTick = 1 / totalTicks;
+ var numTicks = Math.floor(progress / percentPerTick);
+ var numDashes = totalTicks - numTicks;
+ return "[" + Array(numTicks+1).join("|") + Array(numDashes+1).join("-") + "]";
+}
+
+
+
+
+/***/ }),
+/* 2 */
+/*!****************************************!*\
+ !*** ./utils/StringHelperFunctions.js ***!
+ \****************************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getIndicesOf", function() { return getIndicesOf; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "convertTimeMsToTimeElapsedString", function() { return convertTimeMsToTimeElapsedString; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "longestCommonStart", function() { return longestCommonStart; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isString", function() { return isString; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "containsAllStrings", function() { return containsAllStrings; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "formatNumber", function() { return formatNumber; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "numOccurrences", function() { return numOccurrences; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "numNetscriptOperators", function() { return numNetscriptOperators; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isHTML", function() { return isHTML; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "generateRandomString", function() { return generateRandomString; });
+/* harmony import */ var _DialogBox_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./DialogBox.js */ 6);
+
+
+//Netburner String helper functions
+
+//Searches for every occurence of searchStr within str and returns an array of the indices of
+//all these occurences
+function getIndicesOf(searchStr, str, caseSensitive) {
+ var searchStrLen = searchStr.length;
+ if (searchStrLen == 0) {
+ return [];
+ }
+ var startIndex = 0, index, indices = [];
+ if (!caseSensitive) {
+ str = str.toLowerCase();
+ searchStr = searchStr.toLowerCase();
+ }
+ while ((index = str.indexOf(searchStr, startIndex)) > -1) {
+ indices.push(index);
+ startIndex = index + searchStrLen;
+ }
+ return indices;
+}
+
+//Replaces the character at an index with a new character
+String.prototype.replaceAt=function(index, character) {
+ return this.substr(0, index) + character + this.substr(index+character.length);
+}
+
+//Converts a date representing time in milliseconds to a string with the format
+// H hours M minutes and S seconds
+// e.g. 10000 -> "0 hours 0 minutes and 10 seconds"
+// 120000 -> "0 0 hours 2 minutes and 0 seconds"
+function convertTimeMsToTimeElapsedString(time) {
+ //Convert ms to seconds, since we only have second-level precision
+ time = Math.floor(time / 1000);
+
+ var days = Math.floor(time / 86400);
+ time %= 86400;
+
+ var hours = Math.floor(time / 3600);
+ time %= 3600;
+
+ var minutes = Math.floor(time / 60);
+ time %= 60;
+
+ var seconds = time;
+
+ var res = "";
+ if (days) {res += days + " days ";}
+ if (hours) {res += hours + " hours ";}
+ if (minutes) {res += minutes + " minutes ";}
+ res += seconds + " seconds ";
+ return res;
+}
+
+//Finds the longest common starting substring in a set of strings
+function longestCommonStart(strings) {
+ if (!containsAllStrings(strings)) {return;}
+ if (strings.length == 0) {return;}
+
+ var A = strings.concat().sort(),
+ a1= A[0], a2= A[A.length-1], L= a1.length, i= 0;
+ while(i= 0) {
+ ++n;
+ pos += step;
+ } else break;
+ }
+ return n;
+}
+
+//Counters the number of Netscript operators in a string
+function numNetscriptOperators(string) {
+ var total = 0;
+ total += numOccurrences(string, "+");
+ total += numOccurrences(string, "-");
+ total += numOccurrences(string, "*");
+ total += numOccurrences(string, "/");
+ total += numOccurrences(string, "%");
+ total += numOccurrences(string, "&&");
+ total += numOccurrences(string, "||");
+ total += numOccurrences(string, "<");
+ total += numOccurrences(string, ">");
+ total += numOccurrences(string, "<=");
+ total += numOccurrences(string, ">=");
+ total += numOccurrences(string, "==");
+ total += numOccurrences(string, "!=");
+ if (isNaN(total)) {
+ Object(_DialogBox_js__WEBPACK_IMPORTED_MODULE_0__["dialogBoxCreate"])("ERROR in counting number of operators in script. This is a bug, please report to game developer");
+ total = 0;
+ }
+ return total;
+}
+
+//Checks if a string contains HTML elements
+function isHTML(str) {
+ var a = document.createElement('div');
+ a.innerHTML = str;
+ for (var c = a.childNodes, i = c.length; i--; ) {
+ if (c[i].nodeType == 1) return true;
+ }
+ return false;
+}
+
+//Generates a random alphanumeric string with N characters
+function generateRandomString(n) {
+ var str = "",
+ chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
+
+ for (var i = 0; i < n; i++)
+ str += chars.charAt(Math.floor(Math.random() * chars.length));
+
+ return str;
+}
+
+
+
+
+/***/ }),
+/* 3 */
+/*!**************************!*\
+ !*** ./src/Constants.js ***!
+ \**************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CONSTANTS", function() { return CONSTANTS; });
+let CONSTANTS = {
+ Version: "0.36.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,
+
+ //How much reputation is needed to join a megacorporation's faction
+ CorpFactionRepRequirement: 250000,
+
+ /* Base costs */
+ BaseCostFor1GBOfRamHome: 32000,
+ BaseCostFor1GBOfRamServer: 55000, //1 GB of RAM
+ BaseCostFor1GBOfRamHacknetNode: 30000,
+
+ BaseCostForHacknetNode: 1000,
+ BaseCostForHacknetNodeCore: 500000,
+
+ /* Hacknet Node constants */
+ HacknetNodeMoneyGainPerLevel: 1.6,
+ HacknetNodePurchaseNextMult: 1.85, //Multiplier when purchasing an additional hacknet node
+ HacknetNodeUpgradeLevelMult: 1.04, //Multiplier for cost when upgrading level
+ HacknetNodeUpgradeRamMult: 1.28, //Multiplier for cost when upgrading RAM
+ HacknetNodeUpgradeCoreMult: 1.48, //Multiplier for cost when buying another core
+
+ HacknetNodeMaxLevel: 200,
+ HacknetNodeMaxRam: 64,
+ HacknetNodeMaxCores: 16,
+
+ /* Faction and Company favor */
+ 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
+ ScriptWhileRamCost: 0.2,
+ ScriptForRamCost: 0.2,
+ ScriptIfRamCost: 0.15,
+ ScriptHackRamCost: 0.1,
+ ScriptGrowRamCost: 0.15,
+ ScriptWeakenRamCost: 0.15,
+ ScriptScanRamCost: 0.2,
+ ScriptPortProgramRamCost: 0.05,
+ ScriptRunRamCost: 1.0,
+ ScriptExecRamCost: 1.3,
+ ScriptSpawnRamCost: 2.0,
+ ScriptScpRamCost: 0.6,
+ ScriptKillRamCost: 0.5, //Kill and killall
+ ScriptHasRootAccessRamCost: 0.05,
+ ScriptGetHostnameRamCost: 0.05, //getHostname() and getIp()
+ ScriptGetHackingLevelRamCost: 0.05, //getHackingLevel()
+ ScriptGetMultipliersRamCost: 4.0, //getHackingMultipliers() and getBitNodeMultipliers()
+ ScriptGetServerRamCost: 0.1,
+ ScriptFileExistsRamCost: 0.1,
+ ScriptIsRunningRamCost: 0.1,
+ ScriptPurchaseHacknetRamCost: 1.5,
+ ScriptHacknetNodesRamCost: 4.0, //Base cost for accessing hacknet nodes array
+ ScriptHNUpgLevelRamCost: 0.4,
+ ScriptHNUpgRamRamCost: 0.6,
+ ScriptHNUpgCoreRamCost: 0.8,
+ ScriptGetStockRamCost: 2.0,
+ ScriptBuySellStockRamCost: 2.5,
+ ScriptPurchaseServerRamCost: 2.25,
+ ScriptRoundRamCost: 0.05,
+ ScriptReadWriteRamCost: 1.0,
+ ScriptArbScriptRamCost: 1.0, //Functions that apply to all scripts regardless of args
+ ScriptGetScriptRamCost: 0.1,
+ ScriptGetHackTimeRamCost: 0.05,
+
+ ScriptSingularityFn1RamCost: 1,
+ ScriptSingularityFn2RamCost: 2,
+ ScriptSingularityFn3RamCost: 3,
+
+ MultithreadingRAMCost: 1,
+
+ NumNetscriptPorts: 20,
+
+ //Server constants
+ ServerBaseGrowthRate: 1.03, //Unadjusted Growth rate
+ ServerMaxGrowthRate: 1.0035, //Maximum possible growth rate (max rate accounting for server security)
+ ServerFortifyAmount: 0.002, //Amount by which server's security increases when its hacked/grown
+ ServerWeakenAmount: 0.05, //Amount by which server's security decreases when weakened
+
+ PurchasedServerLimit: 25,
+
+ //Augmentation Constants
+ AugmentationCostMultiplier: 5, //Used for balancing costs without having to readjust every Augmentation cost
+ AugmentationRepMultiplier: 2.5, //Used for balancing rep cost without having to readjust every value
+ MultipleAugMultiplier: 1.9,
+
+ //How much a TOR router costs
+ TorRouterCost: 200000,
+
+ //Infiltration constants
+ InfiltrationBribeBaseAmount: 100000, //Amount per clearance level
+ InfiltrationMoneyValue: 2500, //Convert "secret" value to money
+ InfiltrationRepValue: 1.4, //Convert "secret" value to faction reputation
+
+ //Stock market constants
+ WSEAccountCost: 200e6,
+ TIXAPICost: 5e9,
+ StockMarketCommission: 100e3,
+
+ //Hospital/Health
+ HospitalCostPerHp: 100e3,
+
+ //Intelligence-related constants
+ IntelligenceCrimeWeight: 0.05, //Weight for how much int affects crime success rates
+ IntelligenceInfiltrationWeight: 0.1, //Weight for how much int affects infiltration success rates
+ IntelligenceCrimeBaseExpGain: 0.001,
+ IntelligenceProgramBaseExpGain: 500, //Program required hack level divided by this to determine int exp gain
+ IntelligenceTerminalHackBaseExpGain: 200, //Hacking exp divided by this to determine int exp gain
+ IntelligenceSingFnBaseExpGain: 0.002,
+ IntelligenceClassBaseExpGain: 0.000001,
+ IntelligenceHackingMissionBaseExpGain: 0.03, //Hacking Mission difficulty multiplied by this to get exp gain
+
+ //Hacking Missions
+ HackingMissionRepToDiffConversion: 10000, //Faction rep is divided by this to get mission difficulty
+ HackingMissionRepToRewardConversion: 7, //Faction rep divided byt his to get mission rep reward
+ HackingMissionSpamTimeIncrease: 25000, //How much time limit increase is gained when conquering a Spam Node (ms)
+ HackingMissionTransferAttackIncrease: 1.05, //Multiplier by which the attack for all Core Nodes is increased when conquering a Transfer Node
+ HackingMissionMiscDefenseIncrease: 1.05, //The amount by which every misc node's defense is multiplied when one is conquered
+ HackingMissionDifficultyToHacking: 135, //Difficulty is multiplied by this to determine enemy's "hacking" level (to determine effects of scan/attack, etc)
+ 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.",
+
+
+ //Gang constants
+ GangRespectToReputationRatio: 2, //Respect is divided by this to get rep gain
+ MaximumGangMembers: 20,
+ GangRecruitCostMultiplier: 2,
+ GangTerritoryUpdateTimer: 150,
+
+ 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,
+
+ 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,
+
+ CrimeSingFnDivider: 2, //Factor by which exp/profit is reduced when commiting crime through Sing Fn
+ 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",
+
+ /* 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. The language has " +
+ "your basic programming constructs and several built-in commands that are used to hack.
" +
+ "
Official Documentation
" +
+ "Check out Bitburner's official Netscript documentation" +
+ ". This official documentation will contain more details and " +
+ "code examples than this documentation page. Also, it can be opened up in another tab/window for convenience!
" +
+ "
Variables and data types
" +
+ "The following data types are supported by Netscript: " +
+ "numeric - Integers and floats (eg. 6, 10.4999) " +
+ "string - Encapsulated by single or double quotes (eg. 'this is a string') " +
+ "boolean - true or false
" +
+ "Strings are fully functional Javascript strings, " +
+ "which means that all of the member functions of Javascript strings such as toLowerCase() and includes() are also " +
+ "available in Netscript!
" +
+ "To create a variable, use the assign (=) operator. The language is not strongly typed. Examples: " +
+ "i = 5; " +
+ "s = 'this game is awesome!';
" +
+ "In the first example above, we are creating the variable i and assigning it a value of 5. In the second, " +
+ "we are creating the variable s and assigning it the value of a string. Note that all expressions must be " +
+ "ended with a semicolon.
" +
+ "
Operators
" +
+ "The following operators are supported by Netscript: " +
+ " + " +
+ " - " +
+ " * " +
+ " / " +
+ " % " +
+ " && " +
+ " || " +
+ " < " +
+ " > " +
+ " <= " +
+ " >= " +
+ " == " +
+ " != " +
+ " ++ (Note: This ONLY pre-increments. Post-increment does not work) " +
+ " -- (Note: This ONLY pre-decrements. Post-decrement does not work) " +
+ " - (Negation operator) " +
+ " !
" +
+ "
Arrays
" +
+ "Netscript arrays have the same properties and functions as javascript arrays. For information see javascripts array documentation.
"+
+ "
Script Arguments
" +
+ "Arguments passed into a script can be accessed using a special array called 'args'. The arguments can be accessed like a normal array using the [] " +
+ "operator. (args[0], args[1], args[2]...)
" +
+ "For example, let's say we want to make a generic script 'generic-run.script' and we plan to pass two arguments into that script. The first argument will be the name of " +
+ "another script, and the second argument will be a number. This generic script will run the script specified in the first argument " +
+ "with the amount of threads specified in the second element. The code would look like:
" +
+ "run(args[0], args[1]);
" +
+ "It is also possible to get the number of arguments that was passed into a script using:
" +
+ "args.length
" +
+ "Note that none of the other functions that typically work with arrays, such as remove(), insert(), clear(), etc., will work on the " +
+ "args array.
" +
+ "
Javascript Modules
" +
+ "Netscript supports the following Javascript Modules:
" +
+ "Math Date (static functions only)
" +
+ "
Functions
" +
+ "You can NOT define you own functions in Netscript (yet), but there are several built in functions that " +
+ "you may use:
" +
+ "hack(hostname/ip) Core function that is used to try and hack servers to steal money and gain hacking experience. The argument passed in must be a string with " +
+ "either the IP or hostname of the server you want to hack. The runtime for this command depends on your hacking level and the target server's security level. " +
+ " A script can hack a server from anywhere. It does not need to be running on the same server to hack that server. " +
+ "For example, you can create a script that hacks the 'foodnstuff' server and run that script on any server in the game. A successful hack() on " +
+ "a server will raise that server's security level by 0.002. Returns the amount of money stolen if the hack is successful and " +
+ "0 if the hack fails. " +
+ "Examples: hack('foodnstuff'); or hack('148.192.0.12');
" +
+ "sleep(n) Suspends the script for n milliseconds. Example: sleep(5000);
" +
+ "grow(hostname/ip) Use your hacking skills to increase the amount of money available on a server. The argument passed in " +
+ "must be a string with either the IP or hostname of the target server. The runtime for this command depends on your hacking level and the target server's security level. " +
+ "When grow() completes, the money available on a target server will be increased by a certain, fixed percentage. This percentage " +
+ "is determined by the server's growth rate and varies between servers. Generally, higher-level servers have higher growth rates.
" +
+ "Like hack(), grow() can be called on any server, regardless of where the script is running. " +
+ "The grow() command requires root access to the target server, but there is no required hacking level to run the command. " +
+ "It also raises the security level of the target server by 0.004. " +
+ "Returns the number by which the money on the server was multiplied for the growth. " +
+ "Works offline at a slower rate. Example: grow('foodnstuff');
" +
+ "weaken(hostname/ip) Use your hacking skills to attack a server's security, lowering the server's security level. The argument passed " +
+ "in must be a string with either the IP or hostname of the target server. The runtime for this command depends on your " +
+ "hacking level and the target server's security level. This function lowers the security level of the target server by " +
+ "0.05.
Like hack() and grow(), weaken() can be called on " +
+ "any server, regardless of where the script is running. This command requires root access to the target server, but " +
+ "there is no required hacking level to run the command. Returns " +
+ "0.1. Works offline at a slower rate Example: weaken('foodnstuff');
" +
+ "print(x) Prints a value or a variable to the scripts logs (which can be viewed with the 'tail [script]' terminal command ).
" +
+ "tprint(x) Prints a value or a variable to the Terminal
" +
+ "clearLog() Clears the script's logs.
" +
+ "disableLog(fn) Disables logging for the given function. Logging can be disabled for every function " +
+ "by passing 'ALL' as an argument.
" +
+ "Note that this does not completely remove all logging functionality. This only stops a function from logging " +
+ "when the function is successful. If the function fails, it will still log the reason for failure.
" +
+ "Notable functions that cannot have their logs disabled: run, exec, exit
" +
+ "enableLog(fn) Re-enables logging for the given function. If 'ALL' is passed into this function " +
+ "as an argument, then it will revert the effects of disableLog('ALL')
" +
+ "scan(hostname/ip, [hostnames=true]) Returns an array containing the hostnames or IPs of all servers that are one node away from the specified server. " +
+ "The argument must be a string containing the IP or hostname of the target server. The second argument is a boolean that specifies whether " +
+ "the hostnames or IPs of the scanned servers should be output. If it is true then hostnames will be returned, and if false then IP addresses will. " +
+ "This second argument is optional and, if ommitted, the function will output " +
+ "the hostnames of the scanned servers. The hostnames/IPs in the returned array are strings.
" +
+ "nuke(hostname/ip) Run NUKE.exe on the target server. NUKE.exe must exist on your home computer. Example: nuke('foodnstuff');
" +
+ "brutessh(hostname/ip) Run BruteSSH.exe on the target server. BruteSSH.exe must exist on your home computer. Example: brutessh('foodnstuff');
" +
+ "ftpcrack(hostname/ip) Run FTPCrack.exe on the target server. FTPCrack.exe must exist on your home computer. Example: ftpcrack('foodnstuff');
" +
+ "relaysmtp(hostname/ip) Run relaySMTP.exe on the target server. relaySMTP.exe must exist on your home computer. Example: relaysmtp('foodnstuff');
" +
+ "httpworm(hostname/ip) Run HTTPWorm.exe on the target server. HTTPWorm.exe must exist on your home computer. Example: httpworm('foodnstuff');
" +
+ "sqlinject(hostname/ip) Run SQLInject.exe on the target server. SQLInject.exe must exist on your home computer. Example: sqlinject('foodnstuff');
" +
+ "run(script, [numThreads], [args...]) Run a script as a separate process. The first argument that is passed in is the name of the script as a string. This function can only " +
+ "be used to run scripts located on the current server (the server running the script that calls this function). The second argument " +
+ "is optional, and it specifies how many threads to run the script with. This argument must be a number greater than 0. If it is omitted, then the script will be run single-threaded. Any additional arguments will specify " +
+ "arguments to pass into the new script that is being run. If arguments are specified for the new script, then the second argument numThreads argument must be filled in with a value.
" +
+ "Returns true if the script is successfully started, and false otherwise. Requires a significant amount " +
+ "of RAM to run this command.
" +
+ "The simplest way to use the run command is to call it with just the script name. The following example will run 'foo.script' single-threaded with no arguments:
" +
+ "run('foo.script');
" +
+ "The following example will run 'foo.script' but with 5 threads instead of single-threaded:
" +
+ "run('foo.script', 5);
" +
+ "The following example will run 'foo.script' single-threaded, and will pass the string 'foodnstuff' into the script as an argument:
" +
+ "run('foo.script', 1, 'foodnstuff');
" +
+ "exec(script, hostname/ip, [numThreads], [args...]) Run a script as a separate process on another server. The first argument is the name of the script as a string. The " +
+ "second argument is a string with the hostname or IP of the 'target server' on which to run the script. The specified script must exist on the target server. " +
+ "The third argument is optional, and it specifies how many threads to run the script with. If it is omitted, then the script will be run single-threaded. " +
+ "This argument must be a number that is greater than 0. Any additional arguments will specify arguments to pass into the new script that is being run. If " +
+ "arguments are specified for the new script, then the third argument numThreads must be filled in with a value.
Returns " +
+ "true if the script is successfully started, and false otherwise.
" +
+ "The simplest way to use the exec command is to call it with just the script name and the target server. The following example will try to run 'generic-hack.script' " +
+ "on the 'foodnstuff' server:
" +
+ "exec('generic-hack.script', 'foodnstuff');
" +
+ "The following example will try to run the script 'generic-hack.script' on the 'joesguns' server with 10 threads:
" +
+ "The following example will try to run the script 'foo.script' on the 'foodnstuff' server with 5 threads. It will also pass the number 1 and the string 'test' in as arguments " +
+ "to the script.
" +
+ "spawn(script, numThreads, [args...]) Terminates the current script, and then after a delay of about 20 seconds " +
+ "it will execute the newly specified script. The purpose of this function is to execute a new script without being constrained " +
+ "by the RAM usage of the current one. This function can only be used to run scripts on the local server.
" +
+ "The first argument must be a string with the name of the script. The second argument must be an integer specifying the number " +
+ "of threads to run the script with. Any additional arguments will specify arguments to pass into the 'newly-spawned' script." +
+ "Because this function immediately terminates the script, it does not have a return value.
" +
+ "The following example will execute the script 'foo.script' with 10 threads and the arguments 'foodnstuff' and 90:
" +
+ "spawn('foo.script', 10, 'foodnstuff', 90);
" +
+ "kill(script, hostname/ip, [args...]) Kills the script on the target server specified by the script's name and arguments. Remember that " +
+ "scripts are uniquely identified by both their name and arguments. For example, if 'foo.script' is run with the argument 1, then this is not the " +
+ "same as 'foo.script' run with the argument 2, even though they have the same code.
" +
+ "The first argument must be a string with the name of the script. The name is case-sensitive. " +
+ "The second argument must be a string with the hostname or IP of the target server. Any additional arguments to the function will specify the arguments passed " +
+ "into the script that should be killed.
The function will try to kill the specified script on the target server. " +
+ "If the script is found on the specified server and is running, then it will be killed and this function " +
+ "will return true. Otherwise, this function will return false.
" +
+ "Examples: " +
+ "If you are trying to kill a script named 'foo.script' on the 'foodnstuff' server that was ran with no arguments, use this:
" +
+ "kill('foo.script', 'foodnstuff');
" +
+ "If you are trying to kill a script named 'foo.script' on the current server that was ran with no arguments, use this:
" +
+ "kill('foo.script', getHostname());
" +
+ "If you are trying to kill a script named 'foo.script' on the current server that was ran with the arguments 1 and 'foodnstuff', use this:
" +
+ "killall(hostname/ip) Kills all running scripts on the specified server. This function takes a single argument which " +
+ "must be a string containing the hostname or IP of the target server. This function returns true if any scripts were killed, and false otherwise.
" +
+ "exit() Terminates the script immediately
" +
+ "scp(script, [source], destination) Copies a script or literature (.lit) file to another server. The first argument is a string with " +
+ "the filename of the script or literature file " +
+ "to be copied, or an array of filenames to be copied. The next two arguments are strings containing the hostname/IPs of the source and target server. " +
+ "The source refers to the server from which the script/literature file will be copied, while the destination " +
+ "refers to the server to which it will be copied. The source server argument is optional, and if ommitted the source " +
+ "will be the current server (the server on which the script is running). Returns true if the script/literature file is " +
+ "successfully copied over and false otherwise. If the first argument passed in is an array, then the function " +
+ "will return if at least one of the files in the array is successfully copied over.
" +
+ "Example: scp('hack-template.script', 'foodnstuff'); //Copies hack-template.script from the current server to foodnstuff " +
+ "Example: scp('foo.lit', 'helios', 'home'); //Copies foo.lit from the helios server to the home computer
" +
+ "ls(hostname/ip) Returns an array containing the names of all files on the specified server. The argument must be a " +
+ "string with the hostname or IP of the target server.
" +
+ "hasRootAccess(hostname/ip) Returns a boolean (true or false) indicating whether or not the Player has root access to a server. " +
+ "The argument passed in must be a string with either the hostname or IP of the target server. " +
+ "Example: if (hasRootAccess('foodnstuff') == false) { nuke('foodnstuff'); }
" +
+ "getIp() Returns a string with the IP Address of the server that the script is running on
" +
+ "getHostname() Returns a string with the hostname of the server that the script is running on
" +
+ "getHackingLevel() Returns the Player's current hacking level.
" +
+ "getHackingMultipliers() Returns an object containing the Player's hacking related multipliers. " +
+ "These multipliers are returned in integer forms, not percentages (e.g. 1.5 instead of 150%). " +
+ "The object has the following structure:
" +
+ "getBitNodeMultipliers() Returns an object containing the current BitNode multipliers. " +
+ "This function requires Source-File 5 in order to run. The multipliers are returned in integer forms, not percentages " +
+ "(e.g. 1.5 instead of 150%). The multipliers represent the difference between the current BitNode and the " +
+ "original BitNode (BitNode-1). For example, if the 'CrimeMoney' multiplier has a value of 0.1 then that means " +
+ "that committing crimes in the current BitNode will only give 10% of the money you would have received in " +
+ "BitNode-1. The object has the following structure (subject to change in the future):
" +
+ "getServerMoneyAvailable(hostname/ip) Returns the amount of money available on a server. The argument passed in must be a string with either the " +
+ "hostname or IP of the target server. Example: getServerMoneyAvailable('foodnstuff');
" +
+ "getServerMaxMoney(hostname/ip) Returns the maximum amount of money that can be available on a server. The argument passed in must be a string with " +
+ "the hostname or IP of the target server. Example: getServerMaxMoney('foodnstuff');
" +
+ "getServerGrowth(hostname/ip) Returns the server's intrinsic 'growth parameter'. This growth parameter is a number " +
+ "between 1 and 100 that represents how quickly the server's money grows. This parameter affects the percentage by which this server's " +
+ "money is increased when using the grow() function. A higher growth parameter will result in a higher percentage from grow().
" +
+ "The argument passed in must be a string with the hostname or IP of the target server.
" +
+ "getServerSecurityLevel(hostname/ip) Returns the security level of a server. The argument passed in must be a string with either the " +
+ "hostname or IP of the target server. A server's security is denoted by a number, typically between 1 and 100.
" +
+ "getServerBaseSecurityLevel(hostname/ip) Returns the base security level of a server. This is the security level that the server starts out with. " +
+ "This is different than getServerSecurityLevel() because getServerSecurityLevel() returns the current security level of a server, which can constantly change " +
+ "due to hack(), grow(), and weaken() calls on that server. The base security level will stay the same until you reset by installing an Augmentation.
" +
+ "The argument passed in must be a string with either the hostname or IP of the target server. A server's base security is denoted by a number, typically between 1 and 100. " +
+ "
" +
+ "getServerMinSecurityLevel(hostname/ip)Returns the minimum security level of a server. The argument passed in must be a string with " +
+ "either the hostname or IP of the target server.
" +
+ "getServerRequiredHackingLevel(hostname/ip) Returns the required hacking level of a server. The argument passed in must be a string with either the " +
+ "hostname or IP or the target server.
" +
+ "getServerNumPortsRequired(hostname/ip) Returns the number of open ports required to successfully run NUKE.exe on a server. The argument " +
+ "passed in must be a string with either the hostname or IP of the target server.
" +
+ "getServerRam(hostname/ip) Returns an array with two elements that gives information about the target server's RAM. The first " +
+ "element in the array is the amount of RAM that the server has (in GB). The second element in the array is the amount of RAM that " +
+ "is currently being used on the server.
" +
+ "serverExists(hostname/ip) Returns a boolean denoting whether or not the specified server exists. The argument " +
+ "must be a string with the hostname or IP of the target server.
" +
+ "fileExists(filename, [hostname/ip]) Returns a boolean (true or false) indicating whether the specified file exists on a server. " +
+ "The first argument must be a string with the filename. A file can either be a script, program, literature file, or a text file. The filename for a script is case-sensitive, but " +
+ "for the other files it is not. For example, fileExists('brutessh.exe') will work fine, even though the actual program is named BruteSSH.exe.
" +
+ "The second argument is a string with the hostname or IP of the server on which to search for the program. This second argument is optional. " +
+ "If it is omitted, then the function will search through the current server (the server running the script that calls this function) for the file. " +
+ "Example: fileExists('foo.script', 'foodnstuff'); " +
+ "Example: fileExists('ftpcrack.exe');
" +
+ "The first example above will return true if the script named 'foo.script' exists on the 'foodnstuff' server, and false otherwise. The second example above will " +
+ "return true if the current server (the server on which this function runs) contains the FTPCrack.exe program, and false otherwise.
" +
+ "isRunning(filename, hostname/ip, [args...]) Returns a boolean (true or false) indicating whether the specified script is running on a server. " +
+ "Remember that a script is uniquely identified by both its name and its arguments.
" +
+ "The first argument must be a string with the name of the script. The script name is case sensitive. The second argument is a string with the " +
+ "hostname or IP of the target server. Any additional arguments passed to the function will specify the arguments passed into the target script. " +
+ "The function will check whether the script is running on that target server. " +
+ "Example: isRunning('foo.script', 'foodnstuff'); " +
+ "Example: isRunning('foo.script', getHostname()); " +
+ "Example: isRunning('foo.script', 'joesguns', 1, 5, 'test');
" +
+ "The first example above will return true if there is a script named 'foo.script' with no arguments running on the 'foodnstuff' server, and false otherwise. The second " +
+ "example above will return true if there is a script named 'foo.script' with no arguments running on the current server, and false otherwise. " +
+ "The third example above will return true if there is a script named 'foo.script' with the arguments 1, 5, and 'test' running on the 'joesguns' server, and " +
+ "false otherwise.
" +
+ "getNextHacknetNodeCost() Returns the cost of purchasing a new Hacknet Node
" +
+ "purchaseHacknetNode() Purchases a new Hacknet Node. Returns a number with the index of the Hacknet Node. This index is equivalent to the number " +
+ "at the end of the Hacknet Node's name (e.g The Hacknet Node named 'hacknet-node-4' will have an index of 4). If the player cannot afford to purchase " +
+ "a new Hacknet Node then the function will return false. Does NOT work offline
" +
+ "purchaseServer(hostname, ram) Purchases a server with the specified hostname and amount of RAM. The first argument can be any data type, " +
+ "but it will be converted to a string using Javascript's String function. Anything that resolves to an empty string will cause the function to fail. " +
+ "The second argument specified the amount of RAM (in GB) for the server. This argument must resolve to a numeric and it must be a power of 2 " +
+ "(2, 4, 8, etc...).
" +
+ "This function returns the hostname of the newly purchased server as a string. If the function fails to purchase a server, then it will return " +
+ "an empty string. The function will fail if the arguments passed in are invalid or if the player does not have enough money to purchase the specified server.
" +
+ "deleteServer(hostname) Deletes one of the servers you've purchased with the specified hostname. The function will fail if " +
+ "there are any scripts running on the specified server. Returns true if successful and false otherwise
" +
+ "getPurchasedServers([hostname=true]) Returns an array with either the hostname or IPs of all of the servers you " +
+ "have purchased. It takes an optional parameter specifying whether the hostname or IP addresses will be returned. If this " +
+ "parameter is not specified, it is true by default and hostnames will be returned
" +
+ "write(port/fn, data='', mode='a') This function can be used to either write data to a port or to a text file (.txt).
" +
+ "If the first argument is a number between 1 and 10, then it specifies a port and this function will write data to a port. If the second " +
+ "argument is not specified then it will write an empty string to the port. The third argument, mode, is not used when writing data to a port.
" +
+ "If the first argument is a string, then it specifies the name of a text file (.txt) and this function will write data to a text file. " +
+ "The second argument defines the data to be written to the text file. If it is not specified then it is an empty string by default. " +
+ "This third argument, mode, defines how the data will be written to the text file. If mode is set to 'w', then the data is written in 'write' " +
+ "mode which means that it will overwrite the existing data on the file, or it will create a new file if it does not already exist. Otherwise, " +
+ "the data will be written in 'append' mode which means that the data will be added at the end of the existing file, or it will create a new file if it " +
+ "does not already exist. If mode isn't specified then it will be 'a' for 'append' mode by default.
" +
+ "read(port/fn) This function is used to read data from a port or from a text file (.txt).
" +
+ "This function takes a single argument. If this argument is a number between 1 and 10, then it specifies a port and it will read data from " +
+ "a port. A port is a serialized queue. This function will remove the first element from the queue and return it. If the queue is empty, " +
+ "then the string 'NULL PORT DATA' will be returned.
" +
+ "If the first argument is a string, then it specifies the name of a text file and this function will return the data in the " +
+ "specified text file. If the text file does not exist, an empty string will be returned
" +
+ "peek(port) This function is used to peek data from a port. It returns the first element from the specified " +
+ "Netscript Port without removing that element. If the port is empty, then the string 'NULL PORT DATA' will be returned.
" +
+ "The argument must be an integer between 1 and 10.
" +
+ "clear(port/fn) This function is used to clear a Netscript Port or a text file.
" +
+ "It takes a single argument. If this argument is a number between 1 and 10, then it specifies a port and will clear it (deleting all data from it). " +
+ "If the argument is a string, then it specifies the name of a text file (.txt) and will clear the text file so that it is empty.
" +
+ "rm(fn) This function is used to remove a file. It takes a string with the filename as the argument. Returns " +
+ "true if it successfully deletes the given file, and false otherwise. This function works for every file type except message files (.msg).
" +
+ "scriptRunning(scriptname, hostname/ip) Returns a boolean indicating whether any instance of the specified script is running " +
+ "on a server, regardless of its arguments. This is different than the isRunning() function because it does not " +
+ "try to identify a specific instance of a running script by its arguments.
" +
+ "The first argument must be a string with the name of the script. The script name is case sensitive. The second argument is " +
+ "a string with the hostname or IP of the target server. Both arguments are required.
" +
+ "scriptKill(scriptname, hostname/ip) Kills all scripts with the specified filename that are running on the server specified by the " +
+ "hostname/ip, regardless of arguments. Returns true if one or more scripts were successfully killed, and false if there were none.
" +
+ "The first argument must be a string with the name of the script. The script name is case sensitive. The second argument is " +
+ "a string with the hostname or IP of the target server. Both arguments are required.
" +
+ "getScriptRam(scriptname, hostname/ip) Returns the amount of RAM required to run the specified script on the " +
+ "target server. The first argument must be a string with the name of the script. The script name is case sensitive. " +
+ "The second argument is a string with the hostname or IP of the server where that script is. Both arguments are required.
" +
+ "getHackTime(hostname/ip) Returns the amount of time in seconds it takes to execute the hack() Netscript function " +
+ "on the server specified by the hostname/ip. The argument must be a string with the hostname/ip of the target server.
" +
+ "getGrowTime(hostname/ip) Returns the amount of time in seconds it takes to execute the grow() Netscript function " +
+ "on the server specified by the hostname/ip. The argument must be a string with the hostname/ip of the target server.
" +
+ "getWeakenTime(hostname/ip) Returns the amount of time in seconds it takes to execute the weaken() Netscript function " +
+ "on the server specified by the hostname/ip. The argument must be a string with the hostname/ip of the target server.
" +
+ "getScriptIncome([scriptname], [hostname/ip], [args...]) " +
+ "Returns the amount of income the specified script generates while online (when the game is open, does not apply for " +
+ "offline income). This function can also be called with no arguments. If called with no arguments, then this function " +
+ "will return an array of two values. The first value is the total income ($/sec) of all of your active scripts (currently running). " +
+ "The second value is the total income ($/sec) from scripts since you last installed Augmentations (or destroyed a BitNode).
" +
+ "Remember that a script is uniquely identified by both its name and its arguments. So for example if you ran a script " +
+ "with the arguments 'foodnstuff' and '5' then in order to use this function to get that script's income you must " +
+ "specify those arguments in this function call.
" +
+ "The first argument, if specified, must be a string with the name of the script (including the .script extension). " +
+ "The second argument must be a string with the hostname/IP of the target server. If the first argument is specified " +
+ "then the second argument must be specified as well. Any additional arguments passed to the function will specify " +
+ "the arguments passed into the target script.
" +
+ "getScriptExpGain([scriptname], [hostname/ip], [args...]) " +
+ "Returns the amount of hacking experience the specified script generates while online (when the game is open, does not apply for " +
+ "offline experience gains). This function can also return the total experience gain rate of all of your active scripts by running the function " +
+ "with no arguments.
" +
+ "Remember that a script is uniquely identified by both its name and its arguments. So for example if you ran a script " +
+ "with the arguments 'foodnstuff' and '5' then in order to use this function to get that script's income you must " +
+ "specify those arguments in this function call.
" +
+ "The first argument, if specified, must be a string with the name of the script (including the .script extension). " +
+ "The second argument must be a string with the hostname/IP of the target server. If the first argument is specified " +
+ "then the second argument must be specified as well. Any additional arguments passed to the function will specify " +
+ "the arguments passed into the target script.
" +
+ "getTimeSinceLastAug() " +
+ "Returns the amount of time in milliseconds that have passed since you last installed Augmentations (or destroyed a BitNode).
" +
+ "prompt(message) " +
+ "Prompts the player with a dialog box with two options: 'Yes' and 'No'. This function will returns true if " +
+ "the player clicks 'Yes' and false if the player click's 'No'. The script's execution is halted until the " +
+ "player selects 'Yes' or 'No'. The function takes a single string as an argument which specifies the text " +
+ "that appears on the dialog box.
" +
+ "
Hacknet Nodes API
" +
+ "Netscript provides the following API for accessing and upgrading your Hacknet Nodes through scripts. This API does NOT work offline.
" +
+ "hacknetnodes A special variable. This is an array that maps to the Player's Hacknet Nodes. The Hacknet Nodes are accessed through " +
+ "indexes. These indexes correspond to the number at the end of the name of the Hacknet Node. For example, the first Hacknet Node you purchase " +
+ "will have the same 'hacknet-node-0' and can be accessed with hacknetnodes[0]. The fourth Hacknet Node you purchase will have the name " +
+ "'hacknet-node-3' and can be accessed with hacknetnodes[3].
" +
+ "hacknetnodes.length Returns the number of Hacknet Nodes that the player owns
" +
+ "hacknetnodes[i].level Returns the level of the corresponding Hacknet Node
" +
+ "hacknetnodes[i].ram Returns the amount of RAM on the corresponding Hacknet Node
" +
+ "hacknetnodes[i].cores Returns the number of cores on the corresponding Hacknet Node
" +
+ "hacknetnodes[i].totalMoneyGenerated Returns the total amount of money that the corresponding Hacknet Node has earned
" +
+ "hacknetnodes[i].onlineTimeSeconds Returns the total amount of time that the corresponding Hacknet Node has existed
" +
+ "hacknetnodes[i].moneyGainRatePerSecond Returns the income ($ / sec) that the corresponding Hacknet Node earns
" +
+ "hacknetnodes[i].upgradeLevel(n) Tries to upgrade the level of the corresponding Hacknet Node n times. The argument n must be a " +
+ "positive integer. Returns true if the Hacknet Node's level is successfully upgraded n times or up to the max level (200), and false otherwise.
" +
+ "hacknetnodes[i].upgradeRam() Tries to upgrade the amount of RAM on the corresponding Hacknet Node. Returns true if the " +
+ "RAM is successfully upgraded, and false otherwise.
" +
+ "hacknetnodes[i].upgradeCore() Attempts to purchase an additional core for the corresponding Hacknet Node. Returns true if the " +
+ "additional core is successfully purchase, and false otherwise.
" +
+ "Example: The following is an example of one way a script can be used to automate the purchasing and upgrading of Hacknet Nodes. " +
+ "This script purchases new Hacknet Nodes until the player has four. Then, it iteratively upgrades each of those four Hacknet Nodes " +
+ "to a level of at least 75, RAM to at least 8GB, and number of cores to at least 2.
" +
+ "getStockPrice(sym) Returns the price of a stock. The argument passed in must be the stock's symbol (NOT THE COMPANY NAME!). The symbol " +
+ "is a sequence of two to four capital letters. The symbol argument must be a string.
" +
+ "Example: getStockPrice('FSIG');
" +
+ "getStockPosition(sym) Returns an array of two elements that represents the player's position in a stock. The first element " +
+ "in the array is the number of shares the player owns of the specified stock. The second element in the array is the average price of the player's " +
+ "shares. Both elements are numbers. The argument passed in must be the stock's symbol, which is a sequence of two to four capital letters.
"+
+ "buyStock(sym, shares) Attempts to purchase shares of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument " +
+ "must be the number of shares to purchase.
" +
+ "If the player does not have enough money to purchase specified number of shares, then no shares will be purchased (it will not purchase the most you can afford). " +
+ "Remember that every transaction on the stock exchange costs a certain commission fee.
" +
+ "If this function successfully purchases the shares, it will return the stock price at which each share was purchased. Otherwise, it will return 0.
" +
+ "sellStock(sym, shares) Attempts to sell shares of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument " +
+ "must be the number of shares to sell.
" +
+ "If the specified number of shares in the function exceeds the amount that the player actually owns, then this function will sell all owned shares. " +
+ "Remember that every transaction on the stock exchange costs a certain commission fee.
" +
+ "The net profit made from selling stocks with this function is reflected in the script's statistics. This net profit is calculated as:
" +
+ "shares * (sell price - average price of purchased shares)
" +
+ "If the sale is successful, this function will return the stock price at which each share was sold. Otherwise, it will return 0.
" +
+ "shortStock(sym, shares) " +
+ "Attempts to purchase a short position of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument " +
+ "must be the number of shares to purchase.
" +
+ "In order to use this function the player must be in BitNode-8 or must have Level 2 of Source-File 8.
" +
+ "If the player does not have enough money to purchase the specified number of shares, then no shares will be purchased. Remember that every " +
+ "every transaction on the stock exchange costs a certain commission fee.
" +
+ "If the purchase is successful, this function will return the stock price at which each share was purchased. Otherwise, it will return 0.
" +
+ "sellShort(sym, shares) " +
+ "Attempts to sell a short position of a stock using a Market Order. The first argument must be a string with the stock's symbol. The second argument must be the " +
+ "number of shares to sell.
" +
+ "In order to use this function the player must be in BitNode-8 or must have Level 2 of Source-File 8.
" +
+ "If the specified number of shares exceeds the amount that the player actually owns, then this function will sell all owned shares. " +
+ "Remember that every transaction on the stock exchange costs a certain commission fee.
" +
+ "If the sale was successful, this function will return the stock price at which each sale was sold. Otherwise, it will return 0.
" +
+ "placeOrder(sym, shares, price, type, pos) " +
+ "Places an order on the stock market. This function only works for Limit and Stop Orders. Use the buyStock/sellStock/shortStock/sellShort functions " +
+ "to place Market Orders. In order to use this function the player must be in BitNode-8 or must have Level 3 of Source-File 8.
" +
+ "The 'sym' argument must be a string with the symbol of the stock. The 'shares' and 'price' arguments " +
+ "specify the number of shares and the execution price for the order. They must be numeric.
" +
+ "The 'type' argument is a string that specifies the type of order. It must specify either 'limit' or 'stop', and must " +
+ "also specify 'buy' or 'sell'. This argument is NOT case-sensitive. Here are four examples that will work:
" +
+ "limitbuy, limitsell, stopbuy, stopsell
" +
+ "The last argument, 'pos', is a string that specifies whether the order is a 'Long' or 'Short' position. The values 'L' and " +
+ "'S' can also be used. This argument is NOT case-sensitive.
" +
+ "Returns true if the order is successfully placed, and false otherwise.
" +
+ "cancelOrder(sym, shares, price, type, pos) " +
+ "Cancels an oustanding order on the stock market. In order to use this function the player must be in BitNode-8 or must have " +
+ "Level 3 of Source-File 8. This function uses the same arguments as placeOrder()
" +
+ "
While loops
" +
+ "A while loop is a control flow statement that repeatedly executes code as long as a condition is met.
" +
+ "while ([cond]) { [code] }
" +
+ "As long as [cond] remains true, the code block [code] will continuously execute. Example:
" +
+ "i = 0; while (i < 10) { hack('foodnstuff'); i = i + 1; }
" +
+ "This code above repeats the 'hack('foodnstuff')' command 10 times before it stops and exits.
" +
+ "while(true) { hack('foodnstuff'); }
" +
+ "This while loop above is an infinite loop (continuously runs until the script is manually stopped) that repeatedly runs the 'hack('foodnstuff')' command. " +
+ "Note that a semicolon is needed at closing bracket of the while loop, UNLESS it is at the end of the code
" +
+ "
For loops
" +
+ "A for loop is another control flow statement that allows code to be repeated by iterations. The structure is:
" +
+ "for ([init]; [cond]; [post]) { code }
" +
+ "The [init] expression evaluates before the for loop begins. The for loop will continue to execute " +
+ "as long as [cond] is met. The [post] expression will evaluate at the end of every iteration " +
+ "of the for loop. The following example shows code that will run the 'hack('foodnstuff');' command 10 times " +
+ " using a for loop:
" +
+ "for (i = 0; i < 10; i = i++) { hack('foodnstuff'); }
" +
+ "
If statements
" +
+ "If/Else if/Else statements are conditional statements used to perform different actions based on different conditions:
" +
+ "In the code above, first condition1 will be checked. If this condition is true, then code1 will execute and the " +
+ "rest of the if/else if/else statement will be skipped. If condition1 is NOT true, then the code will then go on to check " +
+ "condition2. If condition2 is true, then code2 will be executed, and the rest of the if/else if/else statement " +
+ "will be skipped. If none of the conditions are true, then the code within the else block (code3) will be executed. " +
+ "Note that a conditional statement can have any number of 'else if' statements.
" +
+ "The code above will use the getServerMoneyAvailable() function to check how much money there is on the 'foodnstuff' server. " +
+ "If there is more than $200,000, then it will try to hack that server. If there is $200,000 or less on the server, " +
+ "then the code will call grow('foodnstuff') instead and add more money to the server.
",
+ TutorialSingularityFunctionsText: "
Singularity Functions
" +
+ "The Singularity Functions are a special set of Netscript functions that are unlocked in BitNode-4. " +
+ "These functions allow you to control many additional aspects of the game through scripts, such as " +
+ "working for factions/companies, purchasing/installing Augmentations, and creating programs.
" +
+ "If you are in BitNode-4, then you will automatically have access to all of these functions. " +
+ "You can use the Singularity Functions in other BitNodes if and only if you have the Source-File " +
+ "for BitNode-4 (aka Source-File 4). Each level of Source-File 4 will open up additional Singularity " +
+ "Functions that you can use in other BitNodes. If your Source-File 4 is upgraded all the way to level 3, " +
+ "then you will be able to access all of the Singularity Functions.
" +
+ "Note that Singularity Functions require a lot of RAM outside of BitNode-4 (their RAM costs are multiplied by " +
+ "10 if you are not in BitNode-4).
" +
+ "universityCourse(universityName, courseName) " +
+ "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.
" +
+ "This function will automatically set you to start taking a course at a university. If you are already " +
+ "in the middle of some 'working' action (such as working at a company, for a faction, or on a program), " +
+ "then running this function will automatically cancel that action and give you your earnings.
" +
+ "The first argument must be a string with the name of the university. The names are NOT case-sensitive. " +
+ "Note that you must be in the correct city for whatever university you specify. The three universities are:
" +
+ "Summit University Rothman University ZB Institute of Technology
" +
+ "The second argument must be a string with the name of the course you are taking. These names are NOT case-sensitive. " +
+ "The available courses are:
" +
+ "The cost and experience gains for all of these universities and classes are the same as if you were to manually " +
+ "visit and take these classes.
" +
+ "This function will return true if you successfully start taking the course, and false otherwise.
" +
+ "gymWorkout(gymName, stat) " +
+ "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.
" +
+ "This function will automatically set you to start working out at a gym to train a particular stat. If you are " +
+ "already in the middle of some 'working' action (such as working at a company, for a faction, or on a program), then " +
+ "running this function will automatically cancel that action and give you your earnings.
" +
+ "The first argument must be a string with the name of the gym. The names are NOT case-sensitive. Note that you must " +
+ "be in the correct city for whatever gym you specify. The available gyms are:
" +
+ "The second argument must be a string with the stat you want to work out. These are NOT case-sensitive. " +
+ "The valid stats are:
strength OR str defense OR def dexterity OR dex agility OR agi
" +
+ "The cost and experience gains for all of these gyms are the same as if you were to manually visit these gyms and train " +
+ "This function will return true if you successfully start working out at the gym, and false otherwise.
" +
+ "travelToCity(cityname) " +
+ "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.
" +
+ "This function allows the player to travel to any city. The cost for using this function is the same as the cost for traveling through the Travel Agency.
" +
+ "The argument passed into this must be a string with the name of the city to travel to. Note that this argument IS CASE SENSITIVE. The valid cities are:
" +
+ "Aevum Chongqing Sector-12 New Tokyo Ishima Volhaven
" +
+ "This function will return true if you successfully travel to the specified city and false otherwise.
" +
+ "purchaseTor() " +
+ "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.
" +
+ "This function allows you to automatically purchase a TOR router. The cost for purchasing a TOR router using this " +
+ "function is the same as if you were to manually purchase one.
" +
+ "This function will return true if it successfully purchase a TOR router and false otherwise.
" +
+ "purchaseProgram(programName) " +
+ "If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to use this function.
" +
+ "This function allows you to automatically purchase programs. You MUST have a TOR router in order to use this function.
" +
+ "The argument passed in must be a string with the name of the program (including the '.exe' extension). This argument is " +
+ "NOT case-sensitive.
Example: " +
+ "purchaseProgram('brutessh.exe');
" +
+ "The cost of purchasing programs using this function is the same as if you were purchasing them through the Dark Web (using " +
+ "the buy Terminal command).
" +
+ "This function will return true if the specified program is purchased, and false otherwise.
" +
+ "getStats() If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to run this " +
+ "function.
Returns an object with the Player's stats. The object has the following properties:
" +
+ "isBusy() If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to run this " +
+ "function.
Returns a boolean indicating whether or not the player is currently performing an 'action'. " +
+ "These actions include working for a company/faction, studying at a univeristy, working out at a gym, " +
+ "creating a program, or committing a crime.
" +
+ "stopAction() If you are not in BitNode-4, then you must have Level 1 of Source-File 4 in order to " +
+ "run this function.
This function is used to end whatever 'action' the player is currently performing. The player " +
+ "will receive whatever money/experience/etc. he has earned from that action. The actions that can be stopped with this function " +
+ "are:
" +
+ "-Studying at a university -Working for a company/faction -Creating a program -Committing a Crime
" +
+ "This function will return true if the player's action was ended. It will return false if the player was not " +
+ "performing an action when this function was called.
" +
+ "upgradeHomeRam() " +
+ "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.
" +
+ "This function will upgrade amount of RAM on the player's home computer. The cost is the same as if you were to do it manually.
" +
+ "This function will return true if the player's home computer RAM is successfully upgraded, and false otherwise.
" +
+ "getUpgradeHomeRamCost() " +
+ "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.
" +
+ "Returns the cost of upgrading the player's home computer RAM.
" +
+ "workForCompany() " +
+ "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.
" +
+ "This function will automatically set you to start working at the company at which you are employed. If you are already " +
+ "in the middle of some 'working' action (such as working for a faction, training at a gym, or creating a program), then " +
+ "running this function will automatically cancel that action and give you your earnings.
" +
+ "This function will return true if the player starts working, and false otherwise.
" +
+ "applyToCompany(companyName, field) " +
+ "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.
" +
+ "This function will automatically try to apply to the specified company for a position in the specified field. This " +
+ "function can also be used to apply for promotions by specifying the company and field you are already employed at.
" +
+ "The first argument must be a string with the name of the company. This argument IS CASE-SENSITIVE. The second argument must " +
+ "be a string representing the 'field' to which you want to apply. This second argument is NOT case-sensitive. Valid values for " +
+ "the second argument are:
" +
+ "software software consultant it security engineer network engineer business business consultant " +
+ "security agent employee part-time employee waiter part-time waiter
" +
+ "This function will return true if you successfully get a job/promotion, and false otherwise. Note " +
+ "that if you are trying to use this function to apply for a promotion and you don't get one, it will return false.
" +
+ "getCompanyRep(companyName) " +
+ "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.
" +
+ "This function will return the amount of reputation you have at the specified company. If the company passed in as " +
+ "an argument is invalid, -1 will be returned.
" +
+ "The argument passed in must be a string with the name of the company. This argument IS CASE-SENSITIVE.
" +
+ "checkFactionInvitations() " +
+ "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.
" +
+ "Returns an array with the name of all Factions you currently have oustanding invitations from.
" +
+ "joinFaction(name) " +
+ "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.
" +
+ "This function will automatically accept an invitation from a faction and join it.
" +
+ "The argument must be a string with the name of the faction. This name IS CASE-SENSITIVE.
" +
+ "workForFaction(factionName, workType) " +
+ "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.
" +
+ "This function will automatically set you to start working for the specified Faction. Obviously, you " +
+ "must be a member of the Faction or else this function will fail. If you are already in the middle of " +
+ "some 'working' action (such as working for a company, training at a gym, or creating a program), then running " +
+ "this function will automatically cancel that action and give you your earnings.
" +
+ "The first argument must be a string with the name of the faction. This argument IS CASE-SENSITIVE. The second argument " +
+ "must be a string with the type of work you want to perform for the faction. The valid values for this argument are:
" +
+ " hacking/hacking contracts/hackingcontracts field/fieldwork/field work security/securitywork/security work
" +
+ "This function will return true if you successfully start working for the specified faction, and false otherwise.
" +
+ "getFactionRep(factionName) " +
+ "If you are not in BitNode-4, then you must have Level 2 of Source-File 4 in order to use this function.
" +
+ "This function returns the amount of reputation you have for the specified Faction. The argument must be a " +
+ "string with the name of the Faction. The argument IS CASE-SENSITIVE.
" +
+ "createProgram(programName) " +
+ "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.
" +
+ "This function will automatically set you to start working on creating the specified program. If you are already in " +
+ "the middle of some 'working' action (such as working for a company, training at a gym, or taking a course), then " +
+ "running this function will automatically cancel that action and give you your earnings.
" +
+ "The argument passed in must be a string designating the name of the program. This argument is NOT case-sensitive.
" +
+ "Example:
createProgram('relaysmtp.exe');
" +
+ "Note that creating a program using this function has the same hacking level requirements as it normally would. These level requirements are:
" +
+ "This function returns true if you successfully start working on the specified program, and false otherwise.
" +
+ "commitCrime(crime) " +
+ "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.
" +
+ "This function is used to automatically attempt to commit crimes. If you are already in the middle of some 'working' " +
+ "action (such as working for a company or training at a gym), then running this function will automatically cancel " +
+ "that action and give you your earnings.
" +
+ "The function takes a string that specifies what crime to attempt. This argument is not case-sensitive and is fairly " +
+ "lenient in terms of what inputs it accepts. Here is a list of valid inputs for all of the crimes:
" +
+ "shoplift, rob store, mug, larceny, deal drugs, bond forgery, traffick arms, homicide, grand theft auto, " +
+ "kidnap, assassinate, heist
" +
+ "Crimes committed using this function will have all of their earnings halved (this applies for both money and experience!)
" +
+ "This function returns the number of seconds it takes to attempt the specified crime (e.g It takes 60 seconds to attempt " +
+ "the 'Rob Store' crime, so running commitCrime('rob store') will return 60). Warning: I do not recommend using the time " +
+ "returned from this function to try and schedule your crime attempts. Instead, I would use the isBusy() Singularity function " +
+ "to check whether you have finished attempting a crime. This is because although the game sets a certain crime to be X amount of seconds, " +
+ "there is no guarantee that your browser will follow that time limit.
" +
+ "getCrimeChance(crime) If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to " +
+ "use this function.
" +
+ "This function returns your chance of success at commiting the specified crime. The chance is returned as a decimal " +
+ "(i.e. 60% would be returned as 0.6). The argument for this function is a string. It is not case-sensitive and is fairly " +
+ "lenient in terms of what inputs it accepts. Check the documentation for the commitCrime() Singularity Function to see " +
+ "examples of valid inputs.
" +
+ "getOwnedAugmentations(purchased=false) " +
+ "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.
" +
+ "This function returns an array of the names of all Augmentations you own as strings. It takes a single optional " +
+ "boolean argument that specifies whether the returned array should include Augmentations you have purchased " +
+ "but not yet installed. If it is true, then the returned array will include these Augmentations. By default, " +
+ "this argument is false.
" +
+ "getAugmentationsFromFaction(facName) " +
+ "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.
" +
+ "Returns an array containing the names (as strings) of all Augmentations that are available from the specified faction. " +
+ "The argument must be a string with the faction's name. This argument is case-sensitive.
" +
+ "getAugmentationCost(augName) " +
+ "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.
" +
+ "This function returns an array with two elements that gives the cost for the specified Augmentation" +
+ ". The first element in the returned array is the reputation requirement of the Augmentation, and the second element " +
+ "is the money cost.
" +
+ "The argument passed in must be a string with the name of the Augmentation. This argument IS CASE-SENSITIVE. " +
+ "If an invalid Augmentation name is passed in, this function will return the array [-1, -1].
" +
+ "purchaseAugmentation(factionName, augName) " +
+ "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.
" +
+ "This function will try to purchase the specified Augmentation through the given Faction.
" +
+ "The two arguments must be strings specifying the name of the Faction and Augmentation, respectively. These arguments are both CASE-SENSITIVE.
" +
+ "This function will return true if the Augmentation is successfully purchased, and false otherwise.
" +
+ "installAugmentations(cbScript) " +
+ "If you are not in BitNode-4, then you must have Level 3 of Source-File 4 in order to use this function.
" +
+ "This function will automatically install your Augmentations, resetting the game as usual.
" +
+ "It will return true if successful, and false otherwise.
" +
+ "This function takes a single optional parameter that specifies a callback script. This is " +
+ "a script that will automatically be run after Augmentations are installed (after the reset). " +
+ "This script will be run with no arguments and 1 thread. It must be located on your home computer. This argument, if used, " +
+ "must be a string with the name of the script.",
+
+ TutorialTravelingText:"There are six major cities in the world that you are able to travel to:
" +
+ "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:
" +
+ "This will upgrade your RAM from " + currentRam + "GB to " + newRam + "GB.
" +
+ "This will cost $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_16__["formatNumber"])(cost, 2));
+ });
+
+ purchaseHomeCores.addEventListener("click", function() {
+ var currentCores = _Player_js__WEBPACK_IMPORTED_MODULE_8__["Player"].getHomeComputer().cpuCores;
+ if (currentCores >= 8) {return;} //Max of 8 cores
+
+ //Cost of purchasing another cost is found by indexing this array with number of current cores
+ var cost = [0,
+ 10000000000, //1->2 Cores - 10 bn
+ 250000000000, //2->3 Cores - 250 bn
+ 5000000000000, //3->4 Cores - 5 trillion
+ 100000000000000, //4->5 Cores - 100 trillion
+ 1000000000000000, //5->6 Cores - 1 quadrillion
+ 20000000000000000, //6->7 Cores - 20 quadrillion
+ 200000000000000000]; //7->8 Cores - 200 quadrillion
+ cost = cost[currentCores];
+ var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_17__["yesNoBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_17__["yesNoBoxGetNoButton"])();
+ yesBtn.innerHTML = "Purchase"; noBtn.innerHTML = "Cancel";
+ yesBtn.addEventListener("click", ()=>{
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_8__["Player"].money.lt(cost)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_12__["dialogBoxCreate"])("You do not have enough mone to purchase an additional CPU Core for your home computer!");
+ } else {
+ _Player_js__WEBPACK_IMPORTED_MODULE_8__["Player"].loseMoney(cost);
+ _Player_js__WEBPACK_IMPORTED_MODULE_8__["Player"].getHomeComputer().cpuCores++;
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_12__["dialogBoxCreate"])("You purchased an additional CPU Core for your home computer! It now has " +
+ _Player_js__WEBPACK_IMPORTED_MODULE_8__["Player"].getHomeComputer().cpuCores + " cores.");
+ }
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_17__["yesNoBoxClose"])();
+ });
+ noBtn.addEventListener("click", ()=>{
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_17__["yesNoBoxClose"])();
+ });
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_17__["yesNoBoxCreate"])("Would you like to purchase an additional CPU Core for your home computer? Each CPU Core " +
+ "lets you start with an additional Core Node in Hacking Missions.
",
+ }));
+
+ Engine.Display.characterInfo.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("p", {
+ width:"60%", fontSize: "13px", marginLeft:"4%",
+ innerHTML:_BitNode_js__WEBPACK_IMPORTED_MODULE_8__["BitNodes"][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_js__WEBPACK_IMPORTED_MODULE_26__["Player"].city;
+ var cityDesc = document.getElementById("world-city-desc"); //TODO
+ switch(_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].city) {
+ case _Location_js__WEBPACK_IMPORTED_MODULE_17__["Locations"].Aevum:
+ Engine.aevumLocationsList.style.display = "inline";
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_17__["Locations"].Chongqing:
+ Engine.chongqingLocationsList.style.display = "inline";
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_17__["Locations"].Sector12:
+ Engine.sector12LocationsList.style.display = "inline";
+
+ //City hall only in BitNode-3/with Source-File 3
+ if ((_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].bitNodeN === 3 || _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_24__["hasCorporationSF"]) && _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].bitNodeN !== 8) {
+ document.getElementById("sector12-cityhall-li").style.display = "block";
+ } else {
+ document.getElementById("sector12-cityhall-li").style.display = "none";
+ }
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_17__["Locations"].NewTokyo:
+ Engine.newTokyoLocationsList.style.display = "inline";
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_17__["Locations"].Ishima:
+ Engine.ishimaLocationsList.style.display = "inline";
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_17__["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)
+ var genericLocationsList = document.getElementById("generic-locations-list");
+ genericLocationsList.style.display = "inline";
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["removeChildrenFromElement"])(genericLocationsList);
+ var li = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("li");
+ li.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ innerText:"World Stock Exchange", class:"a-link-button",
+ clickListener:()=>{
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_17__["Locations"].WorldStockExchange;
+ Engine.loadStockMarketContent();
+ return false;
+ }
+ }));
+ genericLocationsList.appendChild(li);
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].corporation instanceof _CompanyManagement_js__WEBPACK_IMPORTED_MODULE_12__["Corporation"] && document.getElementById("location-corporation-button") == null) {
+ var li = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("li");
+ li.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ innerText:_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].corporation.name, id:"location-corporation-button",
+ class:"a-link-button",
+ clickListener:()=>{
+ Engine.loadCorporationContent();
+ return false;
+ }
+ }));
+ genericLocationsList.appendChild(li);
+ }
+ },
+
+ displayFactionsInfo: function() {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["removeChildrenFromElement"])(Engine.Display.factionsContent);
+
+ //Factions
+ Engine.Display.factionsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("h1", {
+ innerText:"Factions"
+ }));
+ Engine.Display.factionsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("p", {
+ innerText:"Lists all factions you have joined"
+ }));
+ var factionsList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("ul");
+ Engine.Display.factionsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("br"));
+
+ //Add a button for each faction you are a member of
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].factions.length; ++i) {
+ (function () {
+ var factionName = _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].factions[i];
+
+ factionsList.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", innerText:factionName, padding:"4px", margin:"4px",
+ display:"inline-block",
+ clickListener:()=>{
+ Engine.loadFactionContent();
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_15__["displayFactionContent"])(factionName);
+ return false;
+ }
+ }));
+ factionsList.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("br"));
+ }()); //Immediate invocation
+ }
+ Engine.Display.factionsContent.appendChild(factionsList);
+ Engine.Display.factionsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("br"));
+
+ //Invited Factions
+ Engine.Display.factionsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("h1", {
+ innerText:"Outstanding Faction Invitations"
+ }));
+ Engine.Display.factionsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("ul");
+
+ //Add a button to accept for each faction you have invitiations for
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].factionInvitations.length; ++i) {
+ (function () {
+ var factionName = _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].factionInvitations[i];
+
+ var item = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("li", {padding:"6px", margin:"6px"});
+ item.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("p", {
+ innerText:factionName, display:"inline", margin:"4px", padding:"4px"
+ }));
+ item.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ innerText:"Accept Faction Invitation",
+ class:"a-link-button", display:"inline", margin:"4px", padding:"4px",
+ clickListener:()=>{
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_15__["joinFaction"])(_Faction_js__WEBPACK_IMPORTED_MODULE_15__["Factions"][factionName]);
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].factionInvitations.length; ++i) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].factionInvitations[i] == factionName) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].factionInvitations.splice(i, 1);
+ break;
+ }
+ }
+ 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_js__WEBPACK_IMPORTED_MODULE_26__["Player"].lastUpdate = _thisUpdate - offset;
+ Engine.updateGame(diff);
+ }
+
+ window.requestAnimationFrame(Engine.idleTimer);
+ },
+
+ updateGame: function(numCycles = 1) {
+ //Update total playtime
+ var time = numCycles * Engine._idleSpeed;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].totalPlaytime == null) {_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].totalPlaytime = 0;}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].playtimeSinceLastAug == null) {_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].playtimeSinceLastAug = 0;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].totalPlaytime += time;
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].playtimeSinceLastAug += time;
+
+ //Start Manual hack
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].startAction == true) {
+ Engine._totalActionTime = _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].actionTime;
+ Engine._actionTimeLeft = _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].actionTime;
+ Engine._actionInProgress = true;
+ Engine._actionProgressBarCount = 1;
+ Engine._actionProgressStr = "[ ]";
+ Engine._actionTimeStr = "Time left: ";
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].startAction = false;
+ }
+
+ //Working
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].isWorking) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeFaction) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workForFaction(numCycles);
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCreateProgram) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].createProgramWork(numCycles);
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeStudyClass) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].takeClass(numCycles);
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCrime) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].commitCrime(numCycles);
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCompanyPartTime) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workPartTime(numCycles);
+ } else {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].work(numCycles);
+ }
+ }
+
+ //Gang, if applicable
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].bitNodeN == 2 && _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].inGang()) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].gang.process(numCycles);
+ }
+
+ //Mission
+ if (_Missions_js__WEBPACK_IMPORTED_MODULE_23__["inMission"] && _Missions_js__WEBPACK_IMPORTED_MODULE_23__["currMission"]) {
+ _Missions_js__WEBPACK_IMPORTED_MODULE_23__["currMission"].process(numCycles);
+ }
+
+ //Corporation
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].corporation instanceof _CompanyManagement_js__WEBPACK_IMPORTED_MODULE_12__["Corporation"]) {
+ //Stores cycles in a "buffer". Processed separately using Engine Counters
+ //This is to avoid constant DOM redraws when Corporation is catching up
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].corporation.storeCycles(numCycles);
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_9__["Bladeburner"]) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].bladeburner.storeCycles(numCycles);
+ }
+
+ //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_js__WEBPACK_IMPORTED_MODULE_25__["updateOnlineScriptTimes"])(numCycles);
+
+ //Hacknet Nodes
+ Object(_HacknetNode_js__WEBPACK_IMPORTED_MODULE_19__["processAllHacknetNodeEarnings"])(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, //Update displays such as Active Scripts display and character display
+ updateDisplaysMed: 9,
+ updateDisplaysLong: 15,
+ 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,
+ stockTick: 30, //Update stock prices
+ sCr: 1500,
+ mechanicProcess: 5, //Processes certain mechanics (Corporation, Bladeburner)
+ },
+
+ 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_js__WEBPACK_IMPORTED_MODULE_29__["saveObject"].saveGame(indexedDb);
+ if (_Settings_js__WEBPACK_IMPORTED_MODULE_32__["Settings"].AutosaveInterval == null) {
+ _Settings_js__WEBPACK_IMPORTED_MODULE_32__["Settings"].AutosaveInterval = 60;
+ }
+ if (_Settings_js__WEBPACK_IMPORTED_MODULE_32__["Settings"].AutosaveInterval === 0) {
+ Engine.Counters.autoSaveCounter = Infinity;
+ } else {
+ Engine.Counters.autoSaveCounter = _Settings_js__WEBPACK_IMPORTED_MODULE_32__["Settings"].AutosaveInterval * 5;
+ }
+ }
+
+ if (Engine.Counters.updateSkillLevelsCounter <= 0) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].updateSkillLevels();
+ Engine.Counters.updateSkillLevelsCounter = 10;
+ }
+
+ if (Engine.Counters.updateDisplays <= 0) {
+ Engine.displayCharacterOverviewInfo();
+ if (Engine.currentPage == Engine.Page.CharacterInfo) {
+ Engine.displayCharacterInfo();
+ } else if (Engine.currentPage == Engine.Page.HacknetNodes) {
+ Object(_HacknetNode_js__WEBPACK_IMPORTED_MODULE_19__["updateHacknetNodesContent"])();
+ } else if (Engine.currentPage == Engine.Page.CreateProgram) {
+ Object(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_14__["displayCreateProgramContent"])();
+ }
+
+ if (_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_5__["logBoxOpened"]) {
+ Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_5__["logBoxUpdateText"])();
+ }
+
+ Engine.Counters.updateDisplays = 3;
+ }
+
+ if (Engine.Counters.updateDisplaysMed <= 0) {
+ if (Engine.currentPage == Engine.Page.ActiveScripts) {
+ Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_6__["updateActiveScriptsItems"])();
+ } else if (Engine.currentPage === Engine.Page.Corporation) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].corporation.updateUIContent();
+ }
+ Engine.Counters.updateDisplaysMed = 9;
+ }
+
+ if (Engine.Counters.updateDisplaysLong <= 0) {
+ if (Engine.currentPage === Engine.Page.Gang) {
+ Object(_Gang_js__WEBPACK_IMPORTED_MODULE_18__["updateGangContent"])();
+ } else if (Engine.currentPage === Engine.Page.ScriptEditor) {
+ Object(_Script_js__WEBPACK_IMPORTED_MODULE_30__["updateScriptEditorContent"])();
+ }
+ Engine.Counters.updateDisplaysLong = 15;
+ }
+
+ if (Engine.Counters.createProgramNotifications <= 0) {
+ var num = Object(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_14__["getNumAvailableCreateProgram"])();
+ 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_js__WEBPACK_IMPORTED_MODULE_26__["Player"].checkForFactionInvitations();
+ if (invitedFactions.length > 0) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].firstFacInvRecvd === false) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].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_js__WEBPACK_IMPORTED_MODULE_15__["inviteToFaction"])(randFaction);
+ }
+ Engine.Counters.checkFactionInvitations = 100;
+ }
+
+ if (Engine.Counters.passiveFactionGrowth <= 0) {
+ var adjustedCycles = Math.floor((600 - Engine.Counters.passiveFactionGrowth));
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_15__["processPassiveFactionRepGain"])(adjustedCycles);
+ Engine.Counters.passiveFactionGrowth = 600;
+ }
+
+ if (Engine.Counters.messages <= 0) {
+ Object(_Message_js__WEBPACK_IMPORTED_MODULE_22__["checkForMessagesToSend"])();
+ if (_Augmentations_js__WEBPACK_IMPORTED_MODULE_7__["Augmentations"][_Augmentations_js__WEBPACK_IMPORTED_MODULE_7__["AugmentationNames"].TheRedPill].owned) {
+ Engine.Counters.messages = 4500; //15 minutes for Red pill message
+ } else {
+ Engine.Counters.messages = 150;
+ }
+ }
+
+ if (Engine.Counters.stockTick <= 0) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hasWseAccount) {
+ Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_35__["updateStockPrices"])();
+ }
+ Engine.Counters.stockTick = 30;
+ }
+
+ if (Engine.Counters.sCr <= 0) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hasWseAccount) {
+ Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_35__["stockMarketCycle"])();
+ }
+ Engine.Counters.sCr = 1500;
+ }
+
+ if (Engine.Counters.mechanicProcess <= 0) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].corporation instanceof _CompanyManagement_js__WEBPACK_IMPORTED_MODULE_12__["Corporation"]) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].corporation.process();
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_9__["Bladeburner"]) {
+ try {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].bladeburner.process();
+ } catch(e) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["exceptionAlert"])("Exception caught in Bladeburner.process(): " + e);
+ }
+
+ }
+ Engine.Counters.mechanicProcess = 5;
+ }
+ },
+
+ /* 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 = Engine._actionProgressStr.replaceAt(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_js__WEBPACK_IMPORTED_MODULE_36__["Terminal"].finishAction();
+ }
+ },
+
+ _prevTimeout: null,
+ createStatusText: function(txt) {
+ if (Engine._prevTimeout != null) {
+ clearTimeout(Engine._prevTimeout);
+ Engine._prevTimeout = null;
+ }
+ var statusText = document.getElementById("status-text")
+ statusText.style.display = "inline-block";
+ statusText.setAttribute("class", "status-text");
+ statusText.innerHTML = txt;
+ Engine._prevTimeout = setTimeout(function() {
+ statusText.style.display = "none";
+ statusText.removeAttribute("class");
+ statusText.innerHTML = "";
+ }, 3000);
+ },
+
+ removeLoadingScreen: function() {
+ var loader = document.getElementById("loader");
+ if (!loader) {return;}
+ while(loader.firstChild) {
+ loader.removeChild(loader.firstChild);
+ }
+ loader.parentNode.removeChild(loader);
+ document.getElementById("entire-game-container").style.visibility = "visible";
+ },
+
+ //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 tutorial = document.getElementById("tutorial-tab");
+ var options = document.getElementById("options-tab");
+
+ //Load game from save or create new game
+ if (Object(_SaveObject_js__WEBPACK_IMPORTED_MODULE_29__["loadGame"])(saveString)) {
+ console.log("Loaded game from save");
+ Object(_BitNode_js__WEBPACK_IMPORTED_MODULE_8__["initBitNodes"])();
+ Object(_BitNode_js__WEBPACK_IMPORTED_MODULE_8__["initBitNodeMultipliers"])();
+ Object(_SourceFile_js__WEBPACK_IMPORTED_MODULE_33__["initSourceFiles"])();
+ Engine.setDisplayElements(); //Sets variables for important DOM elements
+ Engine.init(); //Initialize buttons, work, etc.
+ _Company_js__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"].init();
+ Object(_Augmentations_js__WEBPACK_IMPORTED_MODULE_7__["initAugmentations"])(); //Also calls Player.reapplyAllAugmentations()
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].reapplyAllSourceFiles();
+ Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_35__["initStockSymbols"])();
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].hasWseAccount) {
+ Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_35__["initSymbolToStockMap"])();
+ }
+ Object(_Literature_js__WEBPACK_IMPORTED_MODULE_21__["initLiterature"])();
+ Object(_NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_24__["initSingularitySFFlags"])();
+
+ console.log(_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].intelligence_exp);
+
+ //Calculate the number of cycles have elapsed while offline
+ Engine._lastUpdate = new Date().getTime();
+ var lastUpdate = _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].lastUpdate;
+ var numCyclesOffline = Math.floor((Engine._lastUpdate - lastUpdate) / Engine._idleSpeed);
+
+ /* Process offline progress */
+ var offlineProductionFromScripts = Object(_Script_js__WEBPACK_IMPORTED_MODULE_30__["loadAllRunningScripts"])(); //This also takes care of offline production for those scripts
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].isWorking) {
+ console.log("work() called in load() for " + numCyclesOffline * Engine._idleSpeed + " milliseconds");
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeFaction) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workForFaction(numCyclesOffline);
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCreateProgram) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].createProgramWork(numCyclesOffline);
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeStudyClass) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].takeClass(numCyclesOffline);
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCrime) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].commitCrime(numCyclesOffline);
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCompanyPartTime) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workPartTime(numCyclesOffline);
+ } else {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].work(numCyclesOffline);
+ }
+ }
+
+ //Hacknet Nodes offline progress
+ var offlineProductionFromHacknetNodes = Object(_HacknetNode_js__WEBPACK_IMPORTED_MODULE_19__["processAllHacknetNodeEarnings"])(numCyclesOffline);
+
+ //Passive faction rep gain offline
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_15__["processPassiveFactionRepGain"])(numCyclesOffline);
+
+ //Gang progress for BitNode 2
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].bitNodeN != null && _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].bitNodeN === 2 && _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].inGang()) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].gang.process(numCyclesOffline);
+ }
+
+ //Bladeburner offline progress
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].bladeburner instanceof _Bladeburner_js__WEBPACK_IMPORTED_MODULE_9__["Bladeburner"]) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].bladeburner.storeCycles(numCyclesOffline);
+ }
+
+ //Update total playtime
+ var time = numCyclesOffline * Engine._idleSpeed;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].totalPlaytime == null) {_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].totalPlaytime = 0;}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].playtimeSinceLastAug == null) {_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].playtimeSinceLastAug = 0;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].totalPlaytime += time;
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].playtimeSinceLastAug += time;
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].lastUpdate = Engine._lastUpdate;
+ Engine.start(); //Run main game loop and Scripts loop
+ Engine.removeLoadingScreen();
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_0__["dialogBoxCreate"])("While you were offline, your scripts generated $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_4__["formatNumber"])(offlineProductionFromScripts, 2) + " and your Hacknet Nodes generated $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_4__["formatNumber"])(offlineProductionFromHacknetNodes, 2));
+ //Close main menu accordions for loaded game
+ var visibleMenuTabs = [terminal, createScript, activeScripts, stats,
+ hacknetnodes, city, tutorial, options];
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].firstFacInvRecvd) {visibleMenuTabs.push(factions);}
+ else {factions.style.display = "none";}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].firstAugPurchased) {visibleMenuTabs.push(augmentations);}
+ else {augmentations.style.display = "none";}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].firstJobRecvd) {visibleMenuTabs.push(job);}
+ else {job.style.display = "none";}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].firstTimeTraveled) {visibleMenuTabs.push(travel);}
+ else {travel.style.display = "none";}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].firstProgramAvailable) {visibleMenuTabs.push(createProgram);}
+ else {createProgram.style.display = "none";}
+
+ Engine.closeMainMenuHeader(visibleMenuTabs);
+ } else {
+ //No save found, start new game
+ console.log("Initializing new game");
+ Object(_BitNode_js__WEBPACK_IMPORTED_MODULE_8__["initBitNodes"])();
+ Object(_BitNode_js__WEBPACK_IMPORTED_MODULE_8__["initBitNodeMultipliers"])();
+ Object(_SourceFile_js__WEBPACK_IMPORTED_MODULE_33__["initSourceFiles"])();
+ Object(_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_34__["initSpecialServerIps"])();
+ Engine.setDisplayElements(); //Sets variables for important DOM elements
+ Engine.start(); //Run main game loop and Scripts loop
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].init();
+ Object(_Server_js__WEBPACK_IMPORTED_MODULE_31__["initForeignServers"])();
+ Object(_Company_js__WEBPACK_IMPORTED_MODULE_11__["initCompanies"])();
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_15__["initFactions"])();
+ _Company_js__WEBPACK_IMPORTED_MODULE_11__["CompanyPositions"].init();
+ Object(_Augmentations_js__WEBPACK_IMPORTED_MODULE_7__["initAugmentations"])();
+ Object(_Message_js__WEBPACK_IMPORTED_MODULE_22__["initMessages"])();
+ Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_35__["initStockSymbols"])();
+ Object(_Literature_js__WEBPACK_IMPORTED_MODULE_21__["initLiterature"])();
+ Object(_NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_24__["initSingularitySFFlags"])();
+
+ //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";
+ travel.style.display = "none";
+ createProgram.style.display = "none";
+
+ Engine.openMainMenuHeader(
+ [terminal, createScript, activeScripts, stats,
+ hacknetnodes, city,
+ tutorial, options]
+ );
+
+ //Start interactive tutorial
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_20__["iTutorialStart"])();
+ Engine.removeLoadingScreen();
+ }
+ //Initialize labels on game settings
+ Object(_Settings_js__WEBPACK_IMPORTED_MODULE_32__["setSettingsLabels"])();
+ Object(_Script_js__WEBPACK_IMPORTED_MODULE_30__["scriptEditorInit"])();
+ _Terminal_js__WEBPACK_IMPORTED_MODULE_36__["Terminal"].resetTerminalInput();
+ },
+
+ setDisplayElements: function() {
+ //Content elements
+ Engine.Display.terminalContent = document.getElementById("terminal-container");
+ Engine.currentPage = Engine.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_js__WEBPACK_IMPORTED_MODULE_17__["initLocationButtons"])();
+
+ //Tutorial buttons
+ Engine.Clickables.tutorialNetworkingButton = document.getElementById("tutorial-networking-link");
+ Engine.Clickables.tutorialNetworkingButton.addEventListener("click", function() {
+ Engine.displayTutorialPage(_Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].TutorialNetworkingText);
+ });
+
+ Engine.Clickables.tutorialHackingButton = document.getElementById("tutorial-hacking-link");
+ Engine.Clickables.tutorialHackingButton.addEventListener("click", function() {
+ Engine.displayTutorialPage(_Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].TutorialHackingText);
+ });
+
+ Engine.Clickables.tutorialScriptsButton = document.getElementById("tutorial-scripts-link");
+ Engine.Clickables.tutorialScriptsButton.addEventListener("click", function() {
+ Engine.displayTutorialPage(_Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].TutorialScriptsText);
+ });
+
+ Engine.Clickables.tutorialNetscriptButton = document.getElementById("tutorial-netscript-link");
+ Engine.Clickables.tutorialNetscriptButton.addEventListener("click", function() {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].bitNodeN === 4 || _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_24__["hasSingularitySF"]) {
+ Engine.displayTutorialPage(_Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].TutorialNetscriptText + _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].TutorialSingularityFunctionsText);
+ } else {
+ Engine.displayTutorialPage(_Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].TutorialNetscriptText);
+ }
+
+ });
+
+ Engine.Clickables.tutorialTravelingButton = document.getElementById("tutorial-traveling-link");
+ Engine.Clickables.tutorialTravelingButton.addEventListener("click", function() {
+ Engine.displayTutorialPage(_Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].TutorialTravelingText);
+ });
+
+ Engine.Clickables.tutorialCompaniesButton = document.getElementById("tutorial-jobs-link");
+ Engine.Clickables.tutorialCompaniesButton.addEventListener("click", function() {
+ Engine.displayTutorialPage(_Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].TutorialCompaniesText);
+ });
+
+ Engine.Clickables.tutorialFactionsButton = document.getElementById("tutorial-factions-link");
+ Engine.Clickables.tutorialFactionsButton.addEventListener("click", function() {
+ Engine.displayTutorialPage(_Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].TutorialFactionsText);
+ });
+
+ Engine.Clickables.tutorialAugmentationsButton = document.getElementById("tutorial-augmentations-link");
+ Engine.Clickables.tutorialAugmentationsButton.addEventListener("click", function() {
+ Engine.displayTutorialPage(_Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].TutorialAugmentationsText);
+ });
+
+ Engine.Clickables.tutorialBackButton = document.getElementById("tutorial-back-button");
+ Engine.Clickables.tutorialBackButton.addEventListener("click", function() {
+ Engine.displayTutorialContent();
+ });
+
+ //If DarkWeb already purchased, disable the button
+ if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_34__["SpecialServerIps"].hasOwnProperty("Darkweb Server")) {
+ document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button-inactive");
+ }
+ },
+
+ /* Initialization */
+ init: function() {
+ //Import game link
+ document.getElementById("import-game-link").onclick = function() {
+ _SaveObject_js__WEBPACK_IMPORTED_MODULE_29__["saveObject"].importGame();
+ };
+
+ //Main menu accordions
+ var hackingHdr = document.getElementById("hacking-menu-header");
+ var characterHdr = document.getElementById("character-menu-header");
+ var worldHdr = document.getElementById("world-menu-header");
+ var helpHdr = document.getElementById("help-menu-header");
+
+ hackingHdr.onclick = function() {
+ var terminal = document.getElementById("terminal-tab");
+ var terminalLink = document.getElementById("terminal-menu-link");
+ var createScript = document.getElementById("create-script-tab");
+ var createScriptLink = document.getElementById("create-script-menu-link");
+ var activeScripts = document.getElementById("active-scripts-tab");
+ var activeScriptsLink = document.getElementById("active-scripts-menu-link");
+ var createProgram = document.getElementById("create-program-tab");
+ var createProgramLink = document.getElementById("create-program-menu-link");
+ var createProgramNot = document.getElementById("create-program-notification");
+ this.classList.toggle("opened");
+ if (terminal.style.maxHeight) {
+ Engine.toggleMainMenuHeader(false,
+ [terminal, createScript, activeScripts, createProgram],
+ [terminalLink, createScriptLink, activeScriptsLink, createProgramLink]
+ );
+
+ createProgramNot.style.display = "none";
+ } else {
+ Engine.toggleMainMenuHeader(true,
+ [terminal, createScript, activeScripts, createProgram],
+ [terminalLink, createScriptLink, activeScriptsLink, createProgramLink]
+ );
+
+ createProgramNot.style.display = "block"
+ }
+ }
+
+ characterHdr.onclick = function() {
+ var stats = document.getElementById("stats-tab");
+ var statsLink = document.getElementById("stats-menu-link");
+ var factions = document.getElementById("factions-tab");
+ var factionsLink = document.getElementById("factions-menu-link");
+ var augmentations = document.getElementById("augmentations-tab");
+ var augmentationsLink = document.getElementById("augmentations-menu-link");
+ var hacknetnodes = document.getElementById("hacknet-nodes-tab");
+ var hacknetnodesLink = document.getElementById("hacknet-nodes-menu-link");
+ this.classList.toggle("opened");
+ if (stats.style.maxHeight) {
+ Engine.toggleMainMenuHeader(false,
+ [stats, factions, augmentations, hacknetnodes],
+ [statsLink, factionsLink, augmentationsLink, hacknetnodesLink]
+ );
+ } else {
+ Engine.toggleMainMenuHeader(true,
+ [stats, factions, augmentations, hacknetnodes],
+ [statsLink, factionsLink, augmentationsLink, hacknetnodesLink]
+ );
+ }
+ }
+
+ worldHdr.onclick = function() {
+ var city = document.getElementById("city-tab");
+ var cityLink = document.getElementById("city-menu-link");
+ var travel = document.getElementById("travel-tab");
+ var travelLink = document.getElementById("travel-menu-link");
+ var job = document.getElementById("job-tab");
+ var jobLink = document.getElementById("job-menu-link");
+ this.classList.toggle("opened");
+ if (city.style.maxHeight) {
+ Engine.toggleMainMenuHeader(false,
+ [city, travel, job],
+ [cityLink, travelLink, jobLink]
+ );
+ } else {
+ Engine.toggleMainMenuHeader(true,
+ [city, travel, job],
+ [cityLink, travelLink, jobLink]
+ );
+ }
+ }
+
+ helpHdr.onclick = function() {
+ var tutorial = document.getElementById("tutorial-tab");
+ var tutorialLink = document.getElementById("tutorial-menu-link");
+ var options = document.getElementById("options-tab");
+ var optionsLink = document.getElementById("options-menu-link");
+ this.classList.toggle("opened");
+ if (tutorial.style.maxHeight) {
+ Engine.toggleMainMenuHeader(false,
+ [tutorial, options],
+ [tutorialLink, optionsLink]
+ );
+ } else {
+ Engine.toggleMainMenuHeader(true,
+ [tutorial, options],
+ [tutorialLink, optionsLink]
+ );
+ }
+ }
+
+ //Main menu buttons and content
+ Engine.Clickables.terminalMainMenuButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["clearEventListeners"])("terminal-menu-link");
+ Engine.Clickables.terminalMainMenuButton.addEventListener("click", function() {
+ Engine.loadTerminalContent();
+ return false;
+ });
+
+ Engine.Clickables.characterMainMenuButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["clearEventListeners"])("stats-menu-link");
+ Engine.Clickables.characterMainMenuButton.addEventListener("click", function() {
+ Engine.loadCharacterContent();
+ return false;
+ });
+
+ Engine.Clickables.scriptEditorMainMenuButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["clearEventListeners"])("create-script-menu-link");
+ Engine.Clickables.scriptEditorMainMenuButton.addEventListener("click", function() {
+ Engine.loadScriptEditorContent();
+ return false;
+ });
+
+ Engine.Clickables.activeScriptsMainMenuButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["clearEventListeners"])("active-scripts-menu-link");
+ Engine.Clickables.activeScriptsMainMenuButton.addEventListener("click", function() {
+ Engine.loadActiveScriptsContent();
+ return false;
+ });
+
+ Engine.Clickables.hacknetNodesMainMenuButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["clearEventListeners"])("hacknet-nodes-menu-link");
+ Engine.Clickables.hacknetNodesMainMenuButton.addEventListener("click", function() {
+ Engine.loadHacknetNodesContent();
+ return false;
+ });
+
+ Engine.Clickables.worldMainMenuButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["clearEventListeners"])("city-menu-link");
+ Engine.Clickables.worldMainMenuButton.addEventListener("click", function() {
+ Engine.loadWorldContent();
+ return false;
+ });
+
+ Engine.Clickables.travelMainMenuButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["clearEventListeners"])("travel-menu-link");
+ Engine.Clickables.travelMainMenuButton.addEventListener("click", function() {
+ Engine.loadTravelContent();
+ return false;
+ });
+
+ Engine.Clickables.jobMainMenuButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["clearEventListeners"])("job-menu-link");
+ Engine.Clickables.jobMainMenuButton.addEventListener("click", function() {
+ Engine.loadJobContent();
+ return false;
+ });
+
+
+ Engine.Clickables.createProgramMainMenuButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["clearEventListeners"])("create-program-menu-link");
+ Engine.Clickables.createProgramMainMenuButton.addEventListener("click", function() {
+ Engine.loadCreateProgramContent();
+ return false;
+ });
+
+ Engine.Clickables.factionsMainMenuButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["clearEventListeners"])("factions-menu-link");
+ Engine.Clickables.factionsMainMenuButton.addEventListener("click", function() {
+ Engine.loadFactionsContent();
+ return false;
+ });
+
+ Engine.Clickables.augmentationsMainMenuButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["clearEventListeners"])("augmentations-menu-link");
+ Engine.Clickables.augmentationsMainMenuButton.addEventListener("click", function() {
+ Engine.loadAugmentationsContent();
+ return false;
+ });
+
+ Engine.Clickables.tutorialMainMenuButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["clearEventListeners"])("tutorial-menu-link");
+ Engine.Clickables.tutorialMainMenuButton.addEventListener("click", function() {
+ Engine.loadTutorialContent();
+ 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_js__WEBPACK_IMPORTED_MODULE_29__["saveObject"].saveGame(indexedDb);
+ return false;
+ });
+
+ Engine.Clickables.deleteMainMenuButton = document.getElementById("delete-game-link");
+ Engine.Clickables.deleteMainMenuButton.addEventListener("click", function() {
+ _SaveObject_js__WEBPACK_IMPORTED_MODULE_29__["saveObject"].deleteGame(indexedDb);
+ return false;
+ });
+
+ document.getElementById("export-game-link").addEventListener("click", function() {
+ _SaveObject_js__WEBPACK_IMPORTED_MODULE_29__["saveObject"].exportGame();
+ return false;
+ });
+
+ //Character Overview buttons
+ document.getElementById("character-overview-save-button").addEventListener("click", function() {
+ _SaveObject_js__WEBPACK_IMPORTED_MODULE_29__["saveObject"].saveGame(indexedDb);
+ return false;
+ });
+
+ document.getElementById("character-overview-options-button").addEventListener("click", function() {
+ Object(_utils_GameOptions_js__WEBPACK_IMPORTED_MODULE_1__["gameOptionsBoxOpen"])();
+ return false;
+ });
+
+ //Create Program buttons
+ Object(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_14__["initCreateProgramButtons"])();
+
+ //Message at the top of terminal
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_36__["postNetburnerText"])();
+
+ //Player was working cancel button
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].isWorking) {
+ var cancelButton = document.getElementById("work-in-progress-cancel-button");
+ cancelButton.addEventListener("click", function() {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeFaction) {
+ var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_15__["Factions"][_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].currentWorkFactionName];
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].finishFactionWork(true);
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCreateProgram) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].finishCreateProgramWork(true);
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeStudyClass) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].finishClass();
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCrime) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].finishCrime(true);
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].workType == _Constants_js__WEBPACK_IMPORTED_MODULE_13__["CONSTANTS"].WorkTypeCompanyPartTime) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].finishWorkPartTime();
+ } else {
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].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");
+
+ //DEBUG Delete active Scripts on home
+ document.getElementById("debug-delete-scripts-link").addEventListener("click", function() {
+ console.log("Deleting running scripts on home computer");
+ _Player_js__WEBPACK_IMPORTED_MODULE_26__["Player"].getHomeComputer().runningScripts = [];
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_0__["dialogBoxCreate"])("Forcefully deleted all running scripts on home computer. Please save and refresh page");
+ Object(_utils_GameOptions_js__WEBPACK_IMPORTED_MODULE_1__["gameOptionsBoxClose"])();
+ return false;
+ });
+
+ //DEBUG Soft Reset
+ document.getElementById("debug-soft-reset").addEventListener("click", function() {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_0__["dialogBoxCreate"])("Soft Reset!");
+ Object(_Prestige_js__WEBPACK_IMPORTED_MODULE_27__["prestigeAugmentation"])();
+ Object(_utils_GameOptions_js__WEBPACK_IMPORTED_MODULE_1__["gameOptionsBoxClose"])();
+ return false;
+ });
+ },
+
+ start: function() {
+ //Run main loop
+ Engine.idleTimer();
+
+ //Scripts
+ Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_25__["runScriptsLoop"])();
+ }
+};
+
+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 */ 41)))
+
+/***/ }),
+/* 6 */
+/*!****************************!*\
+ !*** ./utils/DialogBox.js ***!
+ \****************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dialogBoxCreate", function() { return dialogBoxCreate; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "dialogBoxOpened", function() { return dialogBoxOpened; });
+/* Pop up Dialog Box */
+let dialogBoxes = [];
+
+//Close dialog box when clicking outside
+$(document).click(function(event) {
+ if (dialogBoxOpened && dialogBoxes.length >= 1) {
+ if (!$(event.target).closest(dialogBoxes[0]).length){
+ dialogBoxes[0].remove();
+ dialogBoxes.splice(0, 1);
+ if (dialogBoxes.length == 0) {
+ dialogBoxOpened = false;
+ } else {
+ dialogBoxes[0].style.visibility = "visible";
+ }
+ }
+ }
+});
+
+
+//Dialog box close buttons
+$(document).on('click', '.dialog-box-close-button', function( event ) {
+ if (dialogBoxOpened && dialogBoxes.length >= 1) {
+ dialogBoxes[0].remove();
+ dialogBoxes.splice(0, 1);
+ if (dialogBoxes.length == 0) {
+ dialogBoxOpened = false;
+ } else {
+ dialogBoxes[0].style.visibility = "visible";
+ }
+ }
+});
+
+var dialogBoxOpened = false;
+
+function dialogBoxCreate(txt, preformatted=false) {
+ var container = document.createElement("div");
+ container.setAttribute("class", "dialog-box-container");
+
+ var content = document.createElement("div");
+ content.setAttribute("class", "dialog-box-content");
+
+ var closeButton = document.createElement("span");
+ closeButton.setAttribute("class", "dialog-box-close-button");
+ closeButton.innerHTML = "×"
+
+ var textE;
+ if (preformatted) {
+ // For text files as they are often computed data that
+ // shouldn't be wrapped and should retain tabstops.
+ textE = document.createElement("pre");
+ textE.innerHTML = txt;
+ } else {
+ textE = document.createElement("p");
+ textE.innerHTML = txt.replace(/(?:\r\n|\r|\n)/g, ' ');
+ }
+
+ content.appendChild(closeButton);
+ content.appendChild(textE);
+ container.appendChild(content);
+
+ document.body.appendChild(container);
+ if (dialogBoxes.length >= 1) {
+ container.style.visibility = "hidden";
+ }
+ dialogBoxes.push(container);
+
+ setTimeout(function() {
+ dialogBoxOpened = true;
+ }, 400);
+}
+
+
+
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 41)))
+
+/***/ }),
+/* 7 */
+/*!***********************************!*\
+ !*** ./src/NetscriptEvaluator.js ***!
+ \***********************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "makeRuntimeRejectMsg", function() { return makeRuntimeRejectMsg; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "netscriptDelay", function() { return netscriptDelay; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runScriptFromScript", function() { return runScriptFromScript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateHackingChance", function() { return scriptCalculateHackingChance; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateHackingTime", function() { return scriptCalculateHackingTime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateExpGain", function() { return scriptCalculateExpGain; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculatePercentMoneyHacked", function() { return scriptCalculatePercentMoneyHacked; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateGrowTime", function() { return scriptCalculateGrowTime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptCalculateWeakenTime", function() { return scriptCalculateWeakenTime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "evaluate", function() { return evaluate; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isScriptErrorMessage", function() { return isScriptErrorMessage; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "killNetscriptDelay", function() { return killNetscriptDelay; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "evaluateImport", function() { return evaluateImport; });
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 16);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 65);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Server.js */ 10);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Settings.js */ 24);
+/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Script.js */ 29);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/acorn.js */ 36);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/IPAddress.js */ 15);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+var Promise = __webpack_require__(/*! bluebird */ 167);
+
+Promise.config({
+ warnings: false,
+ longStackTraces: false,
+ cancellation: true,
+ monitoring: false
+});
+/* Evaluator
+ * Evaluates/Interprets the Abstract Syntax Tree generated by Acorns parser
+ *
+ * Returns a promise
+ */
+function evaluate(exp, workerScript) {
+ return Promise.delay(_Settings_js__WEBPACK_IMPORTED_MODULE_6__["Settings"].CodeInstructionRunTime).then(function() {
+ var env = workerScript.env;
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+ if (exp == null) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Error: NULL expression", exp));
+ }
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+ switch (exp.type) {
+ case "BlockStatement":
+ case "Program":
+ var evaluateProgPromise = evaluateProg(exp, workerScript, 0); //TODO: make every block/program use individual enviroment
+ return evaluateProgPromise.then(function(w) {
+ return Promise.resolve(workerScript);
+ }).catch(function(e) {
+ if (e.constructor === Array && e.length === 2 && e[0] === "RETURNSTATEMENT") {
+ return Promise.reject(e);
+ } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["isString"])(e)) {
+ workerScript.errorMessage = e;
+ return Promise.reject(workerScript);
+ } else if (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]) {
+ return Promise.reject(e);
+ } else {
+ return Promise.reject(workerScript);
+ }
+ });
+ break;
+ case "Literal":
+ return Promise.resolve(exp.value);
+ break;
+ case "Identifier":
+ //Javascript constructor() method can be used as an exploit to run arbitrary code
+ if (exp.name == "constructor") {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Illegal usage of constructor() method. If you have your own function named 'constructor', you must re-name it.", exp));
+ }
+
+ if (!(exp.name in env.vars)){
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.name + " not defined", exp));
+ }
+ return Promise.resolve(env.get(exp.name))
+ break;
+ case "ExpressionStatement":
+ return evaluate(exp.expression, workerScript);
+ break;
+ case "ArrayExpression":
+ var argPromises = exp.elements.map(function(arg) {
+ return evaluate(arg, workerScript);
+ });
+ return Promise.all(argPromises).then(function(array) {
+ return Promise.resolve(array)
+ });
+ break;
+ case "CallExpression":
+ return evaluate(exp.callee, workerScript).then(function(func) {
+ return Promise.map(exp.arguments, function(arg) {
+ return evaluate(arg, workerScript);
+ }).then(function(args) {
+ if (func instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__["Node"]) { //Player-defined function
+ //Create new Environment for the function
+ //Should be automatically garbage collected...
+ var funcEnv = env.extend();
+
+ //Define function arguments in this new environment
+ for (var i = 0; i < func.params.length; ++i) {
+ var arg;
+ if (i >= args.length) {
+ arg = null;
+ } else {
+ arg = args[i];
+ }
+ funcEnv.def(func.params[i].name, arg);
+ }
+
+ //Create a new WorkerScript for this function evaluation
+ var funcWorkerScript = new _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"](workerScript.scriptRef);
+ funcWorkerScript.serverIp = workerScript.serverIp;
+ funcWorkerScript.env = funcEnv;
+ workerScript.fnWorker = funcWorkerScript;
+
+ return evaluate(func.body, funcWorkerScript).then(function(res) {
+ //If the function finished successfuly, that means there
+ //was no return statement since a return statement rejects. So resolve to null
+ workerScript.fnWorker = null;
+ return Promise.resolve(null);
+ }).catch(function(e) {
+ if (e.constructor === Array && e.length === 2 && e[0] === "RETURNSTATEMENT") {
+ //Return statement from function
+ return Promise.resolve(e[1]);
+ workerScript.fnWorker = null;
+ } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["isString"])(e)) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, e));
+ } else if (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]) {
+ //Parse out the err message from the WorkerScript and re-reject
+ var errorMsg = e.errorMessage;
+ var errorTextArray = errorMsg.split("|");
+ if (errorTextArray.length === 4) {
+ errorMsg = errorTextArray[3];
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, errorMsg));
+ } else {
+ if (env.stopFlag) {
+ return Promise.reject(workerScript);
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Error in one of your functions. Could not identify which function"));
+ }
+ }
+ } else if (e instanceof Error) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, e.toString()));
+ }
+ });
+ } else if (exp.callee.type === "MemberExpression"){
+ return evaluate(exp.callee.object, workerScript).then(function(object) {
+ try {
+ if (func === "NETSCRIPTFOREACH") {
+ return evaluateForeach(object, args, workerScript).then(function(res) {
+ return Promise.resolve(res);
+ }).catch(function(e) {
+ return Promise.reject(e);
+ });
+ }
+ var res = func.apply(object,args);
+ return Promise.resolve(res);
+ } catch (e) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, e, exp));
+ }
+ });
+ } else {
+ try {
+ var out = func.apply(null,args);
+ if (out instanceof Promise){
+ return out.then(function(res) {
+ return Promise.resolve(res)
+ }).catch(function(e) {
+ if (isScriptErrorMessage(e)) {
+ //Functions don't have line number appended in error message, so add it
+ var num = getErrorLineNumber(exp, workerScript);
+ e += " (Line " + num + ")";
+ }
+ return Promise.reject(e);
+ });
+ } else {
+ return Promise.resolve(out);
+ }
+ } catch (e) {
+ if (isScriptErrorMessage(e)) {
+ if (isScriptErrorMessage(e)) {
+ //Functions don't have line number appended in error message, so add it
+ var num = getErrorLineNumber(exp, workerScript);
+ e += " (Line " + num + ")";
+ }
+ return Promise.reject(e);
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, e, exp));
+ }
+ }
+ }
+ });
+ });
+ break;
+ case "MemberExpression":
+ return evaluate(exp.object, workerScript).then(function(object) {
+ if (exp.computed){
+ return evaluate(exp.property, workerScript).then(function(index) {
+ if (index >= object.length) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid index for arrays", exp));
+ }
+ return Promise.resolve(object[index]);
+ }).catch(function(e) {
+ if (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"] || isScriptErrorMessage(e)) {
+ return Promise.reject(e);
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid MemberExpression", exp));
+ }
+ });
+ } else {
+ if (exp.property.name === "constructor") {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Illegal usage of constructor() method. If you have your own function named 'constructor', you must re-name it.", exp));
+ }
+ if (object != null && object instanceof Array && exp.property.name === "forEach") {
+ return "NETSCRIPTFOREACH";
+ }
+ try {
+ return Promise.resolve(object[exp.property.name])
+ } catch (e) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Failed to get property: " + e.toString(), exp));
+ }
+ }
+ });
+ break;
+ case "LogicalExpression":
+ case "BinaryExpression":
+ return evalBinary(exp, workerScript);
+ break;
+ case "UnaryExpression":
+ return evalUnary(exp, workerScript);
+ break;
+ case "AssignmentExpression":
+ return evalAssignment(exp, workerScript);
+ break;
+ case "UpdateExpression":
+ if (exp.argument.type==="Identifier"){
+ if (exp.argument.name in env.vars){
+ if (exp.operator === "++" || exp.operator === "--") {
+ switch (exp.operator) {
+ case "++":
+ env.set(exp.argument.name,env.get(exp.argument.name)+1);
+ break;
+ case "--":
+ env.set(exp.argument.name,env.get(exp.argument.name)-1);
+ break;
+ default: break;
+ }
+ return Promise.resolve(env.get(exp.argument.name));
+ }
+ //Not sure what prefix UpdateExpressions there would be besides ++/--
+ if (exp.prefix){
+ return Promise.resolve(env.get(exp.argument.name))
+ }
+ switch (exp.operator){
+ default:
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unrecognized token: " + exp.type + ". You are trying to use code that is currently unsupported", exp));
+ }
+ return Promise.resolve(env.get(exp.argument.name))
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.argument.name + " not defined", exp));
+ }
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "argument must be an identifier", exp));
+ }
+ break;
+ case "EmptyStatement":
+ return Promise.resolve(false);
+ break;
+ case "ReturnStatement":
+ return evaluate(exp.argument, workerScript).then(function(res) {
+ return Promise.reject(["RETURNSTATEMENT", res]);
+ });
+ break;
+ case "BreakStatement":
+ return Promise.reject("BREAKSTATEMENT");
+ break;
+ case "ContinueStatement":
+ return Promise.reject("CONTINUESTATEMENT");
+ break;
+ case "IfStatement":
+ return evaluateIf(exp, workerScript);
+ break;
+ case "SwitchStatement":
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Switch statements are not yet implemented in Netscript", exp));
+ break;
+ case "WhileStatement":
+ return evaluateWhile(exp, workerScript).then(function(res) {
+ return Promise.resolve(res);
+ }).catch(function(e) {
+ if (e == "BREAKSTATEMENT" ||
+ (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"] && e.errorMessage == "BREAKSTATEMENT")) {
+ return Promise.resolve("whileLoopBroken");
+ } else {
+ return Promise.reject(e);
+ }
+ });
+ break;
+ case "ForStatement":
+ return evaluate(exp.init, workerScript).then(function(expInit) {
+ return evaluateFor(exp, workerScript);
+ }).then(function(forLoopRes) {
+ return Promise.resolve("forLoopDone");
+ }).catch(function(e) {
+ if (e == "BREAKSTATEMENT" ||
+ (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"] && e.errorMessage == "BREAKSTATEMENT")) {
+ return Promise.resolve("forLoopBroken");
+ } else {
+ return Promise.reject(e);
+ }
+ });
+ break;
+ case "FunctionDeclaration":
+ if (exp.id && exp.id.name) {
+ env.set(exp.id.name, exp);
+ return Promise.resolve(true);
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid function declaration", exp));
+ }
+ break;
+ case "ImportDeclaration":
+ return evaluateImport(exp, workerScript).then(function(res) {
+ return Promise.resolve(res);
+ }).catch(function(e) {
+ return Promise.reject(e);
+ });
+ break;
+ case "ThrowStatement":
+ return evaluate(exp.argument, workerScript).then(function(res) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, res));
+ });
+ break;
+ default:
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unrecognized token: " + exp.type + ". This is currently unsupported in Netscript", exp));
+ break;
+ } //End switch
+ }).catch(function(e) {
+ return Promise.reject(e);
+ }); // End Promise
+}
+
+function evalBinary(exp, workerScript){
+ return evaluate(exp.left, workerScript).then(function(expLeft) {
+ //Short circuiting
+ if (expLeft == true && exp.operator === "||") {
+ return Promise.resolve(true);
+ }
+ if (expLeft == false && exp.operator === "&&") {
+ return Promise.resolve(false);
+ }
+ return evaluate(exp.right, workerScript).then(function(expRight) {
+ switch (exp.operator){
+ case "===":
+ case "==":
+ return Promise.resolve(expLeft===expRight);
+ break;
+ case "!==":
+ case "!=":
+ return Promise.resolve(expLeft!==expRight);
+ break;
+ case "<":
+ return Promise.resolve(expLeft":
+ return Promise.resolve(expLeft>expRight);
+ break;
+ case ">=":
+ return Promise.resolve(expLeft>=expRight);
+ break;
+ case "+":
+ return Promise.resolve(expLeft+expRight);
+ break;
+ case "-":
+ return Promise.resolve(expLeft-expRight);
+ break;
+ case "*":
+ return Promise.resolve(expLeft*expRight);
+ break;
+ case "/":
+ if (expRight === 0) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "ERROR: Divide by zero"));
+ } else {
+ return Promise.resolve(expLeft/expRight);
+ }
+ break;
+ case "%":
+ return Promise.resolve(expLeft%expRight);
+ break;
+ case "in":
+ return Promise.resolve(expLeft in expRight);
+ break;
+ case "instanceof":
+ return Promise.resolve(expLeft instanceof expRight);
+ break;
+ case "||":
+ return Promise.resolve(expLeft || expRight);
+ break;
+ case "&&":
+ return Promise.resolve(expLeft && expRight);
+ break;
+ default:
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unsupported operator: " + exp.operator));
+ }
+ });
+ });
+}
+
+function evalUnary(exp, workerScript){
+ var env = workerScript.env;
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+ return evaluate(exp.argument, workerScript).then(function(res) {
+ if (exp.operator == "!") {
+ return Promise.resolve(!res);
+ } else if (exp.operator == "-") {
+ if (isNaN(res)) {
+ return Promise.resolve(res);
+ } else {
+ return Promise.resolve(-1 * res);
+ }
+ } else {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Unimplemented unary operator: " + exp.operator));
+ }
+ });
+}
+
+//Takes in a MemberExpression that should represent a Netscript array (possible multidimensional)
+//The return value is an array of the form:
+// [0th index (leftmost), array name, 1st index, 2nd index, ...]
+function getArrayElement(exp, workerScript) {
+ var indices = [];
+ return evaluate(exp.property, workerScript).then(function(idx) {
+ if (isNaN(idx)) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid access to array. Index is not a number: " + idx));
+ } else {
+ if (exp.object.name === undefined && exp.object.object) {
+ return getArrayElement(exp.object, workerScript).then(function(res) {
+ res.push(idx);
+ indices = res;
+ return Promise.resolve(indices);
+ }).catch(function(e) {
+ return Promise.reject(e);
+ });
+ } else {
+ indices.push(idx);
+ indices.push(exp.object.name);
+ return Promise.resolve(indices);
+ }
+ }
+ });
+}
+
+function evalAssignment(exp, workerScript) {
+ var env = workerScript.env;
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+
+ if (exp.left.type != "Identifier" && exp.left.type != "MemberExpression") {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Cannot assign to " + JSON.stringify(exp.left)));
+ }
+
+ if (exp.operator !== "=" && !(exp.left.name in env.vars)){
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "variable " + exp.left.name + " not defined"));
+ }
+
+ return evaluate(exp.right, workerScript).then(function(expRight) {
+ if (exp.left.type == "MemberExpression") {
+ if (!exp.left.computed) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Cannot assign to an object's property. This is currently unsupported in Netscript", exp));
+ }
+ //Assign to array element
+ //Array object designed by exp.left.object.name
+ //Index designated by exp.left.property
+ return getArrayElement(exp.left, workerScript).then(function(res) {
+ if (!(res instanceof Array) || res.length < 2) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Error evaluating array assignment. This is (probably) a bug please report to game dev"));
+ }
+
+ //The array name is the second value
+ var arrName = res.splice(1, 1);
+ arrName = arrName[0];
+
+ var res;
+ try {
+ res = env.setArrayElement(arrName, res, expRight);
+ } catch (e) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, e));
+ }
+ return Promise.resolve(res);
+ }).catch(function(e) {
+ return Promise.reject(e);
+ });
+ } else {
+ //Other assignments
+ try {
+ var assign;
+ switch (exp.operator) {
+ case "=":
+ assign = expRight; break;
+ case "+=":
+ assign = env.get(exp.left.name) + expRight; break;
+ case "-=":
+ assign = env.get(exp.left.name) - expRight; break;
+ case "*=":
+ assign = env.get(exp.left.name) * expRight; break;
+ case "/=":
+ assign = env.get(exp.left.name) / expRight; break;
+ case "%=":
+ assign = env.get(exp.left.name) % expRight; break;
+ default:
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Bitwise assignment is not implemented"));
+ }
+ env.set(exp.left.name, assign);
+ return Promise.resolve(assign);
+ } catch (e) {
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Failed to set environment variable: " + e.toString()));
+ }
+ }
+ });
+}
+
+function evaluateIf(exp, workerScript, i) {
+ var env = workerScript.env;
+ return evaluate(exp.test, workerScript).then(function(condRes) {
+ if (condRes) {
+ return evaluate(exp.consequent, workerScript).then(function(res) {
+ return Promise.resolve(true);
+ }, function(e) {
+ return Promise.reject(e);
+ });
+ } else if (exp.alternate) {
+ return evaluate(exp.alternate, workerScript).then(function(res) {
+ return Promise.resolve(true);
+ }, function(e) {
+ return Promise.reject(e);
+ });
+ } else {
+ return Promise.resolve("endIf");
+ }
+ });
+}
+
+//Evaluate the looping part of a for loop (Initialization block is NOT done in here)
+function evaluateFor(exp, workerScript) {
+ var env = workerScript.env;
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+ return new Promise(function(resolve, reject) {
+ function recurse() {
+ //Don't return a promise so the promise chain is broken on each recursion (saving memory)
+ evaluate(exp.test, workerScript).then(function(resCond) {
+ if (resCond) {
+ return evaluate(exp.body, workerScript).then(function(res) {
+ return evaluate(exp.update, workerScript);
+ }).catch(function(e) {
+ if (e == "CONTINUESTATEMENT" ||
+ (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"] && e.errorMessage == "CONTINUESTATEMENT")) {
+ //Continue statement, recurse to next iteration
+ return evaluate(exp.update, workerScript).then(function(resPostloop) {
+ return evaluateFor(exp, workerScript);
+ }).then(function(foo) {
+ return Promise.resolve("endForLoop");
+ }).catch(function(e) {
+ return Promise.reject(e);
+ });
+ } else {
+ return Promise.reject(e);
+ }
+ }).then(recurse, reject).catch(function(e) {
+ return Promise.reject(e);
+ });
+ } else {
+ resolve();
+ }
+ }).catch(function(e) {
+ reject(e);
+ });
+ }
+ recurse();
+ });
+}
+
+function evaluateForeach(arr, args, workerScript) {
+ console.log("evaluateForeach called");
+ if (!(arr instanceof Array)) {
+ return Promise.reject("Invalid array passed into forEach");
+ }
+ if (!(args instanceof Array) && args.length != 1) {
+ return Promise.reject("Invalid argument passed into forEach");
+ }
+ var func = args[0];
+ if (typeof func !== "function") {
+ return Promise.reject("Invalid function passed into forEach");
+ }
+ console.log(func);
+ return new Promise(function(resolve, reject) {
+ //Don't return a promise so the promise chain is broken on each recursion
+ function recurse(i) {
+ console.log("recurse() called with i: " + i);
+ if (i >= arr.length) {
+ resolve();
+ } else {
+ return Promise.delay(_Settings_js__WEBPACK_IMPORTED_MODULE_6__["Settings"].CodeInstructionRunTime).then(function() {
+ console.log("About to apply function");
+ var res = func.apply(null, [arr[i]]);
+ console.log("Applied function");
+ ++i;
+ Promise.resolve(res).then(function(val) {
+ recurse(i);
+ }, reject).catch(function(e) {
+ return Promise.reject(e);
+ });
+ });
+ }
+ }
+ recurse(0);
+ });
+}
+
+function evaluateWhile(exp, workerScript) {
+ var env = workerScript.env;
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+ return new Promise(function (resolve, reject) {
+ function recurse() {
+ //Don't return a promise so the promise chain is broken on each recursion (saving memory)
+ evaluate(exp.test, workerScript).then(function(resCond) {
+ if (resCond) {
+ return evaluate(exp.body, workerScript).catch(function(e) {
+ if (e == "CONTINUESTATEMENT" ||
+ (e instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"] && e.errorMessage == "CONTINUESTATEMENT")) {
+ //Continue statement, recurse
+ return evaluateWhile(exp, workerScript).then(function(foo) {
+ return Promise.resolve("endWhileLoop");
+ }, function(e) {
+ return Promise.reject(e);
+ });
+ } else {
+ return Promise.reject(e);
+ }
+ }).then(recurse, reject).catch(function(e) {
+ return Promise.reject(e);
+ });
+ } else {
+ resolve();
+ }
+ }).catch(function(e) {
+ reject(e);
+ });
+ }
+ recurse();
+ });
+}
+
+function evaluateProg(exp, workerScript, index) {
+ var env = workerScript.env;
+ if (env.stopFlag) {return Promise.reject(workerScript);}
+ if (index >= exp.body.length) {
+ return Promise.resolve("progFinished");
+ } else {
+ //Evaluate this line of code in the prog
+ //After the code finishes evaluating, evaluate the next line recursively
+ return evaluate(exp.body[index], workerScript).then(function(res) {
+ return evaluateProg(exp, workerScript, index + 1);
+ }).then(function(res) {
+ return Promise.resolve(workerScript);
+ }).catch(function(e) {
+ return Promise.reject(e);
+ });
+ }
+}
+
+function evaluateImport(exp, workerScript, checkingRam=false) {
+ //When its checking RAM, it exports an array of nodes for each imported function
+ var ramCheckRes = [];
+
+ var env = workerScript.env;
+ if (env.stopFlag) {
+ if (checkingRam) {return ramCheckRes;}
+ return Promise.reject(workerScript);
+ }
+
+ //Get source script and name of all functions to import
+ var scriptName = exp.source.value;
+ var namespace, namespaceObj, allFns = false, fnNames = [];
+ if (exp.specifiers.length === 1 && exp.specifiers[0].type === "ImportNamespaceSpecifier") {
+ allFns = true;
+ namespace = exp.specifiers[0].local.name;
+ } else {
+ for (var i = 0; i < exp.specifiers.length; ++i) {
+ fnNames.push(exp.specifiers[i].local.name);
+ }
+ }
+
+ //Get the code
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_5__["getServer"])(workerScript.serverIp), code = "";
+ if (server == null) {
+ if (checkingRam) {return ramCheckRes;}
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Failed to identify server. This is a bug please report to dev", exp));
+ }
+ for (var i = 0; i < server.scripts.length; ++i) {
+ if (server.scripts[i].filename === scriptName) {
+ code = server.scripts[i].code;
+ break;
+ }
+ }
+ if (code === "") {
+ if (checkingRam) {return ramCheckRes;}
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Could not find script " + scriptName + " to import", exp));
+ }
+
+ //Create the AST
+ try {
+ var ast = Object(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__["parse"])(code, {sourceType:"module"});
+ } catch(e) {
+ console.log("Failed to parse import script");
+ if (checkingRam) {return ramCheckRes;}
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Failed to import functions from " + scriptName +
+ " This is most likely due to a syntax error in the imported script", exp));
+ }
+
+ if (allFns) {
+ //A namespace is implemented as a JS obj
+ env.set(namespace, {});
+ namespaceObj = env.get(namespace);
+ }
+
+ //Search through the AST for all imported functions
+ var queue = [ast];
+ while (queue.length != 0) {
+ var node = queue.shift();
+ switch (node.type) {
+ case "BlockStatement":
+ case "Program":
+ for (var i = 0; i < node.body.length; ++i) {
+ if (node.body[i] instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__["Node"]) {
+ queue.push(node.body[i]);
+ }
+ }
+ break;
+ case "FunctionDeclaration":
+ if (node.id && node.id.name) {
+ if (allFns) {
+ //Import all functions under this namespace
+ if (checkingRam) {
+ ramCheckRes.push(node);
+ } else {
+ namespaceObj[node.id.name] = node;
+ }
+ } else {
+ //Only import specified functions
+ if (fnNames.includes(node.id.name)) {
+ if (checkingRam) {
+ ramCheckRes.push(node);
+ } else {
+ env.set(node.id.name, node);
+ }
+
+ }
+ }
+ } else {
+ if (checkingRam) {return ramCheckRes;}
+ return Promise.reject(makeRuntimeRejectMsg(workerScript, "Invalid function declaration in imported script " + scriptName, exp));
+ }
+ break;
+ default:
+ break;
+ }
+
+ for (var prop in node) {
+ if (node.hasOwnProperty(prop)) {
+ if (node[prop] instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__["Node"]) {
+ queue.push(node[prop]);
+ }
+ }
+ }
+ }
+ if (!checkingRam) {workerScript.scriptRef.log("Imported functions from " + scriptName);}
+ if (checkingRam) {return ramCheckRes;}
+ return Promise.resolve(true);
+}
+
+function killNetscriptDelay(workerScript) {
+ if (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]) {
+ if (workerScript.delay) {
+ clearTimeout(workerScript.delay);
+ workerScript.delayResolve();
+ }
+ }
+}
+
+function netscriptDelay(time, workerScript) {
+ return new Promise(function(resolve, reject) {
+ workerScript.delay = setTimeout(()=>{
+ workerScript.delay = null;
+ resolve();
+ }, time);
+ workerScript.delayResolve = resolve;
+ });
+}
+
+function makeRuntimeRejectMsg(workerScript, msg, exp=null) {
+ var lineNum = "";
+ if (exp != null) {
+ var num = getErrorLineNumber(exp, workerScript);
+ lineNum = " (Line " + num + ")"
+ }
+ return "|"+workerScript.serverIp+"|"+workerScript.name+"|" + msg + lineNum;
+}
+
+//Run a script from inside a script using run() command
+function runScriptFromScript(server, scriptname, args, workerScript, threads=1) {
+ //Check if the script is already running
+ var runningScriptObj = Object(_Script_js__WEBPACK_IMPORTED_MODULE_7__["findRunningScript"])(scriptname, args, server);
+ if (runningScriptObj != null) {
+ workerScript.scriptRef.log(scriptname + " is already running on " + server.hostname);
+ return Promise.resolve(false);
+ }
+
+ //'null/undefined' arguments are not allowed
+ for (var i = 0; i < args.length; ++i) {
+ if (args[i] == null) {
+ workerScript.scriptRef.log("ERROR: Cannot execute a script with null/undefined as an argument");
+ return Promise.resolve(false);
+ }
+ }
+
+ //Check if the script exists and if it does run it
+ for (var i = 0; i < server.scripts.length; ++i) {
+ if (server.scripts[i].filename == scriptname) {
+ //Check for admin rights and that there is enough RAM availble to run
+ var script = server.scripts[i];
+ var ramUsage = script.ramUsage;
+ threads = Math.round(Number(threads)); //Convert to number and round
+ ramUsage = ramUsage * threads * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, threads-1);
+ var ramAvailable = server.maxRam - server.ramUsed;
+
+ if (server.hasAdminRights == false) {
+ workerScript.scriptRef.log("Cannot run script " + scriptname + " on " + server.hostname + " because you do not have root access!");
+ return Promise.resolve(false);
+ } else if (ramUsage > ramAvailable){
+ workerScript.scriptRef.log("Cannot run script " + scriptname + "(t=" + threads + ") on " + server.hostname + " because there is not enough available RAM!");
+ return Promise.resolve(false);
+ } else {
+ //Able to run script
+ workerScript.scriptRef.log("Running script: " + scriptname + " on " + server.hostname + " with " + threads + " threads and args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_9__["printArray"])(args) + ". May take a few seconds to start up...");
+ var runningScriptObj = new _Script_js__WEBPACK_IMPORTED_MODULE_7__["RunningScript"](script, args);
+ runningScriptObj.threads = threads;
+ server.runningScripts.push(runningScriptObj); //Push onto runningScripts
+ Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["addWorkerScript"])(runningScriptObj, server);
+ return Promise.resolve(true);
+ }
+ }
+ }
+ workerScript.scriptRef.log("Could not find script " + scriptname + " on " + server.hostname);
+ return Promise.resolve(false);
+}
+
+function getErrorLineNumber(exp, workerScript) {
+ var code = workerScript.scriptRef.scriptRef.code;
+
+ //Split code up to the start of the node
+ try {
+ code = code.substring(0, exp.start);
+ return (code.match(/\n/g) || []).length + 1;
+ } catch(e) {
+ return -1;
+ }
+}
+
+function isScriptErrorMessage(msg) {
+ if (!Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["isString"])(msg)) {return false;}
+ let splitMsg = msg.split("|");
+ if (splitMsg.length != 4){
+ return false;
+ }
+ var ip = splitMsg[1];
+ if (!Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_10__["isValidIPAddress"])(ip)) {
+ return false;
+ }
+ return true;
+}
+
+//The same as Player's calculateHackingChance() function but takes in the server as an argument
+function scriptCalculateHackingChance(server) {
+ var difficultyMult = (100 - server.hackDifficulty) / 100;
+ var skillMult = (1.75 * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_skill) + (0.2 * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].intelligence);
+ var skillChance = (skillMult - server.requiredHackingSkill) / skillMult;
+ var chance = skillChance * difficultyMult * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_chance_mult;
+ if (chance > 1) {return 1;}
+ if (chance < 0) {return 0;}
+ else {return chance;}
+}
+
+//The same as Player's calculateHackingTime() function but takes in the server as an argument
+function scriptCalculateHackingTime(server) {
+ var difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
+ var skillFactor = (2.5 * difficultyMult + 500) / (_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_skill + 50 + (0.1 * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].intelligence));
+ var hackingTime = 5 * skillFactor / _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_speed_mult; //This is in seconds
+ return hackingTime;
+}
+
+//The same as Player's calculateExpGain() function but takes in the server as an argument
+function scriptCalculateExpGain(server) {
+ if (server.baseDifficulty == null) {
+ server.baseDifficulty = server.hackDifficulty;
+ }
+ return (server.baseDifficulty * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_exp_mult * 0.3 + 3) * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].HackExpGain;
+}
+
+//The same as Player's calculatePercentMoneyHacked() function but takes in the server as an argument
+function scriptCalculatePercentMoneyHacked(server) {
+ var difficultyMult = (100 - server.hackDifficulty) / 100;
+ var skillMult = (_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_skill - (server.requiredHackingSkill - 1)) / _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_skill;
+ var percentMoneyHacked = difficultyMult * skillMult * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_money_mult / 240;
+ if (percentMoneyHacked < 0) {return 0;}
+ if (percentMoneyHacked > 1) {return 1;}
+ return percentMoneyHacked * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ScriptHackMoney;
+}
+
+//Amount of time to execute grow() in milliseconds
+function scriptCalculateGrowTime(server) {
+ var difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
+ var skillFactor = (2.5 * difficultyMult + 500) / (_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_skill + 50 + (0.1 * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].intelligence));
+ var growTime = 16 * skillFactor / _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_speed_mult; //This is in seconds
+ return growTime * 1000;
+}
+
+//Amount of time to execute weaken() in milliseconds
+function scriptCalculateWeakenTime(server) {
+ var difficultyMult = server.requiredHackingSkill * server.hackDifficulty;
+ var skillFactor = (2.5 * difficultyMult + 500) / (_Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_skill + 50 + (0.1 * _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].intelligence));
+ var weakenTime = 20 * skillFactor / _Player_js__WEBPACK_IMPORTED_MODULE_2__["Player"].hacking_speed_mult; //This is in seconds
+ return weakenTime * 1000;
+}
+
+
+
+
+/***/ }),
+/* 8 */
+/*!******************************!*\
+ !*** ./utils/JSONReviver.js ***!
+ \******************************/
+/***/ (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;
+}
+
+
+
+
+/***/ }),
+/* 9 */
+/*!************************!*\
+ !*** ./src/Company.js ***!
+ \************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompanyPositions", function() { return CompanyPositions; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initCompanies", function() { return initCompanies; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Companies", function() { return Companies; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getJobRequirementText", function() { return getJobRequirementText; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNextCompanyPosition", function() { return getNextCompanyPosition; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadCompanies", function() { return loadCompanies; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Company", function() { return Company; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "CompanyPosition", function() { return CompanyPosition; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "companyExists", function() { return companyExists; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Location.js */ 4);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
+
+
+
+
+
+
+//Netburner Company class
+// Note: Company Positions can be loaded every time with init() but Company class needs
+// to be saved/loaded from localStorage
+function Company(name="", salaryMult=0, expMult=0, jobStatReqOffset=0) {
+ this.companyName = name;
+ this.info = "";
+ this.companyPositions = []; //Names (only name, not object) of all company positions
+ this.perks = []; //Available Perks
+ this.salaryMultiplier = salaryMult; //Multiplier for base salary
+ this.expMultiplier = expMult; //Multiplier for base exp gain
+
+ //The additional levels you need in the relevant stat to qualify for a job.
+ //E.g the offset for a megacorporation will be high, let's say 200, so the
+ //stat level you'd need to get an intern job would be 200 instead of 1.
+ this.jobStatReqOffset = jobStatReqOffset;
+
+ //Player-related properties for company
+ this.isPlayerEmployed = false;
+ this.playerPosition = ""; //Name (only name, not object) of the current position player holds
+ this.playerReputation = 1; //"Reputation" within company, gain reputation by working for company
+ this.favor = 0;
+ this.rolloverRep = 0;
+};
+
+Company.prototype.setInfo = function(inf) {
+ this.info = inf;
+}
+
+Company.prototype.addPosition = function(pos) {
+ this.companyPositions.push(pos.positionName); //Company object holds only name of positions
+}
+
+Company.prototype.addPositions = function(positions) {
+ for (var i = 0; i < positions.length; i++) {
+ this.addPosition(positions[i]);
+ }
+}
+
+Company.prototype.hasPosition = function(pos) {
+ for (var i = 0; i < this.companyPositions.length; ++i) {
+ if (pos.positionName == this.companyPositions[i]) {
+ return true;
+ }
+ }
+ return false;
+}
+
+Company.prototype.gainFavor = function() {
+ if (this.favor == null || this.favor == undefined) {this.favor = 0;}
+ if (this.rolloverRep == null || this.rolloverRep == undefined) {this.rolloverRep = 0;}
+ var res = this.getFavorGain();
+ if (res.length != 2) {
+ console.log("Error: invalid result from getFavorGain() function");
+ return;
+ }
+ this.favor += res[0];
+ this.rolloverRep = res[1];
+}
+
+Company.prototype.getFavorGain = function() {
+ if (this.favor == null || this.favor == undefined) {this.favor = 0;}
+ if (this.rolloverRep == null || this.rolloverRep == undefined) {this.rolloverRep = 0;}
+ var favorGain = 0, rep = this.playerReputation + this.rolloverRep;
+ var reqdRep = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CompanyReputationToFavorBase *
+ Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CompanyReputationToFavorMult, this.favor);
+ while(rep > 0) {
+ if (rep >= reqdRep) {
+ ++favorGain;
+ rep -= reqdRep;
+ } else {
+ break;
+ }
+ reqdRep *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].FactionReputationToFavorMult;
+ }
+ return [favorGain, rep];
+}
+
+Company.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_3__["Generic_toJSON"])("Company", this);
+}
+
+Company.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_3__["Generic_fromJSON"])(Company, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_3__["Reviver"].constructors.Company = Company;
+
+//Object that defines a position within a Company and its requirements
+function CompanyPosition(name, reqHack, reqStr, reqDef, reqDex, reqAgi, reqCha, reqRep, salary) {
+ this.positionName = name;
+ this.requiredHacking = reqHack;
+ this.requiredStrength = reqStr;
+ this.requiredDefense = reqDef;
+ this.requiredDexterity = reqDex;
+ this.requiredAgility = reqAgi;
+ this.requiredCharisma = reqCha;
+ this.requiredReputation = reqRep;
+
+ //Base salary for a position. This will be multiplied by a company-specific multiplier. Better companies will have
+ //higher multipliers.
+ //
+ //NOTE: This salary denotes the $ gained every loop (200 ms)
+ this.baseSalary = salary;
+};
+
+//Set the parameters that are used to determine how good/effective the Player is at a job.
+//The Player's "effectiveness" at a job determines how much reputation he gains when he works
+//
+//NOTE: These parameters should total to 100, such that each parameter represents a "weighting" of how
+// important that stat/skill is for the job
+CompanyPosition.prototype.setPerformanceParameters = function(hackEff, strEff, defEff, dexEff, agiEff, chaEff, posMult=1) {
+ if (hackEff + strEff + defEff + dexEff + agiEff + chaEff != 100) {
+ console.log("CompanyPosition.setPerformanceParameters() arguments do not total to 100");
+ return;
+ }
+ this.hackingEffectiveness = hackEff;
+ this.strengthEffectiveness = strEff;
+ this.defenseEffectiveness = defEff;
+ this.dexterityEffectiveness = dexEff;
+ this.agilityEffectiveness = agiEff;
+ this.charismaEffectiveness = chaEff;
+ this.positionMultiplier = posMult; //Reputation multiplier for this position
+}
+
+//Set the stat/skill experience a Player should gain for working at a CompanyPosition. The experience is per game loop (200 ms)
+//These will be constant for a single position, but is affected by a company-specific multiplier
+CompanyPosition.prototype.setExperienceGains = function(hack, str, def, dex, agi, cha) {
+ this.hackingExpGain = hack;
+ this.strengthExpGain = str;
+ this.defenseExpGain = def;
+ this.dexterityExpGain = dex;
+ this.agilityExpGain = agi;
+ this.charismaExpGain = cha;
+}
+
+//Calculate a player's effectiveness at a certain job. Returns the amount of job reputation
+//that should be gained every game loop (200 ms)
+CompanyPosition.prototype.calculateJobPerformance = function(hacking, str, def, dex, agi, cha) {
+ var hackRatio = this.hackingEffectiveness * hacking / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MaxSkillLevel;
+ var strRatio = this.strengthEffectiveness * str / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MaxSkillLevel;
+ var defRatio = this.defenseEffectiveness * def / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MaxSkillLevel;
+ var dexRatio = this.dexterityEffectiveness * dex / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MaxSkillLevel;
+ var agiRatio = this.agilityEffectiveness * agi / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MaxSkillLevel;
+ var chaRatio = this.charismaEffectiveness * cha / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MaxSkillLevel;
+
+ var reputationGain = this.positionMultiplier * (hackRatio + strRatio + defRatio + dexRatio + agiRatio + chaRatio) / 100;
+ if (isNaN(reputationGain)) {
+ console.log("ERROR: Code should not reach here");
+ reputationGain = (hackRatio + strRatio + defRatio + dexRatio + agiRatio + chaRatio) / 100;
+ }
+ return reputationGain;
+}
+
+CompanyPosition.prototype.isSoftwareJob = function() {
+ if (this.positionName == "Software Engineering Intern" ||
+ this.positionName == "Junior Software Engineer" ||
+ this.positionName == "Senior Software Engineer" ||
+ this.positionName == "Lead Software Developer" ||
+ this.positionName == "Head of Software" ||
+ this.positionName == "Head of Engineering" ||
+ this.positionName == "Vice President of Technology" ||
+ this.positionName == "Chief Technology Officer") {
+ return true;
+ }
+ return false;
+}
+
+CompanyPosition.prototype.isITJob = function() {
+ if (this.positionName == "IT Intern" ||
+ this.positionName == "IT Analyst" ||
+ this.positionName == "IT Manager" ||
+ this.positionName == "Systems Administrator") {
+ return true;
+ }
+ return false;
+}
+
+CompanyPosition.prototype.isSecurityEngineerJob = function() {
+ if (this.positionName == "Security Engineer") {
+ return true;
+ }
+ return false;
+}
+
+CompanyPosition.prototype.isNetworkEngineerJob = function() {
+ if (this.positionName == "Network Engineer" || this.positionName == "Network Administrator") {
+ return true;
+ }
+ return false;
+}
+
+CompanyPosition.prototype.isBusinessJob = function() {
+ if (this.positionName == "Business Intern" ||
+ this.positionName == "Business Analyst" ||
+ this.positionName == "Business Manager" ||
+ this.positionName == "Operations Manager" ||
+ this.positionName == "Chief Financial Officer" ||
+ this.positionName == "Chief Executive Officer") {
+ return true;
+ }
+ return false;
+}
+
+CompanyPosition.prototype.isSecurityJob = function() {
+ if (this.positionName == "Security Guard" ||
+ this.positionName == "Police Officer" ||
+ this.positionName == "Security Officer" ||
+ this.positionName == "Security Supervisor" ||
+ this.positionName == "Head of Security") {
+ return true;
+ }
+ return false;
+}
+
+CompanyPosition.prototype.isAgentJob = function() {
+ if (this.positionName == "Field Agent" ||
+ this.positionName == "Secret Agent" ||
+ this.positionName == "Special Operative") {
+ return true;
+ }
+ return false;
+}
+
+CompanyPosition.prototype.isSoftwareConsultantJob = function() {
+ if (this.positionName == "Software Consultant" ||
+ this.positionName == "Senior Software Consultant") {return true;}
+ return false;
+}
+
+CompanyPosition.prototype.isBusinessConsultantJob = function() {
+ if (this.positionName == "Business Consultant" ||
+ this.positionName == "Senior Business Consultant") {return true;}
+ return false;
+}
+
+CompanyPosition.prototype.isPartTimeJob = function() {
+ if (this.isSoftwareConsultantJob() ||
+ this.isBusinessConsultantJob() ||
+ this.positionName == "Part-time Waiter" ||
+ this.positionName == "Part-time Employee") {return true;}
+ return false;
+}
+
+CompanyPosition.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_3__["Generic_toJSON"])("CompanyPosition", this);
+}
+
+CompanyPosition.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_3__["Generic_fromJSON"])(CompanyPosition, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_3__["Reviver"].constructors.CompanyPosition = CompanyPosition;
+
+let CompanyPositions = {
+ //Constructor: CompanyPosition(name, reqHack, reqStr, reqDef, reqDex, reqAgi, reqCha, reqRep, salary)
+
+ //Software
+ SoftwareIntern: new CompanyPosition("Software Engineering Intern", 1, 0, 0, 0, 0, 0, 0, 33),
+ JuniorDev: new CompanyPosition("Junior Software Engineer", 51, 0, 0, 0, 0, 0, 8000, 80),
+ SeniorDev: new CompanyPosition("Senior Software Engineer", 251, 0, 0, 0, 0, 51, 40000, 165),
+ LeadDev: new CompanyPosition("Lead Software Developer", 401, 0, 0, 0, 0, 151, 200000, 500),
+
+ //TODO Through darkweb, maybe?
+ FreelanceDeveloper: new CompanyPosition("Freelance Developer", 0, 0, 0, 0, 0, 0, 0, 0),
+
+ SoftwareConsultant: new CompanyPosition("Software Consultant", 51, 0, 0, 0, 0, 0, 0, 66),
+ SeniorSoftwareConsultant: new CompanyPosition("Senior Software Consultant", 251, 0, 0, 0, 0, 51, 0, 132),
+
+ //IT
+ ITIntern: new CompanyPosition("IT Intern", 1, 0, 0, 0, 0, 0, 0, 26),
+ ITAnalyst: new CompanyPosition("IT Analyst", 26, 0, 0, 0, 0, 0, 7000, 66),
+ ITManager: new CompanyPosition("IT Manager", 151, 0, 0, 0, 0, 51, 35000, 132),
+ SysAdmin: new CompanyPosition("Systems Administrator", 251, 0, 0, 0, 0, 76, 175000, 410),
+ SecurityEngineer: new CompanyPosition("Security Engineer", 151, 0, 0, 0, 0, 26, 35000, 121),
+ NetworkEngineer: new CompanyPosition("Network Engineer", 151, 0, 0, 0, 0, 26, 35000, 121),
+ NetworkAdministrator: new CompanyPosition("Network Administrator", 251, 0, 0, 0, 0, 76, 175000, 410),
+
+ //Technology management
+ HeadOfSoftware: new CompanyPosition("Head of Software", 501, 0, 0, 0, 0, 251, 400000, 800),
+ HeadOfEngineering: new CompanyPosition("Head of Engineering", 501, 0, 0, 0, 0, 251, 800000, 1650),
+ VicePresident: new CompanyPosition("Vice President of Technology", 601, 0, 0, 0, 0, 401, 1600000, 2310),
+ CTO: new CompanyPosition("Chief Technology Officer", 751, 0, 0, 0, 0, 501, 3200000, 2640),
+
+ //Business
+ BusinessIntern: new CompanyPosition("Business Intern", 1, 0, 0, 0, 0, 1, 0, 46),
+ BusinessAnalyst: new CompanyPosition("Business Analyst", 6, 0, 0, 0, 0, 51, 8000, 100),
+ BusinessManager: new CompanyPosition("Business Manager", 51, 0, 0, 0, 0, 101, 40000, 200),
+ OperationsManager: new CompanyPosition("Operations Manager", 51, 0, 0, 0, 0, 226, 200000, 660),
+ CFO: new CompanyPosition("Chief Financial Officer", 76, 0, 0, 0, 0, 501, 800000, 1950),
+ CEO: new CompanyPosition("Chief Executive Officer", 101, 0, 0, 0, 0, 751, 3200000, 3900),
+
+ BusinessConsultant: new CompanyPosition("Business Consultant", 6, 0, 0, 0, 0, 51, 0, 88),
+ SeniorBusinessConsultant: new CompanyPosition("Senior Business Consultant", 51, 0, 0, 0, 0, 226, 0, 525),
+
+ //Non-tech/management jobs
+ PartTimeWaiter: new CompanyPosition("Part-time Waiter", 0, 0, 0, 0, 0, 0, 0, 20),
+ PartTimeEmployee: new CompanyPosition("Part-time Employee", 0, 0, 0, 0, 0, 0, 0, 20),
+
+ Waiter: new CompanyPosition("Waiter", 0, 0, 0, 0, 0, 0, 0, 22),
+ Employee: new CompanyPosition("Employee", 0, 0, 0, 0, 0, 0, 0, 22),
+ PoliceOfficer: new CompanyPosition("Police Officer", 11, 101, 101, 101, 101, 51, 8000, 82),
+ PoliceChief: new CompanyPosition("Police Chief", 101, 301, 301, 301, 301, 151, 36000, 460),
+ SecurityGuard: new CompanyPosition("Security Guard", 0, 51, 51, 51, 51, 1, 0, 50),
+ SecurityOfficer: new CompanyPosition("Security Officer", 26, 151, 151, 151, 151, 51, 8000, 195),
+ SecuritySupervisor: new CompanyPosition("Security Supervisor", 26, 251, 251, 251, 251, 101, 36000, 660),
+ HeadOfSecurity: new CompanyPosition("Head of Security", 51, 501, 501, 501, 501, 151, 144000, 1320),
+ FieldAgent: new CompanyPosition("Field Agent", 101, 101, 101, 101, 101, 101, 8000, 330),
+ SecretAgent: new CompanyPosition("Secret Agent", 201, 251, 251, 251, 251, 201, 32000, 990),
+ SpecialOperative: new CompanyPosition("Special Operative", 251, 501, 501, 501, 501, 251, 162000, 2000),
+
+ init: function() {
+ //Argument order: hack, str, def, dex, agi, cha
+ //Software
+ CompanyPositions.SoftwareIntern.setPerformanceParameters(85, 0, 0, 0, 0, 15, 0.9);
+ CompanyPositions.SoftwareIntern.setExperienceGains(.05, 0, 0, 0, 0, .02);
+ CompanyPositions.JuniorDev.setPerformanceParameters(85, 0, 0, 0, 0, 15, 1.1);
+ CompanyPositions.JuniorDev.setExperienceGains(.1, 0, 0, 0, 0, .05);
+ CompanyPositions.SeniorDev.setPerformanceParameters(80, 0, 0, 0, 0, 20, 1.3);
+ CompanyPositions.SeniorDev.setExperienceGains(.4, 0, 0, 0, 0, .08);
+ CompanyPositions.LeadDev.setPerformanceParameters(75, 0, 0, 0, 0, 25, 1.5);
+ CompanyPositions.LeadDev.setExperienceGains(.8, 0, 0, 0, 0, .1);
+
+ CompanyPositions.SoftwareConsultant.setPerformanceParameters(80, 0, 0, 0, 0, 20, 1);
+ CompanyPositions.SoftwareConsultant.setExperienceGains(.08, 0, 0, 0, 0, .03);
+ CompanyPositions.SeniorSoftwareConsultant.setPerformanceParameters(75, 0, 0, 0, 0, 25, 1.2);
+ CompanyPositions.SeniorSoftwareConsultant.setExperienceGains(.25, 0, 0, 0, 0, .06);
+
+ //Security
+ CompanyPositions.ITIntern.setPerformanceParameters(90, 0, 0, 0, 0, 10, 0.9);
+ CompanyPositions.ITIntern.setExperienceGains(.04, 0, 0, 0, 0, .01);
+ CompanyPositions.ITAnalyst.setPerformanceParameters(85, 0, 0, 0, 0, 15, 1.1);
+ CompanyPositions.ITAnalyst.setExperienceGains(.08, 0, 0, 0, 0, .02);
+ CompanyPositions.ITManager.setPerformanceParameters(80, 0, 0, 0, 0, 20, 1.3);
+ CompanyPositions.ITManager.setExperienceGains(.3, 0, 0, 0, 0, .1);
+ CompanyPositions.SysAdmin.setPerformanceParameters(80, 0, 0, 0, 0, 20, 1.4);
+ CompanyPositions.SysAdmin.setExperienceGains(.5, 0, 0, 0, 0, .05);
+ CompanyPositions.SecurityEngineer.setPerformanceParameters(85, 0, 0, 0, 0, 15, 1.2);
+ CompanyPositions.SecurityEngineer.setExperienceGains(0.4, 0, 0, 0, 0, .05);
+ CompanyPositions.NetworkEngineer.setPerformanceParameters(85, 0, 0, 0, 0, 15, 1.2);
+ CompanyPositions.NetworkEngineer.setExperienceGains(0.4, 0, 0, 0, 0, .05);
+ CompanyPositions.NetworkAdministrator.setPerformanceParameters(80, 0, 0, 0, 0, 20, 1.3);
+ CompanyPositions.NetworkAdministrator.setExperienceGains(0.5, 0, 0, 0, 0, .1);
+
+ //Technology management
+ CompanyPositions.HeadOfSoftware.setPerformanceParameters(75, 0, 0, 0, 0, 25, 1.6);
+ CompanyPositions.HeadOfSoftware.setExperienceGains(1, 0, 0, 0, 0, .5);
+ CompanyPositions.HeadOfEngineering.setPerformanceParameters(75, 0, 0, 0, 0, 25, 1.6);
+ CompanyPositions.HeadOfEngineering.setExperienceGains(1.1, 0, 0, 0, 0, .5);
+ CompanyPositions.VicePresident.setPerformanceParameters(70, 0, 0, 0, 0, 30, 1.75);
+ CompanyPositions.VicePresident.setExperienceGains(1.2, 0, 0, 0, 0, .6);
+ CompanyPositions.CTO.setPerformanceParameters(65, 0, 0, 0, 0, 35, 2);
+ CompanyPositions.CTO.setExperienceGains(1.5, 0, 0, 0, 0, 1);
+
+ //Business
+ CompanyPositions.BusinessIntern.setPerformanceParameters(10, 0, 0, 0, 0, 90, 0.9);
+ CompanyPositions.BusinessIntern.setExperienceGains(.01, 0, 0, 0, 0, .08);
+ CompanyPositions.BusinessAnalyst.setPerformanceParameters(15, 0, 0, 0, 0, 85, 1.1);
+ CompanyPositions.BusinessAnalyst.setExperienceGains(.02, 0, 0, 0, 0, .15);
+ CompanyPositions.BusinessManager.setPerformanceParameters(15, 0, 0, 0, 0, 85, 1.3);
+ CompanyPositions.BusinessManager.setExperienceGains(.02, 0, 0, 0, 0, .3);
+ CompanyPositions.OperationsManager.setPerformanceParameters(15, 0, 0, 0, 0, 85, 1.5);
+ CompanyPositions.OperationsManager.setExperienceGains(.02, 0, 0, 0, 0, .4);
+ CompanyPositions.CFO.setPerformanceParameters(10, 0, 0, 0, 0, 90, 1.6);
+ CompanyPositions.CFO.setExperienceGains(.05, 0, 0, 0, 0, 1);
+ CompanyPositions.CEO.setPerformanceParameters(10, 0, 0, 0, 0, 90, 1.75);
+ CompanyPositions.CEO.setExperienceGains(.1, 0, 0, 0, 0, 1.5);
+
+ CompanyPositions.BusinessConsultant.setPerformanceParameters(20, 0, 0, 0, 0, 80, 1);
+ CompanyPositions.BusinessConsultant.setExperienceGains(.015, 0, 0, 0, 0, .15);
+ CompanyPositions.SeniorBusinessConsultant.setPerformanceParameters(15, 0, 0, 0, 0, 85, 1.2);
+ CompanyPositions.SeniorBusinessConsultant.setExperienceGains(.015, 0, 0, 0, 0, .3);
+
+ //Non-tech/management jobs
+ CompanyPositions.PartTimeWaiter.setPerformanceParameters(0, 10, 0, 10, 10, 70);
+ CompanyPositions.PartTimeWaiter.setExperienceGains(0, .0075, .0075, .0075, .0075, .04);
+ CompanyPositions.PartTimeEmployee.setPerformanceParameters(0, 10, 0, 10, 10, 70);
+ CompanyPositions.PartTimeEmployee.setExperienceGains(0, .0075, .0075, .0075, .0075, .03);
+
+ CompanyPositions.Waiter.setPerformanceParameters(0, 10, 0, 10, 10, 70);
+ CompanyPositions.Waiter.setExperienceGains(0, .02, .02, .02, .02, .05);
+ CompanyPositions.Employee.setPerformanceParameters(0, 10, 0, 10, 10, 70);
+ CompanyPositions.Employee.setExperienceGains(0, .02, .02, .02, .02, .04);
+ CompanyPositions.SecurityGuard.setPerformanceParameters(5, 20, 20, 20, 20, 15, 1);
+ CompanyPositions.SecurityGuard.setExperienceGains(.01, .04, .04, .04, .04, .02);
+ CompanyPositions.PoliceOfficer.setPerformanceParameters(5, 20, 20, 20, 20, 15, 1);
+ CompanyPositions.PoliceOfficer.setExperienceGains(.02, .08, .08, .08, .08, .04);
+ CompanyPositions.PoliceChief.setPerformanceParameters(5, 20, 20, 20, 20, 15, 1.25);
+ CompanyPositions.PoliceChief.setExperienceGains(.02, .1, .1, .1, .1, .1);
+ CompanyPositions.SecurityOfficer.setPerformanceParameters(10, 20, 20, 20, 20, 10, 1.1);
+ CompanyPositions.SecurityOfficer.setExperienceGains(.02, .1, .1, .1, .1, .05);
+ CompanyPositions.SecuritySupervisor.setPerformanceParameters(10, 15, 15, 15, 15, 30, 1.25);
+ CompanyPositions.SecuritySupervisor.setExperienceGains(.02, .12, .12, .12, .12, .1);
+ CompanyPositions.HeadOfSecurity.setPerformanceParameters(10, 15, 15, 15, 15, 30, 1.4);
+ CompanyPositions.HeadOfSecurity.setExperienceGains(.05, .15, .15, .15, .15, .15);
+ CompanyPositions.FieldAgent.setPerformanceParameters(10, 15, 15, 20, 20, 20, 1);
+ CompanyPositions.FieldAgent.setExperienceGains(.04, .08, .08, .08, .08, .05);
+ CompanyPositions.SecretAgent.setPerformanceParameters(15, 15, 15, 20, 20, 15, 1.25);
+ CompanyPositions.SecretAgent.setExperienceGains(.1, .15, .15, .15, .15, .1);
+ CompanyPositions.SpecialOperative.setPerformanceParameters(15, 15, 15, 20, 20, 15, 1.5);
+ CompanyPositions.SpecialOperative.setExperienceGains(.15, .2, .2, .2, .2, .15);
+ }
+}
+
+//Returns the next highest position in the company for the relevant career/field
+//I.E returns what your next job would be if you qualify for a promotion
+function getNextCompanyPosition(currPos) {
+ if (currPos == null) {return null;}
+ //Software
+ if (currPos.positionName == CompanyPositions.SoftwareIntern.positionName) {
+ return CompanyPositions.JuniorDev;
+ }
+ if (currPos.positionName == CompanyPositions.JuniorDev.positionName) {
+ return CompanyPositions.SeniorDev;
+ }
+ if (currPos.positionName == CompanyPositions.SeniorDev.positionName) {
+ return CompanyPositions.LeadDev;
+ }
+ if (currPos.positionName == CompanyPositions.LeadDev.positionName) {
+ return CompanyPositions.HeadOfSoftware;
+ }
+
+ //Software Consultant
+ if (currPos.positionName == CompanyPositions.SoftwareConsultant.positionName) {
+ return CompanyPositions.SeniorSoftwareConsultant;
+ }
+
+ //IT
+ if (currPos.positionName == CompanyPositions.ITIntern.positionName) {
+ return CompanyPositions.ITAnalyst;
+ }
+ if (currPos.positionName == CompanyPositions.ITAnalyst.positionName) {
+ return CompanyPositions.ITManager;
+ }
+ if (currPos.positionName == CompanyPositions.ITManager.positionName) {
+ return CompanyPositions.SysAdmin;
+ }
+ if (currPos.positionName == CompanyPositions.SysAdmin.positionName) {
+ return CompanyPositions.HeadOfEngineering;
+ }
+
+ //Security/Network Engineer
+ if (currPos.positionName == CompanyPositions.SecurityEngineer.positionName) {
+ return CompanyPositions.HeadOfEngineering;
+ }
+ if (currPos.positionName == CompanyPositions.NetworkEngineer.positionName) {
+ return CompanyPositions.NetworkAdministrator;
+ }
+ if (currPos.positionName == CompanyPositions.NetworkAdministrator.positionName) {
+ return CompanyPositions.HeadOfEngineering;
+ }
+
+ //Technology management
+ if (currPos.positionName == CompanyPositions.HeadOfSoftware.positionName) {
+ return CompanyPositions.HeadOfEngineering;
+ }
+ if (currPos.positionName == CompanyPositions.HeadOfEngineering.positionName) {
+ return CompanyPositions.VicePresident;
+ }
+ if (currPos.positionName == CompanyPositions.VicePresident.positionName) {
+ return CompanyPositions.CTO;
+ }
+
+ //Business
+ if (currPos.positionName == CompanyPositions.BusinessIntern.positionName) {
+ return CompanyPositions.BusinessAnalyst;
+ }
+ if (currPos.positionName == CompanyPositions.BusinessAnalyst.positionName) {
+ return CompanyPositions.BusinessManager;
+ }
+ if (currPos.positionName == CompanyPositions.BusinessManager.positionName) {
+ return CompanyPositions.OperationsManager;
+ }
+ if (currPos.positionName == CompanyPositions.OperationsManager.positionName) {
+ return CompanyPositions.CFO;
+ }
+ if (currPos.positionName == CompanyPositions.CFO.positionName) {
+ return CompanyPositions.CEO;
+ }
+
+ //Business consultant
+ if (currPos.positionName == CompanyPositions.BusinessConsultant.positionName) {
+ return CompanyPositions.SeniorBusinessConsultant;
+ }
+
+ //Police
+ if (currPos.positionName == CompanyPositions.PoliceOfficer.positionName) {
+ return CompanyPositions.PoliceChief;
+ }
+
+ //Security
+ if (currPos.positionName == CompanyPositions.SecurityGuard.positionName) {
+ return CompanyPositions.SecurityOfficer;
+ }
+ if (currPos.positionName == CompanyPositions.SecurityOfficer.positionName) {
+ return CompanyPositions.SecuritySupervisor;
+ }
+ if (currPos.positionName == CompanyPositions.SecuritySupervisor.positionName) {
+ return CompanyPositions.HeadOfSecurity;
+ }
+
+ //Agent
+ if (currPos.positionName == CompanyPositions.FieldAgent.positionName) {
+ return CompanyPositions.SecretAgent;
+ }
+ if (currPos.positionName == CompanyPositions.SecretAgent.positionName) {
+ return CompanyPositions.SpecialOperative;
+ }
+
+ return null;
+}
+
+/* Initialize all companies. Only called when creating new game/prestiging. Otherwise companies are
+ * usually loaded from localStorage */
+function initCompanies() {
+ /* Companies that also have servers */
+ //Megacorporations
+ var ECorp = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumECorp, 3.0, 3.0, 249);
+ ECorp.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.ITIntern, CompanyPositions.BusinessIntern,
+ CompanyPositions.JuniorDev, CompanyPositions.SeniorDev, CompanyPositions.LeadDev,
+ CompanyPositions.ITAnalyst, CompanyPositions.ITManager, CompanyPositions.SysAdmin,
+ CompanyPositions.SecurityEngineer, CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator,
+ CompanyPositions.HeadOfSoftware, CompanyPositions.HeadOfEngineering,
+ CompanyPositions.VicePresident, CompanyPositions.CTO, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager, CompanyPositions.CFO,
+ CompanyPositions.CEO, CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumECorp)) {
+ ECorp.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumECorp].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumECorp];
+ }
+ AddToCompanies(ECorp);
+
+ var MegaCorp = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12MegaCorp, 3.0, 3.0, 249);
+ MegaCorp.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.ITIntern, CompanyPositions.BusinessIntern,
+ CompanyPositions.JuniorDev, CompanyPositions.SeniorDev, CompanyPositions.LeadDev,
+ CompanyPositions.ITAnalyst, CompanyPositions.ITManager, CompanyPositions.SysAdmin,
+ CompanyPositions.SecurityEngineer, CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator,
+ CompanyPositions.HeadOfSoftware, CompanyPositions.HeadOfEngineering,
+ CompanyPositions.VicePresident, CompanyPositions.CTO, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager, CompanyPositions.CFO,
+ CompanyPositions.CEO, CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12MegaCorp)) {
+ MegaCorp.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12MegaCorp].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12MegaCorp];
+ }
+ AddToCompanies(MegaCorp);
+
+ var BachmanAndAssociates = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumBachmanAndAssociates, 2.6, 2.6, 224);
+ BachmanAndAssociates.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.ITIntern, CompanyPositions.BusinessIntern,
+ CompanyPositions.JuniorDev, CompanyPositions.SeniorDev, CompanyPositions.LeadDev,
+ CompanyPositions.ITAnalyst, CompanyPositions.ITManager, CompanyPositions.SysAdmin,
+ CompanyPositions.SecurityEngineer, CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator,
+ CompanyPositions.HeadOfSoftware, CompanyPositions.HeadOfEngineering,
+ CompanyPositions.VicePresident, CompanyPositions.CTO, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager, CompanyPositions.CFO,
+ CompanyPositions.CEO, CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumBachmanAndAssociates)) {
+ BachmanAndAssociates.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumBachmanAndAssociates].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumBachmanAndAssociates];
+ }
+ AddToCompanies(BachmanAndAssociates);
+
+ var BladeIndustries = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12BladeIndustries, 2.75, 2.75, 224);
+ BladeIndustries.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.ITIntern, CompanyPositions.BusinessIntern,
+ CompanyPositions.JuniorDev, CompanyPositions.SeniorDev, CompanyPositions.LeadDev,
+ CompanyPositions.ITAnalyst, CompanyPositions.ITManager, CompanyPositions.SysAdmin,
+ CompanyPositions.SecurityEngineer, CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator,
+ CompanyPositions.HeadOfSoftware, CompanyPositions.HeadOfEngineering,
+ CompanyPositions.VicePresident, CompanyPositions.CTO, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager, CompanyPositions.CFO,
+ CompanyPositions.CEO, CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12BladeIndustries)) {
+ BladeIndustries.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12BladeIndustries].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12BladeIndustries];
+ }
+ AddToCompanies(BladeIndustries);
+
+ var NWO = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenNWO, 2.75, 2.75, 249);
+ NWO.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.ITIntern, CompanyPositions.BusinessIntern,
+ CompanyPositions.JuniorDev, CompanyPositions.SeniorDev, CompanyPositions.LeadDev,
+ CompanyPositions.ITAnalyst, CompanyPositions.ITManager, CompanyPositions.SysAdmin,
+ CompanyPositions.SecurityEngineer, CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator,
+ CompanyPositions.HeadOfSoftware, CompanyPositions.HeadOfEngineering,
+ CompanyPositions.VicePresident, CompanyPositions.CTO, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager, CompanyPositions.CFO,
+ CompanyPositions.CEO, CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenNWO)) {
+ NWO.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenNWO].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenNWO];
+ }
+ AddToCompanies(NWO);
+
+ var ClarkeIncorporated = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumClarkeIncorporated, 2.25, 2.25, 224);
+ ClarkeIncorporated.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.ITIntern, CompanyPositions.BusinessIntern,
+ CompanyPositions.JuniorDev, CompanyPositions.SeniorDev, CompanyPositions.LeadDev,
+ CompanyPositions.ITAnalyst, CompanyPositions.ITManager, CompanyPositions.SysAdmin,
+ CompanyPositions.SecurityEngineer, CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator,
+ CompanyPositions.HeadOfSoftware, CompanyPositions.HeadOfEngineering,
+ CompanyPositions.VicePresident, CompanyPositions.CTO, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager, CompanyPositions.CFO,
+ CompanyPositions.CEO, CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumClarkeIncorporated)) {
+ ClarkeIncorporated.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumClarkeIncorporated].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumClarkeIncorporated];
+ }
+ AddToCompanies(ClarkeIncorporated);
+
+ var OmniTekIncorporated = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenOmniTekIncorporated, 2.25, 2.25, 224);
+ OmniTekIncorporated.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.ITIntern, CompanyPositions.BusinessIntern,
+ CompanyPositions.JuniorDev, CompanyPositions.SeniorDev, CompanyPositions.LeadDev,
+ CompanyPositions.ITAnalyst, CompanyPositions.ITManager, CompanyPositions.SysAdmin,
+ CompanyPositions.SecurityEngineer, CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator,
+ CompanyPositions.HeadOfSoftware, CompanyPositions.HeadOfEngineering,
+ CompanyPositions.VicePresident, CompanyPositions.CTO, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager, CompanyPositions.CFO,
+ CompanyPositions.CEO, CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenOmniTekIncorporated)) {
+ OmniTekIncorporated.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenOmniTekIncorporated].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenOmniTekIncorporated];
+ }
+ AddToCompanies(OmniTekIncorporated);
+
+ var FourSigma = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12FourSigma, 2.5, 2.5, 224);
+ FourSigma.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.ITIntern, CompanyPositions.BusinessIntern,
+ CompanyPositions.JuniorDev, CompanyPositions.SeniorDev, CompanyPositions.LeadDev,
+ CompanyPositions.ITAnalyst, CompanyPositions.ITManager, CompanyPositions.SysAdmin,
+ CompanyPositions.SecurityEngineer, CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator,
+ CompanyPositions.HeadOfSoftware, CompanyPositions.HeadOfEngineering,
+ CompanyPositions.VicePresident, CompanyPositions.CTO, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager, CompanyPositions.CFO,
+ CompanyPositions.CEO, CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12FourSigma)) {
+ FourSigma.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12FourSigma].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12FourSigma];
+ }
+ AddToCompanies(FourSigma);
+
+ var KuaiGongInternational = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].ChongqingKuaiGongInternational, 2.2, 2.2, 224);
+ KuaiGongInternational.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.ITIntern, CompanyPositions.BusinessIntern,
+ CompanyPositions.JuniorDev, CompanyPositions.SeniorDev, CompanyPositions.LeadDev,
+ CompanyPositions.ITAnalyst, CompanyPositions.ITManager, CompanyPositions.SysAdmin,
+ CompanyPositions.SecurityEngineer, CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator,
+ CompanyPositions.HeadOfSoftware, CompanyPositions.HeadOfEngineering,
+ CompanyPositions.VicePresident, CompanyPositions.CTO, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager, CompanyPositions.CFO,
+ CompanyPositions.CEO, CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].ChongqingKuaiGongInternational)) {
+ KuaiGongInternational.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].ChongqingKuaiGongInternational].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].ChongqingKuaiGongInternational];
+ }
+ AddToCompanies(KuaiGongInternational);
+
+ //Technology and communication companies ("Large" servers)
+ var FulcrumTechnologies = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumFulcrumTechnologies, 2.0, 2.0, 224);
+ FulcrumTechnologies.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.ITIntern, CompanyPositions.BusinessIntern,
+ CompanyPositions.JuniorDev, CompanyPositions.SeniorDev, CompanyPositions.LeadDev,
+ CompanyPositions.ITAnalyst, CompanyPositions.ITManager, CompanyPositions.SysAdmin,
+ CompanyPositions.SecurityEngineer, CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator,
+ CompanyPositions.HeadOfSoftware, CompanyPositions.HeadOfEngineering,
+ CompanyPositions.VicePresident, CompanyPositions.CTO, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager, CompanyPositions.CFO,
+ CompanyPositions.CEO]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumFulcrumTechnologies)) {
+ FulcrumTechnologies.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumFulcrumTechnologies].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumFulcrumTechnologies];
+ }
+ AddToCompanies(FulcrumTechnologies);
+
+ var StormTechnologies = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].IshimaStormTechnologies, 1.8, 1.8, 199);
+ StormTechnologies.addPositions([
+ CompanyPositions.SoftwareIntern,
+ CompanyPositions.JuniorDev, CompanyPositions.SeniorDev, CompanyPositions.LeadDev,
+ CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITAnalyst, CompanyPositions.ITManager, CompanyPositions.SysAdmin,
+ CompanyPositions.SecurityEngineer, CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator,
+ CompanyPositions.HeadOfSoftware, CompanyPositions.HeadOfEngineering,
+ CompanyPositions.VicePresident, CompanyPositions.CTO,
+ CompanyPositions.BusinessIntern, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager, CompanyPositions.CFO,
+ CompanyPositions.CEO]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].IshimaStormTechnologies)) {
+ StormTechnologies.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].IshimaStormTechnologies].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].IshimaStormTechnologies];
+ }
+ AddToCompanies(StormTechnologies);
+
+ var DefComm = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoDefComm, 1.75, 1.75, 199);
+ DefComm.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.HeadOfEngineering, CompanyPositions.CTO, CompanyPositions.CEO]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoDefComm)) {
+ DefComm.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoDefComm].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoDefComm];
+ }
+ AddToCompanies(DefComm);
+
+ var HeliosLabs = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenHeliosLabs, 1.8, 1.8, 199);
+ HeliosLabs.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.HeadOfEngineering, CompanyPositions.CTO, CompanyPositions.CEO]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenHeliosLabs)) {
+ HeliosLabs.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenHeliosLabs].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenHeliosLabs];
+ }
+ AddToCompanies(HeliosLabs);
+
+ var VitaLife = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoVitaLife, 1.8, 1.8, 199);
+ VitaLife.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.HeadOfEngineering, CompanyPositions.CTO,
+ CompanyPositions.BusinessIntern, CompanyPositions.BusinessAnalyst, CompanyPositions.BusinessManager,
+ CompanyPositions.OperationsManager, CompanyPositions.CFO, CompanyPositions.CEO]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoVitaLife)) {
+ VitaLife.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoVitaLife].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoVitaLife];
+ }
+ AddToCompanies(VitaLife);
+
+ var IcarusMicrosystems = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12IcarusMicrosystems, 1.9, 1.9, 199);
+ IcarusMicrosystems.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.HeadOfEngineering, CompanyPositions.CTO,
+ CompanyPositions.BusinessIntern, CompanyPositions.BusinessAnalyst, CompanyPositions.BusinessManager,
+ CompanyPositions.OperationsManager, CompanyPositions.CFO, CompanyPositions.CEO]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12IcarusMicrosystems)) {
+ IcarusMicrosystems.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12IcarusMicrosystems].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12IcarusMicrosystems];
+ }
+ AddToCompanies(IcarusMicrosystems);
+
+ var UniversalEnergy = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12UniversalEnergy, 2.0, 2.0, 199);
+ UniversalEnergy.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.HeadOfEngineering, CompanyPositions.CTO,
+ CompanyPositions.BusinessIntern, CompanyPositions.BusinessAnalyst, CompanyPositions.BusinessManager,
+ CompanyPositions.OperationsManager, CompanyPositions.CFO, CompanyPositions.CEO]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12UniversalEnergy)) {
+ UniversalEnergy.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12UniversalEnergy].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12UniversalEnergy];
+ }
+ AddToCompanies(UniversalEnergy);
+
+ var GalacticCybersystems = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumGalacticCybersystems, 1.9, 1.9, 199);
+ GalacticCybersystems.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.HeadOfEngineering, CompanyPositions.CTO,
+ CompanyPositions.BusinessIntern, CompanyPositions.BusinessAnalyst, CompanyPositions.BusinessManager,
+ CompanyPositions.OperationsManager, CompanyPositions.CFO, CompanyPositions.CEO]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumGalacticCybersystems)) {
+ GalacticCybersystems.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumGalacticCybersystems].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumGalacticCybersystems];
+ }
+ AddToCompanies(GalacticCybersystems);
+
+ //Defense Companies ("Large" Companies)
+ var AeroCorp = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumAeroCorp, 1.7, 1.7, 199);
+ AeroCorp.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.HeadOfEngineering, CompanyPositions.CTO,
+ CompanyPositions.OperationsManager, CompanyPositions.CEO,
+ CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer, CompanyPositions.SecuritySupervisor,
+ CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumAeroCorp)) {
+ AeroCorp.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumAeroCorp].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumAeroCorp];
+ }
+ AddToCompanies(AeroCorp);
+
+ var OmniaCybersystems = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenOmniaCybersystems, 1.7, 1.7, 199);
+ OmniaCybersystems.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.HeadOfEngineering, CompanyPositions.CTO,
+ CompanyPositions.OperationsManager, CompanyPositions.CEO,
+ CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer, CompanyPositions.SecuritySupervisor,
+ CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenOmniaCybersystems)) {
+ OmniaCybersystems.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenOmniaCybersystems].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenOmniaCybersystems];
+ }
+ AddToCompanies(OmniaCybersystems);
+
+ var SolarisSpaceSystems = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].ChongqingSolarisSpaceSystems, 1.7, 1.7, 199);
+ SolarisSpaceSystems.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.HeadOfEngineering, CompanyPositions.CTO,
+ CompanyPositions.OperationsManager, CompanyPositions.CEO,
+ CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer, CompanyPositions.SecuritySupervisor,
+ CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].ChongqingSolarisSpaceSystems)) {
+ SolarisSpaceSystems.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].ChongqingSolarisSpaceSystems].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].ChongqingSolarisSpaceSystems];
+ }
+ AddToCompanies(SolarisSpaceSystems);
+
+ var DeltaOne = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12DeltaOne, 1.6, 1.6, 199);
+ DeltaOne.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.HeadOfEngineering, CompanyPositions.CTO,
+ CompanyPositions.OperationsManager, CompanyPositions.CEO,
+ CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer, CompanyPositions.SecuritySupervisor,
+ CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12DeltaOne)) {
+ DeltaOne.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12DeltaOne].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12DeltaOne];
+ }
+ AddToCompanies(DeltaOne);
+
+ //Health, medicine, pharmaceutical companies ("Large" servers)
+ var GlobalPharmaceuticals = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoGlobalPharmaceuticals, 1.8, 1.8, 224);
+ GlobalPharmaceuticals.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.ITIntern, CompanyPositions.BusinessIntern,
+ CompanyPositions.JuniorDev, CompanyPositions.SeniorDev, CompanyPositions.LeadDev,
+ CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITAnalyst, CompanyPositions.ITManager, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator,
+ CompanyPositions.HeadOfSoftware, CompanyPositions.CTO, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager,
+ CompanyPositions.CFO, CompanyPositions.CEO, CompanyPositions.SecurityGuard,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoGlobalPharmaceuticals)) {
+ GlobalPharmaceuticals.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoGlobalPharmaceuticals].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoGlobalPharmaceuticals];
+ }
+ AddToCompanies(GlobalPharmaceuticals);
+
+ var NovaMedical = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].IshimaNovaMedical, 1.75, 1.75, 199);
+ NovaMedical.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.ITIntern, CompanyPositions.BusinessIntern,
+ CompanyPositions.JuniorDev, CompanyPositions.SeniorDev, CompanyPositions.LeadDev,
+ CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITAnalyst, CompanyPositions.ITManager, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator,
+ CompanyPositions.HeadOfSoftware, CompanyPositions.CTO, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager,
+ CompanyPositions.CFO, CompanyPositions.CEO, CompanyPositions.SecurityGuard,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].IshimaNovaMedical)) {
+ NovaMedical.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].IshimaNovaMedical].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].IshimaNovaMedical];
+ }
+ AddToCompanies(NovaMedical);
+
+ //Other large companies
+ var CIA = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12CIA, 2.0, 2.0, 149);
+ CIA.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.HeadOfEngineering, CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity, CompanyPositions.FieldAgent,
+ CompanyPositions.SecretAgent, CompanyPositions.SpecialOperative]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12CIA)) {
+ CIA.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12CIA].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12CIA];
+ }
+ AddToCompanies(CIA);
+
+ var NSA = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12NSA, 2.0, 2.0, 149);
+ NSA.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.HeadOfEngineering, CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity, CompanyPositions.FieldAgent,
+ CompanyPositions.SecretAgent, CompanyPositions.SpecialOperative]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12NSA)) {
+ NSA.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12NSA].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12NSA];
+ }
+ AddToCompanies(NSA);
+
+ var WatchdogSecurity = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumWatchdogSecurity, 1.5, 1.5, 124);
+ WatchdogSecurity.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.HeadOfEngineering, CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity, CompanyPositions.FieldAgent,
+ CompanyPositions.SecretAgent, CompanyPositions.SpecialOperative]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumWatchdogSecurity)) {
+ WatchdogSecurity.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumWatchdogSecurity].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumWatchdogSecurity];
+ }
+ AddToCompanies(WatchdogSecurity);
+
+ //"Medium level" companies
+ var LexoCorp = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenLexoCorp, 1.4, 1.4, 99);
+ LexoCorp.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.HeadOfSoftware, CompanyPositions.CTO,
+ CompanyPositions.BusinessIntern, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.OperationsManager, CompanyPositions.CFO, CompanyPositions.CEO,
+ CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer, CompanyPositions.HeadOfSecurity]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenLexoCorp)) {
+ LexoCorp.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenLexoCorp].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenLexoCorp];
+ }
+ AddToCompanies(LexoCorp);
+
+ var RhoConstruction = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumRhoConstruction, 1.3, 1.3, 49);
+ RhoConstruction.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.BusinessIntern, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumRhoConstruction)) {
+ RhoConstruction.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumRhoConstruction].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumRhoConstruction];
+ }
+ AddToCompanies(RhoConstruction);
+
+ var AlphaEnterprises = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12AlphaEnterprises, 1.5, 1.5, 99);
+ AlphaEnterprises.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.BusinessIntern, CompanyPositions.BusinessAnalyst,
+ CompanyPositions.BusinessManager, CompanyPositions.OperationsManager]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12AlphaEnterprises)) {
+ AlphaEnterprises.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12AlphaEnterprises].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12AlphaEnterprises];
+ }
+ AddToCompanies(AlphaEnterprises);
+
+ var AevumPolice = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumPolice, 1.3, 1.3, 99);
+ AevumPolice.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.SecurityGuard, CompanyPositions.PoliceOfficer]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumPolice)) {
+ AevumPolice.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumPolice].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumPolice];
+ }
+ AddToCompanies(AevumPolice);
+
+ var SysCoreSecurities = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenSysCoreSecurities, 1.3, 1.3, 124);
+ SysCoreSecurities.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.CTO]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenSysCoreSecurities)) {
+ SysCoreSecurities.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenSysCoreSecurities].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenSysCoreSecurities];
+ }
+ AddToCompanies(SysCoreSecurities);
+
+ var CompuTek = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenCompuTek, 1.2, 1.2, 74);
+ CompuTek.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.CTO]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenCompuTek)) {
+ CompuTek.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenCompuTek].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].VolhavenCompuTek];
+ }
+ AddToCompanies(CompuTek);
+
+ var NetLinkTechnologies = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumNetLinkTechnologies, 1.2, 1.2, 99);
+ NetLinkTechnologies.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.CTO]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumNetLinkTechnologies)) {
+ NetLinkTechnologies.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumNetLinkTechnologies].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].AevumNetLinkTechnologies];
+ }
+ AddToCompanies(NetLinkTechnologies);
+
+ var CarmichaelSecurity = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12CarmichaelSecurity, 1.2, 1.2, 74);
+ CarmichaelSecurity.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.SysAdmin, CompanyPositions.SecurityEngineer,
+ CompanyPositions.NetworkEngineer, CompanyPositions.NetworkAdministrator, CompanyPositions.HeadOfSoftware,
+ CompanyPositions.HeadOfEngineering, CompanyPositions.SecurityGuard, CompanyPositions.SecurityOfficer,
+ CompanyPositions.SecuritySupervisor, CompanyPositions.HeadOfSecurity, CompanyPositions.FieldAgent,
+ CompanyPositions.SecretAgent, CompanyPositions.SpecialOperative]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12CarmichaelSecurity)) {
+ CarmichaelSecurity.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12CarmichaelSecurity].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12CarmichaelSecurity];
+ }
+ AddToCompanies(CarmichaelSecurity);
+
+ //"Low level" companies
+ var FoodNStuff = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12FoodNStuff, 1, 1, 0);
+ FoodNStuff.addPositions([CompanyPositions.Employee, CompanyPositions.PartTimeEmployee]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12FoodNStuff)) {
+ FoodNStuff.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12FoodNStuff].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12FoodNStuff];
+ }
+ AddToCompanies(FoodNStuff);
+
+ var JoesGuns = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12JoesGuns, 1, 1, 0);
+ JoesGuns.addPositions([CompanyPositions.Employee, CompanyPositions.PartTimeEmployee]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12JoesGuns)) {
+ JoesGuns.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12JoesGuns].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].Sector12JoesGuns];
+ }
+ AddToCompanies(JoesGuns);
+
+ var OmegaSoftware = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].IshimaOmegaSoftware, 1.1, 1.1, 49);
+ OmegaSoftware.addPositions([
+ CompanyPositions.SoftwareIntern, CompanyPositions.JuniorDev, CompanyPositions.SeniorDev,
+ CompanyPositions.LeadDev, CompanyPositions.SoftwareConsultant, CompanyPositions.SeniorSoftwareConsultant,
+ CompanyPositions.ITIntern, CompanyPositions.ITAnalyst,
+ CompanyPositions.ITManager, CompanyPositions.CTO, CompanyPositions.CEO]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].IshimaOmegaSoftware)) {
+ OmegaSoftware.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].IshimaOmegaSoftware].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].IshimaOmegaSoftware];
+ }
+ AddToCompanies(OmegaSoftware);
+
+ /* Companies that do not have servers */
+ var NoodleBar = new Company(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoNoodleBar, 1, 1, 0);
+ NoodleBar.addPositions([CompanyPositions.Waiter, CompanyPositions.PartTimeWaiter]);
+ if (companyExists(_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoNoodleBar)) {
+ NoodleBar.favor = Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoNoodleBar].favor;
+ delete Companies[_Location_js__WEBPACK_IMPORTED_MODULE_1__["Locations"].NewTokyoNoodleBar];
+ }
+ AddToCompanies(NoodleBar);
+}
+
+//Map of all companies that exist in the game, indexed by their name
+let Companies = {}
+
+function loadCompanies(saveString) {
+ Companies = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_3__["Reviver"]);
+}
+
+//Add a Company object onto the map of all Companies in the game
+function AddToCompanies(company) {
+ var name = company.companyName;
+ Companies[name] = company;
+}
+
+function companyExists(name) {
+ return Companies.hasOwnProperty(name);
+}
+
+function getJobRequirementText(company, pos, tooltiptext=false) {
+ var reqText = "";
+ var offset = company.jobStatReqOffset;
+ var reqHacking = pos.requiredHacking > 0 ? pos.requiredHacking+offset : 0;
+ var reqStrength = pos.requiredStrength > 0 ? pos.requiredStrength+offset : 0;
+ var reqDefense = pos.requiredDefense > 0 ? pos.requiredDefense+offset : 0;
+ var reqDexterity = pos.requiredDexterity > 0 ? pos.requiredDexterity+offset : 0;
+ var reqAgility = pos.requiredDexterity > 0 ? pos.requiredDexterity+offset : 0;
+ var reqCharisma = pos.requiredCharisma > 0 ? pos.requiredCharisma+offset : 0;
+ var reqRep = pos.requiredReputation;
+ if (tooltiptext) {
+ reqText = "Requires: ";
+ reqText += (reqHacking.toString() + " hacking ");
+ reqText += (reqStrength.toString() + " strength ");
+ reqText += (reqDefense.toString() + " defense ");
+ reqText += (reqDexterity.toString() + " dexterity ");
+ reqText += (reqAgility.toString() + " agility ");
+ reqText += (reqCharisma.toString() + " charisma ");
+ reqText += (reqRep.toString() + " reputation");
+ } else {
+ reqText = "(Requires ";
+ if (reqHacking > 0) {reqText += (reqHacking + " hacking, ");}
+ if (reqStrength > 0) {reqText += (reqStrength + " strength, ");}
+ if (reqDefense > 0) {reqText += (reqDefense + " defense, ");}
+ if (reqDexterity > 0) {reqText += (reqDexterity + " dexterity, ");}
+ if (reqAgility > 0) {reqText += (reqAgility + " agility, ");}
+ if (reqCharisma > 0) {reqText += (reqCharisma + " charisma, ");}
+ if (reqRep > 1) {reqText += (reqRep + " reputation, ");}
+ reqText = reqText.substring(0, reqText.length - 2);
+ reqText += ")";
+ }
+ return reqText;
+}
+
+
+
+
+/***/ }),
+/* 10 */
+/*!***********************!*\
+ !*** ./src/Server.js ***!
+ \***********************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Server", function() { return Server; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AllServers", function() { return AllServers; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getServer", function() { return getServer; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GetServerByHostname", function() { return GetServerByHostname; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadAllServers", function() { return loadAllServers; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AddToAllServers", function() { return AddToAllServers; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "processSingleServerGrowth", function() { return processSingleServerGrowth; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initForeignServers", function() { return initForeignServers; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prestigeAllServers", function() { return prestigeAllServers; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prestigeHomeComputer", function() { return prestigeHomeComputer; });
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./BitNode.js */ 16);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CreateProgram.js */ 13);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Script.js */ 29);
+/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/IPAddress.js */ 15);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
+
+
+
+
+
+
+
+
+
+
+function Server(ip=Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), hostname="", organizationName="",
+ isConnectedTo=false, adminRights=false, purchasedByPlayer=false, maxRam=0) {
+ /* Properties */
+ //Connection information
+ this.ip = ip;
+ var i = 0;
+ var suffix = "";
+ while (GetServerByHostname(hostname+suffix) != null) {
+ //Server already exists
+ suffix = "-" + i;
+ ++i;
+ }
+ this.hostname = hostname + suffix;
+ this.organizationName = organizationName;
+ this.isConnectedTo = isConnectedTo; //Whether the player is connected to this server
+
+ //Access information
+ this.hasAdminRights = adminRights; //Whether player has admin rights
+ this.purchasedByPlayer = purchasedByPlayer;
+ this.manuallyHacked = false; //Flag that tracks whether or not the server has been hacked at least once
+
+ //RAM, CPU speed and Scripts
+ this.maxRam = maxRam; //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.dir = 0; //new Directory(this, null, "");
+
+ /* Hacking information (only valid for "foreign" aka non-purchased servers) */
+ //Skill required to attempt a hack. Whether a hack is successful will be determined
+ //by a separate formula
+ this.requiredHackingSkill = 1;
+
+ //Total money available on this server
+ this.moneyAvailable = 0;
+ this.moneyMax = 0;
+
+ //Parameters used in formulas that dictate how moneyAvailable and requiredHackingSkill change.
+ this.hackDifficulty = 1; //Affects hack success rate and how the requiredHackingSkill increases over time (1-100)
+ this.baseDifficulty = 1; //Starting difficulty
+ this.minDifficulty = 1;
+ this.serverGrowth = 0; //Affects how the moneyAvailable increases (0-100)
+
+ //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 = 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;
+};
+
+//Set the hacking properties of a server
+Server.prototype.setHackingParameters = function(requiredHackingSkill, moneyAvailable, hackDifficulty, serverGrowth) {
+ this.requiredHackingSkill = requiredHackingSkill;
+ if (isNaN(moneyAvailable)) {
+ this.moneyAvailable = 1e6;
+ } else {
+ this.moneyAvailable = moneyAvailable * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerStartingMoney;
+ }
+ this.moneyMax = 25 * this.moneyAvailable * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerMaxMoney;
+ this.hackDifficulty = hackDifficulty * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerStartingSecurity;
+ this.baseDifficulty = hackDifficulty * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerStartingSecurity;
+ this.minDifficulty = Math.max(1, Math.round(this.hackDifficulty / 3));
+ this.serverGrowth = serverGrowth;
+}
+
+//Set the port properties of a server
+//Right now its only the number of open ports needed to PortHack the server.
+Server.prototype.setPortProperties = function(numOpenPortsReq) {
+ this.numOpenPortsRequired = numOpenPortsReq;
+}
+
+Server.prototype.setMaxRam = function(ram) {
+ this.maxRam = ram;
+}
+
+//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;
+}
+
+//Strengthens a server's security level (difficulty) by the specified amount
+Server.prototype.fortify = function(amt) {
+ this.hackDifficulty += amt;
+ //Place some arbitrarily limit that realistically should never happen unless someone is
+ //screwing around with the game
+ if (this.hackDifficulty > 1000000) {this.hackDifficulty = 1000000;}
+}
+
+Server.prototype.weaken = function(amt) {
+ this.hackDifficulty -= (amt * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerWeakenRate);
+ if (this.hackDifficulty < this.minDifficulty) {this.hackDifficulty = this.minDifficulty;}
+ if (this.hackDifficulty < 1) {this.hackDifficulty = 1;}
+}
+
+//Functions for loading and saving a Server
+Server.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_toJSON"])("Server", this);
+}
+
+Server.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_fromJSON"])(Server, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"].constructors.Server = Server;
+
+function initForeignServers() {
+ //MegaCorporations
+ var ECorpServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "ecorp", "ECorp", false, false, false, 0);
+ ECorpServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1150, 1300), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(30000000000, 70000000000), 99, 99);
+ ECorpServer.setPortProperties(5);
+ AddToAllServers(ECorpServer);
+
+ var MegaCorpServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "megacorp", "MegaCorp", false, false, false, 0);
+ MegaCorpServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1150, 1300), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(40000000000, 60000000000), 99, 99);
+ MegaCorpServer.setPortProperties(5);
+ AddToAllServers(MegaCorpServer);
+
+ var BachmanAndAssociatesServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "b-and-a", "Bachman & Associates", false, false, false, 0);
+ BachmanAndAssociatesServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1000, 1050), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(20000000000, 25000000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(75, 85), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(65, 75));
+ BachmanAndAssociatesServer.setPortProperties(5);
+ AddToAllServers(BachmanAndAssociatesServer);
+
+ var BladeIndustriesServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "blade", "Blade Industries", false, false, false, 2);
+ BladeIndustriesServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1000, 1100), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(12000000000, 20000000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(90, 95), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(60, 75));
+ BladeIndustriesServer.setPortProperties(5);
+ BladeIndustriesServer.messages.push("beyond-man.lit");
+ AddToAllServers(BladeIndustriesServer);
+
+ var NWOServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "nwo", "New World Order", false, false, false, 2);
+ NWOServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1000, 1200), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(25000000000, 35000000000), 99, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(75, 85));
+ NWOServer.setPortProperties(5);
+ NWOServer.messages.push("the-hidden-world.lit");
+ AddToAllServers(NWOServer);
+
+ var ClarkeIncorporatedServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "clarkeinc", "Clarke Incorporated", false, false, false, 2);
+ ClarkeIncorporatedServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1000, 1200), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(15000000000, 25000000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(50, 60), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(50, 70));
+ ClarkeIncorporatedServer.setPortProperties(5);
+ ClarkeIncorporatedServer.messages.push("beyond-man.lit");
+ ClarkeIncorporatedServer.messages.push("cost-of-immortality.lit");
+ AddToAllServers(ClarkeIncorporatedServer);
+
+ var OmniTekIncorporatedServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "omnitek", "OmniTek Incorporated", false, false, false, 2);
+ OmniTekIncorporatedServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(900, 1100), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(15000000000, 20000000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(90, 99), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(95, 99));
+ OmniTekIncorporatedServer.setPortProperties(5);
+ OmniTekIncorporatedServer.messages.push("coded-intelligence.lit");
+ AddToAllServers(OmniTekIncorporatedServer);
+
+ var FourSigmaServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "4sigma", "FourSigma", false, false, false, 0);
+ FourSigmaServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(950, 1200), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(15000000000, 25000000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(60, 70), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(75, 99));
+ FourSigmaServer.setPortProperties(5);
+ AddToAllServers(FourSigmaServer);
+
+ var KuaiGongInternationalServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "kuai-gong", "KuaiGong International", false, false, false, 0);
+ KuaiGongInternationalServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1000, 1250), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(20000000000, 30000000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(95, 99), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(90, 99));
+ KuaiGongInternationalServer.setPortProperties(5);
+ AddToAllServers(KuaiGongInternationalServer);
+
+ //Technology and communications companies (large targets)
+ var FulcrumTechnologiesServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "fulcrumtech", "Fulcrum Technologies", false, false, false, 64);
+ FulcrumTechnologiesServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1000, 1200), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1400000000, 1800000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(85, 95), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(80, 99));
+ FulcrumTechnologiesServer.setPortProperties(5);
+ FulcrumTechnologiesServer.messages.push("simulated-reality.lit");
+ AddToAllServers(FulcrumTechnologiesServer);
+
+ var FulcrumSecretTechnologiesServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "fulcrumassets", "Fulcrum Technologies Assets", false, false, false, 0);
+ FulcrumSecretTechnologiesServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1200, 1500), 1000000, 99, 1);
+ FulcrumSecretTechnologiesServer.setPortProperties(5);
+ AddToAllServers(FulcrumSecretTechnologiesServer);
+ _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerIps"].addIp(_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerNames"].FulcrumSecretTechnologies, FulcrumSecretTechnologiesServer.ip);
+
+ var StormTechnologiesServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "stormtech", "Storm Technologies", false, false, false, 0);
+ StormTechnologiesServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(900, 1050), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1000000000, 1200000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(80, 90), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 90));
+ StormTechnologiesServer.setPortProperties(5);
+ AddToAllServers(StormTechnologiesServer);
+
+ var DefCommServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "defcomm", "DefComm", false, false, false, 0);
+ DefCommServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(900, 1000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(800000000, 950000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(85, 95), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(50, 70));
+ DefCommServer.setPortProperties(5);
+ AddToAllServers(DefCommServer);
+
+ var InfoCommServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "infocomm", "InfoComm", false, false, false, 0);
+ InfoCommServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(875, 950), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(600000000, 900000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 90), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(35, 75));
+ InfoCommServer.setPortProperties(5);
+ AddToAllServers(InfoCommServer);
+
+ var HeliosLabsServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "helios", "Helios Labs", false, false, false, 2);
+ HeliosLabsServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(800, 900), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(550000000, 750000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(85, 95), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 80));
+ HeliosLabsServer.setPortProperties(5);
+ HeliosLabsServer.messages.push("beyond-man.lit");
+ AddToAllServers(HeliosLabsServer);
+
+ var VitaLifeServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "vitalife", "VitaLife", false, false, false, 32);
+ VitaLifeServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(775, 900), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(700000000, 800000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(80, 90), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(60, 80));
+ VitaLifeServer.setPortProperties(5);
+ VitaLifeServer.messages.push("A-Green-Tomorrow.lit");
+ AddToAllServers(VitaLifeServer);
+
+ var IcarusMicrosystemsServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "icarus", "Icarus Microsystems", false, false, false, 0);
+ IcarusMicrosystemsServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(850, 925), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(900000000, 1000000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(85, 95), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(85, 95));
+ IcarusMicrosystemsServer.setPortProperties(5);
+ AddToAllServers(IcarusMicrosystemsServer);
+
+ var UniversalEnergyServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "univ-energy", "Universal Energy", false, false, false, 32);
+ UniversalEnergyServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(800, 900), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1100000000, 1200000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(80, 90), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(80, 90));
+ UniversalEnergyServer.setPortProperties(4);
+ AddToAllServers(UniversalEnergyServer);
+
+ var TitanLabsServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "titan-labs", "Titan Laboratories", false, false, false, 32);
+ TitanLabsServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(800, 875), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(750000000, 900000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 80), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(60, 80));
+ TitanLabsServer.setPortProperties(5);
+ TitanLabsServer.messages.push("coded-intelligence.lit");
+ AddToAllServers(TitanLabsServer);
+
+ var MicrodyneTechnologiesServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "microdyne", "Microdyne Technologies", false, false, false, 16);
+ MicrodyneTechnologiesServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(800, 875), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(500000000, 700000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(65, 75), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 90));
+ MicrodyneTechnologiesServer.setPortProperties(5);
+ MicrodyneTechnologiesServer.messages.push("synthetic-muscles.lit");
+ AddToAllServers(MicrodyneTechnologiesServer);
+
+ var TaiYangDigitalServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "taiyang-digital", "Taiyang Digital", false, false, false, 2);
+ TaiYangDigitalServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(850, 950), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(800000000, 900000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 80), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 80));
+ TaiYangDigitalServer.setPortProperties(5);
+ TaiYangDigitalServer.messages.push("A-Green-Tomorrow.lit");
+ TaiYangDigitalServer.messages.push("brighter-than-the-sun.lit");
+ AddToAllServers(TaiYangDigitalServer);
+
+ var GalacticCyberSystemsServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "galactic-cyber", "Galactic Cybersystems", false, false, false, 0);
+ GalacticCyberSystemsServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(825, 875), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(750000000, 850000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(55, 65), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 90));
+ GalacticCyberSystemsServer.setPortProperties(5);
+ AddToAllServers(GalacticCyberSystemsServer);
+
+ //Defense Companies ("Large" Companies)
+ var AeroCorpServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "aerocorp", "AeroCorp", false, false, false, 2);
+ AeroCorpServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(850, 925), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1000000000, 1200000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(80, 90), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(55, 65));
+ AeroCorpServer.setPortProperties(5);
+ AeroCorpServer.messages.push("man-and-machine.lit");
+ AddToAllServers(AeroCorpServer);
+
+ var OmniaCybersystemsServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "omnia", "Omnia Cybersystems", false, false, false, 0);
+ OmniaCybersystemsServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(850, 950), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(900000000, 1000000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(85, 95), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(60, 70));
+ OmniaCybersystemsServer.setPortProperties(5);
+ AddToAllServers(OmniaCybersystemsServer);
+
+ var ZBDefenseServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "zb-def", "ZB Defense Industries", false, false, false, 2);
+ ZBDefenseServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(775, 825), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(900000000, 1100000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(55, 65), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(65, 75));
+ ZBDefenseServer.setPortProperties(4);
+ ZBDefenseServer.messages.push("synthetic-muscles.lit");
+ AddToAllServers(ZBDefenseServer);
+
+ var AppliedEnergeticsServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "applied-energetics", "Applied Energetics", false, false, false, 0);
+ AppliedEnergeticsServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(775, 850), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(700000000, 1000000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(60, 80), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 75));
+ AppliedEnergeticsServer.setPortProperties(4);
+ AddToAllServers(AppliedEnergeticsServer);
+
+ var SolarisSpaceSystemsServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "solaris", "Solaris Space Systems", false, false, false, 2);
+ SolarisSpaceSystemsServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(750, 850), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(700000000, 900000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 80), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 80));
+ SolarisSpaceSystemsServer.setPortProperties(5);
+ SolarisSpaceSystemsServer.messages.push("A-Green-Tomorrow.lit");
+ SolarisSpaceSystemsServer.messages.push("the-failed-frontier.lit");
+ AddToAllServers(SolarisSpaceSystemsServer);
+
+ var DeltaOneServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "deltaone", "Delta One", false, false, false, 0);
+ DeltaOneServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(800, 900), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1300000000, 1700000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(75, 85), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(50, 70));
+ DeltaOneServer.setPortProperties(5);
+ AddToAllServers(DeltaOneServer);
+
+ //Health, medicine, pharmaceutical companies ("Large" targets)
+ var GlobalPharmaceuticalsServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "global-pharm", "Global Pharmaceuticals", false, false, false, 16);
+ GlobalPharmaceuticalsServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(750, 850), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1500000000, 1750000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(75, 85), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(80, 90));
+ GlobalPharmaceuticalsServer.setPortProperties(4);
+ GlobalPharmaceuticalsServer.messages.push("A-Green-Tomorrow.lit");
+ AddToAllServers(GlobalPharmaceuticalsServer);
+
+ var NovaMedicalServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "nova-med", "Nova Medical", false, false, false, 0);
+ NovaMedicalServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(775, 850), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1100000000, 1250000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(60, 80), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(65, 85));
+ NovaMedicalServer.setPortProperties(4);
+ AddToAllServers(NovaMedicalServer);
+
+ var ZeusMedicalServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "zeus-med", "Zeus Medical", false, false, false, 0);
+ ZeusMedicalServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(800, 850), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1300000000, 1500000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 90), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 80));
+ ZeusMedicalServer.setPortProperties(5);
+ AddToAllServers(ZeusMedicalServer);
+
+ var UnitaLifeGroupServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "unitalife", "UnitaLife Group", false, false, false, 32);
+ UnitaLifeGroupServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(775, 825), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(1000000000, 1100000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 80), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 80));
+ UnitaLifeGroupServer.setPortProperties(4);
+ AddToAllServers(UnitaLifeGroupServer);
+
+ //"Medium level" targets
+ var LexoCorpServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "lexo-corp", "Lexo Corporation", false, false, false, 16);
+ LexoCorpServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(650, 750), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(700000000, 800000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(60, 80), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(55, 65));
+ LexoCorpServer.setPortProperties(4);
+ AddToAllServers(LexoCorpServer);
+
+ var RhoConstructionServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "rho-construction", "Rho Construction", false, false, false, 0);
+ RhoConstructionServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(475, 525), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(500000000, 700000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(40, 60), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(40, 60));
+ RhoConstructionServer.setPortProperties(3);
+ AddToAllServers(RhoConstructionServer);
+
+ var AlphaEnterprisesServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "alpha-ent", "Alpha Enterprises", false, false, false, 2);
+ AlphaEnterprisesServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(500, 600), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(600000000, 750000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(50, 70), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(50, 60));
+ AlphaEnterprisesServer.setPortProperties(4);
+ AlphaEnterprisesServer.messages.push("sector-12-crime.lit");
+ AddToAllServers(AlphaEnterprisesServer);
+
+ var AevumPoliceServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "aevum-police", "Aevum Police Network", false, false, false, 0);
+ AevumPoliceServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(400, 450), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(200000000, 400000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70, 80), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(30, 50));
+ AevumPoliceServer.setPortProperties(4);
+ AddToAllServers(AevumPoliceServer);
+
+ var RothmanUniversityServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "rothman-uni", "Rothman University Network", false, false, false, 4);
+ RothmanUniversityServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(370, 430), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(175000000, 250000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(45, 55), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(35, 45));
+ RothmanUniversityServer.setPortProperties(3);
+ RothmanUniversityServer.messages.push("secret-societies.lit");
+ RothmanUniversityServer.messages.push("the-failed-frontier.lit");
+ RothmanUniversityServer.messages.push("tensions-in-tech-race.lit");
+ AddToAllServers(RothmanUniversityServer);
+
+ var ZBInstituteOfTechnologyServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "zb-institute", "ZB Institute of Technology Network", false, false, false, 4);
+ ZBInstituteOfTechnologyServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(725, 775), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(800000000, 1100000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(65, 85), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(75, 85));
+ ZBInstituteOfTechnologyServer.setPortProperties(5);
+ AddToAllServers(ZBInstituteOfTechnologyServer);
+
+ var SummitUniversityServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "summit-uni", "Summit University Network", false, false, false, 4);
+ SummitUniversityServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(425, 475), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(200000000, 350000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(45, 65), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(40, 60));
+ SummitUniversityServer.setPortProperties(3);
+ SummitUniversityServer.messages.push("secret-societies.lit");
+ SummitUniversityServer.messages.push("the-failed-frontier.lit");
+ SummitUniversityServer.messages.push("synthetic-muscles.lit");
+ AddToAllServers(SummitUniversityServer);
+
+ var SysCoreSecuritiesServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "syscore", "SysCore Securities", false, false, false, 0);
+ SysCoreSecuritiesServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(550, 650), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(400000000, 600000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(60, 80), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(60, 70));
+ SysCoreSecuritiesServer.setPortProperties(4);
+ AddToAllServers(SysCoreSecuritiesServer);
+
+ var CatalystVenturesServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "catalyst", "Catalyst Ventures", false, false, false, 2);
+ CatalystVenturesServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(400, 450), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(300000000, 550000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(60, 70), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(25, 55));
+ CatalystVenturesServer.setPortProperties(3);
+ CatalystVenturesServer.messages.push("tensions-in-tech-race.lit");
+ AddToAllServers(CatalystVenturesServer);
+
+ var TheHubServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "the-hub", "The Hub", false, false, false, 0);
+ TheHubServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(275, 325), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(150000000, 200000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(35, 45), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(45, 55));
+ TheHubServer.setPortProperties(2);
+ AddToAllServers(TheHubServer);
+
+ var CompuTekServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "comptek", "CompuTek", false, false, false, 8);
+ CompuTekServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(300, 400), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(220000000, 250000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(55, 65), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(45, 65));
+ CompuTekServer.setPortProperties(3);
+ CompuTekServer.messages.push("man-and-machine.lit");
+ AddToAllServers(CompuTekServer);
+
+ var NetLinkTechnologiesServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "netlink", "NetLink Technologies", false, false, false, 2);
+ NetLinkTechnologiesServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(375, 425), 275000000, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(60, 80), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(45, 75));
+ NetLinkTechnologiesServer.setPortProperties(3);
+ NetLinkTechnologiesServer.messages.push("simulated-reality.lit");
+ AddToAllServers(NetLinkTechnologiesServer);
+
+ var JohnsonOrthopedicsServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "johnson-ortho", "Johnson Orthopedics", false, false, false, 4);
+ JohnsonOrthopedicsServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(250, 300), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(70000000, 85000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(35, 65), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(35, 65));
+ JohnsonOrthopedicsServer.setPortProperties(2);
+ AddToAllServers(JohnsonOrthopedicsServer);
+
+ //"Low level" targets
+ var FoodNStuffServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "foodnstuff", "Food N Stuff Supermarket", false, false, false, 16);
+ FoodNStuffServer.setHackingParameters(1, 2000000, 10, 5);
+ FoodNStuffServer.setPortProperties(0);
+ FoodNStuffServer.messages.push("sector-12-crime.lit");
+ AddToAllServers(FoodNStuffServer);
+
+ var SigmaCosmeticsServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "sigma-cosmetics", "Sigma Cosmetics", false, false, false, 16);
+ SigmaCosmeticsServer.setHackingParameters(5, 2300000, 10, 10);
+ SigmaCosmeticsServer.setPortProperties(0);
+ AddToAllServers(SigmaCosmeticsServer);
+
+ var JoesGunsServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "joesguns", "Joe's Guns", false, false, false, 16);
+ JoesGunsServer.setHackingParameters(10, 2500000, 15, 20);
+ JoesGunsServer.setPortProperties(0);
+ AddToAllServers(JoesGunsServer);
+
+ var Zer0NightclubServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "zer0", "ZER0 Nightclub", false, false, false, 32);
+ Zer0NightclubServer.setHackingParameters(75, 7500000, 25, 40);
+ Zer0NightclubServer.setPortProperties(1);
+ AddToAllServers(Zer0NightclubServer);
+
+ var NectarNightclubServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "nectar-net", "Nectar Nightclub Network", false, false, false, 8);
+ NectarNightclubServer.setHackingParameters(20, 2750000, 20, 25);
+ NectarNightclubServer.setPortProperties(0);
+ AddToAllServers(NectarNightclubServer);
+
+ var NeoNightclubServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "neo-net", "Neo Nightclub Network", false, false, false, 32);
+ NeoNightclubServer.setHackingParameters(50, 5000000, 25, 25);
+ NeoNightclubServer.setPortProperties(1);
+ NeoNightclubServer.messages.push("the-hidden-world.lit");
+ AddToAllServers(NeoNightclubServer);
+
+ var SilverHelixServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "silver-helix", "Silver Helix", false, false, false, 64);
+ SilverHelixServer.setHackingParameters(150, 45000000, 30, 30);
+ SilverHelixServer.setPortProperties(2);
+ SilverHelixServer.messages.push("new-triads.lit");
+ AddToAllServers(SilverHelixServer);
+
+ var HongFangTeaHouseServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "hong-fang-tea", "HongFang Teahouse", false, false, false, 16);
+ HongFangTeaHouseServer.setHackingParameters(30, 3000000, 15, 20);
+ HongFangTeaHouseServer.setPortProperties(0);
+ HongFangTeaHouseServer.messages.push("brighter-than-the-sun.lit");
+ AddToAllServers(HongFangTeaHouseServer);
+
+ var HaraKiriSushiBarServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "harakiri-sushi", "HaraKiri Sushi Bar Network", false, false, false, 16);
+ HaraKiriSushiBarServer.setHackingParameters(40, 4000000, 15, 40);
+ HaraKiriSushiBarServer.setPortProperties(0);
+ AddToAllServers(HaraKiriSushiBarServer);
+
+ var PhantasyServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "phantasy", "Phantasy Club", false, false, false, 32);
+ PhantasyServer.setHackingParameters(100, 24000000, 20, 35);
+ PhantasyServer.setPortProperties(2);
+ AddToAllServers(PhantasyServer);
+
+ var MaxHardwareServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "max-hardware", "Max Hardware Store", false, false, false, 32);
+ MaxHardwareServer.setHackingParameters(80, 10000000, 15, 30);
+ MaxHardwareServer.setPortProperties(1);
+ AddToAllServers(MaxHardwareServer);
+
+ var OmegaSoftwareServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "omega-net", "Omega Software", false, false, false, 32);
+ OmegaSoftwareServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(180, 220), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(60000000, 70000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(25, 35), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(30, 40));
+ OmegaSoftwareServer.setPortProperties(2);
+ OmegaSoftwareServer.messages.push("the-new-god.lit");
+ AddToAllServers(OmegaSoftwareServer);
+
+ //Gyms
+ var CrushFitnessGymServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "crush-fitness", "Crush Fitness", false, false, false, 0);
+ CrushFitnessGymServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(225, 275), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(40000000, 60000000), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(35, 45), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(27, 33));
+ CrushFitnessGymServer.setPortProperties(2);
+ AddToAllServers(CrushFitnessGymServer);
+
+ var IronGymServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "iron-gym", "Iron Gym Network", false, false, false, 32);
+ IronGymServer.setHackingParameters(100, 20000000, 30, 20);
+ IronGymServer.setPortProperties(1);
+ AddToAllServers(IronGymServer);
+
+ var MilleniumFitnessGymServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "millenium-fitness", "Millenium Fitness Network", false, false, false, 0);
+ MilleniumFitnessGymServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(475, 525), 250000000, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(45, 55), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(25, 45));
+ MilleniumFitnessGymServer.setPortProperties(3);
+ AddToAllServers(MilleniumFitnessGymServer);
+
+ var PowerhouseGymServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "powerhouse-fitness", "Powerhouse Fitness", false, false, false, 0);
+ PowerhouseGymServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(950, 1100), 900000000, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(55, 65), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(50, 60));
+ PowerhouseGymServer.setPortProperties(5);
+ AddToAllServers(PowerhouseGymServer);
+
+ var SnapFitnessGymServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "snap-fitness", "Snap Fitness", false, false, false, 0);
+ SnapFitnessGymServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(675, 800), 450000000, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(40, 60), Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(40, 60));
+ SnapFitnessGymServer.setPortProperties(4);
+ AddToAllServers(SnapFitnessGymServer);
+
+ //Faction servers, cannot hack money from these
+ var BitRunnersServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "run4theh111z", "The Runners", false, false, false, 2);
+ BitRunnersServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(505, 550), 0, 0, 0);
+ BitRunnersServer.setPortProperties(4);
+ BitRunnersServer.messages.push("simulated-reality.lit");
+ BitRunnersServer.messages.push("the-new-god.lit");
+ AddToAllServers(BitRunnersServer);
+ _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerIps"].addIp(_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerNames"].BitRunnersServer, BitRunnersServer.ip);
+
+ var TheBlackHandServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "I.I.I.I", "I.I.I.I", false, false, false, 2);
+ TheBlackHandServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(340, 365), 0, 0, 0);
+ TheBlackHandServer.setPortProperties(3);
+ TheBlackHandServer.messages.push("democracy-is-dead.lit");
+ AddToAllServers(TheBlackHandServer);
+ _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerIps"].addIp(_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerNames"].TheBlackHandServer, TheBlackHandServer.ip);
+
+ var NiteSecServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "avmnite-02h", "NiteSec", false, false, false, 2);
+ NiteSecServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(202, 220), 0, 0, 0);
+ NiteSecServer.setPortProperties(2);
+ NiteSecServer.messages.push("democracy-is-dead.lit");
+ AddToAllServers(NiteSecServer);
+ _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerIps"].addIp(_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerNames"].NiteSecServer, NiteSecServer.ip);
+
+ var DarkArmyServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), ".", ".", false, false, false, 0);
+ DarkArmyServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(505, 550), 0, 0, 0);
+ DarkArmyServer.setPortProperties(4);
+ AddToAllServers(DarkArmyServer);
+ _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerIps"].addIp(_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerNames"].TheDarkArmyServer, DarkArmyServer.ip);
+
+ var CyberSecServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "CSEC", "CyberSec", false, false, false, 2);
+ CyberSecServer.setHackingParameters(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(51, 60), 0, 0, 0);
+ CyberSecServer.setPortProperties(1);
+ CyberSecServer.messages.push("democracy-is-dead.lit");
+ AddToAllServers(CyberSecServer);
+ _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerIps"].addIp(_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerNames"].CyberSecServer, CyberSecServer.ip);
+
+ var DaedalusServer = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), "The-Cave", "Helios", false, false, false, 2);
+ DaedalusServer.setHackingParameters(925, 0, 0, 0);
+ DaedalusServer.setPortProperties(5);
+ DaedalusServer.messages.push("alpha-omega.lit");
+ AddToAllServers(DaedalusServer);
+ _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerIps"].addIp(_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerNames"].DaedalusServer, DaedalusServer.ip);
+
+ //Super special Servers
+ var WorldDaemon = new Server(Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["createRandomIp"])(), _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerNames"].WorldDaemon, _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerNames"].WorldDaemon, false, false, false, 0);
+ WorldDaemon.setHackingParameters(3000, 0, 0, 0);
+ WorldDaemon.setPortProperties(5);
+ AddToAllServers(WorldDaemon);
+ _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerIps"].addIp(_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_5__["SpecialServerNames"].WorldDaemon, WorldDaemon.ip);
+
+ /* Create a randomized network for all the foreign servers */
+ //Groupings for creating a randomized network
+ var NetworkGroup1 = [IronGymServer, FoodNStuffServer, SigmaCosmeticsServer, JoesGunsServer, HongFangTeaHouseServer, HaraKiriSushiBarServer];
+ var NetworkGroup2 = [MaxHardwareServer, NectarNightclubServer, Zer0NightclubServer, CyberSecServer];
+ var NetworkGroup3 = [OmegaSoftwareServer, PhantasyServer, SilverHelixServer, NeoNightclubServer];
+ var NetworkGroup4 = [CrushFitnessGymServer, NetLinkTechnologiesServer, CompuTekServer, TheHubServer, JohnsonOrthopedicsServer, NiteSecServer];
+ var NetworkGroup5 = [CatalystVenturesServer, SysCoreSecuritiesServer, SummitUniversityServer, ZBInstituteOfTechnologyServer, RothmanUniversityServer, TheBlackHandServer];
+ var NetworkGroup6 = [LexoCorpServer, RhoConstructionServer, AlphaEnterprisesServer, AevumPoliceServer, MilleniumFitnessGymServer];
+ var NetworkGroup7 = [GlobalPharmaceuticalsServer, AeroCorpServer, GalacticCyberSystemsServer, SnapFitnessGymServer];
+ var NetworkGroup8 = [DeltaOneServer, UnitaLifeGroupServer, OmniaCybersystemsServer];
+ var NetworkGroup9 = [ZeusMedicalServer, SolarisSpaceSystemsServer, UniversalEnergyServer, IcarusMicrosystemsServer, DefCommServer];
+ var NetworkGroup10 = [NovaMedicalServer, ZBDefenseServer, TaiYangDigitalServer, InfoCommServer];
+ var NetworkGroup11 = [AppliedEnergeticsServer, MicrodyneTechnologiesServer, TitanLabsServer, BitRunnersServer];
+ var NetworkGroup12 = [VitaLifeServer, HeliosLabsServer, StormTechnologiesServer, FulcrumTechnologiesServer];
+ var NetworkGroup13 = [KuaiGongInternationalServer, FourSigmaServer, OmniTekIncorporatedServer, DarkArmyServer];
+ var NetworkGroup14 = [PowerhouseGymServer, ClarkeIncorporatedServer, NWOServer, BladeIndustriesServer, BachmanAndAssociatesServer];
+ var NetworkGroup15 = [FulcrumSecretTechnologiesServer, MegaCorpServer, ECorpServer, DaedalusServer];
+
+ for (var i = 0; i < NetworkGroup2.length; i++) {
+ var randomServerFromPrevGroup = NetworkGroup1[Math.floor(Math.random() * NetworkGroup1.length)];
+ NetworkGroup2[i].serversOnNetwork.push(randomServerFromPrevGroup.ip);
+ randomServerFromPrevGroup.serversOnNetwork.push(NetworkGroup2[i].ip);
+ }
+
+ for (var i = 0; i < NetworkGroup3.length; i++) {
+ var randomServerFromPrevGroup = NetworkGroup2[Math.floor(Math.random() * NetworkGroup2.length)];
+ NetworkGroup3[i].serversOnNetwork.push(randomServerFromPrevGroup.ip);
+ randomServerFromPrevGroup.serversOnNetwork.push(NetworkGroup3[i].ip);
+ }
+
+ for (var i = 0; i < NetworkGroup4.length; i++) {
+ var randomServerFromPrevGroup = NetworkGroup3[Math.floor(Math.random() * NetworkGroup3.length)];
+ NetworkGroup4[i].serversOnNetwork.push(randomServerFromPrevGroup.ip);
+ randomServerFromPrevGroup.serversOnNetwork.push(NetworkGroup4[i].ip);
+ }
+
+ for (var i = 0; i < NetworkGroup5.length; i++) {
+ var randomServerFromPrevGroup = NetworkGroup4[Math.floor(Math.random() * NetworkGroup4.length)];
+ NetworkGroup5[i].serversOnNetwork.push(randomServerFromPrevGroup.ip);
+ randomServerFromPrevGroup.serversOnNetwork.push(NetworkGroup5[i].ip);
+ }
+
+ for (var i = 0; i < NetworkGroup6.length; i++) {
+ var randomServerFromPrevGroup = NetworkGroup5[Math.floor(Math.random() * NetworkGroup5.length)];
+ NetworkGroup6[i].serversOnNetwork.push(randomServerFromPrevGroup.ip);
+ randomServerFromPrevGroup.serversOnNetwork.push(NetworkGroup6[i].ip);
+ }
+
+ for (var i = 0; i < NetworkGroup7.length; i++) {
+ var randomServerFromPrevGroup = NetworkGroup6[Math.floor(Math.random() * NetworkGroup6.length)];
+ NetworkGroup7[i].serversOnNetwork.push(randomServerFromPrevGroup.ip);
+ randomServerFromPrevGroup.serversOnNetwork.push(NetworkGroup7[i].ip);
+ }
+
+ for (var i = 0; i < NetworkGroup8.length; i++) {
+ var randomServerFromPrevGroup = NetworkGroup7[Math.floor(Math.random() * NetworkGroup7.length)];
+ NetworkGroup8[i].serversOnNetwork.push(randomServerFromPrevGroup.ip);
+ randomServerFromPrevGroup.serversOnNetwork.push(NetworkGroup8[i].ip);
+ }
+
+ for (var i = 0; i < NetworkGroup9.length; i++) {
+ var randomServerFromPrevGroup = NetworkGroup8[Math.floor(Math.random() * NetworkGroup8.length)];
+ NetworkGroup9[i].serversOnNetwork.push(randomServerFromPrevGroup.ip);
+ randomServerFromPrevGroup.serversOnNetwork.push(NetworkGroup9[i].ip);
+ }
+
+ for (var i = 0; i < NetworkGroup10.length; i++) {
+ var randomServerFromPrevGroup = NetworkGroup9[Math.floor(Math.random() * NetworkGroup9.length)];
+ NetworkGroup10[i].serversOnNetwork.push(randomServerFromPrevGroup.ip);
+ randomServerFromPrevGroup.serversOnNetwork.push(NetworkGroup10[i].ip);
+ }
+
+ for (var i = 0; i < NetworkGroup11.length; i++) {
+ var randomServerFromPrevGroup = NetworkGroup10[Math.floor(Math.random() * NetworkGroup10.length)];
+ NetworkGroup11[i].serversOnNetwork.push(randomServerFromPrevGroup.ip);
+ randomServerFromPrevGroup.serversOnNetwork.push(NetworkGroup11[i].ip);
+ }
+
+ for (var i = 0; i < NetworkGroup12.length; i++) {
+ var randomServerFromPrevGroup = NetworkGroup11[Math.floor(Math.random() * NetworkGroup11.length)];
+ NetworkGroup12[i].serversOnNetwork.push(randomServerFromPrevGroup.ip);
+ randomServerFromPrevGroup.serversOnNetwork.push(NetworkGroup12[i].ip);
+ }
+
+ for (var i = 0; i < NetworkGroup13.length; i++) {
+ var randomServerFromPrevGroup = NetworkGroup12[Math.floor(Math.random() * NetworkGroup12.length)];
+ NetworkGroup13[i].serversOnNetwork.push(randomServerFromPrevGroup.ip);
+ randomServerFromPrevGroup.serversOnNetwork.push(NetworkGroup13[i].ip);
+ }
+
+ for (var i = 0; i < NetworkGroup14.length; i++) {
+ var randomServerFromPrevGroup = NetworkGroup13[Math.floor(Math.random() * NetworkGroup13.length)];
+ NetworkGroup14[i].serversOnNetwork.push(randomServerFromPrevGroup.ip);
+ randomServerFromPrevGroup.serversOnNetwork.push(NetworkGroup14[i].ip);
+ }
+
+ for (var i = 0; i < NetworkGroup15.length; i++) {
+ var randomServerFromPrevGroup = NetworkGroup14[Math.floor(Math.random() * NetworkGroup14.length)];
+ NetworkGroup15[i].serversOnNetwork.push(randomServerFromPrevGroup.ip);
+ randomServerFromPrevGroup.serversOnNetwork.push(NetworkGroup15[i].ip);
+ }
+
+ //Connect the first tier of servers to the player's home computer
+ for (var i = 0; i < NetworkGroup1.length; i++) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].getHomeComputer().serversOnNetwork.push(NetworkGroup1[i].ip);
+ NetworkGroup1[i].serversOnNetwork.push(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].homeComputer);
+ }
+}
+
+//Applied server growth for a single server. Returns the percentage growth
+function processSingleServerGrowth(server, numCycles) {
+ //Server growth processed once every 450 game cycles
+ var numServerGrowthCycles = Math.max(Math.floor(numCycles / 450), 0);
+
+ //Get adjusted growth rate, which accounts for server security
+ var growthRate = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].ServerBaseGrowthRate;
+ var adjGrowthRate = 1 + (growthRate - 1) / server.hackDifficulty;
+ if (adjGrowthRate > _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].ServerMaxGrowthRate) {adjGrowthRate = _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].ServerMaxGrowthRate;}
+
+ //Calculate adjusted server growth rate based on parameters
+ var serverGrowthPercentage = server.serverGrowth / 100;
+ var numServerGrowthCyclesAdjusted = numServerGrowthCycles * serverGrowthPercentage * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].ServerGrowthRate;
+
+ //Apply serverGrowth for the calculated number of growth cycles
+ var serverGrowth = Math.pow(adjGrowthRate, numServerGrowthCyclesAdjusted * _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_grow_mult);
+ if (serverGrowth < 1) {
+ console.log("WARN: serverGrowth calculated to be less than 1");
+ serverGrowth = 1;
+ }
+
+ var oldMoneyAvailable = server.moneyAvailable;
+ server.moneyAvailable *= serverGrowth;
+ if (server.moneyMax && isNaN(server.moneyAvailable)) {
+ server.moneyAvailable = server.moneyMax;
+ }
+ if (server.moneyMax && server.moneyAvailable > server.moneyMax) {
+ server.moneyAvailable = server.moneyMax;
+ return server.moneyAvailable / oldMoneyAvailable;
+ }
+
+ //Growing increases server security twice as much as hacking
+ server.fortify(2 * _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].ServerFortifyAmount * numServerGrowthCycles);
+ return serverGrowth;
+}
+
+function prestigeHomeComputer(homeComp) {
+ homeComp.programs.length = 0; //Remove programs
+ homeComp.runningScripts = [];
+ homeComp.serversOnNetwork = [];
+ homeComp.isConnectedTo = true;
+ homeComp.ramUsed = 0;
+ homeComp.programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].NukeProgram);
+
+ //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_js__WEBPACK_IMPORTED_MODULE_8__["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_js__WEBPACK_IMPORTED_MODULE_7__["ipExists"])(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_IPAddress_js__WEBPACK_IMPORTED_MODULE_7__["isValidIPAddress"])(s)) {
+ return GetServerByHostname(s);
+ } else {
+ return AllServers[s];
+ }
+}
+
+//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("");
+}
+
+
+
+
+/***/ }),
+/* 11 */
+/*!***************************!*\
+ !*** ./utils/YesNoBox.js ***!
+ \***************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoBoxCreate", function() { return yesNoBoxCreate; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoTxtInpBoxCreate", function() { return yesNoTxtInpBoxCreate; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoBoxGetYesButton", function() { return yesNoBoxGetYesButton; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoBoxGetNoButton", function() { return yesNoBoxGetNoButton; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoTxtInpBoxGetYesButton", function() { return yesNoTxtInpBoxGetYesButton; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoTxtInpBoxGetNoButton", function() { return yesNoTxtInpBoxGetNoButton; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoTxtInpBoxGetInput", function() { return yesNoTxtInpBoxGetInput; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoBoxClose", function() { return yesNoBoxClose; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoTxtInpBoxClose", function() { return yesNoTxtInpBoxClose; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "yesNoBoxOpen", function() { return yesNoBoxOpen; });
+/* harmony import */ var _HelperFunctions_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./HelperFunctions.js */ 1);
+
+/* Generic Yes-No Pop-up box
+ * Can be used to create pop-up boxes that require a yes/no response from player
+ */
+var yesNoBoxOpen = false;
+function yesNoBoxClose() {
+ var container = document.getElementById("yes-no-box-container");
+ if (container) {
+ container.style.display = "none";
+ } else {
+ console.log("ERROR: Container not found for YesNoBox");
+ }
+ yesNoBoxOpen = false;
+ return false; //So that 'return yesNoBoxClose()' is return false in event listeners
+}
+
+function yesNoBoxGetYesButton() {
+ return Object(_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_0__["clearEventListeners"])("yes-no-box-yes");
+}
+
+function yesNoBoxGetNoButton() {
+ return Object(_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_0__["clearEventListeners"])("yes-no-box-no");
+}
+
+function yesNoBoxCreate(txt) {
+ if (yesNoBoxOpen) {return false;} //Already open
+ yesNoBoxOpen = true;
+ var textElement = document.getElementById("yes-no-box-text");
+ if (textElement) {
+ textElement.innerHTML = txt;
+ }
+
+ var c = document.getElementById("yes-no-box-container");
+ if (c) {
+ c.style.display = "block";
+ } else {
+ console.log("ERROR: Container not found for YesNoBox");
+ }
+ return true;
+}
+
+/* Generic Yes-No POp-up Box with Text input */
+function yesNoTxtInpBoxClose() {
+ var c = document.getElementById("yes-no-text-input-box-container");
+ if (c) {
+ c.style.display = "none";
+ } else {
+ console.log("ERROR: Container not found for YesNoTextInputBox");
+ }
+ yesNoBoxOpen = false;
+ document.getElementById("yes-no-text-input-box-input").value = "";
+ return false;
+}
+
+function yesNoTxtInpBoxGetYesButton() {
+ return Object(_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_0__["clearEventListeners"])("yes-no-text-input-box-yes");
+}
+
+function yesNoTxtInpBoxGetNoButton() {
+ return Object(_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_0__["clearEventListeners"])("yes-no-text-input-box-no");
+}
+
+function yesNoTxtInpBoxGetInput() {
+ var val = document.getElementById("yes-no-text-input-box-input").value;
+ val = val.replace(/\s+/g, '');
+ return val;
+}
+
+function yesNoTxtInpBoxCreate(txt) {
+ yesNoBoxOpen = true;
+ var txtE = document.getElementById("yes-no-text-input-box-text");
+ if (txtE) {
+ txtE.innerHTML = txt;
+ }
+
+ var c = document.getElementById("yes-no-text-input-box-container");
+ if (c) {
+ c.style.display = "block";
+ } else {
+ console.log("ERROR: Container not found for YesNoTextInputBox");
+ }
+
+ document.getElementById("yes-no-text-input-box-input").focus();
+}
+
+
+
+
+/***/ }),
+/* 12 */
+/*!******************************!*\
+ !*** ./utils/numeral.min.js ***!
+ \******************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+var __WEBPACK_AMD_DEFINE_FACTORY__, __WEBPACK_AMD_DEFINE_RESULT__;/*! @preserve
+ * numeral.js
+ * version : 2.0.6
+ * author : Adam Draper
+ * license : MIT
+ * http://adamwdraper.github.com/Numeral-js/
+ */
+!function(a,b){ true?!(__WEBPACK_AMD_DEFINE_FACTORY__ = (b),
+ __WEBPACK_AMD_DEFINE_RESULT__ = (typeof __WEBPACK_AMD_DEFINE_FACTORY__ === 'function' ?
+ (__WEBPACK_AMD_DEFINE_FACTORY__.call(exports, __webpack_require__, exports, module)) :
+ __WEBPACK_AMD_DEFINE_FACTORY__),
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__)):undefined}(this,function(){function a(a,b){this._input=a,this._value=b}var b,c,d="2.0.6",e={},f={},g={currentLocale:"en",zeroFormat:null,nullFormat:null,defaultFormat:"0,0",scalePercentBy100:!0},h={currentLocale:g.currentLocale,zeroFormat:g.zeroFormat,nullFormat:g.nullFormat,defaultFormat:g.defaultFormat,scalePercentBy100:g.scalePercentBy100};return b=function(d){var f,g,i,j;if(b.isNumeral(d))f=d.value();else if(0===d||"undefined"==typeof d)f=0;else if(null===d||c.isNaN(d))f=null;else if("string"==typeof d)if(h.zeroFormat&&d===h.zeroFormat)f=0;else if(h.nullFormat&&d===h.nullFormat||!d.replace(/[^0-9]+/g,"").length)f=null;else{for(g in e)if(j="function"==typeof e[g].regexps.unformat?e[g].regexps.unformat():e[g].regexps.unformat,j&&d.match(j)){i=e[g].unformat;break}i=i||b._.stringToNumber,f=i(d)}else f=Number(d)||null;return new a(d,f)},b.version=d,b.isNumeral=function(b){return b instanceof a},b._=c={numberToFormat:function(a,c,d){var e,g,h,i,j,k,l,m=f[b.options.currentLocale],n=!1,o=!1,p=0,q="",r=1e12,s=1e9,t=1e6,u=1e3,v="",w=!1;if(a=a||0,g=Math.abs(a),b._.includes(c,"(")?(n=!0,c=c.replace(/[\(|\)]/g,"")):(b._.includes(c,"+")||b._.includes(c,"-"))&&(j=b._.includes(c,"+")?c.indexOf("+"):0>a?c.indexOf("-"):-1,c=c.replace(/[\+|\-]/g,"")),b._.includes(c,"a")&&(e=c.match(/a(k|m|b|t)?/),e=e?e[1]:!1,b._.includes(c," a")&&(q=" "),c=c.replace(new RegExp(q+"a[kmbt]?"),""),g>=r&&!e||"t"===e?(q+=m.abbreviations.trillion,a/=r):r>g&&g>=s&&!e||"b"===e?(q+=m.abbreviations.billion,a/=s):s>g&&g>=t&&!e||"m"===e?(q+=m.abbreviations.million,a/=t):(t>g&&g>=u&&!e||"k"===e)&&(q+=m.abbreviations.thousand,a/=u)),b._.includes(c,"[.]")&&(o=!0,c=c.replace("[.]",".")),h=a.toString().split(".")[0],i=c.split(".")[1],k=c.indexOf(","),p=(c.split(".")[0].split(",")[0].match(/0/g)||[]).length,i?(b._.includes(i,"[")?(i=i.replace("]",""),i=i.split("["),v=b._.toFixed(a,i[0].length+i[1].length,d,i[1].length)):v=b._.toFixed(a,i.length,d),h=v.split(".")[0],v=b._.includes(v,".")?m.delimiters.decimal+v.split(".")[1]:"",o&&0===Number(v.slice(1))&&(v="")):h=b._.toFixed(a,0,d),q&&!e&&Number(h)>=1e3&&q!==m.abbreviations.trillion)switch(h=String(Number(h)/1e3),q){case m.abbreviations.thousand:q=m.abbreviations.million;break;case m.abbreviations.million:q=m.abbreviations.billion;break;case m.abbreviations.billion:q=m.abbreviations.trillion}if(b._.includes(h,"-")&&(h=h.slice(1),w=!0),h.length
0;x--)h="0"+h;return k>-1&&(h=h.toString().replace(/(\d)(?=(\d{3})+(?!\d))/g,"$1"+m.delimiters.thousands)),0===c.indexOf(".")&&(h=""),l=h+v+(q?q:""),n?l=(n&&w?"(":"")+l+(n&&w?")":""):j>=0?l=0===j?(w?"-":"+")+l:l+(w?"-":"+"):w&&(l="-"+l),l},stringToNumber:function(a){var b,c,d,e=f[h.currentLocale],g=a,i={thousand:3,million:6,billion:9,trillion:12};if(h.zeroFormat&&a===h.zeroFormat)c=0;else if(h.nullFormat&&a===h.nullFormat||!a.replace(/[^0-9]+/g,"").length)c=null;else{c=1,"."!==e.delimiters.decimal&&(a=a.replace(/\./g,"").replace(e.delimiters.decimal,"."));for(b in i)if(d=new RegExp("[^a-zA-Z]"+e.abbreviations[b]+"(?:\\)|(\\"+e.currency.symbol+")?(?:\\))?)?$"),g.match(d)){c*=Math.pow(10,i[b]);break}c*=(a.split("-").length+Math.min(a.split("(").length-1,a.split(")").length-1))%2?1:-1,a=a.replace(/[^0-9\.]+/g,""),c*=Number(a)}return c},isNaN:function(a){return"number"==typeof a&&isNaN(a)},includes:function(a,b){return-1!==a.indexOf(b)},insert:function(a,b,c){return a.slice(0,c)+b+a.slice(c)},reduce:function(a,b){if(null===this)throw new TypeError("Array.prototype.reduce called on null or undefined");if("function"!=typeof b)throw new TypeError(b+" is not a function");var c,d=Object(a),e=d.length>>>0,f=0;if(3===arguments.length)c=arguments[2];else{for(;e>f&&!(f in d);)f++;if(f>=e)throw new TypeError("Reduce of empty array with no initial value");c=d[f++]}for(;e>f;f++)f in d&&(c=b(c,d[f],f,d));return c},multiplier:function(a){var b=a.toString().split(".");return b.length<2?1:Math.pow(10,b[1].length)},correctionFactor:function(){var a=Array.prototype.slice.call(arguments);return a.reduce(function(a,b){var d=c.multiplier(b);return a>d?a:d},1)},toFixed:function(a,b,c,d){var e,f,g,h,i=a.toString().split("."),j=b-(d||0);return e=2===i.length?Math.min(Math.max(i[1].length,j),b):j,g=Math.pow(10,e),h=(c(a+"e+"+e)/g).toFixed(e),d>b-e&&(f=new RegExp("\\.?0{1,"+(d-(b-e))+"}$"),h=h.replace(f,"")),h}},b.options=h,b.formats=e,b.locales=f,b.locale=function(a){return a&&(h.currentLocale=a.toLowerCase()),h.currentLocale},b.localeData=function(a){if(!a)return f[h.currentLocale];if(a=a.toLowerCase(),!f[a])throw new Error("Unknown locale : "+a);return f[a]},b.reset=function(){for(var a in g)h[a]=g[a]},b.zeroFormat=function(a){h.zeroFormat="string"==typeof a?a:null},b.nullFormat=function(a){h.nullFormat="string"==typeof a?a:null},b.defaultFormat=function(a){h.defaultFormat="string"==typeof a?a:"0.0"},b.register=function(a,b,c){if(b=b.toLowerCase(),this[a+"s"][b])throw new TypeError(b+" "+a+" already registered.");return this[a+"s"][b]=c,c},b.validate=function(a,c){var d,e,f,g,h,i,j,k;if("string"!=typeof a&&(a+="",console.warn&&console.warn("Numeral.js: Value is not string. It has been co-erced to: ",a)),a=a.trim(),a.match(/^\d+$/))return!0;if(""===a)return!1;try{j=b.localeData(c)}catch(l){j=b.localeData(b.locale())}return f=j.currency.symbol,h=j.abbreviations,d=j.delimiters.decimal,e="."===j.delimiters.thousands?"\\.":j.delimiters.thousands,k=a.match(/^[^\d]+/),null!==k&&(a=a.substr(1),k[0]!==f)?!1:(k=a.match(/[^\d]+$/),null!==k&&(a=a.slice(0,-1),k[0]!==h.thousand&&k[0]!==h.million&&k[0]!==h.billion&&k[0]!==h.trillion)?!1:(i=new RegExp(e+"{2}"),a.match(/[^\d.,]/g)?!1:(g=a.split(d),g.length>2?!1:g.length<2?!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i):1===g[0].length?!!g[0].match(/^\d+$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/):!!g[0].match(/^\d+.*\d$/)&&!g[0].match(i)&&!!g[1].match(/^\d+$/))))},b.fn=a.prototype={clone:function(){return b(this)},format:function(a,c){var d,f,g,i=this._value,j=a||h.defaultFormat;if(c=c||Math.round,0===i&&null!==h.zeroFormat)f=h.zeroFormat;else if(null===i&&null!==h.nullFormat)f=h.nullFormat;else{for(d in e)if(j.match(e[d].regexps.format)){g=e[d].format;break}g=g||b._.numberToFormat,f=g(i,j,c)}return f},value:function(){return this._value},input:function(){return this._input},set:function(a){return this._value=Number(a),this},add:function(a){function b(a,b,c,e){return a+Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([this._value,a],b,0)/d,this},subtract:function(a){function b(a,b,c,e){return a-Math.round(d*b)}var d=c.correctionFactor.call(null,this._value,a);return this._value=c.reduce([a],b,Math.round(this._value*d))/d,this},multiply:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)*Math.round(b*f)/Math.round(f*f)}return this._value=c.reduce([this._value,a],b,1),this},divide:function(a){function b(a,b,d,e){var f=c.correctionFactor(a,b);return Math.round(a*f)/Math.round(b*f)}return this._value=c.reduce([this._value,a],b),this},difference:function(a){return Math.abs(b(this._value).subtract(a).value())}},b.register("locale","en",{delimiters:{thousands:",",decimal:"."},abbreviations:{thousand:"k",million:"m",billion:"b",trillion:"t"},ordinal:function(a){var b=a%10;return 1===~~(a%100/10)?"th":1===b?"st":2===b?"nd":3===b?"rd":"th"},currency:{symbol:"$"}}),function(){b.register("format","bps",{regexps:{format:/(BPS)/,unformat:/(BPS)/},format:function(a,c,d){var e,f=b._.includes(c," BPS")?" ":"";return a=1e4*a,c=c.replace(/\s?BPS/,""),e=b._.numberToFormat(a,c,d),b._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"BPS"),e=e.join("")):e=e+f+"BPS",e},unformat:function(a){return+(1e-4*b._.stringToNumber(a)).toFixed(15)}})}(),function(){var a={base:1e3,suffixes:["B","KB","MB","GB","TB","PB","EB","ZB","YB"]},c={base:1024,suffixes:["B","KiB","MiB","GiB","TiB","PiB","EiB","ZiB","YiB"]},d=a.suffixes.concat(c.suffixes.filter(function(b){return a.suffixes.indexOf(b)<0})),e=d.join("|");e="("+e.replace("B","B(?!PS)")+")",b.register("format","bytes",{regexps:{format:/([0\s]i?b)/,unformat:new RegExp(e)},format:function(d,e,f){var g,h,i,j,k=b._.includes(e,"ib")?c:a,l=b._.includes(e," b")||b._.includes(e," ib")?" ":"";for(e=e.replace(/\s?i?b/,""),h=0;h<=k.suffixes.length;h++)if(i=Math.pow(k.base,h),j=Math.pow(k.base,h+1),null===d||0===d||d>=i&&j>d){l+=k.suffixes[h],i>0&&(d/=i);break}return g=b._.numberToFormat(d,e,f),g+l},unformat:function(d){var e,f,g=b._.stringToNumber(d);if(g){for(e=a.suffixes.length-1;e>=0;e--){if(b._.includes(d,a.suffixes[e])){f=Math.pow(a.base,e);break}if(b._.includes(d,c.suffixes[e])){f=Math.pow(c.base,e);break}}g*=f||1}return g}})}(),function(){b.register("format","currency",{regexps:{format:/(\$)/},format:function(a,c,d){var e,f,g,h=b.locales[b.options.currentLocale],i={before:c.match(/^([\+|\-|\(|\s|\$]*)/)[0],after:c.match(/([\+|\-|\)|\s|\$]*)$/)[0]};for(c=c.replace(/\s?\$\s?/,""),e=b._.numberToFormat(a,c,d),a>=0?(i.before=i.before.replace(/[\-\(]/,""),i.after=i.after.replace(/[\-\)]/,"")):0>a&&!b._.includes(i.before,"-")&&!b._.includes(i.before,"(")&&(i.before="-"+i.before),g=0;g=0;g--)switch(f=i.after[g]){case"$":e=g===i.after.length-1?e+h.currency.symbol:b._.insert(e,h.currency.symbol,-(i.after.length-(1+g)));break;case" ":e=g===i.after.length-1?e+" ":b._.insert(e," ",-(i.after.length-(1+g)+h.currency.symbol.length-1))}return e}})}(),function(){b.register("format","exponential",{regexps:{format:/(e\+|e-)/,unformat:/(e\+|e-)/},format:function(a,c,d){var e,f="number"!=typeof a||b._.isNaN(a)?"0e+0":a.toExponential(),g=f.split("e");return c=c.replace(/e[\+|\-]{1}0/,""),e=b._.numberToFormat(Number(g[0]),c,d),e+"e"+g[1]},unformat:function(a){function c(a,c,d,e){var f=b._.correctionFactor(a,c),g=a*f*(c*f)/(f*f);return g}var d=b._.includes(a,"e+")?a.split("e+"):a.split("e-"),e=Number(d[0]),f=Number(d[1]);return f=b._.includes(a,"e-")?f*=-1:f,b._.reduce([e,Math.pow(10,f)],c,1)}})}(),function(){b.register("format","ordinal",{regexps:{format:/(o)/},format:function(a,c,d){var e,f=b.locales[b.options.currentLocale],g=b._.includes(c," o")?" ":"";return c=c.replace(/\s?o/,""),g+=f.ordinal(a),e=b._.numberToFormat(a,c,d),e+g}})}(),function(){b.register("format","percentage",{regexps:{format:/(%)/,unformat:/(%)/},format:function(a,c,d){var e,f=b._.includes(c," %")?" ":"";return b.options.scalePercentBy100&&(a=100*a),c=c.replace(/\s?\%/,""),e=b._.numberToFormat(a,c,d),b._.includes(e,")")?(e=e.split(""),e.splice(-1,0,f+"%"),e=e.join("")):e=e+f+"%",e},unformat:function(a){var c=b._.stringToNumber(a);return b.options.scalePercentBy100?.01*c:c}})}(),function(){b.register("format","time",{regexps:{format:/(:)/,unformat:/(:)/},format:function(a,b,c){var d=Math.floor(a/60/60),e=Math.floor((a-60*d*60)/60),f=Math.round(a-60*d*60-60*e);return d+":"+(10>e?"0"+e:e)+":"+(10>f?"0"+f:f)},unformat:function(a){var b=a.split(":"),c=0;return 3===b.length?(c+=60*Number(b[0])*60,c+=60*Number(b[1]),c+=Number(b[2])):2===b.length&&(c+=60*Number(b[0]),c+=Number(b[1])),Number(c)}})}(),b});
+
+/***/ }),
+/* 13 */
+/*!******************************!*\
+ !*** ./src/CreateProgram.js ***!
+ \******************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Programs", function() { return Programs; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayCreateProgramContent", function() { return displayCreateProgramContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNumAvailableCreateProgram", function() { return getNumAvailableCreateProgram; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initCreateProgramButtons", function() { return initCreateProgramButtons; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+
+
+
+
+/* Create programs */
+let Programs = {
+ NukeProgram: "NUKE.exe",
+ BruteSSHProgram: "BruteSSH.exe",
+ FTPCrackProgram: "FTPCrack.exe",
+ RelaySMTPProgram: "relaySMTP.exe",
+ HTTPWormProgram: "HTTPWorm.exe",
+ SQLInjectProgram: "SQLInject.exe",
+ DeepscanV1: "DeepscanV1.exe",
+ DeepscanV2: "DeepscanV2.exe",
+ ServerProfiler: "ServerProfiler.exe",
+ AutoLink: "AutoLink.exe",
+ Flight: "fl1ght.exe",
+ BitFlume: "b1t_flum3.exe"
+};
+
+var nukeALink, bruteSshALink, ftpCrackALink, relaySmtpALink, httpWormALink, sqlInjectALink,
+ deepscanv1ALink, deepscanv2ALink, servProfilerALink, autolinkALink, bitFlumeALink;
+function displayCreateProgramContent() {
+ nukeALink.style.display = "none";
+ bruteSshALink.style.display = "none";
+ ftpCrackALink.style.display = "none";
+ relaySmtpALink.style.display = "none";
+ httpWormALink.style.display = "none";
+ sqlInjectALink.style.display = "none";
+ deepscanv1ALink.style.display = "none";
+ deepscanv2ALink.style.display = "none";
+ servProfilerALink.style.display = "none";
+ autolinkALink.style.display = "none";
+ bitFlumeALink.style.display = "none";
+
+ //NUKE.exe (in case you delete it lol)
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.NukeProgram) == -1) {
+ nukeALink.style.display = "inline-block";
+ }
+ //BruteSSH
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.BruteSSHProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 50) {
+ bruteSshALink.style.display = "inline-block";
+ }
+ //FTPCrack
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.FTPCrackProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 100) {
+ ftpCrackALink.style.display = "inline-block";
+ }
+ //relaySMTP
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.RelaySMTPProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 250) {
+ relaySmtpALink.style.display = "inline-block";
+ }
+ //HTTPWorm
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.HTTPWormProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 500) {
+ httpWormALink.style.display = "inline-block";
+ }
+ //SQLInject
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.SQLInjectProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 750) {
+ sqlInjectALink.style.display = "inline-block";
+ }
+ //Deepscan V1 and V2
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.DeepscanV1) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 75) {
+ deepscanv1ALink.style.display = "inline-block";
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.DeepscanV2) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 400) {
+ deepscanv2ALink.style.display = "inline-block";
+ }
+ //Server profiler
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.ServerProfiler) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 75) {
+ servProfilerALink.style.display = "inline-block";
+ }
+ //Auto Link
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.AutoLink) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 25) {
+ autolinkALink.style.display = "inline-block";
+ }
+ //Bit Flume
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.BitFlume) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].sourceFiles.length > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 5) {
+ bitFlumeALink.style.display = "inline-block";
+ }
+}
+
+//Returns the number of programs that are currently available to be created
+function getNumAvailableCreateProgram() {
+ var count = 0;
+ //PortHack.exe (in case you delete it lol)
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.NukeProgram) == -1) {
+ ++count;
+ }
+ //BruteSSH
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.BruteSSHProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 50) {
+ ++count;
+ }
+ //FTPCrack
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.FTPCrackProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 100) {
+ ++count;
+ }
+ //relaySMTP
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.RelaySMTPProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 250) {
+ ++count;
+ }
+ //HTTPWorm
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.HTTPWormProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 500) {
+ ++count;
+ }
+ //SQLInject
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.indexOf(Programs.SQLInjectProgram) == -1 &&
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 750) {
+ ++count;
+ }
+ //Deepscan V1 and V2
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.DeepscanV1) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 75) {
+ ++count;
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.DeepscanV2) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 400) {
+ ++count;
+ }
+ //Server profiler
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.ServerProfiler) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 75) {
+ ++count;
+ }
+ //Auto link
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.AutoLink) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 25) {
+ ++count;
+ }
+ //Bit Flume
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hasProgram(Programs.BitFlume) && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].sourceFiles.length > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill >= 5) {
+ ++count;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].firstProgramAvailable === false && count > 0) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].firstProgramAvailable = true;
+ document.getElementById("create-program-tab").style.display = "list-item";
+ document.getElementById("hacking-menu-header").click();
+ document.getElementById("hacking-menu-header").click();
+ }
+ return count;
+}
+
+function initCreateProgramButtons() {
+ var createProgramList = document.getElementById("create-program-list");
+ nukeALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-nuke", innerText:Programs.NukeProgram,
+ tooltip:"This virus is used to gain root access to a machine if enough ports are opened.",
+ });
+ createProgramList.appendChild(nukeALink);
+
+ bruteSshALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-brutessh", innerText:Programs.BruteSSHProgram,
+ tooltip:"This program executes a brute force attack that opens SSH ports"
+ });
+ createProgramList.appendChild(bruteSshALink);
+
+ ftpCrackALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-ftpcrack", innerText:Programs.FTPCrackProgram,
+ tooltip:"This program cracks open FTP ports"
+ });
+ createProgramList.appendChild(ftpCrackALink);
+
+ relaySmtpALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-relaysmtp", innerText:Programs.RelaySMTPProgram,
+ tooltip:"This program opens SMTP ports by redirecting data"
+ }) ;
+ createProgramList.appendChild(relaySmtpALink);
+
+ httpWormALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-httpworm", innerText:Programs.HTTPWormProgram,
+ tooltip:"This virus opens up HTTP ports"
+ });
+ createProgramList.appendChild(httpWormALink);
+
+ sqlInjectALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-sqlinject", innerText:Programs.SQLInjectProgram,
+ tooltip:"This virus opens SQL ports"
+ });
+ createProgramList.appendChild(sqlInjectALink);
+
+ deepscanv1ALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-deepscanv1", innerText:Programs.DeepscanV1,
+ tooltip:"This program allows you to use the scan-analyze command with a depth up to 5"
+ });
+ createProgramList.appendChild(deepscanv1ALink);
+
+ deepscanv2ALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-deepscanv2", innerText:Programs.DeepscanV2,
+ tooltip:"This program allows you to use the scan-analyze command with a depth up to 10"
+ });
+ createProgramList.appendChild(deepscanv2ALink);
+
+ servProfilerALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-serverprofiler", innerText:Programs.ServerProfiler,
+ tooltip:"This program is used to display hacking and Netscript-related information about servers"
+ });
+ createProgramList.appendChild(servProfilerALink);
+
+ bitFlumeALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-bitflume", innerText:Programs.BitFlume,
+ tooltip:"This program creates a portal to the BitNode Nexus (allows you to restart and switch BitNodes)"
+ });
+ createProgramList.appendChild(bitFlumeALink);
+
+ autolinkALink = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_2__["createElement"])("a", {
+ class:"a-link-button", id:"create-program-autolink", innerText:"AutoLink.exe",
+ tooltip:"This program allows you to directly connect to other servers through the 'scan-analyze' command"
+ });
+ createProgramList.appendChild(autolinkALink);
+
+ nukeALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.NukeProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerFiveMinutes, 1);
+ return false;
+ });
+ bruteSshALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.BruteSSHProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerFiveMinutes * 2, 50);
+ return false;
+ });
+ ftpCrackALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.FTPCrackProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerHalfHour, 100);
+ return false;
+ });
+ relaySmtpALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.RelaySMTPProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPer2Hours, 250);
+ return false;
+ });
+ httpWormALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.HTTPWormProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPer4Hours, 500);
+ return false;
+ });
+ sqlInjectALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.SQLInjectProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPer8Hours, 750);
+ return false;
+ });
+ deepscanv1ALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.DeepscanV1, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerQuarterHour, 75);
+ return false;
+ });
+ deepscanv2ALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.DeepscanV2, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPer2Hours, 400);
+ return false;
+ });
+ servProfilerALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.ServerProfiler, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerHalfHour, 75);
+ return false;
+ });
+ autolinkALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.AutoLink, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerQuarterHour, 25);
+ return false;
+ });
+ bitFlumeALink.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCreateProgramWork(Programs.BitFlume, _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MillisecondsPerFiveMinutes / 5, 5);
+ return false;
+ });
+}
+
+
+
+
+/***/ }),
+/* 14 */
+/*!************************!*\
+ !*** ./src/Faction.js ***!
+ \************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "getNextNeurofluxLevel", function() { return getNextNeurofluxLevel; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Factions", function() { return Factions; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initFactions", function() { return initFactions; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inviteToFaction", function() { return inviteToFaction; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "joinFaction", function() { return joinFaction; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayFactionContent", function() { return displayFactionContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "processPassiveFactionRepGain", function() { return processPassiveFactionRepGain; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadFactions", function() { return loadFactions; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Faction", function() { return Faction; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "purchaseAugmentation", function() { return purchaseAugmentation; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "factionExists", function() { return factionExists; });
+/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Augmentations.js */ 18);
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./BitNode.js */ 16);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./FactionInfo.js */ 26);
+/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Location.js */ 4);
+/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Missions.js */ 32);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Settings.js */ 24);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_FactionInvitationBox_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/FactionInvitationBox.js */ 114);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
+/* harmony import */ var _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../utils/numeral.min.js */ 12);
+/* harmony import */ var _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_13___default = /*#__PURE__*/__webpack_require__.n(_utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_13__);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 11);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+function Faction(name="") {
+ this.name = name;
+ this.augmentations = []; //Name of augmentation only
+ this.info = ""; //Introductory/informational text about the faction
+
+ //Player-related properties for faction
+ this.isMember = false; //Whether player is member
+ this.isBanned = false; //Whether or not player is banned from joining this faction
+ this.playerReputation = 0; //"Reputation" within faction
+ this.alreadyInvited = false;
+
+ //Multipliers for unlocking and purchasing augmentations
+ this.augmentationPriceMult = 1;
+ this.augmentationRepRequirementMult = 1;
+
+ //Faction favor
+ this.favor = 0;
+ this.rolloverRep = 0;
+};
+
+Faction.prototype.setAugmentationMultipliers = function(price, rep) {
+ this.augmentationPriceMult = price;
+ this.augmentationRepRequirementMult = rep;
+}
+
+Faction.prototype.setInfo = function(inf) {
+ this.info = inf;
+}
+
+Faction.prototype.gainFavor = function() {
+ if (this.favor == null || this.favor == undefined) {this.favor = 0;}
+ if (this.rolloverRep == null || this.rolloverRep == undefined) {this.rolloverRep = 0;}
+ var res = this.getFavorGain();
+ if (res.length != 2) {
+ console.log("Error: invalid result from getFavorGain() function");
+ return;
+ }
+ this.favor += res[0];
+ this.rolloverRep = res[1];
+}
+
+//Returns an array with [How much favor would be gained, how much favor would be left over]
+Faction.prototype.getFavorGain = function() {
+ if (this.favor == null || this.favor == undefined) {this.favor = 0;}
+ if (this.rolloverRep == null || this.rolloverRep == undefined) {this.rolloverRep = 0;}
+ var favorGain = 0, rep = this.playerReputation + this.rolloverRep;
+ var reqdRep = _Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].FactionReputationToFavorBase *
+ Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].FactionReputationToFavorMult, this.favor);
+ while(rep > 0) {
+ if (rep >= reqdRep) {
+ ++favorGain;
+ rep -= reqdRep;
+ } else {
+ break;
+ }
+ reqdRep *= _Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].FactionReputationToFavorMult;
+ }
+ return [favorGain, rep];
+}
+
+//Adds all Augmentations to this faction.
+Faction.prototype.addAllAugmentations = function() {
+ this.augmentations.length = 0;
+ for (var name in _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"]) {
+ if (_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"].hasOwnProperty(name)) {
+ this.augmentations.push(name);
+ }
+ }
+}
+
+Faction.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_12__["Generic_toJSON"])("Faction", this);
+}
+
+Faction.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_12__["Generic_fromJSON"])(Faction, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_12__["Reviver"].constructors.Faction = Faction;
+
+//Map of factions indexed by faction name
+let Factions = {}
+
+function loadFactions(saveString) {
+ Factions = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_12__["Reviver"]);
+}
+
+function AddToFactions(faction) {
+ var name = faction.name;
+ Factions[name] = faction;
+}
+
+function factionExists(name) {
+ return Factions.hasOwnProperty(name);
+}
+
+//TODO Augmentation price and rep requirement mult are 1 for everything right now,
+// This might change in the future for balance
+function initFactions() {
+ //Endgame
+ var Illuminati = new Faction("Illuminati");
+ Illuminati.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].IlluminatiInfo);
+ resetFaction(Illuminati);
+
+ var Daedalus = new Faction("Daedalus");
+ Daedalus.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].DaedalusInfo);
+ resetFaction(Daedalus);
+
+ var Covenant = new Faction("The Covenant");
+ Covenant.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].CovenantInfo);
+ resetFaction(Covenant);
+
+ //Megacorporations, each forms its own faction
+ var ECorp = new Faction("ECorp");
+ ECorp.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].ECorpInfo);
+ resetFaction(ECorp);
+
+ var MegaCorp = new Faction("MegaCorp");
+ MegaCorp.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].MegaCorpInfo);
+ resetFaction(MegaCorp);
+
+ var BachmanAndAssociates = new Faction("Bachman & Associates");
+ BachmanAndAssociates.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].BachmanAndAssociatesInfo);
+ resetFaction(BachmanAndAssociates);
+
+ var BladeIndustries = new Faction("Blade Industries");
+ BladeIndustries.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].BladeIndustriesInfo);
+ resetFaction(BladeIndustries);
+
+ var NWO = new Faction("NWO");
+ NWO.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].NWOInfo);
+ resetFaction(NWO);
+
+ var ClarkeIncorporated = new Faction("Clarke Incorporated");
+ ClarkeIncorporated.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].ClarkeIncorporatedInfo);
+ resetFaction(ClarkeIncorporated);
+
+ var OmniTekIncorporated = new Faction("OmniTek Incorporated");
+ OmniTekIncorporated.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].OmniTekIncorporatedInfo);
+ resetFaction(OmniTekIncorporated);
+
+ var FourSigma = new Faction("Four Sigma");
+ FourSigma.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].FourSigmaInfo);
+ resetFaction(FourSigma);
+
+ var KuaiGongInternational = new Faction("KuaiGong International");
+ KuaiGongInternational.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].KuaiGongInternationalInfo);
+ resetFaction(KuaiGongInternational);
+
+ //Other corporations
+ var FulcrumTechnologies = new Faction("Fulcrum Secret Technologies");
+ FulcrumTechnologies.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].FulcrumSecretTechnologiesInfo);
+ resetFaction(FulcrumTechnologies);
+
+ //Hacker groups
+ var BitRunners = new Faction("BitRunners");
+ BitRunners.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].BitRunnersInfo);
+ resetFaction(BitRunners);
+
+ var BlackHand = new Faction("The Black Hand");
+ BlackHand.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].BlackHandInfo);
+ resetFaction(BlackHand);
+
+ var NiteSec = new Faction("NiteSec");
+ NiteSec.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].NiteSecInfo);
+ resetFaction(NiteSec);
+
+ //City factions, essentially governments
+ var Chongqing = new Faction("Chongqing");
+ Chongqing.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].ChongqingInfo);
+ resetFaction(Chongqing);
+
+ var Sector12 = new Faction("Sector-12");
+ Sector12.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].Sector12Info);
+ resetFaction(Sector12);
+
+ var NewTokyo = new Faction("New Tokyo");
+ NewTokyo.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].NewTokyoInfo);
+ resetFaction(NewTokyo);
+
+ var Aevum = new Faction("Aevum");
+ Aevum.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].AevumInfo);
+ resetFaction(Aevum);
+
+ var Ishima = new Faction("Ishima");
+ Ishima.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].Ishima);
+ resetFaction(Ishima);
+
+ var Volhaven = new Faction("Volhaven");
+ Volhaven.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].VolhavenInfo);
+ resetFaction(Volhaven);
+
+ //Criminal Organizations/Gangs
+ var SpeakersForTheDead = new Faction("Speakers for the Dead");
+ SpeakersForTheDead.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].SpeakersForTheDeadInfo);
+ resetFaction(SpeakersForTheDead);
+
+ var DarkArmy = new Faction("The Dark Army");
+ DarkArmy.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].DarkArmyInfo);
+ resetFaction(DarkArmy);
+
+ var TheSyndicate = new Faction("The Syndicate");
+ TheSyndicate.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].TheSyndicateInfo);
+ resetFaction(TheSyndicate);
+
+ var Silhouette = new Faction("Silhouette");
+ Silhouette.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].SilhouetteInfo);
+ resetFaction(Silhouette);
+
+ var Tetrads = new Faction("Tetrads"); //Low-medium level asian crime gang
+ Tetrads.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].TetradsInfo);
+ resetFaction(Tetrads);
+
+ var SlumSnakes = new Faction("Slum Snakes"); //Low level crime gang
+ SlumSnakes.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].SlumSnakesInfo);
+ resetFaction(SlumSnakes);
+
+ //Earlygame factions - factions the player will prestige with early on that don't
+ //belong in other categories
+ var Netburners = new Faction("Netburners");
+ Netburners.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].NetburnersInfo);
+ resetFaction(Netburners);
+
+ var TianDiHui = new Faction("Tian Di Hui"); //Society of the Heaven and Earth
+ TianDiHui.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].TianDiHuiInfo);
+ resetFaction(TianDiHui);
+
+ var CyberSec = new Faction("CyberSec");
+ CyberSec.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].CyberSecInfo);
+ resetFaction(CyberSec);
+
+ //Special Factions
+ var Bladeburners = new Faction("Bladeburners");
+ Bladeburners.setInfo(_FactionInfo_js__WEBPACK_IMPORTED_MODULE_4__["FactionInfo"].BladeburnersInfo);
+ resetFaction(Bladeburners);
+}
+
+//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)) {
+ throw new Error("Invalid argument 'newFactionObject' passed into resetFaction()");
+ }
+ var factionName = newFactionObject.name;
+ if (factionExists(factionName)) {
+ newFactionObject.favor = Factions[factionName].favor;
+ delete Factions[factionName];
+ }
+ AddToFactions(newFactionObject);
+}
+
+function inviteToFaction(faction) {
+ if (_Settings_js__WEBPACK_IMPORTED_MODULE_8__["Settings"].SuppressFactionInvites) {
+ faction.alreadyInvited = true;
+ _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].factionInvitations.push(faction.name);
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].currentPage === _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Page.Factions) {
+ _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].loadFactionsContent();
+ }
+ } else {
+ Object(_utils_FactionInvitationBox_js__WEBPACK_IMPORTED_MODULE_10__["factionInvitationBoxCreate"])(faction);
+ }
+}
+
+function joinFaction(faction) {
+ faction.isMember = true;
+ _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].factions.push(faction.name);
+
+ //Determine what factions you are banned from now that you have joined this faction
+ if (faction.name == "Chongqing") {
+ Factions["Sector-12"].isBanned = true;
+ Factions["Aevum"].isBanned = true;
+ Factions["Volhaven"].isBanned = true;
+ } else if (faction.name == "Sector-12") {
+ Factions["Chongqing"].isBanned = true;
+ Factions["New Tokyo"].isBanned = true;
+ Factions["Ishima"].isBanned = true;
+ Factions["Volhaven"].isBanned = true;
+ } else if (faction.name == "New Tokyo") {
+ Factions["Sector-12"].isBanned = true;
+ Factions["Aevum"].isBanned = true;
+ Factions["Volhaven"].isBanned = true;
+ } else if (faction.name == "Aevum") {
+ Factions["Chongqing"].isBanned = true;
+ Factions["New Tokyo"].isBanned = true;
+ Factions["Ishima"].isBanned = true;
+ Factions["Volhaven"].isBanned = true;
+ } else if (faction.name == "Ishima") {
+ Factions["Sector-12"].isBanned = true;
+ Factions["Aevum"].isBanned = true;
+ Factions["Volhaven"].isBanned = true;
+ } else if (faction.name == "Volhaven") {
+ Factions["Chongqing"].isBanned = true;
+ Factions["Sector-12"].isBanned = true;
+ Factions["New Tokyo"].isBanned = true;
+ Factions["Aevum"].isBanned = true;
+ Factions["Ishima"].isBanned = true;
+ }
+}
+
+//Displays the HTML content for a specific faction
+function displayFactionContent(factionName) {
+ var faction = Factions[factionName];
+ if (faction == null) {
+ throw new Error("Invalid factionName passed into displayFactionContent: " + factionName);
+ }
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["removeChildrenFromElement"])(_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Display.factionContent);
+ var elements = [];
+
+ //Header and faction info
+ elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("h1", {
+ innerText:factionName
+ }));
+ elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("pre", {
+ innerHTML:"" + faction.info + ""
+ }));
+ elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
+ innerText:"---------------",
+ }));
+
+ //Faction reputation and favor
+ var favorGain = faction.getFavorGain();
+ if (favorGain.length != 2) {favorGain = 0;}
+ favorGain = favorGain[0];
+ elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
+ innerText: "Reputation: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__["formatNumber"])(faction.playerReputation, 4),
+ tooltip:"You will earn " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__["formatNumber"])(favorGain, 4) +
+ " faction favor upon resetting after installing an Augmentation"
+ }))
+ elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
+ innerText:"---------------",
+ }));
+ elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
+ innerText:"Faction Favor: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__["formatNumber"])(faction.favor, 4),
+ 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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
+ innerText:"---------------",
+ }));
+
+ //Faction Work Description Text
+ elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("br"));
+
+ //Hacking Mission Option
+ var hackMissionDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {
+ id:"faction-hack-mission-div", class:"faction-work-div",
+ });
+ var hackMissionDivWrapper = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {class:"faction-work-div-wrapper"});
+ hackMissionDiv.appendChild(hackMissionDivWrapper);
+ hackMissionDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
+ class:"a-link-button", innerText:"Hacking Mission",
+ clickListener:()=>{
+ _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].loadMissionContent();
+ var mission = new _Missions_js__WEBPACK_IMPORTED_MODULE_6__["HackingMission"](faction.playerReputation, faction);
+ Object(_Missions_js__WEBPACK_IMPORTED_MODULE_6__["setInMission"])(true, mission); //Sets inMission flag to true
+ mission.init();
+ return false;
+ }
+ }));
+ hackMissionDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {
+ id:"faction-hack-div", class:"faction-work-div",
+ });
+ var hackDivWrapper = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {class:"faction-work-div-wrapper"});
+ hackDiv.appendChild(hackDivWrapper);
+ hackDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
+ class:"a-link-button", innerText:"Hacking Contracts",
+ clickListener:()=>{
+ _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].startFactionHackWork(faction);
+ return false;
+ }
+ }));
+ hackDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {
+ id:"faction-fieldwork-div", class:"faction-work-div"
+ });
+ var fieldWorkDivWrapper = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {class:"faction-work-div-wrapper"});
+ fieldWorkDiv.appendChild(fieldWorkDivWrapper);
+ fieldWorkDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
+ class:"a-link-button", innerText:"Field Work",
+ clickListener:()=>{
+ _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].startFactionFieldWork(faction);
+ return false;
+ }
+ }));
+ fieldWorkDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {
+ id:"faction-securitywork-div", class:"faction-work-div"
+ });
+ var securityWorkDivWrapper = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {class:"faction-work-div-wrapper"});
+ securityWorkDiv.appendChild(securityWorkDivWrapper);
+ securityWorkDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
+ class:"a-link-button", innerText:"Security Work",
+ clickListener:()=>{
+ _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].startFactionSecurityWork(faction);
+ return false;
+ }
+ }));
+ securityWorkDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {
+ id:"faction-donate-div", class:"faction-work-div"
+ });
+ var donateDivWrapper = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {class:"faction-work-div-wrapper"});
+ donateDiv.appendChild(donateDivWrapper);
+ var donateRepGain = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
+ innerText:"This donation will result in 0 reputation gain"
+ });
+ var donateAmountInput = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("input", {
+ placeholder:"Donation amount",
+ inputListener:()=>{
+ var amt = parseFloat(donateAmountInput.value);
+ if (isNaN(amt) || amt < 0) {
+ donateRepGain.innerText = "Invalid donate amount entered!";
+ } else {
+ var repGain = amt / 1e6 * _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].faction_rep_mult;
+ donateRepGain.innerText = "This donation will result in " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__["formatNumber"])(repGain, 3) + " reputation gain";
+ }
+ },
+ });
+ donateDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
+ class:"a-link-button", innerText:"Donate Money",
+ clickListener:()=>{
+ var amt = parseFloat(donateAmountInput.value);
+ if (isNaN(amt) || amt < 0) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Invalid amount entered!");
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].money.lt(amt)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("You cannot afford to donate this much money!");
+ } else {
+ _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].loseMoney(amt);
+ var repGain = amt / 1e6 * _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].faction_rep_mult;
+ faction.playerReputation += repGain;
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("You just donated " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_13___default()(amt).format("$0.000a") + " to " +
+ faction.name + " to gain " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__["formatNumber"])(repGain, 3) + " reputation");
+ displayFactionContent(factionName);
+ }
+ }
+ }));
+ donateDivWrapper.appendChild(donateAmountInput);
+ donateDivWrapper.appendChild(donateRepGain);
+ elements.push(donateDiv);
+
+ //Purchase Augmentations
+ elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
+ class:"a-link-button", innerText:"Purchase Augmentations",
+ clickListener:()=>{
+ _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].hideAllContent();
+ _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Display.factionAugmentationsContent.style.display = "block";
+
+
+ displayFactionAugmentations(factionName);
+ return false;
+ }
+ }));
+
+ //Gang (BitNode-2)
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {
+ id:"faction-gang-div", class:"faction-work-div", display:"inline"
+ });
+ var gangDivWrapper = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {class:"faction-work-div-wrapper"});
+ gangDiv.appendChild(gangDivWrapper);
+ gangDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
+ class:"a-link-button", innerText:"Manage Gang",
+ clickListener:()=>{
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].inGang()) {
+ var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxGetNoButton"])();
+ yesBtn.innerHTML = "Create Gang";
+ noBtn.innerHTML = "Cancel";
+ yesBtn.addEventListener("click", () => {
+ var hacking = false;
+ if (factionName === "NiteSec" || factionName === "The Black Hand") {hacking = true;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].startGang(factionName, hacking);
+ _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].loadGangContent();
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxClose"])();
+ });
+ noBtn.addEventListener("click", () => {
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxClose"])();
+ });
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["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. There are NO differences between the Factions you can " +
+ "create a Gang with and each of these Factions have all Augmentations available");
+ } else {
+ _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].loadGangContent();
+ }
+ }
+ }));
+ gangDivWrapper.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["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_js__WEBPACK_IMPORTED_MODULE_7__["Player"].inGang() && _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].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_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Display.factionContent.appendChild(elements[i]);
+ }
+ return;
+ }
+
+ if (faction.isMember) {
+ if (faction.favor >= (150 * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].RepToDonateToFaction)) {
+ donateDiv.style.display = "inline";
+ } else {
+ donateDiv.style.display = "none";
+ }
+
+ switch(faction.name) {
+ case "Illuminati":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "none";
+ break;
+ case "Daedalus":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "none";
+ break;
+ case "The Covenant":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "none";
+ break;
+ case "ECorp":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "MegaCorp":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "Bachman & Associates":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "Blade Industries":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "NWO":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "Clarke Incorporated":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "OmniTek Incorporated":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "Four Sigma":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "KuaiGong International":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "Fulcrum Secret Technologies":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "none";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "BitRunners":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "none";
+ securityWorkDiv.style.display = "none";
+ break;
+ case "The Black Hand":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "none";
+ break;
+ case "NiteSec":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "none";
+ securityWorkDiv.style.display = "none";
+ break;
+ case "Chongqing":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "Sector-12":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "New Tokyo":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "Aevum":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "Ishima":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "Volhaven":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "Speakers for the Dead":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "The Dark Army":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "none";
+ break;
+ case "The Syndicate":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "Silhouette":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "none";
+ break;
+ case "Tetrads":
+ hackMissionDiv.style.display = "none";
+ hackDiv.style.display = "none";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "Slum Snakes":
+ hackMissionDiv.style.display = "none";
+ hackDiv.style.display = "none";
+ fieldWorkDiv.style.display = "inline";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "Netburners":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "none";
+ securityWorkDiv.style.display = "none";
+ break;
+ case "Tian Di Hui":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "none";
+ securityWorkDiv.style.display = "inline";
+ break;
+ case "CyberSec":
+ hackMissionDiv.style.display = "inline";
+ hackDiv.style.display = "inline";
+ fieldWorkDiv.style.display = "none";
+ securityWorkDiv.style.display = "none";
+ break;
+ case "Bladeburners":
+ hackMissionDiv.style.display = "none";
+ hackDiv.style.display = "none";
+ fieldWorkDiv.style.display = "none";
+ securityWorkDiv.style.display = "none";
+ break;
+ default:
+ console.log("Faction does not exist");
+ break;
+ }
+ } else {
+ throw new Error("Not a member of this faction, cannot display faction information");
+ }
+
+ //Display all elements
+ for (var i = 0; i < elements.length; ++i) {
+ _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Display.factionContent.appendChild(elements[i]);
+ }
+}
+
+var confirmingPurchases = true;
+var sortOption = null;
+function displayFactionAugmentations(factionName) {
+ var faction = Factions[factionName];
+ if (faction == null) {
+ throw new Error("Could not find faction " + factionName + " in displayFactionAugmentations");
+ }
+
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["removeChildrenFromElement"])(_engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].Display.factionAugmentationsContent);
+ var elements = [];
+
+ //Back button
+ elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
+ innerText:"Back", class:"a-link-button",
+ clickListener:()=>{
+ _engine_js__WEBPACK_IMPORTED_MODULE_3__["Engine"].loadFactionContent();
+ displayFactionContent(factionName);
+ return false;
+ }
+ }));
+
+ //Header text
+ elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("h1", {innerText:"Faction Augmentations"}));
+ elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["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."
+ }));
+
+ //Confirming not confirming button
+ elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("label", {
+ for:"faction-augmentations-confirming-checkbox",innerText:"Confirm Purchases",
+ color:"white", margin:"4px", padding:"4px",
+ }));
+ var confirmingPurchasesCheckbox = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("input", {
+ type:"checkbox", id:"faction-augmentations-confirming-checkbox", checked:confirmingPurchases,
+ margin:"4px", padding:"4px",
+ clickListener:()=>{
+ confirmingPurchases = confirmingPurchasesCheckbox.checked;
+ }
+ });
+ elements.push(confirmingPurchasesCheckbox);
+ elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("br"));
+ elements.push(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("br"));
+
+ //Augmentations List
+ var augmentationsList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("ul");
+
+ //Sort buttons
+ var sortByCostBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
+ innerText:"Sort by Cost", class:"a-link-button",
+ clickListener:()=>{
+ sortOption = "cost";
+ var augs = faction.augmentations.slice();
+ augs.sort((augName1, augName2)=>{
+ var aug1 = _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augName1], aug2 = _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augName2];
+ if (aug1 == null || aug2 == null) {
+ throw new Error("Invalid Augmentation Names");
+ }
+ return aug1.baseCost - aug2.baseCost;
+ });
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["removeChildrenFromElement"])(augmentationsList);
+ createFactionAugmentationDisplayElements(augmentationsList, augs, faction);
+ }
+ });
+ var sortByRepBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
+ innerText:"Sort by Reputation", class:"a-link-button",
+ clickListener:()=>{
+ sortOption = "reputation";
+ var augs = faction.augmentations.slice();
+ augs.sort((augName1, augName2)=>{
+ var aug1 = _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augName1], aug2 = _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][augName2];
+ if (aug1 == null || aug2 == null) {
+ throw new Error("Invalid Augmentation Names");
+ }
+ return aug1.baseRepRequirement - aug2.baseRepRequirement;
+ });
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["removeChildrenFromElement"])(augmentationsList);
+ createFactionAugmentationDisplayElements(augmentationsList, augs, faction);
+ }
+ });
+ var defaultSortBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
+ innerText:"Sort by Default Order", class:"a-link-button",
+ clickListener:()=>{
+ sortOption = "default";
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["removeChildrenFromElement"])(augmentationsList);
+ createFactionAugmentationDisplayElements(augmentationsList, faction.augmentations, faction);
+ }
+ });
+ elements.push(sortByCostBtn);
+ elements.push(sortByRepBtn);
+ elements.push(defaultSortBtn);
+ switch(sortOption) {
+ case "cost":
+ sortByCostBtn.click();
+ break;
+ case "reputation":
+ sortByRepBtn.click();
+ break;
+ default:
+ defaultSortBtn.click();
+ break;
+ }
+
+ elements.push(augmentationsList);
+
+ for (var i = 0; i < elements.length; ++i) {
+ _engine_js__WEBPACK_IMPORTED_MODULE_3__["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) {
+ for (var i = 0; i < augs.length; ++i) {
+ (function () {
+ var aug = _Augmentations_js__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_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations.length; ++j) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations[j].name == aug.name) {
+ owned = true;
+ break;
+ }
+ }
+ for (var j = 0; j < _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].augmentations.length; ++j) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].augmentations[j].name == aug.name) {
+ owned = true;
+ break;
+ }
+ }
+
+ var item = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("li");
+ var span = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("span", {display:"inline-block"});
+ var aDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("div", {tooltip:aug.info});
+ var aElem = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("a", {
+ innerText:aug.name, display:"inline",
+ clickListener:()=>{
+ if (confirmingPurchases) {
+ purchaseAugmentationBoxCreate(aug, faction);
+ } else {
+ purchaseAugmentation(aug, faction);
+ }
+ return false;
+ }
+ });
+ if (aug.name == _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].NeuroFluxGovernor) {
+ aElem.innerText += " - Level " + (getNextNeurofluxLevel());
+ }
+ var pElem = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_11__["createElement"])("p", {
+ display:"inline",
+ })
+ var req = aug.baseRepRequirement * faction.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 != _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["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 - " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_13___default()(aug.baseCost * faction.augmentationPriceMult).format("$0.000a");
+ } else {
+ aElem.setAttribute("class", "a-link-button-inactive");
+ pElem.innerHTML = "LOCKED (Requires " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__["formatNumber"])(req, 1) + " faction reputation) - " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_13___default()(aug.baseCost * faction.augmentationPriceMult).format("$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) {
+ var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxGetNoButton"])();
+ yesBtn.innerHTML = "Purchase";
+ noBtn.innerHTML = "Cancel";
+ yesBtn.addEventListener("click", function() {
+ purchaseAugmentation(aug, fac);
+ });
+ noBtn.addEventListener("click", function() {
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxClose"])();
+ });
+
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxCreate"])("
" + aug.name + "
" +
+ aug.info + "
" +
+ " Would you like to purchase the " + aug.name + " Augmentation for $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_14__["formatNumber"])(aug.baseCost * fac.augmentationPriceMult, 2) + "?");
+}
+
+//Returns a boolean indicating whether the player has the prerequisites for the
+//specified Augmentation
+function hasAugmentationPrereqs(aug) {
+ var hasPrereqs = true;
+ if (aug.prereqs && aug.prereqs.length > 0) {
+ for (var i = 0; i < aug.prereqs.length; ++i) {
+ var prereqAug = _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][aug.prereqs[i]];
+ if (prereqAug == null) {
+ console.log("ERROR: Invalid prereq Augmentation: " + aug.prereqs[i]);
+ continue;
+ }
+ if (prereqAug.owned === false) {
+ hasPrereqs = false;
+
+ //Check if the aug is purchased
+ for (var j = 0; j < _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations.length; ++j) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations[j].name === prereqAug.name) {
+ hasPrereqs = true;
+ break;
+ }
+ }
+ }
+ }
+ }
+ return hasPrereqs;
+}
+
+function purchaseAugmentation(aug, fac, sing=false) {
+ var hasPrereqs = hasAugmentationPrereqs(aug);
+ if (!hasPrereqs) {
+ var txt = "You must first purchase or install " + aug.prereqs.join(",") + " before you can " +
+ "purchase this one.";
+ if (sing) {return txt;} else {Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])(txt);}
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].money.gte(aug.baseCost * fac.augmentationPriceMult)) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].firstAugPurchased === false) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].firstAugPurchased = true;
+ document.getElementById("augmentations-tab").style.display = "list-item";
+ document.getElementById("character-menu-header").click();
+ document.getElementById("character-menu-header").click();
+ }
+
+ var queuedAugmentation = new _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["PlayerOwnedAugmentation"](aug.name);
+ if (aug.name == _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].NeuroFluxGovernor) {
+ queuedAugmentation.level = getNextNeurofluxLevel();
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations.push(queuedAugmentation);
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].loseMoney((aug.baseCost * fac.augmentationPriceMult));
+
+ //If you just purchased Neuroflux Governor, recalculate the cost
+ if (aug.name == _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].NeuroFluxGovernor) {
+ var nextLevel = getNextNeurofluxLevel();
+ --nextLevel;
+ var mult = Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].NeuroFluxGovernorLevelMult, nextLevel);
+ aug.baseRepRequirement = 500 * mult * _Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].AugmentationRepMultiplier * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].AugmentationRepCost;
+ aug.baseCost = 750e3 * mult * _Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].AugmentationCostMultiplier * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].AugmentationMoneyCost;
+
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations.length-1; ++i) {
+ aug.baseCost *= _Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].MultipleAugMultiplier;
+ }
+ }
+
+ for (var name in _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"]) {
+ if (_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"].hasOwnProperty(name)) {
+ _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][name].baseCost *= _Constants_js__WEBPACK_IMPORTED_MODULE_2__["CONSTANTS"].MultipleAugMultiplier;
+ }
+ }
+
+ if (sing) {
+ return "You purchased " + aug.name;
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("You purchased " + aug.name + ". It's enhancements will not take " +
+ "effect until they are installed. To install your augmentations, go to the " +
+ "'Augmentations' tab on the left-hand navigation menu. Purchasing additional " +
+ "augmentations will now be more expensive.");
+ }
+
+ displayFactionAugmentations(fac.name);
+ } else {
+ if (sing) {
+ return "You don't have enough money to purchase " + aug.name;
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("You don't have enough money to purchase this Augmentation!");
+ }
+ }
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_15__["yesNoBoxClose"])();
+}
+
+function getNextNeurofluxLevel() {
+ var aug = _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].NeuroFluxGovernor];
+ if (aug == null) {
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].augmentations.length; ++i) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].augmentations[i].name == _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].NeuroFluxGovernor) {
+ aug = _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].augmentations[i];
+ }
+ }
+ if (aug == null) {
+ console.log("ERROR, Could not find NeuroFlux Governor aug");
+ return 1;
+ }
+ }
+ var nextLevel = aug.level + 1;
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations.length; ++i) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].queuedAugmentations[i].name == _Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].NeuroFluxGovernor) {
+ ++nextLevel;
+ }
+ }
+ return nextLevel;
+}
+
+function processPassiveFactionRepGain(numCycles) {
+ var numTimesGain = (numCycles / 600) * _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].faction_rep_mult;
+ for (var name in Factions) {
+ if (Factions.hasOwnProperty(name)) {
+ var faction = Factions[name];
+
+ //TODO Get hard value of 1 rep per "rep gain cycle"" for now..
+ //maybe later make this based on
+ //a player's 'status' like how powerful they are and how much money they have
+ if (faction.isMember) {faction.playerReputation += (numTimesGain * _BitNode_js__WEBPACK_IMPORTED_MODULE_1__["BitNodeMultipliers"].FactionPassiveRepGain);}
+ }
+ }
+}
+
+
+
+
+/***/ }),
+/* 15 */
+/*!****************************!*\
+ !*** ./utils/IPAddress.js ***!
+ \****************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createRandomIp", function() { return createRandomIp; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "ipExists", function() { return ipExists; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "isValidIPAddress", function() { return isValidIPAddress; });
+/* harmony import */ var _src_Server_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../src/Server.js */ 10);
+
+/* Functions to deal with manipulating IP addresses*/
+
+//Generate a random IP address
+//Will not return an IP address that already exists in the AllServers array
+function createRandomIp() {
+ var ip = createRandomByte(99) +'.' +
+ createRandomByte(9) +'.' +
+ createRandomByte(9) +'.' +
+ createRandomByte(9);
+
+ //If the Ip already exists, recurse to create a new one
+ if (ipExists(ip)) {
+ return createRandomIp();
+ }
+ return ip;
+}
+
+//Returns true if the IP already exists in one of the game's servers
+function ipExists(ip) {
+ for (var property in _src_Server_js__WEBPACK_IMPORTED_MODULE_0__["AllServers"]) {
+ if (_src_Server_js__WEBPACK_IMPORTED_MODULE_0__["AllServers"].hasOwnProperty(property)) {
+ if (property == ip) {
+ return true;
+ }
+ }
+ }
+ return false;
+}
+
+function createRandomByte(n=9) {
+ return Math.round(Math.random()*n);
+}
+
+function isValidIPAddress(ipaddress) {
+ if (/^(25[0-6]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-6]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-6]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.(25[0-6]|2[0-4][0-9]|[01]?[0-9][0-9]?)$/.test(ipaddress))
+ {
+ return true;
+ }
+ return false;
+}
+
+
+
+
+/***/ }),
+/* 16 */
+/*!************************!*\
+ !*** ./src/BitNode.js ***!
+ \************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initBitNodes", function() { return initBitNodes; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BitNode", function() { return BitNode; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BitNodes", function() { return BitNodes; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "BitNodeMultipliers", function() { return BitNodeMultipliers; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initBitNodeMultipliers", function() { return initBitNodeMultipliers; });
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Player.js */ 0);
+
+
+function BitNode(n, name, desc="", info="") {
+ this.number = n;
+ this.name = name;
+ this.desc = desc;
+ this.info = info;
+}
+
+let BitNodes = {};
+function initBitNodes() {
+ BitNodes = {};
+ BitNodes["BitNode1"] = new BitNode(1, "Source Genesis", "The original BitNode",
+ "The first BitNode created by the Enders to imprison the minds of humans. It became " +
+ "the prototype and testing-grounds for all of the BitNodes that followed.
" +
+ "This is the first BitNode that you play through. It has no special " +
+ "modifications or mechanics.
" +
+ "Destroying this BitNode will give you Source-File 1, or if you already have " +
+ "this Source-File it will upgrade its level up to a maximum of 3. This Source-File " +
+ "lets the player start with 32GB of RAM on his/her home computer when entering a " +
+ "new BitNode, and also increases all of the player's multipliers by:
" +
+ "Level 1: 16% " +
+ "Level 2: 24% " +
+ "Level 3: 28%");
+ BitNodes["BitNode2"] = new BitNode(2, "Rise of the Underworld", "From the shadows, they rose", //Gangs
+ "From the shadows, they rose.
Organized crime groups quickly filled the void of power " +
+ "left behind from the collapse of Western government in the 2050's. As society and civlization broke down, " +
+ "people quickly succumbed to the innate human impulse of evil and savagery. The organized crime " +
+ "factions quickly rose to the top of the modern world.
" +
+ "In this BitNode:
The maximum amount of money available on a server is significantly decreased " +
+ "The amount of money gained from crimes and Infiltration is tripled " +
+ "Certain Factions (Slum Snakes, Tetrads, The Syndicate, The Dark Army, Speakers for the Dead, " +
+ "NiteSec, The Black Hand) give the player the ability to form and manage their own gangs. These gangs " +
+ "will earn the player money and reputation with the corresponding Faction " +
+ "Every Augmentation in the game will be available through the Factions listed above " +
+ "For every Faction NOT listed above, reputation gains are halved " +
+ "You will no longer gain passive reputation with Factions
" +
+ "Destroying this BitNode will give you Source-File 2, or if you already have this Source-File it will " +
+ "upgrade its level up to a maximum of 3. This Source-File increases the player's crime success rate, " +
+ "crime money, and charisma multipliers by:
" +
+ "Level 1: 20% " +
+ "Level 2: 30% " +
+ "Level 3: 35%");
+ BitNodes["BitNode3"] = new BitNode(3, "Corporatocracy", "The Price of Civilization",
+ "Our greatest illusion is that a healthy society can revolve around a " +
+ "single-minded pursuit of wealth.
" +
+ "Sometime in the early 21st century economic and political globalization turned " +
+ "the world into a corporatocracy, and it never looked back. Now, the privileged " +
+ "elite will happily bankrupt their own countrymen, decimate their own community, " +
+ "and evict their neighbors from houses in their desperate bid to increase their wealth.
" +
+ "In this BitNode you can create and manage your own corporation. Running a successful corporation " +
+ "has the potential of generating massive profits. All other forms of income are reduced by 75%. Furthermore:
" +
+ "The price and reputation cost of all Augmentations is tripled " +
+ "The starting and maximum amount of money on servers is reduced by 75% " +
+ "Server growth rate is reduced by 80% " +
+ "You will start out with $150b so that you can start your corporation " +
+ "You now only need 75 reputation with a faction in order to donate to it, rather than 150
" +
+ "Destroying this BitNode will give you Source-File 3, or if you already have this Source-File it will " +
+ "upgrade its level up to a maximum of 3. This Source-File lets you create corporations on other BitNodes (although " +
+ "some BitNodes will disable this mechanic). This Source-File also increases your charisma and company salary multipliers by: " +
+ "Level 1: 8% " +
+ "Level 2: 12% " +
+ "Level 3: 14%");
+ BitNodes["BitNode4"] = new BitNode(4, "The Singularity", "The Man and the Machine", "The Singularity has arrived. The human race is gone, replaced " +
+ "by artificially superintelligent beings that are more machine than man.
" +
+ "In this BitNode, progressing is significantly harder. Experience gain rates " +
+ "for all stats are reduced. Most methods of earning money will now give significantly less.
" +
+ "In this BitNode you will gain access to a new set of Netscript Functions known as Singularity Functions. " +
+ "These functions allow you to control most aspects of the game through scripts, including working for factions/companies, " +
+ "purchasing/installing Augmentations, and creating programs.
" +
+ "Destroying this BitNode will give you Source-File 4, or if you already have this Source-File it will " +
+ "upgrade its level up to a maximum of 3. This Source-File lets you access and use the Singularity " +
+ "Functions in other BitNodes. Each level of this Source-File will open up more Singularity Functions " +
+ "that you can use.");
+ BitNodes["BitNode5"] = new BitNode(5, "Artificial Intelligence", "Posthuman", "They said it couldn't be done. They said the human brain, " +
+ "along with its consciousness and intelligence, couldn't be replicated. They said the complexity " +
+ "of the brain results from unpredictable, nonlinear interactions that couldn't be modeled " +
+ "by 1's and 0's. They were wrong.
" +
+ "In this BitNode:
" +
+ "The base security level of servers is doubled " +
+ "The starting money on servers is halved, but the maximum money remains the same " +
+ "Most methods of earning money now give significantly less " +
+ "Infiltration gives 50% more reputation and money " +
+ "Corporations have 50% lower valuations and are therefore less profitable " +
+ "Augmentations are more expensive " +
+ "Hacking experience gain rates are reduced
" +
+ "Destroying this BitNode will give you Source-File 5, or if you already have this Source-File it will " +
+ "upgrade its level up to a maximum of 3. This Source-File grants you a special new stat called Intelligence. " +
+ "Intelligence is unique because it is permanent and persistent (it never gets reset back to 1). However " +
+ "gaining Intelligence experience is much slower than other stats, and it is also hidden (you won't know " +
+ "when you gain experience and how much). Higher Intelligence levels will boost your production for many actions " +
+ "in the game.
" +
+ "In addition, this Source-File will unlock the getBitNodeMultipliers() Netscript function, " +
+ "and will also raise all of your hacking-related multipliers by:
" +
+ "Level 1: 4% " +
+ "Level 2: 6% " +
+ "Level 3: 7%");
+ BitNodes["BitNode6"] = new BitNode(6, "Bladeburners", "Like Tears in Rain",
+ "In the middle of the 21st century, OmniTek Incorporated began designing and manufacturing advanced synthetic " +
+ "androids, or Synthoids for short. They achieved a major technological breakthrough in the sixth generation " +
+ "of their Synthoid design, called MK-VI, by developing a hyperintelligent AI. Many argue that this was " +
+ "the first sentient AI ever created. This resulted in Synthoid models that were stronger, faster, and more intelligent " +
+ "than the humans that had created them.
" +
+ "In this BitNode you will be able to access the Bladeburner Division at the NSA, which provides a new mechanic " +
+ "for progression. Furthermore:
" +
+ "Hacking and Hacknet Nodes will be significantly less profitable " +
+ "Your hacking level is reduced by 50% " +
+ "Hacking experience gain from scripts is reduced by 80% " +
+ "Corporations have 80% lower valuations and are therefore less profitable " +
+ "Working for companies is 50% less profitable " +
+ "Crimes and Infiltration are 75% less profitable
" +
+ "Destroying this BitNode will give you Source-File 6, or if you already have this Source-File it will upgrade " +
+ "its level up to a maximum of 3. This Source-File allows you to access the NSA's Bladeburner Division in other " +
+ "BitNodes. In addition, this Source-File will raise the experience gain rate of all your combat stats by:
" +
+ "Level 1: 8% " +
+ "Level 2: 12% " +
+ "Level 3: 14%");
+ BitNodes["BitNode7"] = new BitNode(7, "Hacktocracy", "COMING SOON"); //Healthy Hacknet balancing mechanic
+ BitNodes["BitNode8"] = new BitNode(8, "Ghost of Wall Street", "Money never sleeps",
+ "You are trying to make a name for yourself as an up-and-coming hedge fund manager on Wall Street.
" +
+ "In this BitNode:
" +
+ "You start with $100 million " +
+ "The only way to earn money is by trading on the stock market " +
+ "You start with a WSE membership and access to the TIX API " +
+ "You are able to short stocks and place different types of orders (limit/stop) " +
+ "You can immediately donate to factions to gain reputation
" +
+ "Destroying this BitNode will give you Source-File 8, or if you already have this Source-File it will " +
+ "upgrade its level up to a maximum of 3. This Source-File grants the following benefits:
" +
+ "Level 1: Permanent access to WSE and TIX API " +
+ "Level 2: Ability to short stocks in other BitNodes " +
+ "Level 3: Ability to use limit/stop orders in other BitNodes
" +
+ "This Source-File also increases your hacking growth multipliers by: " +
+ " Level 1: 8% Level 2: 12% Level 3: 14%");
+ BitNodes["BitNode9"] = new BitNode(9, "Do Androids Dream?", "COMING SOON");
+ BitNodes["BitNode10"] = new BitNode(10, "MegaCorp", "COMING SOON"); //Not sure yet
+ BitNodes["BitNode11"] = new BitNode(11, "The Big Crash", "Okay. Sell it all.",
+ "The 2050s was defined by the massive amounts of violent civil unrest and anarchic rebellion that rose all around the world. It was this period " +
+ "of disorder that eventually lead to the governmental reformation of many global superpowers, most notably " +
+ "the USA and China. But just as the world was slowly beginning to recover from these dark times, financial catastrophe hit.
" +
+ "In many countries, the high cost of trying to deal with the civil disorder bankrupted the governments. In all of this chaos and confusion, hackers " +
+ "were able to steal billions of dollars from the world's largest electronic banks, prompting an international banking crisis as " +
+ "governments were unable to bail out insolvent banks. Now, the world is slowly crumbling in the middle of the biggest economic crisis of all time.
" +
+ "In this BitNode:
" +
+ "The starting and maximum amount of money available on servers is significantly decreased " +
+ "The growth rate of servers is halved " +
+ "Weakening a server is twice as effective " +
+ "Company wages are decreased by 50% " +
+ "Corporation valuations are 99% lower and are therefore significantly less profitable " +
+ "Hacknet Node production is significantly decreased " +
+ "Crime and Infiltration are more lucrative " +
+ "Augmentations are twice as expensive
" +
+ "Destroying this BitNode will give you Source-File 11, or if you already have this Source-File it will " +
+ "upgrade its level up to a maximum of 3. This Source-File makes it so that company favor increases BOTH " +
+ "the player's salary and reputation gain rate at that company by 1% per favor (rather than just the reputation gain). " +
+ "This Source-File also increases the player's company salary and reputation gain multipliers by:
This augmentation increases all of the player's combat stats by 8%."
+ });
+ HemoRecirculator.addToFactions(["Tetrads", "The Dark Army", "The Syndicate"]);
+ if (augmentationExists(AugmentationNames.HemoRecirculator)) {
+ delete Augmentations[AugmentationNames.HemoRecirculator];
+ }
+ AddToAugmentations(HemoRecirculator);
+
+ var Targeting1 = new Augmentation({
+ name:AugmentationNames.Targeting1, moneyCost:3e6, repCost:2e3,
+ info:"This cranial implant is embedded within the player's inner ear structure and optic nerves. It regulates and enhances the user's " +
+ "balance and hand-eye coordination. It is also capable of augmenting reality by projecting digital information " +
+ "directly onto the retina. These enhancements allow the player to better lock-on and keep track of enemies.
" +
+ "This augmentation increases the player's dexterity by 10%."
+ });
+ Targeting1.addToFactions(["Slum Snakes", "The Dark Army", "The Syndicate", "Sector-12", "Volhaven", "Ishima",
+ "OmniTek Incorporated", "KuaiGong International", "Blade Industries"]);
+ if (augmentationExists(AugmentationNames.Targeting1)) {
+ delete Augmentations[AugmentationNames.Targeting1];
+ }
+ AddToAugmentations(Targeting1);
+
+ var Targeting2 = new Augmentation({
+ name:AugmentationNames.Targeting2, moneyCost:8.5e6, repCost:3.5e3,
+ info:"This is an upgrade of the Augmented Targeting I cranial implant, which is capable of augmenting reality " +
+ "and enhances the user's balance and hand-eye coordination.
This upgrade increases the player's dexterity " +
+ "by an additional 20%.",
+ prereqs:[AugmentationNames.Targeting1]
+ });
+ Targeting2.addToFactions(["The Dark Army", "The Syndicate", "Sector-12", "Volhaven", "Ishima",
+ "OmniTek Incorporated", "KuaiGong International", "Blade Industries"]);
+ if (augmentationExists(AugmentationNames.Targeting2)) {
+ delete Augmentations[AugmentationNames.Targeting2];
+ }
+ AddToAugmentations(Targeting2);
+
+ var Targeting3 = new Augmentation({
+ name:AugmentationNames.Targeting3, moneyCost:23e6, repCost:11e3,
+ info:"This is an upgrade of the Augmented Targeting II cranial implant, which is capable of augmenting reality " +
+ "and enhances the user's balance and hand-eye coordination.
This upgrade increases the player's dexterity " +
+ "by an additional 30%.",
+ prereqs:[AugmentationNames.Targeting2]
+ });
+ Targeting3.addToFactions(["The Dark Army", "The Syndicate", "OmniTek Incorporated",
+ "KuaiGong International", "Blade Industries", "The Covenant"]);
+ if (augmentationExists(AugmentationNames.Targeting3)) {
+ delete Augmentations[AugmentationNames.Targeting3];
+ }
+ AddToAugmentations(Targeting3);
+
+ var SyntheticHeart = new Augmentation({
+ name:AugmentationNames.SyntheticHeart, moneyCost:575e6, repCost:300e3,
+ info:"This advanced artificial heart, created from plasteel and graphene, is capable of pumping more blood " +
+ "at much higher efficiencies than a normal human heart.
This augmentation increases the player's agility " +
+ "and strength by 50%"
+ });
+ SyntheticHeart.addToFactions(["KuaiGong International", "Fulcrum Secret Technologies", "Speakers for the Dead",
+ "NWO", "The Covenant", "Daedalus", "Illuminati"]);
+ if (augmentationExists(AugmentationNames.SyntheticHeart)) {
+ delete Augmentations[AugmentationNames.SyntheticHeart];
+ }
+ AddToAugmentations(SyntheticHeart);
+
+ var SynfibrilMuscle = new Augmentation({
+ name:AugmentationNames.SynfibrilMuscle, repCost:175e3, moneyCost:225e6,
+ info:"The myofibrils in human muscles are injected with special chemicals that react with the proteins inside " +
+ "the myofibrils, altering their underlying structure. The end result is muscles that are stronger and more elastic. " +
+ "Scientists have named these artificially enhanced units 'synfibrils'.
This augmentation increases the player's " +
+ "strength and defense by 30%."
+ });
+ SynfibrilMuscle.addToFactions(["KuaiGong International", "Fulcrum Secret Technologies", "Speakers for the Dead",
+ "NWO", "The Covenant", "Daedalus", "Illuminati", "Blade Industries"]);
+ if (augmentationExists(AugmentationNames.SynfibrilMuscle)) {
+ delete Augmentations[AugmentationNames.SynfibrilMuscle];
+ }
+ AddToAugmentations(SynfibrilMuscle)
+
+ var CombatRib1 = new Augmentation({
+ name:AugmentationNames.CombatRib1, repCost:3e3, moneyCost:4750000,
+ info:"The human body's ribs are replaced with artificial ribs that automatically and continuously release cognitive " +
+ "and performance-enhancing drugs into the bloodstream, improving the user's abilities in combat.
" +
+ "This augmentation increases the player's strength and defense by 10%."
+ });
+ CombatRib1.addToFactions(["Slum Snakes", "The Dark Army", "The Syndicate", "Sector-12", "Volhaven", "Ishima",
+ "OmniTek Incorporated", "KuaiGong International", "Blade Industries"]);
+ if (augmentationExists(AugmentationNames.CombatRib1)) {
+ delete Augmentations[AugmentationNames.CombatRib1];
+ }
+ AddToAugmentations(CombatRib1);
+
+ var CombatRib2 = new Augmentation({
+ name:AugmentationNames.CombatRib2, repCost:7.5e3, moneyCost:13e6,
+ info:"This is an upgrade to the Combat Rib I augmentation, and is capable of releasing even more potent combat-enhancing " +
+ "drugs into the bloodstream.
This upgrade increases the player's strength and defense by an additional 14%.",
+ prereqs:[AugmentationNames.CombatRib1]
+ });
+ CombatRib2.addToFactions(["The Dark Army", "The Syndicate", "Sector-12", "Volhaven", "Ishima",
+ "OmniTek Incorporated", "KuaiGong International", "Blade Industries"]);
+ if (augmentationExists(AugmentationNames.CombatRib2)) {
+ delete Augmentations[AugmentationNames.CombatRib2];
+ }
+ AddToAugmentations(CombatRib2);
+
+ var CombatRib3 = new Augmentation({
+ name:AugmentationNames.CombatRib3, repCost:14e3, moneyCost:24e6,
+ info:"This is an upgrade to the Combat Rib II augmentation, and is capable of releasing even more potent combat-enhancing " +
+ "drugs into the bloodstream
. This upgrade increases the player's strength and defense by an additional 18%.",
+ prereqs:[AugmentationNames.CombatRib2],
+ });
+ CombatRib3.addToFactions(["The Dark Army", "The Syndicate", "OmniTek Incorporated",
+ "KuaiGong International", "Blade Industries", "The Covenant"]);
+ if (augmentationExists(AugmentationNames.CombatRib3)) {
+ delete Augmentations[AugmentationNames.CombatRib3];
+ }
+ AddToAugmentations(CombatRib3);
+
+ var NanofiberWeave = new Augmentation({
+ name:AugmentationNames.NanofiberWeave, repCost:15e3, moneyCost:25e6,
+ info:"Synthetic nanofibers are woven into the skin's extracellular matrix using electrospinning. " +
+ "This improves the skin's ability to regenerate itself and protect the body from external stresses and forces.
" +
+ "This augmentation increases the player's strength and defense by 20%."
+ });
+ NanofiberWeave.addToFactions(["Tian Di Hui", "The Syndicate", "The Dark Army", "Speakers for the Dead",
+ "Blade Industries", "Fulcrum Secret Technologies", "OmniTek Incorporated"]);
+ if (augmentationExists(AugmentationNames.NanofiberWeave)) {
+ delete Augmentations[AugmentationNames.NanofiberWeave];
+ }
+ AddToAugmentations(NanofiberWeave);
+
+ var SubdermalArmor = new Augmentation({
+ name:AugmentationNames.SubdermalArmor, repCost:350e3, moneyCost:650e6,
+ info:"The NEMEAN Subdermal Weave is a thin, light-weight, graphene plating that houses a dilatant fluid. " +
+ "The material is implanted underneath the skin, and is the most advanced form of defensive enhancement " +
+ "that has ever been created. The dilatant fluid, despite being thin and light, is extremely effective " +
+ "at stopping piercing blows and reducing blunt trauma. The properties of graphene allow the plating to " +
+ "mitigate damage from any fire-related or electrical traumas.
" +
+ "This augmentation increases the player's defense by 120%."
+ });
+ SubdermalArmor.addToFactions(["The Syndicate", "Fulcrum Secret Technologies", "Illuminati", "Daedalus",
+ "The Covenant"]);
+ if (augmentationExists(AugmentationNames.SubdermalArmor)) {
+ delete Augmentations[AugmentationNames.SubdermalArmor];
+ }
+ AddToAugmentations(SubdermalArmor);
+
+ var WiredReflexes = new Augmentation({
+ name:AugmentationNames.WiredReflexes, repCost:500, moneyCost:500e3,
+ info:"Synthetic nerve-enhancements are injected into all major parts of the somatic nervous system, " +
+ "supercharging the body's ability to send signals through neurons. This results in increased reflex speed.
" +
+ "This augmentation increases the player's agility and dexterity by 5%."
+ });
+ WiredReflexes.addToFactions(["Tian Di Hui", "Slum Snakes", "Sector-12", "Volhaven", "Aevum", "Ishima",
+ "The Syndicate", "The Dark Army", "Speakers for the Dead"]);
+ if (augmentationExists(AugmentationNames.WiredReflexes)) {
+ delete Augmentations[AugmentationNames.WiredReflexes];
+ }
+ AddToAugmentations(WiredReflexes);
+
+ var GrapheneBoneLacings = new Augmentation({
+ name:AugmentationNames.GrapheneBoneLacings, repCost:450e3, moneyCost:850e6,
+ info:"A graphene-based material is grafted and fused into the user's bones, significantly increasing " +
+ "their density and tensile strength.
" +
+ "This augmentation increases the player's strength and defense by 70%."
+ });
+ GrapheneBoneLacings.addToFactions(["Fulcrum Secret Technologies", "The Covenant"]);
+ if (augmentationExists(AugmentationNames.GrapheneBoneLacings)) {
+ delete Augmentations[AugmentationNames.GrapheneBoneLacings];
+ }
+ AddToAugmentations(GrapheneBoneLacings);
+
+ var BionicSpine = new Augmentation({
+ name:AugmentationNames.BionicSpine, repCost:18e3, moneyCost:25e6,
+ info:"An artificial spine created from plasteel and carbon fibers that completely replaces the organic spine. " +
+ "Not only is the Bionic Spine physically stronger than a human spine, but it is also capable of digitally " +
+ "stimulating and regulating the neural signals that are sent and received by the spinal cord. This results in " +
+ "greatly improved senses and reaction speeds.
" +
+ "This augmentation increases all of the player's combat stats by 15%."
+ });
+ BionicSpine.addToFactions(["Speakers for the Dead", "The Syndicate", "KuaiGong International",
+ "OmniTek Incorporated", "Blade Industries"]);
+ if (augmentationExists(AugmentationNames.BionicSpine)) {
+ delete Augmentations[AugmentationNames.BionicSpine];
+ }
+ AddToAugmentations(BionicSpine);
+
+ var GrapheneBionicSpine = new Augmentation({
+ name:AugmentationNames.GrapheneBionicSpine, repCost:650e3, moneyCost:1200e6,
+ info:"An upgrade to the Bionic Spine augmentation. It fuses the implant with an advanced graphene " +
+ "material to make it much stronger and lighter.
" +
+ "This augmentation increases all of the player's combat stats by 60%.",
+ prereqs:[AugmentationNames.BionicSpine],
+ });
+ GrapheneBionicSpine.addToFactions(["Fulcrum Secret Technologies", "ECorp"]);
+ if (augmentationExists(AugmentationNames.GrapheneBionicSpine)) {
+ delete Augmentations[AugmentationNames.GrapheneBionicSpine];
+ }
+ AddToAugmentations(GrapheneBionicSpine);
+
+ var BionicLegs = new Augmentation({
+ name:AugmentationNames.BionicLegs, repCost:60e3, moneyCost:75e6,
+ info:"Cybernetic legs created from plasteel and carbon fibers that completely replace the user's organic legs.
" +
+ "This augmentation increases the player's agility by 60%."
+ });
+ BionicLegs.addToFactions(["Speakers for the Dead", "The Syndicate", "KuaiGong International",
+ "OmniTek Incorporated", "Blade Industries"]);
+ if (augmentationExists(AugmentationNames.BionicLegs)) {
+ delete Augmentations[AugmentationNames.BionicLegs];
+ }
+ AddToAugmentations(BionicLegs);
+
+ var GrapheneBionicLegs = new Augmentation({
+ name:AugmentationNames.GrapheneBionicLegs, repCost:300e3, moneyCost:900e6,
+ info:"An upgrade to the Bionic Legs augmentation. It fuses the implant with an advanced graphene " +
+ "material to make it much stronger and lighter.
" +
+ "This augmentation increases the player's agility by an additional 150%.",
+ prereqs:[AugmentationNames.BionicLegs],
+ });
+ GrapheneBionicLegs.addToFactions(["MegaCorp", "ECorp", "Fulcrum Secret Technologies"]);
+ if (augmentationExists(AugmentationNames.GrapheneBionicLegs)) {
+ delete Augmentations[AugmentationNames.GrapheneBionicLegs];
+ }
+ AddToAugmentations(GrapheneBionicLegs);
+
+ //Labor stat augmentations
+ var SpeechProcessor = new Augmentation({
+ name:AugmentationNames.SpeechProcessor, repCost:3e3, moneyCost:10e6,
+ info:"A cochlear implant with an embedded computer that analyzes incoming speech. " +
+ "The embedded computer processes characteristics of incoming speech, such as tone " +
+ "and inflection, to pick up on subtle cues and aid in social interactions.
" +
+ "This augmentation increases the player's charisma by 20%."
+ });
+ SpeechProcessor.addToFactions(["Tian Di Hui", "Chongqing", "Sector-12", "New Tokyo", "Aevum",
+ "Ishima", "Volhaven", "Silhouette"]);
+ if (augmentationExists(AugmentationNames.SpeechProcessor)) {
+ delete Augmentations[AugmentationNames.SpeechProcessor];
+ }
+ AddToAugmentations(SpeechProcessor);
+
+ let TITN41Injection = new Augmentation({
+ name:AugmentationNames.TITN41Injection, repCost:10e3, moneyCost:38e6,
+ info:"TITN is a series of viruses that targets and alters the sequences of human DNA in genes that " +
+ "control personality. The TITN-41 strain alters these genes so that the subject becomes more " +
+ "outgoing and socialable.
" +
+ "This augmentation increases the player's charisma and charisma experience gain rate by 15%"
+ });
+ TITN41Injection.addToFactions(["Silhouette"]);
+ if (augmentationExists(AugmentationNames.TITN41Injection)) {
+ delete Augmentations[AugmentationNames.TITN41Injection];
+ }
+ AddToAugmentations(TITN41Injection);
+
+ var EnhancedSocialInteractionImplant = new Augmentation({
+ name:AugmentationNames.EnhancedSocialInteractionImplant, repCost:150e3, moneyCost:275e6,
+ info:"A cranial implant that greatly assists in the user's ability to analyze social situations " +
+ "and interactions. The system uses a wide variety of factors such as facial expression, body " +
+ "language, and the voice's tone/inflection to determine the best course of action during social" +
+ "situations. The implant also uses deep learning software to continuously learn new behavior" +
+ "patterns and how to best respond.
" +
+ "This augmentation increases the player's charisma and charisma experience gain rate by 60%."
+ });
+ EnhancedSocialInteractionImplant.addToFactions(["Bachman & Associates", "NWO", "Clarke Incorporated",
+ "OmniTek Incorporated", "Four Sigma"]);
+ if (augmentationExists(AugmentationNames.EnhancedSocialInteractionImplant)) {
+ delete Augmentations[AugmentationNames.EnhancedSocialInteractionImplant];
+ }
+ AddToAugmentations(EnhancedSocialInteractionImplant);
+
+ //Hacking augmentations
+ var BitWire = new Augmentation({
+ name:AugmentationNames.BitWire, repCost:1500, moneyCost:2e6,
+ info: "A small brain implant embedded in the cerebrum. This regulates and improves the brain's computing " +
+ "capabilities.
This augmentation increases the player's hacking skill by 5%"
+ });
+ BitWire.addToFactions(["CyberSec", "NiteSec"]);
+ if (augmentationExists(AugmentationNames.BitWire)) {
+ delete Augmentations[AugmentationNames.BitWire];
+ }
+ AddToAugmentations(BitWire);
+
+ var ArtificialBioNeuralNetwork = new Augmentation({
+ name:AugmentationNames.ArtificialBioNeuralNetwork, repCost:110e3, moneyCost:600e6,
+ info:"A network consisting of millions of nanoprocessors is embedded into the brain. " +
+ "The network is meant to mimick the way a biological brain solves a problem, which each " +
+ "nanoprocessor acting similar to the way a neuron would in a neural network. However, these " +
+ "nanoprocessors are programmed to perform computations much faster than organic neurons, " +
+ "allowing its user to solve much more complex problems at a much faster rate.
" +
+ "This augmentation: " +
+ "Increases the player's hacking speed by 3% " +
+ "Increases the amount of money the player's gains from hacking by 15% " +
+ "Increases the player's hacking skill by 12%"
+ });
+ ArtificialBioNeuralNetwork.addToFactions(["BitRunners", "Fulcrum Secret Technologies"]);
+ if (augmentationExists(AugmentationNames.ArtificialBioNeuralNetwork)) {
+ delete Augmentations[AugmentationNames.ArtificialBioNeuralNetwork];
+ }
+ AddToAugmentations(ArtificialBioNeuralNetwork);
+
+ var ArtificialSynapticPotentiation = new Augmentation({
+ name:AugmentationNames.ArtificialSynapticPotentiation, repCost:2500, moneyCost:16e6,
+ info:"The body is injected with a chemical that artificially induces synaptic potentiation, " +
+ "otherwise known as the strengthening of synapses. This results in a enhanced cognitive abilities.
" +
+ "This augmentation: " +
+ "Increases the player's hacking speed by 2% " +
+ "Increases the player's hacking chance by 5% " +
+ "Increases the player's hacking experience gain rate by 5%"
+ });
+ ArtificialSynapticPotentiation.addToFactions(["The Black Hand", "NiteSec"]);
+ if (augmentationExists(AugmentationNames.ArtificialSynapticPotentiation)) {
+ delete Augmentations[AugmentationNames.ArtificialSynapticPotentiation];
+ }
+ AddToAugmentations(ArtificialSynapticPotentiation);
+
+ var EnhancedMyelinSheathing = new Augmentation({
+ name:AugmentationNames.EnhancedMyelinSheathing, repCost:40e3, moneyCost:275e6,
+ info:"Electrical signals are used to induce a new, artificial form of myelinogensis in the human body. " +
+ "This process results in the proliferation of new, synthetic myelin sheaths in the nervous " +
+ "system. These myelin sheaths can propogate neuro-signals much faster than their organic " +
+ "counterparts, leading to greater processing speeds and better brain function.
" +
+ "This augmentation: " +
+ "Increases the player's hacking speed by 3% " +
+ "Increases the player's hacking skill by 8% " +
+ "Increases the player's hacking experience gain rate by 10%"
+ });
+ EnhancedMyelinSheathing.addToFactions(["Fulcrum Secret Technologies", "BitRunners", "The Black Hand"]);
+ if (augmentationExists(AugmentationNames.EnhancedMyelinSheathing)) {
+ delete Augmentations[AugmentationNames.EnhancedMyelinSheathing];
+ }
+ AddToAugmentations(EnhancedMyelinSheathing);
+
+ var SynapticEnhancement = new Augmentation({
+ name:AugmentationNames.SynapticEnhancement, repCost:800, moneyCost:1.5e6,
+ info:"A small cranial implant that continuously uses weak electric signals to stimulate the brain and " +
+ "induce stronger synaptic activity. This improves the user's cognitive abilities.
" +
+ "This augmentation increases the player's hacking speed by 3%."
+ });
+ SynapticEnhancement.addToFactions(["CyberSec"]);
+ if (augmentationExists(AugmentationNames.SynapticEnhancement)) {
+ delete Augmentations[AugmentationNames.SynapticEnhancement];
+ }
+ AddToAugmentations(SynapticEnhancement);
+
+ var NeuralRetentionEnhancement = new Augmentation({
+ name:AugmentationNames.NeuralRetentionEnhancement, repCost:8e3, moneyCost:50e6,
+ info:"Chemical injections are used to permanently alter and strengthen the brain's neuronal " +
+ "circuits, strengthening its ability to retain information.
" +
+ "This augmentation increases the player's hacking experience gain rate by 25%."
+ });
+ NeuralRetentionEnhancement.addToFactions(["NiteSec"]);
+ if (augmentationExists(AugmentationNames.NeuralRetentionEnhancement)) {
+ delete Augmentations[AugmentationNames.NeuralRetentionEnhancement];
+ }
+ AddToAugmentations(NeuralRetentionEnhancement);
+
+ var DataJack = new Augmentation({
+ name:AugmentationNames.DataJack, repCost:45e3, moneyCost:90e6,
+ info:"A brain implant that provides an interface for direct, wireless communication between a computer's main " +
+ "memory and the mind. This implant allows the user to not only access a computer's memory, but also alter " +
+ "and delete it.
" +
+ "This augmentation increases the amount of money the player gains from hacking by 25%"
+ });
+ DataJack.addToFactions(["BitRunners", "The Black Hand", "NiteSec", "Chongqing", "New Tokyo"]);
+ if (augmentationExists(AugmentationNames.DataJack)) {
+ delete Augmentations[AugmentationNames.DataJack];
+ }
+ AddToAugmentations(DataJack);
+
+ var ENM = new Augmentation({
+ name:AugmentationNames.ENM, repCost:6e3, moneyCost:50e6,
+ info:"A thin device embedded inside the arm containing a wireless module capable of connecting " +
+ "to nearby networks. Once connected, the Netburner Module is capable of capturing and " +
+ "processing all of the traffic on that network. By itself, the Embedded Netburner Module does " +
+ "not do much, but a variety of very powerful upgrades can be installed that allow you to fully " +
+ "control the traffic on a network.
" +
+ "This augmentation increases the player's hacking skill by 8%"
+ });
+ ENM.addToFactions(["BitRunners", "The Black Hand", "NiteSec", "ECorp", "MegaCorp",
+ "Fulcrum Secret Technologies", "NWO", "Blade Industries"]);
+ if (augmentationExists(AugmentationNames.ENM)) {
+ delete Augmentations[AugmentationNames.ENM];
+ }
+ AddToAugmentations(ENM);
+
+ var ENMCore = new Augmentation({
+ name:AugmentationNames.ENMCore, repCost:100e3, moneyCost:500e6,
+ info:"The Core library is an implant that upgrades the firmware of the Embedded Netburner Module. " +
+ "This upgrade allows the Embedded Netburner Module to generate its own data on a network.
" +
+ "This augmentation: " +
+ "Increases the player's hacking speed by 3% " +
+ "Increases the amount of money the player gains from hacking by 10% " +
+ "Increases the player's chance of successfully performing a hack by 3% " +
+ "Increases the player's hacking experience gain rate by 7% " +
+ "Increases the player's hacking skill by 7%",
+ prereqs:[AugmentationNames.ENM]
+ });
+ ENMCore.addToFactions(["BitRunners", "The Black Hand", "ECorp", "MegaCorp",
+ "Fulcrum Secret Technologies", "NWO", "Blade Industries"]);
+ if (augmentationExists(AugmentationNames.ENMCore)) {
+ delete Augmentations[AugmentationNames.ENMCore];
+ }
+ AddToAugmentations(ENMCore);
+
+ var ENMCoreV2 = new Augmentation({
+ name:AugmentationNames.ENMCoreV2, repCost:400e3, moneyCost:900e6,
+ info:"The Core V2 library is an implant that upgrades the firmware of the Embedded Netburner Module. " +
+ "This upgraded firmware allows the Embedded Netburner Module to control the information on " +
+ "a network by re-routing traffic, spoofing IP addresses, or altering the data inside network " +
+ "packets.
" +
+ "This augmentation: " +
+ "Increases the player's hacking speed by 5% " +
+ "Increases the amount of money the player gains from hacking by 30% " +
+ "Increases the player's chance of successfully performing a hack by 5% " +
+ "Increases the player's hacking experience gain rate by 15% " +
+ "Increases the player's hacking skill by 8%",
+ prereqs:[AugmentationNames.ENMCore]
+ });
+ ENMCoreV2.addToFactions(["BitRunners", "ECorp", "MegaCorp", "Fulcrum Secret Technologies", "NWO",
+ "Blade Industries", "OmniTek Incorporated", "KuaiGong International"]);
+ if (augmentationExists(AugmentationNames.ENMCoreV2)) {
+ delete Augmentations[AugmentationNames.ENMCoreV2];
+ }
+ AddToAugmentations(ENMCoreV2);
+
+ var ENMCoreV3 = new Augmentation({
+ name:AugmentationNames.ENMCoreV3, repCost:700e3, moneyCost:1500e6,
+ info:"The Core V3 library is an implant that upgrades the firmware of the Embedded Netburner Module. " +
+ "This upgraded firmware allows the Embedded Netburner Module to seamlessly inject code into " +
+ "any device on a network.
" +
+ "This augmentation: " +
+ "Increases the player's hacking speed by 5% " +
+ "Increases the amount of money the player gains from hacking by 40% " +
+ "Increases the player's chance of successfully performing a hack by 10% " +
+ "Increases the player's hacking experience gain rate by 25% " +
+ "Increases the player's hacking skill by 10%",
+ prereqs:[AugmentationNames.ENMCoreV2],
+ });
+ ENMCoreV3.addToFactions(["ECorp", "MegaCorp", "Fulcrum Secret Technologies", "NWO",
+ "Daedalus", "The Covenant", "Illuminati"]);
+ if (augmentationExists(AugmentationNames.ENMCoreV3)) {
+ delete Augmentations[AugmentationNames.ENMCoreV3];
+ }
+ AddToAugmentations(ENMCoreV3);
+
+ var ENMAnalyzeEngine = new Augmentation({
+ name:AugmentationNames.ENMAnalyzeEngine, repCost:250e3, moneyCost:1200e6,
+ info:"Installs the Analyze Engine for the Embedded Netburner Module, which is a CPU cluster " +
+ "that vastly outperforms the Netburner Module's native single-core processor.
" +
+ "This augmentation increases the player's hacking speed by 10%.",
+ prereqs:[AugmentationNames.ENM],
+ });
+ ENMAnalyzeEngine.addToFactions(["ECorp", "MegaCorp", "Fulcrum Secret Technologies", "NWO",
+ "Daedalus", "The Covenant", "Illuminati"]);
+ if (augmentationExists(AugmentationNames.ENMAnalyzeEngine)) {
+ delete Augmentations[AugmentationNames.ENMAnalyzeEngine];
+ }
+ AddToAugmentations(ENMAnalyzeEngine);
+
+ var ENMDMA = new Augmentation({
+ name:AugmentationNames.ENMDMA, repCost:400e3, moneyCost:1400e6,
+ info:"This implant installs a Direct Memory Access (DMA) controller into the " +
+ "Embedded Netburner Module. This allows the Module to send and receive data " +
+ "directly to and from the main memory of devices on a network.
" +
+ "This augmentation: " +
+ "Increases the amount of money the player gains from hacking by 40% " +
+ "Increases the player's chance of successfully performing a hack by 20%",
+ prereqs:[AugmentationNames.ENM],
+ });
+ ENMDMA.addToFactions(["ECorp", "MegaCorp", "Fulcrum Secret Technologies", "NWO",
+ "Daedalus", "The Covenant", "Illuminati"]);
+ if (augmentationExists(AugmentationNames.ENMDMA)) {
+ delete Augmentations[AugmentationNames.ENMDMA];
+ }
+ AddToAugmentations(ENMDMA);
+
+ var Neuralstimulator = new Augmentation({
+ name:AugmentationNames.Neuralstimulator, repCost:20e3, moneyCost:600e6,
+ info:"A cranial implant that intelligently stimulates certain areas of the brain " +
+ "in order to improve cognitive functions
" +
+ "This augmentation: " +
+ "Increases the player's hacking speed by 2% " +
+ "Increases the player's chance of successfully performing a hack by 10% " +
+ "Increases the player's hacking experience gain rate by 12%"
+ });
+ Neuralstimulator.addToFactions(["The Black Hand", "Chongqing", "Sector-12", "New Tokyo", "Aevum",
+ "Ishima", "Volhaven", "Bachman & Associates", "Clarke Incorporated",
+ "Four Sigma"]);
+ if (augmentationExists(AugmentationNames.Neuralstimulator)) {
+ delete Augmentations[AugmentationNames.Neuralstimulator];
+ }
+ AddToAugmentations(Neuralstimulator);
+
+ var NeuralAccelerator = new Augmentation({
+ name:AugmentationNames.NeuralAccelerator, repCost:80e3, moneyCost:350e6,
+ info:"A microprocessor that accelerates the processing " +
+ "speed of biological neural networks. This is a cranial implant that is embedded inside the brain.
" +
+ "This augmentation: " +
+ "Increases the player's hacking skill by 10% " +
+ "Increases the player's hacking experience gain rate by 15% " +
+ "Increases the amount of money the player gains from hacking by 20%"
+ });
+ NeuralAccelerator.addToFactions(["BitRunners"]);
+ if (augmentationExists(AugmentationNames.NeuralAccelerator)) {
+ delete Augmentations[AugmentationNames.NeuralAccelerator];
+ }
+ AddToAugmentations(NeuralAccelerator);
+
+ var CranialSignalProcessorsG1 = new Augmentation({
+ name:AugmentationNames.CranialSignalProcessorsG1, repCost:4e3, moneyCost:14e6,
+ info:"The first generation of Cranial Signal Processors. Cranial Signal Processors " +
+ "are a set of specialized microprocessors that are attached to " +
+ "neurons in the brain. These chips process neural signals to quickly and automatically perform specific computations " +
+ "so that the brain doesn't have to.
" +
+ "This augmentation: " +
+ "Increases the player's hacking speed by 1% " +
+ "Increases the player's hacking skill by 5%"
+ });
+ CranialSignalProcessorsG1.addToFactions(["CyberSec"]);
+ if (augmentationExists(AugmentationNames.CranialSignalProcessorsG1)) {
+ delete Augmentations[AugmentationNames.CranialSignalProcessorsG1];
+ }
+ AddToAugmentations(CranialSignalProcessorsG1);
+
+ var CranialSignalProcessorsG2 = new Augmentation({
+ name:AugmentationNames.CranialSignalProcessorsG2, repCost:7500, moneyCost:25e6,
+ info:"The second generation of Cranial Signal Processors. Cranial Signal Processors " +
+ "are a set of specialized microprocessors that are attached to " +
+ "neurons in the brain. These chips process neural signals to quickly and automatically perform specific computations " +
+ "so that the brain doesn't have to.
" +
+ "This augmentation: " +
+ "Increases the player's hacking speed by 2% " +
+ "Increases the player's chance of successfully performing a hack by 5% " +
+ "Increases the player's hacking skill by 7%"
+ });
+ CranialSignalProcessorsG2.addToFactions(["NiteSec"]);
+ if (augmentationExists(AugmentationNames.CranialSignalProcessorsG2)) {
+ delete Augmentations[AugmentationNames.CranialSignalProcessorsG2];
+ }
+ AddToAugmentations(CranialSignalProcessorsG2);
+
+ var CranialSignalProcessorsG3 = new Augmentation({
+ name:AugmentationNames.CranialSignalProcessorsG3, repCost:20e3, moneyCost:110e6,
+ info:"The third generation of Cranial Signal Processors. Cranial Signal Processors " +
+ "are a set of specialized microprocessors that are attached to " +
+ "neurons in the brain. These chips process neural signals to quickly and automatically perform specific computations " +
+ "so that the brain doesn't have to.
" +
+ "This augmentation: " +
+ "Increases the player's hacking speed by 2% " +
+ "Increases the amount of money the player gains from hacking by 15% " +
+ "Increases the player's hacking skill by 9%"
+ });
+ CranialSignalProcessorsG3.addToFactions(["NiteSec", "The Black Hand"]);
+ if (augmentationExists(AugmentationNames.CranialSignalProcessorsG3)) {
+ delete Augmentations[AugmentationNames.CranialSignalProcessorsG3];
+ }
+ AddToAugmentations(CranialSignalProcessorsG3);
+
+ var CranialSignalProcessorsG4 = new Augmentation({
+ name:AugmentationNames.CranialSignalProcessorsG4, repCost:50e3, moneyCost:220e6,
+ info:"The fourth generation of Cranial Signal Processors. Cranial Signal Processors " +
+ "are a set of specialized microprocessors that are attached to " +
+ "neurons in the brain. These chips process neural signals to quickly and automatically perform specific computations " +
+ "so that the brain doesn't have to.
" +
+ "This augmentation: " +
+ "Increases the player's hacking speed by 2% " +
+ "Increases the amount of money the player gains from hacking by 20% " +
+ "Increases the amount of money the player can inject into servers using grow() by 25%"
+ });
+ CranialSignalProcessorsG4.addToFactions(["The Black Hand"]);
+ if (augmentationExists(AugmentationNames.CranialSignalProcessorsG4)) {
+ delete Augmentations[AugmentationNames.CranialSignalProcessorsG4];
+ }
+ AddToAugmentations(CranialSignalProcessorsG4);
+
+ var CranialSignalProcessorsG5 = new Augmentation({
+ name:AugmentationNames.CranialSignalProcessorsG5, repCost:100e3, moneyCost:450e6,
+ info:"The fifth generation of Cranial Signal Processors. Cranial Signal Processors " +
+ "are a set of specialized microprocessors that are attached to " +
+ "neurons in the brain. These chips process neural signals to quickly and automatically perform specific computations " +
+ "so that the brain doesn't have to.
" +
+ "This augmentation: " +
+ "Increases the player's hacking skill by 30% " +
+ "Increases the amount of money the player gains from hacking by 25% " +
+ "Increases the amount of money the player can inject into servers using grow() by 75%"
+ });
+ CranialSignalProcessorsG5.addToFactions(["BitRunners"]);
+ if (augmentationExists(AugmentationNames.CranialSignalProcessorsG5)) {
+ delete Augmentations[AugmentationNames.CranialSignalProcessorsG5];
+ }
+ AddToAugmentations(CranialSignalProcessorsG5);
+
+ var NeuronalDensification = new Augmentation({
+ name:AugmentationNames.NeuronalDensification, repCost:75e3, moneyCost:275e6,
+ info:"The brain is surgically re-engineered to have increased neuronal density " +
+ "by decreasing the neuron gap junction. Then, the body is genetically modified " +
+ "to enhance the production and capabilities of its neural stem cells.
" +
+ "This augmentation: " +
+ "Increases the player's hacking skill by 15% " +
+ "Increases the player's hacking experience gain rate by 10% "+
+ "Increases the player's hacking speed by 3%"
+ });
+ NeuronalDensification.addToFactions(["Clarke Incorporated"]);
+ if (augmentationExists(AugmentationNames.NeuronalDensification)) {
+ delete Augmentations[AugmentationNames.NeuronalDensification];
+ }
+ AddToAugmentations(NeuronalDensification);
+
+ //Work Augmentations
+ var NuoptimalInjectorImplant = new Augmentation({
+ name:AugmentationNames.NuoptimalInjectorImplant, repCost:2e3, moneyCost:4e6,
+ info:"This torso implant automatically injects nootropic supplements into " +
+ "the bloodstream to improve memory, increase focus, and provide other " +
+ "cognitive enhancements.
" +
+ "This augmentation increases the amount of reputation the player gains " +
+ "when working for a company by 20%."
+ });
+ NuoptimalInjectorImplant.addToFactions(["Tian Di Hui", "Volhaven", "New Tokyo", "Chongqing", "Ishima",
+ "Clarke Incorporated", "Four Sigma", "Bachman & Associates"]);
+ if (augmentationExists(AugmentationNames.NuoptimalInjectorImplant)) {
+ delete Augmentations[AugmentationNames.NuoptimalInjectorImplant];
+ }
+ AddToAugmentations(NuoptimalInjectorImplant);
+
+ var SpeechEnhancement = new Augmentation({
+ name:AugmentationNames.SpeechEnhancement, repCost:1e3, moneyCost:2.5e6,
+ info:"An advanced neural implant that improves your speaking abilities, making " +
+ "you more convincing and likable in conversations and overall improving your " +
+ "social interactions.
" +
+ "This augmentation: " +
+ "Increases the player's charisma by 10% " +
+ "Increases the amount of reputation the player gains when working for a company by 10%"
+ });
+ SpeechEnhancement.addToFactions(["Tian Di Hui", "Speakers for the Dead", "Four Sigma", "KuaiGong International",
+ "Clarke Incorporated", "Four Sigma", "Bachman & Associates"]);
+ if (augmentationExists(AugmentationNames.SpeechEnhancement)) {
+ delete Augmentations[AugmentationNames.SpeechEnhancement];
+ }
+ AddToAugmentations(SpeechEnhancement);
+
+ var FocusWire = new Augmentation({
+ name:AugmentationNames.FocusWire, repCost:30e3, moneyCost:180e6,
+ info:"A cranial implant that stops procrastination by blocking specific neural pathways " +
+ "in the brain.
" +
+ "This augmentation: " +
+ "Increases all experience gains by 5% " +
+ "Increases the amount of money the player gains from working by 20% " +
+ "Increases the amount of reputation the player gains when working for a company by 10%"
+ });
+ FocusWire.addToFactions(["Bachman & Associates", "Clarke Incorporated", "Four Sigma", "KuaiGong International"]);
+ if (augmentationExists(AugmentationNames.FocusWire)) {
+ delete Augmentations[AugmentationNames.FocusWire];
+ }
+ AddToAugmentations(FocusWire)
+
+ var PCDNI = new Augmentation({
+ name:AugmentationNames.PCDNI, repCost:150e3, moneyCost:750e6,
+ info:"Installs a Direct-Neural Interface jack into your arm that is compatible with most " +
+ "computers. Connecting to a computer through this jack allows you to interface with " +
+ "it using the brain's electrochemical signals.
" +
+ "This augmentation: " +
+ "Increases the amount of reputation the player gains when working for a company by 30% " +
+ "Increases the player's hacking skill by 8%"
+ });
+ PCDNI.addToFactions(["Four Sigma", "OmniTek Incorporated", "ECorp", "Blade Industries"]);
+ if (augmentationExists(AugmentationNames.PCDNI)) {
+ delete Augmentations[AugmentationNames.PCDNI];
+ }
+ AddToAugmentations(PCDNI);
+
+ var PCDNIOptimizer = new Augmentation({
+ name:AugmentationNames.PCDNIOptimizer, repCost:200e3, moneyCost:900e6,
+ info:"This is a submodule upgrade to the PC Direct-Neural Interface augmentation. It " +
+ "improves the performance of the interface and gives the user more control options " +
+ "to the connected computer.
" +
+ "This augmentation: " +
+ "Increases the amount of reputation the player gains when working for a company by 75% " +
+ "Increases the player's hacking skill by 10%",
+ prereqs:[AugmentationNames.PCDNI],
+ });
+ PCDNIOptimizer.addToFactions(["Fulcrum Secret Technologies", "ECorp", "Blade Industries"]);
+ if (augmentationExists(AugmentationNames.PCDNIOptimizer)) {
+ delete Augmentations[AugmentationNames.PCDNIOptimizer];
+ }
+ AddToAugmentations(PCDNIOptimizer);
+
+ var PCDNINeuralNetwork = new Augmentation({
+ name:AugmentationNames.PCDNINeuralNetwork, repCost:600e3, moneyCost:1500e6,
+ info:"This is an additional installation that upgrades the functionality of the " +
+ "PC Direct-Neural Interface augmentation. When connected to a computer, " +
+ "The NeuroNet Injector upgrade allows the user to use his/her own brain's " +
+ "processing power to aid the computer in computational tasks.
" +
+ "This augmentation: " +
+ "Increases the amount of reputation the player gains when working for a company by 100% " +
+ "Increases the player's hacking skill by 10% " +
+ "Increases the player's hacking speed by 5%",
+ prereqs:[AugmentationNames.PCDNI],
+ });
+ PCDNINeuralNetwork.addToFactions(["Fulcrum Secret Technologies"]);
+ if (augmentationExists(AugmentationNames.PCDNINeuralNetwork)) {
+ delete Augmentations[AugmentationNames.PCDNINeuralNetwork];
+ }
+ AddToAugmentations(PCDNINeuralNetwork);
+
+ var ADRPheromone1 = new Augmentation({
+ name:AugmentationNames.ADRPheromone1, repCost:1500, moneyCost:3.5e6,
+ info:"The body is genetically re-engineered so that it produces the ADR-V1 pheromone, " +
+ "an artificial pheromone discovered by scientists. The ADR-V1 pheromone, when excreted, " +
+ "triggers feelings of admiration and approval in other people.
" +
+ "This augmentation: " +
+ "Increases the amount of reputation the player gains when working for a company by 10% " +
+ "Increases the amount of reputation the player gains for a faction by 10%"
+ });
+ ADRPheromone1.addToFactions(["Tian Di Hui", "The Syndicate", "NWO", "MegaCorp", "Four Sigma"]);
+ if (augmentationExists(AugmentationNames.ADRPheromone1)) {
+ delete Augmentations[AugmentationNames.ADRPheromone1];
+ }
+ AddToAugmentations(ADRPheromone1);
+
+ var ADRPheromone2 = new Augmentation({
+ name:AugmentationNames.ADRPheromone2, repCost:25e3, moneyCost:110e6,
+ info:"The body is genetically re-engineered so that it produces the ADR-V2 pheromone, " +
+ "which is similar to but more potent than ADR-V1. This pheromone, when excreted, " +
+ "triggers feelings of admiration, approval, and respect in others.
" +
+ "This augmentation: " +
+ "Increases the amount of reputation the player gains for a faction and company by 20%."
+ });
+ ADRPheromone2.addToFactions(["Silhouette", "Four Sigma", "Bachman & Associates", "Clarke Incorporated"]);
+ if (augmentationExists(AugmentationNames.ADRPheromone2)) {
+ delete Augmentations[AugmentationNames.ADRPheromone2];
+ }
+ AddToAugmentations(ADRPheromone2);
+
+ //HacknetNode Augmentations
+ var HacknetNodeCPUUpload = new Augmentation({
+ name:AugmentationNames.HacknetNodeCPUUpload, repCost:1500, moneyCost:2.2e6,
+ info:"Uploads the architecture and design details of a Hacknet Node's CPU into " +
+ "the brain. This allows the user to engineer custom hardware and software " +
+ "for the Hacknet Node that provides better performance.
" +
+ "This augmentation: " +
+ "Increases the amount of money produced by Hacknet Nodes by 15% " +
+ "Decreases the cost of purchasing a Hacknet Node by 15%"
+ });
+ HacknetNodeCPUUpload.addToFactions(["Netburners"]);
+ if (augmentationExists(AugmentationNames.HacknetNodeCPUUpload)) {
+ delete Augmentations[AugmentationNames.HacknetNodeCPUUpload];
+ }
+ AddToAugmentations(HacknetNodeCPUUpload);
+
+ var HacknetNodeCacheUpload = new Augmentation({
+ name:AugmentationNames.HacknetNodeCacheUpload, repCost:1e3, moneyCost:1.1e6,
+ info:"Uploads the architecture and design details of a Hacknet Node's main-memory cache " +
+ "into the brain. This allows the user to engineer custom cache hardware for the " +
+ "Hacknet Node that offers better performance.
" +
+ "This augmentation: " +
+ "Increases the amount of money produced by Hacknet Nodes by 10% " +
+ "Decreases the cost of leveling up a Hacknet Node by 15%"
+ });
+ HacknetNodeCacheUpload.addToFactions(["Netburners"]);
+ if (augmentationExists(AugmentationNames.HacknetNodeCacheUpload)) {
+ delete Augmentations[AugmentationNames.HacknetNodeCacheUpload];
+ }
+ AddToAugmentations(HacknetNodeCacheUpload);
+
+ var HacknetNodeNICUpload = new Augmentation({
+ name:AugmentationNames.HacknetNodeNICUpload, repCost:750, moneyCost:900e3,
+ info:"Uploads the architecture and design details of a Hacknet Node's Network Interface Card (NIC) " +
+ "into the brain. This allows the user to engineer a custom NIC for the Hacknet Node that " +
+ "offers better performance.
" +
+ "This augmentation: " +
+ "Increases the amount of money produced by Hacknet Nodes by 10% " +
+ "Decreases the cost of purchasing a Hacknet Node by 10%"
+ });
+ HacknetNodeNICUpload.addToFactions(["Netburners"]);
+ if (augmentationExists(AugmentationNames.HacknetNodeNICUpload)) {
+ delete Augmentations[AugmentationNames.HacknetNodeNICUpload];
+ }
+ AddToAugmentations(HacknetNodeNICUpload);
+
+ var HacknetNodeKernelDNI = new Augmentation({
+ name:AugmentationNames.HacknetNodeKernelDNI, repCost:3e3, moneyCost:8e6,
+ info:"Installs a Direct-Neural Interface jack into the arm that is capable of connecting to a " +
+ "Hacknet Node. This lets the user access and manipulate the Node's kernel using the mind's " +
+ "electrochemical signals.
" +
+ "This augmentation increases the amount of money produced by Hacknet Nodes by 25%."
+ });
+ HacknetNodeKernelDNI.addToFactions(["Netburners"]);
+ if (augmentationExists(AugmentationNames.HacknetNodeKernelDNI)) {
+ delete Augmentations[AugmentationNames.HacknetNodeKernelDNI];
+ }
+ AddToAugmentations(HacknetNodeKernelDNI);
+
+ var HacknetNodeCoreDNI = new Augmentation({
+ name:AugmentationNames.HacknetNodeCoreDNI, repCost:5e3, moneyCost:12e6,
+ info:"Installs a Direct-Neural Interface jack into the arm that is capable of connecting " +
+ "to a Hacknet Node. This lets the user access and manipulate the Node's processing logic using " +
+ "the mind's electrochemical signals.
" +
+ "This augmentation increases the amount of money produced by Hacknet Nodes by 45%."
+ });
+ HacknetNodeCoreDNI.addToFactions(["Netburners"]);
+ if (augmentationExists(AugmentationNames.HacknetNodeCoreDNI)) {
+ delete Augmentations[AugmentationNames.HacknetNodeCoreDNI];
+ }
+ AddToAugmentations(HacknetNodeCoreDNI);
+
+ //Misc/Hybrid augmentations
+ var NeuroFluxGovernor = new Augmentation({
+ name:AugmentationNames.NeuroFluxGovernor, repCost:500, moneyCost: 750e3,
+ info:"A device that is embedded in the back of the neck. The NeuroFlux Governor " +
+ "monitors and regulates nervous impulses coming to and from the spinal column, " +
+ "essentially 'governing' the body. By doing so, it improves the functionality of the " +
+ "body's nervous system.
" +
+ "This is a special augmentation because it can be leveled up infinitely. Each level of this augmentation " +
+ "increases ALL of the player's multipliers by 1%"
+ });
+ var nextLevel = Object(_Faction_js__WEBPACK_IMPORTED_MODULE_3__["getNextNeurofluxLevel"])();
+ NeuroFluxGovernor.level = nextLevel - 1;
+ mult = Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].NeuroFluxGovernorLevelMult, NeuroFluxGovernor.level);
+ NeuroFluxGovernor.baseRepRequirement = 500 * mult * _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].AugmentationRepMultiplier * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].AugmentationRepCost;
+ NeuroFluxGovernor.baseCost = 750e3 * mult * _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].AugmentationCostMultiplier * _BitNode_js__WEBPACK_IMPORTED_MODULE_0__["BitNodeMultipliers"].AugmentationMoneyCost;
+ if (augmentationExists(AugmentationNames.NeuroFluxGovernor)) {
+ delete Augmentations[AugmentationNames.NeuroFluxGovernor];
+ }
+ NeuroFluxGovernor.addToAllFactions();
+ AddToAugmentations(NeuroFluxGovernor);
+
+ var Neurotrainer1 = new Augmentation({
+ name:AugmentationNames.Neurotrainer1, repCost:400, moneyCost:800e3,
+ info:"A decentralized cranial implant that improves the brain's ability to learn. It is " +
+ "installed by releasing millions of nanobots into the human brain, each of which " +
+ "attaches to a different neural pathway to enhance the brain's ability to retain " +
+ "and retrieve information.
" +
+ "This augmentation increases the player's experience gain rate for all stats by 10%"
+ });
+ Neurotrainer1.addToFactions(["CyberSec"]);
+ if (augmentationExists(AugmentationNames.Neurotrainer1)) {
+ delete Augmentations[AugmentationNames.Neurotrainer1];
+ }
+ AddToAugmentations(Neurotrainer1);
+
+ var Neurotrainer2 = new Augmentation({
+ name:AugmentationNames.Neurotrainer2, repCost:4e3, moneyCost:9e6,
+ info:"A decentralized cranial implant that improves the brain's ability to learn. This " +
+ "is a more powerful version of the Neurotrainer I augmentation, but it does not " +
+ "require Neurotrainer I to be installed as a prerequisite.
" +
+ "This augmentation increases the player's experience gain rate for all stats by 15%"
+ });
+ Neurotrainer2.addToFactions(["BitRunners", "NiteSec"]);
+ if (augmentationExists(AugmentationNames.Neurotrainer2)) {
+ delete Augmentations[AugmentationNames.Neurotrainer2];
+ }
+ AddToAugmentations(Neurotrainer2);
+
+ var Neurotrainer3 = new Augmentation({
+ name:AugmentationNames.Neurotrainer3, repCost:10e3, moneyCost:26e6,
+ info:"A decentralized cranial implant that improves the brain's ability to learn. This " +
+ "is a more powerful version of the Neurotrainer I and Neurotrainer II augmentation, " +
+ "but it does not require either of them to be installed as a prerequisite.
" +
+ "This augmentation increases the player's experience gain rate for all stats by 20%"
+ });
+ Neurotrainer3.addToFactions(["NWO", "Four Sigma"]);
+ if (augmentationExists(AugmentationNames.Neurotrainer3)) {
+ delete Augmentations[AugmentationNames.Neurotrainer3];
+ }
+ AddToAugmentations(Neurotrainer3);
+
+ var Hypersight = new Augmentation({
+ name:AugmentationNames.Hypersight, repCost:60e3, moneyCost:550e6,
+ info:"A bionic eye implant that grants sight capabilities far beyond those of a natural human. " +
+ "Embedded circuitry within the implant provides the ability to detect heat and movement " +
+ "through solid objects such as wells, thus providing 'x-ray vision'-like capabilities.
" +
+ "This augmentation: " +
+ "Increases the player's dexterity by 40% " +
+ "Increases the player's hacking speed by 3% " +
+ "Increases the amount of money the player gains from hacking by 10%"
+ });
+ Hypersight.addToFactions(["Blade Industries", "KuaiGong International"]);
+ if (augmentationExists(AugmentationNames.Hypersight)) {
+ delete Augmentations[AugmentationNames.Hypersight];
+ }
+ AddToAugmentations(Hypersight);
+
+ var LuminCloaking1 = new Augmentation({
+ name:AugmentationNames.LuminCloaking1, repCost:600, moneyCost:1e6,
+ info:"A skin implant that reinforces the skin with highly-advanced synthetic cells. These " +
+ "cells, when powered, have a negative refractive index. As a result, they bend light " +
+ "around the skin, making the user much harder to see from the naked eye.
" +
+ "This augmentation: " +
+ "Increases the player's agility by 5% " +
+ "Increases the amount of money the player gains from crimes by 10%"
+ });
+ LuminCloaking1.addToFactions(["Slum Snakes", "Tetrads"]);
+ if (augmentationExists(AugmentationNames.LuminCloaking1)) {
+ delete Augmentations[AugmentationNames.LuminCloaking1];
+ }
+ AddToAugmentations(LuminCloaking1);
+
+ var LuminCloaking2 = new Augmentation({
+ name:AugmentationNames.LuminCloaking2, repCost:2e3, moneyCost:6e6,
+ info:"This is a more advanced version of the LuminCloaking-V2 augmentation. This skin implant " +
+ "reinforces the skin with highly-advanced synthetic cells. These " +
+ "cells, when powered, are capable of not only bending light but also of bending heat, " +
+ "making the user more resilient as well as stealthy.
" +
+ "This augmentation: " +
+ "Increases the player's agility by 10% " +
+ "Increases the player's defense by 10% " +
+ "Increases the amount of money the player gains from crimes by 25%"
+ });
+ LuminCloaking2.addToFactions(["Slum Snakes", "Tetrads"]);
+ if (augmentationExists(AugmentationNames.LuminCloaking2)) {
+ delete Augmentations[AugmentationNames.LuminCloaking2];
+ }
+ AddToAugmentations(LuminCloaking2);
+
+ var SmartSonar = new Augmentation({
+ name:AugmentationNames.SmartSonar, repCost:9e3, moneyCost:15e6,
+ info:"A cochlear implant that helps the player detect and locate enemies " +
+ "using sound propagation.
" +
+ "This augmentation: " +
+ "Increases the player's dexterity by 10% " +
+ "Increases the player's dexterity experience gain rate by 15% " +
+ "Increases the amount of money the player gains from crimes by 25%"
+ });
+ SmartSonar.addToFactions(["Slum Snakes"]);
+ if (augmentationExists(AugmentationNames.SmartSonar)) {
+ delete Augmentations[AugmentationNames.SmartSonar];
+ }
+ AddToAugmentations(SmartSonar);
+
+ var PowerRecirculator = new Augmentation({
+ name:AugmentationNames.PowerRecirculator, repCost:10e3, moneyCost:36e6,
+ info:"The body's nerves are attached with polypyrrole nanocircuits that " +
+ "are capable of capturing wasted energy (in the form of heat) " +
+ "and converting it back into usable power.
" +
+ "This augmentation: " +
+ "Increases all of the player's stats by 5% " +
+ "Increases the player's experience gain rate for all stats by 10%"
+ });
+ PowerRecirculator.addToFactions(["Tetrads", "The Dark Army", "The Syndicate", "NWO"]);
+ if (augmentationExists(AugmentationNames.PowerRecirculator)) {
+ delete Augmentations[AugmentationNames.PowerRecirculator];
+ }
+ AddToAugmentations(PowerRecirculator);
+
+ //Unique AUGS (Each Faction gets one unique augmentation)
+ //Factions that already have unique augs up to this point:
+ // Slum Snakes, CyberSec, Netburners, Fulcrum Secret Technologies,
+ // Silhouette
+
+ //Illuminati
+ var QLink = new Augmentation({
+ name:AugmentationNames.QLink, repCost:750e3, moneyCost:1300e6,
+ info:"A brain implant that wirelessly connects you to the Illuminati's " +
+ "quantum supercomputer, allowing you to access and use its incredible " +
+ "computing power.
" +
+ "This augmentation: " +
+ "Increases the player's hacking speed by 10% " +
+ "Increases the player's chance of successfully performing a hack by 30% " +
+ "Increases the amount of money the player gains from hacking by 100%"
+ });
+ QLink.addToFactions(["Illuminati"]);
+ if (augmentationExists(AugmentationNames.QLink)) {
+ delete Augmentations[AugmentationNames.QLink];
+ }
+ AddToAugmentations(QLink);
+
+ //Daedalus
+ var RedPill = new Augmentation({
+ name:AugmentationNames.TheRedPill, repCost:1e6, moneyCost:0,
+ info:"It's time to leave the cave"
+ });
+ RedPill.addToFactions(["Daedalus"]);
+ if (augmentationExists(AugmentationNames.TheRedPill)) {
+ delete Augmentations[AugmentationNames.TheRedPill];
+ }
+ AddToAugmentations(RedPill);
+
+ //Covenant
+ var SPTN97 = new Augmentation({
+ name:AugmentationNames.SPTN97, repCost:500e3, moneyCost:975e6,
+ info:"The SPTN-97 gene is injected into the genome. The SPTN-97 gene is an " +
+ "artificially-synthesized gene that was developed by DARPA to create " +
+ "super-soldiers through genetic modification. The gene was outlawed in " +
+ "2056.
" +
+ "This augmentation: " +
+ "Increases all of the player's combat stats by 75% " +
+ "Increases the player's hacking skill by 15%"
+ });
+ SPTN97.addToFactions(["The Covenant"]);
+ if (augmentationExists(AugmentationNames.SPTN97)) {
+ delete Augmentations[AugmentationNames.SPTN97];
+ }
+ AddToAugmentations(SPTN97);
+
+ //ECorp
+ var HiveMind = new Augmentation({
+ name:AugmentationNames.HiveMind, repCost:600e3, moneyCost:1100e6,
+ info:"A brain implant developed by ECorp. They do not reveal what " +
+ "exactly the implant does, but they promise that it will greatly " +
+ "enhance your abilities."
+ });
+ HiveMind.addToFactions(["ECorp"]);
+ if (augmentationExists(AugmentationNames.HiveMind)) {
+ delete Augmentations[AugmentationNames.HiveMind];
+ }
+ AddToAugmentations(HiveMind);
+
+ //MegaCorp
+ var CordiARCReactor = new Augmentation({
+ name:AugmentationNames.CordiARCReactor, repCost:450e3, moneyCost:1000e6,
+ info:"The thoracic cavity is equipped with a small chamber designed " +
+ "to hold and sustain hydrogen plasma. The plasma is used to generate " +
+ "fusion power through nuclear fusion, providing limitless amount of clean " +
+ "energy for the body.
" +
+ "This augmentation: " +
+ "Increases all of the player's combat stats by 35% " +
+ "Increases all of the player's combat stat experience gain rate by 35%"
+ });
+ CordiARCReactor.addToFactions(["MegaCorp"]);
+ if (augmentationExists(AugmentationNames.CordiARCReactor)) {
+ delete Augmentations[AugmentationNames.CordiARCReactor];
+ }
+ AddToAugmentations(CordiARCReactor);
+
+ //BachmanAndAssociates
+ var SmartJaw = new Augmentation({
+ name:AugmentationNames.SmartJaw, repCost:150e3, moneyCost:550e6,
+ info:"A bionic jaw that contains advanced hardware and software " +
+ "capable of psychoanalyzing and profiling the personality of " +
+ "others using optical imaging software.
" +
+ "This augmentation: " +
+ "Increases the player's charisma by 50%. " +
+ "Increases the player's charisma experience gain rate by 50% " +
+ "Increases the amount of reputation the player gains for a company by 25% " +
+ "Increases the amount of reputation the player gains for a faction by 25%"
+ });
+ SmartJaw.addToFactions(["Bachman & Associates"]);
+ if (augmentationExists(AugmentationNames.SmartJaw)) {
+ delete Augmentations[AugmentationNames.SmartJaw];
+ }
+ AddToAugmentations(SmartJaw);
+
+ //BladeIndustries
+ var Neotra = new Augmentation({
+ name:AugmentationNames.Neotra, repCost:225e3, moneyCost:575e6,
+ info:"A highly-advanced techno-organic drug that is injected into the skeletal " +
+ "and integumentary system. The drug permanently modifies the DNA of the " +
+ "body's skin and bone cells, granting them the ability to repair " +
+ "and restructure themselves.
" +
+ "This augmentation increases the player's strength and defense by 55%"
+ });
+ Neotra.addToFactions(["Blade Industries"]);
+ if (augmentationExists(AugmentationNames.Neotra)) {
+ delete Augmentations[AugmentationNames.Neotra];
+ }
+ AddToAugmentations(Neotra);
+
+ //NWO
+ var Xanipher = new Augmentation({
+ name:AugmentationNames.Xanipher, repCost:350e3, moneyCost:850e6,
+ info:"A concoction of advanced nanobots that is orally ingested into the " +
+ "body. These nanobots induce physiological change and significantly " +
+ "improve the body's functionining in all aspects.
" +
+ "This augmentation: " +
+ "Increases all of the player's stats by 20% " +
+ "Increases the player's experience gain rate for all stats by 15%"
+ });
+ Xanipher.addToFactions(["NWO"]);
+ if (augmentationExists(AugmentationNames.Xanipher)) {
+ delete Augmentations[AugmentationNames.Xanipher];
+ }
+ AddToAugmentations(Xanipher);
+
+ //ClarkeIncorporated
+ var nextSENS = new Augmentation({
+ name:AugmentationNames.nextSENS, repCost:175e3, moneyCost:385e6,
+ info:"The body is genetically re-engineered to maintain a state " +
+ "of negligible senescence, preventing the body from " +
+ "deteriorating with age.
" +
+ "This augmentation increases all of the player's stats by 20%"
+ });
+ nextSENS.addToFactions(["Clarke Incorporated"]);
+ if (augmentationExists(AugmentationNames.nextSENS)) {
+ delete Augmentations[AugmentationNames.nextSENS];
+ }
+ AddToAugmentations(nextSENS);
+
+ //OmniTekIncorporated
+ var OmniTekInfoLoad = new Augmentation({
+ name:AugmentationNames.OmniTekInfoLoad, repCost:250e3, moneyCost:575e6,
+ info:"OmniTek's data and information repository is uploaded " +
+ "into your brain, enhancing your programming and " +
+ "hacking abilities.
" +
+ "This augmentation: " +
+ "Increases the player's hacking skill by 20% " +
+ "Increases the player's hacking experience gain rate by 25%"
+ });
+ OmniTekInfoLoad.addToFactions(["OmniTek Incorporated"]);
+ if (augmentationExists(AugmentationNames.OmniTekInfoLoad)) {
+ delete Augmentations[AugmentationNames.OmniTekInfoLoad];
+ }
+ AddToAugmentations(OmniTekInfoLoad);
+
+ //FourSigma
+ //TODO Later when Intelligence is added in . Some aug that greatly increases int
+
+ //KuaiGongInternational
+ var PhotosyntheticCells = new Augmentation({
+ name:AugmentationNames.PhotosyntheticCells, repCost:225e3, moneyCost:550e6,
+ info:"Chloroplasts are added to epidermal stem cells and are applied " +
+ "to the body using a skin graft. The result is photosynthetic " +
+ "skin cells, allowing users to generate their own energy " +
+ "and nutrition using solar power.
" +
+ "This augmentation increases the player's strength, defense, and agility by 40%"
+ });
+ PhotosyntheticCells.addToFactions(["KuaiGong International"]);
+ if (augmentationExists(AugmentationNames.PhotosyntheticCells)) {
+ delete Augmentations[AugmentationNames.PhotosyntheticCells];
+ }
+ AddToAugmentations(PhotosyntheticCells);
+
+ //BitRunners
+ var Neurolink = new Augmentation({
+ name:AugmentationNames.Neurolink, repCost:350e3, moneyCost:875e6,
+ info:"A brain implant that provides a high-bandwidth, direct neural link between your " +
+ "mind and BitRunners' data servers, which reportedly contain " +
+ "the largest database of hacking tools and information in the world.
" +
+ "This augmentation: " +
+ "Increases the player's hacking skill by 15% " +
+ "Increases the player's hacking experience gain rate by 20% " +
+ "Increases the player's chance of successfully performing a hack by 10% " +
+ "Increases the player's hacking speed by 5% " +
+ "Lets the player start with the FTPCrack.exe and relaySMTP.exe programs after a reset"
+ });
+ Neurolink.addToFactions(["BitRunners"]);
+ if (augmentationExists(AugmentationNames.Neurolink)) {
+ delete Augmentations[AugmentationNames.Neurolink];
+ }
+ AddToAugmentations(Neurolink);
+
+ //BlackHand
+ var TheBlackHand = new Augmentation({
+ name:AugmentationNames.TheBlackHand, repCost:40e3, moneyCost:110e6,
+ info:"A highly advanced bionic hand. This prosthetic not only " +
+ "enhances strength and dexterity but it is also embedded " +
+ "with hardware and firmware that lets the user connect to, access and hack " +
+ "devices and machines just by touching them.
" +
+ "This augmentation: " +
+ "Increases the player's strength and dexterity by 15% " +
+ "Increases the player's hacking skill by 10% " +
+ "Increases the player's hacking speed by 2% " +
+ "Increases the amount of money the player gains from hacking by 10%"
+ });
+ TheBlackHand.addToFactions(["The Black Hand"]);
+ if (augmentationExists(AugmentationNames.TheBlackHand)) {
+ delete Augmentations[AugmentationNames.TheBlackHand];
+ }
+ AddToAugmentations(TheBlackHand);
+
+ //NiteSec
+ var CRTX42AA = new Augmentation({
+ name:AugmentationNames.CRTX42AA, repCost:18e3, moneyCost:45e6,
+ info:"The CRTX42-AA gene is injected into the genome. " +
+ "The CRTX42-AA is an artificially-synthesized gene that targets the visual and prefrontal " +
+ "cortex and improves cognitive abilities.
" +
+ "This augmentation: " +
+ "Improves the player's hacking skill by 8% " +
+ "Improves the player's hacking experience gain rate by 15%"
+ });
+ CRTX42AA.addToFactions(["NiteSec"]);
+ if (augmentationExists(AugmentationNames.CRTX42AA)) {
+ delete Augmentations[AugmentationNames.CRTX42AA];
+ }
+ AddToAugmentations(CRTX42AA);
+
+ //Chongqing
+ var Neuregen = new Augmentation({
+ name:AugmentationNames.Neuregen, repCost:15e3, moneyCost:75e6,
+ info:"A drug that genetically modifies the neurons in the brain. " +
+ "The result is that these neurons never die and continuously " +
+ "regenerate and strengthen themselves.
" +
+ "This augmentation increases the player's hacking experience gain rate by 40%"
+ });
+ Neuregen.addToFactions(["Chongqing"]);
+ if (augmentationExists(AugmentationNames.Neuregen)) {
+ delete Augmentations[AugmentationNames.Neuregen];
+ }
+ AddToAugmentations(Neuregen);
+
+ //Sector12
+ var CashRoot = new Augmentation({
+ name:AugmentationNames.CashRoot, repCost:5e3, moneyCost:25e6,
+ info:"A collection of digital assets saved on a small chip. The chip is implanted " +
+ "into your wrist. A small jack in the chip allows you to connect it to a computer " +
+ "and upload the assets.
" +
+ "This augmentation: " +
+ "Lets the player start with $1,000,000 after a reset " +
+ "Lets the player start with the BruteSSH.exe program after a reset"
+ });
+ CashRoot.addToFactions(["Sector-12"]);
+ if (augmentationExists(AugmentationNames.CashRoot)) {
+ delete Augmentations[AugmentationNames.CashRoot];
+ }
+ AddToAugmentations(CashRoot);
+
+ //NewTokyo
+ var NutriGen = new Augmentation({
+ name:AugmentationNames.NutriGen, repCost:2500, moneyCost:500e3,
+ info:"A thermo-powered artificial nutrition generator. Endogenously " +
+ "synthesizes glucose, amino acids, and vitamins and redistributes them " +
+ "across the body. The device is powered by the body's naturally wasted " +
+ "energy in the form of heat.
" +
+ "This augmentation: " +
+ "Increases the player's experience gain rate for all combat stats by 20%"
+ });
+ NutriGen.addToFactions(["New Tokyo"]);
+ if (augmentationExists(AugmentationNames.NutriGen)) {
+ delete Augmentations[AugmentationNames.NutriGen];
+ }
+ AddToAugmentations(NutriGen);
+
+ //Aevum
+ //TODO Later Something that lets you learn advanced math...this increases int
+ //and profits as a trader/from trading
+
+ //Ishima
+ var INFRARet = new Augmentation({
+ name:AugmentationNames.INFRARet, repCost:3e3, moneyCost:6e6,
+ info:"A retina implant consisting of a tiny chip that sits behind the " +
+ "retina. This implant lets people visually detect infrared radiation.
" +
+ "This augmentation: " +
+ "Increases the player's crime success rate by 25% " +
+ "Increases the amount of money the player gains from crimes by 10% " +
+ "Increases the player's dexterity by 10%"
+ });
+ INFRARet.addToFactions(["Ishima"]);
+ if (augmentationExists(AugmentationNames.INFRARet)) {
+ delete Augmentations[AugmentationNames.INFRARet];
+ }
+ AddToAugmentations(INFRARet);
+
+ //Volhaven
+ var DermaForce = new Augmentation({
+ name:AugmentationNames.DermaForce, repCost:6e3, moneyCost:10e6,
+ info:"A synthetic skin is grafted onto the body. The skin consists of " +
+ "millions of nanobots capable of projecting high-density muon beams, " +
+ "creating an energy barrier around the user.
" +
+ "This augmentation increases the player's defense by 40%"
+ });
+ DermaForce.addToFactions(["Volhaven"]);
+ if (augmentationExists(AugmentationNames.DermaForce)) {
+ delete Augmentations[AugmentationNames.DermaForce];
+ }
+ AddToAugmentations(DermaForce);
+
+ //SpeakersForTheDead
+ var GrapheneBrachiBlades = new Augmentation({
+ name:AugmentationNames.GrapheneBrachiBlades, repCost:90e3, moneyCost:500e6,
+ info:"An upgrade to the BrachiBlades augmentation. It infuses " +
+ "the retractable blades with an advanced graphene material " +
+ "to make them much stronger and lighter.
" +
+ "This augmentation: " +
+ "Increases the player's strength and defense by 40% " +
+ "Increases the player's crime success rate by 10% " +
+ "Increases the amount of money the player gains from crimes by 30%",
+ prereqs:[AugmentationNames.BrachiBlades],
+ });
+ GrapheneBrachiBlades.addToFactions(["Speakers for the Dead"]);
+ if (augmentationExists(AugmentationNames.GrapheneBrachiBlades)) {
+ delete Augmentations[AugmentationNames.GrapheneBrachiBlades];
+ }
+ AddToAugmentations(GrapheneBrachiBlades);
+
+ //DarkArmy
+ var GrapheneBionicArms = new Augmentation({
+ name:AugmentationNames.GrapheneBionicArms, repCost:200e3, moneyCost:750e6,
+ info:"An upgrade to the Bionic Arms augmentation. It infuses the " +
+ "prosthetic arms with an advanced graphene material " +
+ "to make them much stronger and lighter.
" +
+ "This augmentation increases the player's strength and dexterity by 85%",
+ prereqs:[AugmentationNames.BionicArms],
+ });
+ GrapheneBionicArms.addToFactions(["The Dark Army"]);
+ if (augmentationExists(AugmentationNames.GrapheneBionicArms)) {
+ delete Augmentations[AugmentationNames.GrapheneBionicArms];
+ }
+ AddToAugmentations(GrapheneBionicArms);
+
+ //TheSyndicate
+ var BrachiBlades = new Augmentation({
+ name:AugmentationNames.BrachiBlades, repCost:5e3, moneyCost:18e6,
+ info:"A set of retractable plasteel blades are implanted in the arm, underneath the skin. " +
+ "
This augmentation: " +
+ "Increases the player's strength and defense by 15% " +
+ "Increases the player's crime success rate by 10% " +
+ "Increases the amount of money the player gains from crimes by 15%"
+ });
+ BrachiBlades.addToFactions(["The Syndicate"]);
+ if (augmentationExists(AugmentationNames.BrachiBlades)) {
+ delete Augmentations[AugmentationNames.BrachiBlades];
+ }
+ AddToAugmentations(BrachiBlades);
+
+ //Tetrads
+ var BionicArms = new Augmentation({
+ name:AugmentationNames.BionicArms, repCost:25e3, moneyCost:55e6,
+ info:"Cybernetic arms created from plasteel and carbon fibers that completely replace " +
+ "the user's organic arms.
" +
+ "This augmentation increases the user's strength and dexterity by 30%"
+ });
+ BionicArms.addToFactions(["Tetrads"]);
+ if (augmentationExists(AugmentationNames.BionicArms)) {
+ delete Augmentations[AugmentationNames.BionicArms];
+ }
+ AddToAugmentations(BionicArms);
+
+ //TianDiHui
+ var SNA = new Augmentation({
+ name:AugmentationNames.SNA, repCost:2500, moneyCost:6e6,
+ info:"A cranial implant that affects the user's personality, making them better " +
+ "at negotiation in social situations.
" +
+ "This augmentation: " +
+ "Increases the amount of money the player earns at a company by 10% " +
+ "Increases the amount of reputation the player gains when working for a " +
+ "company or faction by 15%"
+ });
+ SNA.addToFactions(["Tian Di Hui"]);
+ if (augmentationExists(AugmentationNames.SNA)) {
+ delete Augmentations[AugmentationNames.SNA];
+ }
+ AddToAugmentations(SNA);
+
+ //For BitNode-2, add all Augmentations to crime/evil factions.
+ //Do this before adding special Augmentations that become available in later BitNodes
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bitNodeN === 2) {
+ console.log("Adding all augmentations to crime factions for Bit node 2");
+ _Faction_js__WEBPACK_IMPORTED_MODULE_3__["Factions"]["Slum Snakes"].addAllAugmentations();
+ _Faction_js__WEBPACK_IMPORTED_MODULE_3__["Factions"]["Tetrads"].addAllAugmentations();
+ _Faction_js__WEBPACK_IMPORTED_MODULE_3__["Factions"]["The Syndicate"].addAllAugmentations();
+ _Faction_js__WEBPACK_IMPORTED_MODULE_3__["Factions"]["The Dark Army"].addAllAugmentations();
+ _Faction_js__WEBPACK_IMPORTED_MODULE_3__["Factions"]["Speakers for the Dead"].addAllAugmentations();
+ _Faction_js__WEBPACK_IMPORTED_MODULE_3__["Factions"]["NiteSec"].addAllAugmentations();
+ _Faction_js__WEBPACK_IMPORTED_MODULE_3__["Factions"]["The Black Hand"].addAllAugmentations();
+ }
+
+ //Special Bladeburner Augmentations
+ var BladeburnersFactionName = "Bladeburners";
+ if (Object(_Faction_js__WEBPACK_IMPORTED_MODULE_3__["factionExists"])(BladeburnersFactionName)) {
+ var EsperEyewear = new Augmentation({
+ name:AugmentationNames.EsperEyewear, repCost:400, moneyCost:30e6,
+ info:"Ballistic-grade protective and retractable eyewear that was designed specially " +
+ "for Bladeburner units. This " +
+ "is implanted by installing a mechanical frame in the skull's orbit. " +
+ "This frame interfaces with the brain and allows the user to " +
+ "automatically extrude and extract the eyewear. The eyewear protects " +
+ "against debris, shrapnel, laser, flash, and gas. It is also " +
+ "embedded with a data processing chip that can be programmed to display an " +
+ "AR HUD and assist the user in field missions.
" +
+ "This augmentation: " +
+ "Increases the player's success chance in Bladeburner contracts/operations by 3% " +
+ "Increases the player's dexterity by 3%"
+ });
+ EsperEyewear.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(EsperEyewear);
+
+ var EMS4Recombination = new Augmentation({
+ name:AugmentationNames.EMS4Recombination, repCost: 800, moneyCost:50e6,
+ info:"A DNA recombination of the EMS-4 Gene. This genetic engineering " +
+ "technique was originally used on Bladeburners during the Synthoid uprising " +
+ "to induce wakefulness and concentration, suppress fear, reduce empathy, and " +
+ "improve reflexes and memory-recall among other things.
" +
+ "This augmentation: " +
+ "Increases the player's sucess chance in Bladeburner contracts/operations by 3% " +
+ "Increases the player's effectiveness in Bladeburner Field Analysis by 5% " +
+ "Increases the player's Bladeburner stamina gain rate by 1%"
+ });
+ EMS4Recombination.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(EMS4Recombination);
+
+ var OrionShoulder = new Augmentation({
+ name:AugmentationNames.OrionShoulder, repCost:2e3, moneyCost:100e6,
+ info:"A bionic shoulder augmentation for the right shoulder. Using cybernetics, " +
+ "the ORION-MKIV shoulder enhances the strength and dexterity " +
+ "of the user's right arm. It also provides protection due to its " +
+ "crystallized graphene plating.
" +
+ "This augmentation: " +
+ "Increases the player's defense by 5%. " +
+ "Increases the player's strength and dexterity by 3% " +
+ "Increases the player's success chance in Bladeburner contracts/operations by 4%"
+ });
+ OrionShoulder.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(OrionShoulder);
+
+ var HyperionV1 = new Augmentation({
+ name:AugmentationNames.HyperionV1, repCost: 4e3, moneyCost:500e6,
+ info:"A pair of mini plasma cannons embedded into the hands. The Hyperion is capable " +
+ "of rapidly firing bolts of high-density plasma. The weapon is meant to " +
+ "be used against augmented enemies as the ionized " +
+ "nature of the plasma disrupts the electrical systems of Augmentations. However, " +
+ "it can also be effective against non-augmented enemies due to its high temperature " +
+ "and concussive force.
" +
+ "This augmentation: " +
+ "Increases the player's success chance in Bladeburner contracts/operations by 5%"
+ });
+ HyperionV1.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(HyperionV1);
+
+ var HyperionV2 = new Augmentation({
+ name:AugmentationNames.HyperionV2, repCost:8e3, moneyCost:1e9,
+ info:"A pair of mini plasma cannons embedded into the hands. This augmentation " +
+ "is more advanced and powerful than the original V1 model. This V2 model is " +
+ "more power-efficiency, more accurate, and can fire plasma bolts at a much " +
+ "higher velocity than the V1 model.
" +
+ "This augmentation: " +
+ "Increases the player's success chance in Bladeburner contracts/operations by 7%",
+ prereqs:[AugmentationNames.HyperionV1]
+ });
+ HyperionV2.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(HyperionV2);
+
+ var GolemSerum = new Augmentation({
+ name:AugmentationNames.GolemSerum, repCost:10e3, moneyCost:2e9,
+ info:"A serum that permanently enhances many aspects of a human's capabilities, " +
+ "including strength, speed, immune system performance, and mitochondrial efficiency. The " +
+ "serum was originally developed by the Chinese military in an attempt to " +
+ "create super soldiers.
" +
+ "This augmentation: " +
+ "Increases all of the player's combat stats by 5% " +
+ "Increases the player's Bladeburner stamina gain rate by 5% "
+ });
+ GolemSerum.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(GolemSerum);
+
+ var VangelisVirus = new Augmentation({
+ name:AugmentationNames.VangelisVirus, repCost:6e3, moneyCost:500e6,
+ info:"A synthetic symbiotic virus that is injected into the human brain tissue. The Vangelis virus " +
+ "heightens the senses and focus of its host, and also enhances its intuition.
" +
+ "This augmentation: " +
+ "Increases the player's effectiveness in Bladeburner Field Analysis by 10% " +
+ "Increases the player's success chance in Bladeburner contracts/operations by 4% " +
+ "Increases the player's dexterity experience gain rate by 5%"
+ });
+ VangelisVirus.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(VangelisVirus);
+
+ var VangelisVirus3 = new Augmentation({
+ name:AugmentationNames.VangelisVirus3, repCost:12e3, moneyCost:2e9,
+ info:"An improved version of Vangelis, a synthetic symbiotic virus that is " +
+ "injected into the human brain tissue. On top of the benefits of the original " +
+ "virus, this also grants an accelerated healing factor and enhanced " +
+ "agility/reflexes.
" +
+ "This augmentation: " +
+ "Increases the player's effectiveness in Bladeburner Field Analysis by 15% " +
+ "Increases the player's defense and dexterity experience gain rate by 5% " +
+ "Increases the player's success chance in Bladeburner contracts/operations by 5%",
+ prereqs:[AugmentationNames.VangelisVirus]
+ });
+ VangelisVirus3.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(VangelisVirus3);
+
+ var INTERLINKED = new Augmentation({
+ name:AugmentationNames.INTERLINKED, repCost:8e3, moneyCost:1e9,
+ info:"The DNA is genetically modified to enhance the human's body " +
+ "extracellular matrix (ECM). This improves the ECM's ability to " +
+ "structurally support the body and grants heightened strength and " +
+ "durability.
" +
+ "This augmentation: " +
+ "Increases the player's experience gain rate for all combat stats by 4% " +
+ "Increases the player's Bladeburner max stamina by 10%"
+ });
+ INTERLINKED.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(INTERLINKED);
+
+ var BladeRunner = new Augmentation({
+ name:AugmentationNames.BladeRunner, repCost:8e3, moneyCost:1.5e9,
+ info:"A cybernetic foot augmentation that was specially created for Bladeburners " +
+ "during the Synthoid Uprising. The organic musculature of the human foot " +
+ "is enhanced with flexible carbon nanotube matrices that are controlled by " +
+ "intelligent servo-motors.
" +
+ "This augmentation: " +
+ "Increases the player's agility by 5% " +
+ "Increases the player's Bladeburner max stamina by 5% " +
+ "Increases the player's Bladeburner stamina gain rate by 5% "
+ });
+ BladeRunner.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(BladeRunner);
+
+ var BladeArmor = new Augmentation({
+ name:AugmentationNames.BladeArmor, repCost:4e3, moneyCost:250e6,
+ info:"A powered exoskeleton suit (exosuit) designed as armor for Bladeburner units. This " +
+ "exoskeleton is incredibly adaptable and can protect the wearer from blunt, piercing, " +
+ "concussive, thermal, chemical, and electric trauma. It also enhances the user's " +
+ "strength and agility.
" +
+ "This augmentation: " +
+ "Increases all of the player's combat stats by 2% " +
+ "Increases the player's Bladeburner stamina gain rate by 2% " +
+ "Increases the player's success chance in Bladeburner contracts/operations by 3%",
+ });
+ BladeArmor.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(BladeArmor);
+
+ var BladeArmorPowerCells = new Augmentation({
+ name:AugmentationNames.BladeArmorPowerCells, repCost:6e3, moneyCost:500e6,
+ info:"Upgrades the BLADE-51b Tesla Armor with Ion Power Cells, which are capable of " +
+ "more efficiently storing and using power.
" +
+ "This augmentation: " +
+ "Increases the player's success chance in Bladeburner contracts/operations by 5%" +
+ "Increases the player's Bladeburner stamina gain rate by 2% " +
+ "Increases the player's Bladeburner max stamina by 5% ",
+ prereqs:[AugmentationNames.BladeArmor]
+ });
+ BladeArmorPowerCells.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(BladeArmorPowerCells);
+
+ var BladeArmorEnergyShielding = new Augmentation({
+ name:AugmentationNames.BladeArmorEnergyShielding, repCost:7e3, moneyCost:1e9,
+ info:"Upgrades the BLADE-51b Tesla Armor with a plasma energy propulsion system " +
+ "that is capable of projecting an energy shielding force field.
" +
+ "This augmentation: " +
+ "Increases the player's defense by 5% " +
+ "Increases the player's success chance in Bladeburner contracts/operations by 6%",
+ prereqs:[AugmentationNames.BladeArmor]
+ });
+ BladeArmorEnergyShielding.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(BladeArmorEnergyShielding);
+
+ var BladeArmorUnibeam = new Augmentation({
+ name:AugmentationNames.BladeArmorUnibeam, repCost:10e3, moneyCost:3e9,
+ info:"Upgrades the BLADE-51b Tesla Armor with a concentrated deuterium-fluoride laser " +
+ "weapon. It's precision an accuracy makes it useful for quickly neutralizing " +
+ "threats while keeping casualties to a minimum.
" +
+ "This augmentation: " +
+ "Increases the player's success chance in Bladeburner contracts/operations by 8%",
+ prereqs:[AugmentationNames.BladeArmor]
+ });
+ BladeArmorUnibeam.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(BladeArmorUnibeam);
+
+ var BladeArmorOmnibeam = new Augmentation({
+ name:AugmentationNames.BladeArmorOmnibeam, repCost:20e3, moneyCost:5e9,
+ info:"Upgrades the BLADE-51b Tesla Armor Unibeam augmentation to use " +
+ "multiple-fiber system. The upgraded weapon uses multiple fiber laser " +
+ "modules that combine together to form a single, more powerful beam of up to " +
+ "2000MW.
" +
+ "This augmentation: " +
+ "Increases the player's success chance in Bladeburner contracts/operations by 10%",
+ prereqs:[AugmentationNames.BladeArmorUnibeam]
+ });
+ BladeArmorOmnibeam.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(BladeArmorOmnibeam);
+
+ var BladeArmorIPU = new Augmentation({
+ name:AugmentationNames.BladeArmorIPU, repCost: 5e3, moneyCost:200e6,
+ info:"Upgrades the BLADE-51b Tesla Armor with an AI Information Processing " +
+ "Unit that was specially designed to analyze Synthoid related data and " +
+ "information.
" +
+ "This augmentation: " +
+ "Increases the player's effectiveness in Bladeburner Field Analysis by 15% " +
+ "Increases the player's success chance in Bladeburner contracts/operations by 2%",
+ prereqs:[AugmentationNames.BladeArmor]
+ });
+ BladeArmorIPU.addToFactions([BladeburnersFactionName]);
+ resetAugmentation(BladeArmorIPU);
+ }
+
+ //Update costs based on how many have been purchased
+ var mult = Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultipleAugMultiplier, _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].queuedAugmentations.length);
+ for (var name in Augmentations) {
+ if (Augmentations.hasOwnProperty(name)) {
+ Augmentations[name].baseCost *= mult;
+ }
+ }
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].reapplyAllAugmentations();
+
+
+}
+
+//Resets an Augmentation during (re-initizliation)
+function resetAugmentation(newAugObject) {
+ if (!(newAugObject instanceof Augmentation)) {
+ throw new Error("Invalid argument 'newAugObject' passed into resetAugmentation");
+ }
+ var name = newAugObject.name;
+ if (augmentationExists(name)) {
+ delete Augmentations[name];
+ }
+ AddToAugmentations(newAugObject);
+}
+
+function applyAugmentation(aug, reapply=false) {
+ Augmentations[aug.name].owned = true;
+ switch(aug.name) {
+ //Combat stat augmentations
+ case AugmentationNames.Targeting1:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.10;
+ break;
+ case AugmentationNames.Targeting2:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.20;
+ break;
+ case AugmentationNames.Targeting3:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.30;
+ break;
+ case AugmentationNames.SyntheticHeart: //High level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.5;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.5;
+ break;
+ case AugmentationNames.SynfibrilMuscle: //Medium-high level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.3;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.3;
+ break;
+ case AugmentationNames.CombatRib1:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.1;
+ break;
+ case AugmentationNames.CombatRib2:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.14;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.14;
+ break;
+ case AugmentationNames.CombatRib3:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.18;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.18;
+ break;
+ case AugmentationNames.NanofiberWeave: //Med level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.2;
+ break;
+ case AugmentationNames.SubdermalArmor: //High level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 2.2;
+ break;
+ case AugmentationNames.WiredReflexes: //Low level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.05;
+ break;
+ case AugmentationNames.GrapheneBoneLacings: //High level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.7;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.7;
+ break;
+ case AugmentationNames.BionicSpine: //Med level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.15;
+ break;
+ case AugmentationNames.GrapheneBionicSpine: //High level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.6;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.6;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.6;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.6;
+ break;
+ case AugmentationNames.BionicLegs: //Med level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.6;
+ break;
+ case AugmentationNames.GrapheneBionicLegs: //High level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 2.5;
+ break;
+
+ //Labor stats augmentations
+ case AugmentationNames.EnhancedSocialInteractionImplant: //Med-high level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_mult *= 1.6;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_exp_mult *= 1.6;
+ break;
+ case AugmentationNames.TITN41Injection:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_exp_mult *= 1.15;
+ break;
+ case AugmentationNames.SpeechProcessor: //Med level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_mult *= 1.2;
+ break;
+
+ //Hacking augmentations
+ case AugmentationNames.BitWire:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.05;
+ break;
+ case AugmentationNames.ArtificialBioNeuralNetwork: //Med level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.03;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_money_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.12;
+ break;
+ case AugmentationNames.ArtificialSynapticPotentiation: //Med level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.02;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_chance_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.05;
+ break;
+ case AugmentationNames.EnhancedMyelinSheathing: //Med level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.03;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.08;
+ break;
+ case AugmentationNames.SynapticEnhancement: //Low Level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.03;
+ break;
+ case AugmentationNames.NeuralRetentionEnhancement: //Med level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.25;
+ break;
+ case AugmentationNames.DataJack: //Med low level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_money_mult *= 1.25;
+ break;
+ case AugmentationNames.ENM: //Medium level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.08;
+ break;
+ case AugmentationNames.ENMCore: //Medium level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.03;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_money_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_chance_mult *= 1.03;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.07;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.07;
+ break;
+ case AugmentationNames.ENMCoreV2: //Medium high level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_money_mult *= 1.3;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_chance_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.08;
+ break;
+ case AugmentationNames.ENMCoreV3: //High level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_money_mult *= 1.4;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_chance_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.25;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.1;
+ break;
+ case AugmentationNames.ENMAnalyzeEngine: //High level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.1;
+ break;
+ case AugmentationNames.ENMDMA: //High level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_money_mult *= 1.4;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_chance_mult *= 1.2;
+ break;
+ case AugmentationNames.Neuralstimulator: //Medium Level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.02;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_chance_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.12;
+ break;
+ case AugmentationNames.NeuralAccelerator:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_money_mult *= 1.2;
+ break;
+ case AugmentationNames.CranialSignalProcessorsG1:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.05;
+ break;
+ case AugmentationNames.CranialSignalProcessorsG2:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.02;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_chance_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.07;
+ break;
+ case AugmentationNames.CranialSignalProcessorsG3:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.02;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_money_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.09;
+ break;
+ case AugmentationNames.CranialSignalProcessorsG4:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.02;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_money_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_grow_mult *= 1.25;
+ break;
+ case AugmentationNames.CranialSignalProcessorsG5:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.3;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_money_mult *= 1.25;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_grow_mult *= 1.75;
+ break;
+ case AugmentationNames.NeuronalDensification:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.03;
+ break;
+
+ //Work augmentations
+ case AugmentationNames.NuoptimalInjectorImplant: //Low medium level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].company_rep_mult *= 1.2;
+ break;
+ case AugmentationNames.SpeechEnhancement: //Low level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].company_rep_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_mult *= 1.1;
+ break;
+ case AugmentationNames.FocusWire: //Med level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_exp_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_exp_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_exp_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].company_rep_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].work_money_mult *= 1.2;
+ break;
+ case AugmentationNames.PCDNI: //Med level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].company_rep_mult *= 1.3;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.08;
+ break;
+ case AugmentationNames.PCDNIOptimizer: //High level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].company_rep_mult *= 1.75;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.1;
+ break;
+ case AugmentationNames.PCDNINeuralNetwork: //High level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].company_rep_mult *= 2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.05;
+ break;
+ case AugmentationNames.ADRPheromone1:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].company_rep_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].faction_rep_mult *= 1.1;
+ break;
+ case AugmentationNames.ADRPheromone2:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].company_rep_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].faction_rep_mult *= 1.2;
+ break;
+
+ //Hacknet Node Augmentations
+ case AugmentationNames.HacknetNodeCPUUpload:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacknet_node_money_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacknet_node_purchase_cost_mult *= 0.85;
+ break;
+ case AugmentationNames.HacknetNodeCacheUpload:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacknet_node_money_mult *= 1.10;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacknet_node_level_cost_mult *= 0.85;
+ break;
+ case AugmentationNames.HacknetNodeNICUpload:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacknet_node_money_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacknet_node_purchase_cost_mult *= 0.9;
+ break;
+ case AugmentationNames.HacknetNodeKernelDNI:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacknet_node_money_mult *= 1.25;
+ break;
+ case AugmentationNames.HacknetNodeCoreDNI:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacknet_node_money_mult *= 1.45;
+ break;
+
+ //Misc augmentations
+ case AugmentationNames.NeuroFluxGovernor:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_chance_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_money_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_grow_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.01;
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_mult *= 1.01;
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_exp_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_exp_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_exp_mult *= 1.01;
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].company_rep_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].faction_rep_mult *= 1.01;
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].crime_money_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].crime_success_mult *= 1.01;
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacknet_node_money_mult *= 1.01;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacknet_node_purchase_cost_mult *= 0.99;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacknet_node_ram_cost_mult *= 0.99;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacknet_node_core_cost_mult *= 0.99;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacknet_node_level_cost_mult *= 0.99;
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].work_money_mult *= 1.01;
+
+ if (!reapply) {
+ Augmentations[aug.name].level = aug.level;
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].augmentations.length; ++i) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].augmentations[i].name == AugmentationNames.NeuroFluxGovernor) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].augmentations[i].level = aug.level;
+ break;
+ }
+ }
+ }
+ break;
+ case AugmentationNames.Neurotrainer1: //Low Level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_exp_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_exp_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_exp_mult *= 1.1;
+ break;
+ case AugmentationNames.Neurotrainer2: //Medium level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_exp_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_exp_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_exp_mult *= 1.15;
+ break;
+ case AugmentationNames.Neurotrainer3: //High Level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_exp_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_exp_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_exp_mult *= 1.2;
+ break;
+ case AugmentationNames.Hypersight: //Medium high level
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.4;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.03;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_money_mult *= 1.1;
+ break;
+ case AugmentationNames.LuminCloaking1:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].crime_money_mult *= 1.1;
+ break;
+ case AugmentationNames.LuminCloaking2:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].crime_money_mult *= 1.25;
+ break;
+ case AugmentationNames.HemoRecirculator:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.08;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.08;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.08;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.08;
+ break;
+ case AugmentationNames.SmartSonar:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].crime_money_mult *= 1.25;
+ break;
+ case AugmentationNames.PowerRecirculator:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_exp_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_exp_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_exp_mult *= 1.1;
+ break;
+ //Unique augmentations (for factions)
+ case AugmentationNames.QLink:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_chance_mult *= 1.3;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_money_mult *= 2;
+ break;
+ case AugmentationNames.TheRedPill:
+ break;
+ case AugmentationNames.SPTN97:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.75;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.75;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.75;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.75;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.15;
+ break;
+ case AugmentationNames.HiveMind:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_grow_mult *= 3;
+ break;
+ case AugmentationNames.CordiARCReactor:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.35;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.35;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.35;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.35;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_exp_mult *= 1.35;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult *= 1.35;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult *= 1.35;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_exp_mult *= 1.35;
+ break;
+ case AugmentationNames.SmartJaw:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_mult *= 1.5;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_exp_mult *= 1.5;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].company_rep_mult *= 1.25;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].faction_rep_mult *= 1.25;
+ break;
+ case AugmentationNames.Neotra:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.55;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.55;
+ break;
+ case AugmentationNames.Xanipher:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_exp_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_exp_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_exp_mult *= 1.15;
+ break;
+ case AugmentationNames.nextSENS:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].charisma_mult *= 1.2;
+ break;
+ case AugmentationNames.OmniTekInfoLoad:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.25;
+ break;
+ case AugmentationNames.PhotosyntheticCells:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.4;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.4;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.4;
+ break;
+ case AugmentationNames.Neurolink:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_chance_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.05;
+ break;
+ case AugmentationNames.TheBlackHand:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_speed_mult *= 1.02;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_money_mult *= 1.1;
+ break;
+ case AugmentationNames.CRTX42AA:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_mult *= 1.08;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.15;
+ break;
+ case AugmentationNames.Neuregen:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].hacking_exp_mult *= 1.4;
+ break;
+ case AugmentationNames.CashRoot:
+ break;
+ case AugmentationNames.NutriGen:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_exp_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult *= 1.2;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_exp_mult *= 1.2;
+ break;
+ case AugmentationNames.INFRARet:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].crime_success_mult *= 1.25;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].crime_money_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.1;
+ break;
+ case AugmentationNames.DermaForce:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.4;
+ break;
+ case AugmentationNames.GrapheneBrachiBlades:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.4;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.4;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].crime_success_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].crime_money_mult *= 1.3;
+ break;
+ case AugmentationNames.GrapheneBionicArms:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.85;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.85;
+ break;
+ case AugmentationNames.BrachiBlades:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].crime_success_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].crime_money_mult *= 1.15;
+ break;
+ case AugmentationNames.BionicArms:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.3;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.3;
+ break;
+ case AugmentationNames.SNA:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].work_money_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].company_rep_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].faction_rep_mult *= 1.15;
+ break;
+
+ //Bladeburner augmentations
+ case AugmentationNames.EsperEyewear:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult *= 1.03;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.03;
+ break;
+ case AugmentationNames.EMS4Recombination:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult *= 1.03;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_analysis_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_stamina_gain_mult *= 1.01;
+ break;
+ case AugmentationNames.OrionShoulder:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.03;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.03;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult *= 1.04;
+ break;
+ case AugmentationNames.HyperionV1:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult *= 1.05;
+ break;
+ case AugmentationNames.HyperionV2:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult *= 1.07;
+ break;
+ case AugmentationNames.GolemSerum:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_stamina_gain_mult *= 1.05;
+ break;
+ case AugmentationNames.VangelisVirus:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_analysis_mult *= 1.1;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult *= 1.04;
+ break;
+ case AugmentationNames.VangelisVirus3:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_analysis_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult *= 1.05;
+ break;
+ case AugmentationNames.INTERLINKED:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_exp_mult *= 1.04;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_exp_mult *= 1.04;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_exp_mult *= 1.04;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_exp_mult *= 1.04;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_max_stamina_mult *= 1.1;
+ break;
+ case AugmentationNames.BladeRunner:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_max_stamina_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_stamina_gain_mult *= 1.05;
+ break;
+ case AugmentationNames.BladeArmor:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].strength_mult *= 1.02;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.02;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].dexterity_mult *= 1.02;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].agility_mult *= 1.02;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_stamina_gain_mult *= 1.02;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult *= 1.03;
+ break;
+ case AugmentationNames.BladeArmorPowerCells:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_stamina_gain_mult *= 1.02;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_max_stamina_mult *= 1.05;
+ break;
+ case AugmentationNames.BladeArmorEnergyShielding:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].defense_mult *= 1.05;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult *= 1.06;
+ break;
+ case AugmentationNames.BladeArmorUnibeam:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult *= 1.08;
+ break;
+ case AugmentationNames.BladeArmorOmnibeam:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult *= 1.1;
+ break;
+ case AugmentationNames.BladeArmorIPU:
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_analysis_mult *= 1.15;
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bladeburner_success_chance_mult *= 1.02;
+ break;
+ default:
+ throw new Error("ERROR: No such augmentation!");
+ return;
+ }
+
+ if (aug.name == AugmentationNames.NeuroFluxGovernor) {
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].augmentations.length; ++i) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].augmentations[i].name == AugmentationNames.NeuroFluxGovernor) {
+ //Already have this aug, just upgrade the level
+ return;
+ }
+ }
+ }
+
+ if (!reapply) {
+ var ownedAug = new PlayerOwnedAugmentation(aug.name);
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].augmentations.push(ownedAug);
+ }
+}
+
+function PlayerOwnedAugmentation(name) {
+ this.name = name;
+ this.level = 1;
+}
+
+function installAugmentations(cbScript=null) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].queuedAugmentations.length == 0) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_12__["dialogBoxCreate"])("You have not purchased any Augmentations to install!");
+ return false;
+ }
+ var augmentationList = "";
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].queuedAugmentations.length; ++i) {
+ var aug = Augmentations[_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].queuedAugmentations[i].name];
+ if (aug == null) {
+ console.log("ERROR. Invalid augmentation");
+ continue;
+ }
+ applyAugmentation(_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].queuedAugmentations[i]);
+ augmentationList += (aug.name + " ");
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].queuedAugmentations = [];
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_12__["dialogBoxCreate"])("You slowly drift to sleep as scientists put you under in order " +
+ "to install the following Augmentations: " + augmentationList +
+ " You wake up in your home...you feel different...");
+ Object(_Prestige_js__WEBPACK_IMPORTED_MODULE_7__["prestigeAugmentation"])();
+
+ //Run a script after prestiging
+ if (cbScript && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_15__["isString"])(cbScript)) {
+ var home = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].getHomeComputer();
+ for (var i = 0; i < home.scripts.length; ++i) {
+ if (home.scripts[i].filename === cbScript) {
+ var script = home.scripts[i];
+ var ramUsage = script.ramUsage;
+ var ramAvailable = home.maxRam - home.ramUsed;
+ if (ramUsage > ramAvailable) {
+ return; //Not enough RAM
+ }
+ var runningScriptObj = new _Script_js__WEBPACK_IMPORTED_MODULE_9__["RunningScript"](script, []); //No args
+ runningScriptObj.threads = 1; //Only 1 thread
+ home.runningScripts.push(runningScriptObj);
+ Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_5__["addWorkerScript"])(runningScriptObj, home);
+ }
+ }
+ }
+}
+
+function augmentationExists(name) {
+ return Augmentations.hasOwnProperty(name);
+}
+
+//Used for testing balance
+function giveAllAugmentations() {
+ for (var name in Augmentations) {
+ var aug = Augmentations[name];
+ if (aug == null) {continue;}
+ var ownedAug = new PlayerOwnedAugmentation(name);
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].augmentations.push(ownedAug);
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].reapplyAllAugmentations();
+}
+
+function displayAugmentationsContent() {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["removeChildrenFromElement"])(_engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Display.augmentationsContent);
+ _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Display.augmentationsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createElement"])("h1", {
+ innerText:"Purchased Augmentations",
+ }));
+
+ //Bladeburner text, once mechanic is unlocked
+ var bladeburnerText = "\n";
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].bitNodeN === 6 || _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_4__["hasBladeburnerSF"]) {
+ bladeburnerText = "Bladeburner Progress\n\n";
+ }
+
+ _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Display.augmentationsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createElement"])("pre", {
+ width:"70%", whiteSpace:"pre-wrap", display:"block",
+ innerText:"Below is a list of all Augmentations you have purchased but not yet installed. Click the button below to install them.\n" +
+ "WARNING: Installing your Augmentations resets most of your progress, including:\n\n" +
+ "Stats/Skill levels and Experience\n" +
+ "Money\n" +
+ "Scripts on every computer but your home computer\n" +
+ "Purchased servers\n" +
+ "Hacknet Nodes\n" +
+ "Faction/Company reputation\n" +
+ "Stocks\n" +
+ bladeburnerText +
+ "Installing Augmentations lets you start over with the perks and benefits granted by all " +
+ "of the Augmentations you have ever installed. Also, you will keep any scripts and RAM/Core upgrades " +
+ "on your home computer (but you will lose all programs besides NUKE.exe)."
+ }));
+
+ //Install Augmentations button
+ _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Display.augmentationsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createElement"])("a", {
+ class:"a-link-button", innerText:"Install Augmentations",
+ tooltip:"'I never asked for this'",
+ clickListener:()=>{
+ installAugmentations();
+ return false;
+ }
+ }));
+
+ //Backup button
+ _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Display.augmentationsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createElement"])("a", {
+ class:"a-link-button flashing-button", innerText:"Backup Save (Export)",
+ tooltip:"It's always a good idea to backup/export your save!",
+ clickListener:()=>{
+ _SaveObject_js__WEBPACK_IMPORTED_MODULE_8__["saveObject"].exportGame();
+ return false;
+ }
+ }));
+
+ //Purchased/queued augmentations list
+ var queuedAugmentationsList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createElement"])("ul", {class:"augmentations-list"});
+
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].queuedAugmentations.length; ++i) {
+ var augName = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].queuedAugmentations[i].name;
+ var aug = Augmentations[augName];
+
+ var displayName = augName;
+ if (augName === AugmentationNames.NeuroFluxGovernor) {
+ displayName += " - Level " + (_Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].queuedAugmentations[i].level);
+ }
+
+ var accordion = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createAccordionElement"])({hdrText:displayName, panelText:aug.info});
+ queuedAugmentationsList.appendChild(accordion[0]);
+ }
+ _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Display.augmentationsContent.appendChild(queuedAugmentationsList);
+
+ //Installed augmentations list
+ _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Display.augmentationsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createElement"])("h1", {
+ innerText:"Installed Augmentations", marginTop:"8px",
+ }));
+ _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Display.augmentationsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createElement"])("p", {
+ width:"70%", whiteSpace:"pre-wrap",
+ innerText:"List of all Augmentations (including Source Files) that have been " +
+ "installed. You have gained the effects of these Augmentations."
+ }));
+
+ var augmentationsList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createElement"])("ul", {class:"augmentations-list"});
+
+ //Expand/Collapse All buttons
+ _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Display.augmentationsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createElement"])("a", {
+ class:"a-link-button", fontSize:"14px", innerText:"Expand All", display:"inline-block",
+ clickListener:()=>{
+ var allHeaders = augmentationsList.getElementsByClassName("accordion-header");
+ for (var i = 0; i < allHeaders.length; ++i) {
+ if (!allHeaders[i].classList.contains("active")) {allHeaders[i].click();}
+ }
+ }
+ }));
+ _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Display.augmentationsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createElement"])("a", {
+ class:"a-link-button", fontSize:"14px", innerText:"Collapse All", display:"inline-block",
+ clickListener:()=>{
+ var allHeaders = augmentationsList.getElementsByClassName("accordion-header");
+ for (var i = 0; i < allHeaders.length; ++i) {
+ if (allHeaders[i].classList.contains("active")) {allHeaders[i].click();}
+ }
+ }
+ }));
+
+ //Sort Buttons
+ _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Display.augmentationsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createElement"])("a", {
+ class:"a-link-button", fontSize:"14px", innerText:"Sort in Order",
+ tooltip:"Sorts the Augmentations alphabetically and Source Files in numerical order (1, 2, 3,...)",
+ clickListener:()=>{
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["removeChildrenFromElement"])(augmentationsList);
+
+ //Create a copy of Player's Source Files and augs array and sort them
+ var sourceFiles = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].sourceFiles.slice();
+ var augs = _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].augmentations.slice();
+ sourceFiles.sort((sf1, sf2)=>{
+ return sf1.n - sf2.n;
+ });
+ augs.sort((aug1, aug2)=>{
+ return aug1.name <= aug2.name ? -1 : 1;
+ });
+ displaySourceFiles(augmentationsList, sourceFiles);
+ displayAugmentations(augmentationsList, augs);
+ }
+ }));
+
+ _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Display.augmentationsContent.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createElement"])("a", {
+ class:"a-link-button", fontSize:"14px", innerText:"Sort by Acquirement Time",
+ tooltip:"Sorts the Augmentations and Source Files based on when you acquired them (same as default)",
+ clickListener:()=>{
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["removeChildrenFromElement"])(augmentationsList);
+ displaySourceFiles(augmentationsList, _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].sourceFiles);
+ displayAugmentations(augmentationsList, _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].augmentations);
+ }
+ }));
+
+ //Source Files - Temporary...Will probably put in a separate pane Later
+ displaySourceFiles(augmentationsList, _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].sourceFiles);
+ displayAugmentations(augmentationsList, _Player_js__WEBPACK_IMPORTED_MODULE_6__["Player"].augmentations);
+ _engine_js__WEBPACK_IMPORTED_MODULE_2__["Engine"].Display.augmentationsContent.appendChild(augmentationsList);
+}
+
+//Creates the accordion elements to display Augmentations
+// @listElement - List DOM element to append accordion elements to
+// @augs - Array of Augmentation objects
+function displayAugmentations(listElement, augs) {
+ for (var i = 0; i < augs.length; ++i) {
+ var augName = augs[i].name;
+ var aug = Augmentations[augName];
+
+ var displayName = augName;
+ if (augName === AugmentationNames.NeuroFluxGovernor) {
+ displayName += " - Level " + (augs[i].level);
+ }
+ var accordion = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createAccordionElement"])({hdrText:displayName, panelText:aug.info});
+ listElement.appendChild(accordion[0]);
+ }
+}
+
+//Creates the accordion elements to display Source Files
+// @listElement - List DOM element to append accordion elements to
+// @sourceFiles - Array of Source File objects
+function displaySourceFiles(listElement, sourceFiles) {
+ for (var i = 0; i < sourceFiles.length; ++i) {
+ var srcFileKey = "SourceFile" + sourceFiles[i].n;
+ var sourceFileObject = _SourceFile_js__WEBPACK_IMPORTED_MODULE_11__["SourceFiles"][srcFileKey];
+ if (sourceFileObject == null) {
+ console.log("ERROR: Invalid source file number: " + sourceFiles[i].n);
+ continue;
+ }
+ var accordion = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_13__["createAccordionElement"])({
+ hdrText:sourceFileObject.name + " " + "Level " + (sourceFiles[i].lvl) + " / 3",
+ panelText:sourceFileObject.info
+ });
+
+ listElement.appendChild(accordion[0]);
+ }
+}
+
+
+
+
+
+/***/ }),
+/* 19 */
+/*!***********************!*\
+ !*** ./src/Crimes.js ***!
+ \***********************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitShopliftCrime", function() { return commitShopliftCrime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitRobStoreCrime", function() { return commitRobStoreCrime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitMugCrime", function() { return commitMugCrime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitLarcenyCrime", function() { return commitLarcenyCrime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitDealDrugsCrime", function() { return commitDealDrugsCrime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitBondForgeryCrime", function() { return commitBondForgeryCrime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitTraffickArmsCrime", function() { return commitTraffickArmsCrime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitHomicideCrime", function() { return commitHomicideCrime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitGrandTheftAutoCrime", function() { return commitGrandTheftAutoCrime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitKidnapCrime", function() { return commitKidnapCrime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitAssassinationCrime", function() { return commitAssassinationCrime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "commitHeistCrime", function() { return commitHeistCrime; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeSuccess", function() { return determineCrimeSuccess; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceShoplift", function() { return determineCrimeChanceShoplift; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceRobStore", function() { return determineCrimeChanceRobStore; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceMug", function() { return determineCrimeChanceMug; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceLarceny", function() { return determineCrimeChanceLarceny; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceDealDrugs", function() { return determineCrimeChanceDealDrugs; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceBondForgery", function() { return determineCrimeChanceBondForgery; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceTraffickArms", function() { return determineCrimeChanceTraffickArms; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceHomicide", function() { return determineCrimeChanceHomicide; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceGrandTheftAuto", function() { return determineCrimeChanceGrandTheftAuto; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceKidnap", function() { return determineCrimeChanceKidnap; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceAssassination", function() { return determineCrimeChanceAssassination; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "determineCrimeChanceHeist", function() { return determineCrimeChanceHeist; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+
+
+
+
+/* Crimes.js */
+function commitShopliftCrime(div=1, singParams=null) {
+ if (div <= 0) {div = 1;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeShoplift;
+ var time = 2000;
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 0, 0, 2/div, 2/div, 0, 15000/div, time, singParams); //$7500/s, 1 exp/s
+ return time;
+}
+
+function commitRobStoreCrime(div=1, singParams=null) {
+ if (div <= 0) {div = 1;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeRobStore;
+ var time = 60000;
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(30/div, 0, 0, 45/div, 45/div, 0, 400000/div, time, singParams); //$6666,6/2, 0.5exp/s, 0.75exp/s
+ return time;
+}
+
+function commitMugCrime(div=1, singParams=null) {
+ if (div <= 0) {div = 1;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeMug;
+ var time = 4000;
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 3/div, 3/div, 3/div, 3/div, 0, 36000/div, time, singParams); //$9000/s, .66 exp/s
+ return time;
+}
+
+function commitLarcenyCrime(div=1, singParams=null) {
+ if (div <= 0) {div = 1;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeLarceny;
+ var time = 90000;
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(45/div, 0, 0, 60/div, 60/div, 0, 800000/div, time, singParams) // $8888.88/s, .5 exp/s, .66 exp/s
+ return time;
+}
+
+function commitDealDrugsCrime(div=1, singParams=null) {
+ if (div <= 0) {div = 1;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeDrugs;
+ var time = 10000;
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 0, 0, 5/div, 5/div, 10/div, 120000/div, time, singParams); //$12000/s, .5 exp/s, 1 exp/s
+ return time;
+}
+
+function commitBondForgeryCrime(div=1, singParams=null) {
+ if (div <= 0) {div = 1;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeBondForgery;
+ var time = 300000;
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(100/div, 0, 0, 150/div, 0, 15/div, 4500000/div, time, singParams); //$15000/s, 0.33 hack exp/s, .5 dex exp/s, .05 cha exp
+ return time;
+}
+
+function commitTraffickArmsCrime(div=1, singParams=null) {
+ if (div <= 0) {div = 1;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeTraffickArms;
+ var time = 40000;
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 20/div, 20/div, 20/div, 20/div, 40/div, 600000/div, time, singParams); //$15000/s, .5 combat exp/s, 1 cha exp/s
+ return time;
+}
+
+function commitHomicideCrime(div=1, singParams=null) {
+ if (div <= 0) {div = 1;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeHomicide;
+ var time = 3000;
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 2/div, 2/div, 2/div, 2/div, 0, 45000/div, time, singParams); //$15000/s, 0.66 combat exp/s
+ return time;
+}
+
+function commitGrandTheftAutoCrime(div=1, singParams=null) {
+ if (div <= 0) {div = 1;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeGrandTheftAuto;
+ var time = 80000;
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 20/div, 20/div, 20/div, 80/div, 40/div, 1600000/div, time, singParams); //$20000/s, .25 exp/s, 1 exp/s, .5 exp/s
+ return time;
+}
+
+function commitKidnapCrime(div=1, singParams=null) {
+ if (div <= 0) {div = 1;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeKidnap;
+ var time = 120000;
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 80/div, 80/div, 80/div, 80/div, 80/div, 3600000/div, time, singParams); //$30000/s. .66 exp/s
+ return time;
+}
+
+function commitAssassinationCrime(div=1, singParams=null) {
+ if (div <= 0) {div = 1;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeAssassination;
+ var time = 300000;
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(0, 300/div, 300/div, 300/div, 300/div, 0, 12000000/div, time, singParams); //$40000/s, 1 exp/s
+ return time;
+}
+
+function commitHeistCrime(div=1, singParams=null) {
+ if (div <= 0) {div = 1;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crimeType = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeHeist;
+ var time = 600000;
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].startCrime(450/div, 450/div, 450/div, 450/div, 450/div, 450/div, 120000000/div, time, singParams); //$200000/s, .75exp/s
+ return time;
+}
+
+function determineCrimeSuccess(crime, moneyGained) {
+ var chance = 0;
+ switch (crime) {
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeShoplift:
+ chance = determineCrimeChanceShoplift();
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeRobStore:
+ chance = determineCrimeChanceRobStore();
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeMug:
+ chance = determineCrimeChanceMug();
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeLarceny:
+ chance = determineCrimeChanceLarceny();
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeDrugs:
+ chance = determineCrimeChanceDealDrugs();
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeBondForgery:
+ chance = determineCrimeChanceBondForgery();
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeTraffickArms:
+ chance = determineCrimeChanceTraffickArms();
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeHomicide:
+ chance = determineCrimeChanceHomicide();
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeGrandTheftAuto:
+ chance = determineCrimeChanceGrandTheftAuto();
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeKidnap:
+ chance = determineCrimeChanceKidnap();
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeAssassination:
+ chance = determineCrimeChanceAssassination();
+ break;
+ case _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].CrimeHeist:
+ chance = determineCrimeChanceHeist();
+ break;
+ default:
+ console.log(crime);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__["dialogBoxCreate"])("ERR: Unrecognized crime type. This is probably a bug please contact the developer");
+ return;
+ }
+
+ if (Math.random() <= chance) {
+ //Success
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].gainMoney(moneyGained);
+ return true;
+ } else {
+ //Failure
+ return false;
+ }
+}
+
+let intWgt = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceCrimeWeight;
+let maxLvl = _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].MaxSkillLevel;
+
+function determineCrimeChanceShoplift() {
+ var chance = (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
+ intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) * 20;
+ chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
+ return Math.min(chance, 1);
+}
+
+function determineCrimeChanceRobStore() {
+ var chance = (0.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill / maxLvl +
+ 2 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
+ 1 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
+ intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) * 5;
+ chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
+ return Math.min(chance, 1);
+}
+
+function determineCrimeChanceMug() {
+ var chance = (1.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength / maxLvl +
+ 0.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].defense / maxLvl +
+ 1.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
+ 0.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
+ intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) * 5;
+ chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
+ return Math.min(chance, 1);
+}
+
+function determineCrimeChanceLarceny() {
+ var chance = (0.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
+ intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) * 3;
+ chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
+ return Math.min(chance, 1);
+}
+
+function determineCrimeChanceDealDrugs() {
+ var chance = (3*_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].charisma / maxLvl +
+ 2*_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
+ intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl);
+ chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
+ return Math.min(chance, 1);
+}
+
+function determineCrimeChanceBondForgery() {
+ var chance = (0.1*_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill / maxLvl +
+ 2.5*_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
+ 2*intWgt*_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl);
+ chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
+ return Math.min(chance, 1);
+}
+
+function determineCrimeChanceTraffickArms() {
+ var chance = (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].charisma / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].defense / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
+ intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) / 2;
+ chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
+ return Math.min(chance, 1);
+}
+
+function determineCrimeChanceHomicide() {
+ var chance = (2 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength / maxLvl +
+ 2 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].defense / maxLvl +
+ 0.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
+ 0.5 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
+ intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl);
+ chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
+ return Math.min(chance, 1);
+}
+
+function determineCrimeChanceGrandTheftAuto() {
+ var chance = (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength / maxLvl +
+ 4 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
+ 2 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
+ 2 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].charisma / maxLvl +
+ intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) / 8;
+ chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
+ return Math.min(chance, 1);
+}
+
+function determineCrimeChanceKidnap() {
+ var chance = (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].charisma / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
+ intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) / 5;
+ chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
+ return Math.min(chance, 1);
+}
+
+function determineCrimeChanceAssassination() {
+ var chance = (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength / maxLvl +
+ 2 * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
+ intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) / 8;
+ chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
+ return Math.min(chance, 1);
+}
+
+function determineCrimeChanceHeist() {
+ var chance = (_Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].hacking_skill / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].strength / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].defense / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].dexterity / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].agility / maxLvl +
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].charisma / maxLvl +
+ intWgt * _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].intelligence / maxLvl) / 18;
+ chance *= _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].crime_success_mult;
+ return Math.min(chance, 1);
+}
+
+
+
+
+/***/ }),
+/* 20 */
+/*!****************************!*\
+ !*** ./src/StockMarket.js ***!
+ \****************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StockMarket", function() { return StockMarket; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "StockSymbols", function() { return StockSymbols; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "SymbolToStockMap", function() { return SymbolToStockMap; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initStockSymbols", function() { return initStockSymbols; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initStockMarket", function() { return initStockMarket; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSymbolToStockMap", function() { return initSymbolToStockMap; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "stockMarketCycle", function() { return stockMarketCycle; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "buyStock", function() { return buyStock; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sellStock", function() { return sellStock; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "shortStock", function() { return shortStock; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "sellShort", function() { return sellShort; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockPrices", function() { return updateStockPrices; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayStockMarketContent", function() { return displayStockMarketContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockTicker", function() { return updateStockTicker; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateStockPlayerPosition", function() { return updateStockPlayerPosition; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadStockMarket", function() { return loadStockMarket; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setStockMarketContentCreated", function() { return setStockMarketContentCreated; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "placeOrder", function() { return placeOrder; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "cancelOrder", function() { return cancelOrder; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Order", function() { return Order; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "OrderTypes", function() { return OrderTypes; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "PositionTypes", function() { return PositionTypes; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Location.js */ 4);
+/* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 30);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
+/* harmony import */ var _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/numeral.min.js */ 12);
+/* harmony import */ var _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_9___default = /*#__PURE__*/__webpack_require__.n(_utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_9__);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 11);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* StockMarket.js */
+function Stock(name, symbol, mv, b, otlkMag, initPrice=10000) {
+ this.symbol = symbol;
+ this.name = name;
+ 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.posTxtEl = null;
+}
+
+Stock.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_toJSON"])("Stock", this);
+}
+
+Stock.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_fromJSON"])(Stock, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"].constructors.Stock = Stock;
+
+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_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
+ 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_js__WEBPACK_IMPORTED_MODULE_6__["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)) {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_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
+ if (StockMarket["Orders"] == null) {return false;}
+ if (params.order && params.order instanceof Order) {
+ var order = params.order;
+ //An 'Order' object is passed in
+ var stockOrders = StockMarket["Orders"][order.stock.symbol];
+ for (var i = 0; i < stockOrders.length; ++i) {
+ if (order == stockOrders[i]) {
+ stockOrders.splice(i, 1);
+ updateStockOrderList(order.stock);
+ return true;
+ }
+ }
+ return false;
+ } else if (params.stock && params.shares && params.price && params.type &&
+ params.pos && params.stock instanceof Stock) {
+ //Order properties are passed in. Need to look for the order
+ var stockOrders = StockMarket["Orders"][params.stock.symbol];
+ var orderTxt = params.stock.symbol + " - " + params.shares + " @ " +
+ _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_9___default()(params.price).format('$0.000a');
+ for (var i = 0; i < stockOrders.length; ++i) {
+ var order = stockOrders[i];
+ if (params.shares === order.shares &&
+ params.price === order.price &&
+ params.type === order.type &&
+ params.pos === order.pos) {
+ stockOrders.splice(i, 1);
+ updateStockOrderList(order.stock);
+ if (tixApi) {
+ workerScript.scriptRef.log("Successfully cancelled order: " + orderTxt);
+ }
+ return true;
+ }
+ }
+ if (tixApi) {
+ workerScript.scriptRef.log("Failed to cancel order: " + orderTxt);
+ }
+ return false;
+ }
+ return false;
+}
+
+function executeOrder(order) {
+ var stock = order.stock;
+ var orderBook = StockMarket["Orders"];
+ var stockOrders = orderBook[stock.symbol];
+ var res = true;
+ console.log("Executing the following order:");
+ console.log(order);
+ switch (order.type) {
+ case OrderTypes.LimitBuy:
+ case OrderTypes.StopBuy:
+ if (order.pos === PositionTypes.Long) {
+ res = buyStock(order.stock, order.shares) && res;
+ } else if (order.pos === PositionTypes.Short) {
+ res = shortStock(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_js__WEBPACK_IMPORTED_MODULE_8__["Generic_toJSON"])("Order", this);
+}
+
+Order.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["Generic_fromJSON"])(Order, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["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_js__WEBPACK_IMPORTED_MODULE_8__["Reviver"]);
+ }
+}
+
+function initStockSymbols() {
+ //Stocks for companies at which you can work
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumECorp] = "ECP";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12MegaCorp] = "MGCP";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12BladeIndustries] = "BLD";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumClarkeIncorporated] = "CLRK";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniTekIncorporated] = "OMTK";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FourSigma] = "FSIG";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingKuaiGongInternational] = "KGI";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumFulcrumTechnologies] = "FLCM";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaStormTechnologies] = "STM";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoDefComm] = "DCOMM";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenHeliosLabs] = "HLS";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoVitaLife] = "VITA";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12IcarusMicrosystems] = "ICRS";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12UniversalEnergy] = "UNV";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumAeroCorp] = "AERO";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniaCybersystems] = "OMN";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingSolarisSpaceSystems] = "SLRS";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoGlobalPharmaceuticals] = "GPH";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaNovaMedical] = "NVMD";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumWatchdogSecurity] = "WDS";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenLexoCorp] = "LXO";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumRhoConstruction] = "RHOC";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12AlphaEnterprises] = "APHE";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenSysCoreSecurities] = "SYSC";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenCompuTek] = "CTK";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumNetLinkTechnologies] = "NTLK";
+ StockSymbols[_Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaOmegaSoftware] = "OMGA";
+ StockSymbols[_Location_js__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];
+ }
+ }
+
+ var ecorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumECorp;
+ var ecorpStk = new Stock(ecorp, StockSymbols[ecorp], 0.45, true, 19, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
+ StockMarket[ecorp] = ecorpStk;
+
+ var megacorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12MegaCorp;
+ var megacorpStk = new Stock(megacorp, StockSymbols[megacorp], 0.45, true, 19, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(25000, 33000));
+ StockMarket[megacorp] = megacorpStk;
+
+ var blade = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12BladeIndustries;
+ var bladeStk = new Stock(blade, StockSymbols[blade], 0.75, true, 13, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 22000));
+ StockMarket[blade] = bladeStk;
+
+ var clarke = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumClarkeIncorporated;
+ var clarkeStk = new Stock(clarke, StockSymbols[clarke], 0.7, true, 12, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 20000));
+ StockMarket[clarke] = clarkeStk;
+
+ var omnitek = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniTekIncorporated;
+ var omnitekStk = new Stock(omnitek, StockSymbols[omnitek], 0.65, true, 12, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(35000, 40000));
+ StockMarket[omnitek] = omnitekStk;
+
+ var foursigma = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FourSigma;
+ var foursigmaStk = new Stock(foursigma, StockSymbols[foursigma], 1.05, true, 17, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(60000, 70000));
+ StockMarket[foursigma] = foursigmaStk;
+
+ var kuaigong = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingKuaiGongInternational;
+ var kuaigongStk = new Stock(kuaigong, StockSymbols[kuaigong], 0.8, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 24000));
+ StockMarket[kuaigong] = kuaigongStk;
+
+ var fulcrum = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumFulcrumTechnologies;
+ var fulcrumStk = new Stock(fulcrum, StockSymbols[fulcrum], 1.25, true, 16, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(30000, 35000));
+ StockMarket[fulcrum] = fulcrumStk;
+
+ var storm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaStormTechnologies;
+ var stormStk = new Stock(storm, StockSymbols[storm], 0.85, true, 7, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(21000, 24000));
+ StockMarket[storm] = stormStk;
+
+ var defcomm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoDefComm;
+ var defcommStk = new Stock(defcomm, StockSymbols[defcomm], 0.65, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 15000));
+ StockMarket[defcomm] = defcommStk;
+
+ var helios = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenHeliosLabs;
+ var heliosStk = new Stock(helios, StockSymbols[helios], 0.6, true, 9, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(12000, 16000));
+ StockMarket[helios] = heliosStk;
+
+ var vitalife = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoVitaLife;
+ var vitalifeStk = new Stock(vitalife, StockSymbols[vitalife], 0.75, true, 7, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 12000));
+ StockMarket[vitalife] = vitalifeStk;
+
+ var icarus = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12IcarusMicrosystems;
+ var icarusStk = new Stock(icarus, StockSymbols[icarus], 0.65, true, 7.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(16000, 20000));
+ StockMarket[icarus] = icarusStk;
+
+ var universalenergy = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12UniversalEnergy;
+ var universalenergyStk = new Stock(universalenergy, StockSymbols[universalenergy], 0.55, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
+ StockMarket[universalenergy] = universalenergyStk;
+
+ var aerocorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumAeroCorp;
+ var aerocorpStk = new Stock(aerocorp, StockSymbols[aerocorp], 0.6, true, 6, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(10000, 15000));
+ StockMarket[aerocorp] = aerocorpStk;
+
+ var omnia = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenOmniaCybersystems;
+ var omniaStk = new Stock(omnia, StockSymbols[omnia], 0.7, true, 4.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(9000, 12000));
+ StockMarket[omnia] = omniaStk;
+
+ var solaris = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].ChongqingSolarisSpaceSystems;
+ var solarisStk = new Stock(solaris, StockSymbols[solaris], 0.75, true, 8.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
+ StockMarket[solaris] = solarisStk;
+
+ var globalpharm = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].NewTokyoGlobalPharmaceuticals;
+ var globalpharmStk = new Stock(globalpharm, StockSymbols[globalpharm], 0.6, true, 10.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
+ StockMarket[globalpharm] = globalpharmStk;
+
+ var nova = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaNovaMedical;
+ var novaStk = new Stock(nova, StockSymbols[nova], 0.75, true, 5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(18000, 24000));
+ StockMarket[nova] = novaStk;
+
+ var watchdog = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumWatchdogSecurity;
+ var watchdogStk = new Stock(watchdog, StockSymbols[watchdog], 2.5, true, 1.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
+ StockMarket[watchdog] = watchdogStk;
+
+ var lexocorp = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenLexoCorp;
+ var lexocorpStk = new Stock(lexocorp, StockSymbols[lexocorp], 1.25, true, 6, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
+ StockMarket[lexocorp] = lexocorpStk;
+
+ var rho = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumRhoConstruction;
+ var rhoStk = new Stock(rho, StockSymbols[rho], 0.6, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(3000, 6000));
+ StockMarket[rho] = rhoStk;
+
+ var alpha = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12AlphaEnterprises;
+ var alphaStk = new Stock(alpha, StockSymbols[alpha], 1.9, true, 10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(5000, 7500));
+ StockMarket[alpha] = alphaStk;
+
+ var syscore = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenSysCoreSecurities;
+ var syscoreStk = new Stock(syscore, StockSymbols[syscore], 1.6, true, 3, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(4000, 7000))
+ StockMarket[syscore] = syscoreStk;
+
+ var computek = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].VolhavenCompuTek;
+ var computekStk = new Stock(computek, StockSymbols[computek], 0.9, true, 4, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 5000));
+ StockMarket[computek] = computekStk;
+
+ var netlink = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].AevumNetLinkTechnologies;
+ var netlinkStk = new Stock(netlink, StockSymbols[netlink], 4.2, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 4000));
+ StockMarket[netlink] = netlinkStk;
+
+ var omega = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].IshimaOmegaSoftware;
+ var omegaStk = new Stock(omega, StockSymbols[omega], 1, true, 0.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(3000, 6000));
+ StockMarket[omega] = omegaStk;
+
+ var fns = _Location_js__WEBPACK_IMPORTED_MODULE_2__["Locations"].Sector12FoodNStuff;
+ var fnsStk = new Stock(fns, StockSymbols[fns], 0.75, false, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(1000, 4000));
+ StockMarket[fns] = fnsStk;
+
+ var sigmacosm = "Sigma Cosmetics";
+ var sigmacosmStk = new Stock(sigmacosm, StockSymbols[sigmacosm], 2.8, true, 0, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(2000, 3000));
+ StockMarket[sigmacosm] = sigmacosmStk;
+
+ var joesguns = "Joes Guns";
+ var joesgunsStk = new Stock(joesguns, StockSymbols[joesguns], 3.8, true, 1, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(500, 1000));
+ StockMarket[joesguns] = joesgunsStk;
+
+ var catalyst = "Catalyst Ventures";
+ var catalystStk = new Stock(catalyst, StockSymbols[catalyst], 1.45, true, 13.5, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(500, 1000));
+ StockMarket[catalyst] = catalystStk;
+
+ var microdyne = "Microdyne Technologies";
+ var microdyneStk = new Stock(microdyne, StockSymbols[microdyne], 0.75, true, 8, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(20000, 25000));
+ StockMarket[microdyne] = microdyneStk;
+
+ var titanlabs = "Titan Laboratories";
+ var titanlabsStk = new Stock(titanlabs, StockSymbols[titanlabs], 0.6, true, 11, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["getRandomInt"])(15000, 20000));
+ StockMarket[titanlabs] = titanlabsStk;
+
+ var orders = {};
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;}
+ orders[stock.symbol] = [];
+ }
+ }
+ StockMarket["Orders"] = orders;
+}
+
+function initSymbolToStockMap() {
+ for (var name in StockSymbols) {
+ if (StockSymbols.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (stock == null) {
+ console.log("ERROR finding stock");
+ continue;
+ }
+ var symbol = StockSymbols[name];
+ SymbolToStockMap[symbol] = stock;
+ }
+ }
+}
+
+function stockMarketCycle() {
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ 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) {
+ if (stock == null || shares < 0 || isNaN(shares)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Failed to buy stock. This may be a bug, contact developer");
+ return false;
+ }
+ shares = Math.round(shares);
+ if (shares == 0) {return false;}
+
+ var totalPrice = stock.price * shares;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.lt(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("You do not have enough money to purchase this. You need $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2).toString() + ".");
+ return false;
+ }
+
+ var origTotal = stock.playerShares * stock.playerAvgPx;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission);
+ var newTotal = origTotal + totalPrice;
+ stock.playerShares += shares;
+ stock.playerAvgPx = newTotal / stock.playerShares;
+ updateStockPlayerPosition(stock);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Bought " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. You also paid $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " 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_js__WEBPACK_IMPORTED_MODULE_6__["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_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].gainMoney(gains);
+ stock.playerShares -= shares;
+ if (stock.playerShares == 0) {
+ stock.playerAvgPx = 0;
+ }
+ updateStockPlayerPosition(stock);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Sold " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. After commissions, you gained " +
+ "a total of $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(gains, 2));
+ return true;
+}
+
+//Returns true if successful and false otherwise
+function shortStock(stock, shares, workerScript=null) {
+ var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
+ if (stock == null || isNaN(shares) || shares < 0) {
+ if (tixApi) {
+ workerScript.scriptRef.log("ERROR: shortStock() failed because of invalid arguments.");
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["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;
+ }
+ shares = Math.round(shares);
+ if (shares === 0) {return false;}
+
+ var totalPrice = stock.price * shares;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.lt(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission)) {
+ if (tixApi) {
+ workerScript.scriptRef.log("ERROR: shortStock() failed because you do not have " +
+ "money to purchase this short position. You need " +
+ _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_9___default()(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission).format('($0.000a)'));
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("You do not have enough money to purchase this short position. You need $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + ".");
+ }
+
+ return false;
+ }
+
+ var origTotal = stock.playerShortShares * stock.playerAvgShortPx;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission);
+ var newTotal = origTotal + totalPrice;
+ 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 " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at " +
+ _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_9___default()(stock.price).format('($0.000a)') + " per share. Paid " +
+ _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_9___default()(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission).format('($0.000a)') + " in commission fees.");
+ }
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Bought a short position of " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. You also paid $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " in commission fees.");
+ }
+ return true;
+}
+
+//Returns true if successful and false otherwise
+function sellShort(stock, shares, workerScript=null) {
+ var tixApi = (workerScript instanceof _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_4__["WorkerScript"]);
+ if (stock == null || isNaN(shares) || shares < 0) {
+ if (tixApi) {
+ workerScript.scriptRef.log("ERROR: sellShort() failed because of invalid arguments.");
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["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_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
+ if (isNaN(profit)) {profit = 0;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].gainMoney(origCost + profit);
+ if (tixApi) {
+ workerScript.scriptRef.onlineMoneyMade += profit;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].scriptProdSinceLastAug += profit;
+ }
+
+ 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 " + shares + " shares of " + stock.symbol + " at " +
+ _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_9___default()(stock.price).format('($0.000a)') + " per share. After commissions, you gained " +
+ "a total of " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_9___default()(origCost + profit).format('($0.000a)'));
+ }
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])("Sold your short position of " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2) + " per share. After commissions, you gained " +
+ "a total of $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(origCost + profit, 2));
+ }
+
+ return true;
+}
+
+function updateStockPrices() {
+ var v = Math.random();
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof 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;}
+ }
+
+ var c = Math.random();
+ if (c < chc) {
+ stock.price *= (1 + av);
+ processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Short);
+ processOrders(stock, OrderTypes.LimitSell, PositionTypes.Long);
+ processOrders(stock, OrderTypes.StopBuy, PositionTypes.Long);
+ processOrders(stock, OrderTypes.StopSell, PositionTypes.Short);
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {
+ updateStockTicker(stock, true);
+ }
+ } else {
+ stock.price /= (1 + av);
+ processOrders(stock, OrderTypes.LimitBuy, PositionTypes.Long);
+ processOrders(stock, OrderTypes.LimitSell, PositionTypes.Short);
+ processOrders(stock, OrderTypes.StopBuy, PositionTypes.Short);
+ processOrders(stock, OrderTypes.StopSell, PositionTypes.Long);
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].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)) {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_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission;
+function displayStockMarketContent() {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount == null) {_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount = false;}
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess == null) {_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess = false;}
+
+ //Purchase WSE Account button
+ var wseAccountButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-buy-account");
+ wseAccountButton.innerText = "Buy WSE Account - $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost, 2).toString();
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.gte(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost)) {
+ wseAccountButton.setAttribute("class", "a-link-button");
+ } else {
+ wseAccountButton.setAttribute("class", "a-link-button-inactive");
+ }
+ wseAccountButton.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount = true;
+ initStockMarket();
+ initSymbolToStockMap();
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].WSEAccountCost);
+ displayStockMarketContent();
+ return false;
+ });
+
+ //Purchase TIX API Access account
+ var tixApiAccessButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-buy-tix-api");
+ tixApiAccessButton.innerText = "Buy Trade Information eXchange (TIX) API Access - $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost, 2).toString();
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.gte(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost)) {
+ tixApiAccessButton.setAttribute("class", "a-link-button");
+ } else {
+ tixApiAccessButton.setAttribute("class", "a-link-button-inactive");
+ }
+ tixApiAccessButton.addEventListener("click", function() {
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasTixApiAccess = true;
+ _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].TIXAPICost);
+ displayStockMarketContent();
+ return false;
+ });
+
+ var stockList = document.getElementById("stock-market-list");
+ if (stockList == null) {return;}
+
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
+ stockMarketContentCreated = false;
+ while (stockList.firstChild) {
+ stockList.removeChild(stockList.firstChild);
+ }
+ return;
+ }
+
+ //Create stock market content if you have an account
+ if (!stockMarketContentCreated && _Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
+ console.log("Creating Stock Market UI");
+ document.getElementById("stock-market-commission").innerHTML =
+ "Commission Fees: Every transaction you make has a $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].StockMarketCommission, 2) + " commission fee.
" +
+ "WARNING: When you reset after installing Augmentations, the Stock Market is reset. " +
+ "This means all your positions are lost, so make sure to sell your stocks before installing " +
+ "Augmentations!";
+
+ var investopediaButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["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_js__WEBPACK_IMPORTED_MODULE_6__["dialogBoxCreate"])(txt);
+ return false;
+ });
+
+ //Switch to Portfolio Mode Button
+ var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["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);
+ }
+
+ //Expand/Collapse tickers buttons
+ var expandBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-expand-tickers"),
+ collapseBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-collapse-tickers"),
+ 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();
+ }
+ }
+ });
+ }
+
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;} //orders property is an array
+ createStockTicker(stock);
+ }
+ }
+ setStockTickerClickHandlers(); //Clicking headers opens/closes panels
+ stockMarketContentCreated = true;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].hasWseAccount) {
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ updateStockTicker(stock, null);
+ updateStockOrderList(stock);
+ }
+ }
+ }
+}
+
+//Displays only stocks you have position/order in
+function switchToPortfolioMode() {
+ stockMarketPortfolioMode = true;
+ var stockList = document.getElementById("stock-market-list");
+ if (stockList == null) {return;}
+ var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["clearEventListeners"])("stock-market-mode");
+ if (modeBtn) {
+ modeBtn.innerHTML = "Switch to 'All stocks' Mode" +
+ "Displays all stocks on the WSE";
+ modeBtn.addEventListener("click", switchToDisplayAllMode);
+ }
+ while(stockList.firstChild) {stockList.removeChild(stockList.firstChild);}
+
+ //Get Order book (create it if it hasn't been created)
+ var orderBook = StockMarket["Orders"];
+ if (orderBook == null) {
+ var orders = {};
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;}
+ orders[stock.symbol] = [];
+ }
+ }
+ StockMarket["Orders"] = orders;
+ }
+
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;} //orders property is an array
+ var stockOrders = orderBook[stock.symbol];
+ if (stock.playerShares === 0 && stock.playerShortShares === 0 &&
+ stockOrders.length === 0) {continue;}
+ createStockTicker(stock);
+ }
+ }
+ setStockTickerClickHandlers();
+}
+
+//Displays all stocks
+function switchToDisplayAllMode() {
+ stockMarketPortfolioMode = false;
+ var stockList = document.getElementById("stock-market-list");
+ if (stockList == null) {return;}
+ var modeBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["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);
+ }
+ while(stockList.firstChild) {stockList.removeChild(stockList.firstChild);}
+ for (var name in StockMarket) {
+ if (StockMarket.hasOwnProperty(name)) {
+ var stock = StockMarket[name];
+ if (!(stock instanceof Stock)) {continue;} //orders property is an array
+ createStockTicker(stock);
+ }
+ }
+ setStockTickerClickHandlers();
+}
+
+function createStockTicker(stock) {
+ if (!(stock instanceof 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 + " - $" + stock.price;
+
+ //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_js__WEBPACK_IMPORTED_MODULE_5__["Player"].bitNodeN === 8 || (_NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__["hasWallStreetSF"] && _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__["wallStreetSFLvl"] >= 2)) {
+ var shortOpt = document.createElement("option");
+ shortOpt.text = "Short";
+ longShortSelect.add(shortOpt);
+ }
+
+ orderTypeSelect.classList.add("stock-market-input");
+ orderTypeSelect.setAttribute("id", tickerId + "-order-selector");
+ var marketOpt = document.createElement("option");
+ marketOpt.text = "Market Order";
+ orderTypeSelect.add(marketOpt);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_5__["Player"].bitNodeN === 8 || (_NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__["hasWallStreetSF"] && _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_3__["wallStreetSFLvl"] >= 3)) {
+ var limitOpt = document.createElement("option");
+ limitOpt.text = "Limit Order";
+ orderTypeSelect.add(limitOpt);
+ var stopOpt = document.createElement("option");
+ stopOpt.text = "Stop Order";
+ orderTypeSelect.add(stopOpt);
+ }
+
+ 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_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxGetYesButton"])(),
+ noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxGetNoButton"])();
+ yesBtn.innerText = "Place Buy " + ordType;
+ noBtn.innerText = "Cancel Order";
+ yesBtn.addEventListener("click", ()=>{
+ var price = Number(Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxGetInput"])()), type;
+ if (ordType === "Limit Order") {
+ type = OrderTypes.LimitBuy;
+ } else {
+ type = OrderTypes.StopBuy;
+ }
+ placeOrder(stock, shares, price, type, pos);
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxClose"])();
+ });
+ noBtn.addEventListener("click", ()=>{
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxClose"])();
+ });
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["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_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxGetYesButton"])(),
+ noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxGetNoButton"])();
+ yesBtn.innerText = "Place Sell " + ordType;
+ noBtn.innerText = "Cancel Order";
+ yesBtn.addEventListener("click", ()=>{
+ var price = Number(Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxGetInput"])()), type;
+ if (ordType === "Limit Order") {
+ type = OrderTypes.LimitSell;
+ } else {
+ type = OrderTypes.StopSell;
+ }
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxClose"])();
+ placeOrder(stock, shares, price, type, pos);
+ });
+ noBtn.addEventListener("click", ()=>{
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxClose"])();
+ });
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["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_js__WEBPACK_IMPORTED_MODULE_5__["Player"].money.toNumber();
+ switch (ordType) {
+ case "Market Order":
+ var shares = Math.floor((money - COMM) / stock.price);
+ pos === PositionTypes.Long ? buyStock(stock, shares) : shortStock(stock, shares, null);
+ break;
+ case "Limit Order":
+ case "Stop Order":
+ var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxGetYesButton"])(),
+ noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxGetNoButton"])();
+ yesBtn.innerText = "Place Buy " + ordType;
+ noBtn.innerText = "Cancel Order";
+ yesBtn.addEventListener("click", ()=>{
+ var price = Number(Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxGetInput"])()), type;
+ if (ordType === "Limit Order") {
+ type = OrderTypes.LimitBuy;
+ } else {
+ type = OrderTypes.StopBuy;
+ }
+ var shares = Math.floor((money-COMM) / price);
+ placeOrder(stock, shares, price, type, pos);
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxClose"])();
+ });
+ noBtn.addEventListener("click", ()=>{
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["yesNoTxtInpBoxClose"])();
+ });
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_11__["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_js__WEBPACK_IMPORTED_MODULE_6__["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 (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {return;}
+ if (!(stock instanceof 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) {console.log("ERROR: Couldn't find ticker element for stock: " + stock.symbol);}
+ return;
+ }
+ hdr.innerHTML = stock.name + " - " + stock.symbol + " - $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(stock.price, 2);
+ if (increase != null) {
+ increase ? hdr.style.color = "#66ff33" : hdr.style.color = "red";
+ }
+}
+
+function updateStockPlayerPosition(stock) {
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {return;}
+ if (!(stock instanceof 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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["removeElementById"])(tickerId + "-hdr");
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["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
+ var totalCost = stock.playerShares * stock.playerAvgPx,
+ gains = (stock.price - stock.playerAvgPx) * stock.playerShares,
+ percentageGains = gains / totalCost;
+ if (isNaN(percentageGains)) {percentageGains = 0;}
+
+ var shortTotalCost = stock.playerShortShares * stock.playerAvgShortPx,
+ shortGains = (stock.playerAvgShortPx - stock.price) * stock.playerShortShares,
+ shortPercentageGains = shortGains/ shortTotalCost;
+ if (isNaN(shortPercentageGains)) {shortPercentageGains = 0;}
+
+ stock.posTxtEl.innerHTML =
+ "
Long Position: " +
+ "Shares in the long position will increase " +
+ "in value if the price of the corresponding stock increases
";
+ }
+
+}
+
+function updateStockOrderList(stock) {
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage !== _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.StockMarket) {return;}
+ var tickerId = "stock-market-ticker-" + stock.symbol;
+ var orderList = document.getElementById(tickerId + "-order-list");
+ if (orderList == null) {
+ if (!stockMarketPortfolioMode) {console.log("ERROR: Could not find order list for " + stock.symbol);}
+ return;
+ }
+
+ var orderBook = StockMarket["Orders"];
+ if (orderBook == null) {
+ console.log("ERROR: Could not find order book in stock market");
+ return;
+ }
+ var stockOrders = orderBook[stock.symbol];
+ if (stockOrders == null) {
+ console.log("ERROR: Could not find orders for: " + stock.symbol);
+ return;
+ }
+
+ if (stockMarketPortfolioMode) {
+ if (stock.playerShares === 0 && stock.playerShortShares === 0 &&
+ StockMarket["Orders"] && StockMarket["Orders"][stock.symbol] &&
+ StockMarket["Orders"][stock.symbol].length === 0) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["removeElementById"])(tickerId + "-hdr");
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_7__["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;
+ }
+ }
+ }
+
+ //Remove everything from list
+ while (orderList.firstChild) {
+ orderList.removeChild(orderList.firstChild);
+ }
+
+ for (var i = 0; i < stockOrders.length; ++i) {
+ (function() {
+ var order = stockOrders[i];
+ var li = document.createElement("li");
+ li.style.padding = "4px";
+ var posText = (order.pos === PositionTypes.Long ? "Long Position" : "Short Position");
+ li.style.color = "white";
+ li.innerText = order.type + " - " + posText + " - " +
+ order.shares + " @ $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["formatNumber"])(order.price, 2);
+
+ var cancelButton = document.createElement("span");
+ cancelButton.classList.add("stock-market-order-cancel-btn");
+ cancelButton.classList.add("a-link-button");
+ cancelButton.innerHTML = "Cancel Order";
+ cancelButton.addEventListener("click", function() {
+ cancelOrder({order: order}, null);
+ return false;
+ });
+ li.appendChild(cancelButton);
+ orderList.appendChild(li);
+ }());
+
+ }
+}
+
+
+
+
+/***/ }),
+/* 21 */
+/*!********************************!*\
+ !*** ./src/NetscriptWorker.js ***!
+ \********************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "WorkerScript", function() { return WorkerScript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "workerScripts", function() { return workerScripts; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NetscriptPorts", function() { return NetscriptPorts; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "runScriptsLoop", function() { return runScriptsLoop; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "killWorkerScript", function() { return killWorkerScript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "addWorkerScript", function() { return addWorkerScript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateOnlineScriptTimes", function() { return updateOnlineScriptTimes; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "prestigeWorkerScripts", function() { return prestigeWorkerScripts; });
+/* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ActiveScriptsUI.js */ 42);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 65);
+/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 7);
+/* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptPort.js */ 43);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./Server.js */ 10);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Settings.js */ 24);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/acorn.js */ 36);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_8___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+
+
+
+
+
+
+
+
+
+
+
+
+
+function WorkerScript(runningScriptObj) {
+ this.name = runningScriptObj.filename;
+ this.running = false;
+ this.serverIp = null;
+ this.code = runningScriptObj.scriptRef.code;
+ this.env = new _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_3__["Environment"](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
+ this.disableLogs = {}; //Stores names of fns that should have logs disabled
+}
+
+//Returns the server on which the workerScript is running
+WorkerScript.prototype.getServer = function() {
+ return _Server_js__WEBPACK_IMPORTED_MODULE_6__["AllServers"][this.serverIp];
+}
+
+//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_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].NumNetscriptPorts; ++i) {
+ NetscriptPorts.push(new _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_5__["NetscriptPort"]());
+}
+
+function prestigeWorkerScripts() {
+ for (var i = 0; i < workerScripts.length; ++i) {
+ Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["deleteActiveScriptsItem"])(workerScripts[i]);
+ workerScripts[i].env.stopFlag = true;
+ }
+ workerScripts.length = 0;
+}
+
+//Loop through workerScripts and run every script that is not currently running
+function runScriptsLoop() {
+ //Delete any scripts that finished or have been killed. Loop backwards bc removing
+ //items fucks up the indexing
+ for (var i = workerScripts.length - 1; i >= 0; i--) {
+ if (workerScripts[i].running == false && workerScripts[i].env.stopFlag == true) {
+ //Delete script from the runningScripts array on its host serverIp
+ var ip = workerScripts[i].serverIp;
+ var name = workerScripts[i].name;
+
+ //Free RAM
+ _Server_js__WEBPACK_IMPORTED_MODULE_6__["AllServers"][ip].ramUsed -= workerScripts[i].ramUsage;
+
+ //Delete script from Active Scripts
+ Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["deleteActiveScriptsItem"])(workerScripts[i]);
+
+ for (var j = 0; j < _Server_js__WEBPACK_IMPORTED_MODULE_6__["AllServers"][ip].runningScripts.length; j++) {
+ if (_Server_js__WEBPACK_IMPORTED_MODULE_6__["AllServers"][ip].runningScripts[j].filename == name &&
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["compareArrays"])(_Server_js__WEBPACK_IMPORTED_MODULE_6__["AllServers"][ip].runningScripts[j].args, workerScripts[i].args)) {
+ _Server_js__WEBPACK_IMPORTED_MODULE_6__["AllServers"][ip].runningScripts.splice(j, 1);
+ break;
+ }
+ }
+
+ //Delete script from workerScripts
+ workerScripts.splice(i, 1);
+ }
+ }
+
+ //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) {
+ try {
+ var ast = Object(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_8__["parse"])(workerScripts[i].code, {sourceType:"module"});
+ //console.log(ast);
+ } catch (e) {
+ console.log("Error parsing script: " + workerScripts[i].name);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Syntax ERROR in " + workerScripts[i].name + ": " + e);
+ workerScripts[i].env.stopFlag = true;
+ continue;
+ }
+
+ workerScripts[i].running = true;
+ var p = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["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_js__WEBPACK_IMPORTED_MODULE_9__["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_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(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_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Script runtime error: Server Ip: " + serverIp +
+ " Script name: " + scriptName +
+ " Args:" + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["printArray"])(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_js__WEBPACK_IMPORTED_MODULE_4__["isScriptErrorMessage"])(w)) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["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_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("An unknown script died for an unknown reason. This is a bug please contact game dev");
+ }
+ });
+ }
+ }
+
+ 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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["compareArrays"])(workerScripts[i].args, runningScriptObj.args)) {
+ workerScripts[i].env.stopFlag = true;
+ Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["killNetscriptDelay"])(workerScripts[i]);
+ //Recursively kill all functions
+ var curr = workerScripts[i];
+ while (curr.fnWorker) {
+ curr.fnWorker.env.stopFlag = true;
+ Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__["killNetscriptDelay"])(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 = runningScriptObj.scriptRef.ramUsage * threads
+ * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, threads-1);
+ var ramAvailable = server.maxRam - server.ramUsed;
+ if (ramUsage > ramAvailable) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_9__["dialogBoxCreate"])("Not enough RAM to run script " + runningScriptObj.filename + " with args " +
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_10__["printArray"])(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 += 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_js__WEBPACK_IMPORTED_MODULE_0__["addActiveScriptsItem"])(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_js__WEBPACK_IMPORTED_MODULE_2__["Engine"]._idleSpeed) / 1000; //seconds
+ for (var i = 0; i < workerScripts.length; ++i) {
+ workerScripts[i].scriptRef.onlineRunningTime += time;
+ }
+}
+
+
+
+
+/***/ }),
+/* 22 */
+/*!*************************!*\
+ !*** ./src/Terminal.js ***!
+ \*************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "postNetburnerText", function() { return postNetburnerText; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "post", function() { return post; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Terminal", function() { return Terminal; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "KEY", function() { return KEY; });
+/* harmony import */ var _Alias_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Alias.js */ 28);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./CreateProgram.js */ 13);
+/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./DarkWeb.js */ 33);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Fconf.js */ 34);
+/* harmony import */ var _HelpText_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./HelpText.js */ 68);
+/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 25);
+/* harmony import */ var _Literature_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Literature.js */ 53);
+/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Message.js */ 27);
+/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 7);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _RedPill_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./RedPill.js */ 49);
+/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Script.js */ 29);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Server.js */ 10);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Settings.js */ 24);
+/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17);
+/* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./TextFile.js */ 39);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ../utils/LogBox.js */ 50);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 11);
+/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! jszip */ 111);
+/* harmony import */ var jszip__WEBPACK_IMPORTED_MODULE_23___default = /*#__PURE__*/__webpack_require__.n(jszip__WEBPACK_IMPORTED_MODULE_23__);
+/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! file-saver */ 110);
+/* harmony import */ var file_saver__WEBPACK_IMPORTED_MODULE_24___default = /*#__PURE__*/__webpack_require__.n(file_saver__WEBPACK_IMPORTED_MODULE_24__);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+/* Write text to terminal */
+//If replace is true then spaces are replaced with " "
+function post(input) {
+ $("#terminal-input").before('
' + input + '
');
+ updateTerminalScroll();
+}
+
+//Same thing as post but the td cells have ids so they can be animated for the hack progress bar
+function hackProgressBarPost(input) {
+ $("#terminal-input").before('
" +
+ '';
+ var hdr = document.getElementById("terminal-input-header");
+ hdr.style.display = "inline";
+ },
+
+ modifyInput: function(mod) {
+ try {
+ var terminalInput = document.getElementById("terminal-input-text-box");
+ if (terminalInput == null) {return;}
+ terminalInput.focus();
+
+ var inputLength = terminalInput.value.length;
+ var start = terminalInput.selectionStart;
+ var end = terminalInput.selectionEnd;
+ var inputText = terminalInput.value;
+
+ switch(mod.toLowerCase()) {
+ case "backspace":
+ if (start > 0 && start <= inputLength+1) {
+ terminalInput.value = inputText.substr(0, start-1) + inputText.substr(start);
+ }
+ break;
+ case "deletewordbefore": //Delete rest of word before the cursor
+ for (var delStart = start-1; delStart > 0; --delStart) {
+ if (inputText.charAt(delStart) === " ") {
+ terminalInput.value = inputText.substr(0, delStart) + inputText.substr(start);
+ return;
+ }
+ }
+ break;
+ case "deletewordafter": //Delete rest of word after the cursor
+ for (var delStart = start+1; delStart <= text.length+1; ++delStart) {
+ if (inputText.charAt(delStart) === " ") {
+ terminalInput.value = inputText.substr(0, start) + inputText.substr(delStart);
+ return;
+ }
+ }
+ break;
+ case "clearafter": //Deletes everything after cursor
+ break;
+ case "clearbefore:": //Deleetes everything before cursor
+ break;
+ }
+ } catch(e) {
+ console.log("Exception in Terminal.modifyInput: " + e);
+ }
+ },
+
+ moveTextCursor: function(loc) {
+ try {
+ var terminalInput = document.getElementById("terminal-input-text-box");
+ if (terminalInput == null) {return;}
+ terminalInput.focus();
+
+ var inputLength = terminalInput.value.length;
+ var start = terminalInput.selectionStart;
+ var end = terminalInput.selectionEnd;
+
+ switch(loc.toLowerCase()) {
+ case "home":
+ terminalInput.setSelectionRange(0,0);
+ break;
+ case "end":
+ terminalInput.setSelectionRange(inputLength, inputLength);
+ break;
+ case "prevchar":
+ if (start > 0) {terminalInput.setSelectionRange(start-1, start-1);}
+ break;
+ case "prevword":
+ for (var i = start-2; i >= 0; --i) {
+ if (terminalInput.value.charAt(i) === " ") {
+ terminalInput.setSelectionRange(i+1, i+1);
+ return;
+ }
+ }
+ terminalInput.setSelectionRange(0, 0);
+ break;
+ case "nextchar":
+ terminalInput.setSelectionRange(start+1, start+1);
+ break;
+ case "nextword":
+ for (var i = start+1; i <= inputLength; ++i) {
+ if (terminalInput.value.charAt(i) === " ") {
+ terminalInput.setSelectionRange(i, i);
+ return;
+ }
+ }
+ terminalInput.setSelectionRange(inputLength, inputLength);
+ break;
+ default:
+ console.log("WARNING: Invalid loc argument in Terminal.moveTextCursor()");
+ break;
+ }
+ } catch(e) {
+ console.log("Exception in Terminal.moveTextCursor: " + e);
+ }
+ },
+
+ finishAction: function(cancelled = false) {
+ if (Terminal.hackFlag) {
+ Terminal.finishHack(cancelled);
+ } else if (Terminal.analyzeFlag) {
+ Terminal.finishAnalyze(cancelled);
+ }
+ },
+
+ //Complete the hack/analyze command
+ finishHack: function(cancelled = false) {
+ if (cancelled == false) {
+ var server = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer();
+
+ //Calculate whether hack was successful
+ var hackChance = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingChance();
+ var rand = Math.random();
+ console.log("Hack success chance: " + hackChance + ", rand: " + rand);
+ var expGainedOnSuccess = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateExpGain();
+ var expGainedOnFailure = (expGainedOnSuccess / 4);
+ if (rand < hackChance) { //Success!
+ if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerNames"].WorldDaemon] &&
+ _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"][_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerNames"].WorldDaemon] == server.ip) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN == null) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN = 1;
+ }
+ Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_13__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN);
+ return;
+ }
+ server.manuallyHacked = true;
+ var moneyGained = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculatePercentMoneyHacked();
+ moneyGained = Math.floor(server.moneyAvailable * moneyGained);
+
+ if (moneyGained <= 0) {moneyGained = 0;} //Safety check
+
+ server.moneyAvailable -= moneyGained;
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainMoney(moneyGained);
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainHackingExp(expGainedOnSuccess)
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainIntelligenceExp(expGainedOnSuccess / _Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].IntelligenceTerminalHackBaseExpGain);
+
+ server.fortify(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].ServerFortifyAmount);
+
+ post("Hack successful! Gained $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(moneyGained, 2) + " and " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(expGainedOnSuccess, 4) + " hacking EXP");
+ } else { //Failure
+ //Player only gains 25% exp for failure? TODO Can change this later to balance
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].gainHackingExp(expGainedOnFailure)
+ post("Failed to hack " + server.hostname + ". Gained " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(expGainedOnFailure, 4) + " hacking EXP");
+ }
+ }
+
+ //Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal
+ $("#hack-progress-bar").attr('id', "old-hack-progress-bar");
+ $("#hack-progress").attr('id', "old-hack-progress");
+ Terminal.resetTerminalInput();
+ $('input[class=terminal-input]').prop('disabled', false);
+
+ Terminal.hackFlag = false;
+ },
+
+ finishAnalyze: function(cancelled = false) {
+ if (cancelled == false) {
+ post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname + ": ");
+ post("Organization name: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().organizationName);
+ var rootAccess = "";
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights) {rootAccess = "YES";}
+ else {rootAccess = "NO";}
+ post("Root Access: " + rootAccess);
+ post("Required hacking skill: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().requiredHackingSkill);
+ post("Estimated server security level: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hackDifficulty, 5), 3));
+ post("Estimated chance to hack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingChance() * 100, 5), 2) + "%");
+ post("Estimated time to hack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].calculateHackingTime(), 5), 3) + " seconds");
+ post("Estimated total money available on server: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["addOffset"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().moneyAvailable, 5), 2));
+ post("Required number of open ports for NUKE: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().numOpenPortsRequired);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().sshPortOpen) {
+ post("SSH port: Open")
+ } else {
+ post("SSH port: Closed")
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ftpPortOpen) {
+ post("FTP port: Open")
+ } else {
+ post("FTP port: Closed")
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().smtpPortOpen) {
+ post("SMTP port: Open")
+ } else {
+ post("SMTP port: Closed")
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().httpPortOpen) {
+ post("HTTP port: Open")
+ } else {
+ post("HTTP port: Closed")
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().sqlPortOpen) {
+ post("SQL port: Open")
+ } else {
+ post("SQL port: Closed")
+ }
+ }
+ Terminal.analyzeFlag = false;
+
+ //Rename the progress bar so that the next hacks dont trigger it. Re-enable terminal
+ $("#hack-progress-bar").attr('id', "old-hack-progress-bar");
+ $("#hack-progress").attr('id', "old-hack-progress");
+ Terminal.resetTerminalInput();
+ $('input[class=terminal-input]').prop('disabled', false);
+ },
+
+ executeCommand: function(command) {
+ command = command.trim();
+ //Replace all extra whitespace in command with a single space
+ command = command.replace(/\s\s+/g, ' ');
+
+ //Terminal history
+ if (Terminal.commandHistory[Terminal.commandHistory.length-1] != command) {
+ Terminal.commandHistory.push(command);
+ if (Terminal.commandHistory.length > 50) {
+ Terminal.commandHistory.splice(0, 1);
+ }
+ }
+ Terminal.commandHistoryIndex = Terminal.commandHistory.length;
+
+ //Process any aliases
+ command = Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["substituteAliases"])(command);
+
+ //Allow usage of ./
+ if (command.startsWith("./")) {
+ command = "run " + command.slice(2);
+ }
+
+ //Only split the first space
+ var commandArray = command.split(" ");
+ if (commandArray.length > 1) {
+ commandArray = [commandArray.shift(), commandArray.join(" ")];
+ }
+
+ if (commandArray.length == 0) {return;}
+
+ /****************** Interactive Tutorial Terminal Commands ******************/
+ if (_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialIsRunning"]) {
+ var foodnstuffServ = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["GetServerByHostname"])("foodnstuff");
+ if (foodnstuffServ == null) {throw new Error("Could not get foodnstuff server"); return;}
+
+ switch(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["currITutorialStep"]) {
+ case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalHelp:
+ if (commandArray[0] == "help") {
+ post(_HelpText_js__WEBPACK_IMPORTED_MODULE_6__["TerminalHelpText"]);
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])();
+ } else {post("Bad command. Please follow the tutorial");}
+ break;
+ case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalLs:
+ if (commandArray[0] == "ls") {
+ Terminal.executeListCommand(commandArray);
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])();
+ } else {post("Bad command. Please follow the tutorial");}
+ break;
+ case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScan:
+ if (commandArray[0] == "scan") {
+ Terminal.executeScanCommand(commandArray);
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])();
+ } else {post("Bad command. Please follow the tutorial");}
+ break;
+ case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScanAnalyze1:
+ if (commandArray.length == 1 && commandArray[0] == "scan-analyze") {
+ Terminal.executeScanAnalyzeCommand(1);
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])();
+ } else {post("Bad command. Please follow the tutorial");}
+ break;
+ case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalScanAnalyze2:
+ if (commandArray.length == 2 && commandArray[0] == "scan-analyze" &&
+ commandArray[1] == "2") {
+ Terminal.executeScanAnalyzeCommand(2);
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])();
+ } else {post("Bad command. Please follow the tutorial");}
+ break;
+ break;
+ case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalConnect:
+ if (commandArray.length == 2) {
+ if ((commandArray[0] == "connect") &&
+ (commandArray[1] == "foodnstuff" || commandArray[1] == foodnstuffServ.ip)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false;
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = foodnstuffServ.ip;
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true;
+ post("Connected to foodnstuff");
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])();
+ } else {post("Wrong command! Try again!"); return;}
+ } else {post("Bad command. Please follow the tutorial");}
+ break;
+ case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalAnalyze:
+ if (commandArray[0] == "analyze") {
+ if (commandArray.length != 1) {
+ post("Incorrect usage of analyze command. Usage: analyze"); return;
+ }
+ //Analyze the current server for information
+ Terminal.analyzeFlag = true;
+ post("Analyzing system...");
+ hackProgressPost("Time left:");
+ hackProgressBarPost("[");
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].analyze();
+
+ //Disable terminal
+ //Terminal.resetTerminalInput();
+ document.getElementById("terminal-input-td").innerHTML = '';
+ $('input[class=terminal-input]').prop('disabled', true);
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])();
+ } else {
+ post("Bad command. Please follow the tutorial");
+ }
+ break;
+ case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalNuke:
+ if (commandArray.length == 2 &&
+ commandArray[0] == "run" && commandArray[1] == "NUKE.exe") {
+ foodnstuffServ.hasAdminRights = true;
+ post("NUKE successful! Gained root access to foodnstuff");
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])();
+ } else {post("Bad command. Please follow the tutorial");}
+ break;
+ case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalManualHack:
+ if (commandArray.length == 1 && commandArray[0] == "hack") {
+ Terminal.hackFlag = true;
+ hackProgressPost("Time left:");
+ hackProgressBarPost("[");
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hack();
+
+ //Disable terminal
+ //Terminal.resetTerminalInput();
+ document.getElementById("terminal-input-td").innerHTML = '';
+ $('input[class=terminal-input]').prop('disabled', true);
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])();
+ } else {post("Bad command. Please follow the tutorial");}
+ break;
+ case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalCreateScript:
+ if (commandArray.length == 2 &&
+ commandArray[0] == "nano" && commandArray[1] == "foodnstuff.script") {
+ _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent("foodnstuff.script", "");
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])();
+ } else {post("Bad command. Please follow the tutorial");}
+ case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalFree:
+ if (commandArray.length == 1 && commandArray[0] == "free") {
+ Terminal.executeFreeCommand(commandArray);
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])();
+ }
+ break;
+ case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].TerminalRunScript:
+ if (commandArray.length == 2 &&
+ commandArray[0] == "run" && commandArray[1] == "foodnstuff.script") {
+ Terminal.runScript("foodnstuff.script");
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])();
+ } else {post("Bad command. Please follow the tutorial");}
+ break;
+ case _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialSteps"].ActiveScriptsToTerminal:
+ if (commandArray.length == 2 &&
+ commandArray[0] == "tail" && commandArray[1] == "foodnstuff.script") {
+ //Check that the script exists on this machine
+ var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])("foodnstuff.script", [], _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer());
+ if (runningScript == null) {
+ post("Error: No such script exists");
+ return;
+ }
+ Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__["logBoxCreate"])(runningScript);
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_7__["iTutorialNextStep"])();
+ } else {post("Bad command. Please follow the tutorial");}
+ break;
+ default:
+ post("Please follow the tutorial, or click 'Exit Tutorial' if you'd like to skip it");
+ return;
+ }
+ return;
+ }
+
+ /****************** END INTERACTIVE TUTORIAL ******************/
+
+ /* Command parser */
+ var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer();
+ switch (commandArray[0].toLowerCase()) {
+ case "alias":
+ if (commandArray.length == 1) {
+ Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["printAliases"])();
+ return;
+ }
+ if (commandArray.length == 2) {
+ if (commandArray[1].startsWith("-g ")) {
+ var alias = commandArray[1].substring(3);
+ if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["parseAliasDeclaration"])(alias, true)) {
+ return;
+ }
+ } else {
+ if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["parseAliasDeclaration"])(commandArray[1])) {
+ return;
+ }
+ }
+ }
+ post('Incorrect usage of alias command. Usage: alias [-g] [aliasname="value"]');
+ break;
+ case "analyze":
+ if (commandArray.length != 1) {
+ post("Incorrect usage of analyze command. Usage: analyze"); return;
+ }
+ //Analyze the current server for information
+ Terminal.analyzeFlag = true;
+ post("Analyzing system...");
+ hackProgressPost("Time left:");
+ hackProgressBarPost("[");
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].analyze();
+
+ //Disable terminal
+ //Terminal.resetTerminalInput();
+ document.getElementById("terminal-input-td").innerHTML = '';
+ $('input[class=terminal-input]').prop('disabled', true);
+ break;
+ case "buy":
+ if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_17__["SpecialServerIps"].hasOwnProperty("Darkweb Server")) {
+ Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__["executeDarkwebTerminalCommand"])(commandArray);
+ } else {
+ post("You need to be able to connect to the Dark Web to use the buy command. (Maybe there's a TOR router you can buy somewhere)");
+ }
+ break;
+ case "cat":
+ if (commandArray.length != 2) {
+ post("Incorrect usage of cat command. Usage: cat [file]"); return;
+ }
+ var filename = commandArray[1];
+ if (!filename.endsWith(".msg") && !filename.endsWith(".lit") && !filename.endsWith(".txt")) {
+ post("Error: Only .msg, .txt, and .lit files are viewable with cat (filename must end with .msg, .txt, or .lit)"); return;
+ }
+ for (var i = 0; i < s.messages.length; ++i) {
+ if (filename.endsWith(".lit") && s.messages[i] == filename) {
+ Object(_Literature_js__WEBPACK_IMPORTED_MODULE_8__["showLiterature"])(s.messages[i]);
+ return;
+ } else if (filename.endsWith(".msg") && s.messages[i].filename == filename) {
+ Object(_Message_js__WEBPACK_IMPORTED_MODULE_9__["showMessage"])(s.messages[i]);
+ return;
+ }
+ }
+ for (var i = 0; i < s.textFiles.length; ++i) {
+ if (s.textFiles[i].fn === filename) {
+ s.textFiles[i].show();
+ return;
+ }
+ }
+ post("Error: No such file " + filename);
+ break;
+ case "check":
+ if (commandArray.length < 2) {
+ post("Incorrect number of arguments. Usage: check [script] [arg1] [arg2]...");
+ } else {
+ var results = commandArray[1].split(" ");
+ var scriptName = results[0];
+ var args = [];
+ for (var i = 1; i < results.length; ++i) {
+ args.push(results[i]);
+ }
+
+ //Can only tail script files
+ if (scriptName.endsWith(".script") == false) {
+ post("Error: tail can only be called on .script files (filename must end with .script)"); return;
+ }
+
+ //Check that the script exists on this machine
+ var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s);
+ if (runningScript == null) {
+ post("Error: No such script exists");
+ return;
+ }
+ runningScript.displayLog();
+ }
+ break;
+ case "clear":
+ case "cls":
+ if (commandArray.length != 1) {
+ post("Incorrect usage of clear/cls command. Usage: clear/cls"); return;
+ }
+ $("#terminal tr:not(:last)").remove();
+ postNetburnerText();
+ break;
+ case "connect":
+ //Disconnect from current server in terminal and connect to new one
+ if (commandArray.length != 2) {
+ post("Incorrect usage of connect command. Usage: connect [ip/hostname]");
+ return;
+ }
+
+ var ip = commandArray[1];
+
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().serversOnNetwork.length; i++) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip == ip || _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).hostname == ip) {
+ Terminal.connectToServer(ip);
+ return;
+ }
+ }
+
+ post("Host not found");
+ break;
+ case "download":
+ if (commandArray.length != 2) {
+ post("Incorrect usage of download command. Usage: download [text file]");
+ return;
+ }
+ var fn = commandArray[1];
+ if (fn === "*" || fn === "*.script" || fn === "*.txt") {
+ //Download all scripts as a zip
+ var zip = new jszip__WEBPACK_IMPORTED_MODULE_23__();
+ if (fn === "*" || fn === "*.script") {
+ for (var i = 0; i < s.scripts.length; ++i) {
+ var file = new Blob([s.scripts[i].code], {type:"text/plain"});
+ zip.file(s.scripts[i].filename + ".js", file);
+ }
+ }
+ if (fn === "*" || fn === "*.txt") {
+ for (var i = 0; i < s.textFiles.length; ++i) {
+ var file = new Blob([s.textFiles[i].text], {type:"text/plain"});
+ zip.file(s.textFiles[i].fn, file);
+ }
+ }
+
+ var filename;
+ switch (fn) {
+ case "*.script":
+ filename = "bitburnerScripts.zip"; break;
+ case "*.txt":
+ filename = "bitburnerTexts.zip"; break;
+ default:
+ filename = "bitburnerFiles.zip"; break;
+ }
+
+ zip.generateAsync({type:"blob"}).then(function(content) {
+ file_saver__WEBPACK_IMPORTED_MODULE_24__["saveAs"](content, filename);
+ });
+ return;
+ } else if (fn.endsWith(".script")) {
+ //Download a single script
+ for (var i = 0; i < s.scripts.length; ++i) {
+ if (s.scripts[i].filename === fn) {
+ return s.scripts[i].download();
+ }
+ }
+ } else if (fn.endsWith(".txt")) {
+ //Download a single text file
+ var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_18__["getTextFile"])(fn, s);
+ if (txtFile !== null) {
+ return txtFile.download();
+ }
+ }
+ post("Error: " + fn + " does not exist");
+ break;
+ case "free":
+ Terminal.executeFreeCommand(commandArray);
+ break;
+ case "hack":
+ if (commandArray.length != 1) {
+ post("Incorrect usage of hack command. Usage: hack"); return;
+ }
+ //Hack the current PC (usually for money)
+ //You can't hack your home pc or servers you purchased
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().purchasedByPlayer) {
+ post("Cannot hack your own machines! You are currently connected to your home PC or one of your purchased servers");
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights == false ) {
+ post("You do not have admin rights for this machine! Cannot hack");
+ } else if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().requiredHackingSkill > _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hacking_skill) {
+ post("Your hacking skill is not high enough to attempt hacking this machine. Try analyzing the machine to determine the required hacking skill");
+ } else {
+ Terminal.hackFlag = true;
+ hackProgressPost("Time left:");
+ hackProgressBarPost("[");
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hack();
+
+ //Disable terminal
+ //Terminal.resetTerminalInput();
+ document.getElementById("terminal-input-td").innerHTML = '';
+ $('input[class=terminal-input]').prop('disabled', true);
+ }
+ break;
+ case "help":
+ if (commandArray.length != 1 && commandArray.length != 2) {
+ post("Incorrect usage of help command. Usage: help"); return;
+ }
+ if (commandArray.length == 1) {
+ post(_HelpText_js__WEBPACK_IMPORTED_MODULE_6__["TerminalHelpText"]);
+ } else {
+ var cmd = commandArray[1];
+ var txt = _HelpText_js__WEBPACK_IMPORTED_MODULE_6__["HelpTexts"][cmd];
+ if (txt == null) {
+ post("Error: No help topics match '" + cmd + "'");
+ return;
+ }
+ post(txt);
+ }
+ break;
+ case "home":
+ if (commandArray.length != 1) {
+ post("Incorrect usage of home command. Usage: home"); return;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false;
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getHomeComputer().ip;
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true;
+ post("Connected to home");
+ Terminal.resetTerminalInput();
+ break;
+ case "hostname":
+ if (commandArray.length != 1) {
+ post("Incorrect usage of hostname command. Usage: hostname"); return;
+ }
+ //Print the hostname of current system
+ post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname);
+ break;
+ case "ifconfig":
+ if (commandArray.length != 1) {
+ post("Incorrect usage of ifconfig command. Usage: ifconfig"); return;
+ }
+ //Print the IP address of the current system
+ post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ip);
+ break;
+ case "kill":
+ if (commandArray.length < 2) {
+ post("Incorrect usage of kill command. Usage: kill [scriptname] [arg1] [arg2]..."); return;
+ }
+ var results = commandArray[1].split(" ");
+ var scriptName = results[0];
+ var args = [];
+ for (var i = 1; i < results.length; ++i) {
+ args.push(results[i]);
+ }
+ var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s);
+ if (runningScript == null) {
+ post("No such script is running. Nothing to kill");
+ return;
+ }
+ Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["killWorkerScript"])(runningScript, s.ip);
+ post("Killing " + scriptName + ". May take up to a few minutes for the scripts to die...");
+ break;
+ case "killall":
+ for (var i = s.runningScripts.length-1; i >= 0; --i) {
+ Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["killWorkerScript"])(s.runningScripts[i], s.ip);
+ }
+ post("Killing all running scripts. May take up to a few minutes for the scripts to die...");
+ break;
+ case "ls":
+ Terminal.executeListCommand(commandArray);
+ break;
+ case "lscpu":
+ post(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().cpuCores + " Core(s)");
+ break;
+ case "mem":
+ if (commandArray.length != 2) {
+ post("Incorrect usage of mem command. usage: mem [scriptname] [-t] [number threads]"); return;
+ }
+ var scriptName = commandArray[1];
+ var numThreads = 1;
+ if (scriptName.indexOf(" -t ") != -1) {
+ var results = scriptName.split(" ");
+ if (results.length != 3) {
+ post("Invalid use of run command. Usage: mem [script] [-t] [number threads]");
+ return;
+ }
+ numThreads = Math.round(Number(results[2]));
+ if (isNaN(numThreads) || numThreads < 1) {
+ post("Invalid number of threads specified. Number of threads must be greater than 1");
+ return;
+ }
+ scriptName = results[0];
+ }
+
+ var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer();
+ for (var i = 0; i < currServ.scripts.length; ++i) {
+ if (scriptName == currServ.scripts[i].filename) {
+ var scriptBaseRamUsage = currServ.scripts[i].ramUsage;
+ var ramUsage = scriptBaseRamUsage * numThreads * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, numThreads-1);
+
+ post("This script requires " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(ramUsage, 2) + "GB of RAM to run for " + numThreads + " thread(s)");
+ return;
+ }
+ }
+ post("ERR: No such script exists!");
+ break;
+ case "nano":
+ if (commandArray.length != 2) {
+ post("Incorrect usage of nano command. Usage: nano [scriptname]"); return;
+ }
+
+ var filename = commandArray[1];
+ if (filename === ".fconf") {
+ var text = Object(_Fconf_js__WEBPACK_IMPORTED_MODULE_5__["createFconf"])();
+ _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, text);
+ return;
+ } else if (filename.endsWith(".script")) {
+ for (var i = 0; i < s.scripts.length; i++) {
+ if (filename == s.scripts[i].filename) {
+ _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, s.scripts[i].code);
+ return;
+ }
+ }
+ } else if (filename.endsWith(".txt")) {
+ for (var i = 0; i < s.textFiles.length; ++i) {
+ if (filename === s.textFiles[i].fn) {
+ _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename, s.textFiles[i].text);
+ return;
+ }
+ }
+ } else {
+ post("Error: Invalid file. Only scripts (.script), text files (.txt), or .fconf can be edited with nano"); return;
+ }
+ _engine_js__WEBPACK_IMPORTED_MODULE_4__["Engine"].loadScriptEditorContent(filename);
+ break;
+ case "ps":
+ if (commandArray.length != 1) {
+ post("Incorrect usage of ps command. Usage: ps"); return;
+ }
+ for (var i = 0; i < s.runningScripts.length; i++) {
+ var rsObj = s.runningScripts[i];
+ var res = rsObj.filename;
+ for (var j = 0; j < rsObj.args.length; ++j) {
+ res += (" " + rsObj.args[j].toString());
+ }
+ post(res);
+ }
+ break;
+ case "rm":
+ if (commandArray.length != 2) {
+ post("Incorrect number of arguments. Usage: rm [program/script]"); return;
+ }
+
+ //Check programs
+ var delTarget = commandArray[1];
+
+ if (delTarget.includes(".exe")) {
+ for (var i = 0; i < s.programs.length; ++i) {
+ if (s.programs[i] == delTarget) {
+ s.programs.splice(i, 1);
+ return;
+ }
+ }
+ } else if (delTarget.endsWith(".script")) {
+ for (var i = 0; i < s.scripts.length; ++i) {
+ if (s.scripts[i].filename == delTarget) {
+ //Check that the script isnt currently running
+ for (var j = 0; j < s.runningScripts.length; ++j) {
+ if (s.runningScripts[j].filename == delTarget) {
+ post("Cannot delete a script that is currently running!");
+ return;
+ }
+ }
+ s.scripts.splice(i, 1);
+ return;
+ }
+ }
+ } else if (delTarget.endsWith(".lit")) {
+ for (var i = 0; i < s.messages.length; ++i) {
+ var f = s.messages[i];
+ if (!(f instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["isString"])(f) && f === delTarget) {
+ s.messages.splice(i, 1);
+ return;
+ }
+ }
+ } else if (delTarget.endsWith(".txt")) {
+ for (var i = 0; i < s.textFiles.length; ++i) {
+ if (s.textFiles[i].fn === delTarget) {
+ s.textFiles.splice(i, 1);
+ return;
+ }
+ }
+ }
+ post("Error: No such file exists");
+ break;
+ case "run":
+ //Run a program or a script
+ if (commandArray.length != 2) {
+ post("Incorrect number of arguments. Usage: run [program/script] [-t] [num threads] [arg1] [arg2]...");
+ } else {
+ var executableName = commandArray[1];
+
+ //Secret Music player!
+ if (executableName === "musicplayer") {
+ post('', false);
+ return;
+ }
+
+ //Check if its a script or just a program/executable
+ if (executableName.indexOf(".script") == -1) {
+ //Not a script
+ Terminal.runProgram(executableName);
+ } else {
+ //Script
+ Terminal.runScript(executableName);
+ }
+ }
+ break;
+ case "scan":
+ Terminal.executeScanCommand(commandArray);
+ break;
+ case "scan-analyze":
+ if (commandArray.length == 1) {
+ Terminal.executeScanAnalyzeCommand(1);
+ } else if (commandArray.length == 2) {
+ var all = false;
+ if (commandArray[1].endsWith("-a")) {
+ all = true;
+ commandArray[1] = commandArray[1].replace("-a", "");
+ }
+ var depth;
+ if (commandArray[1].length === 0) {
+ depth = 1;
+ } else {
+ depth = Number(commandArray[1]);
+ }
+ if (isNaN(depth) || depth < 0) {
+ post("Incorrect usage of scan-analyze command. depth argument must be positive numeric");
+ return;
+ }
+ if (depth > 3 && !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1) &&
+ !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2)) {
+ post("You cannot scan-analyze with that high of a depth. Maximum depth is 3");
+ return;
+ } else if (depth > 5 && !_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2)) {
+ post("You cannot scan-analyze with that high of a depth. Maximum depth is 5");
+ return;
+ } else if (depth > 10) {
+ post("You cannot scan-analyze with that high of a depth. Maximum depth is 10");
+ return;
+ }
+ Terminal.executeScanAnalyzeCommand(depth, all);
+ } else {
+ post("Incorrect usage of scan-analyze command. usage: scan-analyze [depth]");
+ }
+ break;
+ case "scp":
+ if (commandArray.length != 2) {
+ post("Incorrect usage of scp command. Usage: scp [file] [destination hostname/ip]");
+ return;
+ }
+ var args = commandArray[1].split(" ");
+ if (args.length != 2) {
+ post("Incorrect usage of scp command. Usage: scp [file] [destination hostname/ip]");
+ return;
+ }
+ var scriptname = args[0];
+ if (!scriptname.endsWith(".lit") && !scriptname.endsWith(".script") &&
+ !scriptname.endsWith(".txt")){
+ post("Error: scp only works for .script, .txt, and .lit files");
+ return;
+ }
+ var destServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(args[1]);
+ if (destServer == null) {
+ post("Invalid destination. " + args[1] + " not found");
+ return;
+ }
+ var ip = destServer.ip;
+ var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer();
+
+ //Scp for lit files
+ if (scriptname.endsWith(".lit")) {
+ var found = false;
+ for (var i = 0; i < currServ.messages.length; ++i) {
+ if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) && currServ.messages[i] == scriptname) {
+ found = true;
+ break;
+ }
+ }
+
+ if (!found) {return post("Error: no such file exists!");}
+
+ for (var i = 0; i < destServer.messages.length; ++i) {
+ if (destServer.messages[i] === scriptname) {
+ post(scriptname + " copied over to " + destServer.hostname);
+ return; //Already exists
+ }
+ }
+ destServer.messages.push(scriptname);
+ post(scriptname + " copied over to " + destServer.hostname);
+ return;
+ }
+
+ //Scp for txt files
+ if (scriptname.endsWith(".txt")) {
+ var found = false, txtFile;
+ for (var i = 0; i < currServ.textFiles.length; ++i) {
+ if (currServ.textFiles[i].fn === scriptname) {
+ found = true;
+ txtFile = currServ.textFiles[i];
+ break;
+ }
+ }
+
+ if (!found) {return post("Error: no such file exists!");}
+
+ for (var i = 0; i < destServer.textFiles.length; ++i) {
+ if (destServer.textFiles[i].fn === scriptname) {
+ //Overwrite
+ destServer.textFiles[i].text = txtFile.text;
+ post("WARNING: " + scriptname + " already exists on " + destServer.hostname +
+ "and will be overwriten");
+ return post(scriptname + " copied over to " + destServer.hostname);
+ }
+ }
+ var newFile = new _TextFile_js__WEBPACK_IMPORTED_MODULE_18__["TextFile"](txtFile.fn, txtFile.text);
+ destServer.textFiles.push(newFile);
+ return post(scriptname + " copied over to " + destServer.hostname);
+ }
+
+ //Get the current script
+ var sourceScript = null;
+ for (var i = 0; i < currServ.scripts.length; ++i) {
+ if (scriptname == currServ.scripts[i].filename) {
+ sourceScript = currServ.scripts[i];
+ break;
+ }
+ }
+ if (sourceScript == null) {
+ post("ERROR: scp() failed. No such script exists");
+ return;
+ }
+
+ //Overwrite script if it exists
+ for (var i = 0; i < destServer.scripts.length; ++i) {
+ if (scriptname == destServer.scripts[i].filename) {
+ post("WARNING: " + scriptname + " already exists on " + destServer.hostname + " and will be overwritten");
+ var oldScript = destServer.scripts[i];
+ oldScript.code = sourceScript.code;
+ oldScript.ramUsage = sourceScript.ramUsage;
+ post(scriptname + " overwriten on " + destServer.hostname);
+ return;
+ }
+ }
+
+ var newScript = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["Script"]();
+ newScript.filename = scriptname;
+ newScript.code = sourceScript.code;
+ newScript.ramUsage = sourceScript.ramUsage;
+ newScript.destServer = ip;
+ destServer.scripts.push(newScript);
+ post(scriptname + " copied over to " + destServer.hostname);
+ break;
+ case "sudov":
+ if (commandArray.length != 1) {
+ post("Incorrect number of arguments. Usage: sudov"); return;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hasAdminRights) {
+ post("You have ROOT access to this machine");
+ } else {
+ post("You do NOT have root access to this machine");
+ }
+ break;
+ case "tail":
+ if (commandArray.length < 2) {
+ post("Incorrect number of arguments. Usage: tail [script] [arg1] [arg2]...");
+ } else {
+ var results = commandArray[1].split(" ");
+ var scriptName = results[0];
+ var args = [];
+ for (var i = 1; i < results.length; ++i) {
+ args.push(results[i]);
+ }
+
+ //Can only tail script files
+ if (scriptName.endsWith(".script") == false) {
+ post("Error: tail can only be called on .script files (filename must end with .script)"); return;
+ }
+
+ //Check that the script exists on this machine
+ var runningScript = Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, s);
+ if (runningScript == null) {
+ post("Error: No such script exists");
+ return;
+ }
+ Object(_utils_LogBox_js__WEBPACK_IMPORTED_MODULE_21__["logBoxCreate"])(runningScript);
+ }
+ break;
+ case "theme":
+ //todo support theme saving
+ var args = commandArray[1] ? commandArray[1].split(" ") : [];
+ if (args.length != 1 && args.length != 3) {
+ post("Incorrect number of arguments.");
+ post("Usage: theme [default|muted|solarized] | #[background color hex] #[text color hex] #[highlight color hex]");
+ } else if(args.length == 1){
+ var themeName = args[0];
+ if (themeName == "default"){
+ document.body.style.setProperty('--my-highlight-color',"#ffffff");
+ document.body.style.setProperty('--my-font-color',"#66ff33");
+ document.body.style.setProperty('--my-background-color',"#000000");
+ } else if (themeName == "muted"){
+ document.body.style.setProperty('--my-highlight-color',"#ffffff");
+ document.body.style.setProperty('--my-font-color',"#66ff33");
+ document.body.style.setProperty('--my-background-color',"#252527");
+ } else if (themeName == "solarized"){
+ document.body.style.setProperty('--my-highlight-color',"#6c71c4");
+ document.body.style.setProperty('--my-font-color',"#839496");
+ document.body.style.setProperty('--my-background-color',"#002b36");
+ } else {
+ return post("Theme not found");
+ }
+ _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeHighlightColor = document.body.style.getPropertyValue("--my-highlight-color");
+ _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeFontColor = document.body.style.getPropertyValue("--my-font-color");
+ _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeBackgroundColor = document.body.style.getPropertyValue("--my-background-color");
+ } else {
+ var inputBackgroundHex = args[0];
+ var inputTextHex = args[1];
+ var inputHighlightHex = args[2];
+ if (/(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputBackgroundHex) &&
+ /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputTextHex) &&
+ /(^#[0-9A-F]{6}$)|(^#[0-9A-F]{3}$)/i.test(inputHighlightHex)){
+ document.body.style.setProperty('--my-highlight-color',inputHighlightHex);
+ document.body.style.setProperty('--my-font-color',inputTextHex);
+ document.body.style.setProperty('--my-background-color',inputBackgroundHex);
+ _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeHighlightColor = document.body.style.getPropertyValue("--my-highlight-color");
+ _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeFontColor = document.body.style.getPropertyValue("--my-font-color");
+ _Settings_js__WEBPACK_IMPORTED_MODULE_16__["Settings"].ThemeBackgroundColor = document.body.style.getPropertyValue("--my-background-color");
+ } else {
+ return post("Invalid Hex Input for theme");
+ }
+ }
+ break;
+ case "top":
+ if(commandArray.length != 1) {
+ post("Incorrect usage of top command. Usage: top"); return;
+ }
+
+ post("Script Threads RAM Usage");
+
+ var currRunningScripts = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().runningScripts;
+ //Iterate through scripts on current server
+ for(var i = 0; i < currRunningScripts.length; i++) {
+ var script = currRunningScripts[i];
+
+ //Calculate name padding
+ var numSpacesScript = 32 - script.filename.length; //26 -> width of name column
+ if (numSpacesScript < 0) {numSpacesScript = 0;}
+ var spacesScript = Array(numSpacesScript+1).join(" ");
+
+ //Calculate thread padding
+ var numSpacesThread = 16 - (script.threads + "").length; //16 -> width of thread column
+ var spacesThread = Array(numSpacesThread+1).join(" ");
+
+ //Calculate and transform RAM usage
+ ramUsage = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(script.scriptRef.ramUsage * script.threads, 2).toString() + "GB";
+
+ var entry = [script.filename, spacesScript, script.threads, spacesThread, ramUsage];
+ post(entry.join(""));
+ }
+ break;
+ case "unalias":
+ if (commandArray.length != 2) {
+ post('Incorrect usage of unalias name. Usage: unalias "[alias]"');
+ return;
+ } else if (!(commandArray[1].startsWith('"') && commandArray[1].endsWith('"'))) {
+ post('Incorrect usage of unalias name. Usage: unalias "[alias]"');
+ } else {
+ var alias = commandArray[1].slice(1, -1);
+ if (Object(_Alias_js__WEBPACK_IMPORTED_MODULE_0__["removeAlias"])(alias)) {
+ post("Removed alias " + alias);
+ } else {
+ post("No such alias exists");
+ }
+ }
+ break;
+ default:
+ post("Command not found");
+ }
+ },
+
+ connectToServer: function(ip) {
+ console.log("Connect to server called");
+ var serv = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(ip);
+ if (serv == null) {
+ post("Invalid server. Connection failed.");
+ return;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = false;
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].currentServer = serv.ip;
+ _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().isConnectedTo = true;
+ post("Connected to " + serv.hostname);
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname == "darkweb") {
+ Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_3__["checkIfConnectedToDarkweb"])(); //Posts a 'help' message if connecting to dark web
+ }
+ Terminal.resetTerminalInput();
+ },
+
+ executeListCommand: function(commandArray) {
+ if (commandArray.length != 1 && commandArray.length != 2) {
+ post("Incorrect usage of ls command. Usage: ls [| grep pattern]"); return;
+ }
+
+ //grep
+ var filter = null;
+ if (commandArray.length == 2) {
+ if (commandArray[1].startsWith("| grep ")) {
+ var pattern = commandArray[1].replace("| grep ", "");
+ if (pattern != " ") {
+ filter = pattern;
+ }
+ } else {
+ post("Incorrect usage of ls command. Usage: ls [| grep pattern]"); return;
+ }
+ }
+
+ //Display all programs and scripts
+ var allFiles = [];
+
+ //Get all of the programs and scripts on the machine into one temporary array
+ var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer();
+ for (var i = 0; i < s.programs.length; i++) {
+ if (filter) {
+ if (s.programs[i].includes(filter)) {
+ allFiles.push(s.programs[i]);
+ }
+ } else {
+ allFiles.push(s.programs[i]);
+ }
+ }
+ for (var i = 0; i < s.scripts.length; i++) {
+ if (filter) {
+ if (s.scripts[i].filename.includes(filter)) {
+ allFiles.push(s.scripts[i].filename);
+ }
+ } else {
+ allFiles.push(s.scripts[i].filename);
+ }
+
+ }
+ for (var i = 0; i < s.messages.length; i++) {
+ if (filter) {
+ if (s.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) {
+ if (s.messages[i].filename.includes(filter)) {
+ allFiles.push(s.messages[i].filename);
+ }
+ } else if (s.messages[i].includes(filter)) {
+ allFiles.push(s.messages[i]);
+ }
+ } else {
+ if (s.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_9__["Message"]) {
+ allFiles.push(s.messages[i].filename);
+ } else {
+ allFiles.push(s.messages[i]);
+ }
+ }
+ }
+ for (var i = 0; i < s.textFiles.length; ++i) {
+ if (filter) {
+ if (s.textFiles[i].fn.includes(filter)) {
+ allFiles.push(s.textFiles[i].fn);
+ }
+ } else {
+ allFiles.push(s.textFiles[i].fn);
+ }
+ }
+
+ //Sort the files alphabetically then print each
+ allFiles.sort();
+
+ for (var i = 0; i < allFiles.length; i++) {
+ post(allFiles[i]);
+ }
+ },
+
+ executeScanCommand: function(commandArray) {
+ if (commandArray.length != 1) {
+ post("Incorrect usage of netstat/scan command. Usage: netstat/scan"); return;
+ }
+ //Displays available network connections using TCP
+ post("Hostname IP Root Access");
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().serversOnNetwork.length; i++) {
+ //Add hostname
+ var entry = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i);
+ if (entry == null) {continue;}
+ entry = entry.hostname;
+
+ //Calculate padding and add IP
+ var numSpaces = 21 - entry.length;
+ var spaces = Array(numSpaces+1).join(" ");
+ entry += spaces;
+ entry += _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip;
+
+ //Calculate padding and add root access info
+ var hasRoot;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).hasAdminRights) {
+ hasRoot = 'Y';
+ } else {
+ hasRoot = 'N';
+ }
+ numSpaces = 21 - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().getServerOnNetwork(i).ip.length;
+ spaces = Array(numSpaces+1).join(" ");
+ entry += spaces;
+ entry += hasRoot;
+ post(entry);
+ }
+ },
+
+ executeScanAnalyzeCommand: function(depth=1, all=false) {
+ //We'll use the AllServersMap as a visited() array
+ //TODO Using array as stack for now, can make more efficient
+ post("~~~~~~~~~~ Beginning scan-analyze ~~~~~~~~~~");
+ post(" ");
+ var visited = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["AllServersMap"]();
+
+ var stack = [];
+ var depthQueue = [0];
+ var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer();
+ stack.push(currServ);
+ while(stack.length != 0) {
+ var s = stack.pop();
+ var d = depthQueue.pop();
+ if (!all && s.purchasedByPlayer && s.hostname != "home") {
+ continue; //Purchased server
+ } else if (visited[s.ip] || d > depth) {
+ continue; //Already visited or out-of-depth
+ } else {
+ visited[s.ip] = 1;
+ }
+ for (var i = s.serversOnNetwork.length-1; i >= 0; --i) {
+ stack.push(s.getServerOnNetwork(i));
+ depthQueue.push(d+1);
+ }
+ if (d == 0) {continue;} //Don't print current server
+ var titleDashes = Array((d-1) * 4 + 1).join("-");
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].AutoLink)) {
+ post("" + titleDashes + "> " + s.hostname + "", false);
+ } else {
+ post("" + titleDashes + ">" + s.hostname + "");
+ }
+
+ var dashes = titleDashes + "--";
+ //var dashes = Array(d * 2 + 1).join("-");
+ var c = "NO";
+ if (s.hasAdminRights) {c = "YES";}
+ post(dashes + "Root Access: " + c + ", Required hacking skill: " + s.requiredHackingSkill);
+ post(dashes + "Number of open ports required to NUKE: " + s.numOpenPortsRequired);
+ post(dashes + "RAM: " + s.maxRam);
+ post(" ");
+ }
+
+ var links = document.getElementsByClassName("scan-analyze-link");
+ for (var i = 0; i < links.length; ++i) {
+ (function() {
+ var hostname = links[i].innerHTML.toString();
+ links[i].onclick = function() {
+ if (Terminal.analyzeFlag || Terminal.hackFlag) {return;}
+ Terminal.connectToServer(hostname);
+ }
+ }());//Immediate invocation
+ }
+
+ },
+
+ executeFreeCommand: function(commandArray) {
+ if (commandArray.length != 1) {
+ post("Incorrect usage of free command. Usage: free"); return;
+ }
+ post("Total: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().maxRam, 2) + " GB");
+ post("Used: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ramUsed, 2) + " GB");
+ post("Available: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().maxRam - _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().ramUsed, 2) + " GB");
+ },
+
+ //First called when the "run [program]" command is called. Checks to see if you
+ //have the executable and, if you do, calls the executeProgram() function
+ runProgram: function(programName) {
+ //Check if you have the program on your computer. If you do, execute it, otherwise
+ //display an error message
+ var splitArgs = programName.split(" ");
+ var name = " ";
+ if (splitArgs.length > 1) {
+ name = splitArgs[0];
+ } else {
+ name = programName;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hasProgram(name)) {
+ Terminal.executeProgram(programName);
+ return;
+ }
+ post("ERROR: No such executable on home computer (Only programs that exist on your home computer can be run)");
+ },
+
+ //Contains the implementations of all possible programs
+ executeProgram: function(programName) {
+ var s = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer();
+ var splitArgs = programName.split(" ");
+ if (splitArgs.length > 1) {
+ programName = splitArgs[0];
+ }
+ switch (programName) {
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].NukeProgram:
+ if (s.hasAdminRights) {
+ post("You already have root access to this computer. There is no reason to run NUKE.exe");
+ } else {
+ if (s.openPortCount >= _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().numOpenPortsRequired) {
+ s.hasAdminRights = true;
+ post("NUKE successful! Gained root access to " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer().hostname);
+ //TODO Make this take time rather than be instant
+ } else {
+ post("NUKE unsuccessful. Not enough ports have been opened");
+ }
+ }
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BruteSSHProgram:
+ if (s.sshPortOpen) {
+ post("SSH Port (22) is already open!");
+ } else {
+ s.sshPortOpen = true;
+ post("Opened SSH Port(22)!")
+ ++s.openPortCount;
+ }
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].FTPCrackProgram:
+ if (s.ftpPortOpen) {
+ post("FTP Port (21) is already open!");
+ } else {
+ s.ftpPortOpen = true;
+ post("Opened FTP Port (21)!");
+ ++s.openPortCount;
+ }
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].RelaySMTPProgram:
+ if (s.smtpPortOpen) {
+ post("SMTP Port (25) is already open!");
+ } else {
+ s.smtpPortOpen = true;
+ post("Opened SMTP Port (25)!");
+ ++s.openPortCount;
+ }
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].HTTPWormProgram:
+ if (s.httpPortOpen) {
+ post("HTTP Port (80) is already open!");
+ } else {
+ s.httpPortOpen = true;
+ post("Opened HTTP Port (80)!");
+ ++s.openPortCount;
+ }
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].SQLInjectProgram:
+ if (s.sqlPortOpen) {
+ post("SQL Port (1433) is already open!");
+ } else {
+ s.sqlPortOpen = true;
+ post("Opened SQL Port (1433)!");
+ ++s.openPortCount;
+ }
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].ServerProfiler:
+ if (splitArgs.length != 2) {
+ post("Must pass a server hostname or IP as an argument for ServerProfiler.exe");
+ return;
+ }
+ var serv = Object(_Server_js__WEBPACK_IMPORTED_MODULE_15__["getServer"])(splitArgs[1]);
+ if (serv == null) {
+ post("Invalid server IP/hostname");
+ return;
+ }
+ post(serv.hostname + ":");
+ post("Server base security level: " + serv.baseDifficulty);
+ post("Server current security level: " + serv.hackDifficulty);
+ post("Server growth rate: " + serv.serverGrowth);
+ post("Netscript hack() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateHackingTime"])(serv), 1) + "s");
+ post("Netscript grow() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateGrowTime"])(serv)/1000, 1) + "s");
+ post("Netscript weaken() execution time: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_10__["scriptCalculateWeakenTime"])(serv)/1000, 1) + "s");
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].AutoLink:
+ post("This executable cannot be run.");
+ post("AutoLink.exe lets you automatically connect to other servers when using 'scan-analyze'.");
+ post("When using scan-analyze, click on a server's hostname to connect to it.");
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV1:
+ post("This executable cannot be run.");
+ post("DeepscanV1.exe lets you run 'scan-analyze' with a depth up to 5.");
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].DeepscanV2:
+ post("This executable cannot be run.");
+ post("DeepscanV2.exe lets you run 'scan-analyze' with a depth up to 10.");
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].Flight:
+ post("Augmentations: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].augmentations.length + " / 30");
+ post("Money: $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].money.toNumber(), 2) + " / $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_19__["formatNumber"])(100000000000, 2));
+ post("One path below must be fulfilled...");
+ post("----------HACKING PATH----------");
+ post("Hacking skill: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].hacking_skill + " / 2500");
+ post("----------COMBAT PATH----------");
+ post("Strength: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].strength + " / 1500");
+ post("Defense: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].defense + " / 1500");
+ post("Dexterity: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].dexterity + " / 1500");
+ post("Agility: " + _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].agility + " / 1500");
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_2__["Programs"].BitFlume:
+ var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxGetYesButton"])(),
+ noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxGetNoButton"])();
+ yesBtn.innerHTML = "Travel to BitNode Nexus";
+ noBtn.innerHTML = "Cancel";
+ yesBtn.addEventListener("click", function() {
+ Object(_RedPill_js__WEBPACK_IMPORTED_MODULE_13__["hackWorldDaemon"])(_Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].bitNodeN, true);
+ return Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxClose"])();
+ });
+ noBtn.addEventListener("click", function() {
+ return Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxClose"])();
+ });
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_22__["yesNoBoxCreate"])("WARNING: USING THIS PROGRAM WILL CAUSE YOU TO LOSE ALL OF YOUR PROGRESS ON THE CURRENT BITNODE.
" +
+ "Do you want to travel to the BitNode Nexus? This allows you to reset the current BitNode " +
+ "and select a new one.");
+
+ break;
+ default:
+ post("Invalid executable. Cannot be run");
+ return;
+ }
+ },
+
+ runScript: function(scriptName) {
+ var server = _Player_js__WEBPACK_IMPORTED_MODULE_12__["Player"].getCurrentServer();
+
+ var numThreads = 1;
+ var args = [];
+ var results = scriptName.split(" ");
+ if (results.length <= 0) {
+ post("This is a bug. Please contact developer");
+ }
+ scriptName = results[0];
+ if (results.length > 1) {
+ if (results.length >= 3 && results[1] == "-t") {
+ numThreads = Math.round(Number(results[2]));
+ if (isNaN(numThreads) || numThreads < 1) {
+ post("Invalid number of threads specified. Number of threads must be greater than 0");
+ return;
+ }
+ for (var i = 3; i < results.length; ++i) {
+ var arg = results[i];
+
+ //Forced string
+ if ((arg.startsWith("'") && arg.endsWith("'")) ||
+ (arg.startsWith('"') && arg.endsWith('"'))) {
+ args.push(arg.slice(1, -1));
+ continue;
+ }
+ //Number
+ var tempNum = Number(arg);
+ if (!isNaN(tempNum)) {
+ args.push(tempNum);
+ continue;
+ }
+ //Otherwise string
+ args.push(arg);
+ }
+ } else {
+ for (var i = 1; i < results.length; ++i) {
+ var arg = results[i];
+
+ //Forced string
+ if ((arg.startsWith("'") && arg.endsWith("'")) ||
+ (arg.startsWith('"') && arg.endsWith('"'))) {
+ args.push(arg.slice(1, -1));
+ continue;
+ }
+ //Number
+ var tempNum = Number(arg);
+ if (!isNaN(tempNum)) {
+ args.push(tempNum);
+ continue;
+ }
+ //Otherwise string
+ args.push(arg);
+ }
+ }
+ }
+
+
+ //Check if this script is already running
+ if (Object(_Script_js__WEBPACK_IMPORTED_MODULE_14__["findRunningScript"])(scriptName, args, server) != null) {
+ post("ERROR: This script is already running. Cannot run multiple instances");
+ return;
+ }
+
+ //Check if the script exists and if it does run it
+ for (var i = 0; i < server.scripts.length; i++) {
+ if (server.scripts[i].filename == scriptName) {
+ //Check for admin rights and that there is enough RAM availble to run
+ var script = server.scripts[i];
+ var ramUsage = script.ramUsage * numThreads * Math.pow(_Constants_js__WEBPACK_IMPORTED_MODULE_1__["CONSTANTS"].MultithreadingRAMCost, numThreads-1);
+ var ramAvailable = server.maxRam - server.ramUsed;
+
+ if (server.hasAdminRights == false) {
+ post("Need root access to run script");
+ return;
+ } else if (ramUsage > ramAvailable){
+ post("This machine does not have enough RAM to run this script with " +
+ numThreads + " threads. Script requires " + ramUsage + "GB of RAM");
+ return;
+ } else {
+ //Able to run script
+ post("Running script with " + numThreads + " thread(s) and args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_20__["printArray"])(args) + ".");
+ post("May take a few seconds to start up the process...");
+ var runningScriptObj = new _Script_js__WEBPACK_IMPORTED_MODULE_14__["RunningScript"](script, args);
+ runningScriptObj.threads = numThreads;
+ server.runningScripts.push(runningScriptObj);
+
+ Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_11__["addWorkerScript"])(runningScriptObj, server);
+ return;
+ }
+ }
+ }
+
+ post("ERROR: No such script");
+ }
+};
+
+
+
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 41)))
+
+/***/ }),
+/* 23 */
+/*!**************************!*\
+ !*** ./utils/decimal.js ***!
+ \**************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+var __WEBPACK_AMD_DEFINE_RESULT__;/*! decimal.js v7.2.3 https://github.com/MikeMcl/decimal.js/LICENCE */
+;(function (globalScope) {
+ 'use strict';
+
+
+ /*
+ * decimal.js v7.2.3
+ * An arbitrary-precision Decimal type for JavaScript.
+ * https://github.com/MikeMcl/decimal.js
+ * Copyright (c) 2017 Michael Mclaughlin
+ * MIT Licence
+ */
+
+
+ // ----------------------------------- EDITABLE DEFAULTS ------------------------------------ //
+
+
+ // The maximum exponent magnitude.
+ // The limit on the value of `toExpNeg`, `toExpPos`, `minE` and `maxE`.
+ var EXP_LIMIT = 9e15, // 0 to 9e15
+
+ // The limit on the value of `precision`, and on the value of the first argument to
+ // `toDecimalPlaces`, `toExponential`, `toFixed`, `toPrecision` and `toSignificantDigits`.
+ MAX_DIGITS = 1e9, // 0 to 1e9
+
+ // Base conversion alphabet.
+ NUMERALS = '0123456789abcdef',
+ // The natural logarithm of 10 (1025 digits).
+ LN10 = '2.3025850929940456840179914546843642076011014886287729760333279009675726096773524802359972050895982983419677840422862486334095254650828067566662873690987816894829072083255546808437998948262331985283935053089653777326288461633662222876982198867465436674744042432743651550489343149393914796194044002221051017141748003688084012647080685567743216228355220114804663715659121373450747856947683463616792101806445070648000277502684916746550586856935673420670581136429224554405758925724208241314695689016758940256776311356919292033376587141660230105703089634572075440370847469940168269282808481184289314848524948644871927809676271275775397027668605952496716674183485704422507197965004714951050492214776567636938662976979522110718264549734772662425709429322582798502585509785265383207606726317164309505995087807523710333101197857547331541421808427543863591778117054309827482385045648019095610299291824318237525357709750539565187697510374970888692180205189339507238539205144634197265287286965110862571492198849978748873771345686209167058',
+
+ // Pi (1025 digits).
+ PI = '3.1415926535897932384626433832795028841971693993751058209749445923078164062862089986280348253421170679821480865132823066470938446095505822317253594081284811174502841027019385211055596446229489549303819644288109756659334461284756482337867831652712019091456485669234603486104543266482133936072602491412737245870066063155881748815209209628292540917153643678925903600113305305488204665213841469519415116094330572703657595919530921861173819326117931051185480744623799627495673518857527248912279381830119491298336733624406566430860213949463952247371907021798609437027705392171762931767523846748184676694051320005681271452635608277857713427577896091736371787214684409012249534301465495853710507922796892589235420199561121290219608640344181598136297747713099605187072113499999983729780499510597317328160963185950244594553469083026425223082533446850352619311881710100031378387528865875332083814206171776691473035982534904287554687311595628638823537875937519577818577805321712268066130019278766111959092164201989380952572010654858632789',
+
+
+ // The initial configuration properties of the Decimal constructor.
+ Decimal = {
+
+ // These values must be integers within the stated ranges (inclusive).
+ // Most of these values can be changed at run-time using the `Decimal.config` method.
+
+ // The maximum number of significant digits of the result of a calculation or base conversion.
+ // E.g. `Decimal.config({ precision: 20 });`
+ precision: 20, // 1 to MAX_DIGITS
+
+ // The rounding mode used when rounding to `precision`.
+ //
+ // ROUND_UP 0 Away from zero.
+ // ROUND_DOWN 1 Towards zero.
+ // ROUND_CEIL 2 Towards +Infinity.
+ // ROUND_FLOOR 3 Towards -Infinity.
+ // ROUND_HALF_UP 4 Towards nearest neighbour. If equidistant, up.
+ // ROUND_HALF_DOWN 5 Towards nearest neighbour. If equidistant, down.
+ // ROUND_HALF_EVEN 6 Towards nearest neighbour. If equidistant, towards even neighbour.
+ // ROUND_HALF_CEIL 7 Towards nearest neighbour. If equidistant, towards +Infinity.
+ // ROUND_HALF_FLOOR 8 Towards nearest neighbour. If equidistant, towards -Infinity.
+ //
+ // E.g.
+ // `Decimal.rounding = 4;`
+ // `Decimal.rounding = Decimal.ROUND_HALF_UP;`
+ rounding: 4, // 0 to 8
+
+ // The modulo mode used when calculating the modulus: a mod n.
+ // The quotient (q = a / n) is calculated according to the corresponding rounding mode.
+ // The remainder (r) is calculated as: r = a - n * q.
+ //
+ // UP 0 The remainder is positive if the dividend is negative, else is negative.
+ // DOWN 1 The remainder has the same sign as the dividend (JavaScript %).
+ // FLOOR 3 The remainder has the same sign as the divisor (Python %).
+ // HALF_EVEN 6 The IEEE 754 remainder function.
+ // EUCLID 9 Euclidian division. q = sign(n) * floor(a / abs(n)). Always positive.
+ //
+ // Truncated division (1), floored division (3), the IEEE 754 remainder (6), and Euclidian
+ // division (9) are commonly used for the modulus operation. The other rounding modes can also
+ // be used, but they may not give useful results.
+ modulo: 1, // 0 to 9
+
+ // The exponent value at and beneath which `toString` returns exponential notation.
+ // JavaScript numbers: -7
+ toExpNeg: -7, // 0 to -EXP_LIMIT
+
+ // The exponent value at and above which `toString` returns exponential notation.
+ // JavaScript numbers: 21
+ toExpPos: 21, // 0 to EXP_LIMIT
+
+ // The minimum exponent value, beneath which underflow to zero occurs.
+ // JavaScript numbers: -324 (5e-324)
+ minE: -EXP_LIMIT, // -1 to -EXP_LIMIT
+
+ // The maximum exponent value, above which overflow to Infinity occurs.
+ // JavaScript numbers: 308 (1.7976931348623157e+308)
+ maxE: EXP_LIMIT, // 1 to EXP_LIMIT
+
+ // Whether to use cryptographically-secure random number generation, if available.
+ crypto: false // true/false
+ },
+
+
+ // ----------------------------------- END OF EDITABLE DEFAULTS ------------------------------- //
+
+
+ inexact, noConflict, quadrant,
+ external = true,
+
+ decimalError = '[DecimalError] ',
+ invalidArgument = decimalError + 'Invalid argument: ',
+ precisionLimitExceeded = decimalError + 'Precision limit exceeded',
+ cryptoUnavailable = decimalError + 'crypto unavailable',
+
+ mathfloor = Math.floor,
+ mathpow = Math.pow,
+
+ isBinary = /^0b([01]+(\.[01]*)?|\.[01]+)(p[+-]?\d+)?$/i,
+ isHex = /^0x([0-9a-f]+(\.[0-9a-f]*)?|\.[0-9a-f]+)(p[+-]?\d+)?$/i,
+ isOctal = /^0o([0-7]+(\.[0-7]*)?|\.[0-7]+)(p[+-]?\d+)?$/i,
+ isDecimal = /^(\d+(\.\d*)?|\.\d+)(e[+-]?\d+)?$/i,
+
+ BASE = 1e7,
+ LOG_BASE = 7,
+ MAX_SAFE_INTEGER = 9007199254740991,
+
+ LN10_PRECISION = LN10.length - 1,
+ PI_PRECISION = PI.length - 1,
+
+ // Decimal.prototype object
+ P = {};
+
+
+ // Decimal prototype methods
+
+
+ /*
+ * absoluteValue abs
+ * ceil
+ * comparedTo cmp
+ * cosine cos
+ * cubeRoot cbrt
+ * decimalPlaces dp
+ * dividedBy div
+ * dividedToIntegerBy divToInt
+ * equals eq
+ * floor
+ * greaterThan gt
+ * greaterThanOrEqualTo gte
+ * hyperbolicCosine cosh
+ * hyperbolicSine sinh
+ * hyperbolicTangent tanh
+ * inverseCosine acos
+ * inverseHyperbolicCosine acosh
+ * inverseHyperbolicSine asinh
+ * inverseHyperbolicTangent atanh
+ * inverseSine asin
+ * inverseTangent atan
+ * isFinite
+ * isInteger isInt
+ * isNaN
+ * isNegative isNeg
+ * isPositive isPos
+ * isZero
+ * lessThan lt
+ * lessThanOrEqualTo lte
+ * logarithm log
+ * [maximum] [max]
+ * [minimum] [min]
+ * minus sub
+ * modulo mod
+ * naturalExponential exp
+ * naturalLogarithm ln
+ * negated neg
+ * plus add
+ * precision sd
+ * round
+ * sine sin
+ * squareRoot sqrt
+ * tangent tan
+ * times mul
+ * toBinary
+ * toDecimalPlaces toDP
+ * toExponential
+ * toFixed
+ * toFraction
+ * toHexadecimal toHex
+ * toNearest
+ * toNumber
+ * toOctal
+ * toPower pow
+ * toPrecision
+ * toSignificantDigits toSD
+ * toString
+ * truncated trunc
+ * valueOf toJSON
+ */
+
+
+ /*
+ * Return a new Decimal whose value is the absolute value of this Decimal.
+ *
+ */
+ P.absoluteValue = P.abs = function () {
+ var x = new this.constructor(this);
+ if (x.s < 0) x.s = 1;
+ return finalise(x);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the
+ * direction of positive Infinity.
+ *
+ */
+ P.ceil = function () {
+ return finalise(new this.constructor(this), this.e + 1, 2);
+ };
+
+
+ /*
+ * Return
+ * 1 if the value of this Decimal is greater than the value of `y`,
+ * -1 if the value of this Decimal is less than the value of `y`,
+ * 0 if they have the same value,
+ * NaN if the value of either Decimal is NaN.
+ *
+ */
+ P.comparedTo = P.cmp = function (y) {
+ var i, j, xdL, ydL,
+ x = this,
+ xd = x.d,
+ yd = (y = new x.constructor(y)).d,
+ xs = x.s,
+ ys = y.s;
+
+ // Either NaN or ±Infinity?
+ if (!xd || !yd) {
+ return !xs || !ys ? NaN : xs !== ys ? xs : xd === yd ? 0 : !xd ^ xs < 0 ? 1 : -1;
+ }
+
+ // Either zero?
+ if (!xd[0] || !yd[0]) return xd[0] ? xs : yd[0] ? -ys : 0;
+
+ // Signs differ?
+ if (xs !== ys) return xs;
+
+ // Compare exponents.
+ if (x.e !== y.e) return x.e > y.e ^ xs < 0 ? 1 : -1;
+
+ xdL = xd.length;
+ ydL = yd.length;
+
+ // Compare digit by digit.
+ for (i = 0, j = xdL < ydL ? xdL : ydL; i < j; ++i) {
+ if (xd[i] !== yd[i]) return xd[i] > yd[i] ^ xs < 0 ? 1 : -1;
+ }
+
+ // Compare lengths.
+ return xdL === ydL ? 0 : xdL > ydL ^ xs < 0 ? 1 : -1;
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the cosine of the value in radians of this Decimal.
+ *
+ * Domain: [-Infinity, Infinity]
+ * Range: [-1, 1]
+ *
+ * cos(0) = 1
+ * cos(-0) = 1
+ * cos(Infinity) = NaN
+ * cos(-Infinity) = NaN
+ * cos(NaN) = NaN
+ *
+ */
+ P.cosine = P.cos = function () {
+ var pr, rm,
+ x = this,
+ Ctor = x.constructor;
+
+ if (!x.d) return new Ctor(NaN);
+
+ // cos(0) = cos(-0) = 1
+ if (!x.d[0]) return new Ctor(1);
+
+ pr = Ctor.precision;
+ rm = Ctor.rounding;
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
+ Ctor.rounding = 1;
+
+ x = cosine(Ctor, toLessThanHalfPi(Ctor, x));
+
+ Ctor.precision = pr;
+ Ctor.rounding = rm;
+
+ return finalise(quadrant == 2 || quadrant == 3 ? x.neg() : x, pr, rm, true);
+ };
+
+
+ /*
+ *
+ * Return a new Decimal whose value is the cube root of the value of this Decimal, rounded to
+ * `precision` significant digits using rounding mode `rounding`.
+ *
+ * cbrt(0) = 0
+ * cbrt(-0) = -0
+ * cbrt(1) = 1
+ * cbrt(-1) = -1
+ * cbrt(N) = N
+ * cbrt(-I) = -I
+ * cbrt(I) = I
+ *
+ * Math.cbrt(x) = (x < 0 ? -Math.pow(-x, 1/3) : Math.pow(x, 1/3))
+ *
+ */
+ P.cubeRoot = P.cbrt = function () {
+ var e, m, n, r, rep, s, sd, t, t3, t3plusx,
+ x = this,
+ Ctor = x.constructor;
+
+ if (!x.isFinite() || x.isZero()) return new Ctor(x);
+ external = false;
+
+ // Initial estimate.
+ s = x.s * Math.pow(x.s * x, 1 / 3);
+
+ // Math.cbrt underflow/overflow?
+ // Pass x to Math.pow as integer, then adjust the exponent of the result.
+ if (!s || Math.abs(s) == 1 / 0) {
+ n = digitsToString(x.d);
+ e = x.e;
+
+ // Adjust n exponent so it is a multiple of 3 away from x exponent.
+ if (s = (e - n.length + 1) % 3) n += (s == 1 || s == -2 ? '0' : '00');
+ s = Math.pow(n, 1 / 3);
+
+ // Rarely, e may be one less than the result exponent value.
+ e = mathfloor((e + 1) / 3) - (e % 3 == (e < 0 ? -1 : 2));
+
+ if (s == 1 / 0) {
+ n = '5e' + e;
+ } else {
+ n = s.toExponential();
+ n = n.slice(0, n.indexOf('e') + 1) + e;
+ }
+
+ r = new Ctor(n);
+ r.s = x.s;
+ } else {
+ r = new Ctor(s.toString());
+ }
+
+ sd = (e = Ctor.precision) + 3;
+
+ // Halley's method.
+ // TODO? Compare Newton's method.
+ for (;;) {
+ t = r;
+ t3 = t.times(t).times(t);
+ t3plusx = t3.plus(x);
+ r = divide(t3plusx.plus(x).times(t), t3plusx.plus(t3), sd + 2, 1);
+
+ // TODO? Replace with for-loop and checkRoundingDigits.
+ if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
+ n = n.slice(sd - 3, sd + 1);
+
+ // The 4th rounding digit may be in error by -1 so if the 4 rounding digits are 9999 or 4999
+ // , i.e. approaching a rounding boundary, continue the iteration.
+ if (n == '9999' || !rep && n == '4999') {
+
+ // On the first iteration only, check to see if rounding up gives the exact result as the
+ // nines may infinitely repeat.
+ if (!rep) {
+ finalise(t, e + 1, 0);
+
+ if (t.times(t).times(t).eq(x)) {
+ r = t;
+ break;
+ }
+ }
+
+ sd += 4;
+ rep = 1;
+ } else {
+
+ // If the rounding digits are null, 0{0,4} or 50{0,3}, check for an exact result.
+ // If not, then there are further digits and m will be truthy.
+ if (!+n || !+n.slice(1) && n.charAt(0) == '5') {
+
+ // Truncate to the first rounding digit.
+ finalise(r, e + 1, 1);
+ m = !r.times(r).times(r).eq(x);
+ }
+
+ break;
+ }
+ }
+ }
+
+ external = true;
+
+ return finalise(r, e, Ctor.rounding, m);
+ };
+
+
+ /*
+ * Return the number of decimal places of the value of this Decimal.
+ *
+ */
+ P.decimalPlaces = P.dp = function () {
+ var w,
+ d = this.d,
+ n = NaN;
+
+ if (d) {
+ w = d.length - 1;
+ n = (w - mathfloor(this.e / LOG_BASE)) * LOG_BASE;
+
+ // Subtract the number of trailing zeros of the last word.
+ w = d[w];
+ if (w) for (; w % 10 == 0; w /= 10) n--;
+ if (n < 0) n = 0;
+ }
+
+ return n;
+ };
+
+
+ /*
+ * n / 0 = I
+ * n / N = N
+ * n / I = 0
+ * 0 / n = 0
+ * 0 / 0 = N
+ * 0 / N = N
+ * 0 / I = 0
+ * N / n = N
+ * N / 0 = N
+ * N / N = N
+ * N / I = N
+ * I / n = I
+ * I / 0 = I
+ * I / N = N
+ * I / I = N
+ *
+ * Return a new Decimal whose value is the value of this Decimal divided by `y`, rounded to
+ * `precision` significant digits using rounding mode `rounding`.
+ *
+ */
+ P.dividedBy = P.div = function (y) {
+ return divide(this, new this.constructor(y));
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the integer part of dividing the value of this Decimal
+ * by the value of `y`, rounded to `precision` significant digits using rounding mode `rounding`.
+ *
+ */
+ P.dividedToIntegerBy = P.divToInt = function (y) {
+ var x = this,
+ Ctor = x.constructor;
+ return finalise(divide(x, new Ctor(y), 0, 1, 1), Ctor.precision, Ctor.rounding);
+ };
+
+
+ /*
+ * Return true if the value of this Decimal is equal to the value of `y`, otherwise return false.
+ *
+ */
+ P.equals = P.eq = function (y) {
+ return this.cmp(y) === 0;
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the value of this Decimal rounded to a whole number in the
+ * direction of negative Infinity.
+ *
+ */
+ P.floor = function () {
+ return finalise(new this.constructor(this), this.e + 1, 3);
+ };
+
+
+ /*
+ * Return true if the value of this Decimal is greater than the value of `y`, otherwise return
+ * false.
+ *
+ */
+ P.greaterThan = P.gt = function (y) {
+ return this.cmp(y) > 0;
+ };
+
+
+ /*
+ * Return true if the value of this Decimal is greater than or equal to the value of `y`,
+ * otherwise return false.
+ *
+ */
+ P.greaterThanOrEqualTo = P.gte = function (y) {
+ var k = this.cmp(y);
+ return k == 1 || k === 0;
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the hyperbolic cosine of the value in radians of this
+ * Decimal.
+ *
+ * Domain: [-Infinity, Infinity]
+ * Range: [1, Infinity]
+ *
+ * cosh(x) = 1 + x^2/2! + x^4/4! + x^6/6! + ...
+ *
+ * cosh(0) = 1
+ * cosh(-0) = 1
+ * cosh(Infinity) = Infinity
+ * cosh(-Infinity) = Infinity
+ * cosh(NaN) = NaN
+ *
+ * x time taken (ms) result
+ * 1000 9 9.8503555700852349694e+433
+ * 10000 25 4.4034091128314607936e+4342
+ * 100000 171 1.4033316802130615897e+43429
+ * 1000000 3817 1.5166076984010437725e+434294
+ * 10000000 abandoned after 2 minute wait
+ *
+ * TODO? Compare performance of cosh(x) = 0.5 * (exp(x) + exp(-x))
+ *
+ */
+ P.hyperbolicCosine = P.cosh = function () {
+ var k, n, pr, rm, len,
+ x = this,
+ Ctor = x.constructor,
+ one = new Ctor(1);
+
+ if (!x.isFinite()) return new Ctor(x.s ? 1 / 0 : NaN);
+ if (x.isZero()) return one;
+
+ pr = Ctor.precision;
+ rm = Ctor.rounding;
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
+ Ctor.rounding = 1;
+ len = x.d.length;
+
+ // Argument reduction: cos(4x) = 1 - 8cos^2(x) + 8cos^4(x) + 1
+ // i.e. cos(x) = 1 - cos^2(x/4)(8 - 8cos^2(x/4))
+
+ // Estimate the optimum number of times to use the argument reduction.
+ // TODO? Estimation reused from cosine() and may not be optimal here.
+ if (len < 32) {
+ k = Math.ceil(len / 3);
+ n = Math.pow(4, -k).toString();
+ } else {
+ k = 16;
+ n = '2.3283064365386962890625e-10';
+ }
+
+ x = taylorSeries(Ctor, 1, x.times(n), new Ctor(1), true);
+
+ // Reverse argument reduction
+ var cosh2_x,
+ i = k,
+ d8 = new Ctor(8);
+ for (; i--;) {
+ cosh2_x = x.times(x);
+ x = one.minus(cosh2_x.times(d8.minus(cosh2_x.times(d8))));
+ }
+
+ return finalise(x, Ctor.precision = pr, Ctor.rounding = rm, true);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the hyperbolic sine of the value in radians of this
+ * Decimal.
+ *
+ * Domain: [-Infinity, Infinity]
+ * Range: [-Infinity, Infinity]
+ *
+ * sinh(x) = x + x^3/3! + x^5/5! + x^7/7! + ...
+ *
+ * sinh(0) = 0
+ * sinh(-0) = -0
+ * sinh(Infinity) = Infinity
+ * sinh(-Infinity) = -Infinity
+ * sinh(NaN) = NaN
+ *
+ * x time taken (ms)
+ * 10 2 ms
+ * 100 5 ms
+ * 1000 14 ms
+ * 10000 82 ms
+ * 100000 886 ms 1.4033316802130615897e+43429
+ * 200000 2613 ms
+ * 300000 5407 ms
+ * 400000 8824 ms
+ * 500000 13026 ms 8.7080643612718084129e+217146
+ * 1000000 48543 ms
+ *
+ * TODO? Compare performance of sinh(x) = 0.5 * (exp(x) - exp(-x))
+ *
+ */
+ P.hyperbolicSine = P.sinh = function () {
+ var k, pr, rm, len,
+ x = this,
+ Ctor = x.constructor;
+
+ if (!x.isFinite() || x.isZero()) return new Ctor(x);
+
+ pr = Ctor.precision;
+ rm = Ctor.rounding;
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + 4;
+ Ctor.rounding = 1;
+ len = x.d.length;
+
+ if (len < 3) {
+ x = taylorSeries(Ctor, 2, x, x, true);
+ } else {
+
+ // Alternative argument reduction: sinh(3x) = sinh(x)(3 + 4sinh^2(x))
+ // i.e. sinh(x) = sinh(x/3)(3 + 4sinh^2(x/3))
+ // 3 multiplications and 1 addition
+
+ // Argument reduction: sinh(5x) = sinh(x)(5 + sinh^2(x)(20 + 16sinh^2(x)))
+ // i.e. sinh(x) = sinh(x/5)(5 + sinh^2(x/5)(20 + 16sinh^2(x/5)))
+ // 4 multiplications and 2 additions
+
+ // Estimate the optimum number of times to use the argument reduction.
+ k = 1.4 * Math.sqrt(len);
+ k = k > 16 ? 16 : k | 0;
+
+ x = x.times(Math.pow(5, -k));
+
+ x = taylorSeries(Ctor, 2, x, x, true);
+
+ // Reverse argument reduction
+ var sinh2_x,
+ d5 = new Ctor(5),
+ d16 = new Ctor(16),
+ d20 = new Ctor(20);
+ for (; k--;) {
+ sinh2_x = x.times(x);
+ x = x.times(d5.plus(sinh2_x.times(d16.times(sinh2_x).plus(d20))));
+ }
+ }
+
+ Ctor.precision = pr;
+ Ctor.rounding = rm;
+
+ return finalise(x, pr, rm, true);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the hyperbolic tangent of the value in radians of this
+ * Decimal.
+ *
+ * Domain: [-Infinity, Infinity]
+ * Range: [-1, 1]
+ *
+ * tanh(x) = sinh(x) / cosh(x)
+ *
+ * tanh(0) = 0
+ * tanh(-0) = -0
+ * tanh(Infinity) = 1
+ * tanh(-Infinity) = -1
+ * tanh(NaN) = NaN
+ *
+ */
+ P.hyperbolicTangent = P.tanh = function () {
+ var pr, rm,
+ x = this,
+ Ctor = x.constructor;
+
+ if (!x.isFinite()) return new Ctor(x.s);
+ if (x.isZero()) return new Ctor(x);
+
+ pr = Ctor.precision;
+ rm = Ctor.rounding;
+ Ctor.precision = pr + 7;
+ Ctor.rounding = 1;
+
+ return divide(x.sinh(), x.cosh(), Ctor.precision = pr, Ctor.rounding = rm);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the arccosine (inverse cosine) in radians of the value of
+ * this Decimal.
+ *
+ * Domain: [-1, 1]
+ * Range: [0, pi]
+ *
+ * acos(x) = pi/2 - asin(x)
+ *
+ * acos(0) = pi/2
+ * acos(-0) = pi/2
+ * acos(1) = 0
+ * acos(-1) = pi
+ * acos(1/2) = pi/3
+ * acos(-1/2) = 2*pi/3
+ * acos(|x| > 1) = NaN
+ * acos(NaN) = NaN
+ *
+ */
+ P.inverseCosine = P.acos = function () {
+ var halfPi,
+ x = this,
+ Ctor = x.constructor,
+ k = x.abs().cmp(1),
+ pr = Ctor.precision,
+ rm = Ctor.rounding;
+
+ if (k !== -1) {
+ return k === 0
+ // |x| is 1
+ ? x.isNeg() ? getPi(Ctor, pr, rm) : new Ctor(0)
+ // |x| > 1 or x is NaN
+ : new Ctor(NaN);
+ }
+
+ if (x.isZero()) return getPi(Ctor, pr + 4, rm).times(0.5);
+
+ // TODO? Special case acos(0.5) = pi/3 and acos(-0.5) = 2*pi/3
+
+ Ctor.precision = pr + 6;
+ Ctor.rounding = 1;
+
+ x = x.asin();
+ halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
+
+ Ctor.precision = pr;
+ Ctor.rounding = rm;
+
+ return halfPi.minus(x);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the inverse of the hyperbolic cosine in radians of the
+ * value of this Decimal.
+ *
+ * Domain: [1, Infinity]
+ * Range: [0, Infinity]
+ *
+ * acosh(x) = ln(x + sqrt(x^2 - 1))
+ *
+ * acosh(x < 1) = NaN
+ * acosh(NaN) = NaN
+ * acosh(Infinity) = Infinity
+ * acosh(-Infinity) = NaN
+ * acosh(0) = NaN
+ * acosh(-0) = NaN
+ * acosh(1) = 0
+ * acosh(-1) = NaN
+ *
+ */
+ P.inverseHyperbolicCosine = P.acosh = function () {
+ var pr, rm,
+ x = this,
+ Ctor = x.constructor;
+
+ if (x.lte(1)) return new Ctor(x.eq(1) ? 0 : NaN);
+ if (!x.isFinite()) return new Ctor(x);
+
+ pr = Ctor.precision;
+ rm = Ctor.rounding;
+ Ctor.precision = pr + Math.max(Math.abs(x.e), x.sd()) + 4;
+ Ctor.rounding = 1;
+ external = false;
+
+ x = x.times(x).minus(1).sqrt().plus(x);
+
+ external = true;
+ Ctor.precision = pr;
+ Ctor.rounding = rm;
+
+ return x.ln();
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the inverse of the hyperbolic sine in radians of the value
+ * of this Decimal.
+ *
+ * Domain: [-Infinity, Infinity]
+ * Range: [-Infinity, Infinity]
+ *
+ * asinh(x) = ln(x + sqrt(x^2 + 1))
+ *
+ * asinh(NaN) = NaN
+ * asinh(Infinity) = Infinity
+ * asinh(-Infinity) = -Infinity
+ * asinh(0) = 0
+ * asinh(-0) = -0
+ *
+ */
+ P.inverseHyperbolicSine = P.asinh = function () {
+ var pr, rm,
+ x = this,
+ Ctor = x.constructor;
+
+ if (!x.isFinite() || x.isZero()) return new Ctor(x);
+
+ pr = Ctor.precision;
+ rm = Ctor.rounding;
+ Ctor.precision = pr + 2 * Math.max(Math.abs(x.e), x.sd()) + 6;
+ Ctor.rounding = 1;
+ external = false;
+
+ x = x.times(x).plus(1).sqrt().plus(x);
+
+ external = true;
+ Ctor.precision = pr;
+ Ctor.rounding = rm;
+
+ return x.ln();
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the inverse of the hyperbolic tangent in radians of the
+ * value of this Decimal.
+ *
+ * Domain: [-1, 1]
+ * Range: [-Infinity, Infinity]
+ *
+ * atanh(x) = 0.5 * ln((1 + x) / (1 - x))
+ *
+ * atanh(|x| > 1) = NaN
+ * atanh(NaN) = NaN
+ * atanh(Infinity) = NaN
+ * atanh(-Infinity) = NaN
+ * atanh(0) = 0
+ * atanh(-0) = -0
+ * atanh(1) = Infinity
+ * atanh(-1) = -Infinity
+ *
+ */
+ P.inverseHyperbolicTangent = P.atanh = function () {
+ var pr, rm, wpr, xsd,
+ x = this,
+ Ctor = x.constructor;
+
+ if (!x.isFinite()) return new Ctor(NaN);
+ if (x.e >= 0) return new Ctor(x.abs().eq(1) ? x.s / 0 : x.isZero() ? x : NaN);
+
+ pr = Ctor.precision;
+ rm = Ctor.rounding;
+ xsd = x.sd();
+
+ if (Math.max(xsd, pr) < 2 * -x.e - 1) return finalise(new Ctor(x), pr, rm, true);
+
+ Ctor.precision = wpr = xsd - x.e;
+
+ x = divide(x.plus(1), new Ctor(1).minus(x), wpr + pr, 1);
+
+ Ctor.precision = pr + 4;
+ Ctor.rounding = 1;
+
+ x = x.ln();
+
+ Ctor.precision = pr;
+ Ctor.rounding = rm;
+
+ return x.times(0.5);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the arcsine (inverse sine) in radians of the value of this
+ * Decimal.
+ *
+ * Domain: [-Infinity, Infinity]
+ * Range: [-pi/2, pi/2]
+ *
+ * asin(x) = 2*atan(x/(1 + sqrt(1 - x^2)))
+ *
+ * asin(0) = 0
+ * asin(-0) = -0
+ * asin(1/2) = pi/6
+ * asin(-1/2) = -pi/6
+ * asin(1) = pi/2
+ * asin(-1) = -pi/2
+ * asin(|x| > 1) = NaN
+ * asin(NaN) = NaN
+ *
+ * TODO? Compare performance of Taylor series.
+ *
+ */
+ P.inverseSine = P.asin = function () {
+ var halfPi, k,
+ pr, rm,
+ x = this,
+ Ctor = x.constructor;
+
+ if (x.isZero()) return new Ctor(x);
+
+ k = x.abs().cmp(1);
+ pr = Ctor.precision;
+ rm = Ctor.rounding;
+
+ if (k !== -1) {
+
+ // |x| is 1
+ if (k === 0) {
+ halfPi = getPi(Ctor, pr + 4, rm).times(0.5);
+ halfPi.s = x.s;
+ return halfPi;
+ }
+
+ // |x| > 1 or x is NaN
+ return new Ctor(NaN);
+ }
+
+ // TODO? Special case asin(1/2) = pi/6 and asin(-1/2) = -pi/6
+
+ Ctor.precision = pr + 6;
+ Ctor.rounding = 1;
+
+ x = x.div(new Ctor(1).minus(x.times(x)).sqrt().plus(1)).atan();
+
+ Ctor.precision = pr;
+ Ctor.rounding = rm;
+
+ return x.times(2);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the arctangent (inverse tangent) in radians of the value
+ * of this Decimal.
+ *
+ * Domain: [-Infinity, Infinity]
+ * Range: [-pi/2, pi/2]
+ *
+ * atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ...
+ *
+ * atan(0) = 0
+ * atan(-0) = -0
+ * atan(1) = pi/4
+ * atan(-1) = -pi/4
+ * atan(Infinity) = pi/2
+ * atan(-Infinity) = -pi/2
+ * atan(NaN) = NaN
+ *
+ */
+ P.inverseTangent = P.atan = function () {
+ var i, j, k, n, px, t, r, wpr, x2,
+ x = this,
+ Ctor = x.constructor,
+ pr = Ctor.precision,
+ rm = Ctor.rounding;
+
+ if (!x.isFinite()) {
+ if (!x.s) return new Ctor(NaN);
+ if (pr + 4 <= PI_PRECISION) {
+ r = getPi(Ctor, pr + 4, rm).times(0.5);
+ r.s = x.s;
+ return r;
+ }
+ } else if (x.isZero()) {
+ return new Ctor(x);
+ } else if (x.abs().eq(1) && pr + 4 <= PI_PRECISION) {
+ r = getPi(Ctor, pr + 4, rm).times(0.25);
+ r.s = x.s;
+ return r;
+ }
+
+ Ctor.precision = wpr = pr + 10;
+ Ctor.rounding = 1;
+
+ // TODO? if (x >= 1 && pr <= PI_PRECISION) atan(x) = halfPi * x.s - atan(1 / x);
+
+ // Argument reduction
+ // Ensure |x| < 0.42
+ // atan(x) = 2 * atan(x / (1 + sqrt(1 + x^2)))
+
+ k = Math.min(28, wpr / LOG_BASE + 2 | 0);
+
+ for (i = k; i; --i) x = x.div(x.times(x).plus(1).sqrt().plus(1));
+
+ external = false;
+
+ j = Math.ceil(wpr / LOG_BASE);
+ n = 1;
+ x2 = x.times(x);
+ r = new Ctor(x);
+ px = x;
+
+ // atan(x) = x - x^3/3 + x^5/5 - x^7/7 + ...
+ for (; i !== -1;) {
+ px = px.times(x2);
+ t = r.minus(px.div(n += 2));
+
+ px = px.times(x2);
+ r = t.plus(px.div(n += 2));
+
+ if (r.d[j] !== void 0) for (i = j; r.d[i] === t.d[i] && i--;);
+ }
+
+ if (k) r = r.times(2 << (k - 1));
+
+ external = true;
+
+ return finalise(r, Ctor.precision = pr, Ctor.rounding = rm, true);
+ };
+
+
+ /*
+ * Return true if the value of this Decimal is a finite number, otherwise return false.
+ *
+ */
+ P.isFinite = function () {
+ return !!this.d;
+ };
+
+
+ /*
+ * Return true if the value of this Decimal is an integer, otherwise return false.
+ *
+ */
+ P.isInteger = P.isInt = function () {
+ return !!this.d && mathfloor(this.e / LOG_BASE) > this.d.length - 2;
+ };
+
+
+ /*
+ * Return true if the value of this Decimal is NaN, otherwise return false.
+ *
+ */
+ P.isNaN = function () {
+ return !this.s;
+ };
+
+
+ /*
+ * Return true if the value of this Decimal is negative, otherwise return false.
+ *
+ */
+ P.isNegative = P.isNeg = function () {
+ return this.s < 0;
+ };
+
+
+ /*
+ * Return true if the value of this Decimal is positive, otherwise return false.
+ *
+ */
+ P.isPositive = P.isPos = function () {
+ return this.s > 0;
+ };
+
+
+ /*
+ * Return true if the value of this Decimal is 0 or -0, otherwise return false.
+ *
+ */
+ P.isZero = function () {
+ return !!this.d && this.d[0] === 0;
+ };
+
+
+ /*
+ * Return true if the value of this Decimal is less than `y`, otherwise return false.
+ *
+ */
+ P.lessThan = P.lt = function (y) {
+ return this.cmp(y) < 0;
+ };
+
+
+ /*
+ * Return true if the value of this Decimal is less than or equal to `y`, otherwise return false.
+ *
+ */
+ P.lessThanOrEqualTo = P.lte = function (y) {
+ return this.cmp(y) < 1;
+ };
+
+
+ /*
+ * Return the logarithm of the value of this Decimal to the specified base, rounded to `precision`
+ * significant digits using rounding mode `rounding`.
+ *
+ * If no base is specified, return log[10](arg).
+ *
+ * log[base](arg) = ln(arg) / ln(base)
+ *
+ * The result will always be correctly rounded if the base of the log is 10, and 'almost always'
+ * otherwise:
+ *
+ * Depending on the rounding mode, the result may be incorrectly rounded if the first fifteen
+ * rounding digits are [49]99999999999999 or [50]00000000000000. In that case, the maximum error
+ * between the result and the correctly rounded result will be one ulp (unit in the last place).
+ *
+ * log[-b](a) = NaN
+ * log[0](a) = NaN
+ * log[1](a) = NaN
+ * log[NaN](a) = NaN
+ * log[Infinity](a) = NaN
+ * log[b](0) = -Infinity
+ * log[b](-0) = -Infinity
+ * log[b](-a) = NaN
+ * log[b](1) = 0
+ * log[b](Infinity) = Infinity
+ * log[b](NaN) = NaN
+ *
+ * [base] {number|string|Decimal} The base of the logarithm.
+ *
+ */
+ P.logarithm = P.log = function (base) {
+ var isBase10, d, denominator, k, inf, num, sd, r,
+ arg = this,
+ Ctor = arg.constructor,
+ pr = Ctor.precision,
+ rm = Ctor.rounding,
+ guard = 5;
+
+ // Default base is 10.
+ if (base == null) {
+ base = new Ctor(10);
+ isBase10 = true;
+ } else {
+ base = new Ctor(base);
+ d = base.d;
+
+ // Return NaN if base is negative, or non-finite, or is 0 or 1.
+ if (base.s < 0 || !d || !d[0] || base.eq(1)) return new Ctor(NaN);
+
+ isBase10 = base.eq(10);
+ }
+
+ d = arg.d;
+
+ // Is arg negative, non-finite, 0 or 1?
+ if (arg.s < 0 || !d || !d[0] || arg.eq(1)) {
+ return new Ctor(d && !d[0] ? -1 / 0 : arg.s != 1 ? NaN : d ? 0 : 1 / 0);
+ }
+
+ // The result will have a non-terminating decimal expansion if base is 10 and arg is not an
+ // integer power of 10.
+ if (isBase10) {
+ if (d.length > 1) {
+ inf = true;
+ } else {
+ for (k = d[0]; k % 10 === 0;) k /= 10;
+ inf = k !== 1;
+ }
+ }
+
+ external = false;
+ sd = pr + guard;
+ num = naturalLogarithm(arg, sd);
+ denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
+
+ // The result will have 5 rounding digits.
+ r = divide(num, denominator, sd, 1);
+
+ // If at a rounding boundary, i.e. the result's rounding digits are [49]9999 or [50]0000,
+ // calculate 10 further digits.
+ //
+ // If the result is known to have an infinite decimal expansion, repeat this until it is clear
+ // that the result is above or below the boundary. Otherwise, if after calculating the 10
+ // further digits, the last 14 are nines, round up and assume the result is exact.
+ // Also assume the result is exact if the last 14 are zero.
+ //
+ // Example of a result that will be incorrectly rounded:
+ // log[1048576](4503599627370502) = 2.60000000000000009610279511444746...
+ // The above result correctly rounded using ROUND_CEIL to 1 decimal place should be 2.7, but it
+ // will be given as 2.6 as there are 15 zeros immediately after the requested decimal place, so
+ // the exact result would be assumed to be 2.6, which rounded using ROUND_CEIL to 1 decimal
+ // place is still 2.6.
+ if (checkRoundingDigits(r.d, k = pr, rm)) {
+
+ do {
+ sd += 10;
+ num = naturalLogarithm(arg, sd);
+ denominator = isBase10 ? getLn10(Ctor, sd + 10) : naturalLogarithm(base, sd);
+ r = divide(num, denominator, sd, 1);
+
+ if (!inf) {
+
+ // Check for 14 nines from the 2nd rounding digit, as the first may be 4.
+ if (+digitsToString(r.d).slice(k + 1, k + 15) + 1 == 1e14) {
+ r = finalise(r, pr + 1, 0);
+ }
+
+ break;
+ }
+ } while (checkRoundingDigits(r.d, k += 10, rm));
+ }
+
+ external = true;
+
+ return finalise(r, pr, rm);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the maximum of the arguments and the value of this Decimal.
+ *
+ * arguments {number|string|Decimal}
+ *
+ P.max = function () {
+ Array.prototype.push.call(arguments, this);
+ return maxOrMin(this.constructor, arguments, 'lt');
+ };
+ */
+
+
+ /*
+ * Return a new Decimal whose value is the minimum of the arguments and the value of this Decimal.
+ *
+ * arguments {number|string|Decimal}
+ *
+ P.min = function () {
+ Array.prototype.push.call(arguments, this);
+ return maxOrMin(this.constructor, arguments, 'gt');
+ };
+ */
+
+
+ /*
+ * n - 0 = n
+ * n - N = N
+ * n - I = -I
+ * 0 - n = -n
+ * 0 - 0 = 0
+ * 0 - N = N
+ * 0 - I = -I
+ * N - n = N
+ * N - 0 = N
+ * N - N = N
+ * N - I = N
+ * I - n = I
+ * I - 0 = I
+ * I - N = N
+ * I - I = N
+ *
+ * Return a new Decimal whose value is the value of this Decimal minus `y`, rounded to `precision`
+ * significant digits using rounding mode `rounding`.
+ *
+ */
+ P.minus = P.sub = function (y) {
+ var d, e, i, j, k, len, pr, rm, xd, xe, xLTy, yd,
+ x = this,
+ Ctor = x.constructor;
+
+ y = new Ctor(y);
+
+ // If either is not finite...
+ if (!x.d || !y.d) {
+
+ // Return NaN if either is NaN.
+ if (!x.s || !y.s) y = new Ctor(NaN);
+
+ // Return y negated if x is finite and y is ±Infinity.
+ else if (x.d) y.s = -y.s;
+
+ // Return x if y is finite and x is ±Infinity.
+ // Return x if both are ±Infinity with different signs.
+ // Return NaN if both are ±Infinity with the same sign.
+ else y = new Ctor(y.d || x.s !== y.s ? x : NaN);
+
+ return y;
+ }
+
+ // If signs differ...
+ if (x.s != y.s) {
+ y.s = -y.s;
+ return x.plus(y);
+ }
+
+ xd = x.d;
+ yd = y.d;
+ pr = Ctor.precision;
+ rm = Ctor.rounding;
+
+ // If either is zero...
+ if (!xd[0] || !yd[0]) {
+
+ // Return y negated if x is zero and y is non-zero.
+ if (yd[0]) y.s = -y.s;
+
+ // Return x if y is zero and x is non-zero.
+ else if (xd[0]) y = new Ctor(x);
+
+ // Return zero if both are zero.
+ // From IEEE 754 (2008) 6.3: 0 - 0 = -0 - -0 = -0 when rounding to -Infinity.
+ else return new Ctor(rm === 3 ? -0 : 0);
+
+ return external ? finalise(y, pr, rm) : y;
+ }
+
+ // x and y are finite, non-zero numbers with the same sign.
+
+ // Calculate base 1e7 exponents.
+ e = mathfloor(y.e / LOG_BASE);
+ xe = mathfloor(x.e / LOG_BASE);
+
+ xd = xd.slice();
+ k = xe - e;
+
+ // If base 1e7 exponents differ...
+ if (k) {
+ xLTy = k < 0;
+
+ if (xLTy) {
+ d = xd;
+ k = -k;
+ len = yd.length;
+ } else {
+ d = yd;
+ e = xe;
+ len = xd.length;
+ }
+
+ // Numbers with massively different exponents would result in a very high number of
+ // zeros needing to be prepended, but this can be avoided while still ensuring correct
+ // rounding by limiting the number of zeros to `Math.ceil(pr / LOG_BASE) + 2`.
+ i = Math.max(Math.ceil(pr / LOG_BASE), len) + 2;
+
+ if (k > i) {
+ k = i;
+ d.length = 1;
+ }
+
+ // Prepend zeros to equalise exponents.
+ d.reverse();
+ for (i = k; i--;) d.push(0);
+ d.reverse();
+
+ // Base 1e7 exponents equal.
+ } else {
+
+ // Check digits to determine which is the bigger number.
+
+ i = xd.length;
+ len = yd.length;
+ xLTy = i < len;
+ if (xLTy) len = i;
+
+ for (i = 0; i < len; i++) {
+ if (xd[i] != yd[i]) {
+ xLTy = xd[i] < yd[i];
+ break;
+ }
+ }
+
+ k = 0;
+ }
+
+ if (xLTy) {
+ d = xd;
+ xd = yd;
+ yd = d;
+ y.s = -y.s;
+ }
+
+ len = xd.length;
+
+ // Append zeros to `xd` if shorter.
+ // Don't add zeros to `yd` if shorter as subtraction only needs to start at `yd` length.
+ for (i = yd.length - len; i > 0; --i) xd[len++] = 0;
+
+ // Subtract yd from xd.
+ for (i = yd.length; i > k;) {
+
+ if (xd[--i] < yd[i]) {
+ for (j = i; j && xd[--j] === 0;) xd[j] = BASE - 1;
+ --xd[j];
+ xd[i] += BASE;
+ }
+
+ xd[i] -= yd[i];
+ }
+
+ // Remove trailing zeros.
+ for (; xd[--len] === 0;) xd.pop();
+
+ // Remove leading zeros and adjust exponent accordingly.
+ for (; xd[0] === 0; xd.shift()) --e;
+
+ // Zero?
+ if (!xd[0]) return new Ctor(rm === 3 ? -0 : 0);
+
+ y.d = xd;
+ y.e = getBase10Exponent(xd, e);
+
+ return external ? finalise(y, pr, rm) : y;
+ };
+
+
+ /*
+ * n % 0 = N
+ * n % N = N
+ * n % I = n
+ * 0 % n = 0
+ * -0 % n = -0
+ * 0 % 0 = N
+ * 0 % N = N
+ * 0 % I = 0
+ * N % n = N
+ * N % 0 = N
+ * N % N = N
+ * N % I = N
+ * I % n = N
+ * I % 0 = N
+ * I % N = N
+ * I % I = N
+ *
+ * Return a new Decimal whose value is the value of this Decimal modulo `y`, rounded to
+ * `precision` significant digits using rounding mode `rounding`.
+ *
+ * The result depends on the modulo mode.
+ *
+ */
+ P.modulo = P.mod = function (y) {
+ var q,
+ x = this,
+ Ctor = x.constructor;
+
+ y = new Ctor(y);
+
+ // Return NaN if x is ±Infinity or NaN, or y is NaN or ±0.
+ if (!x.d || !y.s || y.d && !y.d[0]) return new Ctor(NaN);
+
+ // Return x if y is ±Infinity or x is ±0.
+ if (!y.d || x.d && !x.d[0]) {
+ return finalise(new Ctor(x), Ctor.precision, Ctor.rounding);
+ }
+
+ // Prevent rounding of intermediate calculations.
+ external = false;
+
+ if (Ctor.modulo == 9) {
+
+ // Euclidian division: q = sign(y) * floor(x / abs(y))
+ // result = x - q * y where 0 <= result < abs(y)
+ q = divide(x, y.abs(), 0, 3, 1);
+ q.s *= y.s;
+ } else {
+ q = divide(x, y, 0, Ctor.modulo, 1);
+ }
+
+ q = q.times(y);
+
+ external = true;
+
+ return x.minus(q);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the natural exponential of the value of this Decimal,
+ * i.e. the base e raised to the power the value of this Decimal, rounded to `precision`
+ * significant digits using rounding mode `rounding`.
+ *
+ */
+ P.naturalExponential = P.exp = function () {
+ return naturalExponential(this);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the natural logarithm of the value of this Decimal,
+ * rounded to `precision` significant digits using rounding mode `rounding`.
+ *
+ */
+ P.naturalLogarithm = P.ln = function () {
+ return naturalLogarithm(this);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the value of this Decimal negated, i.e. as if multiplied by
+ * -1.
+ *
+ */
+ P.negated = P.neg = function () {
+ var x = new this.constructor(this);
+ x.s = -x.s;
+ return finalise(x);
+ };
+
+
+ /*
+ * n + 0 = n
+ * n + N = N
+ * n + I = I
+ * 0 + n = n
+ * 0 + 0 = 0
+ * 0 + N = N
+ * 0 + I = I
+ * N + n = N
+ * N + 0 = N
+ * N + N = N
+ * N + I = N
+ * I + n = I
+ * I + 0 = I
+ * I + N = N
+ * I + I = I
+ *
+ * Return a new Decimal whose value is the value of this Decimal plus `y`, rounded to `precision`
+ * significant digits using rounding mode `rounding`.
+ *
+ */
+ P.plus = P.add = function (y) {
+ var carry, d, e, i, k, len, pr, rm, xd, yd,
+ x = this,
+ Ctor = x.constructor;
+
+ y = new Ctor(y);
+
+ // If either is not finite...
+ if (!x.d || !y.d) {
+
+ // Return NaN if either is NaN.
+ if (!x.s || !y.s) y = new Ctor(NaN);
+
+ // Return x if y is finite and x is ±Infinity.
+ // Return x if both are ±Infinity with the same sign.
+ // Return NaN if both are ±Infinity with different signs.
+ // Return y if x is finite and y is ±Infinity.
+ else if (!x.d) y = new Ctor(y.d || x.s === y.s ? x : NaN);
+
+ return y;
+ }
+
+ // If signs differ...
+ if (x.s != y.s) {
+ y.s = -y.s;
+ return x.minus(y);
+ }
+
+ xd = x.d;
+ yd = y.d;
+ pr = Ctor.precision;
+ rm = Ctor.rounding;
+
+ // If either is zero...
+ if (!xd[0] || !yd[0]) {
+
+ // Return x if y is zero.
+ // Return y if y is non-zero.
+ if (!yd[0]) y = new Ctor(x);
+
+ return external ? finalise(y, pr, rm) : y;
+ }
+
+ // x and y are finite, non-zero numbers with the same sign.
+
+ // Calculate base 1e7 exponents.
+ k = mathfloor(x.e / LOG_BASE);
+ e = mathfloor(y.e / LOG_BASE);
+
+ xd = xd.slice();
+ i = k - e;
+
+ // If base 1e7 exponents differ...
+ if (i) {
+
+ if (i < 0) {
+ d = xd;
+ i = -i;
+ len = yd.length;
+ } else {
+ d = yd;
+ e = k;
+ len = xd.length;
+ }
+
+ // Limit number of zeros prepended to max(ceil(pr / LOG_BASE), len) + 1.
+ k = Math.ceil(pr / LOG_BASE);
+ len = k > len ? k + 1 : len + 1;
+
+ if (i > len) {
+ i = len;
+ d.length = 1;
+ }
+
+ // Prepend zeros to equalise exponents. Note: Faster to use reverse then do unshifts.
+ d.reverse();
+ for (; i--;) d.push(0);
+ d.reverse();
+ }
+
+ len = xd.length;
+ i = yd.length;
+
+ // If yd is longer than xd, swap xd and yd so xd points to the longer array.
+ if (len - i < 0) {
+ i = len;
+ d = yd;
+ yd = xd;
+ xd = d;
+ }
+
+ // Only start adding at yd.length - 1 as the further digits of xd can be left as they are.
+ for (carry = 0; i;) {
+ carry = (xd[--i] = xd[i] + yd[i] + carry) / BASE | 0;
+ xd[i] %= BASE;
+ }
+
+ if (carry) {
+ xd.unshift(carry);
+ ++e;
+ }
+
+ // Remove trailing zeros.
+ // No need to check for zero, as +x + +y != 0 && -x + -y != 0
+ for (len = xd.length; xd[--len] == 0;) xd.pop();
+
+ y.d = xd;
+ y.e = getBase10Exponent(xd, e);
+
+ return external ? finalise(y, pr, rm) : y;
+ };
+
+
+ /*
+ * Return the number of significant digits of the value of this Decimal.
+ *
+ * [z] {boolean|number} Whether to count integer-part trailing zeros: true, false, 1 or 0.
+ *
+ */
+ P.precision = P.sd = function (z) {
+ var k,
+ x = this;
+
+ if (z !== void 0 && z !== !!z && z !== 1 && z !== 0) throw Error(invalidArgument + z);
+
+ if (x.d) {
+ k = getPrecision(x.d);
+ if (z && x.e + 1 > k) k = x.e + 1;
+ } else {
+ k = NaN;
+ }
+
+ return k;
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the value of this Decimal rounded to a whole number using
+ * rounding mode `rounding`.
+ *
+ */
+ P.round = function () {
+ var x = this,
+ Ctor = x.constructor;
+
+ return finalise(new Ctor(x), x.e + 1, Ctor.rounding);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the sine of the value in radians of this Decimal.
+ *
+ * Domain: [-Infinity, Infinity]
+ * Range: [-1, 1]
+ *
+ * sin(x) = x - x^3/3! + x^5/5! - ...
+ *
+ * sin(0) = 0
+ * sin(-0) = -0
+ * sin(Infinity) = NaN
+ * sin(-Infinity) = NaN
+ * sin(NaN) = NaN
+ *
+ */
+ P.sine = P.sin = function () {
+ var pr, rm,
+ x = this,
+ Ctor = x.constructor;
+
+ if (!x.isFinite()) return new Ctor(NaN);
+ if (x.isZero()) return new Ctor(x);
+
+ pr = Ctor.precision;
+ rm = Ctor.rounding;
+ Ctor.precision = pr + Math.max(x.e, x.sd()) + LOG_BASE;
+ Ctor.rounding = 1;
+
+ x = sine(Ctor, toLessThanHalfPi(Ctor, x));
+
+ Ctor.precision = pr;
+ Ctor.rounding = rm;
+
+ return finalise(quadrant > 2 ? x.neg() : x, pr, rm, true);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the square root of this Decimal, rounded to `precision`
+ * significant digits using rounding mode `rounding`.
+ *
+ * sqrt(-n) = N
+ * sqrt(N) = N
+ * sqrt(-I) = N
+ * sqrt(I) = I
+ * sqrt(0) = 0
+ * sqrt(-0) = -0
+ *
+ */
+ P.squareRoot = P.sqrt = function () {
+ var m, n, sd, r, rep, t,
+ x = this,
+ d = x.d,
+ e = x.e,
+ s = x.s,
+ Ctor = x.constructor;
+
+ // Negative/NaN/Infinity/zero?
+ if (s !== 1 || !d || !d[0]) {
+ return new Ctor(!s || s < 0 && (!d || d[0]) ? NaN : d ? x : 1 / 0);
+ }
+
+ external = false;
+
+ // Initial estimate.
+ s = Math.sqrt(+x);
+
+ // Math.sqrt underflow/overflow?
+ // Pass x to Math.sqrt as integer, then adjust the exponent of the result.
+ if (s == 0 || s == 1 / 0) {
+ n = digitsToString(d);
+
+ if ((n.length + e) % 2 == 0) n += '0';
+ s = Math.sqrt(n);
+ e = mathfloor((e + 1) / 2) - (e < 0 || e % 2);
+
+ if (s == 1 / 0) {
+ n = '1e' + e;
+ } else {
+ n = s.toExponential();
+ n = n.slice(0, n.indexOf('e') + 1) + e;
+ }
+
+ r = new Ctor(n);
+ } else {
+ r = new Ctor(s.toString());
+ }
+
+ sd = (e = Ctor.precision) + 3;
+
+ // Newton-Raphson iteration.
+ for (;;) {
+ t = r;
+ r = t.plus(divide(x, t, sd + 2, 1)).times(0.5);
+
+ // TODO? Replace with for-loop and checkRoundingDigits.
+ if (digitsToString(t.d).slice(0, sd) === (n = digitsToString(r.d)).slice(0, sd)) {
+ n = n.slice(sd - 3, sd + 1);
+
+ // The 4th rounding digit may be in error by -1 so if the 4 rounding digits are 9999 or
+ // 4999, i.e. approaching a rounding boundary, continue the iteration.
+ if (n == '9999' || !rep && n == '4999') {
+
+ // On the first iteration only, check to see if rounding up gives the exact result as the
+ // nines may infinitely repeat.
+ if (!rep) {
+ finalise(t, e + 1, 0);
+
+ if (t.times(t).eq(x)) {
+ r = t;
+ break;
+ }
+ }
+
+ sd += 4;
+ rep = 1;
+ } else {
+
+ // If the rounding digits are null, 0{0,4} or 50{0,3}, check for an exact result.
+ // If not, then there are further digits and m will be truthy.
+ if (!+n || !+n.slice(1) && n.charAt(0) == '5') {
+
+ // Truncate to the first rounding digit.
+ finalise(r, e + 1, 1);
+ m = !r.times(r).eq(x);
+ }
+
+ break;
+ }
+ }
+ }
+
+ external = true;
+
+ return finalise(r, e, Ctor.rounding, m);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the tangent of the value in radians of this Decimal.
+ *
+ * Domain: [-Infinity, Infinity]
+ * Range: [-Infinity, Infinity]
+ *
+ * tan(0) = 0
+ * tan(-0) = -0
+ * tan(Infinity) = NaN
+ * tan(-Infinity) = NaN
+ * tan(NaN) = NaN
+ *
+ */
+ P.tangent = P.tan = function () {
+ var pr, rm,
+ x = this,
+ Ctor = x.constructor;
+
+ if (!x.isFinite()) return new Ctor(NaN);
+ if (x.isZero()) return new Ctor(x);
+
+ pr = Ctor.precision;
+ rm = Ctor.rounding;
+ Ctor.precision = pr + 10;
+ Ctor.rounding = 1;
+
+ x = x.sin();
+ x.s = 1;
+ x = divide(x, new Ctor(1).minus(x.times(x)).sqrt(), pr + 10, 0);
+
+ Ctor.precision = pr;
+ Ctor.rounding = rm;
+
+ return finalise(quadrant == 2 || quadrant == 4 ? x.neg() : x, pr, rm, true);
+ };
+
+
+ /*
+ * n * 0 = 0
+ * n * N = N
+ * n * I = I
+ * 0 * n = 0
+ * 0 * 0 = 0
+ * 0 * N = N
+ * 0 * I = N
+ * N * n = N
+ * N * 0 = N
+ * N * N = N
+ * N * I = N
+ * I * n = I
+ * I * 0 = N
+ * I * N = N
+ * I * I = I
+ *
+ * Return a new Decimal whose value is this Decimal times `y`, rounded to `precision` significant
+ * digits using rounding mode `rounding`.
+ *
+ */
+ P.times = P.mul = function (y) {
+ var carry, e, i, k, r, rL, t, xdL, ydL,
+ x = this,
+ Ctor = x.constructor,
+ xd = x.d,
+ yd = (y = new Ctor(y)).d;
+
+ y.s *= x.s;
+
+ // If either is NaN, ±Infinity or ±0...
+ if (!xd || !xd[0] || !yd || !yd[0]) {
+
+ return new Ctor(!y.s || xd && !xd[0] && !yd || yd && !yd[0] && !xd
+
+ // Return NaN if either is NaN.
+ // Return NaN if x is ±0 and y is ±Infinity, or y is ±0 and x is ±Infinity.
+ ? NaN
+
+ // Return ±Infinity if either is ±Infinity.
+ // Return ±0 if either is ±0.
+ : !xd || !yd ? y.s / 0 : y.s * 0);
+ }
+
+ e = mathfloor(x.e / LOG_BASE) + mathfloor(y.e / LOG_BASE);
+ xdL = xd.length;
+ ydL = yd.length;
+
+ // Ensure xd points to the longer array.
+ if (xdL < ydL) {
+ r = xd;
+ xd = yd;
+ yd = r;
+ rL = xdL;
+ xdL = ydL;
+ ydL = rL;
+ }
+
+ // Initialise the result array with zeros.
+ r = [];
+ rL = xdL + ydL;
+ for (i = rL; i--;) r.push(0);
+
+ // Multiply!
+ for (i = ydL; --i >= 0;) {
+ carry = 0;
+ for (k = xdL + i; k > i;) {
+ t = r[k] + yd[i] * xd[k - i - 1] + carry;
+ r[k--] = t % BASE | 0;
+ carry = t / BASE | 0;
+ }
+
+ r[k] = (r[k] + carry) % BASE | 0;
+ }
+
+ // Remove trailing zeros.
+ for (; !r[--rL];) r.pop();
+
+ if (carry) ++e;
+ else r.shift();
+
+ y.d = r;
+ y.e = getBase10Exponent(r, e);
+
+ return external ? finalise(y, Ctor.precision, Ctor.rounding) : y;
+ };
+
+
+ /*
+ * Return a string representing the value of this Decimal in base 2, round to `sd` significant
+ * digits using rounding mode `rm`.
+ *
+ * If the optional `sd` argument is present then return binary exponential notation.
+ *
+ * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ */
+ P.toBinary = function (sd, rm) {
+ return toStringBinary(this, 2, sd, rm);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `dp`
+ * decimal places using rounding mode `rm` or `rounding` if `rm` is omitted.
+ *
+ * If `dp` is omitted, return a new Decimal whose value is the value of this Decimal.
+ *
+ * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ */
+ P.toDecimalPlaces = P.toDP = function (dp, rm) {
+ var x = this,
+ Ctor = x.constructor;
+
+ x = new Ctor(x);
+ if (dp === void 0) return x;
+
+ checkInt32(dp, 0, MAX_DIGITS);
+
+ if (rm === void 0) rm = Ctor.rounding;
+ else checkInt32(rm, 0, 8);
+
+ return finalise(x, dp + x.e + 1, rm);
+ };
+
+
+ /*
+ * Return a string representing the value of this Decimal in exponential notation rounded to
+ * `dp` fixed decimal places using rounding mode `rounding`.
+ *
+ * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ */
+ P.toExponential = function (dp, rm) {
+ var str,
+ x = this,
+ Ctor = x.constructor;
+
+ if (dp === void 0) {
+ str = finiteToString(x, true);
+ } else {
+ checkInt32(dp, 0, MAX_DIGITS);
+
+ if (rm === void 0) rm = Ctor.rounding;
+ else checkInt32(rm, 0, 8);
+
+ x = finalise(new Ctor(x), dp + 1, rm);
+ str = finiteToString(x, true, dp + 1);
+ }
+
+ return x.isNeg() && !x.isZero() ? '-' + str : str;
+ };
+
+
+ /*
+ * Return a string representing the value of this Decimal in normal (fixed-point) notation to
+ * `dp` fixed decimal places and rounded using rounding mode `rm` or `rounding` if `rm` is
+ * omitted.
+ *
+ * As with JavaScript numbers, (-0).toFixed(0) is '0', but e.g. (-0.00001).toFixed(0) is '-0'.
+ *
+ * [dp] {number} Decimal places. Integer, 0 to MAX_DIGITS inclusive.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ * (-0).toFixed(0) is '0', but (-0.1).toFixed(0) is '-0'.
+ * (-0).toFixed(1) is '0.0', but (-0.01).toFixed(1) is '-0.0'.
+ * (-0).toFixed(3) is '0.000'.
+ * (-0.5).toFixed(0) is '-0'.
+ *
+ */
+ P.toFixed = function (dp, rm) {
+ var str, y,
+ x = this,
+ Ctor = x.constructor;
+
+ if (dp === void 0) {
+ str = finiteToString(x);
+ } else {
+ checkInt32(dp, 0, MAX_DIGITS);
+
+ if (rm === void 0) rm = Ctor.rounding;
+ else checkInt32(rm, 0, 8);
+
+ y = finalise(new Ctor(x), dp + x.e + 1, rm);
+ str = finiteToString(y, false, dp + y.e + 1);
+ }
+
+ // To determine whether to add the minus sign look at the value before it was rounded,
+ // i.e. look at `x` rather than `y`.
+ return x.isNeg() && !x.isZero() ? '-' + str : str;
+ };
+
+
+ /*
+ * Return an array representing the value of this Decimal as a simple fraction with an integer
+ * numerator and an integer denominator.
+ *
+ * The denominator will be a positive non-zero value less than or equal to the specified maximum
+ * denominator. If a maximum denominator is not specified, the denominator will be the lowest
+ * value necessary to represent the number exactly.
+ *
+ * [maxD] {number|string|Decimal} Maximum denominator. Integer >= 1 and < Infinity.
+ *
+ */
+ P.toFraction = function (maxD) {
+ var d, d0, d1, d2, e, k, n, n0, n1, pr, q, r,
+ x = this,
+ xd = x.d,
+ Ctor = x.constructor;
+
+ if (!xd) return new Ctor(x);
+
+ n1 = d0 = new Ctor(1);
+ d1 = n0 = new Ctor(0);
+
+ d = new Ctor(d1);
+ e = d.e = getPrecision(xd) - x.e - 1;
+ k = e % LOG_BASE;
+ d.d[0] = mathpow(10, k < 0 ? LOG_BASE + k : k);
+
+ if (maxD == null) {
+
+ // d is 10**e, the minimum max-denominator needed.
+ maxD = e > 0 ? d : n1;
+ } else {
+ n = new Ctor(maxD);
+ if (!n.isInt() || n.lt(n1)) throw Error(invalidArgument + n);
+ maxD = n.gt(d) ? (e > 0 ? d : n1) : n;
+ }
+
+ external = false;
+ n = new Ctor(digitsToString(xd));
+ pr = Ctor.precision;
+ Ctor.precision = e = xd.length * LOG_BASE * 2;
+
+ for (;;) {
+ q = divide(n, d, 0, 1, 1);
+ d2 = d0.plus(q.times(d1));
+ if (d2.cmp(maxD) == 1) break;
+ d0 = d1;
+ d1 = d2;
+ d2 = n1;
+ n1 = n0.plus(q.times(d2));
+ n0 = d2;
+ d2 = d;
+ d = n.minus(q.times(d2));
+ n = d2;
+ }
+
+ d2 = divide(maxD.minus(d0), d1, 0, 1, 1);
+ n0 = n0.plus(d2.times(n1));
+ d0 = d0.plus(d2.times(d1));
+ n0.s = n1.s = x.s;
+
+ // Determine which fraction is closer to x, n0/d0 or n1/d1?
+ r = divide(n1, d1, e, 1).minus(x).abs().cmp(divide(n0, d0, e, 1).minus(x).abs()) < 1
+ ? [n1, d1] : [n0, d0];
+
+ Ctor.precision = pr;
+ external = true;
+
+ return r;
+ };
+
+
+ /*
+ * Return a string representing the value of this Decimal in base 16, round to `sd` significant
+ * digits using rounding mode `rm`.
+ *
+ * If the optional `sd` argument is present then return binary exponential notation.
+ *
+ * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ */
+ P.toHexadecimal = P.toHex = function (sd, rm) {
+ return toStringBinary(this, 16, sd, rm);
+ };
+
+
+
+ /*
+ * Returns a new Decimal whose value is the nearest multiple of the magnitude of `y` to the value
+ * of this Decimal.
+ *
+ * If the value of this Decimal is equidistant from two multiples of `y`, the rounding mode `rm`,
+ * or `Decimal.rounding` if `rm` is omitted, determines the direction of the nearest multiple.
+ *
+ * In the context of this method, rounding mode 4 (ROUND_HALF_UP) is the same as rounding mode 0
+ * (ROUND_UP), and so on.
+ *
+ * The return value will always have the same sign as this Decimal, unless either this Decimal
+ * or `y` is NaN, in which case the return value will be also be NaN.
+ *
+ * The return value is not affected by the value of `precision`.
+ *
+ * y {number|string|Decimal} The magnitude to round to a multiple of.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ * 'toNearest() rounding mode not an integer: {rm}'
+ * 'toNearest() rounding mode out of range: {rm}'
+ *
+ */
+ P.toNearest = function (y, rm) {
+ var x = this,
+ Ctor = x.constructor;
+
+ x = new Ctor(x);
+
+ if (y == null) {
+
+ // If x is not finite, return x.
+ if (!x.d) return x;
+
+ y = new Ctor(1);
+ rm = Ctor.rounding;
+ } else {
+ y = new Ctor(y);
+ if (rm !== void 0) checkInt32(rm, 0, 8);
+
+ // If x is not finite, return x if y is not NaN, else NaN.
+ if (!x.d) return y.s ? x : y;
+
+ // If y is not finite, return Infinity with the sign of x if y is Infinity, else NaN.
+ if (!y.d) {
+ if (y.s) y.s = x.s;
+ return y;
+ }
+ }
+
+ // If y is not zero, calculate the nearest multiple of y to x.
+ if (y.d[0]) {
+ external = false;
+ if (rm < 4) rm = [4, 5, 7, 8][rm];
+ x = divide(x, y, 0, rm, 1).times(y);
+ external = true;
+ finalise(x);
+
+ // If y is zero, return zero with the sign of x.
+ } else {
+ y.s = x.s;
+ x = y;
+ }
+
+ return x;
+ };
+
+
+ /*
+ * Return the value of this Decimal converted to a number primitive.
+ * Zero keeps its sign.
+ *
+ */
+ P.toNumber = function () {
+ return +this;
+ };
+
+
+ /*
+ * Return a string representing the value of this Decimal in base 8, round to `sd` significant
+ * digits using rounding mode `rm`.
+ *
+ * If the optional `sd` argument is present then return binary exponential notation.
+ *
+ * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ */
+ P.toOctal = function (sd, rm) {
+ return toStringBinary(this, 8, sd, rm);
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the value of this Decimal raised to the power `y`, rounded
+ * to `precision` significant digits using rounding mode `rounding`.
+ *
+ * ECMAScript compliant.
+ *
+ * pow(x, NaN) = NaN
+ * pow(x, ±0) = 1
+
+ * pow(NaN, non-zero) = NaN
+ * pow(abs(x) > 1, +Infinity) = +Infinity
+ * pow(abs(x) > 1, -Infinity) = +0
+ * pow(abs(x) == 1, ±Infinity) = NaN
+ * pow(abs(x) < 1, +Infinity) = +0
+ * pow(abs(x) < 1, -Infinity) = +Infinity
+ * pow(+Infinity, y > 0) = +Infinity
+ * pow(+Infinity, y < 0) = +0
+ * pow(-Infinity, odd integer > 0) = -Infinity
+ * pow(-Infinity, even integer > 0) = +Infinity
+ * pow(-Infinity, odd integer < 0) = -0
+ * pow(-Infinity, even integer < 0) = +0
+ * pow(+0, y > 0) = +0
+ * pow(+0, y < 0) = +Infinity
+ * pow(-0, odd integer > 0) = -0
+ * pow(-0, even integer > 0) = +0
+ * pow(-0, odd integer < 0) = -Infinity
+ * pow(-0, even integer < 0) = +Infinity
+ * pow(finite x < 0, finite non-integer) = NaN
+ *
+ * For non-integer or very large exponents pow(x, y) is calculated using
+ *
+ * x^y = exp(y*ln(x))
+ *
+ * Assuming the first 15 rounding digits are each equally likely to be any digit 0-9, the
+ * probability of an incorrectly rounded result
+ * P([49]9{14} | [50]0{14}) = 2 * 0.2 * 10^-14 = 4e-15 = 1/2.5e+14
+ * i.e. 1 in 250,000,000,000,000
+ *
+ * If a result is incorrectly rounded the maximum error will be 1 ulp (unit in last place).
+ *
+ * y {number|string|Decimal} The power to which to raise this Decimal.
+ *
+ */
+ P.toPower = P.pow = function (y) {
+ var e, k, pr, r, rm, s,
+ x = this,
+ Ctor = x.constructor,
+ yn = +(y = new Ctor(y));
+
+ // Either ±Infinity, NaN or ±0?
+ if (!x.d || !y.d || !x.d[0] || !y.d[0]) return new Ctor(mathpow(+x, yn));
+
+ x = new Ctor(x);
+
+ if (x.eq(1)) return x;
+
+ pr = Ctor.precision;
+ rm = Ctor.rounding;
+
+ if (y.eq(1)) return finalise(x, pr, rm);
+
+ // y exponent
+ e = mathfloor(y.e / LOG_BASE);
+
+ // If y is a small integer use the 'exponentiation by squaring' algorithm.
+ if (e >= y.d.length - 1 && (k = yn < 0 ? -yn : yn) <= MAX_SAFE_INTEGER) {
+ r = intPow(Ctor, x, k, pr);
+ return y.s < 0 ? new Ctor(1).div(r) : finalise(r, pr, rm);
+ }
+
+ s = x.s;
+
+ // if x is negative
+ if (s < 0) {
+
+ // if y is not an integer
+ if (e < y.d.length - 1) return new Ctor(NaN);
+
+ // Result is positive if x is negative and the last digit of integer y is even.
+ if ((y.d[e] & 1) == 0) s = 1;
+
+ // if x.eq(-1)
+ if (x.e == 0 && x.d[0] == 1 && x.d.length == 1) {
+ x.s = s;
+ return x;
+ }
+ }
+
+ // Estimate result exponent.
+ // x^y = 10^e, where e = y * log10(x)
+ // log10(x) = log10(x_significand) + x_exponent
+ // log10(x_significand) = ln(x_significand) / ln(10)
+ k = mathpow(+x, yn);
+ e = k == 0 || !isFinite(k)
+ ? mathfloor(yn * (Math.log('0.' + digitsToString(x.d)) / Math.LN10 + x.e + 1))
+ : new Ctor(k + '').e;
+
+ // Exponent estimate may be incorrect e.g. x: 0.999999999999999999, y: 2.29, e: 0, r.e: -1.
+
+ // Overflow/underflow?
+ if (e > Ctor.maxE + 1 || e < Ctor.minE - 1) return new Ctor(e > 0 ? s / 0 : 0);
+
+ external = false;
+ Ctor.rounding = x.s = 1;
+
+ // Estimate the extra guard digits needed to ensure five correct rounding digits from
+ // naturalLogarithm(x). Example of failure without these extra digits (precision: 10):
+ // new Decimal(2.32456).pow('2087987436534566.46411')
+ // should be 1.162377823e+764914905173815, but is 1.162355823e+764914905173815
+ k = Math.min(12, (e + '').length);
+
+ // r = x^y = exp(y*ln(x))
+ r = naturalExponential(y.times(naturalLogarithm(x, pr + k)), pr);
+
+ // r may be Infinity, e.g. (0.9999999999999999).pow(-1e+40)
+ if (r.d) {
+
+ // Truncate to the required precision plus five rounding digits.
+ r = finalise(r, pr + 5, 1);
+
+ // If the rounding digits are [49]9999 or [50]0000 increase the precision by 10 and recalculate
+ // the result.
+ if (checkRoundingDigits(r.d, pr, rm)) {
+ e = pr + 10;
+
+ // Truncate to the increased precision plus five rounding digits.
+ r = finalise(naturalExponential(y.times(naturalLogarithm(x, e + k)), e), e + 5, 1);
+
+ // Check for 14 nines from the 2nd rounding digit (the first rounding digit may be 4 or 9).
+ if (+digitsToString(r.d).slice(pr + 1, pr + 15) + 1 == 1e14) {
+ r = finalise(r, pr + 1, 0);
+ }
+ }
+ }
+
+ r.s = s;
+ external = true;
+ Ctor.rounding = rm;
+
+ return finalise(r, pr, rm);
+ };
+
+
+ /*
+ * Return a string representing the value of this Decimal rounded to `sd` significant digits
+ * using rounding mode `rounding`.
+ *
+ * Return exponential notation if `sd` is less than the number of digits necessary to represent
+ * the integer part of the value in normal notation.
+ *
+ * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ */
+ P.toPrecision = function (sd, rm) {
+ var str,
+ x = this,
+ Ctor = x.constructor;
+
+ if (sd === void 0) {
+ str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
+ } else {
+ checkInt32(sd, 1, MAX_DIGITS);
+
+ if (rm === void 0) rm = Ctor.rounding;
+ else checkInt32(rm, 0, 8);
+
+ x = finalise(new Ctor(x), sd, rm);
+ str = finiteToString(x, sd <= x.e || x.e <= Ctor.toExpNeg, sd);
+ }
+
+ return x.isNeg() && !x.isZero() ? '-' + str : str;
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the value of this Decimal rounded to a maximum of `sd`
+ * significant digits using rounding mode `rm`, or to `precision` and `rounding` respectively if
+ * omitted.
+ *
+ * [sd] {number} Significant digits. Integer, 1 to MAX_DIGITS inclusive.
+ * [rm] {number} Rounding mode. Integer, 0 to 8 inclusive.
+ *
+ * 'toSD() digits out of range: {sd}'
+ * 'toSD() digits not an integer: {sd}'
+ * 'toSD() rounding mode not an integer: {rm}'
+ * 'toSD() rounding mode out of range: {rm}'
+ *
+ */
+ P.toSignificantDigits = P.toSD = function (sd, rm) {
+ var x = this,
+ Ctor = x.constructor;
+
+ if (sd === void 0) {
+ sd = Ctor.precision;
+ rm = Ctor.rounding;
+ } else {
+ checkInt32(sd, 1, MAX_DIGITS);
+
+ if (rm === void 0) rm = Ctor.rounding;
+ else checkInt32(rm, 0, 8);
+ }
+
+ return finalise(new Ctor(x), sd, rm);
+ };
+
+
+ /*
+ * Return a string representing the value of this Decimal.
+ *
+ * Return exponential notation if this Decimal has a positive exponent equal to or greater than
+ * `toExpPos`, or a negative exponent equal to or less than `toExpNeg`.
+ *
+ */
+ P.toString = function () {
+ var x = this,
+ Ctor = x.constructor,
+ str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
+
+ return x.isNeg() && !x.isZero() ? '-' + str : str;
+ };
+
+
+ /*
+ * Return a new Decimal whose value is the value of this Decimal truncated to a whole number.
+ *
+ */
+ P.truncated = P.trunc = function () {
+ return finalise(new this.constructor(this), this.e + 1, 1);
+ };
+
+
+ /*
+ * Return a string representing the value of this Decimal.
+ * Unlike `toString`, negative zero will include the minus sign.
+ *
+ */
+ P.valueOf = P.toJSON = function () {
+ var x = this,
+ Ctor = x.constructor,
+ str = finiteToString(x, x.e <= Ctor.toExpNeg || x.e >= Ctor.toExpPos);
+
+ return x.isNeg() ? '-' + str : str;
+ };
+
+
+ /*
+ // Add aliases to match BigDecimal method names.
+ // P.add = P.plus;
+ P.subtract = P.minus;
+ P.multiply = P.times;
+ P.divide = P.div;
+ P.remainder = P.mod;
+ P.compareTo = P.cmp;
+ P.negate = P.neg;
+ */
+
+
+ // Helper functions for Decimal.prototype (P) and/or Decimal methods, and their callers.
+
+
+ /*
+ * digitsToString P.cubeRoot, P.logarithm, P.squareRoot, P.toFraction, P.toPower,
+ * finiteToString, naturalExponential, naturalLogarithm
+ * checkInt32 P.toDecimalPlaces, P.toExponential, P.toFixed, P.toNearest,
+ * P.toPrecision, P.toSignificantDigits, toStringBinary, random
+ * checkRoundingDigits P.logarithm, P.toPower, naturalExponential, naturalLogarithm
+ * convertBase toStringBinary, parseOther
+ * cos P.cos
+ * divide P.atanh, P.cubeRoot, P.dividedBy, P.dividedToIntegerBy,
+ * P.logarithm, P.modulo, P.squareRoot, P.tan, P.tanh, P.toFraction,
+ * P.toNearest, toStringBinary, naturalExponential, naturalLogarithm,
+ * taylorSeries, atan2, parseOther
+ * finalise P.absoluteValue, P.atan, P.atanh, P.ceil, P.cos, P.cosh,
+ * P.cubeRoot, P.dividedToIntegerBy, P.floor, P.logarithm, P.minus,
+ * P.modulo, P.negated, P.plus, P.round, P.sin, P.sinh, P.squareRoot,
+ * P.tan, P.times, P.toDecimalPlaces, P.toExponential, P.toFixed,
+ * P.toNearest, P.toPower, P.toPrecision, P.toSignificantDigits,
+ * P.truncated, divide, getLn10, getPi, naturalExponential,
+ * naturalLogarithm, ceil, floor, round, trunc
+ * finiteToString P.toExponential, P.toFixed, P.toPrecision, P.toString, P.valueOf,
+ * toStringBinary
+ * getBase10Exponent P.minus, P.plus, P.times, parseOther
+ * getLn10 P.logarithm, naturalLogarithm
+ * getPi P.acos, P.asin, P.atan, toLessThanHalfPi, atan2
+ * getPrecision P.precision, P.toFraction
+ * getZeroString digitsToString, finiteToString
+ * intPow P.toPower, parseOther
+ * isOdd toLessThanHalfPi
+ * maxOrMin max, min
+ * naturalExponential P.naturalExponential, P.toPower
+ * naturalLogarithm P.acosh, P.asinh, P.atanh, P.logarithm, P.naturalLogarithm,
+ * P.toPower, naturalExponential
+ * nonFiniteToString finiteToString, toStringBinary
+ * parseDecimal Decimal
+ * parseOther Decimal
+ * sin P.sin
+ * taylorSeries P.cosh, P.sinh, cos, sin
+ * toLessThanHalfPi P.cos, P.sin
+ * toStringBinary P.toBinary, P.toHexadecimal, P.toOctal
+ * truncate intPow
+ *
+ * Throws: P.logarithm, P.precision, P.toFraction, checkInt32, getLn10, getPi,
+ * naturalLogarithm, config, parseOther, random, Decimal
+ */
+
+
+ function digitsToString(d) {
+ var i, k, ws,
+ indexOfLastWord = d.length - 1,
+ str = '',
+ w = d[0];
+
+ if (indexOfLastWord > 0) {
+ str += w;
+ for (i = 1; i < indexOfLastWord; i++) {
+ ws = d[i] + '';
+ k = LOG_BASE - ws.length;
+ if (k) str += getZeroString(k);
+ str += ws;
+ }
+
+ w = d[i];
+ ws = w + '';
+ k = LOG_BASE - ws.length;
+ if (k) str += getZeroString(k);
+ } else if (w === 0) {
+ return '0';
+ }
+
+ // Remove trailing zeros of last w.
+ for (; w % 10 === 0;) w /= 10;
+
+ return str + w;
+ }
+
+
+ function checkInt32(i, min, max) {
+ if (i !== ~~i || i < min || i > max) {
+ throw Error(invalidArgument + i);
+ }
+ }
+
+
+ /*
+ * Check 5 rounding digits if `repeating` is null, 4 otherwise.
+ * `repeating == null` if caller is `log` or `pow`,
+ * `repeating != null` if caller is `naturalLogarithm` or `naturalExponential`.
+ */
+ function checkRoundingDigits(d, i, rm, repeating) {
+ var di, k, r, rd;
+
+ // Get the length of the first word of the array d.
+ for (k = d[0]; k >= 10; k /= 10) --i;
+
+ // Is the rounding digit in the first word of d?
+ if (--i < 0) {
+ i += LOG_BASE;
+ di = 0;
+ } else {
+ di = Math.ceil((i + 1) / LOG_BASE);
+ i %= LOG_BASE;
+ }
+
+ // i is the index (0 - 6) of the rounding digit.
+ // E.g. if within the word 3487563 the first rounding digit is 5,
+ // then i = 4, k = 1000, rd = 3487563 % 1000 = 563
+ k = mathpow(10, LOG_BASE - i);
+ rd = d[di] % k | 0;
+
+ if (repeating == null) {
+ if (i < 3) {
+ if (i == 0) rd = rd / 100 | 0;
+ else if (i == 1) rd = rd / 10 | 0;
+ r = rm < 4 && rd == 99999 || rm > 3 && rd == 49999 || rd == 50000 || rd == 0;
+ } else {
+ r = (rm < 4 && rd + 1 == k || rm > 3 && rd + 1 == k / 2) &&
+ (d[di + 1] / k / 100 | 0) == mathpow(10, i - 2) - 1 ||
+ (rd == k / 2 || rd == 0) && (d[di + 1] / k / 100 | 0) == 0;
+ }
+ } else {
+ if (i < 4) {
+ if (i == 0) rd = rd / 1000 | 0;
+ else if (i == 1) rd = rd / 100 | 0;
+ else if (i == 2) rd = rd / 10 | 0;
+ r = (repeating || rm < 4) && rd == 9999 || !repeating && rm > 3 && rd == 4999;
+ } else {
+ r = ((repeating || rm < 4) && rd + 1 == k ||
+ (!repeating && rm > 3) && rd + 1 == k / 2) &&
+ (d[di + 1] / k / 1000 | 0) == mathpow(10, i - 3) - 1;
+ }
+ }
+
+ return r;
+ }
+
+
+ // Convert string of `baseIn` to an array of numbers of `baseOut`.
+ // Eg. convertBase('255', 10, 16) returns [15, 15].
+ // Eg. convertBase('ff', 16, 10) returns [2, 5, 5].
+ function convertBase(str, baseIn, baseOut) {
+ var j,
+ arr = [0],
+ arrL,
+ i = 0,
+ strL = str.length;
+
+ for (; i < strL;) {
+ for (arrL = arr.length; arrL--;) arr[arrL] *= baseIn;
+ arr[0] += NUMERALS.indexOf(str.charAt(i++));
+ for (j = 0; j < arr.length; j++) {
+ if (arr[j] > baseOut - 1) {
+ if (arr[j + 1] === void 0) arr[j + 1] = 0;
+ arr[j + 1] += arr[j] / baseOut | 0;
+ arr[j] %= baseOut;
+ }
+ }
+ }
+
+ return arr.reverse();
+ }
+
+
+ /*
+ * cos(x) = 1 - x^2/2! + x^4/4! - ...
+ * |x| < pi/2
+ *
+ */
+ function cosine(Ctor, x) {
+ var k, y,
+ len = x.d.length;
+
+ // Argument reduction: cos(4x) = 8*(cos^4(x) - cos^2(x)) + 1
+ // i.e. cos(x) = 8*(cos^4(x/4) - cos^2(x/4)) + 1
+
+ // Estimate the optimum number of times to use the argument reduction.
+ if (len < 32) {
+ k = Math.ceil(len / 3);
+ y = Math.pow(4, -k).toString();
+ } else {
+ k = 16;
+ y = '2.3283064365386962890625e-10';
+ }
+
+ Ctor.precision += k;
+
+ x = taylorSeries(Ctor, 1, x.times(y), new Ctor(1));
+
+ // Reverse argument reduction
+ for (var i = k; i--;) {
+ var cos2x = x.times(x);
+ x = cos2x.times(cos2x).minus(cos2x).times(8).plus(1);
+ }
+
+ Ctor.precision -= k;
+
+ return x;
+ }
+
+
+ /*
+ * Perform division in the specified base.
+ */
+ var divide = (function () {
+
+ // Assumes non-zero x and k, and hence non-zero result.
+ function multiplyInteger(x, k, base) {
+ var temp,
+ carry = 0,
+ i = x.length;
+
+ for (x = x.slice(); i--;) {
+ temp = x[i] * k + carry;
+ x[i] = temp % base | 0;
+ carry = temp / base | 0;
+ }
+
+ if (carry) x.unshift(carry);
+
+ return x;
+ }
+
+ function compare(a, b, aL, bL) {
+ var i, r;
+
+ if (aL != bL) {
+ r = aL > bL ? 1 : -1;
+ } else {
+ for (i = r = 0; i < aL; i++) {
+ if (a[i] != b[i]) {
+ r = a[i] > b[i] ? 1 : -1;
+ break;
+ }
+ }
+ }
+
+ return r;
+ }
+
+ function subtract(a, b, aL, base) {
+ var i = 0;
+
+ // Subtract b from a.
+ for (; aL--;) {
+ a[aL] -= i;
+ i = a[aL] < b[aL] ? 1 : 0;
+ a[aL] = i * base + a[aL] - b[aL];
+ }
+
+ // Remove leading zeros.
+ for (; !a[0] && a.length > 1;) a.shift();
+ }
+
+ return function (x, y, pr, rm, dp, base) {
+ var cmp, e, i, k, logBase, more, prod, prodL, q, qd, rem, remL, rem0, sd, t, xi, xL, yd0,
+ yL, yz,
+ Ctor = x.constructor,
+ sign = x.s == y.s ? 1 : -1,
+ xd = x.d,
+ yd = y.d;
+
+ // Either NaN, Infinity or 0?
+ if (!xd || !xd[0] || !yd || !yd[0]) {
+
+ return new Ctor(// Return NaN if either NaN, or both Infinity or 0.
+ !x.s || !y.s || (xd ? yd && xd[0] == yd[0] : !yd) ? NaN :
+
+ // Return ±0 if x is 0 or y is ±Infinity, or return ±Infinity as y is 0.
+ xd && xd[0] == 0 || !yd ? sign * 0 : sign / 0);
+ }
+
+ if (base) {
+ logBase = 1;
+ e = x.e - y.e;
+ } else {
+ base = BASE;
+ logBase = LOG_BASE;
+ e = mathfloor(x.e / logBase) - mathfloor(y.e / logBase);
+ }
+
+ yL = yd.length;
+ xL = xd.length;
+ q = new Ctor(sign);
+ qd = q.d = [];
+
+ // Result exponent may be one less than e.
+ // The digit array of a Decimal from toStringBinary may have trailing zeros.
+ for (i = 0; yd[i] == (xd[i] || 0); i++);
+
+ if (yd[i] > (xd[i] || 0)) e--;
+
+ if (pr == null) {
+ sd = pr = Ctor.precision;
+ rm = Ctor.rounding;
+ } else if (dp) {
+ sd = pr + (x.e - y.e) + 1;
+ } else {
+ sd = pr;
+ }
+
+ if (sd < 0) {
+ qd.push(1);
+ more = true;
+ } else {
+
+ // Convert precision in number of base 10 digits to base 1e7 digits.
+ sd = sd / logBase + 2 | 0;
+ i = 0;
+
+ // divisor < 1e7
+ if (yL == 1) {
+ k = 0;
+ yd = yd[0];
+ sd++;
+
+ // k is the carry.
+ for (; (i < xL || k) && sd--; i++) {
+ t = k * base + (xd[i] || 0);
+ qd[i] = t / yd | 0;
+ k = t % yd | 0;
+ }
+
+ more = k || i < xL;
+
+ // divisor >= 1e7
+ } else {
+
+ // Normalise xd and yd so highest order digit of yd is >= base/2
+ k = base / (yd[0] + 1) | 0;
+
+ if (k > 1) {
+ yd = multiplyInteger(yd, k, base);
+ xd = multiplyInteger(xd, k, base);
+ yL = yd.length;
+ xL = xd.length;
+ }
+
+ xi = yL;
+ rem = xd.slice(0, yL);
+ remL = rem.length;
+
+ // Add zeros to make remainder as long as divisor.
+ for (; remL < yL;) rem[remL++] = 0;
+
+ yz = yd.slice();
+ yz.unshift(0);
+ yd0 = yd[0];
+
+ if (yd[1] >= base / 2) ++yd0;
+
+ do {
+ k = 0;
+
+ // Compare divisor and remainder.
+ cmp = compare(yd, rem, yL, remL);
+
+ // If divisor < remainder.
+ if (cmp < 0) {
+
+ // Calculate trial digit, k.
+ rem0 = rem[0];
+ if (yL != remL) rem0 = rem0 * base + (rem[1] || 0);
+
+ // k will be how many times the divisor goes into the current remainder.
+ k = rem0 / yd0 | 0;
+
+ // Algorithm:
+ // 1. product = divisor * trial digit (k)
+ // 2. if product > remainder: product -= divisor, k--
+ // 3. remainder -= product
+ // 4. if product was < remainder at 2:
+ // 5. compare new remainder and divisor
+ // 6. If remainder > divisor: remainder -= divisor, k++
+
+ if (k > 1) {
+ if (k >= base) k = base - 1;
+
+ // product = divisor * trial digit.
+ prod = multiplyInteger(yd, k, base);
+ prodL = prod.length;
+ remL = rem.length;
+
+ // Compare product and remainder.
+ cmp = compare(prod, rem, prodL, remL);
+
+ // product > remainder.
+ if (cmp == 1) {
+ k--;
+
+ // Subtract divisor from product.
+ subtract(prod, yL < prodL ? yz : yd, prodL, base);
+ }
+ } else {
+
+ // cmp is -1.
+ // If k is 0, there is no need to compare yd and rem again below, so change cmp to 1
+ // to avoid it. If k is 1 there is a need to compare yd and rem again below.
+ if (k == 0) cmp = k = 1;
+ prod = yd.slice();
+ }
+
+ prodL = prod.length;
+ if (prodL < remL) prod.unshift(0);
+
+ // Subtract product from remainder.
+ subtract(rem, prod, remL, base);
+
+ // If product was < previous remainder.
+ if (cmp == -1) {
+ remL = rem.length;
+
+ // Compare divisor and new remainder.
+ cmp = compare(yd, rem, yL, remL);
+
+ // If divisor < new remainder, subtract divisor from remainder.
+ if (cmp < 1) {
+ k++;
+
+ // Subtract divisor from remainder.
+ subtract(rem, yL < remL ? yz : yd, remL, base);
+ }
+ }
+
+ remL = rem.length;
+ } else if (cmp === 0) {
+ k++;
+ rem = [0];
+ } // if cmp === 1, k will be 0
+
+ // Add the next digit, k, to the result array.
+ qd[i++] = k;
+
+ // Update the remainder.
+ if (cmp && rem[0]) {
+ rem[remL++] = xd[xi] || 0;
+ } else {
+ rem = [xd[xi]];
+ remL = 1;
+ }
+
+ } while ((xi++ < xL || rem[0] !== void 0) && sd--);
+
+ more = rem[0] !== void 0;
+ }
+
+ // Leading zero?
+ if (!qd[0]) qd.shift();
+ }
+
+ // logBase is 1 when divide is being used for base conversion.
+ if (logBase == 1) {
+ q.e = e;
+ inexact = more;
+ } else {
+
+ // To calculate q.e, first get the number of digits of qd[0].
+ for (i = 1, k = qd[0]; k >= 10; k /= 10) i++;
+ q.e = i + e * logBase - 1;
+
+ finalise(q, dp ? pr + q.e + 1 : pr, rm, more);
+ }
+
+ return q;
+ };
+ })();
+
+
+ /*
+ * Round `x` to `sd` significant digits using rounding mode `rm`.
+ * Check for over/under-flow.
+ */
+ function finalise(x, sd, rm, isTruncated) {
+ var digits, i, j, k, rd, roundUp, w, xd, xdi,
+ Ctor = x.constructor;
+
+ // Don't round if sd is null or undefined.
+ out: if (sd != null) {
+ xd = x.d;
+
+ // Infinity/NaN.
+ if (!xd) return x;
+
+ // rd: the rounding digit, i.e. the digit after the digit that may be rounded up.
+ // w: the word of xd containing rd, a base 1e7 number.
+ // xdi: the index of w within xd.
+ // digits: the number of digits of w.
+ // i: what would be the index of rd within w if all the numbers were 7 digits long (i.e. if
+ // they had leading zeros)
+ // j: if > 0, the actual index of rd within w (if < 0, rd is a leading zero).
+
+ // Get the length of the first word of the digits array xd.
+ for (digits = 1, k = xd[0]; k >= 10; k /= 10) digits++;
+ i = sd - digits;
+
+ // Is the rounding digit in the first word of xd?
+ if (i < 0) {
+ i += LOG_BASE;
+ j = sd;
+ w = xd[xdi = 0];
+
+ // Get the rounding digit at index j of w.
+ rd = w / mathpow(10, digits - j - 1) % 10 | 0;
+ } else {
+ xdi = Math.ceil((i + 1) / LOG_BASE);
+ k = xd.length;
+ if (xdi >= k) {
+ if (isTruncated) {
+
+ // Needed by `naturalExponential`, `naturalLogarithm` and `squareRoot`.
+ for (; k++ <= xdi;) xd.push(0);
+ w = rd = 0;
+ digits = 1;
+ i %= LOG_BASE;
+ j = i - LOG_BASE + 1;
+ } else {
+ break out;
+ }
+ } else {
+ w = k = xd[xdi];
+
+ // Get the number of digits of w.
+ for (digits = 1; k >= 10; k /= 10) digits++;
+
+ // Get the index of rd within w.
+ i %= LOG_BASE;
+
+ // Get the index of rd within w, adjusted for leading zeros.
+ // The number of leading zeros of w is given by LOG_BASE - digits.
+ j = i - LOG_BASE + digits;
+
+ // Get the rounding digit at index j of w.
+ rd = j < 0 ? 0 : w / mathpow(10, digits - j - 1) % 10 | 0;
+ }
+ }
+
+ // Are there any non-zero digits after the rounding digit?
+ isTruncated = isTruncated || sd < 0 ||
+ xd[xdi + 1] !== void 0 || (j < 0 ? w : w % mathpow(10, digits - j - 1));
+
+ // The expression `w % mathpow(10, digits - j - 1)` returns all the digits of w to the right
+ // of the digit at (left-to-right) index j, e.g. if w is 908714 and j is 2, the expression
+ // will give 714.
+
+ roundUp = rm < 4
+ ? (rd || isTruncated) && (rm == 0 || rm == (x.s < 0 ? 3 : 2))
+ : rd > 5 || rd == 5 && (rm == 4 || isTruncated || rm == 6 &&
+
+ // Check whether the digit to the left of the rounding digit is odd.
+ ((i > 0 ? j > 0 ? w / mathpow(10, digits - j) : 0 : xd[xdi - 1]) % 10) & 1 ||
+ rm == (x.s < 0 ? 8 : 7));
+
+ if (sd < 1 || !xd[0]) {
+ xd.length = 0;
+ if (roundUp) {
+
+ // Convert sd to decimal places.
+ sd -= x.e + 1;
+
+ // 1, 0.1, 0.01, 0.001, 0.0001 etc.
+ xd[0] = mathpow(10, (LOG_BASE - sd % LOG_BASE) % LOG_BASE);
+ x.e = -sd || 0;
+ } else {
+
+ // Zero.
+ xd[0] = x.e = 0;
+ }
+
+ return x;
+ }
+
+ // Remove excess digits.
+ if (i == 0) {
+ xd.length = xdi;
+ k = 1;
+ xdi--;
+ } else {
+ xd.length = xdi + 1;
+ k = mathpow(10, LOG_BASE - i);
+
+ // E.g. 56700 becomes 56000 if 7 is the rounding digit.
+ // j > 0 means i > number of leading zeros of w.
+ xd[xdi] = j > 0 ? (w / mathpow(10, digits - j) % mathpow(10, j) | 0) * k : 0;
+ }
+
+ if (roundUp) {
+ for (;;) {
+
+ // Is the digit to be rounded up in the first word of xd?
+ if (xdi == 0) {
+
+ // i will be the length of xd[0] before k is added.
+ for (i = 1, j = xd[0]; j >= 10; j /= 10) i++;
+ j = xd[0] += k;
+ for (k = 1; j >= 10; j /= 10) k++;
+
+ // if i != k the length has increased.
+ if (i != k) {
+ x.e++;
+ if (xd[0] == BASE) xd[0] = 1;
+ }
+
+ break;
+ } else {
+ xd[xdi] += k;
+ if (xd[xdi] != BASE) break;
+ xd[xdi--] = 0;
+ k = 1;
+ }
+ }
+ }
+
+ // Remove trailing zeros.
+ for (i = xd.length; xd[--i] === 0;) xd.pop();
+ }
+
+ if (external) {
+
+ // Overflow?
+ if (x.e > Ctor.maxE) {
+
+ // Infinity.
+ x.d = null;
+ x.e = NaN;
+
+ // Underflow?
+ } else if (x.e < Ctor.minE) {
+
+ // Zero.
+ x.e = 0;
+ x.d = [0];
+ // Ctor.underflow = true;
+ } // else Ctor.underflow = false;
+ }
+
+ return x;
+ }
+
+
+ function finiteToString(x, isExp, sd) {
+ if (!x.isFinite()) return nonFiniteToString(x);
+ var k,
+ e = x.e,
+ str = digitsToString(x.d),
+ len = str.length;
+
+ if (isExp) {
+ if (sd && (k = sd - len) > 0) {
+ str = str.charAt(0) + '.' + str.slice(1) + getZeroString(k);
+ } else if (len > 1) {
+ str = str.charAt(0) + '.' + str.slice(1);
+ }
+
+ str = str + (x.e < 0 ? 'e' : 'e+') + x.e;
+ } else if (e < 0) {
+ str = '0.' + getZeroString(-e - 1) + str;
+ if (sd && (k = sd - len) > 0) str += getZeroString(k);
+ } else if (e >= len) {
+ str += getZeroString(e + 1 - len);
+ if (sd && (k = sd - e - 1) > 0) str = str + '.' + getZeroString(k);
+ } else {
+ if ((k = e + 1) < len) str = str.slice(0, k) + '.' + str.slice(k);
+ if (sd && (k = sd - len) > 0) {
+ if (e + 1 === len) str += '.';
+ str += getZeroString(k);
+ }
+ }
+
+ return str;
+ }
+
+
+ // Calculate the base 10 exponent from the base 1e7 exponent.
+ function getBase10Exponent(digits, e) {
+ var w = digits[0];
+
+ // Add the number of digits of the first word of the digits array.
+ for ( e *= LOG_BASE; w >= 10; w /= 10) e++;
+ return e;
+ }
+
+
+ function getLn10(Ctor, sd, pr) {
+ if (sd > LN10_PRECISION) {
+
+ // Reset global state in case the exception is caught.
+ external = true;
+ if (pr) Ctor.precision = pr;
+ throw Error(precisionLimitExceeded);
+ }
+ return finalise(new Ctor(LN10), sd, 1, true);
+ }
+
+
+ function getPi(Ctor, sd, rm) {
+ if (sd > PI_PRECISION) throw Error(precisionLimitExceeded);
+ return finalise(new Ctor(PI), sd, rm, true);
+ }
+
+
+ function getPrecision(digits) {
+ var w = digits.length - 1,
+ len = w * LOG_BASE + 1;
+
+ w = digits[w];
+
+ // If non-zero...
+ if (w) {
+
+ // Subtract the number of trailing zeros of the last word.
+ for (; w % 10 == 0; w /= 10) len--;
+
+ // Add the number of digits of the first word.
+ for (w = digits[0]; w >= 10; w /= 10) len++;
+ }
+
+ return len;
+ }
+
+
+ function getZeroString(k) {
+ var zs = '';
+ for (; k--;) zs += '0';
+ return zs;
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the value of Decimal `x` to the power `n`, where `n` is an
+ * integer of type number.
+ *
+ * Implements 'exponentiation by squaring'. Called by `pow` and `parseOther`.
+ *
+ */
+ function intPow(Ctor, x, n, pr) {
+ var isTruncated,
+ r = new Ctor(1),
+
+ // Max n of 9007199254740991 takes 53 loop iterations.
+ // Maximum digits array length; leaves [28, 34] guard digits.
+ k = Math.ceil(pr / LOG_BASE + 4);
+
+ external = false;
+
+ for (;;) {
+ if (n % 2) {
+ r = r.times(x);
+ if (truncate(r.d, k)) isTruncated = true;
+ }
+
+ n = mathfloor(n / 2);
+ if (n === 0) {
+
+ // To ensure correct rounding when r.d is truncated, increment the last word if it is zero.
+ n = r.d.length - 1;
+ if (isTruncated && r.d[n] === 0) ++r.d[n];
+ break;
+ }
+
+ x = x.times(x);
+ truncate(x.d, k);
+ }
+
+ external = true;
+
+ return r;
+ }
+
+
+ function isOdd(n) {
+ return n.d[n.d.length - 1] & 1;
+ }
+
+
+ /*
+ * Handle `max` and `min`. `ltgt` is 'lt' or 'gt'.
+ */
+ function maxOrMin(Ctor, args, ltgt) {
+ var y,
+ x = new Ctor(args[0]),
+ i = 0;
+
+ for (; ++i < args.length;) {
+ y = new Ctor(args[i]);
+ if (!y.s) {
+ x = y;
+ break;
+ } else if (x[ltgt](y)) {
+ x = y;
+ }
+ }
+
+ return x;
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the natural exponential of `x` rounded to `sd` significant
+ * digits.
+ *
+ * Taylor/Maclaurin series.
+ *
+ * exp(x) = x^0/0! + x^1/1! + x^2/2! + x^3/3! + ...
+ *
+ * Argument reduction:
+ * Repeat x = x / 32, k += 5, until |x| < 0.1
+ * exp(x) = exp(x / 2^k)^(2^k)
+ *
+ * Previously, the argument was initially reduced by
+ * exp(x) = exp(r) * 10^k where r = x - k * ln10, k = floor(x / ln10)
+ * to first put r in the range [0, ln10], before dividing by 32 until |x| < 0.1, but this was
+ * found to be slower than just dividing repeatedly by 32 as above.
+ *
+ * Max integer argument: exp('20723265836946413') = 6.3e+9000000000000000
+ * Min integer argument: exp('-20723265836946411') = 1.2e-9000000000000000
+ * (Math object integer min/max: Math.exp(709) = 8.2e+307, Math.exp(-745) = 5e-324)
+ *
+ * exp(Infinity) = Infinity
+ * exp(-Infinity) = 0
+ * exp(NaN) = NaN
+ * exp(±0) = 1
+ *
+ * exp(x) is non-terminating for any finite, non-zero x.
+ *
+ * The result will always be correctly rounded.
+ *
+ */
+ function naturalExponential(x, sd) {
+ var denominator, guard, j, pow, sum, t, wpr,
+ rep = 0,
+ i = 0,
+ k = 0,
+ Ctor = x.constructor,
+ rm = Ctor.rounding,
+ pr = Ctor.precision;
+
+ // 0/NaN/Infinity?
+ if (!x.d || !x.d[0] || x.e > 17) {
+
+ return new Ctor(x.d
+ ? !x.d[0] ? 1 : x.s < 0 ? 0 : 1 / 0
+ : x.s ? x.s < 0 ? 0 : x : 0 / 0);
+ }
+
+ if (sd == null) {
+ external = false;
+ wpr = pr;
+ } else {
+ wpr = sd;
+ }
+
+ t = new Ctor(0.03125);
+
+ // while abs(x) >= 0.1
+ while (x.e > -2) {
+
+ // x = x / 2^5
+ x = x.times(t);
+ k += 5;
+ }
+
+ // Use 2 * log10(2^k) + 5 (empirically derived) to estimate the increase in precision
+ // necessary to ensure the first 4 rounding digits are correct.
+ guard = Math.log(mathpow(2, k)) / Math.LN10 * 2 + 5 | 0;
+ wpr += guard;
+ denominator = pow = sum = new Ctor(1);
+ Ctor.precision = wpr;
+
+ for (;;) {
+ pow = finalise(pow.times(x), wpr, 1);
+ denominator = denominator.times(++i);
+ t = sum.plus(divide(pow, denominator, wpr, 1));
+
+ if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
+ j = k;
+ while (j--) sum = finalise(sum.times(sum), wpr, 1);
+
+ // Check to see if the first 4 rounding digits are [49]999.
+ // If so, repeat the summation with a higher precision, otherwise
+ // e.g. with precision: 18, rounding: 1
+ // exp(18.404272462595034083567793919843761) = 98372560.1229999999 (should be 98372560.123)
+ // `wpr - guard` is the index of first rounding digit.
+ if (sd == null) {
+
+ if (rep < 3 && checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
+ Ctor.precision = wpr += 10;
+ denominator = pow = t = new Ctor(1);
+ i = 0;
+ rep++;
+ } else {
+ return finalise(sum, Ctor.precision = pr, rm, external = true);
+ }
+ } else {
+ Ctor.precision = pr;
+ return sum;
+ }
+ }
+
+ sum = t;
+ }
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the natural logarithm of `x` rounded to `sd` significant
+ * digits.
+ *
+ * ln(-n) = NaN
+ * ln(0) = -Infinity
+ * ln(-0) = -Infinity
+ * ln(1) = 0
+ * ln(Infinity) = Infinity
+ * ln(-Infinity) = NaN
+ * ln(NaN) = NaN
+ *
+ * ln(n) (n != 1) is non-terminating.
+ *
+ */
+ function naturalLogarithm(y, sd) {
+ var c, c0, denominator, e, numerator, rep, sum, t, wpr, x1, x2,
+ n = 1,
+ guard = 10,
+ x = y,
+ xd = x.d,
+ Ctor = x.constructor,
+ rm = Ctor.rounding,
+ pr = Ctor.precision;
+
+ // Is x negative or Infinity, NaN, 0 or 1?
+ if (x.s < 0 || !xd || !xd[0] || !x.e && xd[0] == 1 && xd.length == 1) {
+ return new Ctor(xd && !xd[0] ? -1 / 0 : x.s != 1 ? NaN : xd ? 0 : x);
+ }
+
+ if (sd == null) {
+ external = false;
+ wpr = pr;
+ } else {
+ wpr = sd;
+ }
+
+ Ctor.precision = wpr += guard;
+ c = digitsToString(xd);
+ c0 = c.charAt(0);
+
+ if (Math.abs(e = x.e) < 1.5e15) {
+
+ // Argument reduction.
+ // The series converges faster the closer the argument is to 1, so using
+ // ln(a^b) = b * ln(a), ln(a) = ln(a^b) / b
+ // multiply the argument by itself until the leading digits of the significand are 7, 8, 9,
+ // 10, 11, 12 or 13, recording the number of multiplications so the sum of the series can
+ // later be divided by this number, then separate out the power of 10 using
+ // ln(a*10^b) = ln(a) + b*ln(10).
+
+ // max n is 21 (gives 0.9, 1.0 or 1.1) (9e15 / 21 = 4.2e14).
+ //while (c0 < 9 && c0 != 1 || c0 == 1 && c.charAt(1) > 1) {
+ // max n is 6 (gives 0.7 - 1.3)
+ while (c0 < 7 && c0 != 1 || c0 == 1 && c.charAt(1) > 3) {
+ x = x.times(y);
+ c = digitsToString(x.d);
+ c0 = c.charAt(0);
+ n++;
+ }
+
+ e = x.e;
+
+ if (c0 > 1) {
+ x = new Ctor('0.' + c);
+ e++;
+ } else {
+ x = new Ctor(c0 + '.' + c.slice(1));
+ }
+ } else {
+
+ // The argument reduction method above may result in overflow if the argument y is a massive
+ // number with exponent >= 1500000000000000 (9e15 / 6 = 1.5e15), so instead recall this
+ // function using ln(x*10^e) = ln(x) + e*ln(10).
+ t = getLn10(Ctor, wpr + 2, pr).times(e + '');
+ x = naturalLogarithm(new Ctor(c0 + '.' + c.slice(1)), wpr - guard).plus(t);
+ Ctor.precision = pr;
+
+ return sd == null ? finalise(x, pr, rm, external = true) : x;
+ }
+
+ // x1 is x reduced to a value near 1.
+ x1 = x;
+
+ // Taylor series.
+ // ln(y) = ln((1 + x)/(1 - x)) = 2(x + x^3/3 + x^5/5 + x^7/7 + ...)
+ // where x = (y - 1)/(y + 1) (|x| < 1)
+ sum = numerator = x = divide(x.minus(1), x.plus(1), wpr, 1);
+ x2 = finalise(x.times(x), wpr, 1);
+ denominator = 3;
+
+ for (;;) {
+ numerator = finalise(numerator.times(x2), wpr, 1);
+ t = sum.plus(divide(numerator, new Ctor(denominator), wpr, 1));
+
+ if (digitsToString(t.d).slice(0, wpr) === digitsToString(sum.d).slice(0, wpr)) {
+ sum = sum.times(2);
+
+ // Reverse the argument reduction. Check that e is not 0 because, besides preventing an
+ // unnecessary calculation, -0 + 0 = +0 and to ensure correct rounding -0 needs to stay -0.
+ if (e !== 0) sum = sum.plus(getLn10(Ctor, wpr + 2, pr).times(e + ''));
+ sum = divide(sum, new Ctor(n), wpr, 1);
+
+ // Is rm > 3 and the first 4 rounding digits 4999, or rm < 4 (or the summation has
+ // been repeated previously) and the first 4 rounding digits 9999?
+ // If so, restart the summation with a higher precision, otherwise
+ // e.g. with precision: 12, rounding: 1
+ // ln(135520028.6126091714265381533) = 18.7246299999 when it should be 18.72463.
+ // `wpr - guard` is the index of first rounding digit.
+ if (sd == null) {
+ if (checkRoundingDigits(sum.d, wpr - guard, rm, rep)) {
+ Ctor.precision = wpr += guard;
+ t = numerator = x = divide(x1.minus(1), x1.plus(1), wpr, 1);
+ x2 = finalise(x.times(x), wpr, 1);
+ denominator = rep = 1;
+ } else {
+ return finalise(sum, Ctor.precision = pr, rm, external = true);
+ }
+ } else {
+ Ctor.precision = pr;
+ return sum;
+ }
+ }
+
+ sum = t;
+ denominator += 2;
+ }
+ }
+
+
+ // ±Infinity, NaN.
+ function nonFiniteToString(x) {
+ // Unsigned.
+ return String(x.s * x.s / 0);
+ }
+
+
+ /*
+ * Parse the value of a new Decimal `x` from string `str`.
+ */
+ function parseDecimal(x, str) {
+ var e, i, len;
+
+ // Decimal point?
+ if ((e = str.indexOf('.')) > -1) str = str.replace('.', '');
+
+ // Exponential form?
+ if ((i = str.search(/e/i)) > 0) {
+
+ // Determine exponent.
+ if (e < 0) e = i;
+ e += +str.slice(i + 1);
+ str = str.substring(0, i);
+ } else if (e < 0) {
+
+ // Integer.
+ e = str.length;
+ }
+
+ // Determine leading zeros.
+ for (i = 0; str.charCodeAt(i) === 48; i++);
+
+ // Determine trailing zeros.
+ for (len = str.length; str.charCodeAt(len - 1) === 48; --len);
+ str = str.slice(i, len);
+
+ if (str) {
+ len -= i;
+ x.e = e = e - i - 1;
+ x.d = [];
+
+ // Transform base
+
+ // e is the base 10 exponent.
+ // i is where to slice str to get the first word of the digits array.
+ i = (e + 1) % LOG_BASE;
+ if (e < 0) i += LOG_BASE;
+
+ if (i < len) {
+ if (i) x.d.push(+str.slice(0, i));
+ for (len -= LOG_BASE; i < len;) x.d.push(+str.slice(i, i += LOG_BASE));
+ str = str.slice(i);
+ i = LOG_BASE - str.length;
+ } else {
+ i -= len;
+ }
+
+ for (; i--;) str += '0';
+ x.d.push(+str);
+
+ if (external) {
+
+ // Overflow?
+ if (x.e > x.constructor.maxE) {
+
+ // Infinity.
+ x.d = null;
+ x.e = NaN;
+
+ // Underflow?
+ } else if (x.e < x.constructor.minE) {
+
+ // Zero.
+ x.e = 0;
+ x.d = [0];
+ // x.constructor.underflow = true;
+ } // else x.constructor.underflow = false;
+ }
+ } else {
+
+ // Zero.
+ x.e = 0;
+ x.d = [0];
+ }
+
+ return x;
+ }
+
+
+ /*
+ * Parse the value of a new Decimal `x` from a string `str`, which is not a decimal value.
+ */
+ function parseOther(x, str) {
+ var base, Ctor, divisor, i, isFloat, len, p, xd, xe;
+
+ if (str === 'Infinity' || str === 'NaN') {
+ if (!+str) x.s = NaN;
+ x.e = NaN;
+ x.d = null;
+ return x;
+ }
+
+ if (isHex.test(str)) {
+ base = 16;
+ str = str.toLowerCase();
+ } else if (isBinary.test(str)) {
+ base = 2;
+ } else if (isOctal.test(str)) {
+ base = 8;
+ } else {
+ throw Error(invalidArgument + str);
+ }
+
+ // Is there a binary exponent part?
+ i = str.search(/p/i);
+
+ if (i > 0) {
+ p = +str.slice(i + 1);
+ str = str.substring(2, i);
+ } else {
+ str = str.slice(2);
+ }
+
+ // Convert `str` as an integer then divide the result by `base` raised to a power such that the
+ // fraction part will be restored.
+ i = str.indexOf('.');
+ isFloat = i >= 0;
+ Ctor = x.constructor;
+
+ if (isFloat) {
+ str = str.replace('.', '');
+ len = str.length;
+ i = len - i;
+
+ // log[10](16) = 1.2041... , log[10](88) = 1.9444....
+ divisor = intPow(Ctor, new Ctor(base), i, i * 2);
+ }
+
+ xd = convertBase(str, base, BASE);
+ xe = xd.length - 1;
+
+ // Remove trailing zeros.
+ for (i = xe; xd[i] === 0; --i) xd.pop();
+ if (i < 0) return new Ctor(x.s * 0);
+ x.e = getBase10Exponent(xd, xe);
+ x.d = xd;
+ external = false;
+
+ // At what precision to perform the division to ensure exact conversion?
+ // maxDecimalIntegerPartDigitCount = ceil(log[10](b) * otherBaseIntegerPartDigitCount)
+ // log[10](2) = 0.30103, log[10](8) = 0.90309, log[10](16) = 1.20412
+ // E.g. ceil(1.2 * 3) = 4, so up to 4 decimal digits are needed to represent 3 hex int digits.
+ // maxDecimalFractionPartDigitCount = {Hex:4|Oct:3|Bin:1} * otherBaseFractionPartDigitCount
+ // Therefore using 4 * the number of digits of str will always be enough.
+ if (isFloat) x = divide(x, divisor, len * 4);
+
+ // Multiply by the binary exponent part if present.
+ if (p) x = x.times(Math.abs(p) < 54 ? Math.pow(2, p) : Decimal.pow(2, p));
+ external = true;
+
+ return x;
+ }
+
+
+ /*
+ * sin(x) = x - x^3/3! + x^5/5! - ...
+ * |x| < pi/2
+ *
+ */
+ function sine(Ctor, x) {
+ var k,
+ len = x.d.length;
+
+ if (len < 3) return taylorSeries(Ctor, 2, x, x);
+
+ // Argument reduction: sin(5x) = 16*sin^5(x) - 20*sin^3(x) + 5*sin(x)
+ // i.e. sin(x) = 16*sin^5(x/5) - 20*sin^3(x/5) + 5*sin(x/5)
+ // and sin(x) = sin(x/5)(5 + sin^2(x/5)(16sin^2(x/5) - 20))
+
+ // Estimate the optimum number of times to use the argument reduction.
+ k = 1.4 * Math.sqrt(len);
+ k = k > 16 ? 16 : k | 0;
+
+ // Max k before Math.pow precision loss is 22
+ x = x.times(Math.pow(5, -k));
+ x = taylorSeries(Ctor, 2, x, x);
+
+ // Reverse argument reduction
+ var sin2_x,
+ d5 = new Ctor(5),
+ d16 = new Ctor(16),
+ d20 = new Ctor(20);
+ for (; k--;) {
+ sin2_x = x.times(x);
+ x = x.times(d5.plus(sin2_x.times(d16.times(sin2_x).minus(d20))));
+ }
+
+ return x;
+ }
+
+
+ // Calculate Taylor series for `cos`, `cosh`, `sin` and `sinh`.
+ function taylorSeries(Ctor, n, x, y, isHyperbolic) {
+ var j, t, u, x2,
+ i = 1,
+ pr = Ctor.precision,
+ k = Math.ceil(pr / LOG_BASE);
+
+ external = false;
+ x2 = x.times(x);
+ u = new Ctor(y);
+
+ for (;;) {
+ t = divide(u.times(x2), new Ctor(n++ * n++), pr, 1);
+ u = isHyperbolic ? y.plus(t) : y.minus(t);
+ y = divide(t.times(x2), new Ctor(n++ * n++), pr, 1);
+ t = u.plus(y);
+
+ if (t.d[k] !== void 0) {
+ for (j = k; t.d[j] === u.d[j] && j--;);
+ if (j == -1) break;
+ }
+
+ j = u;
+ u = y;
+ y = t;
+ t = j;
+ i++;
+ }
+
+ external = true;
+ t.d.length = k + 1;
+
+ return t;
+ }
+
+
+ // Return the absolute value of `x` reduced to less than or equal to half pi.
+ function toLessThanHalfPi(Ctor, x) {
+ var t,
+ isNeg = x.s < 0,
+ pi = getPi(Ctor, Ctor.precision, 1),
+ halfPi = pi.times(0.5);
+
+ x = x.abs();
+
+ if (x.lte(halfPi)) {
+ quadrant = isNeg ? 4 : 1;
+ return x;
+ }
+
+ t = x.divToInt(pi);
+
+ if (t.isZero()) {
+ quadrant = isNeg ? 3 : 2;
+ } else {
+ x = x.minus(t.times(pi));
+
+ // 0 <= x < pi
+ if (x.lte(halfPi)) {
+ quadrant = isOdd(t) ? (isNeg ? 2 : 3) : (isNeg ? 4 : 1);
+ return x;
+ }
+
+ quadrant = isOdd(t) ? (isNeg ? 1 : 4) : (isNeg ? 3 : 2);
+ }
+
+ return x.minus(pi).abs();
+ }
+
+
+ /*
+ * Return the value of Decimal `x` as a string in base `baseOut`.
+ *
+ * If the optional `sd` argument is present include a binary exponent suffix.
+ */
+ function toStringBinary(x, baseOut, sd, rm) {
+ var base, e, i, k, len, roundUp, str, xd, y,
+ Ctor = x.constructor,
+ isExp = sd !== void 0;
+
+ if (isExp) {
+ checkInt32(sd, 1, MAX_DIGITS);
+ if (rm === void 0) rm = Ctor.rounding;
+ else checkInt32(rm, 0, 8);
+ } else {
+ sd = Ctor.precision;
+ rm = Ctor.rounding;
+ }
+
+ if (!x.isFinite()) {
+ str = nonFiniteToString(x);
+ } else {
+ str = finiteToString(x);
+ i = str.indexOf('.');
+
+ // Use exponential notation according to `toExpPos` and `toExpNeg`? No, but if required:
+ // maxBinaryExponent = floor((decimalExponent + 1) * log[2](10))
+ // minBinaryExponent = floor(decimalExponent * log[2](10))
+ // log[2](10) = 3.321928094887362347870319429489390175864
+
+ if (isExp) {
+ base = 2;
+ if (baseOut == 16) {
+ sd = sd * 4 - 3;
+ } else if (baseOut == 8) {
+ sd = sd * 3 - 2;
+ }
+ } else {
+ base = baseOut;
+ }
+
+ // Convert the number as an integer then divide the result by its base raised to a power such
+ // that the fraction part will be restored.
+
+ // Non-integer.
+ if (i >= 0) {
+ str = str.replace('.', '');
+ y = new Ctor(1);
+ y.e = str.length - i;
+ y.d = convertBase(finiteToString(y), 10, base);
+ y.e = y.d.length;
+ }
+
+ xd = convertBase(str, 10, base);
+ e = len = xd.length;
+
+ // Remove trailing zeros.
+ for (; xd[--len] == 0;) xd.pop();
+
+ if (!xd[0]) {
+ str = isExp ? '0p+0' : '0';
+ } else {
+ if (i < 0) {
+ e--;
+ } else {
+ x = new Ctor(x);
+ x.d = xd;
+ x.e = e;
+ x = divide(x, y, sd, rm, 0, base);
+ xd = x.d;
+ e = x.e;
+ roundUp = inexact;
+ }
+
+ // The rounding digit, i.e. the digit after the digit that may be rounded up.
+ i = xd[sd];
+ k = base / 2;
+ roundUp = roundUp || xd[sd + 1] !== void 0;
+
+ roundUp = rm < 4
+ ? (i !== void 0 || roundUp) && (rm === 0 || rm === (x.s < 0 ? 3 : 2))
+ : i > k || i === k && (rm === 4 || roundUp || rm === 6 && xd[sd - 1] & 1 ||
+ rm === (x.s < 0 ? 8 : 7));
+
+ xd.length = sd;
+
+ if (roundUp) {
+
+ // Rounding up may mean the previous digit has to be rounded up and so on.
+ for (; ++xd[--sd] > base - 1;) {
+ xd[sd] = 0;
+ if (!sd) {
+ ++e;
+ xd.unshift(1);
+ }
+ }
+ }
+
+ // Determine trailing zeros.
+ for (len = xd.length; !xd[len - 1]; --len);
+
+ // E.g. [4, 11, 15] becomes 4bf.
+ for (i = 0, str = ''; i < len; i++) str += NUMERALS.charAt(xd[i]);
+
+ // Add binary exponent suffix?
+ if (isExp) {
+ if (len > 1) {
+ if (baseOut == 16 || baseOut == 8) {
+ i = baseOut == 16 ? 4 : 3;
+ for (--len; len % i; len++) str += '0';
+ xd = convertBase(str, base, baseOut);
+ for (len = xd.length; !xd[len - 1]; --len);
+
+ // xd[0] will always be be 1
+ for (i = 1, str = '1.'; i < len; i++) str += NUMERALS.charAt(xd[i]);
+ } else {
+ str = str.charAt(0) + '.' + str.slice(1);
+ }
+ }
+
+ str = str + (e < 0 ? 'p' : 'p+') + e;
+ } else if (e < 0) {
+ for (; ++e;) str = '0' + str;
+ str = '0.' + str;
+ } else {
+ if (++e > len) for (e -= len; e-- ;) str += '0';
+ else if (e < len) str = str.slice(0, e) + '.' + str.slice(e);
+ }
+ }
+
+ str = (baseOut == 16 ? '0x' : baseOut == 2 ? '0b' : baseOut == 8 ? '0o' : '') + str;
+ }
+
+ return x.s < 0 ? '-' + str : str;
+ }
+
+
+ // Does not strip trailing zeros.
+ function truncate(arr, len) {
+ if (arr.length > len) {
+ arr.length = len;
+ return true;
+ }
+ }
+
+
+ // Decimal methods
+
+
+ /*
+ * abs
+ * acos
+ * acosh
+ * add
+ * asin
+ * asinh
+ * atan
+ * atanh
+ * atan2
+ * cbrt
+ * ceil
+ * clone
+ * config
+ * cos
+ * cosh
+ * div
+ * exp
+ * floor
+ * hypot
+ * ln
+ * log
+ * log2
+ * log10
+ * max
+ * min
+ * mod
+ * mul
+ * pow
+ * random
+ * round
+ * set
+ * sign
+ * sin
+ * sinh
+ * sqrt
+ * sub
+ * tan
+ * tanh
+ * trunc
+ */
+
+
+ /*
+ * Return a new Decimal whose value is the absolute value of `x`.
+ *
+ * x {number|string|Decimal}
+ *
+ */
+ function abs(x) {
+ return new this(x).abs();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the arccosine in radians of `x`.
+ *
+ * x {number|string|Decimal}
+ *
+ */
+ function acos(x) {
+ return new this(x).acos();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the inverse of the hyperbolic cosine of `x`, rounded to
+ * `precision` significant digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal} A value in radians.
+ *
+ */
+ function acosh(x) {
+ return new this(x).acosh();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the sum of `x` and `y`, rounded to `precision` significant
+ * digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal}
+ * y {number|string|Decimal}
+ *
+ */
+ function add(x, y) {
+ return new this(x).plus(y);
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the arcsine in radians of `x`, rounded to `precision`
+ * significant digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal}
+ *
+ */
+ function asin(x) {
+ return new this(x).asin();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the inverse of the hyperbolic sine of `x`, rounded to
+ * `precision` significant digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal} A value in radians.
+ *
+ */
+ function asinh(x) {
+ return new this(x).asinh();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the arctangent in radians of `x`, rounded to `precision`
+ * significant digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal}
+ *
+ */
+ function atan(x) {
+ return new this(x).atan();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the inverse of the hyperbolic tangent of `x`, rounded to
+ * `precision` significant digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal} A value in radians.
+ *
+ */
+ function atanh(x) {
+ return new this(x).atanh();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the arctangent in radians of `y/x` in the range -pi to pi
+ * (inclusive), rounded to `precision` significant digits using rounding mode `rounding`.
+ *
+ * Domain: [-Infinity, Infinity]
+ * Range: [-pi, pi]
+ *
+ * y {number|string|Decimal} The y-coordinate.
+ * x {number|string|Decimal} The x-coordinate.
+ *
+ * atan2(±0, -0) = ±pi
+ * atan2(±0, +0) = ±0
+ * atan2(±0, -x) = ±pi for x > 0
+ * atan2(±0, x) = ±0 for x > 0
+ * atan2(-y, ±0) = -pi/2 for y > 0
+ * atan2(y, ±0) = pi/2 for y > 0
+ * atan2(±y, -Infinity) = ±pi for finite y > 0
+ * atan2(±y, +Infinity) = ±0 for finite y > 0
+ * atan2(±Infinity, x) = ±pi/2 for finite x
+ * atan2(±Infinity, -Infinity) = ±3*pi/4
+ * atan2(±Infinity, +Infinity) = ±pi/4
+ * atan2(NaN, x) = NaN
+ * atan2(y, NaN) = NaN
+ *
+ */
+ function atan2(y, x) {
+ y = new this(y);
+ x = new this(x);
+ var r,
+ pr = this.precision,
+ rm = this.rounding,
+ wpr = pr + 4;
+
+ // Either NaN
+ if (!y.s || !x.s) {
+ r = new this(NaN);
+
+ // Both ±Infinity
+ } else if (!y.d && !x.d) {
+ r = getPi(this, wpr, 1).times(x.s > 0 ? 0.25 : 0.75);
+ r.s = y.s;
+
+ // x is ±Infinity or y is ±0
+ } else if (!x.d || y.isZero()) {
+ r = x.s < 0 ? getPi(this, pr, rm) : new this(0);
+ r.s = y.s;
+
+ // y is ±Infinity or x is ±0
+ } else if (!y.d || x.isZero()) {
+ r = getPi(this, wpr, 1).times(0.5);
+ r.s = y.s;
+
+ // Both non-zero and finite
+ } else if (x.s < 0) {
+ this.precision = wpr;
+ this.rounding = 1;
+ r = this.atan(divide(y, x, wpr, 1));
+ x = getPi(this, wpr, 1);
+ this.precision = pr;
+ this.rounding = rm;
+ r = y.s < 0 ? r.minus(x) : r.plus(x);
+ } else {
+ r = this.atan(divide(y, x, wpr, 1));
+ }
+
+ return r;
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the cube root of `x`, rounded to `precision` significant
+ * digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal}
+ *
+ */
+ function cbrt(x) {
+ return new this(x).cbrt();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is `x` rounded to an integer using `ROUND_CEIL`.
+ *
+ * x {number|string|Decimal}
+ *
+ */
+ function ceil(x) {
+ return finalise(x = new this(x), x.e + 1, 2);
+ }
+
+
+ /*
+ * Configure global settings for a Decimal constructor.
+ *
+ * `obj` is an object with one or more of the following properties,
+ *
+ * precision {number}
+ * rounding {number}
+ * toExpNeg {number}
+ * toExpPos {number}
+ * maxE {number}
+ * minE {number}
+ * modulo {number}
+ * crypto {boolean|number}
+ *
+ * E.g. Decimal.config({ precision: 20, rounding: 4 })
+ *
+ */
+ function config(obj) {
+ if (!obj || typeof obj !== 'object') throw Error(decimalError + 'Object expected');
+ var i, p, v,
+ ps = [
+ 'precision', 1, MAX_DIGITS,
+ 'rounding', 0, 8,
+ 'toExpNeg', -EXP_LIMIT, 0,
+ 'toExpPos', 0, EXP_LIMIT,
+ 'maxE', 0, EXP_LIMIT,
+ 'minE', -EXP_LIMIT, 0,
+ 'modulo', 0, 9
+ ];
+
+ for (i = 0; i < ps.length; i += 3) {
+ if ((v = obj[p = ps[i]]) !== void 0) {
+ if (mathfloor(v) === v && v >= ps[i + 1] && v <= ps[i + 2]) this[p] = v;
+ else throw Error(invalidArgument + p + ': ' + v);
+ }
+ }
+
+ if ((v = obj[p = 'crypto']) !== void 0) {
+ if (v === true || v === false || v === 0 || v === 1) {
+ if (v) {
+ if (typeof crypto != 'undefined' && crypto &&
+ (crypto.getRandomValues || crypto.randomBytes)) {
+ this[p] = true;
+ } else {
+ throw Error(cryptoUnavailable);
+ }
+ } else {
+ this[p] = false;
+ }
+ } else {
+ throw Error(invalidArgument + p + ': ' + v);
+ }
+ }
+
+ return this;
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the cosine of `x`, rounded to `precision` significant
+ * digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal} A value in radians.
+ *
+ */
+ function cos(x) {
+ return new this(x).cos();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the hyperbolic cosine of `x`, rounded to precision
+ * significant digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal} A value in radians.
+ *
+ */
+ function cosh(x) {
+ return new this(x).cosh();
+ }
+
+
+ /*
+ * Create and return a Decimal constructor with the same configuration properties as this Decimal
+ * constructor.
+ *
+ */
+ function clone(obj) {
+ var i, p, ps;
+
+ /*
+ * The Decimal constructor and exported function.
+ * Return a new Decimal instance.
+ *
+ * v {number|string|Decimal} A numeric value.
+ *
+ */
+ function Decimal(v) {
+ var e, i, t,
+ x = this;
+
+ // Decimal called without new.
+ if (!(x instanceof Decimal)) return new Decimal(v);
+
+ // Retain a reference to this Decimal constructor, and shadow Decimal.prototype.constructor
+ // which points to Object.
+ x.constructor = Decimal;
+
+ // Duplicate.
+ if (v instanceof Decimal) {
+ x.s = v.s;
+ x.e = v.e;
+ x.d = (v = v.d) ? v.slice() : v;
+ return;
+ }
+
+ t = typeof v;
+
+ if (t === 'number') {
+ if (v === 0) {
+ x.s = 1 / v < 0 ? -1 : 1;
+ x.e = 0;
+ x.d = [0];
+ return;
+ }
+
+ if (v < 0) {
+ v = -v;
+ x.s = -1;
+ } else {
+ x.s = 1;
+ }
+
+ // Fast path for small integers.
+ if (v === ~~v && v < 1e7) {
+ for (e = 0, i = v; i >= 10; i /= 10) e++;
+ x.e = e;
+ x.d = [v];
+ return;
+
+ // Infinity, NaN.
+ } else if (v * 0 !== 0) {
+ if (!v) x.s = NaN;
+ x.e = NaN;
+ x.d = null;
+ return;
+ }
+
+ return parseDecimal(x, v.toString());
+
+ } else if (t !== 'string') {
+ throw Error(invalidArgument + v);
+ }
+
+ // Minus sign?
+ if (v.charCodeAt(0) === 45) {
+ v = v.slice(1);
+ x.s = -1;
+ } else {
+ x.s = 1;
+ }
+
+ return isDecimal.test(v) ? parseDecimal(x, v) : parseOther(x, v);
+ }
+
+ Decimal.prototype = P;
+
+ Decimal.ROUND_UP = 0;
+ Decimal.ROUND_DOWN = 1;
+ Decimal.ROUND_CEIL = 2;
+ Decimal.ROUND_FLOOR = 3;
+ Decimal.ROUND_HALF_UP = 4;
+ Decimal.ROUND_HALF_DOWN = 5;
+ Decimal.ROUND_HALF_EVEN = 6;
+ Decimal.ROUND_HALF_CEIL = 7;
+ Decimal.ROUND_HALF_FLOOR = 8;
+ Decimal.EUCLID = 9;
+
+ Decimal.config = Decimal.set = config;
+ Decimal.clone = clone;
+
+ Decimal.abs = abs;
+ Decimal.acos = acos;
+ Decimal.acosh = acosh; // ES6
+ Decimal.add = add;
+ Decimal.asin = asin;
+ Decimal.asinh = asinh; // ES6
+ Decimal.atan = atan;
+ Decimal.atanh = atanh; // ES6
+ Decimal.atan2 = atan2;
+ Decimal.cbrt = cbrt; // ES6
+ Decimal.ceil = ceil;
+ Decimal.cos = cos;
+ Decimal.cosh = cosh; // ES6
+ Decimal.div = div;
+ Decimal.exp = exp;
+ Decimal.floor = floor;
+ Decimal.hypot = hypot; // ES6
+ Decimal.ln = ln;
+ Decimal.log = log;
+ Decimal.log10 = log10; // ES6
+ Decimal.log2 = log2; // ES6
+ Decimal.max = max;
+ Decimal.min = min;
+ Decimal.mod = mod;
+ Decimal.mul = mul;
+ Decimal.pow = pow;
+ Decimal.random = random;
+ Decimal.round = round;
+ Decimal.sign = sign; // ES6
+ Decimal.sin = sin;
+ Decimal.sinh = sinh; // ES6
+ Decimal.sqrt = sqrt;
+ Decimal.sub = sub;
+ Decimal.tan = tan;
+ Decimal.tanh = tanh; // ES6
+ Decimal.trunc = trunc; // ES6
+
+ if (obj === void 0) obj = {};
+ if (obj) {
+ ps = ['precision', 'rounding', 'toExpNeg', 'toExpPos', 'maxE', 'minE', 'modulo', 'crypto'];
+ for (i = 0; i < ps.length;) if (!obj.hasOwnProperty(p = ps[i++])) obj[p] = this[p];
+ }
+
+ Decimal.config(obj);
+
+ return Decimal;
+ }
+
+
+ /*
+ * Return a new Decimal whose value is `x` divided by `y`, rounded to `precision` significant
+ * digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal}
+ * y {number|string|Decimal}
+ *
+ */
+ function div(x, y) {
+ return new this(x).div(y);
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the natural exponential of `x`, rounded to `precision`
+ * significant digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal} The power to which to raise the base of the natural log.
+ *
+ */
+ function exp(x) {
+ return new this(x).exp();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is `x` round to an integer using `ROUND_FLOOR`.
+ *
+ * x {number|string|Decimal}
+ *
+ */
+ function floor(x) {
+ return finalise(x = new this(x), x.e + 1, 3);
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the square root of the sum of the squares of the arguments,
+ * rounded to `precision` significant digits using rounding mode `rounding`.
+ *
+ * hypot(a, b, ...) = sqrt(a^2 + b^2 + ...)
+ *
+ */
+ function hypot() {
+ var i, n,
+ t = new this(0);
+
+ external = false;
+
+ for (i = 0; i < arguments.length;) {
+ n = new this(arguments[i++]);
+ if (!n.d) {
+ if (n.s) {
+ external = true;
+ return new this(1 / 0);
+ }
+ t = n;
+ } else if (t.d) {
+ t = t.plus(n.times(n));
+ }
+ }
+
+ external = true;
+
+ return t.sqrt();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the natural logarithm of `x`, rounded to `precision`
+ * significant digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal}
+ *
+ */
+ function ln(x) {
+ return new this(x).ln();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the log of `x` to the base `y`, or to base 10 if no base
+ * is specified, rounded to `precision` significant digits using rounding mode `rounding`.
+ *
+ * log[y](x)
+ *
+ * x {number|string|Decimal} The argument of the logarithm.
+ * y {number|string|Decimal} The base of the logarithm.
+ *
+ */
+ function log(x, y) {
+ return new this(x).log(y);
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the base 2 logarithm of `x`, rounded to `precision`
+ * significant digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal}
+ *
+ */
+ function log2(x) {
+ return new this(x).log(2);
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the base 10 logarithm of `x`, rounded to `precision`
+ * significant digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal}
+ *
+ */
+ function log10(x) {
+ return new this(x).log(10);
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the maximum of the arguments.
+ *
+ * arguments {number|string|Decimal}
+ *
+ */
+ function max() {
+ return maxOrMin(this, arguments, 'lt');
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the minimum of the arguments.
+ *
+ * arguments {number|string|Decimal}
+ *
+ */
+ function min() {
+ return maxOrMin(this, arguments, 'gt');
+ }
+
+
+ /*
+ * Return a new Decimal whose value is `x` modulo `y`, rounded to `precision` significant digits
+ * using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal}
+ * y {number|string|Decimal}
+ *
+ */
+ function mod(x, y) {
+ return new this(x).mod(y);
+ }
+
+
+ /*
+ * Return a new Decimal whose value is `x` multiplied by `y`, rounded to `precision` significant
+ * digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal}
+ * y {number|string|Decimal}
+ *
+ */
+ function mul(x, y) {
+ return new this(x).mul(y);
+ }
+
+
+ /*
+ * Return a new Decimal whose value is `x` raised to the power `y`, rounded to precision
+ * significant digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal} The base.
+ * y {number|string|Decimal} The exponent.
+ *
+ */
+ function pow(x, y) {
+ return new this(x).pow(y);
+ }
+
+
+ /*
+ * Returns a new Decimal with a random value equal to or greater than 0 and less than 1, and with
+ * `sd`, or `Decimal.precision` if `sd` is omitted, significant digits (or less if trailing zeros
+ * are produced).
+ *
+ * [sd] {number} Significant digits. Integer, 0 to MAX_DIGITS inclusive.
+ *
+ */
+ function random(sd) {
+ var d, e, k, n,
+ i = 0,
+ r = new this(1),
+ rd = [];
+
+ if (sd === void 0) sd = this.precision;
+ else checkInt32(sd, 1, MAX_DIGITS);
+
+ k = Math.ceil(sd / LOG_BASE);
+
+ if (!this.crypto) {
+ for (; i < k;) rd[i++] = Math.random() * 1e7 | 0;
+
+ // Browsers supporting crypto.getRandomValues.
+ } else if (crypto.getRandomValues) {
+ d = crypto.getRandomValues(new Uint32Array(k));
+
+ for (; i < k;) {
+ n = d[i];
+
+ // 0 <= n < 4294967296
+ // Probability n >= 4.29e9, is 4967296 / 4294967296 = 0.00116 (1 in 865).
+ if (n >= 4.29e9) {
+ d[i] = crypto.getRandomValues(new Uint32Array(1))[0];
+ } else {
+
+ // 0 <= n <= 4289999999
+ // 0 <= (n % 1e7) <= 9999999
+ rd[i++] = n % 1e7;
+ }
+ }
+
+ // Node.js supporting crypto.randomBytes.
+ } else if (crypto.randomBytes) {
+
+ // buffer
+ d = crypto.randomBytes(k *= 4);
+
+ for (; i < k;) {
+
+ // 0 <= n < 2147483648
+ n = d[i] + (d[i + 1] << 8) + (d[i + 2] << 16) + ((d[i + 3] & 0x7f) << 24);
+
+ // Probability n >= 2.14e9, is 7483648 / 2147483648 = 0.0035 (1 in 286).
+ if (n >= 2.14e9) {
+ crypto.randomBytes(4).copy(d, i);
+ } else {
+
+ // 0 <= n <= 2139999999
+ // 0 <= (n % 1e7) <= 9999999
+ rd.push(n % 1e7);
+ i += 4;
+ }
+ }
+
+ i = k / 4;
+ } else {
+ throw Error(cryptoUnavailable);
+ }
+
+ k = rd[--i];
+ sd %= LOG_BASE;
+
+ // Convert trailing digits to zeros according to sd.
+ if (k && sd) {
+ n = mathpow(10, LOG_BASE - sd);
+ rd[i] = (k / n | 0) * n;
+ }
+
+ // Remove trailing words which are zero.
+ for (; rd[i] === 0; i--) rd.pop();
+
+ // Zero?
+ if (i < 0) {
+ e = 0;
+ rd = [0];
+ } else {
+ e = -1;
+
+ // Remove leading words which are zero and adjust exponent accordingly.
+ for (; rd[0] === 0; e -= LOG_BASE) rd.shift();
+
+ // Count the digits of the first word of rd to determine leading zeros.
+ for (k = 1, n = rd[0]; n >= 10; n /= 10) k++;
+
+ // Adjust the exponent for leading zeros of the first word of rd.
+ if (k < LOG_BASE) e -= LOG_BASE - k;
+ }
+
+ r.e = e;
+ r.d = rd;
+
+ return r;
+ }
+
+
+ /*
+ * Return a new Decimal whose value is `x` rounded to an integer using rounding mode `rounding`.
+ *
+ * To emulate `Math.round`, set rounding to 7 (ROUND_HALF_CEIL).
+ *
+ * x {number|string|Decimal}
+ *
+ */
+ function round(x) {
+ return finalise(x = new this(x), x.e + 1, this.rounding);
+ }
+
+
+ /*
+ * Return
+ * 1 if x > 0,
+ * -1 if x < 0,
+ * 0 if x is 0,
+ * -0 if x is -0,
+ * NaN otherwise
+ *
+ */
+ function sign(x) {
+ x = new this(x);
+ return x.d ? (x.d[0] ? x.s : 0 * x.s) : x.s || NaN;
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the sine of `x`, rounded to `precision` significant digits
+ * using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal} A value in radians.
+ *
+ */
+ function sin(x) {
+ return new this(x).sin();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the hyperbolic sine of `x`, rounded to `precision`
+ * significant digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal} A value in radians.
+ *
+ */
+ function sinh(x) {
+ return new this(x).sinh();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the square root of `x`, rounded to `precision` significant
+ * digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal}
+ *
+ */
+ function sqrt(x) {
+ return new this(x).sqrt();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is `x` minus `y`, rounded to `precision` significant digits
+ * using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal}
+ * y {number|string|Decimal}
+ *
+ */
+ function sub(x, y) {
+ return new this(x).sub(y);
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the tangent of `x`, rounded to `precision` significant
+ * digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal} A value in radians.
+ *
+ */
+ function tan(x) {
+ return new this(x).tan();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is the hyperbolic tangent of `x`, rounded to `precision`
+ * significant digits using rounding mode `rounding`.
+ *
+ * x {number|string|Decimal} A value in radians.
+ *
+ */
+ function tanh(x) {
+ return new this(x).tanh();
+ }
+
+
+ /*
+ * Return a new Decimal whose value is `x` truncated to an integer.
+ *
+ * x {number|string|Decimal}
+ *
+ */
+ function trunc(x) {
+ return finalise(x = new this(x), x.e + 1, 1);
+ }
+
+
+ // Create and configure initial Decimal constructor.
+ Decimal = clone(Decimal);
+
+ // Create the internal constants from their string values.
+ LN10 = new Decimal(LN10);
+ PI = new Decimal(PI);
+
+
+ // Export.
+
+
+ // AMD.
+ if (true) {
+ !(__WEBPACK_AMD_DEFINE_RESULT__ = (function () {
+ return Decimal;
+ }).call(exports, __webpack_require__, exports, module),
+ __WEBPACK_AMD_DEFINE_RESULT__ !== undefined && (module.exports = __WEBPACK_AMD_DEFINE_RESULT__));
+
+ // Node and other environments that support module.exports.
+ } else {}
+})(this);
+
+
+/***/ }),
+/* 24 */
+/*!*************************!*\
+ !*** ./src/Settings.js ***!
+ \*************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Settings", function() { return Settings; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSettings", function() { return initSettings; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setSettingsLabels", function() { return setSettingsLabels; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadSettings", function() { return loadSettings; });
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.js */ 5);
+
+
+/* Settings.js */
+let Settings = {
+ CodeInstructionRunTime: 50,
+ MaxLogCapacity: 50,
+ MaxPortCapacity: 50,
+ SuppressMessages: false,
+ SuppressFactionInvites: false,
+ AutosaveInterval: 60,
+ ThemeHighlightColor: "#ffffff",
+ ThemeFontColor: "#66ff33",
+ ThemeBackgroundColor: "#000000",
+ EditorTheme: "Monokai",
+ EditorKeybinding: "ace",
+}
+
+function loadSettings(saveString) {
+ Settings = JSON.parse(saveString);
+}
+
+function initSettings() {
+ Settings.CodeInstructionRunTime = 50;
+ Settings.MaxLogCapacity = 50;
+ Settings.MaxPortCapacity = 50;
+ Settings.SuppressMessages = false;
+ Settings.SuppressFactionInvites = false;
+ Settings.AutosaveInterval = 60;
+}
+
+function setSettingsLabels() {
+ var nsExecTime = document.getElementById("settingsNSExecTimeRangeValLabel");
+ var nsLogLimit = document.getElementById("settingsNSLogRangeValLabel");
+ var nsPortLimit = document.getElementById("settingsNSPortRangeValLabel");
+ var suppressMsgs = document.getElementById("settingsSuppressMessages");
+ var suppressFactionInv = document.getElementById("settingsSuppressFactionInvites")
+ var autosaveInterval = document.getElementById("settingsAutosaveIntervalValLabel");
+
+ //Initialize values on labels
+ nsExecTime.innerHTML = Settings.CodeInstructionRunTime + "ms";
+ nsLogLimit.innerHTML = Settings.MaxLogCapacity;
+ nsPortLimit.innerHTML = Settings.MaxPortCapacity;
+ suppressMsgs.checked = Settings.SuppressMessages;
+ suppressFactionInv.checked = Settings.SuppressFactionInvites;
+ autosaveInterval.innerHTML = Settings.AutosaveInterval;
+
+ //Set handlers for when input changes
+ var nsExecTimeInput = document.getElementById("settingsNSExecTimeRangeVal");
+ var nsLogRangeInput = document.getElementById("settingsNSLogRangeVal");
+ var nsPortRangeInput = document.getElementById("settingsNSPortRangeVal");
+ var nsAutosaveIntervalInput = document.getElementById("settingsAutosaveIntervalVal");
+ nsExecTimeInput.value = Settings.CodeInstructionRunTime;
+ nsLogRangeInput.value = Settings.MaxLogCapacity;
+ nsPortRangeInput.value = Settings.MaxPortCapacity;
+ nsAutosaveIntervalInput.value = Settings.AutosaveInterval;
+
+ nsExecTimeInput.oninput = function() {
+ nsExecTime.innerHTML = this.value + 'ms';
+ Settings.CodeInstructionRunTime = this.value;
+ };
+
+ nsLogRangeInput.oninput = function() {
+ nsLogLimit.innerHTML = this.value;
+ Settings.MaxLogCapacity = this.value;
+ };
+
+ nsPortRangeInput.oninput = function() {
+ nsPortLimit.innerHTML = this.value;
+ Settings.MaxPortCapacity = this.value;
+ };
+
+ nsAutosaveIntervalInput.oninput = function() {
+ autosaveInterval.innerHTML = this.value;
+ Settings.AutosaveInterval = Number(this.value);
+ if (Number(this.value) === 0) {
+ _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = Infinity;
+ } else {
+ _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = Number(this.value) * 5;
+ }
+ };
+
+ document.getElementById("settingsSuppressMessages").onclick = function() {
+ Settings.SuppressMessages = this.checked;
+ };
+
+ document.getElementById("settingsSuppressFactionInvites").onclick = function() {
+ Settings.SuppressFactionInvites = this.checked;
+ };
+
+ //Theme
+ if (Settings.ThemeHighlightColor == null || Settings.ThemeFontColor == null || Settings.ThemeBackgroundColor == null) {
+ console.log("ERROR: Cannot find Theme Settings");
+ return;
+ }
+ if (/^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeHighlightColor) &&
+ /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeFontColor) &&
+ /^#[0-9a-f]{3}(?:[0-9a-f]{3})?$/i.test(Settings.ThemeBackgroundColor)) {
+ document.body.style.setProperty('--my-highlight-color', Settings.ThemeHighlightColor);
+ document.body.style.setProperty('--my-font-color', Settings.ThemeFontColor);
+ document.body.style.setProperty('--my-background-color', Settings.ThemeBackgroundColor);
+ }
+}
+
+
+
+
+/***/ }),
+/* 25 */
+/*!************************************!*\
+ !*** ./src/InteractiveTutorial.js ***!
+ \************************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "iTutorialSteps", function() { return iTutorialSteps; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "iTutorialEnd", function() { return iTutorialEnd; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "iTutorialStart", function() { return iTutorialStart; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "iTutorialNextStep", function() { return iTutorialNextStep; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "currITutorialStep", function() { return currITutorialStep; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "iTutorialIsRunning", function() { return iTutorialIsRunning; });
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+
+
+
+
+
+/* InteractiveTutorial.js */
+let iTutorialSteps = {
+ Start: "Start",
+ GoToCharacterPage: "Click on the Character page menu link",
+ CharacterPage: "Introduction to Character page",
+ CharacterGoToTerminalPage: "Click on the Terminal link",
+ TerminalIntro: "Introduction to terminal interface",
+ TerminalHelp: "Using the help command to display all options in terminal",
+ TerminalLs: "Use the ls command to show all programs/scripts. Right now we have NUKE.exe",
+ TerminalScan: "Using the scan command to display all available connections",
+ TerminalScanAnalyze1: "Use the scan-analyze command to show hacking related information",
+ TerminalScanAnalyze2: "Use the scan-analyze command with a depth of 3",
+ TerminalConnect: "Using the telnet/connect command to connect to another server",
+ TerminalAnalyze: "Use the analyze command to display details about this server",
+ TerminalNuke: "Use the NUKE Program to gain root access to a server",
+ TerminalManualHack: "Use the hack command to manually hack a server",
+ TerminalHackingMechanics: "Briefly explain hacking mechanics",
+ TerminalCreateScript: "Create a script using nano",
+ TerminalTypeScript: "This occurs in the Script Editor page...type the script then save and close",
+ TerminalFree: "Use the free command to check RAM",
+ TerminalRunScript: "Use the run command to run a script",
+ TerminalGoToActiveScriptsPage: "Go to the ActiveScriptsPage",
+ ActiveScriptsPage: "Introduction to the Active Scripts Page",
+ ActiveScriptsToTerminal: "Go from Active Scripts Page Back to Terminal",
+ TerminalTailScript: "Use the tail command to show a script's logs",
+ GoToHacknetNodesPage: "Go to the Hacknet Nodes page",
+ HacknetNodesIntroduction: "Introduction to Hacknet Nodesm and have user purchase one",
+ HacknetNodesGoToWorldPage: "Go to the world page",
+ WorldDescription: "Tell the user to explore..theres a lot of different stuff to do out there",
+ TutorialPageInfo: "The tutorial page contains a lot of info on different subjects",
+ End: "End",
+}
+
+var currITutorialStep = iTutorialSteps.Start;
+var iTutorialIsRunning = false;
+
+function iTutorialStart() {
+ //Don't autosave during this interactive tutorial
+ _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = 999000000000;
+ console.log("Interactive Tutorial started");
+ currITutorialStep = iTutorialSteps.Start;
+ iTutorialIsRunning = true;
+
+ document.getElementById("interactive-tutorial-container").style.display = "block";
+
+ iTutorialEvaluateStep();
+
+ //Exit tutorial button
+ var exitButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("interactive-tutorial-exit");
+ exitButton.addEventListener("click", function() {
+ iTutorialEnd();
+ return false;
+ });
+
+ //Back button
+ var backButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("interactive-tutorial-back");
+ backButton.style.display = "none";
+ backButton.addEventListener("click", function() {
+ iTutorialPrevStep();
+ return false;
+ });
+}
+
+function iTutorialEvaluateStep() {
+ if (!iTutorialIsRunning) {console.log("Interactive Tutorial not running"); return;}
+ switch(currITutorialStep) {
+ case iTutorialSteps.Start:
+ _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
+
+ iTutorialSetText("Welcome to Bitburner, a cyberpunk-themed incremental RPG! " +
+ "The game takes place in a dark, dystopian future...The year is 2077...
" +
+ "This tutorial will show you the basics of the game. " +
+ "You may skip the tutorial at any time.");
+ var next = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("interactive-tutorial-next");
+ next.style.display = "inline-block";
+ next.addEventListener("click", function() {
+ iTutorialNextStep();
+ return false;
+ });
+ break;
+ case iTutorialSteps.GoToCharacterPage:
+ 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)");
+
+ //No next button
+ var next = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("interactive-tutorial-next");
+ next.style.display = "none";
+
+ //Flash Character tab
+ document.getElementById("stats-menu-link").setAttribute("class", "flashing-button");
+
+ //Initialize everything necessary to open the "Character" page
+ var charaterMainMenuButton = document.getElementById("stats-menu-link");
+ charaterMainMenuButton.addEventListener("click", function() {
+ _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadCharacterContent();
+ iTutorialNextStep(); //Opening the character page will go to the next step
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("stats-menu-link");
+ return false;
+ });
+ break;
+ case iTutorialSteps.CharacterPage:
+ iTutorialSetText("The Stats page shows a lot of important information about your progress, " +
+ "such as your skills, money, and bonuses/multipliers. ")
+ var next = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("interactive-tutorial-next");
+ next.style.display = "inline-block";
+ next.addEventListener("click", function() {
+ iTutorialNextStep();
+ return false;
+ });
+ break;
+ case iTutorialSteps.CharacterGoToTerminalPage:
+ iTutorialSetText("Let's head to your computer's terminal by clicking the 'Terminal' tab on the " +
+ "main navigation menu.");
+ //No next button
+ var next = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("interactive-tutorial-next");
+ next.style.display = "none";
+
+ document.getElementById("terminal-menu-link").setAttribute("class", "flashing-button");
+
+ //Initialize everything necessary to open the 'Terminal' Page
+ var terminalMainMenuButton = document.getElementById("terminal-menu-link");
+ terminalMainMenuButton.addEventListener("click", function() {
+ _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
+ iTutorialNextStep();
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("terminal-menu-link");
+ return false;
+ });
+ break;
+ case iTutorialSteps.TerminalIntro:
+ iTutorialSetText("The Terminal is used to interface with your home computer as well as " +
+ "all of the other machines around the world.");
+ var next = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("interactive-tutorial-next");
+ next.style.display = "inline-block";
+ next.addEventListener("click", function() {
+ iTutorialNextStep();
+ return false;
+ });
+ break;
+ case iTutorialSteps.TerminalHelp:
+ 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)");
+ var next = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("interactive-tutorial-next");
+ next.style.display = "none";
+ //next step triggered by terminal command
+ break;
+ case iTutorialSteps.TerminalLs:
+ 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");
+ //next step triggered by terminal command
+ break;
+ case iTutorialSteps.TerminalScan:
+ 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. ");
+ //next step triggered by terminal command
+ break;
+ case iTutorialSteps.TerminalScanAnalyze1:
+ 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");
+ //next step triggered by terminal command
+ break;
+ case iTutorialSteps.TerminalScanAnalyze2:
+ 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'.")
+ //next step triggered by terminal command
+ break;
+ case iTutorialSteps.TerminalConnect:
+ 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'");
+ //next step triggered by terminal command
+ break;
+ case iTutorialSteps.TerminalAnalyze:
+ 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");
+ //next step triggered by terminal command
+ break;
+ case iTutorialSteps.TerminalNuke:
+ 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.");
+ //next step triggered by terminal command
+ break;
+ case iTutorialSteps.TerminalManualHack:
+ iTutorialSetText("You now have root access! You can hack the server using the 'hack' command. " +
+ "Try doing that now.");
+ //next step triggered by terminal command
+ break;
+ case iTutorialSteps.TerminalHackingMechanics:
+ 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.");
+ var next = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("interactive-tutorial-next");
+ next.style.display = "inline-block";
+ next.addEventListener("click", function() {
+ iTutorialNextStep();
+ return false;
+ });
+ break;
+ case iTutorialSteps.TerminalCreateScript:
+ 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)");
+ var next = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("interactive-tutorial-next");
+ next.style.display = "none";
+ //next step triggered by terminal command
+ break;
+ case iTutorialSteps.TerminalTypeScript:
+ 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.");
+ //next step triggered in saveAndCloseScriptEditor() (Script.js)
+ break;
+ case iTutorialSteps.TerminalFree:
+ 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.");
+ //next step triggered by terminal commmand
+ break;
+ case iTutorialSteps.TerminalRunScript:
+ 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'.");
+ //next step triggered by terminal commmand
+ break;
+ case iTutorialSteps.TerminalGoToActiveScriptsPage:
+ 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.");
+ document.getElementById("active-scripts-menu-link").setAttribute("class", "flashing-button");
+ var activeScriptsMainMenuButton = document.getElementById("active-scripts-menu-link");
+ activeScriptsMainMenuButton.addEventListener("click", function() {
+ _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadActiveScriptsContent();
+ iTutorialNextStep();
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("active-scripts-menu-link");
+ return false;
+ });
+ break;
+ case iTutorialSteps.ActiveScriptsPage:
+ 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.");
+ document.getElementById("terminal-menu-link").setAttribute("class", "flashing-button");
+ //Initialize everything necessary to open the 'Terminal' Page
+ var terminalMainMenuButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("terminal-menu-link");
+ terminalMainMenuButton.addEventListener("click", function() {
+ _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTerminalContent();
+ iTutorialNextStep();
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("terminal-menu-link");
+ return false;
+ });
+ break;
+ case iTutorialSteps.ActiveScriptsToTerminal:
+ 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'");
+ //next step triggered by terminal command
+ break;
+ case iTutorialSteps.TerminalTailScript:
+ 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. For now, let's move on " +
+ "to something else!");
+ var next = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("interactive-tutorial-next");
+ next.style.display = "inline-block";
+ next.addEventListener("click", function() {
+ iTutorialNextStep();
+ return false;
+ });
+ break;
+ case iTutorialSteps.GoToHacknetNodesPage:
+ 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.");
+ document.getElementById("hacknet-nodes-menu-link").setAttribute("class", "flashing-button");
+ var hacknetNodesButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("hacknet-nodes-menu-link");
+ var next = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("interactive-tutorial-next");
+ next.style.display = "none";
+ hacknetNodesButton.addEventListener("click", function() {
+ _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadHacknetNodesContent();
+ iTutorialNextStep();
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("hacknet-nodes-menu-link");
+ return false;
+ });
+ break;
+ case iTutorialSteps.HacknetNodesIntroduction:
+ iTutorialSetText("From this page you can purchase new Hacknet Nodes and upgrade your " +
+ "existing ones. Let's purchase a new one now.");
+ //Next step triggered by purchaseHacknet() (HacknetNode.js)
+ break;
+ case iTutorialSteps.HacknetNodesGoToWorldPage:
+ 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.");
+ document.getElementById("city-menu-link").setAttribute("class", "flashing-button");
+ var worldButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("city-menu-link");
+ worldButton.addEventListener("click", function() {
+ _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadWorldContent();
+ iTutorialNextStep();
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("city-menu-link");
+ return false;
+ });
+ break;
+ case iTutorialSteps.WorldDescription:
+ 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.");
+ document.getElementById("tutorial-menu-link").setAttribute("class", "flashing-button");
+ var tutorialButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("tutorial-menu-link");
+ tutorialButton.addEventListener("click", function() {
+ _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].loadTutorialContent();
+ iTutorialNextStep();
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("tutorial-menu-link");
+ return false;
+ });
+ break;
+
+ case iTutorialSteps.TutorialPageInfo:
+ 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!");
+ var next = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("interactive-tutorial-next");
+ next.style.display = "inline-block";
+ next.innerHTML = "Finish Tutorial";
+
+ var backButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_3__["clearEventListeners"])("interactive-tutorial-back");
+ backButton.style.display = "none";
+
+ next.addEventListener("click", function() {
+ iTutorialNextStep();
+ return false;
+ });
+ break;
+ case iTutorialSteps.End:
+ iTutorialEnd();
+ break;
+ default:
+ throw new Error("Invalid tutorial step");
+ }
+}
+
+//Go to the next step and evaluate it
+function iTutorialNextStep() {
+ switch(currITutorialStep) {
+ case iTutorialSteps.Start:
+ currITutorialStep = iTutorialSteps.GoToCharacterPage;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.GoToCharacterPage:
+ document.getElementById("stats-menu-link").removeAttribute("class");
+ currITutorialStep = iTutorialSteps.CharacterPage;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.CharacterPage:
+ currITutorialStep = iTutorialSteps.CharacterGoToTerminalPage;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.CharacterGoToTerminalPage:
+ document.getElementById("terminal-menu-link").removeAttribute("class");
+ currITutorialStep = iTutorialSteps.TerminalIntro;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalIntro:
+ currITutorialStep = iTutorialSteps.TerminalHelp;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalHelp:
+ currITutorialStep = iTutorialSteps.TerminalLs;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalLs:
+ currITutorialStep = iTutorialSteps.TerminalScan;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalScan:
+ currITutorialStep = iTutorialSteps.TerminalScanAnalyze1;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalScanAnalyze1:
+ currITutorialStep = iTutorialSteps.TerminalScanAnalyze2;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalScanAnalyze2:
+ currITutorialStep = iTutorialSteps.TerminalConnect;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalConnect:
+ currITutorialStep = iTutorialSteps.TerminalAnalyze;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalAnalyze:
+ currITutorialStep = iTutorialSteps.TerminalNuke;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalNuke:
+ currITutorialStep = iTutorialSteps.TerminalManualHack;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalManualHack:
+ currITutorialStep = iTutorialSteps.TerminalHackingMechanics;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalHackingMechanics:
+ currITutorialStep = iTutorialSteps.TerminalCreateScript;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalCreateScript:
+ currITutorialStep = iTutorialSteps.TerminalTypeScript;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalTypeScript:
+ currITutorialStep = iTutorialSteps.TerminalFree;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalFree:
+ currITutorialStep = iTutorialSteps.TerminalRunScript;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalRunScript:
+ currITutorialStep = iTutorialSteps.TerminalGoToActiveScriptsPage;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalGoToActiveScriptsPage:
+ document.getElementById("active-scripts-menu-link").removeAttribute("class");
+ currITutorialStep = iTutorialSteps.ActiveScriptsPage;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.ActiveScriptsPage:
+ document.getElementById("terminal-menu-link").removeAttribute("class");
+ currITutorialStep = iTutorialSteps.ActiveScriptsToTerminal;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.ActiveScriptsToTerminal:
+ currITutorialStep = iTutorialSteps.TerminalTailScript;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalTailScript:
+ currITutorialStep = iTutorialSteps.GoToHacknetNodesPage;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.GoToHacknetNodesPage:
+ document.getElementById("hacknet-nodes-menu-link").removeAttribute("class");
+ currITutorialStep = iTutorialSteps.HacknetNodesIntroduction;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.HacknetNodesIntroduction:
+ currITutorialStep = iTutorialSteps.HacknetNodesGoToWorldPage;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.HacknetNodesGoToWorldPage:
+ document.getElementById("city-menu-link").removeAttribute("class");
+ currITutorialStep = iTutorialSteps.WorldDescription;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.WorldDescription:
+ document.getElementById("tutorial-menu-link").removeAttribute("class");
+ currITutorialStep = iTutorialSteps.TutorialPageInfo;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TutorialPageInfo:
+ currITutorialStep = iTutorialSteps.End;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.End:
+ break;
+ default:
+ throw new Error("Invalid tutorial step");
+ }
+}
+
+//Go to previous step and evaluate
+function iTutorialPrevStep() {
+ switch(currITutorialStep) {
+ case iTutorialSteps.Start:
+ currITutorialStep = iTutorialSteps.Start;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.GoToCharacterPage:
+ currITutorialStep = iTutorialSteps.Start;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.CharacterPage:
+ currITutorialStep = iTutorialSteps.GoToCharacterPage;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.CharacterGoToTerminalPage:
+ currITutorialStep = iTutorialSteps.CharacterPage;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalIntro:
+ currITutorialStep = iTutorialSteps.CharacterGoToTerminalPage;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalHelp:
+ currITutorialStep = iTutorialSteps.TerminalIntro;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalLs:
+ currITutorialStep = iTutorialSteps.TerminalHelp;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalScan:
+ currITutorialStep = iTutorialSteps.TerminalLs;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalConnect:
+ currITutorialStep = iTutorialSteps.TerminalScan;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalAnalyze:
+ currITutorialStep = iTutorialSteps.TerminalConnect;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalNuke:
+ currITutorialStep = iTutorialSteps.TerminalAnalyze;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalManualHack:
+ currITutorialStep = iTutorialSteps.TerminalNuke;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalHackingMechanics:
+ currITutorialStep = iTutorialSteps.TerminalManualHack;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalCreateScript:
+ currITutorialStep = iTutorialSteps.TerminalManualHack;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalTypeScript:
+ currITutorialStep = iTutorialSteps.TerminalCreateScript;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalFree:
+ currITutorialStep = iTutorialSteps.TerminalTypeScript;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalRunScript:
+ currITutorialStep = iTutorialSteps.TerminalFree;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalGoToActiveScriptsPage:
+ currITutorialStep = iTutorialSteps.TerminalRunScript;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.ActiveScriptsPage:
+ currITutorialStep = iTutorialSteps.TerminalGoToActiveScriptsPage;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.ActiveScriptsToTerminal:
+ currITutorialStep = iTutorialSteps.ActiveScriptsPage;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TerminalTailScript:
+ currITutorialStep = iTutorialSteps.ActiveScriptsToTerminal;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.GoToHacknetNodesPage:
+ currITutorialStep = iTutorialSteps.TerminalTailScript;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.HacknetNodesIntroduction:
+ currITutorialStep = iTutorialSteps.GoToHacknetNodesPage;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.HacknetNodesGoToWorldPage:
+ currITutorialStep = iTutorialSteps.HacknetNodesIntroduction;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.WorldDescription:
+ currITutorialStep = iTutorialSteps.HacknetNodesGoToWorldPage;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.TutorialPageInfo:
+ currITutorialStep = iTutorialSteps.WorldDescription;
+ iTutorialEvaluateStep();
+ break;
+ case iTutorialSteps.End:
+ break;
+ default:
+ throw new Error("Invalid tutorial step");
+ }
+}
+
+function iTutorialEnd() {
+ //Re-enable auto save
+ _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].Counters.autoSaveCounter = 300;
+ console.log("Ending interactive tutorial");
+ _engine_js__WEBPACK_IMPORTED_MODULE_0__["Engine"].init();
+ currITutorialStep = iTutorialSteps.End;
+ iTutorialIsRunning = false;
+ document.getElementById("interactive-tutorial-container").style.display = "none";
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_2__["dialogBoxCreate"])("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");
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].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
+}
+
+
+
+
+/***/ }),
+/* 26 */
+/*!****************************!*\
+ !*** ./src/FactionInfo.js ***!
+ \****************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FactionInfo", function() { return FactionInfo; });
+//Contains the "information" property for all the Factions, which is just a description
+//of each faction
+let FactionInfo = {
+ //Endgame
+ IlluminatiInfo: "Humanity never changes. No matter how civilized society becomes, it will eventually fall back " +
+ "into chaos. And from this chaos, we are the Invisible hand that guides them to order. ",
+
+ DaedalusInfo: "Yesterday we obeyed kings and bent our necks to emperors. Today we kneel only to truth.",
+
+ CovenantInfo: "Surrender yourself. Give up your empty individuality to become part of something great, something eternal. " +
+ "Become a slave. Submit your mind, body, and soul. Only then can you set yourself free.
" +
+ "Only then can you discover immortality.",
+
+ //Megacorporations, each forms its own faction
+ ECorpInfo: "ECorp's mission is simple: to connect the world of today with the technology of tomorrow. " +
+ "With our wide range of Internet-related software and commercial hardware, ECorp makes the world's " +
+ "information universally accessible.",
+
+ MegaCorpInfo: "MegaCorp does things that others don't. We imagine. We create. We invent. We build things that " +
+ "others have never even dreamed of. Our work fills the world's needs for food, water, power, and " +
+ "transporation on an unprecendented scale, in ways that no other company can.
" +
+ "In our labs and factories and on the ground with customers, MegaCorp is ushering in a new era for the world.",
+
+ BachmanAndAssociatesInfo: "Where Law and Business meet - thats where we are.
" +
+ "Legal Insight - Business Instinct - Experience Innovation",
+
+ BladeIndustriesInfo: "Augmentation is salvation",
+
+ NWOInfo: "The human being does not truly desire freedom. It wants " +
+ "to be observed, understood, and judged. It wants to be given purpose and " +
+ "direction in its life. That is why humans created God. " +
+ "And that is why humans created civilization - " +
+ "not because of willingness, " +
+ "but because of a need to be incorporated into higher orders of structure and meaning.",
+
+ ClarkeIncorporatedInfo: "Unlocking the power of the genome",
+
+ OmniTekIncorporatedInfo: "Simply put, our mission is to design and build robots that make a difference",
+
+ FourSigmaInfo: "The scientific method is the best way to approach investing. Big strategies backed up with big data. Driven by " +
+ "deep learning and innovative ideas. And improved by iteration. That's Four Sigma.",
+
+ KuaiGongInternationalInfo: "Dream big. Work hard. Make history.",
+
+ //Other Corporations
+ FulcrumSecretTechnologiesInfo: "The human organism has an innate desire to worship. " +
+ "That is why they created gods. If there were no gods, " +
+ "it would be necessary to create them. And now we can.",
+
+ //Hacker groups
+ BitRunnersInfo: "Our entire lives are controlled by bits. All of our actions, our thoughts, our personal information. "+
+ "It's all transformed into bits, stored in bits, communicated through bits. It’s impossible for any person " +
+ "to move, to live, to operate at any level without the use of bits. " +
+ "And when a person moves, lives, and operates, they leave behind their bits, mere traces of seemingly " +
+ "meaningless fragments of information. But these bits can be reconstructed. Transformed. Used.
" +
+ "Those who run the bits, run the world",
+
+
+ BlackHandInfo: "The world, so afraid of strong government, now has no government. Only power - Digital power. Financial power. " +
+ "Technological power. " +
+ "And those at the top rule with an invisible hand. They built a society where the rich get richer, " +
+ "and everyone else suffers.
" +
+ "So much pain. So many lives. Their darkness must end.",
+
+ NiteSecInfo:
+" __..__ " +
+" _.nITESECNIt. " +
+" .-'NITESECNITESEc. " +
+" .' NITESECNITESECn " +
+" / NITESECNITESEC; " +
+" : :NITESECNITESEC; " +
+" ; $ NITESECNITESECN " +
+" : _, ,N'ITESECNITESEC " +
+" : .+^^`, : `NITESECNIT " +
+" ) /), `-,-=,NITESECNI " +
+" / ^ ,-;|NITESECN; " +
+" / _.' '-';NITESECN " +
+" ( , ,-''`^NITE' " +
+" )` :`. .' " +
+" )-- ; `- / " +
+" \' _.-' : " +
+" ( _.-' \. \ " +
+" \------. \ \ " +
+" \. \ \ " +
+" \ _.nIt " +
+" \ _.nITESECNi " +
+" nITESECNIT^' \ " +
+" NITE^' ___ \ " +
+" / .gP''''Tp. \ " +
+" : d' . `b \ " +
+" ; d' o `b ; " +
+" / d; `b| " +
+" /, $; @ `: " +
+" /' $$ ; " +
+" .' $$b o | " +
+" .' d$$$; : " +
+" / .d$$$$; , ; " +
+" d .dNITESEC $ | " +
+" :bp.__.gNITESEC$$ :$ ; " +
+" NITESECNITESECNIT $$b : ",
+
+ //City factions, essentially governments
+ ChongqingInfo: "Serve the people",
+ Sector12Info: "The City of the Future",
+ HongKongInfo: "Asia's World City",
+ AevumInfo: "The Silicon City",
+ IshimaInfo: "The East Asian Order of the Future",
+ VolhavenInfo: "Benefit, Honour, and Glory",
+
+ //Criminal Organizations/Gangs
+ SpeakersForTheDeadInfo: "It is better to reign in hell than to serve in heaven.",
+
+ DarkArmyInfo: "The World doesn't care about right or wrong. It's all about power.",
+
+ TheSyndicateInfo: "Honor holds you back",
+
+ SilhouetteInfo: "Corporations have filled the void of power left behind by the collapse of Western government. The issue is they've become so big " +
+ "that you don't know who they're working for. And if you're employed at one of these corporations, you don't even know who you're working " +
+ "for.\n\n" +
+ "That's terror. Terror, fear, and corruption. All born into the system, all propagated by the system.",
+
+ TetradsInfo: "Following the Mandate of Heaven and Carrying out the Way",
+
+ SlumSnakesInfo: "Slum Snakes rule!",
+
+ //Earlygame factions - factions the player will prestige with early on that don't
+ //belong in other categories
+ NetburnersInfo: "~~//*>H4CK|\|3T 8URN3R5**>?>\\~~",
+
+ TianDiHuiInfo: "Obey Heaven and Work Righteousness",
+
+ CyberSecInfo: "The Internet is the first thing that humanity has built that humanity doesn’t understand, " +
+ "the largest experiment in anarchy that we have ever had. And as the world becomes increasingly " +
+ "dominated by the internet, society approaches the brink of total chaos. " +
+ "We serve only to protect society, to protect humanity, to protect the world from its imminent collapse.",
+
+ //Special Factions
+ BladeburnersInfo: "It's too bad they won't live. But then again, who does?
" +
+ "This message was saved as " + msg.filename + " onto your home computer.";
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxCreate"])(txt);
+}
+
+//Adds a message to a server
+function addMessageToServer(msg, serverHostname) {
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_5__["GetServerByHostname"])(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 (_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["Augmentations"][_Augmentations_js__WEBPACK_IMPORTED_MODULE_0__["AugmentationNames"].TheRedPill].owned) {
+ redpillOwned = true;
+ }
+
+ if (redpill && redpillOwned && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].sourceFiles.length === 0 && !_RedPill_js__WEBPACK_IMPORTED_MODULE_4__["redPillFlag"] && !_Missions_js__WEBPACK_IMPORTED_MODULE_2__["inMission"]) {
+ if (!_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxOpened"]) {
+ sendMessage(redpill, true);
+ }
+ } else if (redpill && redpillOwned) {
+ //If player has already destroyed a BitNode, message is not forced
+ if (!_RedPill_js__WEBPACK_IMPORTED_MODULE_4__["redPillFlag"] && !_Missions_js__WEBPACK_IMPORTED_MODULE_2__["inMission"] && !_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_7__["dialogBoxOpened"]) {
+ sendMessage(redpill);
+ }
+ } else if (jumper0 && !jumper0.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 25) {
+ sendMessage(jumper0);
+ _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_1__["Programs"].Flight);
+ } else if (jumper1 && !jumper1.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 40) {
+ sendMessage(jumper1);
+ } else if (cybersecTest && !cybersecTest.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 50) {
+ sendMessage(cybersecTest);
+ } else if (jumper2 && !jumper2.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 175) {
+ sendMessage(jumper2);
+ } else if (nitesecTest && !nitesecTest.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 200) {
+ sendMessage(nitesecTest);
+ } else if (jumper3 && !jumper3.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 350) {
+ sendMessage(jumper3);
+ } else if (jumper4 && !jumper4.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 490) {
+ sendMessage(jumper4);
+ } else if (bitrunnersTest && !bitrunnersTest.recvd && _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill >= 500) {
+ sendMessage(bitrunnersTest);
+ }
+}
+
+function AddToAllMessages(msg) {
+ Messages[msg.filename] = msg;
+}
+
+let Messages = {}
+
+function loadMessages(saveString) {
+ Messages = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_8__["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.
" +
+ "We can help you find the answers.
" +
+ "run4theh111z"));
+
+ AddToAllMessages(new Message(MessageFilenames.RedPill,
+ "@)(#V%*N)@(#*)*C)@#%*)*V)@#(*%V@)(#VN%*)@#(*% " +
+ ")@B(*#%)@)M#B*%V)____FIND___#$@)#%(B*)@#(*%B) " +
+ "@_#(%_@#M(BDSPOMB__THE-CAVE_#)$(*@#$)@#BNBEGB " +
+ "DFLSMFVMV)#@($*)@#*$MV)@#(*$V)M#(*$)M@(#*VM$)"));
+}
+
+
+
+
+/***/ }),
+/* 28 */
+/*!**********************!*\
+ !*** ./src/Alias.js ***!
+ \**********************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Aliases", function() { return Aliases; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "GlobalAliases", function() { return GlobalAliases; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "printAliases", function() { return printAliases; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseAliasDeclaration", function() { return parseAliasDeclaration; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "removeAlias", function() { return removeAlias; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "substituteAliases", function() { return substituteAliases; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadAliases", function() { return loadAliases; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadGlobalAliases", function() { return loadGlobalAliases; });
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Terminal.js */ 22);
+
+
+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(_Terminal_js__WEBPACK_IMPORTED_MODULE_0__["post"])("alias " + name + "=" + Aliases[name]);
+ }
+ }
+ for (var name in GlobalAliases) {
+ if (GlobalAliases.hasOwnProperty(name)) {
+ Object(_Terminal_js__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(" ");
+}
+
+
+
+
+/***/ }),
+/* 29 */
+/*!***********************!*\
+ !*** ./src/Script.js ***!
+ \***********************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateScriptEditorContent", function() { return updateScriptEditorContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadAllRunningScripts", function() { return loadAllRunningScripts; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "findRunningScript", function() { return findRunningScript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "RunningScript", function() { return RunningScript; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Script", function() { return Script; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AllServersMap", function() { return AllServersMap; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "scriptEditorInit", function() { return scriptEditorInit; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Fconf_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Fconf.js */ 34);
+/* harmony import */ var _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./InteractiveTutorial.js */ 25);
+/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 7);
+/* harmony import */ var _NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./NetscriptFunctions.js */ 30);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./Server.js */ 10);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Settings.js */ 24);
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./Terminal.js */ 22);
+/* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./TextFile.js */ 39);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ../utils/acorn.js */ 36);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_12___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
+var ace = __webpack_require__(/*! brace */ 181);
+__webpack_require__(/*! brace/mode/javascript */ 180);
+__webpack_require__(/*! ../netscript */ 179);
+__webpack_require__(/*! brace/theme/chaos */ 178);
+__webpack_require__(/*! brace/theme/chrome */ 177);
+__webpack_require__(/*! brace/theme/monokai */ 176);
+__webpack_require__(/*! brace/theme/solarized_dark */ 175);
+__webpack_require__(/*! brace/theme/solarized_light */ 174);
+__webpack_require__(/*! brace/theme/terminal */ 173);
+__webpack_require__(/*! brace/theme/twilight */ 172);
+__webpack_require__(/*! brace/theme/xcode */ 171);
+__webpack_require__(/*! brace/keybinding/vim */ 170);
+__webpack_require__(/*! brace/keybinding/emacs */ 169);
+__webpack_require__(/*! brace/ext/language_tools */ 168);
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+var keybindings = {
+ ace: null,
+ vim: "ace/keyboard/vim",
+ emacs: "ace/keyboard/emacs",
+};
+
+var scriptEditorRamCheck = null, scriptEditorRamText = null;
+function scriptEditorInit() {
+ //Create buttons at the bottom of script editor
+ var wrapper = document.getElementById("script-editor-buttons-wrapper");
+ if (wrapper == null) {
+ console.log("Error finding 'script-editor-buttons-wrapper'");
+ return;
+ }
+ var closeButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_15__["createElement"])("a", {
+ class:"a-link-button", display:"inline-block",
+ innerText:"Save & Close (Ctrl + b)",
+ clickListener:()=>{
+ saveAndCloseScriptEditor();
+ return false;
+ }
+ });
+
+ scriptEditorRamText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_15__["createElement"])("p", {
+ display:"inline-block", margin:"10px", id:"script-editor-status-text"
+ });
+
+ var checkboxLabel = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_15__["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"
+ });
+
+ scriptEditorRamCheck = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_15__["createElement"])("input", {
+ type:"checkbox", name:"script-editor-ram-check", id:"script-editor-ram-check",
+ margin:"4px", marginTop: "8px",
+ });
+ scriptEditorRamCheck.checked = true;
+
+ var documentationButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_15__["createElement"])("a", {
+ display:"inline-block", class:"a-link-button", innerText:"Netscript Documentation",
+ href:"https://bitburner.readthedocs.io/en/latest/index.html",
+ target:"_blank"
+ });
+
+ wrapper.appendChild(closeButton);
+ wrapper.appendChild(scriptEditorRamText);
+ wrapper.appendChild(scriptEditorRamCheck);
+ wrapper.appendChild(checkboxLabel);
+ wrapper.appendChild(documentationButton);
+
+ //Initialize ACE Script editor
+ var editor = ace.edit('javascript-editor');
+ editor.getSession().setMode('ace/mode/netscript');
+ editor.setTheme('ace/theme/monokai');
+ document.getElementById('javascript-editor').style.fontSize='16px';
+ editor.setOption("showPrintMargin", false);
+
+ /* Script editor options */
+ //Theme
+ var themeDropdown = document.getElementById("script-editor-option-theme");
+ if (_Settings_js__WEBPACK_IMPORTED_MODULE_9__["Settings"].EditorTheme) {
+ var initialIndex = 2;
+ for (var i = 0; i < themeDropdown.options.length; ++i) {
+ if (themeDropdown.options[i].value === _Settings_js__WEBPACK_IMPORTED_MODULE_9__["Settings"].EditorTheme) {
+ initialIndex = i;
+ break;
+ }
+ }
+ themeDropdown.selectedIndex = initialIndex;
+ } else {
+ themeDropdown.selectedIndex = 2;
+ }
+
+ themeDropdown.onchange = function() {
+ var val = themeDropdown.value;
+ _Settings_js__WEBPACK_IMPORTED_MODULE_9__["Settings"].EditorTheme = val;
+ var themePath = "ace/theme/" + val.toLowerCase();
+ editor.setTheme(themePath);
+ };
+ themeDropdown.onchange();
+
+ //Keybinding
+ var keybindingDropdown = document.getElementById("script-editor-option-keybinding");
+ if (_Settings_js__WEBPACK_IMPORTED_MODULE_9__["Settings"].EditorKeybinding) {
+ var initialIndex = 0;
+ for (var i = 0; i < keybindingDropdown.options.length; ++i) {
+ if (keybindingDropdown.options[i].value === _Settings_js__WEBPACK_IMPORTED_MODULE_9__["Settings"].EditorKeybinding) {
+ initialIndex = i;
+ break;
+ }
+ }
+ keybindingDropdown.selectedIndex = initialIndex;
+ } else {
+ keybindingDropdown.selectedIndex = 0;
+ }
+ keybindingDropdown.onchange = function() {
+ var val = keybindingDropdown.value;
+ _Settings_js__WEBPACK_IMPORTED_MODULE_9__["Settings"].EditorKeybinding = val;
+ editor.setKeyboardHandler(keybindings[val.toLowerCase()]);
+ };
+ keybindingDropdown.onchange();
+
+ //Highlight Active line
+ var highlightActiveChkBox = document.getElementById("script-editor-option-highlightactiveline");
+ highlightActiveChkBox.onchange = function() {
+ editor.setHighlightActiveLine(highlightActiveChkBox.checked);
+ };
+
+ //Show Invisibles
+ var showInvisiblesChkBox = document.getElementById("script-editor-option-showinvisibles");
+ showInvisiblesChkBox.onchange = function() {
+ editor.setShowInvisibles(showInvisiblesChkBox.checked);
+ };
+
+ //Use Soft Tab
+ var softTabChkBox = document.getElementById("script-editor-option-usesofttab");
+ softTabChkBox.onchange = function() {
+ editor.getSession().setUseSoftTabs(softTabChkBox.checked);
+ };
+
+ //Jshint Maxerr
+ var maxerr = document.getElementById("script-editor-option-maxerr");
+ var maxerrLabel = document.getElementById("script-editor-option-maxerror-value-label");
+ maxerrLabel.innerHTML = maxerr.value;
+ maxerr.onchange = function() {
+ editor.getSession().$worker.send("changeOptions", [{maxerr:maxerr.value}]);
+ maxerrLabel.innerHTML = maxerr.value;
+ }
+
+ //Configure some of the VIM keybindings
+ ace.config.loadModule('ace/keyboard/vim', function(module) {
+ var VimApi = module.CodeMirror.Vim;
+ VimApi.defineEx('write', 'w', function(cm, input) {
+ saveAndCloseScriptEditor();
+ });
+ VimApi.defineEx('quit', 'q', function(cm, input) {
+ _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadTerminalContent();
+ });
+ VimApi.defineEx('xwritequit', 'x', function(cm, input) {
+ saveAndCloseScriptEditor();
+ });
+ VimApi.defineEx('wqwritequit', 'wq', function(cm, input) {
+ saveAndCloseScriptEditor();
+ });
+ });
+
+ //Function autocompleter
+ editor.setOption("enableBasicAutocompletion", true);
+ var autocompleter = {
+ getCompletions: function(editor, session, pos, prefix, callback) {
+ if (prefix.length === 0) {callback(null, []); return;}
+ var words = [];
+ var fns = Object(_NetscriptFunctions_js__WEBPACK_IMPORTED_MODULE_5__["NetscriptFunctions"])(null);
+ for (var name in fns) {
+ if (fns.hasOwnProperty(name)) {
+ words.push({
+ name: name,
+ value: name,
+ });
+ }
+ }
+ callback(null, words);
+ },
+ }
+ editor.completers = [autocompleter];
+}
+
+//Updates RAM usage in script
+function updateScriptEditorContent() {
+ var filename = document.getElementById("script-editor-filename").value;
+ if (scriptEditorRamCheck == null || !scriptEditorRamCheck.checked || !filename.endsWith(".script")) {
+ scriptEditorRamText.innerText = "N/A";
+ return;
+ }
+ var editor = ace.edit('javascript-editor');
+ var code = editor.getValue();
+ var codeCopy = code.repeat(1);
+ var ramUsage = calculateRamUsage(codeCopy);
+ if (ramUsage !== -1) {
+ scriptEditorRamText.innerText = "RAM: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_16__["formatNumber"])(ramUsage, 2).toString() + "GB";
+ } else {
+ scriptEditorRamText.innerText = "RAM: Syntax Error";
+ }
+}
+
+//Define key commands in script editor (ctrl o to save + close, etc.)
+$(document).keydown(function(e) {
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.ScriptEditor) {
+ //Ctrl + b
+ if (e.keyCode == 66 && e.ctrlKey) {
+ e.preventDefault();
+ saveAndCloseScriptEditor();
+ }
+ }
+});
+
+function saveAndCloseScriptEditor() {
+ var filename = document.getElementById("script-editor-filename").value;
+ var editor = ace.edit('javascript-editor');
+ var code = editor.getValue();
+ if (_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["iTutorialIsRunning"] && _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["currITutorialStep"] == _InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["iTutorialSteps"].TerminalTypeScript) {
+ if (filename != "foodnstuff.script") {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_13__["dialogBoxCreate"])("Leave the script name as 'foodnstuff'!");
+ return;
+ }
+ code = code.replace(/\s/g, "");
+ if (code.indexOf("while(true){hack('foodnstuff');}") == -1) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_13__["dialogBoxCreate"])("Please copy and paste the code from the tutorial!");
+ return;
+ }
+ Object(_InteractiveTutorial_js__WEBPACK_IMPORTED_MODULE_3__["iTutorialNextStep"])();
+ }
+
+ if (filename == "") {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_13__["dialogBoxCreate"])("You must specify a filename!");
+ return;
+ }
+
+ if (checkValidFilename(filename) == false) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_13__["dialogBoxCreate"])("Script filename can contain only alphanumerics, hyphens, and underscores");
+ return;
+ }
+
+ var s = _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].getCurrentServer();
+ if (filename === ".fconf") {
+ try {
+ Object(_Fconf_js__WEBPACK_IMPORTED_MODULE_2__["parseFconfSettings"])(code);
+ } catch(e) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_13__["dialogBoxCreate"])("Invalid .fconf file");
+ return;
+ }
+ } else if (filename.endsWith(".script")) {
+ //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_js__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_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadTerminalContent();
+ return;
+ }
+ }
+ var textFile = new _TextFile_js__WEBPACK_IMPORTED_MODULE_11__["TextFile"](filename, code);
+ s.textFiles.push(textFile);
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_13__["dialogBoxCreate"])("Invalid filename. Must be either a script (.script) or " +
+ " or text file (.txt)")
+ return;
+ }
+ _engine_js__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() {
+ this.filename = "";
+ this.code = "";
+ this.ramUsage = 0;
+ this.server = ""; //IP of server this script is on
+};
+
+//Get the script data from the Script Editor and save it to the object
+Script.prototype.saveScript = function() {
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.ScriptEditor) {
+ //Update code and filename
+ var editor = ace.edit('javascript-editor');
+ var code = editor.getValue();
+ this.code = code.replace(/^\s+|\s+$/g, '');
+
+ var filename = document.getElementById("script-editor-filename").value;
+ this.filename = filename;
+
+ //Server
+ this.server = _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].currentServer;
+
+ //Calculate/update ram usage, execution time, etc.
+ this.updateRamUsage();
+ }
+}
+
+//Updates how much RAM the script uses when it is running.
+Script.prototype.updateRamUsage = function() {
+ var codeCopy = this.code.repeat(1);
+ var res = calculateRamUsage(codeCopy);
+ if (res !== -1) {
+ this.ramUsage = res;
+ }
+}
+
+function calculateRamUsage(codeCopy) {
+ //Create a temporary/mock WorkerScript and an AST from the code
+ var currServ = _Player_js__WEBPACK_IMPORTED_MODULE_7__["Player"].getCurrentServer();
+ var workerScript = new _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__["WorkerScript"]({
+ filename:"foo",
+ scriptRef: {code:""},
+ args:[]
+ });
+ workerScript.checkingRam = true; //Netscript functions will return RAM usage
+ workerScript.serverIp = currServ.ip;
+
+ try {
+ var ast = Object(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_12__["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 = 1.4;
+ 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_js__WEBPACK_IMPORTED_MODULE_4__["evaluateImport"])(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_js__WEBPACK_IMPORTED_MODULE_12__["Node"]) {
+ queue.push(exp.body[i]);
+ }
+ }
+ break;
+ case "WhileStatement":
+ if (!whileUsed) {
+ ramUsage += _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptWhileRamCost;
+ whileUsed = true;
+ }
+ break;
+ case "ForStatement":
+ if (!forUsed) {
+ ramUsage += _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].ScriptForRamCost;
+ forUsed = true;
+ }
+ break;
+ case "IfStatement":
+ if (!ifUsed) {
+ ramUsage += _Constants_js__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_js__WEBPACK_IMPORTED_MODULE_12__["Node"]) {
+ queue.push(exp[prop]);
+ }
+ }
+ }
+ }
+
+ //Special case: hacknetnodes array
+ if (codeCopy.includes("hacknetnodes")) {
+ ramUsage += _Constants_js__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_js__WEBPACK_IMPORTED_MODULE_14__["Generic_toJSON"])("Script", this);
+}
+
+
+Script.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__["Generic_fromJSON"])(Script, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__["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;
+ for (var property in _Server_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"]) {
+ if (_Server_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"].hasOwnProperty(property)) {
+ var server = _Server_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"][property];
+
+ //Reset each server's RAM usage to 0
+ server.ramUsed = 0;
+
+ for (var j = 0; j < server.runningScripts.length; ++j) {
+ count++;
+ Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_6__["addWorkerScript"])(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_js__WEBPACK_IMPORTED_MODULE_7__["Player"].lastUpdate;
+ var timePassed = (thisUpdate - lastUpdate) / 1000; //Seconds
+ console.log("Offline for " + timePassed + " 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_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"][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_js__WEBPACK_IMPORTED_MODULE_8__["processSingleServerGrowth"])(serv, timesGrown * 450);
+ runningScriptObj.log(serv.hostname + " grown by " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_16__["formatNumber"])(growth * 100 - 100, 6) + "% 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_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"][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_js__WEBPACK_IMPORTED_MODULE_7__["Player"].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_js__WEBPACK_IMPORTED_MODULE_7__["Player"].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_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"][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_js__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_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"][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_js__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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_15__["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_js__WEBPACK_IMPORTED_MODULE_9__["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();
+ }
+ this.logs.push(txt);
+ this.logUpd = true;
+}
+
+RunningScript.prototype.displayLog = function() {
+ for (var i = 0; i < this.logs.length; ++i) {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_10__["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_js__WEBPACK_IMPORTED_MODULE_14__["Generic_toJSON"])("RunningScript", this);
+}
+
+
+RunningScript.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__["Generic_fromJSON"])(RunningScript, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__["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_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"]) {
+ if (_Server_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"].hasOwnProperty(ip)) {
+ if (filterOwned && (_Server_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"][ip].purchasedByPlayer || _Server_js__WEBPACK_IMPORTED_MODULE_8__["AllServers"][ip].hostname === "home")) {
+ continue;
+ }
+ if (arr) {
+ this[ip] = [0, 0, 0, 0];
+ } else {
+ this[ip] = 0;
+ }
+ }
+ }
+}
+
+AllServersMap.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__["Generic_toJSON"])("AllServersMap", this);
+}
+
+
+AllServersMap.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__["Generic_fromJSON"])(AllServersMap, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_14__["Reviver"].constructors.AllServersMap = AllServersMap;
+
+
+
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 41)))
+
+/***/ }),
+/* 30 */
+/*!***********************************!*\
+ !*** ./src/NetscriptFunctions.js ***!
+ \***********************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "NetscriptFunctions", function() { return NetscriptFunctions; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "initSingularitySFFlags", function() { return initSingularitySFFlags; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasSingularitySF", function() { return hasSingularitySF; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasBn11SF", function() { return hasBn11SF; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasWallStreetSF", function() { return hasWallStreetSF; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "wallStreetSFLvl", function() { return wallStreetSFLvl; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasCorporationSF", function() { return hasCorporationSF; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasAISF", function() { return hasAISF; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "hasBladeburnerSF", function() { return hasBladeburnerSF; });
+/* harmony import */ var _ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./ActiveScriptsUI.js */ 42);
+/* harmony import */ var _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Augmentations.js */ 18);
+/* harmony import */ var _BitNode_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./BitNode.js */ 16);
+/* harmony import */ var _Crimes_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Crimes.js */ 19);
+/* harmony import */ var _Company_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ./Company.js */ 9);
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ./CreateProgram.js */ 13);
+/* harmony import */ var _DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ./DarkWeb.js */ 33);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ./Faction.js */ 14);
+/* harmony import */ var _HacknetNode_js__WEBPACK_IMPORTED_MODULE_10__ = __webpack_require__(/*! ./HacknetNode.js */ 38);
+/* harmony import */ var _Location_js__WEBPACK_IMPORTED_MODULE_11__ = __webpack_require__(/*! ./Location.js */ 4);
+/* harmony import */ var _Message_js__WEBPACK_IMPORTED_MODULE_12__ = __webpack_require__(/*! ./Message.js */ 27);
+/* harmony import */ var _Missions_js__WEBPACK_IMPORTED_MODULE_13__ = __webpack_require__(/*! ./Missions.js */ 32);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_14__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _Script_js__WEBPACK_IMPORTED_MODULE_15__ = __webpack_require__(/*! ./Script.js */ 29);
+/* harmony import */ var _Server_js__WEBPACK_IMPORTED_MODULE_16__ = __webpack_require__(/*! ./Server.js */ 10);
+/* harmony import */ var _Settings_js__WEBPACK_IMPORTED_MODULE_17__ = __webpack_require__(/*! ./Settings.js */ 24);
+/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_18__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17);
+/* harmony import */ var _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__ = __webpack_require__(/*! ./StockMarket.js */ 20);
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_20__ = __webpack_require__(/*! ./Terminal.js */ 22);
+/* harmony import */ var _TextFile_js__WEBPACK_IMPORTED_MODULE_21__ = __webpack_require__(/*! ./TextFile.js */ 39);
+/* harmony import */ var _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__ = __webpack_require__(/*! ./NetscriptWorker.js */ 21);
+/* harmony import */ var _NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__ = __webpack_require__(/*! ./NetscriptEvaluator.js */ 7);
+/* harmony import */ var _NetscriptEnvironment_js__WEBPACK_IMPORTED_MODULE_24__ = __webpack_require__(/*! ./NetscriptEnvironment.js */ 65);
+/* harmony import */ var _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_25__ = __webpack_require__(/*! ./NetscriptPort.js */ 43);
+/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_26__ = __webpack_require__(/*! ../utils/decimal.js */ 23);
+/* harmony import */ var _utils_decimal_js__WEBPACK_IMPORTED_MODULE_26___default = /*#__PURE__*/__webpack_require__.n(_utils_decimal_js__WEBPACK_IMPORTED_MODULE_26__);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_27__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_28__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_29__ = __webpack_require__(/*! ../utils/IPAddress.js */ 15);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_31__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 11);
+var sprintf = __webpack_require__(/*! sprintf-js */ 109).sprintf,
+ vsprintf = __webpack_require__(/*! sprintf-js */ 109).vsprintf
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+var hasCorporationSF=false, //Source-File 3
+ hasSingularitySF=false, //Source-File 4
+ hasAISF=false, //Source-File 5
+ hasBladeburnerSF=false, //Source-File 6
+ hasWallStreetSF=false, //Source-File 8
+ hasBn11SF=false; //Source-File 11
+
+
+
+var singularitySFLvl=1, wallStreetSFLvl=1;
+
+//Used to check and set flags for every Source File, despite the name of the function
+function initSingularitySFFlags() {
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].sourceFiles.length; ++i) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].sourceFiles[i].n === 3) {
+ hasCorporationSF = true;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].sourceFiles[i].n === 4) {
+ hasSingularitySF = true;
+ singularitySFLvl = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].sourceFiles[i].lvl;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].sourceFiles[i].n === 5) {
+ hasAISF = true;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].sourceFiles[i].n === 6) {
+ hasBladeburnerSF = true;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].sourceFiles[i].n === 8) {
+ hasWallStreetSF = true;
+ wallStreetSFLvl = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].sourceFiles[i].lvl;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].sourceFiles[i].n === 11) {
+ hasBn11SF = true;
+ }
+ }
+}
+
+function NetscriptFunctions(workerScript) {
+ return {
+ Math : Math,
+ Date : Date,
+ Number : Number,
+ hacknetnodes : _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacknetNodes,
+ sprintf : sprintf,
+ vsprintf: vsprintf,
+ scan : function(ip=workerScript.serverIp, hostnames=true){
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.scan) {
+ return 0;
+ } else {
+ workerScript.loadedFns.scan = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptScanRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, 'Invalid IP or hostname passed into scan() command');
+ }
+ var out = [];
+ for (var i = 0; i < server.serversOnNetwork.length; i++) {
+ var entry;
+ if (hostnames) {
+ entry = server.getServerOnNetwork(i).hostname;
+ } else {
+ entry = server.getServerOnNetwork(i).ip;
+ }
+ if (entry == null) {
+ continue;
+ }
+ out.push(entry);
+ }
+ 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) {
+ if (workerScript.loadedFns.hack) {
+ return 0;
+ } else {
+ workerScript.loadedFns.hack = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptHackRamCost;
+ }
+ }
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Hack() call has incorrect number of arguments. Takes 1 argument");
+ }
+ var threads = workerScript.scriptRef.threads;
+ if (isNaN(threads) || threads < 1) {threads = 1;}
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping...");
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "hack() error. Invalid IP or hostname passed in: " + ip + ". Stopping...");
+ }
+
+ //Calculate the hacking time
+ var hackingTime = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["scriptCalculateHackingTime"])(server); //This is in seconds
+
+ //No root access or skill level too low
+ if (server.hasAdminRights == false) {
+ workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user does not have root access");
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot hack this server (" + server.hostname + ") because user does not have root access");
+ }
+
+ if (server.requiredHackingSkill > _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_skill) {
+ workerScript.scriptRef.log("Cannot hack this server (" + server.hostname + ") because user's hacking skill is not high enough");
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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_js__WEBPACK_IMPORTED_MODULE_23__["netscriptDelay"])(hackingTime* 1000, workerScript).then(function() {
+ if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
+ var hackChance = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["scriptCalculateHackingChance"])(server);
+ var rand = Math.random();
+ var expGainedOnSuccess = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["scriptCalculateExpGain"])(server) * threads;
+ var expGainedOnFailure = (expGainedOnSuccess / 4);
+ if (rand < hackChance) { //Success!
+ var moneyGained = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["scriptCalculatePercentMoneyHacked"])(server);
+ moneyGained = Math.floor(server.moneyAvailable * moneyGained) * threads;
+
+ //Over-the-top safety checks
+ if (moneyGained <= 0) {
+ moneyGained = 0;
+ expGainedOnSuccess = expGainedOnFailure;
+ }
+ if (moneyGained > server.moneyAvailable) {moneyGained = server.moneyAvailable;}
+ server.moneyAvailable -= moneyGained;
+ if (server.moneyAvailable < 0) {server.moneyAvailable = 0;}
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].gainMoney(moneyGained);
+ workerScript.scriptRef.onlineMoneyMade += moneyGained;
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].scriptProdSinceLastAug += moneyGained;
+ workerScript.scriptRef.recordHack(server.ip, moneyGained, threads);
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].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_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(moneyGained, 2) + " and " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(expGainedOnSuccess, 4) + " exp (t=" + threads + ")");
+ }
+ server.fortify(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ServerFortifyAmount * threads);
+ return Promise.resolve(moneyGained);
+ } else {
+ //Player only gains 25% exp for failure?
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].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_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(expGainedOnFailure, 4) + " exp (t=" + threads + ")");
+ }
+ return Promise.resolve(0);
+ }
+ });
+ },
+ sleep : function(time){
+ if (workerScript.checkingRam) {return 0;}
+ if (time === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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_js__WEBPACK_IMPORTED_MODULE_23__["netscriptDelay"])(time, workerScript).then(function() {
+ return Promise.resolve(true);
+ });
+ },
+ grow : function(ip){
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.grow) {
+ return 0;
+ } else {
+ workerScript.loadedFns.grow = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGrowRamCost;
+ }
+ }
+ var threads = workerScript.scriptRef.threads;
+ if (isNaN(threads) || threads < 1) {threads = 1;}
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "grow() call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot grow(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot grow(). Invalid IP or hostname passed in: " + ip);
+ }
+
+ //No root access or skill level too low
+ if (server.hasAdminRights == false) {
+ workerScript.scriptRef.log("Cannot grow this server (" + server.hostname + ") because user does not have root access");
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot grow this server (" + server.hostname + ") because user does not have root access");
+ }
+
+ var growTime = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["scriptCalculateGrowTime"])(server);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.grow == null) {
+ workerScript.scriptRef.log("Executing grow() on server " + server.hostname + " in " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(growTime/1000, 3) + " seconds (t=" + threads + ")");
+ }
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["netscriptDelay"])(growTime, workerScript).then(function() {
+ if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
+ server.moneyAvailable += (1 * threads); //It can be grown even if it has no money
+ var growthPercentage = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["processSingleServerGrowth"])(server, 450 * threads);
+ workerScript.scriptRef.recordGrow(server.ip, threads);
+ var expGain = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["scriptCalculateExpGain"])(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_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(growthPercentage*100 - 100, 6) + "%. Gained " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(expGain, 4) + " hacking exp (t=" + threads +")");
+ }
+ workerScript.scriptRef.onlineExpGained += expGain;
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].gainHackingExp(expGain);
+ return Promise.resolve(growthPercentage);
+ });
+ },
+ weaken : function(ip){
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.weaken) {
+ return 0;
+ } else {
+ workerScript.loadedFns.weaken = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptWeakenRamCost;
+ }
+ }
+ var threads = workerScript.scriptRef.threads;
+ if (isNaN(threads) || threads < 1) {threads = 1;}
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "weaken() call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot weaken(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot weaken(). Invalid IP or hostname passed in: " + ip);
+ }
+
+ //No root access or skill level too low
+ if (server.hasAdminRights == false) {
+ workerScript.scriptRef.log("Cannot weaken this server (" + server.hostname + ") because user does not have root access");
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot weaken this server (" + server.hostname + ") because user does not have root access");
+ }
+
+ var weakenTime = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["scriptCalculateWeakenTime"])(server);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.weaken == null) {
+ workerScript.scriptRef.log("Executing weaken() on server " + server.hostname + " in " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(weakenTime/1000, 3) + " seconds (t=" + threads + ")");
+ }
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["netscriptDelay"])(weakenTime, workerScript).then(function() {
+ if (workerScript.env.stopFlag) {return Promise.reject(workerScript);}
+ server.weaken(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ServerWeakenAmount * threads);
+ workerScript.scriptRef.recordWeaken(server.ip, threads);
+ var expGain = Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["scriptCalculateExpGain"])(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_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(expGain, 4) + " hacking exp (t=" + threads + ")");
+ }
+ workerScript.scriptRef.onlineExpGained += expGain;
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].gainHackingExp(expGain);
+ return Promise.resolve(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ServerWeakenAmount * threads);
+ });
+ },
+ print : function(args){
+ if (workerScript.checkingRam) {return 0;}
+ if (args === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "tprint() call has incorrect number of arguments. Takes 1 argument");
+ }
+ var x = args.toString();
+ if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["isHTML"])(x)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].takeDamage(1);
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_27__["dialogBoxCreate"])("You suddenly feel a sharp shooting pain through your body as an angry voice in your head exclaims:
" +
+ "DON'T USE TPRINT() TO OUTPUT HTML ELEMENTS TO YOUR TERMINAL!!!!
" +
+ "(You lost 1 HP)");
+ return;
+ }
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_20__["post"])(workerScript.scriptRef.filename + ": " + args.toString());
+ },
+ clearLog : function() {
+ if (workerScript.checkingRam) {return 0;}
+ workerScript.scriptRef.clearLog();
+ },
+ disableLog : function(fn) {
+ if (workerScript.checkingRam) {return 0;}
+ workerScript.disableLogs[fn] = true;
+ workerScript.scriptRef.log("Disabled logging for " + fn);
+ },
+ enableLog : function(fn) {
+ if (workerScript.checkingRam) {return 0;}
+ delete workerScript.disableLogs[fn];
+ workerScript.scriptRef.log("Enabled logging for " + fn);
+ },
+ nuke : function(ip){
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.nuke) {
+ return 0;
+ } else {
+ workerScript.loadedFns.nuke = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptPortProgramRamCost;
+ }
+ }
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot call nuke(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot call nuke(). Invalid IP or hostname passed in: " + ip);
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].NukeProgram)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "You do not have the NUKE.exe virus!");
+ }
+ if (server.openPortCount < server.numOpenPortsRequired) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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) {
+ if (workerScript.loadedFns.brutessh) {
+ return 0;
+ } else {
+ workerScript.loadedFns.brutessh = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptPortProgramRamCost;
+ }
+ }
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot call brutessh(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot call brutessh(). Invalid IP or hostname passed in: " + ip);
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].BruteSSHProgram)) {
+ workerScript.scriptRef.log("You do not have the BruteSSH.exe program!");
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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) {
+ if (workerScript.loadedFns.ftpcrack) {
+ return 0;
+ } else {
+ workerScript.loadedFns.ftpcrack = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptPortProgramRamCost;
+ }
+ }
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot call ftpcrack(). Invalid IP or hostname passed in: " + ip);
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].FTPCrackProgram)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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) {
+ if (workerScript.loadedFns.relaysmtp) {
+ return 0;
+ } else {
+ workerScript.loadedFns.relaysmtp = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptPortProgramRamCost;
+ }
+ }
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot call relaysmtp(). Invalid IP or hostname passed in: " + ip);
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].RelaySMTPProgram)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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) {
+ if (workerScript.loadedFns.httpworm) {
+ return 0;
+ } else {
+ workerScript.loadedFns.httpworm = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptPortProgramRamCost;
+ }
+ }
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot call httpworm(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot call httpworm(). Invalid IP or hostname passed in: " + ip);
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].HTTPWormProgram)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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) {
+ if (workerScript.loadedFns.sqlinject) {
+ return 0;
+ } else {
+ workerScript.loadedFns.sqlinject = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptPortProgramRamCost;
+ }
+ }
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Program call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot call sqlinject(). Invalid IP or hostname passed in: " + ip);
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hasProgram(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].SQLInjectProgram)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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) {
+ if (workerScript.loadedFns.run) {
+ return 0;
+ } else {
+ workerScript.loadedFns.run = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptRunRamCost;
+ }
+ }
+ if (scriptname === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "run() call has incorrect number of arguments. Usage: run(scriptname, [numThreads], [arg1], [arg2]...)");
+ }
+ if (isNaN(threads) || threads < 1) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument for thread count passed into run(). Must be numeric and greater than 0");
+ }
+ var argsForNewScript = [];
+ for (var i = 2; i < arguments.length; ++i) {
+ argsForNewScript.push(arguments[i]);
+ }
+ var scriptServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(workerScript.serverIp);
+ if (scriptServer == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Could not find server. This is a bug in the game. Report to game dev");
+ }
+
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["runScriptFromScript"])(scriptServer, scriptname, argsForNewScript, workerScript, threads);
+ },
+ exec : function(scriptname,ip,threads = 1) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.exec) {
+ return 0;
+ } else {
+ workerScript.loadedFns.exec = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptExecRamCost;
+ }
+ }
+ if (scriptname === undefined || ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "exec() call has incorrect number of arguments. Usage: exec(scriptname, server, [numThreads], [arg1], [arg2]...)");
+ }
+ if (isNaN(threads) || threads < 1) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument for thread count passed into exec(). Must be numeric and greater than 0");
+ }
+ var argsForNewScript = [];
+ for (var i = 3; i < arguments.length; ++i) {
+ argsForNewScript.push(arguments[i]);
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid hostname/ip passed into exec() command: " + ip);
+ }
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["runScriptFromScript"])(server, scriptname, argsForNewScript, workerScript, threads);
+ },
+ spawn : function(scriptname, threads) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.spawn) {
+ return 0;
+ } else {
+ workerScript.loadedFns.spawn = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSpawnRamCost;
+ }
+ }
+ if (scriptname == null || threads == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid scriptname or numThreads argument passed to spawn()");
+ }
+ setTimeout(()=>{
+ NetscriptFunctions(workerScript).run.apply(this, arguments);
+ }, 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) {
+ if (workerScript.loadedFns.kill) {
+ return 0;
+ } else {
+ workerScript.loadedFns.kill = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptKillRamCost;
+ }
+ }
+
+ if (filename === undefined || ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "kill() call has incorrect number of arguments. Usage: kill(scriptname, server, [arg1], [arg2]...)");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("kill() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "kill() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ var argsForKillTarget = [];
+ for (var i = 2; i < arguments.length; ++i) {
+ argsForKillTarget.push(arguments[i]);
+ }
+ var runningScriptObj = Object(_Script_js__WEBPACK_IMPORTED_MODULE_15__["findRunningScript"])(filename, argsForKillTarget, server);
+ if (runningScriptObj == null) {
+ workerScript.scriptRef.log("kill() failed. No such script "+ filename + " on " + server.hostname + " with args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_28__["printArray"])(argsForKillTarget));
+ return false;
+ }
+ var res = Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__["killWorkerScript"])(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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_28__["printArray"])(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_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_28__["printArray"])(argsForKillTarget));
+ }
+ return false;
+ }
+ },
+ killall : function(ip=workerScript.serverIp){
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.killall) {
+ return 0;
+ } else {
+ workerScript.loadedFns.killall = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptKillRamCost;
+ }
+ }
+
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "killall() call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("killall() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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_js__WEBPACK_IMPORTED_MODULE_22__["killWorkerScript"])(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) {
+ if (workerScript.loadedFns.exit) {
+ return 0;
+ } else {
+ workerScript.loadedFns.exit = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptKillRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(workerScript.serverIp);
+ if (server == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in exit(). This is a bug please contact game dev");
+ }
+ if (Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__["killWorkerScript"])(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) {
+ if (workerScript.loadedFns.scp) {
+ return 0;
+ } else {
+ workerScript.loadedFns.scp = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptScpRamCost;
+ }
+ }
+ if (arguments.length !== 2 && arguments.length !== 3) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments");
+ }
+ if (scriptname && scriptname.constructor === Array) {
+ //Recursively call scp on all elements of array
+ var res = false;
+ scriptname.forEach(function(script) {
+ if (NetscriptFunctions(workerScript).scp(script, ip1, ip2)) {
+ res = true;
+ };
+ });
+ return res;
+ }
+ if (!scriptname.endsWith(".lit") && !scriptname.endsWith(".script") &&
+ !scriptname.endsWith("txt")) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Error: scp() does not work with this file type. It only works for .script, .lit, and .txt files");
+ }
+
+ var destServer, currServ;
+
+ if (arguments.length === 3) { //scriptname, source, destination
+ if (scriptname === undefined || ip1 === undefined || ip2 === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments");
+ }
+ destServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip2);
+ if (destServer == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Error: Invalid hostname/ip passed into scp() command: " + ip);
+ }
+
+ currServ = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip1);
+ if (currServ == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer");
+ }
+ } else if (arguments.length === 2) { //scriptname, destination
+ if (scriptname === undefined || ip1 === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Error: scp() call has incorrect number of arguments. Takes 2 or 3 arguments");
+ }
+ destServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip1);
+ if (destServer == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Error: Invalid hostname/ip passed into scp() command: " + ip);
+ }
+
+ currServ = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(workerScript.serverIp);
+ if (currServ == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Could not find server ip for this script. This is a bug please contact game developer");
+ }
+ }
+
+ //Scp for lit files
+ if (scriptname.endsWith(".lit")) {
+ var found = false;
+ for (var i = 0; i < currServ.messages.length; ++i) {
+ if (!(currServ.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_12__["Message"]) && 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_js__WEBPACK_IMPORTED_MODULE_21__["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;
+ return true;
+ }
+ }
+
+ //Create new script if it does not already exist
+ var newScript = new _Script_js__WEBPACK_IMPORTED_MODULE_15__["Script"]();
+ 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) {
+ if (workerScript.loadedFns.ls) {
+ return 0;
+ } else {
+ workerScript.loadedFns.ls = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptScanRamCost;
+ }
+ }
+ if (ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ls() failed because of invalid arguments. Usage: ls(ip/hostname, [grep filter])");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("ls() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ls() failed. Invalid IP or hostname passed in: " + ip);
+ }
+
+ //Get the grep filter, if one exists
+ var filter = false;
+ if (arguments.length >= 2) {
+ filter = grep.toString();
+ }
+
+ var allFiles = [];
+ for (var i = 0; i < server.programs.length; i++) {
+ if (filter) {
+ if (server.programs[i].includes(filter)) {
+ allFiles.push(server.programs[i]);
+ }
+ } else {
+ allFiles.push(server.programs[i]);
+ }
+ }
+ for (var i = 0; i < server.scripts.length; i++) {
+ if (filter) {
+ if (server.scripts[i].filename.includes(filter)) {
+ allFiles.push(server.scripts[i].filename);
+ }
+ } else {
+ allFiles.push(server.scripts[i].filename);
+ }
+
+ }
+ for (var i = 0; i < server.messages.length; i++) {
+ if (filter) {
+ if (server.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_12__["Message"]) {
+ if (server.messages[i].filename.includes(filter)) {
+ allFiles.push(server.messages[i].filename);
+ }
+ } else if (server.messages[i].includes(filter)) {
+ allFiles.push(server.messages[i]);
+ }
+ } else {
+ if (server.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_12__["Message"]) {
+ 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);
+ }
+ }
+
+ //Sort the files alphabetically then print each
+ allFiles.sort();
+ return allFiles;
+ },
+ hasRootAccess : function(ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.hasRootAccess) {
+ return 0;
+ } else {
+ workerScript.loadedFns.hasRootAccess = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptHasRootAccessRamCost;
+ }
+ }
+ if (ip===undefined){
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "hasRootAccess() call has incorrect number of arguments. Takes 1 argument");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null){
+ workerScript.scriptRef.log("hasRootAccess() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "hasRootAccess() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ return server.hasAdminRights;
+ },
+ getIp : function() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getIp) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getIp = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetHostnameRamCost;
+ }
+ }
+ var scriptServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(workerScript.serverIp);
+ if (scriptServer == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Could not find server. This is a bug in the game. Report to game dev");
+ }
+ return scriptServer.ip;
+ },
+ getHostname : function(){
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getHostname) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getHostname = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetHostnameRamCost;
+ }
+ }
+ var scriptServer = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(workerScript.serverIp);
+ if (scriptServer == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Could not find server. This is a bug in the game. Report to game dev");
+ }
+ return scriptServer.hostname;
+ },
+ getHackingLevel : function(){
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getHackingLevel) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getHackingLevel = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetHackingLevelRamCost;
+ }
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].updateSkillLevels();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getHackingLevel == null) {
+ workerScript.scriptRef.log("getHackingLevel() returned " + _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_skill);
+ }
+ return _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_skill;
+ },
+ getHackingMultipliers : function() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getHackingMultipliers) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getHackingMultipliers = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetMultipliersRamCost;
+ }
+ }
+ return {
+ chance: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_chance_mult,
+ speed: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_speed_mult,
+ money: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_money_mult,
+ growth: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_grow_mult,
+ };
+ },
+ getBitNodeMultipliers: function() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getBitNodeMultipliers) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getBitNodeMultipliers = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetMultipliersRamCost;
+ }
+ }
+ if (!hasAISF) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getBitNodeMultipliers(). It requires Source-File 5 to run.");
+ }
+ return _BitNode_js__WEBPACK_IMPORTED_MODULE_2__["BitNodeMultipliers"];
+ },
+ getServerMoneyAvailable : function(ip){
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getServerMoneyAvailable) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getServerMoneyAvailable = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetServerRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerMoneyAvailable() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].money.toNumber(), 2));
+ }
+ return _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].money.toNumber();
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.getServerMoneyAvailable == null) {
+ workerScript.scriptRef.log("getServerMoneyAvailable() returned " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(server.moneyAvailable, 2) + " for " + server.hostname);
+ }
+ return server.moneyAvailable;
+ },
+ getServerSecurityLevel : function(ip){
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getServerSecurityLevel) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getServerSecurityLevel = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetServerRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(server.hackDifficulty, 3) + " for " + server.hostname);
+ }
+ return server.hackDifficulty;
+ },
+ getServerBaseSecurityLevel : function(ip){
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getServerBaseSecurityLevel) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getServerBaseSecurityLevel = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetServerRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerBaseSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(server.baseDifficulty, 3) + " for " + server.hostname);
+ }
+ return server.baseDifficulty;
+ },
+ getServerMinSecurityLevel : function(ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getServerMinSecurityLevel) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getServerMinSecurityLevel = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetServerRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerMinSecurityLevel() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(server.minDifficulty, 3) + " for " + server.hostname);
+ }
+ return server.minDifficulty;
+ },
+ getServerRequiredHackingLevel : function(ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getServerRequiredHackingLevel) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getServerRequiredHackingLevel = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetServerRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerRequiredHackingLevel() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(server.requiredHackingSkill, 0) + " for " + server.hostname);
+ }
+ return server.requiredHackingSkill;
+ },
+ getServerMaxMoney : function(ip){
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getServerMaxMoney) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getServerMaxMoney = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetServerRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerMaxMoney() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(server.moneyMax, 0) + " for " + server.hostname);
+ }
+ return server.moneyMax;
+ },
+ getServerGrowth : function(ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getServerGrowth) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getServerGrowth = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetServerRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerGrowth() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(server.serverGrowth, 0) + " for " + server.hostname);
+ }
+ return server.serverGrowth;
+ },
+ getServerNumPortsRequired : function(ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getServerNumPortsRequired) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getServerNumPortsRequired = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetServerRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerNumPortsRequired() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(server.numOpenPortsRequired, 0) + " for " + server.hostname);
+ }
+ return server.numOpenPortsRequired;
+ },
+ getServerRam : function(ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getServerRam) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getServerRam = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetServerRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getServerRam() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(server.maxRam, 2) + "GB, " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(server.ramUsed, 2) + "GB]");
+ }
+ return [server.maxRam, server.ramUsed];
+ },
+ serverExists : function(ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.serverExists) {
+ return 0;
+ } else {
+ workerScript.loadedFns.serverExists = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetServerRamCost;
+ }
+ }
+ return (Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip) !== null);
+ },
+ fileExists : function(filename,ip=workerScript.serverIp) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.fileExists) {
+ return 0;
+ } else {
+ workerScript.loadedFns.fileExists = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptFileExistsRamCost;
+ }
+ }
+ if (filename === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "fileExists() call has incorrect number of arguments. Usage: fileExists(scriptname, [server])");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("fileExists() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "fileExists() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ for (var i = 0; i < server.scripts.length; ++i) {
+ if (filename == server.scripts[i].filename) {
+ return true;
+ }
+ }
+ for (var i = 0; i < server.programs.length; ++i) {
+ if (filename.toLowerCase() == server.programs[i].toLowerCase()) {
+ return true;
+ }
+ }
+ for (var i = 0; i < server.messages.length; ++i) {
+ if (!(server.messages[i] instanceof _Message_js__WEBPACK_IMPORTED_MODULE_12__["Message"]) &&
+ filename.toLowerCase() === server.messages[i]) {
+ return true;
+ }
+ }
+ var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_21__["getTextFile"])(filename, server);
+ if (txtFile != null) {
+ return true;
+ }
+ return false;
+ },
+ isRunning : function(filename,ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.isRunning) {
+ return 0;
+ } else {
+ workerScript.loadedFns.isRunning = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptIsRunningRamCost;
+ }
+ }
+ if (filename === undefined || ip === undefined) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "isRunning() call has incorrect number of arguments. Usage: isRunning(scriptname, server, [arg1], [arg2]...)");
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("isRunning() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "isRunning() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ var argsForTargetScript = [];
+ for (var i = 2; i < arguments.length; ++i) {
+ argsForTargetScript.push(arguments[i]);
+ }
+ return (Object(_Script_js__WEBPACK_IMPORTED_MODULE_15__["findRunningScript"])(filename, argsForTargetScript, server) != null);
+ },
+ getNextHacknetNodeCost : function() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getNextHacknetNodeCost) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getNextHacknetNodeCost = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptPurchaseHacknetRamCost;
+ }
+ }
+ return Object(_HacknetNode_js__WEBPACK_IMPORTED_MODULE_10__["getCostOfNextHacknetNode"])();
+ },
+
+ purchaseHacknetNode : function() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.purchaseHacknetNode) {
+ return 0;
+ } else {
+ workerScript.loadedFns.purchaseHacknetNode = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptPurchaseHacknetRamCost;
+ }
+ }
+ return Object(_HacknetNode_js__WEBPACK_IMPORTED_MODULE_10__["purchaseHacknet"])();
+ },
+ getStockPrice : function(symbol) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getStockPrice) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getStockPrice = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetStockRamCost;
+ }
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use getStockPrice()");
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid stock symbol passed into getStockPrice()");
+ }
+ return parseFloat(stock.price.toFixed(3));
+ },
+ getStockPosition : function(symbol) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getStockPosition) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getStockPosition = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetStockRamCost;
+ }
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use getStockPosition()");
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid stock symbol passed into getStockPrice()");
+ }
+ return [stock.playerShares, stock.playerAvgPx, stock.playerShortShares, stock.playerAvgShortPx];
+ },
+ buyStock : function(symbol, shares) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.buyStock) {
+ return 0;
+ } else {
+ workerScript.loadedFns.buyStock = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptBuySellStockRamCost;
+ }
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use buyStock()");
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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;}
+
+ var totalPrice = stock.price * shares;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].money.lt(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].StockMarketCommission)) {
+ workerScript.scriptRef.log("Not enough money to purchase " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(shares, 0) + " shares of " +
+ symbol + ". Need $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].StockMarketCommission, 2).toString());
+ return 0;
+ }
+
+ var origTotal = stock.playerShares * stock.playerAvgPx;
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].loseMoney(totalPrice + _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].StockMarketCommission);
+ var newTotal = origTotal + totalPrice;
+ stock.playerShares += shares;
+ stock.playerAvgPx = newTotal / stock.playerShares;
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_8__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_8__["Engine"].Page.StockMarket) {
+ Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["updateStockPlayerPosition"])(stock);
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.buyStock == null) {
+ workerScript.scriptRef.log("Bought " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(stock.price, 2) + " per share");
+ }
+ return stock.price;
+ },
+ sellStock : function(symbol, shares) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.sellStock) {
+ return 0;
+ } else {
+ workerScript.loadedFns.sellStock = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptBuySellStockRamCost;
+ }
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use sellStock()");
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(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_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].StockMarketCommission;
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].gainMoney(gains);
+
+ //Calculate net profit and add to script stats
+ var netProfit = ((stock.price - stock.playerAvgPx) * shares) - _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].StockMarketCommission;
+ if (isNaN(netProfit)) {netProfit = 0;}
+ workerScript.scriptRef.onlineMoneyMade += netProfit;
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].scriptProdSinceLastAug += netProfit;
+
+ stock.playerShares -= shares;
+ if (stock.playerShares == 0) {
+ stock.playerAvgPx = 0;
+ }
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_8__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_8__["Engine"].Page.StockMarket) {
+ Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["updateStockPlayerPosition"])(stock);
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.sellStock == null) {
+ workerScript.scriptRef.log("Sold " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(shares, 0) + " shares of " + stock.symbol + " at $" +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(stock.price, 2) + " per share. Gained " +
+ "$" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(gains, 2));
+ }
+ return stock.price;
+ },
+ shortStock(symbol, shares) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.shortStock) {
+ return 0;
+ } else {
+ workerScript.loadedFns.shortStock = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptBuySellStockRamCost;
+ }
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use shortStock()");
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 8) {
+ if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Cannot use shortStock(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8");
+ }
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid stock symbol passed into shortStock()");
+ }
+ var res = Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["shortStock"])(stock, shares, workerScript);
+ return res ? stock.price : 0;
+ },
+ sellShort(symbol, shares) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.sellShort) {
+ return 0;
+ } else {
+ workerScript.loadedFns.sellShort = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptBuySellStockRamCost;
+ }
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use sellShort()");
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 8) {
+ if (!(hasWallStreetSF && wallStreetSFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Cannot use sellShort(). You must either be in BitNode-8 or you must have Level 2 of Source-File 8");
+ }
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid stock symbol passed into sellShort()");
+ }
+ var res = Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["sellShort"])(stock, shares, workerScript);
+ return res ? stock.price : 0;
+ },
+ placeOrder(symbol, shares, price, type, pos) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.placeOrder) {
+ return 0;
+ } else {
+ workerScript.loadedFns.placeOrder = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptBuySellStockRamCost;
+ }
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use placeOrder()");
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 8) {
+ if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Cannot use placeOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8");
+ }
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid stock symbol passed into placeOrder()");
+ }
+ var orderType, orderPos;
+ type = type.toLowerCase();
+ if (type.includes("limit") && type.includes("buy")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["OrderTypes"].LimitBuy;
+ } else if (type.includes("limit") && type.includes("sell")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["OrderTypes"].LimitSell;
+ } else if (type.includes("stop") && type.includes("buy")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["OrderTypes"].StopBuy;
+ } else if (type.includes("stop") && type.includes("sell")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["OrderTypes"].StopSell;
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid Order Type passed into placeOrder()");
+ }
+
+ pos = pos.toLowerCase();
+ if (pos.includes("l")) {
+ orderPos = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["PositionTypes"].Long;
+ } else if (pos.includes('s')) {
+ orderPos = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["PositionTypes"].Short;
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid Position Type passed into placeOrder()");
+ }
+
+ return Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["placeOrder"])(stock, shares, price, orderType, orderPos, workerScript);
+ },
+ cancelOrder(symbol, shares, price, type, pos) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.cancelOrder) {
+ return 0;
+ } else {
+ workerScript.loadedFns.cancelOrder = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptBuySellStockRamCost;
+ }
+ }
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hasTixApiAccess) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "You don't have TIX API Access! Cannot use cancelOrder()");
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 8) {
+ if (!(hasWallStreetSF && wallStreetSFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Cannot use cancelOrder(). You must either be in BitNode-8 or have Level 3 of Source-File 8");
+ }
+ }
+ var stock = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["SymbolToStockMap"][symbol];
+ if (stock == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid stock symbol passed into cancelOrder()");
+ }
+ if (isNaN(shares) || isNaN(price)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid shares or price argument passed into cancelOrder(). Must be numeric");
+ }
+ var orderType, orderPos;
+ type = type.toLowerCase();
+ if (type.includes("limit") && type.includes("buy")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["OrderTypes"].LimitBuy;
+ } else if (type.includes("limit") && type.includes("sell")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["OrderTypes"].LimitSell;
+ } else if (type.includes("stop") && type.includes("buy")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["OrderTypes"].StopBuy;
+ } else if (type.includes("stop") && type.includes("sell")) {
+ orderType = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["OrderTypes"].StopSell;
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid Order Type passed into placeOrder()");
+ }
+
+ pos = pos.toLowerCase();
+ if (pos.includes("l")) {
+ orderPos = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["PositionTypes"].Long;
+ } else if (pos.includes('s')) {
+ orderPos = _StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["PositionTypes"].Short;
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERROR: Invalid Position Type passed into placeOrder()");
+ }
+ var params = {
+ stock: stock,
+ shares: shares,
+ price: price,
+ type: orderType,
+ pos: orderPos
+ };
+ return Object(_StockMarket_js__WEBPACK_IMPORTED_MODULE_19__["cancelOrder"])(params, workerScript);
+ },
+ purchaseServer : function(hostname, ram) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.purchaseServer) {
+ return 0;
+ } else {
+ workerScript.loadedFns.purchaseServer = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptPurchaseServerRamCost;
+ }
+ }
+ var hostnameStr = String(hostname);
+ hostnameStr = hostnameStr.replace(/\s+/g, '');
+ if (hostnameStr == "") {
+ workerScript.scriptRef.log("Error: Passed empty string for hostname argument of purchaseServer()");
+ return "";
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].purchasedServers.length >= _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].PurchasedServerLimit) {
+ workerScript.scriptRef.log("Error: You have reached the maximum limit of " + _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].PurchasedServerLimit +
+ " servers. You cannot purchase any more.");
+ return "";
+ }
+
+ ram = Math.round(ram);
+ if (isNaN(ram) || !Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_28__["powerOfTwo"])(ram)) {
+ workerScript.scriptRef.log("Error: Invalid ram argument passed to purchaseServer(). Must be numeric and a power of 2");
+ return "";
+ }
+
+ var cost = ram * _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].BaseCostFor1GBOfRamServer;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].money.lt(cost)) {
+ workerScript.scriptRef.log("Error: Not enough money to purchase server. Need $" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(cost, 2));
+ return "";
+ }
+ var newServ = new _Server_js__WEBPACK_IMPORTED_MODULE_16__["Server"](Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_29__["createRandomIp"])(), hostnameStr, "", false, true, true, ram);
+ Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["AddToAllServers"])(newServ);
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].purchasedServers.push(newServ.ip);
+ var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].getHomeComputer();
+ homeComputer.serversOnNetwork.push(newServ.ip);
+ newServ.serversOnNetwork.push(homeComputer.ip);
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].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_js__WEBPACK_IMPORTED_MODULE_30__["formatNumber"])(cost, 2));
+ }
+ return newServ.hostname;
+ },
+ deleteServer : function(hostname) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.deleteServer) {
+ return 0;
+ } else {
+ workerScript.loadedFns.deleteServer = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptPurchaseServerRamCost;
+ }
+ }
+ var hostnameStr = String(hostname);
+ hostnameStr = hostnameStr.replace(/\s\s+/g, '');
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["GetServerByHostname"])(hostnameStr);
+ if (server == null) {
+ workerScript.scriptRef.log("Error: Could not find server with hostname " + hostnameStr + ". deleteServer() failed");
+ return false;
+ }
+
+ if (!server.purchasedByPlayer || server.hostname == "home") {
+ workerScript.scriptRef.log("Error: Server " + server.hostname + " is not a purchased server. " +
+ "Cannot be deleted. deleteServer failed");
+ return false;
+ }
+
+ var ip = server.ip;
+
+ //A server cannot delete itself
+ if (ip == workerScript.serverIp) {
+ workerScript.scriptRef.log("Error: Cannot call deleteServer() on self. Function failed");
+ return false;
+ }
+
+ //Delete all scripts running on server
+ if (server.runningScripts.length > 0) {
+ workerScript.scriptRef.log("Error: Cannot delete server " + server.hostname + " because it still has scripts running.");
+ return false;
+ }
+
+ //Delete from player's purchasedServers array
+ var found = false;
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].purchasedServers.length; ++i) {
+ if (ip == _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].purchasedServers[i]) {
+ found = true;
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].purchasedServers.splice(i, 1);
+ break;
+ }
+ }
+
+ if (!found) {
+ workerScript.scriptRef.log("Error: Could not identify server " + server.hostname +
+ "as a purchased server. This is likely a bug please contact game dev");
+ return false;
+ }
+
+ //Delete from all servers
+ delete _Server_js__WEBPACK_IMPORTED_MODULE_16__["AllServers"][ip];
+
+ //Delete from home computer
+ found = false;
+ var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].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) {
+ if (workerScript.loadedFns.getPurchasedServers) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getPurchasedServers = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptPurchaseServerRamCost;
+ }
+ }
+ var res = [];
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].purchasedServers.forEach(function(ip) {
+ if (hostname) {
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find server in getPurchasedServers(). This is a bug please report to game dev");
+ }
+ res.push(server.hostname);
+ } else {
+ res.push(ip);
+ }
+ });
+ return res;
+ },
+ write : function(port, data="", mode="a") {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.write) {
+ return 0;
+ } else {
+ workerScript.loadedFns.write = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptReadWriteRamCost;
+ }
+ }
+ if (!isNaN(port)) { //Write to port
+ //Port 1-10
+ port = Math.round(port);
+ if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].NumNetscriptPorts) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERR: Trying to write to invalid port: " + port + ". Only ports 1-" + _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].NumNetscriptPorts + " are valid.");
+ }
+ var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__["NetscriptPorts"][port-1];
+ if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_25__["NetscriptPort"])) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Could not find port: " + port + ". This is a bug contact the game developer");
+ }
+ return port.write(data);
+ } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["isString"])(port)) { //Write to text file
+ var fn = port;
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(workerScript.serverIp);
+ if (server == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in write(). This is a bug please contact game dev");
+ }
+ var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_21__["getTextFile"])(fn, server);
+ if (txtFile == null) {
+ txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_21__["createTextFile"])(fn, data, server);
+ return true;
+ }
+ if (mode === "w") {
+ txtFile.write(data);
+ } else {
+ txtFile.append(data);
+ }
+ return true;
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument passed in for write: " + port);
+ }
+ },
+ read : function(port) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.read) {
+ return 0;
+ } else {
+ workerScript.loadedFns.read = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptReadWriteRamCost;
+ }
+ }
+ if (!isNaN(port)) { //Read from port
+ //Port 1-10
+ port = Math.round(port);
+ if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].NumNetscriptPorts) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERR: Trying to read from invalid port: " + port + ". Only ports 1-" + _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].NumNetscriptPorts + " are valid.");
+ }
+ var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__["NetscriptPorts"][port-1];
+ if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_25__["NetscriptPort"])) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
+ }
+ return port.read();
+ } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["isString"])(port)) { //Read from text file
+ var fn = port;
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(workerScript.serverIp);
+ if (server == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in read(). This is a bug please contact game dev");
+ }
+ var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_21__["getTextFile"])(fn, server);
+ if (txtFile !== null) {
+ return txtFile.text;
+ } else {
+ return "";
+ }
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument passed in for read(): " + port);
+ }
+ },
+ peek : function(port) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.peek) {
+ return 0;
+ } else {
+ workerScript.loadedFns.peek = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptReadWriteRamCost;
+ }
+ }
+ if (isNaN(port)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERR: peek() called with invalid argument. Must be a port number between 1 and " + _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].NumNetscriptPorts);
+ }
+ port = Math.round(port);
+ if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].NumNetscriptPorts) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERR: peek() called with invalid argument. Must be a port number between 1 and " + _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].NumNetscriptPorts);
+ }
+ var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__["NetscriptPorts"][port-1];
+ if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_25__["NetscriptPort"])) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
+ }
+ return port.peek();
+ },
+ clear : function(port) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.clear) {
+ return 0;
+ } else {
+ workerScript.loadedFns.clear = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptReadWriteRamCost;
+ }
+ }
+ if (!isNaN(port)) { //Clear port
+ port = Math.round(port);
+ if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].NumNetscriptPorts) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERR: Trying to clear invalid port: " + port + ". Only ports 1-" + _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].NumNetscriptPorts + " are valid");
+ }
+ var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__["NetscriptPorts"][port-1];
+ if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_25__["NetscriptPort"])) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
+ }
+ return port.clear();
+ } else if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["isString"])(port)) { //Clear text file
+ var fn = port;
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(workerScript.serverIp);
+ if (server == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in clear(). This is a bug please contact game dev");
+ }
+ var txtFile = Object(_TextFile_js__WEBPACK_IMPORTED_MODULE_21__["getTextFile"])(fn, server);
+ if (txtFile != null) {
+ txtFile.write("");
+ }
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid argument passed in for clear(): " + port);
+ }
+ return 0;
+ },
+ getPortHandle : function(port) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getPortHandle) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getPortHandle = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptReadWriteRamCost * 10;
+ }
+ }
+ if (isNaN(port)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERR: Invalid argument passed into getPortHandle(). Must be an integer between 1 and " + _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].NumNetscriptPorts);
+ }
+ port = Math.round(port);
+ if (port < 1 || port > _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].NumNetscriptPorts) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERR: getPortHandle() called with invalid port number: " + port + ". Only ports 1-" + _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].NumNetscriptPorts + " are valid");
+ }
+ var port = _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__["NetscriptPorts"][port-1];
+ if (port == null || !(port instanceof _NetscriptPort_js__WEBPACK_IMPORTED_MODULE_25__["NetscriptPort"])) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "ERR: Could not find port: " + port + ". This is a bug contact the game developer");
+ }
+ return port;
+ },
+ rm : function(fn) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.rm) {
+ return 0;
+ } else {
+ workerScript.loadedFns.rm = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptReadWriteRamCost;
+ }
+ }
+ var s = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(workerScript.serverIp);
+ if (s == null) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Error getting Server for this script in clear(). This is a bug please contact game dev");
+ }
+
+ 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 (fn.endsWith(".script")) {
+ 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_js__WEBPACK_IMPORTED_MODULE_12__["Message"]) && Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["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;
+ }
+ }
+ }
+ return false;
+ },
+ scriptRunning : function(scriptname, ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.scriptRunning) {
+ return 0;
+ } else {
+ workerScript.loadedFns.scriptRunning = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptArbScriptRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("scriptRunning() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "scriptRunning() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ for (var i = 0; i < server.runningScripts.length; ++i) {
+ if (server.runningScripts[i].filename == scriptname) {
+ return true;
+ }
+ }
+ return false;
+ },
+ scriptKill : function(scriptname, ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.scriptKill) {
+ return 0;
+ } else {
+ workerScript.loadedFns.scriptKill = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptArbScriptRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("scriptKill() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "scriptKill() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ var suc = false;
+ for (var i = 0; i < server.runningScripts.length; ++i) {
+ if (server.runningScripts[i].filename == scriptname) {
+ Object(_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__["killWorkerScript"])(server.runningScripts[i], server.ip);
+ suc = true;
+ }
+ }
+ return suc;
+ },
+ getScriptRam : function (scriptname, ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getScriptRam) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getScriptRam = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetScriptRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getScriptRam() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "getScriptRam() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ for (var i = 0; i < server.scripts.length; ++i) {
+ if (server.scripts[i].filename == scriptname) {
+ return server.scripts[i].ramUsage;
+ }
+ }
+ return 0;
+ },
+ getHackTime : function(ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getHackTime) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getHackTime = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetHackTimeRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getHackTime() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "getHackTime() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["scriptCalculateHackingTime"])(server); //Returns seconds
+ },
+ getGrowTime : function(ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getGrowTime) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getGrowTime = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetHackTimeRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getGrowTime() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "getGrowTime() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["scriptCalculateGrowTime"])(server) / 1000; //Returns seconds
+ },
+ getWeakenTime : function(ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getWeakenTime) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getWeakenTime = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetHackTimeRamCost;
+ }
+ }
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "getWeakenTime() failed. Invalid IP or hostname passed in: " + ip);
+ }
+ return Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["scriptCalculateWeakenTime"])(server) / 1000; //Returns seconds
+ },
+ getScriptIncome : function(scriptname, ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getScriptIncome) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getScriptIncome = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetScriptRamCost;
+ }
+ }
+ if (arguments.length === 0) {
+ //Get total script income
+ var res = [];
+ res.push(Object(_ActiveScriptsUI_js__WEBPACK_IMPORTED_MODULE_0__["updateActiveScriptsItems"])());
+ res.push(_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].scriptProdSinceLastAug / (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].playtimeSinceLastAug/1000));
+ return res;
+ } else {
+ //Get income for a particular script
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "getScriptIncome() failed. Invalid IP or hostnamed passed in: " + ip);
+ }
+ var argsForScript = [];
+ for (var i = 2; i < arguments.length; ++i) {
+ argsForScript.push(arguments[i]);
+ }
+ var runningScriptObj = Object(_Script_js__WEBPACK_IMPORTED_MODULE_15__["findRunningScript"])(scriptname, argsForScript, server);
+ if (runningScriptObj == null) {
+ workerScript.scriptRef.log("getScriptIncome() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_28__["printArray"])(argsForScript));
+ return -1;
+ }
+ return runningScriptObj.onlineMoneyMade / runningScriptObj.onlineRunningTime;
+ }
+ },
+ getScriptExpGain : function(scriptname, ip) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getScriptExpGain) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getScriptExpGain = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetScriptRamCost;
+ }
+ }
+ if (arguments.length === 0) {
+ var total = 0;
+ for (var i = 0; i < _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__["workerScripts"].length; ++i) {
+ total += (_NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__["workerScripts"][i].scriptRef.onlineExpGained / _NetscriptWorker_js__WEBPACK_IMPORTED_MODULE_22__["workerScripts"][i].scriptRef.onlineRunningTime);
+ }
+ return total;
+ } else {
+ //Get income for a particular script
+ var server = Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["getServer"])(ip);
+ if (server == null) {
+ workerScript.scriptRef.log("getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip);
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "getScriptExpGain() failed. Invalid IP or hostnamed passed in: " + ip);
+ }
+ var argsForScript = [];
+ for (var i = 2; i < arguments.length; ++i) {
+ argsForScript.push(arguments[i]);
+ }
+ var runningScriptObj = Object(_Script_js__WEBPACK_IMPORTED_MODULE_15__["findRunningScript"])(scriptname, argsForScript, server);
+ if (runningScriptObj == null) {
+ workerScript.scriptRef.log("getScriptExpGain() failed. No such script "+ scriptname + " on " + server.hostname + " with args: " + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_28__["printArray"])(argsForScript));
+ return -1;
+ }
+ return runningScriptObj.onlineExpGained / runningScriptObj.onlineRunningTime;
+ }
+ },
+ getTimeSinceLastAug : function() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getTimeSinceLastAug) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getTimeSinceLastAug = true;
+ return _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptGetHackTimeRamCost;
+ }
+ }
+ return _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].playtimeSinceLastAug;
+ },
+ prompt : function(txt) {
+ if (workerScript.checkingRam) {return 0;}
+ if (_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_31__["yesNoBoxOpen"]) {
+ workerScript.scriptRef.log("ERROR: confirm() failed because a pop-up dialog box is already open");
+ return false;
+ }
+ if (!Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["isString"])(txt)) {txt = String(txt);}
+ var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_31__["yesNoBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_31__["yesNoBoxGetNoButton"])();
+ yesBtn.innerHTML = "Yes";
+ noBtn.innerHTML = "No";
+ return new Promise(function(resolve, reject) {
+ yesBtn.addEventListener("click", ()=>{
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_31__["yesNoBoxClose"])();
+ resolve(true);
+ });
+ noBtn.addEventListener("click", ()=>{
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_31__["yesNoBoxClose"])();
+ resolve(false);
+ });
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_31__["yesNoBoxCreate"])(txt);
+ });
+ },
+
+ /* Singularity Functions */
+ universityCourse : function(universityName, className) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.universityCourse) {
+ return 0;
+ } else {
+ workerScript.loadedFns.universityCourse = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn1RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run universityCourse(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return false;
+ }
+ }
+ if (_Missions_js__WEBPACK_IMPORTED_MODULE_13__["inMission"]) {
+ workerScript.scriptRef.log("ERROR: universityCourse() failed because you are in the middle of a mission.");
+ return;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].isWorking) {
+ var txt = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].singularityStopWork();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.universityCourse == null) {
+ workerScript.scriptRef.log(txt);
+ }
+ }
+
+ var costMult, expMult;
+ switch(universityName.toLowerCase()) {
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].AevumSummitUniversity.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Aevum) {
+ workerScript.scriptRef.log("ERROR: You cannot study at Summit University because you are not in Aevum. universityCourse() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].AevumSummitUniversity;
+ costMult = 4;
+ expMult = 3;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Sector12RothmanUniversity.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Sector12) {
+ workerScript.scriptRef.log("ERROR: You cannot study at Rothman University because you are not in Sector-12. universityCourse() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Sector12RothmanUniversity;
+ costMult = 3;
+ expMult = 2;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].VolhavenZBInstituteOfTechnology.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_11__["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_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_11__["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_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ClassStudyComputerScience;
+ break;
+ case "Data Structures".toLowerCase():
+ task = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ClassDataStructures;
+ break;
+ case "Networks".toLowerCase():
+ task = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ClassNetworks;
+ break;
+ case "Algorithms".toLowerCase():
+ task = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ClassAlgorithms;
+ break;
+ case "Management".toLowerCase():
+ task = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ClassManagement;
+ break;
+ case "Leadership".toLowerCase():
+ task = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ClassLeadership;
+ break;
+ default:
+ workerScript.scriptRef.log("Invalid class name: " + className + ". universityCourse() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].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) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.gymWorkout) {
+ return 0;
+ } else {
+ workerScript.loadedFns.gymWorkout = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn1RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run gymWorkout(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return false;
+ }
+ }
+ if (_Missions_js__WEBPACK_IMPORTED_MODULE_13__["inMission"]) {
+ workerScript.scriptRef.log("ERROR: gymWorkout() failed because you are in the middle of a mission.");
+ return;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].isWorking) {
+ var txt = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].singularityStopWork();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.gymWorkout == null) {
+ workerScript.scriptRef.log(txt);
+ }
+ }
+ var costMult, expMult;
+ switch(gymName.toLowerCase()) {
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].AevumCrushFitnessGym.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Aevum) {
+ workerScript.scriptRef.log("ERROR: You cannot workout at Crush Fitness because you are not in Aevum. gymWorkout() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].AevumCrushFitnessGym;
+ costMult = 2;
+ expMult = 1.5;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].AevumSnapFitnessGym.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Aevum) {
+ workerScript.scriptRef.log("ERROR: You cannot workout at Snap Fitness because you are not in Aevum. gymWorkout() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].AevumSnapFitnessGym;
+ costMult = 6;
+ expMult = 4;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Sector12IronGym.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Sector12) {
+ workerScript.scriptRef.log("ERROR: You cannot workout at Iron Gym because you are not in Sector-12. gymWorkout() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Sector12IronGym;
+ costMult = 1;
+ expMult = 1;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Sector12PowerhouseGym.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Sector12) {
+ workerScript.scriptRef.log("ERROR: You cannot workout at Powerhouse Gym because you are not in Sector-12. gymWorkout() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Sector12PowerhouseGym;
+ costMult = 10;
+ expMult = 7.5;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].VolhavenMilleniumFitnessGym:
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].city != _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Volhaven) {
+ workerScript.scriptRef.log("ERROR: You cannot workout at Millenium Fitness Gym because you are not in Volhaven. gymWorkout() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].VolhavenMilleniumFitnessGym;
+ costMult = 3;
+ expMult = 2.5;
+ break;
+ default:
+ workerScript.scriptRef.log("Invalid gym name: " + gymName + ". gymWorkout() failed");
+ return false;
+ }
+
+ switch(stat.toLowerCase()) {
+ case "strength".toLowerCase():
+ case "str".toLowerCase():
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startClass(costMult, expMult, _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ClassGymStrength);
+ break;
+ case "defense".toLowerCase():
+ case "def".toLowerCase():
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startClass(costMult, expMult, _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ClassGymDefense);
+ break;
+ case "dexterity".toLowerCase():
+ case "dex".toLowerCase():
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startClass(costMult, expMult, _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ClassGymDexterity);
+ break;
+ case "agility".toLowerCase():
+ case "agi".toLowerCase():
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startClass(costMult, expMult, _Constants_js__WEBPACK_IMPORTED_MODULE_5__["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) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.travelToCity) {
+ return 0;
+ } else {
+ workerScript.loadedFns.travelToCity = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn1RamCost / 2;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run travelToCity(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return false;
+ }
+ }
+
+ switch(cityname) {
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Aevum:
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Chongqing:
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Sector12:
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].NewTokyo:
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Ishima:
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Volhaven:
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].loseMoney(200000);
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].city = cityname;
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
+ 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() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.purchaseTor) {
+ return 0;
+ } else {
+ workerScript.loadedFns.purchaseTor = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn1RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run purchaseTor(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return false;
+ }
+ }
+
+ if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_18__["SpecialServerIps"]["Darkweb Server"] != null) {
+ workerScript.scriptRef.log("You already have a TOR router! purchaseTor() failed");
+ return false;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].money.lt(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].TorRouterCost)) {
+ workerScript.scriptRef.log("ERROR: You cannot afford to purchase a Tor router. purchaseTor() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].loseMoney(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].TorRouterCost);
+
+ var darkweb = new _Server_js__WEBPACK_IMPORTED_MODULE_16__["Server"](Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_29__["createRandomIp"])(), "darkweb", "", false, false, false, 1);
+ Object(_Server_js__WEBPACK_IMPORTED_MODULE_16__["AddToAllServers"])(darkweb);
+ _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_18__["SpecialServerIps"].addIp("Darkweb Server", darkweb.ip);
+
+ document.getElementById("location-purchase-tor").setAttribute("class", "a-link-button-inactive");
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].getHomeComputer().serversOnNetwork.push(darkweb.ip);
+ darkweb.serversOnNetwork.push(_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].getHomeComputer().ip);
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseTor == null) {
+ workerScript.scriptRef.log("You have purchased a Tor router!");
+ }
+ return true;
+ },
+ purchaseProgram(programName) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.purchaseProgram) {
+ return 0;
+ } else {
+ workerScript.loadedFns.purchaseProgram = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn1RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run purchaseProgram(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return false;
+ }
+ }
+
+ if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_18__["SpecialServerIps"]["Darkweb Server"] == null) {
+ workerScript.scriptRef.log("ERROR: You do not have TOR router. purchaseProgram() failed.");
+ return false;
+ }
+
+ switch(programName.toLowerCase()) {
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].BruteSSHProgram.toLowerCase():
+ var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__["DarkWebItems"].BruteSSHProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].BruteSSHProgram);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
+ workerScript.scriptRef.log("You have purchased the BruteSSH.exe program. The new program can be found on your home computer.");
+ }
+ } else {
+ workerScript.scriptRef.log("Not enough money to purchase " + programName);
+ return false;
+ }
+ return true;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].FTPCrackProgram.toLowerCase():
+ var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__["DarkWebItems"].FTPCrackProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].FTPCrackProgram);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
+ workerScript.scriptRef.log("You have purchased the FTPCrack.exe program. The new program can be found on your home computer.");
+ }
+ } else {
+ workerScript.scriptRef.log("Not enough money to purchase " + programName);
+ return false;
+ }
+ return true;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].RelaySMTPProgram.toLowerCase():
+ var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__["DarkWebItems"].RelaySMTPProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].RelaySMTPProgram);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
+ workerScript.scriptRef.log("You have purchased the relaySMTP.exe program. The new program can be found on your home computer.");
+ }
+ } else {
+ workerScript.scriptRef.log("Not enough money to purchase " + programName);
+ return false;
+ }
+ return true;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].HTTPWormProgram.toLowerCase():
+ var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__["DarkWebItems"].HTTPWormProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].HTTPWormProgram);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
+ workerScript.scriptRef.log("You have purchased the HTTPWorm.exe program. The new program can be found on your home computer.");
+ }
+ } else {
+ workerScript.scriptRef.log("Not enough money to purchase " + programName);
+ return false;
+ }
+ return true;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].SQLInjectProgram.toLowerCase():
+ var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__["DarkWebItems"].SQLInjectProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].SQLInjectProgram);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
+ workerScript.scriptRef.log("You have purchased the SQLInject.exe program. The new program can be found on your home computer.");
+ }
+ } else {
+ workerScript.scriptRef.log("Not enough money to purchase " + programName);
+ return false;
+ }
+ return true;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].DeepscanV1.toLowerCase():
+ var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__["DarkWebItems"].DeepScanV1Program);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].DeepscanV1);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
+ workerScript.scriptRef.log("You have purchased the DeepscanV1.exe program. The new program can be found on your home computer.");
+ }
+ } else {
+ workerScript.scriptRef.log("Not enough money to purchase " + programName);
+ return false;
+ }
+ return true;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].DeepscanV2.toLowerCase():
+ var price = Object(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__["parseDarkwebItemPrice"])(_DarkWeb_js__WEBPACK_IMPORTED_MODULE_7__["DarkWebItems"].DeepScanV2Program);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].DeepscanV2);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.purchaseProgram == null) {
+ workerScript.scriptRef.log("You have purchased the DeepscanV2.exe program. The new program can be found on your home computer.");
+ }
+ } else {
+ workerScript.scriptRef.log("Not enough money to purchase " + programName);
+ return false;
+ }
+ return true;
+ default:
+ workerScript.scriptRef.log("ERROR: Invalid program passed into purchaseProgram().");
+ return false;
+ }
+ return true;
+ },
+ getStats : function() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getStats) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getStats = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn1RamCost / 4;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getStats(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return {};
+ }
+ }
+
+ return {
+ hacking: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_skill,
+ strength: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].strength,
+ defense: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].defense,
+ dexterity: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].dexterity,
+ agility: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].agility,
+ charisma: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].charisma,
+ intelligence: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].intelligence
+ }
+ },
+ getCharacterInformation : function() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getCharacterInformation) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getCharacterInformation = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn1RamCost / 4;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getCharacterInformation(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return {};
+ }
+ }
+
+ var companyPositionTitle = "";
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].companyPosition instanceof _Company_js__WEBPACK_IMPORTED_MODULE_4__["CompanyPosition"]) {
+ companyPositionTitle = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].companyPosition.positionName;
+ }
+ return {
+ bitnode: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN,
+ company: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].companyName,
+ jobTitle: companyPositionTitle,
+ city: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].city,
+ factions: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].factions.slice(),
+ tor: _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_18__["SpecialServerIps"].hasOwnProperty("Darkweb Server"),
+ timeWorked: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].timeWorked,
+ workHackExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].workHackExpGained,
+ workStrExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].workStrExpGained,
+ workDefExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].workDefExpGained,
+ workDexExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].workDexExpGained,
+ workAgiExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].workAgiExpGained,
+ workChaExpGain: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].workChaExpGained,
+ workRepGain: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].workRepGained,
+ workMoneyGain: _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].workMoneyGained,
+ };
+ },
+ isBusy : function() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.isBusy) {
+ return 0;
+ } else {
+ workerScript.loadedFns.isBusy = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn1RamCost / 4;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run isBusy(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return;
+ }
+ }
+ return _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].isWorking;
+ },
+ stopAction : function() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.stopAction) {
+ return 0;
+ } else {
+ workerScript.loadedFns.stopAction = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn1RamCost / 2;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 1)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run stopAction(). It is a Singularity Function and requires SourceFile-4 (level 1) to run.");
+ return false;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].isWorking) {
+ var txt = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].singularityStopWork();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.stopAction == null) {
+ workerScript.scriptRef.log(txt);
+ }
+ return true;
+ }
+ return false;
+ },
+ upgradeHomeRam : function() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.upgradeHomeRam) {
+ return 0;
+ } else {
+ workerScript.loadedFns.upgradeHomeRam = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn2RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run upgradeHomeRam(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ //Calculate how many times ram has been upgraded (doubled)
+ var currentRam = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].getHomeComputer().maxRam;
+ var numUpgrades = Math.log2(currentRam);
+
+ //Calculate cost
+ //Have cost increase by some percentage each time RAM has been upgraded
+ var cost = currentRam * _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].BaseCostFor1GBOfRamHome;
+ var mult = Math.pow(1.55, numUpgrades);
+ cost = cost * mult;
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].money.lt(cost)) {
+ workerScript.scriptRef.log("ERROR: upgradeHomeRam() failed because you don't have enough money");
+ return false;
+ }
+
+ var homeComputer = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].getHomeComputer();
+ homeComputer.maxRam *= 2;
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].loseMoney(cost);
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["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() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getUpgradeHomeRamCost) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getUpgradeHomeRamCost = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn2RamCost / 2;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getUpgradeHomeRamCost(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ //Calculate how many times ram has been upgraded (doubled)
+ var currentRam = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].getHomeComputer().maxRam;
+ var numUpgrades = Math.log2(currentRam);
+
+ //Calculate cost
+ //Have cost increase by some percentage each time RAM has been upgraded
+ var cost = currentRam * _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].BaseCostFor1GBOfRamHome;
+ var mult = Math.pow(1.55, numUpgrades);
+ return cost * mult;
+ },
+ workForCompany : function() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.workForCompany) {
+ return 0;
+ } else {
+ workerScript.loadedFns.workForCompany = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn2RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run workForCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ if (_Missions_js__WEBPACK_IMPORTED_MODULE_13__["inMission"]) {
+ workerScript.scriptRef.log("ERROR: workForCompany() failed because you are in the middle of a mission.");
+ return;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].companyPosition == "" || !(_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].companyPosition instanceof _Company_js__WEBPACK_IMPORTED_MODULE_4__["CompanyPosition"])) {
+ workerScript.scriptRef.log("ERROR: workForCompany() failed because you do not have a job");
+ return false;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].isWorking) {
+ var txt = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].singularityStopWork();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForCompany == null) {
+ workerScript.scriptRef.log(txt);
+ }
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].companyPosition.isPartTimeJob()) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startWorkPartTime();
+ } else {
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startWork();
+ }
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForCompany == null) {
+ workerScript.scriptRef.log("Began working at " + _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].companyName + " as a " + _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].companyPosition.positionName);
+ }
+ return true;
+ },
+ applyToCompany : function(companyName, field) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.applyToCompany) {
+ return 0;
+ } else {
+ workerScript.loadedFns.applyToCompany = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn2RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run applyToCompany(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ if (!Object(_Company_js__WEBPACK_IMPORTED_MODULE_4__["companyExists"])(companyName)) {
+ workerScript.scriptRef.log("ERROR: applyToCompany() failed because specified company " + companyName + " does not exist.");
+ return false;
+ }
+
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = companyName;
+ var res;
+ switch (field.toLowerCase()) {
+ case "software":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].applyForSoftwareJob(true);
+ break;
+ case "software consultant":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].applyForSoftwareConsultantJob(true);
+ break;
+ case "it":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].applyForItJob(true);
+ break;
+ case "security engineer":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].applyForSecurityEngineerJob(true);
+ break;
+ case "network engineer":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].applyForNetworkEngineerJob(true);
+ break;
+ case "business":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].applyForBusinessJob(true);
+ break;
+ case "business consultant":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].applyForBusinessConsultantJob(true);
+ break;
+ case "security":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].applyForSecurityJob(true);
+ break;
+ case "agent":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].applyForAgentJob(true);
+ break;
+ case "employee":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].applyForEmployeeJob(true);
+ break;
+ case "part-time employee":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].applyForPartTimeEmployeeJob(true);
+ break;
+ case "waiter":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].applyForWaiterJob(true);
+ break;
+ case "part-time waiter":
+ res = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].applyForPartTimeWaiterJob(true);
+ break;
+ default:
+ workerScript.scriptRef.log("ERROR: Invalid job passed into applyToCompany: " + field + ". applyToCompany() failed");
+ return false;
+ }
+ //The Player object's applyForJob function can return string with special error messages
+ if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["isString"])(res)) {
+ workerScript.scriptRef.log(res);
+ return false;
+ }
+ if (res) {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.applyToCompany == null) {
+ workerScript.scriptRef.log("You were offered a new job at " + companyName + " as a " + _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].companyPosition.positionName);
+ }
+ } else {
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.applyToCompany == null) {
+ workerScript.scriptRef.log("You failed to get a new job/promotion at " + companyName + " in the " + field + " field.");
+ }
+ }
+ return res;
+ },
+ getCompanyRep : function(companyName) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getCompanyRep) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getCompanyRep = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn2RamCost / 4;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getCompanyRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_4__["Companies"][companyName];
+ if (company == null || !(company instanceof _Company_js__WEBPACK_IMPORTED_MODULE_4__["Company"])) {
+ workerScript.scriptRef.log("ERROR: Invalid companyName passed into getCompanyRep(): " + companyName);
+ return -1;
+ }
+ return company.playerReputation;
+ },
+ getCompanyFavor : function(companyName) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getCompanyFavor) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getCompanyFavor = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn2RamCost / 4;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getCompanyFavor(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ var company = _Company_js__WEBPACK_IMPORTED_MODULE_4__["Companies"][companyName];
+ if (company == null || !(company instanceof _Company_js__WEBPACK_IMPORTED_MODULE_4__["Company"])) {
+ workerScript.scriptRef.log("ERROR: Invalid companyName passed into getCompanyFavor(): " + companyName);
+ return -1;
+ }
+ return company.favor;
+ },
+ checkFactionInvitations : function() {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.checkFactionInvitations) {
+ return 0;
+ } else {
+ workerScript.loadedFns.checkFactionInvitations = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn2RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run checkFactionInvitations(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+ //Make a copy of Player.factionInvitations
+ return _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].factionInvitations.slice();
+ },
+ joinFaction : function(name) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.joinFaction) {
+ return 0;
+ } else {
+ workerScript.loadedFns.joinFaction = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn2RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run joinFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_9__["factionExists"])(name)) {
+ workerScript.scriptRef.log("ERROR: Faction specified in joinFaction() does not exist.");
+ return false;
+ }
+
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].factionInvitations.includes(name)) {
+ workerScript.scriptRef.log("ERROR: Cannot join " + name + " Faction because you have not been invited. joinFaction() failed");
+ return false;
+ }
+
+ var index = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].factionInvitations.indexOf(name);
+ if (index === -1) {
+ //Redundant and should never happen...
+ workerScript.scriptRef.log("ERROR: Cannot join " + name + " Faction because you have not been invited. joinFaction() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].factionInvitations.splice(index, 1);
+ var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_9__["Factions"][name];
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_9__["joinFaction"])(fac);
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.joinFaction == null) {
+ workerScript.scriptRef.log("Joined the " + name + " faction.");
+ }
+ return true;
+ },
+ workForFaction : function(name, type) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.workForFaction) {
+ return 0;
+ } else {
+ workerScript.loadedFns.workForFaction = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn2RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run workForFaction(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return false;
+ }
+ }
+
+ if (_Missions_js__WEBPACK_IMPORTED_MODULE_13__["inMission"]) {
+ workerScript.scriptRef.log("ERROR: workForFaction() failed because you are in the middle of a mission.");
+ return;
+ }
+
+ if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_9__["factionExists"])(name)) {
+ workerScript.scriptRef.log("ERROR: Faction specified in workForFaction() does not exist.");
+ return false;
+ }
+
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].factions.includes(name)) {
+ workerScript.scriptRef.log("ERROR: workForFaction() failed because you are not a member of " + name);
+ return false;
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].isWorking) {
+ var txt = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].singularityStopWork();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.workForFaction == null) {
+ workerScript.scriptRef.log(txt);
+ }
+ }
+
+ var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_9__["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_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startFactionHackWork(fac);
+ workerScript.scriptRef.log("Started carrying out hacking contracts for " + fac.name);
+ return true;
+ case "field":
+ case "fieldwork":
+ case "field work":
+ if (!fdWkAvailable.includes(fac.name)) {
+ workerScript.scriptRef.log("ERROR: Cannot carry out field missions for " + fac.name + ". workForFaction() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startFactionFieldWork(fac);
+ workerScript.scriptRef.log("Started carrying out field missions for " + fac.name);
+ return true;
+ case "security":
+ case "securitywork":
+ case "security work":
+ if (!scWkAvailable.includes(fac.name)) {
+ workerScript.scriptRef.log("ERROR: Cannot serve as security detail for " + fac.name + ". workForFaction() failed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startFactionSecurityWork(fac);
+ workerScript.scriptRef.log("Started serving as security details for " + fac.name);
+ return true;
+ default:
+ workerScript.scriptRef.log("ERROR: Invalid work type passed into workForFaction(): " + type);
+ }
+ return true;
+ },
+ getFactionRep : function(name) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getFactionRep) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getFactionRep = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn2RamCost / 4;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getFactionRep(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return -1;
+ }
+ }
+
+ if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_9__["factionExists"])(name)) {
+ workerScript.scriptRef.log("ERROR: Faction specified in getFactionRep() does not exist.");
+ return -1;
+ }
+
+ return _Faction_js__WEBPACK_IMPORTED_MODULE_9__["Factions"][name].playerReputation;
+ },
+ getFactionFavor : function(name) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getFactionFavor) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getFactionFavor = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn2RamCost / 4;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 2)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getFactionFavor(). It is a Singularity Function and requires SourceFile-4 (level 2) to run.");
+ return -1;
+ }
+ }
+
+ if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_9__["factionExists"])(name)) {
+ workerScript.scriptRef.log("ERROR: Faction specified in getFactionFavor() does not exist.");
+ return -1;
+ }
+
+ return _Faction_js__WEBPACK_IMPORTED_MODULE_9__["Factions"][name].favor;
+ },
+ createProgram : function(name) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.createProgram) {
+ return 0;
+ } else {
+ workerScript.loadedFns.createProgram = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run createProgram(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return false;
+ }
+ }
+ if (_Missions_js__WEBPACK_IMPORTED_MODULE_13__["inMission"]) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because you are in the middle of a mission.");
+ return;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].isWorking) {
+ var txt = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].singularityStopWork();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.createProgram == null) {
+ workerScript.scriptRef.log(txt);
+ }
+ }
+
+ switch(name.toLowerCase()) {
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].NukeProgram.toLowerCase():
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].NukeProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].MillisecondsPerFiveMinutes, 1);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].BruteSSHProgram.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_skill < 50) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create BruteSSH (level 50 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].BruteSSHProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].MillisecondsPerFiveMinutes * 2, 50);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].FTPCrackProgram.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_skill < 100) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create FTPCrack (level 100 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].FTPCrackProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].MillisecondsPerHalfHour, 100);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].RelaySMTPProgram.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_skill < 250) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create relaySMTP (level 250 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].RelaySMTPProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].MillisecondsPer2Hours, 250);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].HTTPWormProgram.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_skill < 500) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create HTTPWorm (level 500 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].HTTPWormProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].MillisecondsPer4Hours, 500);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].SQLInjectProgram.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_skill < 750) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create SQLInject (level 750 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].SQLInjectProgram, _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].MillisecondsPer8Hours, 750);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].DeepscanV1.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_skill < 75) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV1 (level 75 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].DeepscanV1, _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].MillisecondsPerQuarterHour, 75);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].DeepscanV2.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_skill < 400) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create DeepscanV2 (level 400 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].DeepscanV2, _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].MillisecondsPer2Hours, 400);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].ServerProfiler.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_skill < 75) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create ServerProfiler (level 75 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].ServerProfiler, _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].MillisecondsPerHalfHour, 75);
+ break;
+ case _CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].AutoLink.toLowerCase():
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].hacking_skill < 25) {
+ workerScript.scriptRef.log("ERROR: createProgram() failed because hacking level is too low to create AutoLink (level 25 req)");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].startCreateProgramWork(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_6__["Programs"].AutoLink, _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].MillisecondsPerQuarterHour, 25);
+ break;
+ default:
+ workerScript.scriptRef.log("ERROR: createProgram() failed because the specified program does not exist: " + name);
+ return false;
+ }
+ workerScript.scriptRef.log("Began creating program: " + name);
+ return true;
+ },
+ commitCrime : function(crime) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.commitCrime) {
+ return 0;
+ } else {
+ workerScript.loadedFns.commitCrime = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run commitCrime(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return;
+ }
+ }
+ if (_Missions_js__WEBPACK_IMPORTED_MODULE_13__["inMission"]) {
+ workerScript.scriptRef.log("ERROR: commitCrime() failed because you are in the middle of a mission.");
+ return;
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].isWorking) {
+ var txt = _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].singularityStopWork();
+ if (workerScript.disableLogs.ALL == null && workerScript.disableLogs.commitCrime == null) {
+ workerScript.scriptRef.log(txt);
+ }
+ }
+
+ //Set Location to slums
+ switch(_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].city) {
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Aevum:
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].AevumSlums;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Chongqing:
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].ChongqingSlums;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Sector12:
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Sector12Slums;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].NewTokyo:
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].NewTokyoSlums;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Ishima:
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].IshimaSlums;
+ break;
+ case _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].Volhaven:
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].location = _Location_js__WEBPACK_IMPORTED_MODULE_11__["Locations"].VolhavenSlums;
+ break;
+ default:
+ console.log("Invalid Player.city value");
+ }
+
+ crime = crime.toLowerCase();
+ if (crime.includes("shoplift")) {
+ workerScript.scriptRef.log("Attempting to shoplift...");
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitShopliftCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
+ } else if (crime.includes("rob") && crime.includes("store")) {
+ workerScript.scriptRef.log("Attempting to rob a store...");
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitRobStoreCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
+ } else if (crime.includes("mug")) {
+ workerScript.scriptRef.log("Attempting to mug someone...");
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitMugCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
+ } else if (crime.includes("larceny")) {
+ workerScript.scriptRef.log("Attempting to commit larceny...");
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitLarcenyCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
+ } else if (crime.includes("drugs")) {
+ workerScript.scriptRef.log("Attempting to deal drugs...");
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitDealDrugsCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
+ } else if (crime.includes("bond") && crime.includes("forge")) {
+ workerScript.scriptRef.log("Attempting to forge corporate bonds...");
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitBondForgeryCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
+ } else if (crime.includes("traffick") && crime.includes("arms")) {
+ workerScript.scriptRef.log("Attempting to traffick illegal arms...");
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitTraffickArmsCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
+ } else if (crime.includes("homicide")) {
+ workerScript.scriptRef.log("Attempting to commit homicide...");
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitHomicideCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
+ } else if (crime.includes("grand") && crime.includes("auto")) {
+ workerScript.scriptRef.log("Attempting to commit grand theft auto...");
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitGrandTheftAutoCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
+ } else if (crime.includes("kidnap")) {
+ workerScript.scriptRef.log("Attempting to kidnap and ransom a high-profile target...");
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitKidnapCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
+ } else if (crime.includes("assassinate")) {
+ workerScript.scriptRef.log("Attempting to assassinate a high-profile target...");
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitAssassinationCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript})
+ } else if (crime.includes("heist")) {
+ workerScript.scriptRef.log("Attempting to pull off a heist...");
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["commitHeistCrime"])(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].CrimeSingFnDivider, {workerscript: workerScript});
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid crime passed into commitCrime(): " + crime);
+ }
+ },
+ getCrimeChance : function(crime) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getCrimeChance) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getCrimeChance = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getCrimeChance(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return;
+ }
+ }
+
+ crime = crime.toLowerCase();
+ if (crime.includes("shoplift")) {
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceShoplift"])();
+ } else if (crime.includes("rob") && crime.includes("store")) {
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceRobStore"])();
+ } else if (crime.includes("mug")) {
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceMug"])();
+ } else if (crime.includes("larceny")) {
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceLarceny"])();
+ } else if (crime.includes("drugs")) {
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceDealDrugs"])();
+ } else if (crime.includes("bond") && crime.includes("forge")) {
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceBondForgery"])();
+ } else if (crime.includes("traffick") && crime.includes("arms")) {
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceTraffickArms"])();
+ } else if (crime.includes("homicide")) {
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceHomicide"])();
+ } else if (crime.includes("grand") && crime.includes("auto")) {
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceGrandTheftAuto"])();
+ } else if (crime.includes("kidnap")) {
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceKidnap"])();
+ } else if (crime.includes("assassinate")) {
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceAssassination"])();
+ } else if (crime.includes("heist")) {
+ return Object(_Crimes_js__WEBPACK_IMPORTED_MODULE_3__["determineCrimeChanceHeist"])();
+ } else {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Invalid crime passed into getCrimeChance(): " + crime);
+ }
+ },
+ getOwnedAugmentations : function(purchased=false) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getOwnedAugmentations) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getOwnedAugmentations = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getOwnedAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return [];
+ }
+ }
+ var res = [];
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].augmentations.length; ++i) {
+ res.push(_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].augmentations[i].name);
+ }
+ if (purchased) {
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].queuedAugmentations.length; ++i) {
+ res.push(_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].queuedAugmentations[i].name);
+ }
+ }
+ return res;
+ },
+ getAugmentationsFromFaction : function(facname) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getAugmentationsFromFaction) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getAugmentationsFromFaction = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getAugmentationsFromFaction(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return [];
+ }
+ }
+
+ if (!Object(_Faction_js__WEBPACK_IMPORTED_MODULE_9__["factionExists"])(facname)) {
+ workerScript.scriptRef.log("ERROR: getAugmentationsFromFaction() failed. Invalid faction name passed in (this is case-sensitive): " + facname);
+ return [];
+ }
+
+ var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_9__["Factions"][facname];
+ var res = [];
+ for (var i = 0; i < fac.augmentations.length; ++i) {
+ res.push(fac.augmentations[i]);
+ }
+ return res;
+ },
+ getAugmentationCost : function(name) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.getAugmentationCost) {
+ return 0;
+ } else {
+ workerScript.loadedFns.getAugmentationCost = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run getAugmentationCost(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return false;
+ }
+ }
+
+ if (!Object(_Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["augmentationExists"])(name)) {
+ workerScript.scriptRef.log("ERROR: getAugmentationCost() failed. Invalid Augmentation name passed in (note: this is case-sensitive): " + name);
+ return [-1, -1];
+ }
+
+ var aug = _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["Augmentations"][name];
+ return [aug.baseRepRequirement, aug.baseCost];
+ },
+ purchaseAugmentation : function(faction, name) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.purchaseAugmentation) {
+ return 0;
+ } else {
+ workerScript.loadedFns.purchaseAugmentation = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run purchaseAugmentation(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return false;
+ }
+ }
+
+ var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_9__["Factions"][faction];
+ if (fac == null || !(fac instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_9__["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 = _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["Augmentations"][name];
+ if (aug == null || !(aug instanceof _Augmentations_js__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 === _Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["AugmentationNames"].NeuroFluxGovernor) {
+ isNeuroflux = true;
+ }
+
+ if (!isNeuroflux) {
+ for (var j = 0; j < _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].queuedAugmentations.length; ++j) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].queuedAugmentations[j].name === aug.name) {
+ workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name);
+ return false;
+ }
+ }
+ for (var j = 0; j < _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].augmentations.length; ++j) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].augmentations[j].name === aug.name) {
+ workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you already have " + name);
+ return false;
+ }
+ }
+ }
+
+ if (fac.playerReputation < aug.baseRepRequirement) {
+ workerScript.scriptRef.log("ERROR: purchaseAugmentation() failed because you do not have enough reputation with " + fac.name);
+ return false;
+ }
+
+ var res = Object(_Faction_js__WEBPACK_IMPORTED_MODULE_9__["purchaseAugmentation"])(aug, fac, true);
+ workerScript.scriptRef.log(res);
+ if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_30__["isString"])(res) && res.startsWith("You purchased")) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
+ return true;
+ } else {
+ return false;
+ }
+ },
+ installAugmentations : function(cbScript) {
+ if (workerScript.checkingRam) {
+ if (workerScript.loadedFns.installAugmentations) {
+ return 0;
+ } else {
+ workerScript.loadedFns.installAugmentations = true;
+ var ramCost = _Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].ScriptSingularityFn3RamCost;
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN !== 4) {ramCost *= 8;}
+ return ramCost;
+ }
+ }
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].bitNodeN != 4) {
+ if (!(hasSingularitySF && singularitySFLvl >= 3)) {
+ throw Object(_NetscriptEvaluator_js__WEBPACK_IMPORTED_MODULE_23__["makeRuntimeRejectMsg"])(workerScript, "Cannot run installAugmentations(). It is a Singularity Function and requires SourceFile-4 (level 3) to run.");
+ return false;
+ }
+ }
+
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].queuedAugmentations.length === 0) {
+ workerScript.scriptRef.log("ERROR: installAugmentations() failed because you do not have any Augmentations to be installed");
+ return false;
+ }
+ _Player_js__WEBPACK_IMPORTED_MODULE_14__["Player"].gainIntelligenceExp(_Constants_js__WEBPACK_IMPORTED_MODULE_5__["CONSTANTS"].IntelligenceSingFnBaseExpGain);
+ workerScript.scriptRef.log("Installing Augmentations. This will cause this script to be killed");
+ Object(_Augmentations_js__WEBPACK_IMPORTED_MODULE_1__["installAugmentations"])(cbScript);
+ return true;
+ }
+ }
+}
+
+
+
+
+/***/ }),
+/* 31 */
+/*!*****************************************!*\
+ !*** ./node_modules/jszip/lib/utils.js ***!
+ \*****************************************/
+/***/ (function(module, exports, __webpack_require__) {
+
+"use strict";
+
+
+var support = __webpack_require__(/*! ./support */ 47);
+var base64 = __webpack_require__(/*! ./base64 */ 99);
+var nodejsUtils = __webpack_require__(/*! ./nodejsUtils */ 62);
+var setImmediate = __webpack_require__(/*! core-js/library/fn/set-immediate */ 152);
+var external = __webpack_require__(/*! ./external */ 57);
+
+
+/**
+ * Convert a string that pass as a "binary string": it should represent a byte
+ * array but may have > 255 char codes. Be sure to take only the first byte
+ * and returns the byte array.
+ * @param {String} str the string to transform.
+ * @return {Array|Uint8Array} the string in a binary format.
+ */
+function string2binary(str) {
+ var result = null;
+ if (support.uint8array) {
+ result = new Uint8Array(str.length);
+ } else {
+ result = new Array(str.length);
+ }
+ return stringToArrayLike(str, result);
+}
+
+/**
+ * Create a new blob with the given content and the given type.
+ * @param {String|ArrayBuffer} part the content to put in the blob. DO NOT use
+ * an Uint8Array because the stock browser of android 4 won't accept it (it
+ * will be silently converted to a string, "[object Uint8Array]").
+ *
+ * Use only ONE part to build the blob to avoid a memory leak in IE11 / Edge:
+ * when a large amount of Array is used to create the Blob, the amount of
+ * memory consumed is nearly 100 times the original data amount.
+ *
+ * @param {String} type the mime type of the blob.
+ * @return {Blob} the created blob.
+ */
+exports.newBlob = function(part, type) {
+ exports.checkSupport("blob");
+
+ try {
+ // Blob constructor
+ return new Blob([part], {
+ type: type
+ });
+ }
+ catch (e) {
+
+ try {
+ // deprecated, browser only, old way
+ var Builder = self.BlobBuilder || self.WebKitBlobBuilder || self.MozBlobBuilder || self.MSBlobBuilder;
+ var builder = new Builder();
+ builder.append(part);
+ return builder.getBlob(type);
+ }
+ catch (e) {
+
+ // well, fuck ?!
+ throw new Error("Bug : can't construct the Blob.");
+ }
+ }
+
+
+};
+/**
+ * The identity function.
+ * @param {Object} input the input.
+ * @return {Object} the same input.
+ */
+function identity(input) {
+ return input;
+}
+
+/**
+ * Fill in an array with a string.
+ * @param {String} str the string to use.
+ * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to fill in (will be mutated).
+ * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated array.
+ */
+function stringToArrayLike(str, array) {
+ for (var i = 0; i < str.length; ++i) {
+ array[i] = str.charCodeAt(i) & 0xFF;
+ }
+ return array;
+}
+
+/**
+ * An helper for the function arrayLikeToString.
+ * This contains static informations and functions that
+ * can be optimized by the browser JIT compiler.
+ */
+var arrayToStringHelper = {
+ /**
+ * Transform an array of int into a string, chunk by chunk.
+ * See the performances notes on arrayLikeToString.
+ * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
+ * @param {String} type the type of the array.
+ * @param {Integer} chunk the chunk size.
+ * @return {String} the resulting string.
+ * @throws Error if the chunk is too big for the stack.
+ */
+ stringifyByChunk: function(array, type, chunk) {
+ var result = [], k = 0, len = array.length;
+ // shortcut
+ if (len <= chunk) {
+ return String.fromCharCode.apply(null, array);
+ }
+ while (k < len) {
+ if (type === "array" || type === "nodebuffer") {
+ result.push(String.fromCharCode.apply(null, array.slice(k, Math.min(k + chunk, len))));
+ }
+ else {
+ result.push(String.fromCharCode.apply(null, array.subarray(k, Math.min(k + chunk, len))));
+ }
+ k += chunk;
+ }
+ return result.join("");
+ },
+ /**
+ * Call String.fromCharCode on every item in the array.
+ * This is the naive implementation, which generate A LOT of intermediate string.
+ * This should be used when everything else fail.
+ * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
+ * @return {String} the result.
+ */
+ stringifyByChar: function(array){
+ var resultStr = "";
+ for(var i = 0; i < array.length; i++) {
+ resultStr += String.fromCharCode(array[i]);
+ }
+ return resultStr;
+ },
+ applyCanBeUsed : {
+ /**
+ * true if the browser accepts to use String.fromCharCode on Uint8Array
+ */
+ uint8array : (function () {
+ try {
+ return support.uint8array && String.fromCharCode.apply(null, new Uint8Array(1)).length === 1;
+ } catch (e) {
+ return false;
+ }
+ })(),
+ /**
+ * true if the browser accepts to use String.fromCharCode on nodejs Buffer.
+ */
+ nodebuffer : (function () {
+ try {
+ return support.nodebuffer && String.fromCharCode.apply(null, nodejsUtils.allocBuffer(1)).length === 1;
+ } catch (e) {
+ return false;
+ }
+ })()
+ }
+};
+
+/**
+ * Transform an array-like object to a string.
+ * @param {Array|ArrayBuffer|Uint8Array|Buffer} array the array to transform.
+ * @return {String} the result.
+ */
+function arrayLikeToString(array) {
+ // Performances notes :
+ // --------------------
+ // String.fromCharCode.apply(null, array) is the fastest, see
+ // see http://jsperf.com/converting-a-uint8array-to-a-string/2
+ // but the stack is limited (and we can get huge arrays !).
+ //
+ // result += String.fromCharCode(array[i]); generate too many strings !
+ //
+ // This code is inspired by http://jsperf.com/arraybuffer-to-string-apply-performance/2
+ // TODO : we now have workers that split the work. Do we still need that ?
+ var chunk = 65536,
+ type = exports.getTypeOf(array),
+ canUseApply = true;
+ if (type === "uint8array") {
+ canUseApply = arrayToStringHelper.applyCanBeUsed.uint8array;
+ } else if (type === "nodebuffer") {
+ canUseApply = arrayToStringHelper.applyCanBeUsed.nodebuffer;
+ }
+
+ if (canUseApply) {
+ while (chunk > 1) {
+ try {
+ return arrayToStringHelper.stringifyByChunk(array, type, chunk);
+ } catch (e) {
+ chunk = Math.floor(chunk / 2);
+ }
+ }
+ }
+
+ // no apply or chunk error : slow and painful algorithm
+ // default browser on android 4.*
+ return arrayToStringHelper.stringifyByChar(array);
+}
+
+exports.applyFromCharCode = arrayLikeToString;
+
+
+/**
+ * Copy the data from an array-like to an other array-like.
+ * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayFrom the origin array.
+ * @param {Array|ArrayBuffer|Uint8Array|Buffer} arrayTo the destination array which will be mutated.
+ * @return {Array|ArrayBuffer|Uint8Array|Buffer} the updated destination array.
+ */
+function arrayLikeToArrayLike(arrayFrom, arrayTo) {
+ for (var i = 0; i < arrayFrom.length; i++) {
+ arrayTo[i] = arrayFrom[i];
+ }
+ return arrayTo;
+}
+
+// a matrix containing functions to transform everything into everything.
+var transform = {};
+
+// string to ?
+transform["string"] = {
+ "string": identity,
+ "array": function(input) {
+ return stringToArrayLike(input, new Array(input.length));
+ },
+ "arraybuffer": function(input) {
+ return transform["string"]["uint8array"](input).buffer;
+ },
+ "uint8array": function(input) {
+ return stringToArrayLike(input, new Uint8Array(input.length));
+ },
+ "nodebuffer": function(input) {
+ return stringToArrayLike(input, nodejsUtils.allocBuffer(input.length));
+ }
+};
+
+// array to ?
+transform["array"] = {
+ "string": arrayLikeToString,
+ "array": identity,
+ "arraybuffer": function(input) {
+ return (new Uint8Array(input)).buffer;
+ },
+ "uint8array": function(input) {
+ return new Uint8Array(input);
+ },
+ "nodebuffer": function(input) {
+ return nodejsUtils.newBufferFrom(input);
+ }
+};
+
+// arraybuffer to ?
+transform["arraybuffer"] = {
+ "string": function(input) {
+ return arrayLikeToString(new Uint8Array(input));
+ },
+ "array": function(input) {
+ return arrayLikeToArrayLike(new Uint8Array(input), new Array(input.byteLength));
+ },
+ "arraybuffer": identity,
+ "uint8array": function(input) {
+ return new Uint8Array(input);
+ },
+ "nodebuffer": function(input) {
+ return nodejsUtils.newBufferFrom(new Uint8Array(input));
+ }
+};
+
+// uint8array to ?
+transform["uint8array"] = {
+ "string": arrayLikeToString,
+ "array": function(input) {
+ return arrayLikeToArrayLike(input, new Array(input.length));
+ },
+ "arraybuffer": function(input) {
+ return input.buffer;
+ },
+ "uint8array": identity,
+ "nodebuffer": function(input) {
+ return nodejsUtils.newBufferFrom(input);
+ }
+};
+
+// nodebuffer to ?
+transform["nodebuffer"] = {
+ "string": arrayLikeToString,
+ "array": function(input) {
+ return arrayLikeToArrayLike(input, new Array(input.length));
+ },
+ "arraybuffer": function(input) {
+ return transform["nodebuffer"]["uint8array"](input).buffer;
+ },
+ "uint8array": function(input) {
+ return arrayLikeToArrayLike(input, new Uint8Array(input.length));
+ },
+ "nodebuffer": identity
+};
+
+/**
+ * Transform an input into any type.
+ * The supported output type are : string, array, uint8array, arraybuffer, nodebuffer.
+ * If no output type is specified, the unmodified input will be returned.
+ * @param {String} outputType the output type.
+ * @param {String|Array|ArrayBuffer|Uint8Array|Buffer} input the input to convert.
+ * @throws {Error} an Error if the browser doesn't support the requested output type.
+ */
+exports.transformTo = function(outputType, input) {
+ if (!input) {
+ // undefined, null, etc
+ // an empty string won't harm.
+ input = "";
+ }
+ if (!outputType) {
+ return input;
+ }
+ exports.checkSupport(outputType);
+ var inputType = exports.getTypeOf(input);
+ var result = transform[inputType][outputType](input);
+ return result;
+};
+
+/**
+ * Return the type of the input.
+ * The type will be in a format valid for JSZip.utils.transformTo : string, array, uint8array, arraybuffer.
+ * @param {Object} input the input to identify.
+ * @return {String} the (lowercase) type of the input.
+ */
+exports.getTypeOf = function(input) {
+ if (typeof input === "string") {
+ return "string";
+ }
+ if (Object.prototype.toString.call(input) === "[object Array]") {
+ return "array";
+ }
+ if (support.nodebuffer && nodejsUtils.isBuffer(input)) {
+ return "nodebuffer";
+ }
+ if (support.uint8array && input instanceof Uint8Array) {
+ return "uint8array";
+ }
+ if (support.arraybuffer && input instanceof ArrayBuffer) {
+ return "arraybuffer";
+ }
+};
+
+/**
+ * Throw an exception if the type is not supported.
+ * @param {String} type the type to check.
+ * @throws {Error} an Error if the browser doesn't support the requested type.
+ */
+exports.checkSupport = function(type) {
+ var supported = support[type.toLowerCase()];
+ if (!supported) {
+ throw new Error(type + " is not supported by this platform");
+ }
+};
+
+exports.MAX_VALUE_16BITS = 65535;
+exports.MAX_VALUE_32BITS = -1; // well, "\xFF\xFF\xFF\xFF\xFF\xFF\xFF\xFF" is parsed as -1
+
+/**
+ * Prettify a string read as binary.
+ * @param {string} str the string to prettify.
+ * @return {string} a pretty string.
+ */
+exports.pretty = function(str) {
+ var res = '',
+ code, i;
+ for (i = 0; i < (str || "").length; i++) {
+ code = str.charCodeAt(i);
+ res += '\\x' + (code < 16 ? "0" : "") + code.toString(16).toUpperCase();
+ }
+ return res;
+};
+
+/**
+ * Defer the call of a function.
+ * @param {Function} callback the function to call asynchronously.
+ * @param {Array} args the arguments to give to the callback.
+ */
+exports.delay = function(callback, args, self) {
+ setImmediate(function () {
+ callback.apply(self || null, args || []);
+ });
+};
+
+/**
+ * Extends a prototype with an other, without calling a constructor with
+ * side effects. Inspired by nodejs' `utils.inherits`
+ * @param {Function} ctor the constructor to augment
+ * @param {Function} superCtor the parent constructor to use
+ */
+exports.inherits = function (ctor, superCtor) {
+ var Obj = function() {};
+ Obj.prototype = superCtor.prototype;
+ ctor.prototype = new Obj();
+};
+
+/**
+ * Merge the objects passed as parameters into a new one.
+ * @private
+ * @param {...Object} var_args All objects to merge.
+ * @return {Object} a new object with the data of the others.
+ */
+exports.extend = function() {
+ var result = {}, i, attr;
+ for (i = 0; i < arguments.length; i++) { // arguments is not enumerable in some browsers
+ for (attr in arguments[i]) {
+ if (arguments[i].hasOwnProperty(attr) && typeof result[attr] === "undefined") {
+ result[attr] = arguments[i][attr];
+ }
+ }
+ }
+ return result;
+};
+
+/**
+ * Transform arbitrary content into a Promise.
+ * @param {String} name a name for the content being processed.
+ * @param {Object} inputData the content to process.
+ * @param {Boolean} isBinary true if the content is not an unicode string
+ * @param {Boolean} isOptimizedBinaryString true if the string content only has one byte per character.
+ * @param {Boolean} isBase64 true if the string content is encoded with base64.
+ * @return {Promise} a promise in a format usable by JSZip.
+ */
+exports.prepareContent = function(name, inputData, isBinary, isOptimizedBinaryString, isBase64) {
+
+ // if inputData is already a promise, this flatten it.
+ var promise = external.Promise.resolve(inputData).then(function(data) {
+
+
+ var isBlob = support.blob && (data instanceof Blob || ['[object File]', '[object Blob]'].indexOf(Object.prototype.toString.call(data)) !== -1);
+
+ if (isBlob && typeof FileReader !== "undefined") {
+ return new external.Promise(function (resolve, reject) {
+ var reader = new FileReader();
+
+ reader.onload = function(e) {
+ resolve(e.target.result);
+ };
+ reader.onerror = function(e) {
+ reject(e.target.error);
+ };
+ reader.readAsArrayBuffer(data);
+ });
+ } else {
+ return data;
+ }
+ });
+
+ return promise.then(function(data) {
+ var dataType = exports.getTypeOf(data);
+
+ if (!dataType) {
+ return external.Promise.reject(
+ new Error("Can't read the data of '" + name + "'. Is it " +
+ "in a supported JavaScript type (String, Blob, ArrayBuffer, etc) ?")
+ );
+ }
+ // special case : it's way easier to work with Uint8Array than with ArrayBuffer
+ if (dataType === "arraybuffer") {
+ data = exports.transformTo("uint8array", data);
+ } else if (dataType === "string") {
+ if (isBase64) {
+ data = base64.decode(data);
+ }
+ else if (isBinary) {
+ // optimizedBinaryString === true means that the file has already been filtered with a 0xFF mask
+ if (isOptimizedBinaryString !== true) {
+ // this is a string, not in a base64 format.
+ // Be sure that this is a correct "binary string"
+ data = string2binary(data);
+ }
+ }
+ }
+ return data;
+ });
+};
+
+
+/***/ }),
+/* 32 */
+/*!*************************!*\
+ !*** ./src/Missions.js ***!
+ \*************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "HackingMission", function() { return HackingMission; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "inMission", function() { return inMission; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "setInMission", function() { return setInMission; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "currMission", function() { return currMission; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Faction.js */ 14);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
+/* harmony import */ var jsplumb__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! jsplumb */ 182);
+/* harmony import */ var jsplumb__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(jsplumb__WEBPACK_IMPORTED_MODULE_7__);
+
+
+
+
+
+
+
+
+
+let inMission = false; //Flag to denote whether a mission is running
+let currMission = null;
+function setInMission(bool, mission) {
+ inMission = bool;
+ if (bool) {
+ currMission = mission;
+ } else {
+ currMission = null;
+ }
+}
+
+//Keyboard shortcuts
+$(document).keydown(function(e) {
+ if (inMission && currMission && currMission.selectedNode.length != 0) {
+ switch (e.keyCode) {
+ case 65: //a for Attack
+ currMission.actionButtons[0].click();
+ break;
+ case 83: //s for Scan
+ currMission.actionButtons[1].click();
+ break;
+ case 87: //w for Weaken
+ currMission.actionButtons[2].click();
+ break;
+ case 70: //f for Fortify
+ currMission.actionButtons[3].click();
+ break;
+ case 82: //r for Overflow
+ currMission.actionButtons[4].click();
+ break;
+ case 68: //d for Detach connection
+ currMission.actionButtons[5].click();
+ break;
+ default:
+ break;
+ }
+ }
+});
+
+let NodeTypes = {
+ Core: "CPU Core Node", //All actions available
+ Firewall: "Firewall Node", //No actions available
+ Database: "Database Node", //No actions available
+ Spam: "Spam Node", //No actions Available
+ Transfer: "Transfer Node", //Can Weaken, Scan, Fortify and Overflow
+ Shield: "Shield Node" //Can Fortify
+}
+
+let NodeActions = {
+ Attack: "Attacking", //Damaged based on attack stat + hacking level + opp def
+ Scan: "Scanning", //-Def for target, affected by attack and hacking level
+ Weaken: "Weakening", //-Attack for target, affected by attack and hacking level
+ Fortify: "Fortifying", //+Defense for Node, affected by hacking level
+ Overflow: "Overflowing", //+Attack but -Defense for Node, affected by hacking level
+}
+
+function Node(type, stats) {
+ this.type = type;
+ this.atk = stats.atk ? stats.atk : 0;
+ this.def = stats.def ? stats.def : 0;
+ this.hp = stats.hp ? stats.hp : 0;
+ this.maxhp = this.hp;
+ this.plyrCtrl = false;
+ this.enmyCtrl = false;
+ this.pos = [0, 0]; //x, y
+ this.el = null; //Holds the Node's DOM element
+ this.action = null;
+ this.targetedCount = 0; //Count of how many connections this node is the target of
+
+ //Holds the JsPlumb Connection object for this Node,
+ //where this Node is the Source (since each Node
+ //can only have 1 outgoing Connection)
+ this.conn = null;
+}
+
+Node.prototype.setPosition = function(x, y) {
+ this.pos = [x, y];
+}
+
+Node.prototype.setControlledByPlayer = function() {
+ this.plyrCtrl = true;
+ this.enmyCtrl = false;
+ if (this.el) {
+ this.el.classList.remove("hack-mission-enemy-node");
+ this.el.classList.add("hack-mission-player-node");
+ }
+}
+
+Node.prototype.setControlledByEnemy = function() {
+ this.plyrCtrl = false;
+ this.enmyCtrl = true;
+ if (this.el) {
+ this.el.classList.remove("hack-mission-player-node");
+ this.el.classList.add("hack-mission-enemy-node");
+ }
+}
+
+//Sets this node to be the active node
+Node.prototype.select = function(actionButtons) {
+ if (this.enmyCtrl) {return;}
+ this.el.classList.add("hack-mission-player-node-active");
+
+ //Make all buttons inactive
+ for (var i = 0; i < actionButtons.length; ++i) {
+ actionButtons[i].classList.remove("a-link-button");
+ actionButtons[i].classList.add("a-link-button-inactive");
+ }
+
+ switch(this.type) {
+ case NodeTypes.Core:
+ //All buttons active
+ for (var i = 0; i < actionButtons.length; ++i) {
+ actionButtons[i].classList.remove("a-link-button-inactive");
+ actionButtons[i].classList.add("a-link-button");
+ }
+ break;
+ case NodeTypes.Transfer:
+ actionButtons[1].classList.remove("a-link-button-inactive");
+ actionButtons[1].classList.add("a-link-button");
+ actionButtons[2].classList.remove("a-link-button-inactive");
+ actionButtons[2].classList.add("a-link-button");
+ actionButtons[3].classList.remove("a-link-button-inactive");
+ actionButtons[3].classList.add("a-link-button");
+ actionButtons[4].classList.remove("a-link-button-inactive");
+ actionButtons[4].classList.add("a-link-button");
+ actionButtons[5].classList.remove("a-link-button-inactive");
+ actionButtons[5].classList.add("a-link-button");
+ break;
+ case NodeTypes.Shield:
+ case NodeTypes.Firewall:
+ actionButtons[3].classList.remove("a-link-button-inactive");
+ actionButtons[3].classList.add("a-link-button");
+ break;
+ default:
+ break;
+ }
+}
+
+Node.prototype.deselect = function(actionButtons) {
+ this.el.classList.remove("hack-mission-player-node-active");
+ for (var i = 0; i < actionButtons.length; ++i) {
+ actionButtons[i].classList.remove("a-link-button");
+ actionButtons[i].classList.add("a-link-button-inactive");
+ }
+}
+
+
+Node.prototype.untarget = function() {
+ if (this.targetedCount === 0) {
+ console.log("WARN: Node " + this.el.id + " is being 'untargeted' when it has no target count");
+ return;
+ }
+ --this.targetedCount;
+}
+
+//Hacking mission instance
+//Takes in the reputation of the Faction for which the mission is
+//being conducted
+function HackingMission(rep, fac) {
+ this.faction = fac;
+
+ this.started = false;
+ this.time = 180000; //5 minutes to start, milliseconds
+
+ this.playerCores = [];
+ this.playerNodes = []; //Non-core nodes
+ this.playerAtk = 0;
+ this.playerDef = 0;
+
+ this.enemyCores = [];
+ this.enemyDatabases = [];
+ this.enemyNodes = []; //Non-core nodes
+ this.enemyAtk = 0;
+ this.enemyDef = 0;
+
+ this.miscNodes = [];
+
+ this.selectedNode = []; //Which of the player's nodes are currently selected
+
+ this.actionButtons = []; //DOM buttons for actions
+
+ this.availablePositions = [];
+ for (var r = 0; r < 8; ++r) {
+ for (var c = 0; c < 8; ++c) {
+ this.availablePositions.push([r, c]);
+ }
+ }
+
+ this.map = [];
+ for (var i = 0; i < 8; ++i) {
+ this.map.push([null, null, null, null, null, null, null, null]);
+ }
+
+ this.jsplumbinstance = null;
+
+ this.difficulty = rep / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionRepToDiffConversion + 1;
+ console.log("difficulty: " + this.difficulty);
+ this.reward = 250 + (rep / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionRepToRewardConversion);
+}
+
+HackingMission.prototype.init = function() {
+ //Create Header DOM
+ this.createPageDom();
+
+ //Create player starting nodes
+ var home = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].getHomeComputer()
+ for (var i = 0; i < home.cpuCores; ++i) {
+ var stats = {
+ atk: (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill / 7.5) + 30,
+ def: (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill / 20),
+ hp: (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill / 4),
+ };
+ this.playerCores.push(new Node(NodeTypes.Core, stats));
+ this.playerCores[i].setControlledByPlayer();
+ this.setNodePosition(this.playerCores[i], i, 0);
+ this.removeAvailablePosition(i, 0);
+ }
+
+ //Randomly generate enemy nodes (CPU and Firewall) based on difficulty
+ var numNodes = Math.min(8, Math.max(1, Math.round(this.difficulty / 4)));
+ var numFirewalls = Math.min(20,
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(Math.round(this.difficulty/3), Math.round(this.difficulty/3) + 1));
+ var numDatabases = Math.min(10, Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(1, Math.round(this.difficulty / 3) + 1));
+ var totalNodes = numNodes + numFirewalls + numDatabases;
+ var xlimit = 7 - Math.floor(totalNodes / 8);
+ var randMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["addOffset"])(0.8 + (this.difficulty / 5), 10);
+ for (var i = 0; i < numNodes; ++i) {
+ var stats = {
+ atk: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(80, 86),
+ def: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(5, 10),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(210, 230)
+ }
+ this.enemyCores.push(new Node(NodeTypes.Core, stats));
+ this.enemyCores[i].setControlledByEnemy();
+ this.setNodeRandomPosition(this.enemyCores[i], xlimit);
+ }
+ for (var i = 0; i < numFirewalls; ++i) {
+ var stats = {
+ atk: 0,
+ def: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(10, 20),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(275, 300)
+ }
+ this.enemyNodes.push(new Node(NodeTypes.Firewall, stats));
+ this.enemyNodes[i].setControlledByEnemy();
+ this.setNodeRandomPosition(this.enemyNodes[i], xlimit);
+ }
+ for (var i = 0; i < numDatabases; ++i) {
+ var stats = {
+ atk: 0,
+ def: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(30, 55),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(210, 275)
+ }
+ var node = new Node(NodeTypes.Database, stats);
+ node.setControlledByEnemy();
+ this.setNodeRandomPosition(node, xlimit);
+ this.enemyDatabases.push(node);
+ }
+ this.calculateDefenses();
+ this.calculateAttacks();
+ this.createMap();
+}
+
+HackingMission.prototype.createPageDom = function() {
+ var container = document.getElementById("mission-container");
+
+ var favorMult = 1 + (this.faction.favor / 100);
+ var gain = this.reward * _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult * favorMult;
+ var headerText = document.createElement("p");
+ headerText.innerHTML = "You are about to start a hacking mission! You will gain " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(gain, 3) + " faction reputation with " + this.faction.name +
+ " if you win. For more information " +
+ "about how hacking missions work, click one of the guide links " +
+ "below (one opens up an in-game guide and the other opens up " +
+ "the guide from the wiki). Click the 'Start' button to begin.";
+ headerText.style.display = "block";
+ headerText.classList.add("hack-mission-header-element");
+ headerText.style.width = "80%";
+
+ var inGameGuideBtn = document.createElement("a");
+ inGameGuideBtn.innerText = "How to Play";
+ inGameGuideBtn.classList.add("a-link-button");
+ inGameGuideBtn.style.display = "inline-block";
+ inGameGuideBtn.classList.add("hack-mission-header-element");
+ inGameGuideBtn.addEventListener("click", function() {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])(_Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionHowToPlay);
+ return false;
+ });
+
+ var wikiGuideBtn = document.createElement("a");
+ wikiGuideBtn.innerText = "Wiki Guide";
+ wikiGuideBtn.classList.add("a-link-button");
+ wikiGuideBtn.style.display = "inline-block";
+ wikiGuideBtn.classList.add("hack-mission-header-element");
+ wikiGuideBtn.target = "_blank";
+ //TODO Add link to wiki page wikiGuideBtn.href =
+
+
+ //Start button will get replaced with forfeit when game is started
+ var startBtn = document.createElement("a");
+ startBtn.innerHTML = "Start";
+ startBtn.setAttribute("id", "hack-mission-start-btn");
+ startBtn.classList.add("a-link-button");
+ startBtn.classList.add("hack-mission-header-element");
+ startBtn.style.display = "inline-block";
+ startBtn.addEventListener("click", ()=>{
+ this.start();
+ return false;
+ });
+
+ var forfeitMission = document.createElement("a");
+ forfeitMission.innerHTML = "Forfeit Mission (Exit)";
+ forfeitMission.classList.add("a-link-button");
+ forfeitMission.classList.add("hack-mission-header-element");
+ forfeitMission.style.display = "inline-block";
+ forfeitMission.addEventListener("click", ()=> {
+ this.finishMission(false);
+ return false;
+ });
+
+ var timer = document.createElement("p");
+ timer.setAttribute("id", "hacking-mission-timer");
+ timer.style.display = "inline-block";
+ timer.style.margin = "6px";
+
+ //Create Action Buttons (Attack/Scan/Weaken/ etc...)
+ var actionsContainer = document.createElement("span");
+ actionsContainer.style.display = "block";
+ actionsContainer.classList.add("hack-mission-action-buttons-container");
+ for (var i = 0; i < 6; ++i) {
+ this.actionButtons.push(document.createElement("a"));
+ this.actionButtons[i].style.display = "inline-block";
+ this.actionButtons[i].classList.add("a-link-button-inactive"); //Disabled at start
+ this.actionButtons[i].classList.add("tooltip"); //Disabled at start
+ this.actionButtons[i].classList.add("hack-mission-header-element");
+ actionsContainer.appendChild(this.actionButtons[i]);
+ }
+ this.actionButtons[0].innerText = "Attack(a)";
+ var atkTooltip = document.createElement("span");
+ atkTooltip.classList.add("tooltiptexthigh");
+ atkTooltip.innerText = "Lowers the targeted node's HP. The effectiveness of this depends on " +
+ "this node's Attack level, your hacking level, and the opponent's defense level.";
+ this.actionButtons[0].appendChild(atkTooltip);
+ this.actionButtons[1].innerText = "Scan(s)";
+ var scanTooltip = document.createElement("span");
+ scanTooltip.classList.add("tooltiptexthigh");
+ scanTooltip.innerText = "Lowers the targeted node's defense. The effectiveness of this depends on " +
+ "this node's Attack level, your hacking level, and the opponent's defense level.";
+ this.actionButtons[1].appendChild(scanTooltip);
+ this.actionButtons[2].innerText = "Weaken(w)";
+ var WeakenTooltip = document.createElement("span");
+ WeakenTooltip.classList.add("tooltiptexthigh");
+ WeakenTooltip.innerText = "Lowers the targeted node's attack. The effectiveness of this depends on " +
+ "this node's Attack level, your hacking level, and the opponent's defense level.";
+ this.actionButtons[2].appendChild(WeakenTooltip);
+ this.actionButtons[3].innerText = "Fortify(f)";
+ var fortifyTooltip = document.createElement("span");
+ fortifyTooltip.classList.add("tooltiptexthigh");
+ fortifyTooltip.innerText = "Raises this node's Defense level. The effectiveness of this depends on " +
+ "your hacking level";
+ this.actionButtons[3].appendChild(fortifyTooltip);
+ this.actionButtons[4].innerText = "Overflow(r)";
+ var overflowTooltip = document.createElement("span");
+ overflowTooltip.classList.add("tooltiptexthigh");
+ overflowTooltip.innerText = "Raises this node's Attack level but lowers its Defense level. The effectiveness " +
+ "of this depends on your hacking level.";
+ this.actionButtons[4].appendChild(overflowTooltip);
+ this.actionButtons[5].innerText = "Drop Connection(d)";
+ var dropconnTooltip = document.createElement("span");
+ dropconnTooltip.classList.add("tooltiptexthigh");
+ dropconnTooltip.innerText = "Removes this Node's current connection to some target Node, if it has one. This can " +
+ "also be done by simply clicking the white connection line.";
+ this.actionButtons[5].appendChild(dropconnTooltip);
+
+ //Player/enemy defense displays will be in action container
+ var playerStats = document.createElement("p");
+ var enemyStats = document.createElement("p");
+ playerStats.style.display = "inline-block";
+ enemyStats.style.display = "inline-block";
+ playerStats.style.color = "#00ccff";
+ enemyStats.style.color = "red";
+ playerStats.style.margin = "4px";
+ enemyStats.style.margin = "4px";
+ playerStats.setAttribute("id", "hacking-mission-player-stats");
+ enemyStats.setAttribute("id", "hacking-mission-enemy-stats");
+ actionsContainer.appendChild(playerStats);
+ actionsContainer.appendChild(enemyStats);
+
+ //Set Action Button event listeners
+ this.actionButtons[0].addEventListener("click", ()=>{
+ if (!(this.selectedNode.length > 0)) {
+ console.log("ERR: Pressing Action button without selected node");
+ return;
+ }
+ if (this.selectedNode[0].type !== NodeTypes.Core) {return;}
+ this.setActionButtonsActive(this.selectedNode[0].type);
+ this.setActionButton(NodeActions.Attack, false); //Set attack button inactive
+ this.selectedNode.forEach(function(node){
+ node.action = NodeActions.Attack;
+ });
+ });
+
+ this.actionButtons[1].addEventListener("click", ()=>{
+ if (!(this.selectedNode.length > 0)) {
+ console.log("ERR: Pressing Action button without selected node");
+ return;
+ }
+ var nodeType = this.selectedNode[0].type; //In a multiselect, every Node will have the same type
+ if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}
+ this.setActionButtonsActive(nodeType);
+ this.setActionButton(NodeActions.Scan, false); //Set scan button inactive
+ this.selectedNode.forEach(function(node){
+ node.action = NodeActions.Scan;
+ });
+ });
+
+ this.actionButtons[2].addEventListener("click", ()=>{
+ if (!(this.selectedNode.length > 0)) {
+ console.log("ERR: Pressing Action button without selected node");
+ return;
+ }
+ var nodeType = this.selectedNode[0].type; //In a multiselect, every Node will have the same type
+ if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}
+ this.setActionButtonsActive(nodeType);
+ this.setActionButton(NodeActions.Weaken, false); //Set Weaken button inactive
+ this.selectedNode.forEach(function(node){
+ node.action = NodeActions.Weaken;
+ });
+ });
+
+ this.actionButtons[3].addEventListener("click", ()=>{
+ if (!(this.selectedNode.length > 0)) {
+ console.log("ERR: Pressing Action button without selected node");
+ return;
+ }
+ this.setActionButtonsActive(this.selectedNode[0].type);
+ this.setActionButton(NodeActions.Fortify, false); //Set Fortify button inactive
+ this.selectedNode.forEach(function(node){
+ node.action = NodeActions.Fortify;
+ });
+ });
+
+ this.actionButtons[4].addEventListener("click", ()=>{
+ if (!(this.selectedNode.length > 0)) {
+ console.log("ERR: Pressing Action button without selected node");
+ return;
+ }
+ var nodeType = this.selectedNode[0].type;
+ if (nodeType !== NodeTypes.Core && nodeType !== NodeTypes.Transfer) {return;}
+ this.setActionButtonsActive(nodeType);
+ this.setActionButton(NodeActions.Overflow, false); //Set Overflow button inactive
+ this.selectedNode.forEach(function(node){
+ node.action = NodeActions.Overflow;
+ });
+ });
+
+ this.actionButtons[5].addEventListener("click", ()=>{
+ if (!(this.selectedNode.length > 0)) {
+ console.log("ERR: Pressing Action button without selected node");
+ return;
+ }
+ this.selectedNode.forEach(function(node){
+ if (node.conn) {
+ var endpoints = node.conn.endpoints;
+ endpoints[0].detachFrom(endpoints[1]);
+ }
+ node.action = NodeActions.Fortify;
+ });
+ // if (this.selectedNode.conn) {
+ // var endpoints = this.selectedNode.conn.endpoints;
+ // endpoints[0].detachFrom(endpoints[1]);
+ // }
+ })
+
+ var timeDisplay = document.createElement("p");
+
+ container.appendChild(headerText);
+ container.appendChild(inGameGuideBtn);
+ container.appendChild(wikiGuideBtn);
+ container.appendChild(startBtn);
+ container.appendChild(forfeitMission);
+ container.appendChild(timer);
+ container.appendChild(actionsContainer);
+ container.appendChild(timeDisplay);
+}
+
+HackingMission.prototype.setActionButtonsInactive = function() {
+ for (var i = 0; i < this.actionButtons.length; ++i) {
+ this.actionButtons[i].classList.remove("a-link-button");
+ this.actionButtons[i].classList.add("a-link-button-inactive");
+ }
+}
+
+HackingMission.prototype.setActionButtonsActive = function(nodeType=null) {
+ for (var i = 0; i < this.actionButtons.length; ++i) {
+ this.actionButtons[i].classList.add("a-link-button");
+ this.actionButtons[i].classList.remove("a-link-button-inactive");
+ }
+
+ //For Transfer, FireWall and Shield Nodes, certain buttons should always be disabled
+ //0 = Attack, 1 = Scan, 2 = Weaken, 3 = Fortify, 4 = overflow, 5 = Drop conn
+ if (nodeType) {
+ switch (nodeType) {
+ case NodeTypes.Firewall:
+ case NodeTypes.Shield:
+ this.actionButtons[0].classList.remove("a-link-button");
+ this.actionButtons[0].classList.add("a-link-button-inactive");
+ this.actionButtons[1].classList.remove("a-link-button");
+ this.actionButtons[1].classList.add("a-link-button-inactive");
+ this.actionButtons[2].classList.remove("a-link-button");
+ this.actionButtons[2].classList.add("a-link-button-inactive");
+ this.actionButtons[4].classList.remove("a-link-button");
+ this.actionButtons[4].classList.add("a-link-button-inactive");
+ this.actionButtons[5].classList.remove("a-link-button");
+ this.actionButtons[5].classList.add("a-link-button-inactive");
+ break;
+ case NodeTypes.Transfer:
+ this.actionButtons[0].classList.remove("a-link-button");
+ this.actionButtons[0].classList.add("a-link-button-inactive");
+ break;
+ default:
+ break;
+ }
+ }
+}
+
+//True for active, false for inactive
+HackingMission.prototype.setActionButton = function(i, active=true) {
+ if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["isString"])(i)) {
+ switch (i) {
+ case NodeActions.Attack:
+ i = 0;
+ break;
+ case NodeActions.Scan:
+ i = 1;
+ break;
+ case NodeActions.Weaken:
+ i = 2;
+ break;
+ case NodeActions.Fortify:
+ i = 3;
+ break;
+ case NodeActions.Overflow:
+ default:
+ i = 4;
+ break;
+ }
+ }
+ if (active) {
+ this.actionButtons[i].classList.remove("a-link-button-inactive");
+ this.actionButtons[i].classList.add("a-link-button");
+ } else {
+ this.actionButtons[i].classList.remove("a-link-button");
+ this.actionButtons[i].classList.add("a-link-button-inactive");
+ }
+
+}
+
+HackingMission.prototype.calculateAttacks = function() {
+ var total = 0;
+ for (var i = 0; i < this.playerCores.length; ++i) {
+ total += this.playerCores[i].atk;
+ }
+ for (var i = 0; i < this.playerNodes.length; ++i) {
+ total += this.playerNodes[i].atk;
+ }
+ this.playerAtk = total;
+ document.getElementById("hacking-mission-player-stats").innerHTML =
+ "Player Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerAtk, 1) + " " +
+ "Player Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerDef, 1);
+ total = 0;
+ for (var i = 0; i < this.enemyCores.length; ++i) {
+ total += this.enemyCores[i].atk;
+ }
+ for (var i = 0; i < this.enemyDatabases.length; ++i) {
+ total += this.enemyDatabases[i].atk;
+ }
+ for (var i = 0; i < this.enemyNodes.length; ++i) {
+ total += this.enemyNodes[i].atk;
+ }
+ this.enemyAtk = total;
+ document.getElementById("hacking-mission-enemy-stats").innerHTML =
+ "Enemy Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyAtk, 1) + " " +
+ "Enemy Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyDef, 1);
+}
+
+HackingMission.prototype.calculateDefenses = function() {
+ var total = 0;
+ for (var i = 0; i < this.playerCores.length; ++i) {
+ total += this.playerCores[i].def;
+ }
+ for (var i = 0; i < this.playerNodes.length; ++i) {
+ total += this.playerNodes[i].def;
+ }
+ this.playerDef = total;
+ document.getElementById("hacking-mission-player-stats").innerHTML =
+ "Player Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerAtk, 1) + " " +
+ "Player Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.playerDef, 1);
+ total = 0;
+ for (var i = 0; i < this.enemyCores.length; ++i) {
+ total += this.enemyCores[i].def;
+ }
+ for (var i = 0; i < this.enemyDatabases.length; ++i) {
+ total += this.enemyDatabases[i].def;
+ }
+ for (var i = 0; i < this.enemyNodes.length; ++i) {
+ total += this.enemyNodes[i].def;
+ }
+ this.enemyDef = total;
+ document.getElementById("hacking-mission-enemy-stats").innerHTML =
+ "Enemy Attack: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyAtk, 1) + " " +
+ "Enemy Defense: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(this.enemyDef, 1);
+}
+
+HackingMission.prototype.removeAvailablePosition = function(x, y) {
+ for (var i = 0; i < this.availablePositions.length; ++i) {
+ if (this.availablePositions[i][0] === x &&
+ this.availablePositions[i][1] === y) {
+ this.availablePositions.splice(i, 1);
+ return;
+ }
+ }
+ console.log("WARNING: removeAvailablePosition() did not remove " + x + ", " + y);
+}
+
+HackingMission.prototype.setNodePosition = function(nodeObj, x, y) {
+ if (!(nodeObj instanceof Node)) {
+ console.log("WARNING: Non-Node object passed into setNodePOsition");
+ return;
+ }
+ if (isNaN(x) || isNaN(y)) {
+ console.log("ERR: Invalid values passed as x and y for setNodePosition");
+ console.log(x);
+ console.log(y);
+ return;
+ }
+ nodeObj.pos = [x, y];
+ this.map[x][y] = nodeObj;
+}
+
+HackingMission.prototype.setNodeRandomPosition = function(nodeObj, xlimit=0) {
+ var i = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.availablePositions.length - 1);
+ if (this.availablePositions[i][1] < xlimit) {
+ //Recurse if not within limit
+ return this.setNodeRandomPosition(nodeObj, xlimit);
+ }
+ var pos = this.availablePositions.splice(i, 1);
+ pos = pos[0];
+ this.setNodePosition(nodeObj, pos[0], pos[1]);
+}
+
+HackingMission.prototype.createMap = function() {
+ //Use a grid
+ var map = document.createElement("div");
+ map.classList.add("hack-mission-grid");
+ map.setAttribute("id", "hacking-mission-map");
+ document.getElementById("mission-container").appendChild(map);
+
+ //Create random Nodes for every space in the map that
+ //hasn't been filled yet. The stats of each Node will be based on
+ //the player/enemy attack
+ var averageAttack = (this.playerAtk + this.enemyAtk) / 2;
+ for (var x = 0; x < 8; ++x) {
+ for (var y = 0; y < 8; ++y) {
+ if (!(this.map[x][y] instanceof Node)) {
+ var node, type = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, 2);
+ var randMult = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["addOffset"])(0.85 + (this.difficulty / 2), 15);
+ switch (type) {
+ case 0: //Spam
+ var stats = {
+ atk: 0,
+ def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(15, 45),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(200, 225)
+ }
+ node = new Node(NodeTypes.Spam, stats);
+ break;
+ case 1: //Transfer
+ var stats = {
+ atk: 0,
+ def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(15, 45),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(250, 275)
+ }
+ node = new Node(NodeTypes.Transfer, stats);
+ break;
+ case 2: //Shield
+ default:
+ var stats = {
+ atk: 0,
+ def: averageAttack * 1.1 + Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(30, 70),
+ hp: randMult * Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(300, 320)
+ }
+ node = new Node(NodeTypes.Shield, stats);
+ break;
+ }
+ this.setNodePosition(node, x, y);
+ this.removeAvailablePosition(x, y);
+ this.miscNodes.push(node);
+ }
+ }
+ }
+
+ //Create DOM elements in order
+ for (var r = 0; r < 8; ++r) {
+ for (var c = 0; c < 8; ++c) {
+ this.createNodeDomElement(this.map[r][c]);
+ }
+ }
+
+ //Configure all Player CPUS
+ for (var i = 0; i < this.playerCores.length; ++i) {
+ console.log("Configuring Player Node: " + this.playerCores[i].el.id);
+ this.configurePlayerNodeElement(this.playerCores[i].el);
+ }
+}
+
+HackingMission.prototype.createNodeDomElement = function(nodeObj) {
+ var nodeDiv = document.createElement("a"), txtEl = document.createElement('p');
+ nodeObj.el = nodeDiv;
+
+ //Set the node element's id based on its coordinates
+ var id = "hacking-mission-node-" + nodeObj.pos[0] + "-" + nodeObj.pos[1];
+ nodeDiv.setAttribute("id", id);
+ txtEl.setAttribute("id", id + "-txt");
+
+ //Set node classes for owner
+ nodeDiv.classList.add("hack-mission-node");
+ if (nodeObj.plyrCtrl) {
+ nodeDiv.classList.add("hack-mission-player-node");
+ } else if (nodeObj.enmyCtrl) {
+ nodeDiv.classList.add("hack-mission-enemy-node");
+ }
+
+ //Set node classes based on type
+ var txt;
+ switch (nodeObj.type) {
+ case NodeTypes.Core:
+ txt = "CPU Core " + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-cpu-node");
+ break;
+ case NodeTypes.Firewall:
+ txt = "Firewall " + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-firewall-node");
+ break;
+ case NodeTypes.Database:
+ txt = "Database " + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-database-node");
+ break;
+ case NodeTypes.Spam:
+ txt = "Spam " + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-spam-node");
+ break;
+ case NodeTypes.Transfer:
+ txt = "Transfer " + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-transfer-node");
+ break;
+ case NodeTypes.Shield:
+ default:
+ txt = "Shield " + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ nodeDiv.classList.add("hack-mission-shield-node");
+ break;
+ }
+
+ txt += " Atk: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.atk, 1) +
+ " Def: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.def, 1);
+ txtEl.innerHTML = txt;
+
+ nodeDiv.appendChild(txtEl);
+ document.getElementById("hacking-mission-map").appendChild(nodeDiv);
+}
+
+HackingMission.prototype.updateNodeDomElement = function(nodeObj) {
+ if (nodeObj.el == null) {
+ console.log("ERR: Calling updateNodeDomElement on a Node without an element");
+ return;
+ }
+
+ var id = "hacking-mission-node-" + nodeObj.pos[0] + "-" + nodeObj.pos[1];
+ var nodeDiv = document.getElementById(id), txtEl = document.getElementById(id + "-txt");
+
+ //Set node classes based on type
+ var txt;
+ switch (nodeObj.type) {
+ case NodeTypes.Core:
+ txt = "CPU Core " + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Firewall:
+ txt = "Firewall " + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Database:
+ txt = "Database " + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Spam:
+ txt = "Spam " + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Transfer:
+ txt = "Transfer " + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ case NodeTypes.Shield:
+ default:
+ txt = "Shield " + "HP: " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.hp, 1);
+ break;
+ }
+
+ txt += " Atk: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.atk, 1) +
+ " Def: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(nodeObj.def, 1);
+ if (nodeObj.action) {
+ txt += " " + nodeObj.action;
+ }
+ txtEl.innerHTML = txt;
+}
+
+//Gets a Node DOM element's corresponding Node object using its
+//element id. Function accepts either the DOM element object or the ID as
+//an argument
+HackingMission.prototype.getNodeFromElement = function(el) {
+ var id;
+ if (Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["isString"])(el)) {
+ id = el;
+ } else {
+ id = el.id;
+ }
+ id = id.replace("hacking-mission-node-", "");
+ var res = id.split('-');
+ if (res.length != 2) {
+ console.log("ERROR Parsing Hacking Mission Node Id. Could not find coordinates");
+ return null;
+ }
+ var x = res[0], y = res[1];
+ if (isNaN(x) || isNaN(y) || x >= 8 || y >= 8 || x < 0 || y < 0) {
+ console.log("ERROR: Unexpected values for x and y: " + x + ", " + y);
+ return null;
+ }
+ return this.map[x][y];
+}
+
+function selectNode(hackMissionInst, el) {
+ var nodeObj = hackMissionInst.getNodeFromElement(el);
+ if (nodeObj == null) {console.log("Error getting Node object");}
+ if (!nodeObj.plyrCtrl) {return;}
+
+ clearAllSelectedNodes(hackMissionInst);
+ nodeObj.select(hackMissionInst.actionButtons);
+ hackMissionInst.selectedNode.push(nodeObj);
+}
+
+function multiselectNode(hackMissionInst, el) {
+ var nodeObj = hackMissionInst.getNodeFromElement(el);
+ if (nodeObj == null) {console.log("ERROR: Getting Node Object in multiselectNode()");}
+ if (!nodeObj.plyrCtrl) {return;}
+
+ clearAllSelectedNodes(hackMissionInst);
+ var type = nodeObj.type;
+ if (type === NodeTypes.Core) {
+ hackMissionInst.playerCores.forEach(function(node) {
+ node.select(hackMissionInst.actionButtons);
+ hackMissionInst.selectedNode.push(node);
+ });
+ } else {
+ hackMissionInst.playerNodes.forEach(function(node) {
+ if (node.type === type) {
+ node.select(hackMissionInst.actionButtons);
+ hackMissionInst.selectedNode.push(node);
+ }
+ });
+ }
+}
+
+function clearAllSelectedNodes(hackMissionInst) {
+ if (hackMissionInst.selectedNode.length > 0) {
+ hackMissionInst.selectedNode.forEach(function(node){
+ node.deselect(hackMissionInst.actionButtons);
+ });
+ hackMissionInst.selectedNode.length = 0;
+ }
+}
+
+//Configures a DOM element representing a player-owned node to
+//be selectable and actionable
+//Note: Does NOT change its css class. This is handled by Node.setControlledBy...
+HackingMission.prototype.configurePlayerNodeElement = function(el) {
+ var nodeObj = this.getNodeFromElement(el);
+ if (nodeObj == null) {console.log("Error getting Node object");}
+
+ //Add event listener
+ var self = this;
+ function selectNodeWrapper() {
+ selectNode(self, el);
+ }
+ el.addEventListener("click", selectNodeWrapper);
+
+ function multiselectNodeWrapper() {
+ multiselectNode(self, el);
+ }
+ el.addEventListener("dblclick", multiselectNodeWrapper);
+
+
+ if (el.firstChild) {
+ el.firstChild.addEventListener("click", selectNodeWrapper);
+ }
+}
+
+//Configures a DOM element representing an enemy-node by removing
+//any event listeners
+HackingMission.prototype.configureEnemyNodeElement = function(el) {
+ //Deselect node if it was the selected node
+ var nodeObj = this.getNodeFromElement(el);
+ for (var i = 0; i < this.selectedNode.length; ++i) {
+ if (this.selectedNode[i] == nodeObj) {
+ nodeObj.deselect(this.actionButtons);
+ this.selectedNode.splice(i, 1);
+ break;
+ }
+ }
+}
+
+//Returns bool indicating whether a node is reachable by player
+//by checking if any of the adjacent nodes are owned by the player
+HackingMission.prototype.nodeReachable = function(node) {
+ var x = node.pos[0], y = node.pos[1];
+ if (x > 0 && this.map[x-1][y].plyrCtrl) {return true;}
+ if (x < 7 && this.map[x+1][y].plyrCtrl) {return true;}
+ if (y > 0 && this.map[x][y-1].plyrCtrl) {return true;}
+ if (y < 7 && this.map[x][y+1].plyrCtrl) {return true;}
+ return false;
+}
+
+HackingMission.prototype.nodeReachableByEnemy = function(node) {
+ if (node == null) {return false;}
+ var x = node.pos[0], y = node.pos[1];
+ if (x > 0 && this.map[x-1][y].enmyCtrl) {return true;}
+ if (x < 7 && this.map[x+1][y].enmyCtrl) {return true;}
+ if (y > 0 && this.map[x][y-1].enmyCtrl) {return true;}
+ if (y < 7 && this.map[x][y+1].enmyCtrl) {return true;}
+ return false;
+}
+
+HackingMission.prototype.start = function() {
+ this.started = true;
+ this.initJsPlumb();
+ var startBtn = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["clearEventListeners"])("hack-mission-start-btn");
+ startBtn.classList.remove("a-link-button");
+ startBtn.classList.add("a-link-button-inactive");
+}
+
+HackingMission.prototype.initJsPlumb = function() {
+ var instance = jsPlumb.getInstance({
+ DragOptions:{cursor:"pointer", zIndex:2000},
+ PaintStyle: {
+ gradient: { stops: [
+ [ 0, "#FFFFFF" ],
+ [ 1, "#FFFFFF" ]
+ ] },
+ stroke: "#FFFFFF",
+ strokeWidth: 8
+ },
+ });
+
+ this.jsplumbinstance = instance;
+
+ //All player cores are sources
+ for (var i = 0; i < this.playerCores.length; ++i) {
+ instance.makeSource(this.playerCores[i].el, {
+ deleteEndpointsOnEmpty:true,
+ maxConnections:1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ }
+
+ //Everything else is a target
+ for (var i = 0; i < this.enemyCores.length; ++i) {
+ instance.makeTarget(this.enemyCores[i].el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ }
+ for (var i = 0; i < this.enemyDatabases.length; ++i) {
+ instance.makeTarget(this.enemyDatabases[i].el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:["Flowchart"]
+ });
+ }
+ for (var i = 0; i < this.enemyNodes.length; ++i) {
+ instance.makeTarget(this.enemyNodes[i].el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ }
+ for (var i = 0; i < this.miscNodes.length; ++i) {
+ instance.makeTarget(this.miscNodes[i].el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ }
+
+ //Clicking a connection drops it
+ instance.bind("click", function(conn, originalEvent) {
+ var endpoints = conn.endpoints;
+ endpoints[0].detachFrom(endpoints[1]);
+ });
+
+ //Connection events
+ instance.bind("connection", (info)=>{
+ var targetNode = this.getNodeFromElement(info.target);
+
+ //Do not detach for enemy nodes
+ var thisNode = this.getNodeFromElement(info.source);
+ if (thisNode.enmyCtrl) {return;}
+
+ //If the node is not reachable, drop the connection
+ if (!this.nodeReachable(targetNode)) {
+ info.sourceEndpoint.detachFrom(info.targetEndpoint);
+ return;
+ }
+
+ var sourceNode = this.getNodeFromElement(info.source);
+ sourceNode.conn = info.connection;
+ var targetNode = this.getNodeFromElement(info.target);
+ ++targetNode.targetedCount;
+ });
+
+ //Detach Connection events
+ instance.bind("connectionDetached", (info, originalEvent)=>{
+ var sourceNode = this.getNodeFromElement(info.source);
+ sourceNode.conn = null;
+ var targetNode = this.getNodeFromElement(info.target);
+ targetNode.untarget();
+ });
+
+}
+
+//Drops all connections where the specified node is the source
+HackingMission.prototype.dropAllConnectionsFromNode = function(node) {
+ var allConns = this.jsplumbinstance.getAllConnections();
+ for (var i = allConns.length-1; i >= 0; --i) {
+ if (allConns[i].source == node.el) {
+ allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]);
+ }
+ }
+}
+
+//Drops all connections where the specified node is the target
+HackingMission.prototype.dropAllConnectionsToNode = function(node) {
+ var allConns = this.jsplumbinstance.getAllConnections();
+ for (var i = allConns.length-1; i >= 0; --i) {
+ if (allConns[i].target == node.el) {
+ allConns[i].endpoints[0].detachFrom(allConns[i].endpoints[1]);
+ }
+ }
+ node.beingTargeted = false;
+}
+
+var storedCycles = 0;
+HackingMission.prototype.process = function(numCycles=1) {
+ if (!this.started) {return;}
+ storedCycles += numCycles;
+ if (storedCycles < 2) {return;} //Only process every 3 cycles minimum
+
+ var res = false;
+ //Process actions of all player nodes
+ this.playerCores.forEach((node)=>{
+ res |= this.processNode(node, storedCycles);
+ });
+
+ this.playerNodes.forEach((node)=>{
+ if (node.type === NodeTypes.Transfer ||
+ node.type === NodeTypes.Shield ||
+ node.type === NodeTypes.Firewall) {
+ res |= this.processNode(node, storedCycles);
+ }
+ });
+
+ //Process actions of all enemy nodes
+ this.enemyCores.forEach((node)=>{
+ this.enemyAISelectAction(node);
+ res |= this.processNode(node, storedCycles);
+ });
+
+ this.enemyNodes.forEach((node)=>{
+ if (node.type === NodeTypes.Transfer ||
+ node.type === NodeTypes.Shield ||
+ node.type === NodeTypes.Firewall) {
+ this.enemyAISelectAction(node);
+ res |= this.processNode(node, storedCycles);
+ }
+ });
+
+ //The hp of enemy databases increases slowly
+ this.enemyDatabases.forEach((node)=>{
+ node.maxhp += (0.1 * storedCycles);
+ node.hp += (0.1 * storedCycles);
+ });
+
+ if (res) {
+ this.calculateAttacks();
+ this.calculateDefenses();
+ }
+
+ //Win if all enemy databases are conquered
+ if (this.enemyDatabases.length === 0) {
+ this.finishMission(true);
+ return;
+ }
+
+ //Lose if all your cores are gone
+ if (this.playerCores.length === 0) {
+ this.finishMission(false);
+ return;
+ }
+
+ //Defense/hp of misc nodes increases slowly over time
+ this.miscNodes.forEach((node)=>{
+ node.def += (0.1 * storedCycles);
+ node.maxhp += (0.05 * storedCycles);
+ node.hp += (0.1 * storedCycles);
+ if (node.hp > node.maxhp) {node.hp = node.maxhp;}
+ this.updateNodeDomElement(node);
+ });
+
+ //Update timer and check if player lost
+ this.time -= (storedCycles * _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"]._idleSpeed);
+ if (this.time <= 0) {
+ this.finishMission(false);
+ return;
+ }
+ this.updateTimer();
+
+ storedCycles = 0;
+}
+
+//Returns a bool representing whether defenses need to be re-calculated
+HackingMission.prototype.processNode = function(nodeObj, numCycles=1) {
+ if (nodeObj.action == null) {
+ return;
+ }
+
+ var targetNode = null, def, atk;
+ if (nodeObj.conn) {
+ if (nodeObj.conn.target != null) {
+ targetNode = this.getNodeFromElement(nodeObj.conn.target);
+ } else {
+ targetNode = this.getNodeFromElement(nodeObj.conn.targetId);
+ }
+
+ if (targetNode == null) {
+ //Player is in the middle of dragging the connection,
+ //so the target node is null. Do nothing here
+ } else if (targetNode.plyrCtrl) {
+ def = this.playerDef;
+ atk = this.enemyAtk;
+ } else if (targetNode.enmyCtrl) {
+ def = this.enemyDef;
+ atk = this.playerAtk;
+ } else { //Misc Node
+ def = targetNode.def;
+ nodeObj.plyrCtrl ? atk = this.playerAtk : atk = this.enemyAtk;
+ }
+ }
+
+ //Calculations are per second, so divide everything by 5
+ var calcStats = false, plyr = nodeObj.plyrCtrl;
+ var enmyHacking = this.difficulty * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionDifficultyToHacking;
+ switch(nodeObj.action) {
+ case NodeActions.Attack:
+ if (targetNode == null) {break;}
+ if (nodeObj.conn == null) {break;}
+ var dmg = this.calculateAttackDamage(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
+ targetNode.hp -= (dmg/5 * numCycles);
+ break;
+ case NodeActions.Scan:
+ if (targetNode == null) {break;}
+ if (nodeObj.conn == null) {break;}
+ var eff = this.calculateScanEffect(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
+ targetNode.def -= (eff/5 * numCycles);
+ calcStats = true;
+ break;
+ case NodeActions.Weaken:
+ if (targetNode == null) {break;}
+ if (nodeObj.conn == null) {break;}
+ var eff = this.calculateWeakenEffect(atk, def, plyr ? _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill : enmyHacking);
+ targetNode.atk -= (eff/5 * numCycles);
+ calcStats = true;
+ break;
+ case NodeActions.Fortify:
+ var eff = this.calculateFortifyEffect(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill);
+ nodeObj.def += (eff/5 * numCycles);
+ calcStats = true;
+ break;
+ case NodeActions.Overflow:
+ var eff = this.calculateOverflowEffect(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].hacking_skill);
+ if (nodeObj.def < eff) {break;}
+ nodeObj.def -= (eff/5 * numCycles);
+ nodeObj.atk += (eff/5 * numCycles);
+ calcStats = true;
+ break;
+ default:
+ console.log("ERR: Invalid Node Action: " + nodeObj.action);
+ break;
+ }
+
+ //Stats can't go below 0
+ if (nodeObj.atk < 0) {nodeObj.atk = 0;}
+ if (nodeObj.def < 0) {nodeObj.def = 0;}
+ if (targetNode && targetNode.atk < 0) {targetNode.atk = 0;}
+ if (targetNode && targetNode.def < 0) {targetNode.def = 0;}
+
+ //Conquering a node
+ if (targetNode && targetNode.hp <= 0) {
+ var conqueredByPlayer = nodeObj.plyrCtrl;
+ targetNode.hp = targetNode.maxhp;
+ targetNode.action = null;
+ targetNode.conn = null;
+ if (this.selectedNode == targetNode) {
+ targetNode.deselect(this.actionButtons);
+ }
+
+ //The conquered node has its stats reduced
+ targetNode.atk /= 2;
+ targetNode.def /= 3.5;
+
+ //Flag for whether the target node was a misc node
+ var isMiscNode = !targetNode.plyrCtrl && !targetNode.enmyCtrl;
+
+ //Remove all connections from Node
+ this.dropAllConnectionsToNode(targetNode);
+ this.dropAllConnectionsFromNode(targetNode);
+
+ //Changes the css class and turn the node into a JsPlumb Source/Target
+ if (conqueredByPlayer) {
+ targetNode.setControlledByPlayer();
+ this.jsplumbinstance.unmakeTarget(targetNode.el);
+ this.jsplumbinstance.makeSource(targetNode.el, {
+ deleteEndpointsOnEmpty:true,
+ maxConnections:1,
+ anchor:"Continuous",
+ connector:"Flowchart"
+ });
+ } else {
+ targetNode.setControlledByEnemy();
+ nodeObj.conn = null; //Clear connection
+ this.jsplumbinstance.unmakeSource(targetNode.el);
+ this.jsplumbinstance.makeTarget(targetNode.el, {
+ maxConnections:-1,
+ anchor:"Continuous",
+ connector:["Flowchart"]
+ });
+ }
+
+ calcStats = true;
+
+ //Helper function to swap nodes between the respective enemyNodes/playerNodes arrays
+ function swapNodes(orig, dest, targetNode) {
+ for (var i = 0; i < orig.length; ++i) {
+ if (orig[i] == targetNode) {
+ var node = orig.splice(i, 1);
+ node = node[0];
+ dest.push(node);
+ break;
+ }
+ }
+ }
+
+ switch(targetNode.type) {
+ case NodeTypes.Core:
+ if (conqueredByPlayer) {
+ swapNodes(this.enemyCores, this.playerCores, targetNode);
+ this.configurePlayerNodeElement(targetNode.el);
+ } else {
+ swapNodes(this.playerCores, this.enemyCores, targetNode);
+ this.configureEnemyNodeElement(targetNode.el);
+ }
+ break;
+ case NodeTypes.Firewall:
+ if (conqueredByPlayer) {
+ swapNodes(this.enemyNodes, this.playerNodes, targetNode);
+ } else {
+ swapNodes(this.playerNodes, this.enemyNodes, targetNode);
+ this.configureEnemyNodeElement(targetNode.el);
+ }
+ break;
+ case NodeTypes.Database:
+ if (conqueredByPlayer) {
+ swapNodes(this.enemyDatabases, this.playerNodes, targetNode);
+ } else {
+ swapNodes(this.playerNodes, this.enemyDatabases, targetNode);
+ }
+ break;
+ case NodeTypes.Spam:
+ if (conqueredByPlayer) {
+ swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
+ //Conquering spam node increases time limit
+ this.time += _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionSpamTimeIncrease;
+ } else {
+ swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
+ }
+
+ break;
+ case NodeTypes.Transfer:
+ //Conquering a Transfer node increases the attack of all cores by some percentages
+ if (conqueredByPlayer) {
+ swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
+ this.playerCores.forEach(function(node) {
+ node.atk *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionTransferAttackIncrease;
+ });
+ this.configurePlayerNodeElement(targetNode.el);
+ } else {
+ swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
+ this.enemyCores.forEach(function(node) {
+ node.atk *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionTransferAttackIncrease;
+ });
+ this.configureEnemyNodeElement(targetNode.el);
+ }
+ break;
+ case NodeTypes.Shield:
+ if (conqueredByPlayer) {
+ swapNodes(isMiscNode ? this.miscNodes : this.enemyNodes, this.playerNodes, targetNode);
+ this.configurePlayerNodeElement(targetNode.el);
+ } else {
+ swapNodes(isMiscNode ? this.miscNodes : this.playerNodes, this.enemyNodes, targetNode);
+ this.configureEnemyNodeElement(targetNode.el);
+ }
+ break;
+ }
+
+ //If a misc node was conquered, the defense for all misc nodes increases by some fixed amount
+ if (isMiscNode) { //&& conqueredByPlayer) {
+ this.miscNodes.forEach((node)=>{
+ if (node.targetedCount === 0) {
+ node.def *= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].HackingMissionMiscDefenseIncrease;
+ }
+ });
+ }
+ }
+
+ //Update node DOMs
+ this.updateNodeDomElement(nodeObj);
+ if (targetNode) {this.updateNodeDomElement(targetNode);}
+ return calcStats;
+}
+
+//Enemy "AI" for CPU Core and Transfer Nodes
+HackingMission.prototype.enemyAISelectAction = function(nodeObj) {
+ if (nodeObj == null) {return;}
+ switch(nodeObj.type) {
+ case NodeTypes.Core:
+ //Select a single RANDOM target from miscNodes and player's Nodes
+ //If it is reachable, it will target it. If not, no target will
+ //be selected for now, and the next time process() gets called this will repeat
+ if (nodeObj.conn == null) {
+ if (this.miscNodes.length === 0) {
+ //Randomly pick a player node and attack it if its reachable
+ var rand = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.playerNodes.length-1);
+ var node;
+ if (this.playerNodes.length === 0) {
+ node = null;
+ } else {
+ node = this.playerNodes[rand];
+ }
+ if (this.nodeReachableByEnemy(node)) {
+ //Create connection
+ nodeObj.conn = this.jsplumbinstance.connect({
+ source:nodeObj.el,
+ target:node.el
+ });
+ ++node.targetedCount;
+ } else {
+ //Randomly pick a player core and attack it if its reachable
+ rand = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.playerCores.length-1);
+ if (this.playerCores.length === 0) {
+ return; //No Misc Nodes, no player Nodes, no Player cores. Player lost
+ } else {
+ node = this.playerCores[rand];
+ }
+
+ if (this.nodeReachableByEnemy(node)) {
+ //Create connection
+ nodeObj.conn = this.jsplumbinstance.connect({
+ source:nodeObj.el,
+ target:node.el
+ });
+ ++node.targetedCount;
+ }
+ }
+ } else {
+ //Randomly pick a misc node and attack it if its reachable
+ var rand = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["getRandomInt"])(0, this.miscNodes.length-1);
+ var node = this.miscNodes[rand];
+ if (this.nodeReachableByEnemy(node)) {
+ nodeObj.conn = this.jsplumbinstance.connect({
+ source:nodeObj.el,
+ target:node.el,
+ });
+ ++node.targetedCount;
+ }
+ }
+
+ //If no connection was made, set the Core to Fortify
+ nodeObj.action = NodeActions.Fortify;
+ } else {
+ //If this node has a selected target
+ var targetNode;
+ if (nodeObj.conn.target) {
+ targetNode = this.getNodeFromElement(nodeObj.conn.target);
+ } else {
+ targetNode = this.getNodeFromElement(nodeObj.conn.targetId);
+ }
+ if (targetNode == null) {
+ console.log("Error getting Target node Object in enemyAISelectAction()");
+ }
+
+ if (targetNode.def > this.enemyAtk + 15) {
+ if (nodeObj.def < 50) {
+ nodeObj.action = NodeActions.Fortify;
+ } else {
+ nodeObj.action = NodeActions.Overflow;
+ }
+ } else if (Math.abs(targetNode.def - this.enemyAtk) <= 15) {
+ nodeObj.action = NodeActions.Scan;
+ } else {
+ nodeObj.action = NodeActions.Attack;
+ }
+ }
+ break;
+ case NodeTypes.Transfer:
+ //Switch between fortifying and overflowing as necessary
+ if (nodeObj.def < 125) {
+ nodeObj.action = NodeActions.Fortify;
+ } else {
+ nodeObj.action = NodeActions.Overflow;
+ }
+ break;
+ case NodeTypes.Firewall:
+ case NodeTypes.Shield:
+ nodeObj.action = NodeActions.Fortify;
+ break;
+ default:
+ break;
+ }
+}
+
+var hackEffWeightSelf = 130; //Weight for Node actions on self
+var hackEffWeightTarget = 25; //Weight for Node Actions against Target
+var hackEffWeightAttack = 80; //Weight for Attack action
+
+//Returns damage per cycle based on stats
+HackingMission.prototype.calculateAttackDamage = function(atk, def, hacking = 0) {
+ return Math.max(0.55 * (atk + (hacking / hackEffWeightAttack) - def), 1);
+}
+
+HackingMission.prototype.calculateScanEffect = function(atk, def, hacking=0) {
+ return Math.max(0.6 * ((atk) + hacking / hackEffWeightTarget - (def * 0.95)), 2);
+}
+
+HackingMission.prototype.calculateWeakenEffect = function(atk, def, hacking=0) {
+ return Math.max((atk) + hacking / hackEffWeightTarget - (def * 0.95), 2);
+}
+
+HackingMission.prototype.calculateFortifyEffect = function(hacking=0) {
+ return 0.9 * hacking / hackEffWeightSelf;
+}
+
+HackingMission.prototype.calculateOverflowEffect = function(hacking=0) {
+ return 0.95 * hacking / hackEffWeightSelf;
+}
+
+//Updates timer display
+HackingMission.prototype.updateTimer = function() {
+ var timer = document.getElementById("hacking-mission-timer");
+
+ //Convert time remaining to a string of the form mm:ss
+ var seconds = Math.round(this.time / 1000);
+ var minutes = Math.trunc(seconds / 60);
+ seconds %= 60;
+ var str = ("0" + minutes).slice(-2) + ":" + ("0" + seconds).slice(-2);
+ timer.innerText = "Time left: " + str;
+}
+
+//The 'win' argument is a bool for whether or not the player won
+HackingMission.prototype.finishMission = function(win) {
+ inMission = false;
+ currMission = null;
+
+ if (win) {
+ var favorMult = 1 + (this.faction.favor / 100);
+ console.log("Hacking mission base reward: " + this.reward);
+ console.log("favorMult: " + favorMult);
+ console.log("rep mult: " + _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult);
+ var gain = this.reward * _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult * favorMult;
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Mission won! You earned " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["formatNumber"])(gain, 3) + " reputation with " + this.faction.name);
+ _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gainIntelligenceExp(this.difficulty * _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].IntelligenceHackingMissionBaseExpGain);
+ this.faction.playerReputation += gain;
+ } else {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("Mission lost/forfeited! You did not gain any faction reputation.");
+ }
+
+ //Clear mission container
+ var container = document.getElementById("mission-container");
+ while(container.firstChild) {
+ container.removeChild(container.firstChild);
+ }
+
+ //Return to Faction page
+ document.getElementById("mainmenu-container").style.visibility = "visible";
+ document.getElementById("character-overview-wrapper").style.visibility = "visible";
+ _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadFactionContent();
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_2__["displayFactionContent"])(this.faction.name);
+}
+
+
+
+/* WEBPACK VAR INJECTION */}.call(this, __webpack_require__(/*! jquery */ 41)))
+
+/***/ }),
+/* 33 */
+/*!************************!*\
+ !*** ./src/DarkWeb.js ***!
+ \************************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "checkIfConnectedToDarkweb", function() { return checkIfConnectedToDarkweb; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "executeDarkwebTerminalCommand", function() { return executeDarkwebTerminalCommand; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "listAllDarkwebItems", function() { return listAllDarkwebItems; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "buyDarkwebItem", function() { return buyDarkwebItem; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseDarkwebItemPrice", function() { return parseDarkwebItemPrice; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "DarkWebItems", function() { return DarkWebItems; });
+/* harmony import */ var _CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./CreateProgram.js */ 13);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./SpecialServerIps.js */ 17);
+/* harmony import */ var _Terminal_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Terminal.js */ 22);
+/* harmony import */ var _utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/IPAddress.js */ 15);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
+
+
+
+
+
+
+
+
+
+/* DarkWeb.js */
+//Posts a "help" message if connected to DarkWeb
+function checkIfConnectedToDarkweb() {
+ if (_SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_2__["SpecialServerIps"].hasOwnProperty("Darkweb Server")) {
+ var darkwebIp = _SpecialServerIps_js__WEBPACK_IMPORTED_MODULE_2__["SpecialServerIps"]["Darkweb Server"];
+ if (!Object(_utils_IPAddress_js__WEBPACK_IMPORTED_MODULE_4__["isValidIPAddress"])(darkwebIp)) {return;}
+ if (darkwebIp == _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getCurrentServer().ip) {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("You are now connected to the dark web. From the dark web you can purchase illegal items. " +
+ "Use the 'buy -l' command to display a list of all the items you can buy. Use 'buy [item-name] " +
+ "to purchase an item");
+ }
+ }
+
+}
+
+//Handler for dark web commands. The terminal's executeCommand() function will pass
+//dark web-specific commands into this. It will pass in the raw split command array
+//rather than the command string
+function executeDarkwebTerminalCommand(commandArray) {
+ if (commandArray.length == 0) {return;}
+ switch (commandArray[0]) {
+ case "buy":
+ if (commandArray.length != 2) {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Incorrect number of arguments. Usage: ");
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("buy -l");
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("buy [item name]");
+ return;
+ }
+ var arg = commandArray[1];
+ if (arg == "-l") {
+ listAllDarkwebItems();
+ } else {
+ buyDarkwebItem(arg);
+ }
+ break;
+ default:
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Command not found");
+ break;
+ }
+}
+
+function listAllDarkwebItems() {
+ for (var item in DarkWebItems) {
+ if (DarkWebItems.hasOwnProperty(item)) {
+ var item = DarkWebItems[item];
+ //Convert string using toLocaleString
+ var split = item.split(" - ");
+ if (split.length == 3 && split[1].charAt(0) == '$') {
+ split[1] = split[1].slice(1);
+ split[1] = split[1].replace(/,/g, '');
+ var price = parseFloat(split[1]);
+ if (isNaN(price)) {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])(item);
+ return;
+ }
+ price = Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_5__["formatNumber"])(price, 0);
+ split[1] = "$" + price.toString();
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])(split.join(" - "));
+ } else {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])(item);
+ }
+ }
+ }
+
+ var priceString = split[1];
+ //Check for errors
+ if (priceString.length == 0 || priceString.charAt(0) != '$') {
+ return -1;
+ }
+ //Remove dollar sign and commas
+ priceString = priceString.slice(1);
+ priceString = priceString.replace(/,/g, '');
+
+ //Convert string to numeric
+ var price = parseFloat(priceString);
+ if (isNaN(price)) {return -1;}
+ else {return price;}
+}
+
+function buyDarkwebItem(itemName) {
+ if (itemName.toLowerCase() == _CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].BruteSSHProgram.toLowerCase()) {
+ var price = parseDarkwebItemPrice(DarkWebItems.BruteSSHProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].BruteSSHProgram);
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("You have purchased the BruteSSH.exe program. The new program " +
+ "can be found on your home computer.");
+ } else {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Not enough money to purchase " + itemName);
+ }
+ } else if (itemName.toLowerCase() == _CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].FTPCrackProgram.toLowerCase()) {
+ var price = parseDarkwebItemPrice(DarkWebItems.FTPCrackProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].FTPCrackProgram);
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("You have purchased the FTPCrack.exe program. The new program " +
+ "can be found on your home computer.");
+ } else {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Not enough money to purchase " + itemName);
+ }
+ } else if (itemName.toLowerCase() == _CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].RelaySMTPProgram.toLowerCase()) {
+ var price = parseDarkwebItemPrice(DarkWebItems.RelaySMTPProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].RelaySMTPProgram);
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("You have purchased the relaySMTP.exe program. The new program " +
+ "can be found on your home computer.");
+ } else {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Not enough money to purchase " + itemName);
+ }
+ } else if (itemName.toLowerCase() == _CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].HTTPWormProgram.toLowerCase()) {
+ var price = parseDarkwebItemPrice(DarkWebItems.HTTPWormProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].HTTPWormProgram);
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("You have purchased the HTTPWorm.exe program. The new program " +
+ "can be found on your home computer.");
+ } else {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Not enough money to purchase " + itemName);
+ }
+ } else if (itemName.toLowerCase() == _CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].SQLInjectProgram.toLowerCase()) {
+ var price = parseDarkwebItemPrice(DarkWebItems.SQLInjectProgram);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].SQLInjectProgram);
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("You have purchased the SQLInject.exe program. The new program " +
+ "can be found on your home computer.");
+ } else {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Not enough money to purchase " + itemName);
+ }
+ } else if (itemName.toLowerCase() == _CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].DeepscanV1.toLowerCase()) {
+ var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV1Program);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].DeepscanV1);
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("You have purchased the DeepscanV1.exe program. The new program " +
+ "can be found on your home computer.");
+ } else {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Not enough money to purchase " + itemName);
+ }
+ } else if (itemName.toLowerCase() == _CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].DeepscanV2.toLowerCase()) {
+ var price = parseDarkwebItemPrice(DarkWebItems.DeepScanV2Program);
+ if (price > 0 && _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].money.gt(price)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].loseMoney(price);
+ _Player_js__WEBPACK_IMPORTED_MODULE_1__["Player"].getHomeComputer().programs.push(_CreateProgram_js__WEBPACK_IMPORTED_MODULE_0__["Programs"].DeepscanV2);
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("You have purchased the DeepscanV2.exe program. The new program " +
+ "can be found on your home computer.");
+ } else {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Not enough money to purchase " + itemName);
+ }
+ } else {
+ Object(_Terminal_js__WEBPACK_IMPORTED_MODULE_3__["post"])("Unrecognized item");
+ }
+}
+
+function parseDarkwebItemPrice(itemDesc) {
+ var split = itemDesc.split(" - ");
+ if (split.length == 3) {
+ var priceString = split[1];
+ //Check for errors
+ if (priceString.length == 0 || priceString.charAt(0) != '$') {
+ return -1;
+ }
+ //Remove dollar sign and commas
+ priceString = priceString.slice(1);
+ priceString = priceString.replace(/,/g, '');
+
+ //Convert string to numeric
+ var price = parseFloat(priceString);
+ if (isNaN(price)) {return -1;}
+ else {return price;}
+ } else {
+ return -1;
+ }
+}
+
+let DarkWebItems = {
+ BruteSSHProgram: "BruteSSH.exe - $500,000 - Opens up SSH Ports",
+ FTPCrackProgram: "FTPCrack.exe - $1,500,000 - Opens up FTP Ports",
+ RelaySMTPProgram: "relaySMTP.exe - $5,000,000 - Opens up SMTP Ports",
+ HTTPWormProgram: "HTTPWorm.exe - $30,000,000 - Opens up HTTP Ports",
+ SQLInjectProgram: "SQLInject.exe - $250,000,000 - Opens up SQL Ports",
+ DeepScanV1Program: "DeepscanV1.exe - $500,000 - Enables 'scan-analyze' with a depth up to 5",
+ DeepScanV2Program: "DeepscanV2.exe - $25,000,000 - Enables 'scan-analyze' with a depth up to 10",
+}
+
+
+
+
+/***/ }),
+/* 34 */
+/*!**********************!*\
+ !*** ./src/Fconf.js ***!
+ \**********************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "FconfSettings", function() { return FconfSettings; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "createFconf", function() { return createFconf; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "parseFconfSettings", function() { return parseFconfSettings; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadFconf", function() { return loadFconf; });
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ../utils/acorn.js */ 36);
+/* harmony import */ var _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0___default = /*#__PURE__*/__webpack_require__.n(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__);
+
+
+var FconfSettings = {
+ ENABLE_BASH_HOTKEYS: false
+}
+
+var FconfComments = {
+ ENABLE_BASH_HOTKEYS: "Improved Bash emulation mode. Setting this to 1 enables several\n" +
+ "new Terminal shortcuts and features that more closely resemble\n" +
+ "a real Bash-style shell. Note that when this mode is enabled,\n" +
+ "the default browser shortcuts are overriden by the new Bash\n" +
+ "shortcuts.\n\n" +
+ "To see a full list of the Terminal shortcuts that this enables, see:\n" +
+ "http://bitburner.readthedocs.io/en/latest/shortcuts.html",
+}
+
+//Parse Fconf settings from the config text
+//Throws an exception if parsing fails
+function parseFconfSettings(config) {
+ var ast = Object(_utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["parse"])(config, {sourceType:"module"});
+ var queue = [];
+ queue.push(ast);
+ while (queue.length != 0) {
+ var exp = queue.shift();
+ switch (exp.type) {
+ case "BlockStatement":
+ case "Program":
+ for (var i = 0; i < exp.body.length; ++i) {
+ if (exp.body[i] instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["Node"]) {
+ queue.push(exp.body[i]);
+ }
+ }
+ break;
+ case "AssignmentExpression":
+ var setting, value;
+ if (exp.left != null && exp.left.name != null) {
+ setting = exp.left.name;
+ } else {
+ break;
+ }
+ if (exp.right != null && exp.right.raw != null) {
+ value = exp.right.raw;
+ } else {
+ break;
+ }
+ parseFconfSetting(setting, value);
+ break;
+ default:
+ break;
+ }
+
+ for (var prop in exp) {
+ if (exp.hasOwnProperty(prop)) {
+ if (exp[prop] instanceof _utils_acorn_js__WEBPACK_IMPORTED_MODULE_0__["Node"]) {
+ queue.push(exp[prop]);
+ }
+ }
+ }
+ }
+}
+
+function parseFconfSetting(setting, value) {
+ setting = String(setting);
+ value = String(value);
+ if (setting == null || value == null || FconfSettings[setting] == null) {
+ console.log("WARNING: Invalid .fconf setting: " + setting);
+ return;
+ }
+
+ //Needed to convert entered value to boolean/strings accordingly
+ switch(setting) {
+ case "ENABLE_BASH_HOTKEYS":
+ var value = value.toLowerCase();
+ if (value === "1" || value === "true" || value === "y") {
+ value = true;
+ } else {
+ value = false;
+ }
+ FconfSettings[setting] = value;
+ break;
+ default:
+ break;
+ }
+ return;
+}
+
+//Create the .fconf file text from the settings
+function createFconf() {
+ var res = "";
+ for (var setting in FconfSettings) {
+ if (FconfSettings.hasOwnProperty(setting)) {
+ //Setting comments (description)
+ var comment = FconfComments[setting];
+ if (comment == null) {continue;}
+ var comment = comment.split("\n");
+ for (var i = 0; i < comment.length; ++i) {
+ res += ("//" + comment[i] + "\n");
+ }
+
+ var value = 0;
+ if (FconfSettings[setting] === true) {
+ value = "1";
+ } else if (FconfSettings[setting] === false) {
+ value = "0";
+ } else {
+ value = String(FconfSettings[setting]);
+ }
+ res += (setting + "=" + value + "\n");
+ }
+ }
+ return res;
+}
+
+function loadFconf(saveString) {
+ FconfSettings = JSON.parse(saveString);
+}
+
+
+
+
+/***/ }),
+/* 35 */
+/*!*********************!*\
+ !*** ./src/Gang.js ***!
+ \*********************/
+/***/ (function(module, __webpack_exports__, __webpack_require__) {
+
+"use strict";
+__webpack_require__.r(__webpack_exports__);
+/* WEBPACK VAR INJECTION */(function($) {/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "Gang", function() { return Gang; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "displayGangContent", function() { return displayGangContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "updateGangContent", function() { return updateGangContent; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "loadAllGangs", function() { return loadAllGangs; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "AllGangs", function() { return AllGangs; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "resetGangs", function() { return resetGangs; });
+/* harmony export (binding) */ __webpack_require__.d(__webpack_exports__, "deleteGangDisplayContent", function() { return deleteGangDisplayContent; });
+/* harmony import */ var _Constants_js__WEBPACK_IMPORTED_MODULE_0__ = __webpack_require__(/*! ./Constants.js */ 3);
+/* harmony import */ var _engine_js__WEBPACK_IMPORTED_MODULE_1__ = __webpack_require__(/*! ./engine.js */ 5);
+/* harmony import */ var _Faction_js__WEBPACK_IMPORTED_MODULE_2__ = __webpack_require__(/*! ./Faction.js */ 14);
+/* harmony import */ var _Player_js__WEBPACK_IMPORTED_MODULE_3__ = __webpack_require__(/*! ./Player.js */ 0);
+/* harmony import */ var _utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__ = __webpack_require__(/*! ../utils/DialogBox.js */ 6);
+/* harmony import */ var _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__ = __webpack_require__(/*! ../utils/JSONReviver.js */ 8);
+/* harmony import */ var _utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__ = __webpack_require__(/*! ../utils/HelperFunctions.js */ 1);
+/* harmony import */ var _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7__ = __webpack_require__(/*! ../utils/numeral.min.js */ 12);
+/* harmony import */ var _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7___default = /*#__PURE__*/__webpack_require__.n(_utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7__);
+/* harmony import */ var _utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__ = __webpack_require__(/*! ../utils/StringHelperFunctions.js */ 2);
+/* harmony import */ var _utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__ = __webpack_require__(/*! ../utils/YesNoBox.js */ 11);
+
+
+
+
+
+
+
+
+
+
+
+/* Gang.js */
+//Switch between territory and management screen with 1 and 2
+$(document).keydown(function(event) {
+ if (_engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].currentPage == _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].Page.Gang && !_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoBoxOpen"]) {
+ if (gangMemberFilter != null && gangMemberFilter === document.activeElement) {return;}
+ if (event.keyCode === 49) {
+ if(gangTerritorySubpage.style.display === "block") {
+ managementButton.click();
+ }
+ } else if (event.keyCode === 50) {
+ if (gangManagementSubpage.style.display === "block") {
+ territoryButton.click();
+ }
+ }
+ }
+});
+
+//Delete upgrade box when clicking outside
+$(document).mousedown(function(event) {
+ var boxId = "gang-member-upgrade-popup-box";
+ var contentId = "gang-member-upgrade-popup-box-content";
+ if (gangMemberUpgradeBoxOpened) {
+ if ( $(event.target).closest("#" + contentId).get(0) == null ) {
+ //Delete the box
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["removeElement"])(gangMemberUpgradeBox);
+ gangMemberUpgradeBox = null;
+ gangMemberUpgradeBoxContent = null;
+ gangMemberUpgradeBoxOpened = false;
+ gangMemberUpgradeBoxElements = null;
+ }
+ }
+});
+
+let GangNames = ["Slum Snakes", "Tetrads", "The Syndicate", "The Dark Army", "Speakers for the Dead",
+ "NiteSec", "The Black Hand"];
+let AllGangs = {
+ "Slum Snakes" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "Tetrads" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "The Syndicate" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "The Dark Army" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "Speakers for the Dead" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "NiteSec" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "The Black Hand" : {
+ power: 1,
+ territory: 1/7,
+ },
+}
+
+function resetGangs() {
+ AllGangs = {
+ "Slum Snakes" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "Tetrads" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "The Syndicate" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "The Dark Army" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "Speakers for the Dead" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "NiteSec" : {
+ power: 1,
+ territory: 1/7,
+ },
+ "The Black Hand" : {
+ power: 1,
+ territory: 1/7,
+ },
+ }
+}
+
+function loadAllGangs(saveString) {
+ AllGangs = JSON.parse(saveString, _utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"]);
+}
+
+//Power is an estimate of a gang's ability to gain/defend territory
+let gangStoredPowerCycles = 0;
+function processAllGangPowerGains(numCycles=1) {
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].inGang()) {return;}
+ gangStoredPowerCycles += numCycles;
+ if (gangStoredPowerCycles < 150) {return;}
+ var playerGangName = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName;
+ for (var name in AllGangs) {
+ if (AllGangs.hasOwnProperty(name)) {
+ if (name == playerGangName) {
+ AllGangs[name].power += _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.calculatePower();
+ } else {
+ var gain = Math.random() * 0.02; //TODO Adjust as necessary
+ AllGangs[name].power += (gain);
+ }
+ }
+ }
+
+ gangStoredPowerCycles -= 150;
+}
+
+let gangStoredTerritoryCycles = 0;
+function processAllGangTerritory(numCycles=1) {
+ if (!_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].inGang()) {return;}
+ gangStoredTerritoryCycles += numCycles;
+ if (gangStoredTerritoryCycles < _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].GangTerritoryUpdateTimer) {return;}
+
+ for (var i = 0; i < GangNames.length; ++i) {
+ var other = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(0, GangNames.length-1);
+ while(other == i) {
+ other = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["getRandomInt"])(0, GangNames.length-1);
+ }
+ var thisPwr = AllGangs[GangNames[i]].power;
+ var otherPwr = AllGangs[GangNames[other]].power;
+ var thisChance = thisPwr / (thisPwr + otherPwr);
+
+ if (Math.random() < thisChance) {
+ if (AllGangs[GangNames[other]].territory <= 0) {
+ return;
+ }
+ AllGangs[GangNames[i]].territory += 0.0001;
+ AllGangs[GangNames[other]].territory -= 0.0001;
+ } else {
+ if (AllGangs[GangNames[i]].territory <= 0) {
+ return;
+ }
+ AllGangs[GangNames[i]].territory -= 0.0001;
+ AllGangs[GangNames[other]].territory += 0.0001;
+ }
+ }
+
+ gangStoredTerritoryCycles -= _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].GangTerritoryUpdateTimer;
+}
+
+/* faction - Name of corresponding faction
+ hacking - Boolean indicating whether its a hacking gang or not
+ */
+function Gang(facName, hacking=false) {
+ this.facName = facName;
+ this.members = []; //Array of GangMembers
+ this.wanted = 1;
+ this.respect = 1;
+ this.power = 0;
+
+ this.isHackingGang = hacking;
+
+ this.respectGainRate = 0;
+ this.wantedGainRate = 0;
+ this.moneyGainRate = 0;
+
+ //When processing gains, this stores the number of cycles until some
+ //limit is reached, and then calculates and applies the gains only at that limit
+ this.storedCycles = 0;
+}
+
+Gang.prototype.process = function(numCycles=1) {
+ this.processGains(numCycles);
+ this.processExperienceGains(numCycles);
+ processAllGangPowerGains(numCycles);
+ processAllGangTerritory(numCycles);
+}
+
+Gang.prototype.processGains = function(numCycles=1) {
+ this.storedCycles += numCycles;
+ if (isNaN(this.storedCycles)) {
+ console.log("ERROR: Gang's storedCylces is NaN");
+ this.storedCycles = 0;
+ }
+ if (this.storedCycles < 25) {return;} //Only process every 5 seconds at least
+
+ //Get gains per cycle
+ var moneyGains = 0, respectGains = 0, wantedLevelGains = 0;
+ for (var i = 0; i < this.members.length; ++i) {
+ respectGains += (this.members[i].calculateRespectGain());
+ wantedLevelGains += (this.members[i].calculateWantedLevelGain());
+ moneyGains += (this.members[i].calculateMoneyGain());
+ }
+ this.respectGainRate = respectGains;
+ this.wantedGainRate = wantedLevelGains;
+ this.moneyGainRate = moneyGains;
+
+ if (!isNaN(respectGains)) {
+ var gain = respectGains * this.storedCycles;
+ this.respect += (gain);
+ //Faction reputation gains is respect gain divided by some constant
+ var fac = _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Factions"][this.facName];
+ if (!(fac instanceof _Faction_js__WEBPACK_IMPORTED_MODULE_2__["Faction"])) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("ERROR: Could not get Faction associates with your gang. This is a bug, please report to game dev");
+ } else {
+ var favorMult = 1 + (fac.favor / 100);
+ fac.playerReputation += ((_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].faction_rep_mult * gain * favorMult) / _Constants_js__WEBPACK_IMPORTED_MODULE_0__["CONSTANTS"].GangRespectToReputationRatio);
+ }
+
+ } else {
+ console.log("ERROR: respectGains is NaN");
+ }
+ if (!isNaN(wantedLevelGains)) {
+ if (this.wanted === 1 && wantedLevelGains < 0) {
+ //Do nothing
+ } else {
+ this.wanted += (wantedLevelGains * this.storedCycles);
+ if (this.wanted < 1) {this.wanted = 1;}
+ }
+ } else {
+ console.log("ERROR: wantedLevelGains is NaN");
+ }
+ if (!isNaN(moneyGains)) {
+ _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gainMoney(moneyGains * this.storedCycles);
+ } else {
+ console.log("ERROR: respectGains is NaN");
+ }
+
+ this.storedCycles = 0;
+}
+
+Gang.prototype.processExperienceGains = function(numCycles=1) {
+ for (var i = 0; i < this.members.length; ++i) {
+ this.members[i].gainExperience(numCycles);
+ this.members[i].updateSkillLevels();
+ }
+}
+
+//Calculates power GAIN, which is added onto the Gang's existing power
+Gang.prototype.calculatePower = function() {
+ var memberTotal = 0;
+ for (var i = 0; i < this.members.length; ++i) {
+ if (this.members[i].task instanceof GangMemberTask &&
+ this.members[i].task.name == "Territory Warfare") {
+ memberTotal += this.members[i].calculatePower();
+ }
+ }
+ return (0.0005 * memberTotal);
+}
+
+Gang.prototype.autoAssignMemberToTask = function(taskName) {
+ for (var i = 0; i < this.members.length; ++i) {
+ if (this.members[i].task.name === taskName) {
+ this.members[i].assignToTask(taskName);
+ return true;
+ }
+ }
+ return false;
+}
+
+Gang.prototype.autoUnassignMemberFromTask = function(taskName) {
+ for (var i = 0; i < this.members.length; ++i) {
+ if (this.members[i].task.name === taskName) {
+ this.members[i].unassignFromTask();
+ return true;
+ }
+ }
+ return false;
+}
+
+Gang.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_toJSON"])("Gang", this);
+}
+
+Gang.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_fromJSON"])(Gang, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"].constructors.Gang = Gang;
+
+/*** Gang Member object ***/
+function GangMember(name) {
+ this.name = name;
+ this.task = GangMemberTasks["Unassigned"]; //GangMemberTask object
+ this.city = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].city;
+
+ this.hack = 1;
+ this.str = 1;
+ this.def = 1;
+ this.dex = 1;
+ this.agi = 1;
+ this.cha = 1;
+
+ this.hack_exp = 0;
+ this.str_exp = 0;
+ this.def_exp = 0;
+ this.dex_exp = 0;
+ this.agi_exp = 0;
+ this.cha_exp = 0;
+
+ this.hack_mult = 1;
+ this.str_mult = 1;
+ this.def_mult = 1;
+ this.dex_mult = 1;
+ this.agi_mult = 1;
+ this.cha_mult = 1;
+
+ this.upgrades = []; //Names of upgrades
+}
+
+//Same formula for Player
+GangMember.prototype.calculateSkill = function(exp) {
+ return Math.max(Math.floor(32 * Math.log(exp + 534.5) - 200), 1);
+}
+
+GangMember.prototype.updateSkillLevels = function() {
+ this.hack = Math.floor(this.calculateSkill(this.hack_exp) * this.hack_mult);
+ this.str = Math.floor(this.calculateSkill(this.str_exp) * this.str_mult);
+ this.def = Math.floor(this.calculateSkill(this.def_exp) * this.def_mult);
+ this.dex = Math.floor(this.calculateSkill(this.dex_exp) * this.dex_mult);
+ this.agi = Math.floor(this.calculateSkill(this.agi_exp) * this.agi_mult);
+ this.cha = Math.floor(this.calculateSkill(this.cha_exp) * this.cha_mult);
+}
+
+GangMember.prototype.calculatePower = function() {
+ return (this.hack + this.str + this.def +
+ this.dex + this.agi + this.cha) / 100;
+}
+
+GangMember.prototype.assignToTask = function(taskName) {
+ if (GangMemberTasks.hasOwnProperty(taskName)) {
+ this.task = GangMemberTasks[taskName];
+ } else {
+ this.task = GangMemberTasks["Unassigned"];
+ }
+}
+
+GangMember.prototype.unassignFromTask = function() {
+ if (GangMemberTasks.hasOwnProperty("Unassigned")) {
+ this.task = GangMemberTasks["Unassigned"];
+ } else {
+ console.log("ERROR: Can't find Unassigned Gang member task");
+ this.task = null;
+ }
+}
+
+//Gains are per cycle
+GangMember.prototype.calculateRespectGain = function() {
+ var task = this.task;
+ if (task == null || !(task instanceof GangMemberTask) || task.baseRespect === 0) {return 0;}
+ var statWeight = (task.hackWeight/100) * this.hack +
+ (task.strWeight/100) * this.str +
+ (task.defWeight/100) * this.def +
+ (task.dexWeight/100) * this.dex +
+ (task.agiWeight/100) * this.agi +
+ (task.chaWeight/100) * this.cha;
+ statWeight -= (3.5 * task.difficulty);
+ if (statWeight <= 0) {return 0;}
+ var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory;
+ if (territoryMult <= 0) {return 0;}
+ var respectMult = (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect) / (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect + _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.wanted);
+ return 12 * task.baseRespect * statWeight * territoryMult * respectMult;
+}
+
+GangMember.prototype.calculateWantedLevelGain = function() {
+ var task = this.task;
+ if (task == null || !(task instanceof GangMemberTask) || task.baseWanted === 0) {return 0;}
+ var statWeight = (task.hackWeight/100) * this.hack +
+ (task.strWeight/100) * this.str +
+ (task.defWeight/100) * this.def +
+ (task.dexWeight/100) * this.dex +
+ (task.agiWeight/100) * this.agi +
+ (task.chaWeight/100) * this.cha;
+ statWeight -= (3.5 * task.difficulty);
+ if (statWeight <= 0) {return 0;}
+ var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory;
+ if (territoryMult <= 0) {return 0;}
+ if (task.baseWanted < 0) {
+ return task.baseWanted * statWeight * territoryMult;
+ } else {
+ return 6 * task.baseWanted / (3 * statWeight * territoryMult);
+ }
+}
+
+GangMember.prototype.calculateMoneyGain = function() {
+ var task = this.task;
+ if (task == null || !(task instanceof GangMemberTask) || task.baseMoney === 0) {return 0;}
+ var statWeight = (task.hackWeight/100) * this.hack +
+ (task.strWeight/100) * this.str +
+ (task.defWeight/100) * this.def +
+ (task.dexWeight/100) * this.dex +
+ (task.agiWeight/100) * this.agi +
+ (task.chaWeight/100) * this.cha;
+ statWeight -= (3.5 * task.difficulty);
+ if (statWeight <= 0) {return 0;}
+ var territoryMult = AllGangs[_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName].territory;
+ if (territoryMult <= 0) {return 0;}
+ var respectMult = (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect) / (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect + _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.wanted);
+ return 5 * task.baseMoney * statWeight * territoryMult * respectMult;
+}
+
+GangMember.prototype.gainExperience = function(numCycles=1) {
+ var task = this.task;
+ if (task == null || !(task instanceof GangMemberTask)) {return;}
+ this.hack_exp += (task.hackWeight / 1500) * task.difficulty * numCycles;
+ this.str_exp += (task.strWeight / 1500) * task.difficulty * numCycles;
+ this.def_exp += (task.defWeight / 1500) * task.difficulty * numCycles;
+ this.dex_exp += (task.dexWeight / 1500) * task.difficulty * numCycles;
+ this.agi_exp += (task.agiWeight / 1500) * task.difficulty * numCycles;
+ this.cha_exp += (task.chaWeight / 1500) * task.difficulty * numCycles;
+}
+
+GangMember.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_toJSON"])("GangMember", this);
+}
+
+GangMember.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_fromJSON"])(GangMember, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"].constructors.GangMember = GangMember;
+
+//Defines tasks that Gang Members can work on
+function GangMemberTask(name="", desc="",
+ params={baseRespect: 0, baseWanted: 0, baseMoney: 0,
+ hackWeight: 0, strWeight: 0, defWeight: 0,
+ dexWeight: 0, agiWeight: 0, chaWeight: 0,
+ difficulty: 0}) {
+ this.name = name;
+ this.desc = desc;
+
+ this.baseRespect = params.baseRespect ? params.baseRespect : 0;
+ this.baseWanted = params.baseWanted ? params.baseWanted : 0;
+ this.baseMoney = params.baseMoney ? params.baseMoney : 0;
+
+ //Weights must add up to 100
+ this.hackWeight = params.hackWeight ? params.hackWeight : 0;
+ this.strWeight = params.strWeight ? params.strWeight : 0;
+ this.defWeight = params.defWeight ? params.defWeight : 0;
+ this.dexWeight = params.dexWeight ? params.dexWeight : 0;
+ this.agiWeight = params.agiWeight ? params.agiWeight : 0;
+ this.chaWeight = params.chaWeight ? params.chaWeight : 0;
+
+ //1 - 100
+ this.difficulty = params.difficulty ? params.difficulty : 1;
+}
+
+GangMemberTask.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_toJSON"])("GangMemberTask", this);
+}
+
+GangMemberTask.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_fromJSON"])(GangMemberTask, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"].constructors.GangMemberTask = GangMemberTask;
+
+//TODO Human trafficking and an equivalent hacking crime
+let GangMemberTasks = {
+ "Unassigned" : new GangMemberTask(
+ "Unassigned",
+ "This gang member is currently idle"),
+ "Ransomware" : new GangMemberTask(
+ "Ransomware",
+ "Assign this gang member to create and distribute ransomware
" +
+ "Earns money - Slightly increases respect - Slightly increases wanted level",
+ {baseRespect: 0.00005, baseWanted: 0.00001, baseMoney: 1,
+ hackWeight: 100, difficulty: 1}),
+ "Phishing" : new GangMemberTask(
+ "Phishing",
+ "Assign this gang member to attempt phishing scams and attacks
" +
+ "Earns money - Slightly increases respect - Slightly increases wanted level",
+ {baseRespect: 0.00008, baseWanted: 0.001, baseMoney: 2.5,
+ hackWeight: 85, chaWeight: 15, difficulty: 3}),
+ "Identity Theft" : new GangMemberTask(
+ "Identity Theft",
+ "Assign this gang member to attempt identity theft
" +
+ "Earns money - Increases respect - Increases wanted level",
+ {baseRespect: 0.0001, baseWanted: 0.01, baseMoney: 6,
+ hackWeight: 80, chaWeight: 20, difficulty: 4}),
+ "DDoS Attacks" : new GangMemberTask(
+ "DDoS Attacks",
+ "Assign this gang member to carry out DDoS attacks
" +
+ "Increases respect - Increases wanted level",
+ {baseRespect: 0.0004, baseWanted: 0.05,
+ hackWeight: 100, difficulty: 7}),
+ "Plant Virus" : new GangMemberTask(
+ "Plant Virus",
+ "Assign this gang member to create and distribute malicious viruses
" +
+ "Increases respect - Increases wanted level",
+ {baseRespect: 0.0006, baseWanted: 0.05,
+ hackWeight: 100, difficulty: 10}),
+ "Fraud & Counterfeiting" : new GangMemberTask(
+ "Fraud & Counterfeiting",
+ "Assign this gang member to commit financial fraud and digital counterfeiting
" +
+ "Earns money - Slightly increases respect - Slightly increases wanted level",
+ {baseRespect: 0.0005, baseWanted: 0.1, baseMoney: 15,
+ hackWeight: 80, chaWeight: 20, difficulty: 17}),
+ "Money Laundering" : new GangMemberTask(
+ "Money Laundering",
+ "Assign this gang member to launder money
" +
+ "Earns money - Increases respect - Increases wanted level",
+ {baseRespect: 0.0006, baseWanted:0.2, baseMoney: 40,
+ hackWeight: 75, chaWeight: 25, difficulty: 20}),
+ "Cyberterrorism" : new GangMemberTask(
+ "Cyberterrorism",
+ "Assign this gang member to commit acts of cyberterrorism
" +
+ "Greatly increases respect - Greatly increases wanted level",
+ {baseRespect: 0.001, baseWanted: 0.5,
+ hackWeight: 80, chaWeight: 20, difficulty: 33}),
+ "Ethical Hacking" : new GangMemberTask(
+ "Ethical Hacking",
+ "Assign this gang member to be an ethical hacker for corporations
" +
+ "Earns money - Lowers wanted level",
+ {baseWanted: -0.001, baseMoney: 1,
+ hackWeight: 90, chaWeight: 10, difficulty: 1}),
+ "Mug People" : new GangMemberTask(
+ "Mug People",
+ "Assign this gang member to mug random people on the streets
" +
+ "Earns money - Slightly increases respect - Very slightly increases wanted level",
+ {baseRespect: 0.00005, baseWanted: 0.00001, baseMoney: 1,
+ strWeight: 25, defWeight: 25, dexWeight: 25, agiWeight: 10, chaWeight: 15, difficulty: 1}),
+ "Deal Drugs" : new GangMemberTask(
+ "Deal Drugs",
+ "Assign this gang member to sell drugs.
" +
+ "Earns money - Slightly increases respect - Slightly increases wanted level",
+ {baseRespect: 0.00008, baseWanted: 0.001, baseMoney: 4,
+ agiWeight: 20, dexWeight: 20, chaWeight: 60, difficulty: 3}),
+ "Run a Con" : new GangMemberTask(
+ "Run a Con",
+ "Assign this gang member to run cons
" +
+ "Earns money - Increases respect - Increases wanted level",
+ {baseRespect: 0.00015, baseWanted: 0.01, baseMoney: 10,
+ strWeight: 5, defWeight: 5, agiWeight: 25, dexWeight: 25, chaWeight: 40, difficulty: 10}),
+ "Armed Robbery" : new GangMemberTask(
+ "Armed Robbery",
+ "Assign this gang member to commit armed robbery on stores, banks and armored cars
" +
+ "Earns money - Increases respect - Increases wanted level",
+ {baseRespect: 0.0003, baseWanted: 0.1, baseMoney: 40,
+ hackWeight: 15, strWeight: 20, defWeight: 20, dexWeight: 20, chaWeight: 75,
+ difficulty: 25}),
+ "Threaten & Blackmail" : new GangMemberTask(
+ "Threaten & Blackmail",
+ "Assign this gang member to threaten and black mail high-profile targets
" +
+ "Earns money - Slightly increases respect - Slightly increases wanted level",
+ {baseRespect: 0.0002, baseWanted: 0.05, baseMoney: 15,
+ hackWeight: 25, strWeight: 25, dexWeight: 25, chaWeight: 25, difficulty: 28}),
+ "Terrorism" : new GangMemberTask(
+ "Terrorism",
+ "Assign this gang member to commit acts of terrorism
" +
+ "Greatly increases respect - Greatly increases wanted level",
+ {baseRespect: 0.001, baseWanted: 1,
+ hackWeight: 20, strWeight: 20, defWeight: 20,dexWeight: 20, chaWeight: 20,
+ difficulty: 33}),
+ "Vigilante Justice" : new GangMemberTask(
+ "Vigilante Justice",
+ "Assign this gang member to be a vigilante and protect the city from criminals
" +
+ "Decreases wanted level",
+ {baseWanted: -0.001,
+ hackWeight: 20, strWeight: 20, defWeight: 20, dexWeight: 20, agiWeight:20,
+ difficulty: 1}),
+ "Train Combat" : new GangMemberTask(
+ "Train Combat",
+ "Assign this gang member to increase their combat stats (str, def, dex, agi)",
+ {strWeight: 25, defWeight: 25, dexWeight: 25, agiWeight: 25, difficulty: 5}),
+ "Train Hacking" : new GangMemberTask(
+ "Train Hacking",
+ "Assign this gang member to train their hacking skills",
+ {hackWeight: 100, difficulty: 8}),
+ "Territory Warfare" : new GangMemberTask(
+ "Territory Warfare",
+ "Assign this gang member to engage in territorial warfare with other gangs. " +
+ "Members assigned to this task will help increase your gang's territory " +
+ "and will defend your territory from being taken.",
+ {hackWeight: 15, strWeight: 20, defWeight: 20, dexWeight: 20, agiWeight: 20,
+ chaWeight: 5, difficulty: 3}),
+}
+
+
+function GangMemberUpgrade(name="", desc="", cost=0, type="w") {
+ this.name = name;
+ this.desc = desc;
+ this.cost = cost;
+ this.type = type; //w, a, v, r
+}
+
+//Passes in a GangMember object
+GangMemberUpgrade.prototype.apply = function(member) {
+ switch(this.name) {
+ case "Baseball Bat":
+ member.str_mult *= 1.05;
+ member.def_mult *= 1.05;
+ break;
+ case "Katana":
+ member.str_mult *= 1.1;
+ member.def_mult *= 1.1;
+ member.dex_mult *= 1.1;
+ break;
+ case "Glock 18C":
+ member.str_mult *= 1.15;
+ member.def_mult *= 1.15;
+ member.dex_mult *= 1.15;
+ member.agi_mult *= 1.15;
+ break;
+ case "P90C":
+ member.str_mult *= 1.2;
+ member.def_mult *= 1.2;
+ member.agi_mult *= 1.1;
+ break;
+ case "Steyr AUG":
+ member.str_mult *= 1.25;
+ member.def_mult *= 1.25;
+ break;
+ case "AK-47":
+ member.str_mult *= 1.5;
+ member.def_mult *= 1.5;
+ break;
+ case "M15A10 Assault Rifle":
+ member.str_mult *= 1.6;
+ member.def_mult *= 1.6;
+ break;
+ case "AWM Sniper Rifle":
+ member.str_mult *= 1.5;
+ member.dex_mult *= 1.5;
+ member.agi_mult *= 1.5;
+ break;
+ case "Bulletproof Vest":
+ member.def_mult *= 1.05;
+ break;
+ case "Full Body Armor":
+ member.def_mult *= 1.1;
+ break;
+ case "Liquid Body Armor":
+ member.def_mult *= 1.25;
+ member.agi_mult *= 1.25;
+ break;
+ case "Graphene Plating Armor":
+ member.def_mult *= 1.5;
+ break;
+ case "Ford Flex V20":
+ member.agi_mult *= 1.1;
+ member.cha_mult *= 1.1;
+ break;
+ case "ATX1070 Superbike":
+ member.agi_mult *= 1.15;
+ member.cha_mult *= 1.15;
+ break;
+ case "Mercedes-Benz S9001":
+ member.agi_mult *= 1.2;
+ member.cha_mult *= 1.2;
+ break;
+ case "White Ferrari":
+ member.agi_mult *= 1.25;
+ member.cha_mult *= 1.25;
+ break;
+ case "NUKE Rootkit":
+ member.hack_mult *= 1.1;
+ break;
+ case "Soulstealer Rootkit":
+ member.hack_mult *= 1.2;
+ break;
+ case "Demon Rootkit":
+ member.hack_mult *= 1.3;
+ break;
+ default:
+ console.log("ERROR: Could not find this upgrade: " + this.name);
+ break;
+ }
+}
+
+GangMemberUpgrade.prototype.toJSON = function() {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_toJSON"])("GangMemberUpgrade", this);
+}
+
+GangMemberUpgrade.fromJSON = function(value) {
+ return Object(_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Generic_fromJSON"])(GangMemberUpgrade, value.data);
+}
+
+_utils_JSONReviver_js__WEBPACK_IMPORTED_MODULE_5__["Reviver"].constructors.GangMemberUpgrade = GangMemberUpgrade;
+
+let GangMemberUpgrades = {
+ "Baseball Bat" : new GangMemberUpgrade("Baseball Bat",
+ "Increases strength and defense by 5%", 1e6, "w"),
+ "Katana" : new GangMemberUpgrade("Katana",
+ "Increases strength, defense, and dexterity by 10%", 12e6, "w"),
+ "Glock 18C" : new GangMemberUpgrade("Glock 18C",
+ "Increases strength, defense, dexterity, and agility by 15%", 25e6, "w"),
+ "P90C" : new GangMemberUpgrade("P90C",
+ "Increases strength and defense by 20%. Increases agility by 10%", 50e6, "w"),
+ "Steyr AUG" : new GangMemberUpgrade("Steyr AUG",
+ "Increases strength and defense by 25%", 60e6, "w"),
+ "AK-47" : new GangMemberUpgrade("AK-47",
+ "Increases strength and defense by 50%", 100e6, "w"),
+ "M15A10 Assault Rifle" : new GangMemberUpgrade("M15A10 Assault Rifle",
+ "Increases strength and defense by 60%", 150e6, "w"),
+ "AWM Sniper Rifle" : new GangMemberUpgrade("AWM Sniper Rifle",
+ "Increases strength, dexterity, and agility by 50%", 225e6, "w"),
+ "Bulletproof Vest" : new GangMemberUpgrade("Bulletproof Vest",
+ "Increases defense by 5%", 2e6, "a"),
+ "Full Body Armor" : new GangMemberUpgrade("Full Body Armor",
+ "Increases defense by 10%", 5e6, "a"),
+ "Liquid Body Armor" : new GangMemberUpgrade("Liquid Body Armor",
+ "Increases defense and agility by 25%", 25e6, "a"),
+ "Graphene Plating Armor" : new GangMemberUpgrade("Graphene Plating Armor",
+ "Increases defense by 50%", 40e6, "a"),
+ "Ford Flex V20" : new GangMemberUpgrade("Ford Flex V20",
+ "Increases agility and charisma by 10%", 3e6, "v"),
+ "ATX1070 Superbike" : new GangMemberUpgrade("ATX1070 Superbike",
+ "Increases agility and charisma by 15%", 9e6, "v"),
+ "Mercedes-Benz S9001" : new GangMemberUpgrade("Mercedes-Benz S9001",
+ "Increases agility and charisma by 20%", 18e6, "v"),
+ "White Ferrari" : new GangMemberUpgrade("White Ferrari",
+ "Increases agility and charisma by 25%", 30e6, "v"),
+ "NUKE Rootkit" : new GangMemberUpgrade("NUKE Rootkit",
+ "Increases hacking by 10%", 5e6, "r"),
+ "Soulstealer Rootkit" : new GangMemberUpgrade("Soulstealer Rootkit",
+ "Increases hacking by 20%", 15e6, "r"),
+ "Demon Rootkit" : new GangMemberUpgrade("Demon Rootkit",
+ "Increases hacking by 30%", 50e6, "r"),
+}
+
+//Create a pop-up box that lets player purchase upgrades
+let gangMemberUpgradeBoxOpened = false;
+function createGangMemberUpgradeBox(initialFilter="") {
+ var boxId = "gang-member-upgrade-popup-box";
+ if (gangMemberUpgradeBoxOpened) {
+ //Already opened, refreshing
+ if (gangMemberUpgradeBoxElements == null || gangMemberUpgradeBox == null || gangMemberUpgradeBoxContent == null) {
+ console.log("ERROR: Refreshing Gang member upgrade box throws error because required elements are null");
+ return;
+ }
+
+ for (var i = 1; i < gangMemberUpgradeBoxElements.length; ++i) {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["removeElement"])(gangMemberUpgradeBoxElements[i]);
+ }
+ gangMemberUpgradeBoxElements = [gangMemberUpgradeBoxFilter];
+
+ var filter = gangMemberUpgradeBoxFilter.value.toString();
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members.length; ++i) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i].name.indexOf(filter) > -1 || _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i].task.name.indexOf(filter) > -1) {
+ var newPanel = createGangMemberUpgradePanel(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i]);
+ gangMemberUpgradeBoxContent.appendChild(newPanel);
+ gangMemberUpgradeBoxElements.push(newPanel);
+ }
+ }
+ } else {
+ //New popup
+ gangMemberUpgradeBoxFilter = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("input", {
+ type:"text", placeholder:"Filter gang members",
+ value:initialFilter,
+ onkeyup:()=>{
+ var filterValue = gangMemberUpgradeBoxFilter.value.toString();
+ createGangMemberUpgradeBox(filterValue);
+ }
+ });
+
+ gangMemberUpgradeBoxElements = [gangMemberUpgradeBoxFilter];
+
+ var filter = gangMemberUpgradeBoxFilter.value.toString();
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members.length; ++i) {
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i].name.indexOf(filter) > -1 || _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i].task.name.indexOf(filter) > -1) {
+ gangMemberUpgradeBoxElements.push(createGangMemberUpgradePanel(_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i]));
+ }
+ }
+
+ gangMemberUpgradeBox = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createPopup"])(boxId, gangMemberUpgradeBoxElements);
+ gangMemberUpgradeBoxContent = document.getElementById(boxId + "-content");
+ gangMemberUpgradeBoxOpened = true;
+ }
+}
+
+//Create upgrade panels for each individual Gang Member
+function createGangMemberUpgradePanel(memberObj) {
+ var container = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
+ border:"1px solid white",
+ });
+
+ var header = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("h1", {
+ innerText:memberObj.name + " (" + memberObj.task.name + ")"
+ });
+ container.appendChild(header);
+
+ var text = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("pre", {
+ fontSize:"14px", display: "inline-block", width:"20%",
+ innerText:
+ "Hack: " + memberObj.hack + " (x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.hack_mult, 2) + ")\n" +
+ "Str: " + memberObj.str + " (x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.str_mult, 2) + ")\n" +
+ "Def: " + memberObj.def + " (x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.def_mult, 2) + ")\n" +
+ "Dex: " + memberObj.dex + " (x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.dex_mult, 2) + ")\n" +
+ "Agi: " + memberObj.agi + " (x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.agi_mult, 2) + ")\n" +
+ "Cha: " + memberObj.cha + " (x" + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(memberObj.cha_mult, 2) + ")\n",
+ });
+
+ //Already purchased upgrades
+ var ownedUpgradesElements = [];
+ for (var i = 0; i < memberObj.upgrades.length; ++i) {
+ var upg = GangMemberUpgrades[memberObj.upgrades[i]];
+ if (upg == null) {
+ console.log("ERR: Could not find this upgrade: " + memberObj.upgrades[i]);
+ continue;
+ }
+ var e = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
+ border:"1px solid white", innerText:memberObj.upgrades[i],
+ margin:"1px", padding:"1px", tooltip:upg.desc, fontSize:"12px",
+ });
+ ownedUpgradesElements.push(e);
+ }
+ var ownedUpgrades = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
+ display:"inline-block", marginLeft:"6px", width:"75%", innerText:"Purchased Upgrades:",
+ });
+ for (var i = 0; i < ownedUpgradesElements.length; ++i) {
+ ownedUpgrades.appendChild(ownedUpgradesElements[i]);
+ }
+ container.appendChild(text);
+ container.appendChild(ownedUpgrades);
+ container.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
+
+ //Upgrade buttons. Only show upgrades that can be afforded
+ var weaponUpgrades = [], armorUpgrades = [], vehicleUpgrades = [], rootkitUpgrades = [];
+ for (var upgName in GangMemberUpgrades) {
+ if (GangMemberUpgrades.hasOwnProperty(upgName)) {
+ var upg = GangMemberUpgrades[upgName];
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].money.lt(upg.cost) || memberObj.upgrades.includes(upgName)) {continue;}
+ switch (upg.type) {
+ case "w":
+ weaponUpgrades.push(upg);
+ break;
+ case "a":
+ armorUpgrades.push(upg);
+ break;
+ case "v":
+ vehicleUpgrades.push(upg);
+ break;
+ case "r":
+ rootkitUpgrades.push(upg);
+ break;
+ default:
+ console.log("ERROR: Invalid Gang Member Upgrade Type: " + upg.type);
+ }
+ }
+ }
+
+ var weaponDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {width:"20%", display:"inline-block",});
+ var armorDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {width:"20%", display:"inline-block",});
+ var vehicleDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {width:"20%", display:"inline-block",});
+ var rootkitDiv = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {width:"20%", display:"inline-block",});
+ var upgrades = [weaponUpgrades, armorUpgrades, vehicleUpgrades, rootkitUpgrades];
+ var divs = [weaponDiv, armorDiv, vehicleDiv, rootkitDiv];
+
+ for (var i = 0; i < upgrades.length; ++i) {
+ var upgradeArray = upgrades[i];
+ var div = divs[i];
+ for (var j = 0; j < upgradeArray.length; ++j) {
+ var upg = upgradeArray[j];
+ (function (upg, div, memberObj) {
+ div.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
+ innerText:upg.name + " - " + _utils_numeral_min_js__WEBPACK_IMPORTED_MODULE_7___default()(upg.cost).format("$0.000a"),
+ class:"a-link-button", margin:"2px", padding:"2px", display:"block",
+ fontSize:"12px",
+ tooltip:upg.desc,
+ clickListener:()=>{
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].money.lt(upg.cost)) {return false;}
+ _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].loseMoney(upg.cost);
+ memberObj.upgrades.push(upg.name);
+ upg.apply(memberObj);
+ var initFilterValue = gangMemberUpgradeBoxFilter.value.toString();
+ createGangMemberUpgradeBox(initFilterValue);
+ return false;
+ }
+ }));
+ })(upg, div, memberObj);
+ }
+ }
+
+ container.appendChild(weaponDiv);
+ container.appendChild(armorDiv);
+ container.appendChild(vehicleDiv);
+ container.appendChild(rootkitDiv);
+ return container;
+}
+
+//Gang DOM elements
+let gangContentCreated = false,
+ gangContainer = null, managementButton = null, territoryButton = null;
+
+//Subpages
+let gangManagementSubpage = null, gangTerritorySubpage = null;
+
+//Gang Management Elements
+let gangDesc = null, gangInfo = null,
+ gangRecruitMemberButton = null, gangRecruitRequirementText = null,
+ gangExpandAllButton = null, gangCollapseAllButton, gangMemberFilter = null,
+ gangManageEquipmentButton = null,
+ gangMemberList = null;
+
+//Gang Equipment Upgrade Elements
+let gangMemberUpgradeBox = null, gangMemberUpgradeBoxContent = null,
+ gangMemberUpgradeBoxFilter = null, gangMemberUpgradeBoxElements = null;
+
+
+//Gang Territory Elements
+let gangTerritoryDescText = null, gangTerritoryInfoText = null;
+
+function displayGangContent() {
+ if (!gangContentCreated || gangContainer == null) {
+ gangContentCreated = true;
+
+ //Create gang container
+ gangContainer = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
+ id:"gang-container", class:"generic-menupage-container",
+ });
+
+ //Get variables
+ var facName = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName,
+ members = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members,
+ wanted = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.wanted,
+ respect = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.respect;
+
+ //Back button
+ gangContainer.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
+ class:"a-link-button", display:"inline-block", innerText:"Back",
+ clickListener:()=>{
+ _engine_js__WEBPACK_IMPORTED_MODULE_1__["Engine"].loadFactionContent();
+ Object(_Faction_js__WEBPACK_IMPORTED_MODULE_2__["displayFactionContent"])(facName);
+ return false;
+ }
+ }));
+
+ //Buttons to switch between panels
+ managementButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
+ id:"gang-management-subpage-button", class:"a-link-button-inactive",
+ display:"inline-block", innerHTML: "Gang Management (1)",
+ clickListener:()=>{
+ gangManagementSubpage.style.display = "block";
+ gangTerritorySubpage.style.display = "none";
+ managementButton.classList.toggle("a-link-button-inactive");
+ managementButton.classList.toggle("a-link-button");
+ territoryButton.classList.toggle("a-link-button-inactive");
+ territoryButton.classList.toggle("a-link-button");
+ updateGangContent();
+ return false;
+ }
+ })
+ territoryButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
+ id:"gang-territory-subpage-button", class:"a-link-button",
+ display:"inline-block", innerHTML:"Gang Territory (2)",
+ clickListener:()=>{
+ gangManagementSubpage.style.display = "none";
+ gangTerritorySubpage.style.display = "block";
+ managementButton.classList.toggle("a-link-button-inactive");
+ managementButton.classList.toggle("a-link-button");
+ territoryButton.classList.toggle("a-link-button-inactive");
+ territoryButton.classList.toggle("a-link-button");
+ updateGangContent();
+ return false;
+ }
+ });
+ gangContainer.appendChild(managementButton);
+ gangContainer.appendChild(territoryButton);
+
+ //Subpage for managing gang members
+ gangManagementSubpage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
+ display:"block", id:"gang-management-subpage",
+ });
+
+ var lowerWantedTask = "";
+ if (_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.isHackingGang) {
+ lowerWantedTask = "Ethical Hacking";
+ } else {
+ lowerWantedTask = "Vigilante Justice";
+ }
+ gangDesc = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {width:"70%",
+ innerHTML:
+ "This page is used to manage your gang members and get an overview of your " +
+ "gang's stats.
" +
+ "If a gang member is not earning much money or respect, the task that you " +
+ "have assigned to that member might be too difficult. Consider training that " +
+ "member's stats or choosing an easier task. The tasks closer to the " +
+ "top of the dropdown list are generally easier. Alternatively, the gang member's " +
+ "low production might be due to the fact that your wanted level is too high. " +
+ "Consider assigning a few members to the '" + lowerWantedTask + "' " +
+ "task to lower your wanted level.
" +
+ "Installing Augmentations does NOT reset your progress with your Gang. " +
+ "Furthermore, after installing Augmentations, you will " +
+ "automatically be a member of whatever Faction you created your gang with.
"
+ });
+ gangManagementSubpage.appendChild(gangDesc);
+
+ gangInfo = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {id:"gang-info", width:"70%"});
+ gangManagementSubpage.appendChild(gangInfo);
+
+ gangRecruitMemberButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
+ id:"gang-management-recruit-member-btn", class:"a-link-button-inactive",
+ innerHTML:"Recruit Gang Member", display:"inline-block", margin:"10px",
+ clickListener:()=>{
+ var yesBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxGetYesButton"])(), noBtn = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxGetNoButton"])();
+ yesBtn.innerHTML = "Recruit Gang Member";
+ noBtn.innerHTML = "Cancel";
+ yesBtn.addEventListener("click", ()=>{
+ var name = Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxGetInput"])();
+ if (name === "") {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("You must enter a name for your Gang member!");
+ } else {
+ for (var i = 0; i < _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members.length; ++i) {
+ if (name == _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members[i].name) {
+ Object(_utils_DialogBox_js__WEBPACK_IMPORTED_MODULE_4__["dialogBoxCreate"])("You already have a gang member with this name!");
+ return false;
+ }
+ }
+ var member = new GangMember(name);
+ _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members.push(member);
+ createGangMemberDisplayElement(member);
+ updateGangContent();
+ }
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxClose"])();
+ });
+ noBtn.addEventListener("click", ()=>{
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxClose"])();
+ });
+ Object(_utils_YesNoBox_js__WEBPACK_IMPORTED_MODULE_9__["yesNoTxtInpBoxCreate"])("Please enter a name for your new Gang member:");
+ return false;
+ }
+ });
+ gangManagementSubpage.appendChild(gangRecruitMemberButton);
+
+ //Text for how much reputation is required for recruiting next memberList
+ gangRecruitRequirementText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {color:"red", id:"gang-recruit-requirement-text"});
+ gangManagementSubpage.appendChild(gangRecruitRequirementText);
+
+ //Gang Member List management buttons (Expand/Collapse All, select a single member)
+ gangManagementSubpage.appendChild(Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("br", {}));
+ gangExpandAllButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
+ class:"a-link-button", display:"inline-block",
+ innerHTML:"Expand All",
+ clickListener:()=>{
+ var allHeaders = gangManagementSubpage.getElementsByClassName("accordion-header");
+ for (var i = 0; i < allHeaders.length; ++i) {
+ var hdr = allHeaders[i];
+ if (!hdr.classList.contains("active")) {
+ hdr.click();
+ }
+ }
+ return false;
+ }
+ });
+ gangCollapseAllButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
+ class:"a-link-button", display:"inline-block",
+ innerHTML:"Collapse All",
+ clickListener:()=>{
+ var allHeaders = gangManagementSubpage.getElementsByClassName("accordion-header");
+ for (var i = 0; i < allHeaders.length; ++i) {
+ var hdr = allHeaders[i];
+ if (hdr.classList.contains("active")) {
+ hdr.click();
+ }
+ }
+ return false;
+ }
+ });
+ gangMemberFilter = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("input", {
+ type:"text", placeholder:"Filter gang members", margin:"5px", padding:"5px",
+ onkeyup:()=>{
+ displayGangMemberList();
+ }
+ });
+ gangManageEquipmentButton = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("a", {
+ class:"a-link-button", display:"inline-block",
+ innerHTML:"Manage Equipment",
+ clickListener:()=>{
+ createGangMemberUpgradeBox();
+ }
+ });
+ gangManagementSubpage.appendChild(gangExpandAllButton);
+ gangManagementSubpage.appendChild(gangCollapseAllButton);
+ gangManagementSubpage.appendChild(gangMemberFilter);
+ gangManagementSubpage.appendChild(gangManageEquipmentButton);
+
+ //Gang Member list
+ gangMemberList = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("ul", {id:"gang-member-list"});
+ displayGangMemberList();
+ gangManagementSubpage.appendChild(gangMemberList);
+
+ //Subpage for seeing gang territory information
+ gangTerritorySubpage = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("div", {
+ id:"gang-territory-subpage", display:"none"
+ });
+
+ //Info text for territory page
+ gangTerritoryDescText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {
+ width:"70%",
+ innerHTML:"This page shows how much territory your Gang controls. This statistic is listed as a percentage, " +
+ "which represents how much of the total territory you control.
" +
+ "Territory gain and loss is processed automatically and is updated every ~30 seconds. Your chances " +
+ "to gain and lose territory depend on your Gang's power, which is listed in the display below. " +
+ "Your gang's power is determined by the stats of all Gang members you have assigned to the " +
+ "'Territory Warfare' task. Gang members that are not assigned to this task do not contribute to " +
+ "your Gang's power.
" +
+ "The amount of territory you have affects all aspects of your Gang members' production, including " +
+ "money, respect, and wanted level. It is very beneficial to have high territory control.
"
+ });
+ gangTerritorySubpage.appendChild(gangTerritoryDescText);
+
+ var territoryBorder = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("fieldset", {width:"50%", display:"inline-block"});
+
+ gangTerritoryInfoText = Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["createElement"])("p", {id:"gang-territory-info"});
+
+ territoryBorder.appendChild(gangTerritoryInfoText);
+ gangTerritorySubpage.appendChild(territoryBorder);
+
+ gangContainer.appendChild(gangTerritorySubpage);
+ gangContainer.appendChild(gangManagementSubpage);
+ document.getElementById("entire-game-container").appendChild(gangContainer);
+ }
+ gangContainer.style.display = "block";
+ updateGangContent();
+}
+
+function displayGangMemberList() {
+ Object(_utils_HelperFunctions_js__WEBPACK_IMPORTED_MODULE_6__["removeChildrenFromElement"])(gangMemberList);
+ var members = _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.members;
+ var filter = gangMemberFilter.value.toString();
+ for (var i = 0; i < members.length; ++i) {
+ if (members[i].name.indexOf(filter) > -1 || members[i].task.name.indexOf(filter) > -1) {
+ createGangMemberDisplayElement(members[i]);
+ }
+ }
+ //setGangMemberClickHandlers(); //Set buttons to toggle the gang member info panels
+}
+
+function updateGangContent() {
+ if (!gangContentCreated || !_Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].inGang()) {return;}
+
+ if(gangTerritorySubpage.style.display === "block") {
+ //Update territory information
+ gangTerritoryInfoText.innerHTML = "";
+ for (var gangname in AllGangs) {
+ if (AllGangs.hasOwnProperty(gangname)) {
+ var gangTerritoryInfo = AllGangs[gangname];
+ if (gangname == _Player_js__WEBPACK_IMPORTED_MODULE_3__["Player"].gang.facName) {
+ gangTerritoryInfoText.innerHTML += ("" + gangname + " (Power: " + Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(gangTerritoryInfo.power, 6) + "): " +
+ Object(_utils_StringHelperFunctions_js__WEBPACK_IMPORTED_MODULE_8__["formatNumber"])(100*gangTerritoryInfo.territory, 2) + "%
These shortcuts were implemented to better emulate a bash shell. They must be enabled
-in your Terminal's .fconf file. This can be done be entering the Terminal command:
+in your Terminal's .fconf file. This can be done be entering the Terminal command:
nano.fconf
@@ -201,7 +201,7 @@ as well as your browser's shortcuts
Ctrl + p
Same as Up Arrow
-
Ctrl + n
+
Ctrl + m
Same as Down Arrow
Ctrl + a
@@ -259,6 +259,7 @@ as well as your browser's shortcuts