" +
- "This will upgrade your RAM from " + ram + "GB to " + ram*2 + "GB.
" +
- "This will cost " + numeralWrapper.format(cost, '$0.000a'));
- });
-
- purchaseHomeCores.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- var currentCores = 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 = yesNoBoxGetYesButton(), noBtn = yesNoBoxGetNoButton();
- yesBtn.innerHTML = "Purchase"; noBtn.innerHTML = "Cancel";
- yesBtn.addEventListener("click", ()=>{
- if (Player.money.lt(cost)) {
- dialogBoxCreate("You do not have enough money to purchase an additional CPU Core for your home computer!");
- } else {
- Player.loseMoney(cost);
- Player.getHomeComputer().cpuCores++;
- dialogBoxCreate("You purchased an additional CPU Core for your home computer! It now has " +
- Player.getHomeComputer().cpuCores + " cores.");
- }
- yesNoBoxClose();
- });
- noBtn.addEventListener("click", ()=>{
- yesNoBoxClose();
- });
- 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.
" +
- "Purchasing an additional core (for a total of " + (Player.getHomeComputer().cpuCores + 1) + ") will " +
- "cost " + numeralWrapper.format(cost, '$0.000a'));
- });
-
- travelToAevum.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- travelBoxCreate(Locations.Aevum, CONSTANTS.TravelCost);
- return false;
- });
-
- travelToChongqing.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- travelBoxCreate(Locations.Chongqing, CONSTANTS.TravelCost);
- return false;
- });
-
- travelToSector12.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- travelBoxCreate(Locations.Sector12, CONSTANTS.TravelCost);
- return false;
- });
-
- travelToNewTokyo.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- travelBoxCreate(Locations.NewTokyo, CONSTANTS.TravelCost);
- return false;
- });
-
- travelToIshima.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- travelBoxCreate(Locations.Ishima, CONSTANTS.TravelCost);
- return false;
- });
-
- travelToVolhaven.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- travelBoxCreate(Locations.Volhaven, CONSTANTS.TravelCost);
- return false;
- });
-
- slumsShoplift.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- Crimes.Shoplift.commit(Player);
- return false;
- });
-
- slumsRobStore.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- Crimes.RobStore.commit(Player);
- return false;
- });
-
- slumsMug.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- Crimes.Mug.commit(Player);
- return false;
- });
-
- slumsLarceny.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- Crimes.Larceny.commit(Player);
- return false;
- });
-
- slumsDealDrugs.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- Crimes.DealDrugs.commit(Player);
- return false;
- });
-
- slumsBondForgery.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- Crimes.BondForgery.commit(Player);
- return false;
- });
-
- slumsTrafficArms.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- Crimes.TraffickArms.commit(Player);
- return false;
- });
-
- slumsHomicide.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- Crimes.Homicide.commit(Player);
- return false;
- });
-
- slumsGta.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- Crimes.GrandTheftAuto.commit(Player);
- return false;
- });
-
- slumsKidnap.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- Crimes.Kidnap.commit(Player);
- return false;
- });
-
- slumsAssassinate.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- Crimes.Assassination.commit(Player);
- return false;
- });
-
- slumsHeist.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- Crimes.Heist.commit(Player);
- return false;
- });
-
- cityHallCreateCorporation.addEventListener("click", function() {
- const popupId = "create-corporation-popup";
- const txt = createElement("p", {
- innerHTML: "Would you like to start a corporation? This will require $150b for registration " +
- "and initial funding. This $150b can either be self-funded, or you can obtain " +
- "the seed money from the government in exchange for 500 million shares
" +
- "If you would like to start one, please enter a name for your corporation below:",
- });
-
- const nameInput = createElement("input", {
- placeholder: "Corporation Name",
- });
-
- const selfFundedButton = createElement("button", {
- class: "popup-box-button",
- innerText: "Self-Fund",
- clickListener: () => {
- if (Player.money.lt(150e9)) {
- dialogBoxCreate("You don't have enough money to create a corporation! You need $150b");
- return false;
- }
- Player.loseMoney(150e9);
-
- const companyName = nameInput.value;
- if (companyName == null || companyName == "") {
- dialogBoxCreate("Invalid company name!");
- return false;
- }
-
- Player.corporation = new Corporation({
- name: companyName,
- });
-
- displayLocationContent();
- document.getElementById("world-menu-header").click();
- document.getElementById("world-menu-header").click();
- dialogBoxCreate("Congratulations! You just self-funded your own corporation. You can visit " +
- "and manage your company in the City");
- removeElementById(popupId);
- return false;
- }
- });
-
- const seedMoneyButton = createElement("button", {
- class: "popup-box-button",
- innerText: "Use Seed Money",
- clickListener: () => {
- const companyName = nameInput.value;
- if (companyName == null || companyName == "") {
- dialogBoxCreate("Invalid company name!");
- return false;
- }
-
- Player.corporation = new Corporation({
- name: companyName,
- });
- Player.corporation.totalShares += 500e6;
-
- displayLocationContent();
- document.getElementById("world-menu-header").click();
- document.getElementById("world-menu-header").click();
- dialogBoxCreate("Congratulations! You just started your own corporation with government seed money. " +
- "You can visit and manage your company in the City");
- removeElementById(popupId);
- return false;
- }
- })
-
- const cancelBtn = createPopupCloseButton(popupId, { class: "popup-box-button" });
-
- if (Player.corporation instanceof Corporation) {
- return;
- } else {
- createPopup(popupId, [txt, nameInput, cancelBtn, selfFundedButton, seedMoneyButton]);
- nameInput.focus();
- }
- });
-
- nsaBladeburner.addEventListener("click", function() {
- if (Player.bladeburner && Player.bladeburner instanceof Bladeburner) {
- //Enter Bladeburner division
- Engine.loadBladeburnerContent();
- } else {
- //Apply for Bladeburner division
- if (Player.strength >= 100 && Player.defense >= 100 &&
- Player.dexterity >= 100 && Player.agility >= 100) {
- Player.bladeburner = new Bladeburner({new:true});
- dialogBoxCreate("You have been accepted into the Bladeburner division!");
- displayLocationContent();
- document.getElementById("world-menu-header").click();
- document.getElementById("world-menu-header").click();
- } else {
- dialogBoxCreate("Rejected! Please apply again when you have 100 of each combat stat (str, def, dex, agi)");
- }
- }
- });
-
- vitalifeResleeve.addEventListener("click", function() {
- Engine.loadResleevingContent();
- });
-
- hospitalTreatment.addEventListener("click", function(e) {
- if (!e.isTrusted) {return false;}
- if (Player.hp < 0) {Player.hp = 0;}
- var price = (Player.max_hp - Player.hp) * CONSTANTS.HospitalCostPerHp;
- Player.loseMoney(price);
- dialogBoxCreate("You were healed to full health! The hospital billed " +
- "you for $" + formatNumber(price, 2).toString());
- Player.hp = Player.max_hp;
- displayLocationContent();
- return false;
- });
-}
-
-function travelToCity(destCityName, cost) {
- if (Player.firstTimeTraveled === false) {
- Player.firstTimeTraveled = true;
- document.getElementById("travel-tab").style.display = "list-item";
- document.getElementById("world-menu-header").click();
- document.getElementById("world-menu-header").click();
- }
-
- if (Player.money.lt(cost)) {
- dialogBoxCreate("You cannot afford to travel to " + destCityName);
- return;
- }
- Player.loseMoney(cost);
-
- Player.city = destCityName;
- dialogBoxCreate("You are now in " + destCityName + "!");
- Engine.loadWorldContent();
-}
-
-function purchaseTorRouter() {
- if (Player.money.lt(CONSTANTS.TorRouterCost)) {
- dialogBoxCreate("You cannot afford to purchase the Tor router");
- return;
- }
- Player.loseMoney(CONSTANTS.TorRouterCost);
-
- var darkweb = new Server({
- ip:createRandomIp(), hostname:"darkweb", organizationName:"",
- isConnectedTo:false, adminRights:false, purchasedByPlayer:false, maxRam:1
- });
- AddToAllServers(darkweb);
- SpecialServerIps.addIp("Darkweb Server", darkweb.ip);
-
- const purchaseTor = document.getElementById("location-purchase-tor");
- purchaseTor.setAttribute("class", "a-link-button-bought");
- purchaseTor.innerHTML = "TOR Router - Purchased";
-
- Player.getHomeComputer().serversOnNetwork.push(darkweb.ip);
- darkweb.serversOnNetwork.push(Player.getHomeComputer().ip);
- dialogBoxCreate("You have purchased a Tor router! You now have access to the dark web from your home computer Use the scan/scan-analyze commands to search for the dark web connection.");
-}
-
-function displayUniversityLocationContent(costMult) {
- var studyComputerScienceButton = document.getElementById("location-study-computer-science");
- var classDataStructuresButton = document.getElementById("location-data-structures-class");
- var classNetworksButton = document.getElementById("location-networks-class");
- var classAlgorithmsButton = document.getElementById("location-algorithms-class");
- var classManagementButton = document.getElementById("location-management-class");
- var classLeadershipButton = document.getElementById("location-leadership-class");
- studyComputerScienceButton.style.display = "block";
- classDataStructuresButton.style.display = "block";
- classNetworksButton.style.display = "block";
- classAlgorithmsButton.style.display = "block";
- classManagementButton.style.display = "block";
- classLeadershipButton.style.display = "block";
-
- //Costs (per second)
- var dataStructuresCost = CONSTANTS.ClassDataStructuresBaseCost * costMult;
- var networksCost = CONSTANTS.ClassNetworksBaseCost * costMult;
- var algorithmsCost = CONSTANTS.ClassAlgorithmsBaseCost * costMult;
- var managementCost = CONSTANTS.ClassManagementBaseCost * costMult;
- var leadershipCost = CONSTANTS.ClassLeadershipBaseCost * costMult;
-
- //Update button text to show cost
- classDataStructuresButton.innerHTML = "Take Data Structures course ($" + dataStructuresCost + " / sec)";
- classNetworksButton.innerHTML = "Take Networks course ($" + networksCost + " / sec)";
- classAlgorithmsButton.innerHTML = "Take Algorithms course ($" + algorithmsCost + " / sec)";
- classManagementButton.innerHTML = "Take Management course ($" + managementCost + " / sec)";
- classLeadershipButton.innerHTML = "Take Leadership course ($" + leadershipCost + " / sec)";
-}
-
-function setUniversityLocationButtons(costMult, expMult) {
- var newStudyCS = clearEventListeners("location-study-computer-science");
- newStudyCS.addEventListener("click", function() {
- Player.startClass(costMult, expMult, CONSTANTS.ClassStudyComputerScience);
- return false;
- });
-
- var newClassDataStructures = clearEventListeners("location-data-structures-class");
- newClassDataStructures.addEventListener("click", function() {
- Player.startClass(costMult, expMult, CONSTANTS.ClassDataStructures);
- return false;
- });
-
- var newClassNetworks = clearEventListeners("location-networks-class");
- newClassNetworks.addEventListener("click", function() {
- Player.startClass(costMult, expMult, CONSTANTS.ClassNetworks);
- return false;
- });
-
- var newClassAlgorithms = clearEventListeners("location-algorithms-class");
- newClassAlgorithms.addEventListener("click", function() {
- Player.startClass(costMult, expMult, CONSTANTS.ClassAlgorithms);
- return false;
- });
-
- var newClassManagement = clearEventListeners("location-management-class");
- newClassManagement.addEventListener("click", function() {
- Player.startClass(costMult, expMult, CONSTANTS.ClassManagement);
- return false;
- });
-
- var newClassLeadership = clearEventListeners("location-leadership-class");
- newClassLeadership.addEventListener("click", function() {
- Player.startClass(costMult, expMult, CONSTANTS.ClassLeadership);
- return false;
- });
-}
-
-function displayGymLocationContent(costMult) {
- var gymStrButton = document.getElementById("location-gym-train-str");
- var gymDefButton = document.getElementById("location-gym-train-def");
- var gymDexButton = document.getElementById("location-gym-train-dex");
- var gymAgiButton = document.getElementById("location-gym-train-agi");
- gymStrButton.style.display = "block";
- gymDefButton.style.display = "block";
- gymDexButton.style.display = "block";
- gymAgiButton.style.display = "block";
-
- //Costs (per second)
- var cost = CONSTANTS.ClassGymBaseCost * costMult;
-
- //Update button text to show cost
- gymStrButton.innerHTML = "Train Strength ($" + cost + " / sec)";
- gymDefButton.innerHTML = "Train Defense ($" + cost + " / sec)";
- gymDexButton.innerHTML = "Train Dexterity ($" + cost + " / sec)";
- gymAgiButton.innerHTML = "Train Agility ($" + cost + " / sec)";
-}
-
-function setGymLocationButtons(costMult, expMult) {
- var gymStr = clearEventListeners("location-gym-train-str");
- gymStr.addEventListener("click", function() {
- Player.startClass(costMult, expMult, CONSTANTS.ClassGymStrength);
- return false;
- });
-
- var gymDef = clearEventListeners("location-gym-train-def");
- gymDef.addEventListener("click", function() {
- Player.startClass(costMult, expMult, CONSTANTS.ClassGymDefense);
- return false;
- });
-
- var gymDex = clearEventListeners("location-gym-train-dex");
- gymDex.addEventListener("click", function() {
- Player.startClass(costMult, expMult, CONSTANTS.ClassGymDexterity);
- return false;
- });
-
- var gymAgi = clearEventListeners("location-gym-train-agi");
- gymAgi.addEventListener("click", function() {
- Player.startClass(costMult, expMult, CONSTANTS.ClassGymAgility);
- return false;
- });
-}
-
-function setInfiltrateButton(btn, companyName, startLevel, val, maxClearance, difficulty) {
- btn.style.display = "block";
- btn.addEventListener("click", function() {
- Engine.loadInfiltrationContent();
- beginInfiltration(companyName, startLevel, val, maxClearance, difficulty)
- return false;
- });
-}
-
-//Finds the next target job for the player at the given company (loc) and
-//adds the tooltiptext to the Application button, given by 'button'
-function setJobRequirementTooltip(loc, entryPosType, btn) {
- var company = Companies[loc];
- if (company == null) {return;}
- var pos = Player.getNextCompanyPosition(company, entryPosType);
- if (pos == null) { return };
- if (!company.hasPosition(pos)) { return; }
- var reqText = getJobRequirementText(company, pos, true);
- btn.innerHTML += "" + reqText + "";
-}
-
-function travelBoxCreate(destCityName, cost) {
- if(Settings.SuppressTravelConfirmation) {
- travelToCity(destCityName, cost);
- return;
- }
- var yesBtn = yesNoBoxGetYesButton(), noBtn = yesNoBoxGetNoButton();
- yesBtn.innerHTML = "Yes";
- noBtn.innerHTML = "No";
- noBtn.addEventListener("click", () => {
- yesNoBoxClose();
- return false;
- });
- yesBtn.addEventListener("click", () => {
- yesNoBoxClose();
- travelToCity(destCityName, cost);
- return false;
- });
- yesNoBoxCreate("Would you like to travel to " + destCityName + "? The trip will cost $" + formatNumber(cost, 2) + ".");
-}
-
-function purchaseServerBoxCreate(ram) {
- const cost = getPurchaseServerCost(ram);
- if (cost === Infinity) {
- dialogBoxCreate("Something went wrong when trying to purchase this server. Please contact developer");
- return;
- }
-
- var yesBtn = yesNoTxtInpBoxGetYesButton();
- var noBtn = yesNoTxtInpBoxGetNoButton();
- yesBtn.innerHTML = "Purchase Server";
- noBtn.innerHTML = "Cancel";
- yesBtn.addEventListener("click", function() {
- purchaseServer(ram);
- yesNoTxtInpBoxClose();
- });
- noBtn.addEventListener("click", function() {
- yesNoTxtInpBoxClose();
- });
-
- yesNoTxtInpBoxCreate("Would you like to purchase a new server with " + ram +
- "GB of RAM for $" + formatNumber(cost, 2) + "?
" +
- "Please enter the server hostname below: ");
-}
-
-export {displayLocationContent, initLocationButtons};
diff --git a/src/Locations/Location.ts b/src/Locations/Location.ts
index 8667e4d86..7c67efc85 100644
--- a/src/Locations/Location.ts
+++ b/src/Locations/Location.ts
@@ -5,8 +5,18 @@ import { CityName } from "./data/CityNames";
import { LocationName } from "./data/LocationNames";
import { LocationType } from "./LocationTypeEnum";
+interface IInfiltrationMetadata {
+ baseRewardValue: number;
+ difficulty: number;
+ maxClearanceLevel: number;
+ startingSecurityLevel: number;
+}
+
export interface IConstructorParams {
city?: CityName | null;
+ costMult?: number;
+ expMult?: number;
+ infiltrationData?: IInfiltrationMetadata;
name?: LocationName;
types?: LocationType[];
techVendorMaxRam?: number;
@@ -20,6 +30,22 @@ export class Location {
*/
city: CityName | null = null;
+ /**
+ * Cost multiplier that influences how expensive a gym/university is
+ */
+ costMult: number = 0;
+
+ /**
+ * Exp multiplier that influences how effective a gym/university is
+ */
+ expMult: number = 0;
+
+ /**
+ * Companies can be infiltrated. This contains the data required for that
+ * infiltration event
+ */
+ infiltrationData?: IInfiltrationMetadata;
+
/**
* Identifier for location
*/
@@ -45,6 +71,9 @@ export class Location {
constructor(p: IConstructorParams) {
if (p.city) { this.city = p.city; }
+ if (p.costMult) { this.costMult = p.costMult; }
+ if (p.expMult) { this.expMult = p.expMult; }
+ if (p.infiltrationData) { this.infiltrationData = p.infiltrationData; }
if (p.name) { this.name = p.name; }
if (p.types) { this.types = p.types; }
if (p.techVendorMaxRam) { this.techVendorMaxRam = p.techVendorMaxRam; }
diff --git a/src/Locations/LocationsHelpers.js b/src/Locations/LocationsHelpers.js
deleted file mode 100644
index cfa7e3b98..000000000
--- a/src/Locations/LocationsHelpers.js
+++ /dev/null
@@ -1,9 +0,0 @@
-/**
- * Location and traveling-related helper functions.
- * Mostly used for UI
- */
-import { Player } from "../Player";
-
-import { Company } from "../Company/Company";
-import { getJobRequirementText } from "../Company/GetJobRequirementText";
-import * as posNames from "../Company/data/companypositionnames";
diff --git a/src/Locations/LocationsHelpers.ts b/src/Locations/LocationsHelpers.ts
new file mode 100644
index 000000000..2ee71338c
--- /dev/null
+++ b/src/Locations/LocationsHelpers.ts
@@ -0,0 +1,281 @@
+/**
+ * Location and traveling-related helper functions.
+ * Mostly used for UI
+ */
+import { CONSTANTS } from "../Constants";
+
+import { CityName } from "./data/CityNames";
+
+import { IPlayer } from "../PersonObjects/IPlayer";
+import { AllServers,
+ AddToAllServers } from "../Server/AllServers";
+import { Server } from "../Server/Server";
+import { getPurchaseServerCost,
+ purchaseRamForHomeComputer,
+ purchaseServer } from "../Server/ServerPurchases";
+import { SpecialServerIps } from "../Server/SpecialServerIps";
+import { Settings } from "../Settings/Settings";
+
+import { numeralWrapper } from "../ui/numeralFormat";
+
+import { dialogBoxCreate } from "../../utils/DialogBox";
+import { createRandomIp } from "../../utils/IPAddress";
+import { yesNoBoxGetYesButton,
+ yesNoBoxGetNoButton,
+ yesNoBoxClose,
+ yesNoBoxCreate,
+ yesNoTxtInpBoxGetYesButton,
+ yesNoTxtInpBoxGetNoButton,
+ yesNoTxtInpBoxClose,
+ yesNoTxtInpBoxCreate } from "../../utils/YesNoBox";
+
+import { createElement } from "../../utils/uiHelpers/createElement";
+import { createPopup } from "../../utils/uiHelpers/createPopup";
+import { createPopupCloseButton } from "../../utils/uiHelpers/createPopupCloseButton";
+import { removeElementById } from "../../utils/uiHelpers/removeElementById";
+
+/**
+ * Create a pop-up box that lets the player confirm traveling to a different city
+ * If settings are configured to suppress this popup, just instantly travel
+ * The actual "Travel" implementation is implemented in the UI, and is passed in
+ * as an argument
+ */
+type TravelFunction = (to: CityName) => void;
+export function createTravelPopup(destination: CityName, travelFn: TravelFunction) {
+ const cost = CONSTANTS.TravelCost;
+
+ if (Settings.SuppressTravelConfirmation) {
+ travelFn(destination);
+ return;
+ }
+
+ const yesBtn = yesNoBoxGetYesButton();
+ const noBtn = yesNoBoxGetNoButton();
+ if (yesBtn == null || noBtn == null) {
+ console.warn(`Could nto find YesNo pop-up box buttons`);
+ return;
+ }
+
+ yesBtn.innerHTML = "Yes";
+ yesBtn.addEventListener("click", () => {
+ yesNoBoxClose();
+ travelFn(destination);
+ return false;
+ });
+
+ noBtn.innerHTML = "No";
+ noBtn.addEventListener("click", () => {
+ yesNoBoxClose();
+ return false;
+ });
+
+ yesNoBoxCreate(`Would you like to travel to ${destination}? The trip will ` +
+ `cost ${numeralWrapper.formatMoney(cost)}`);
+}
+
+/**
+ * Create a pop-up box that lets the player purchase a server.
+ * @param ram - Amount of RAM (GB) on server
+ * @param p - Player object
+ */
+export function createPurchaseServerPopup(ram: number, p: IPlayer) {
+ const cost = getPurchaseServerCost(ram);
+ if (cost === Infinity) {
+ dialogBoxCreate("Something went wrong when trying to purchase this server. Please contact developer");
+ return;
+ }
+
+ var yesBtn = yesNoTxtInpBoxGetYesButton();
+ var noBtn = yesNoTxtInpBoxGetNoButton();
+ if (yesBtn == null || noBtn == null) { return; }
+ yesBtn.innerHTML = "Purchase Server";
+ noBtn.innerHTML = "Cancel";
+ yesBtn.addEventListener("click", function() {
+ purchaseServer(ram, p);
+ yesNoTxtInpBoxClose();
+ });
+ noBtn.addEventListener("click", function() {
+ yesNoTxtInpBoxClose();
+ });
+
+ yesNoTxtInpBoxCreate("Would you like to purchase a new server with " + ram +
+ "GB of RAM for $" + numeralWrapper.formatMoney(cost) + "?
" +
+ "Please enter the server hostname below: ");
+}
+
+/**
+ * Create a popup that lets the player start a Corporation
+ */
+export function createStartCorporationPopup(p: IPlayer) {
+ if (p.hasCorporation) { return; }
+
+ const popupId = "create-corporation-popup";
+ const txt = createElement("p", {
+ innerHTML: "Would you like to start a corporation? This will require $150b for registration " +
+ "and initial funding. This $150b can either be self-funded, or you can obtain " +
+ "the seed money from the government in exchange for 500 million shares
" +
+ "If you would like to start one, please enter a name for your corporation below:",
+ });
+
+ const nameInput = createElement("input", {
+ placeholder: "Corporation Name",
+ }) as HTMLInputElement;
+
+ const selfFundedButton = createElement("button", {
+ class: "popup-box-button",
+ innerText: "Self-Fund",
+ clickListener: () => {
+ if (!p.canAfford(150e9)) {
+ dialogBoxCreate("You don't have enough money to create a corporation! You need $150b");
+ return false;
+ }
+ p.loseMoney(150e9);
+
+ const companyName = nameInput.value;
+ if (companyName == null || companyName == "") {
+ dialogBoxCreate("Invalid company name!");
+ return false;
+ }
+
+ p.startCorporation(companyName);
+
+ const worldHeader = document.getElementById("world-menu-header");
+ if (worldHeader instanceof HTMLElement) {
+ worldHeader.click(); worldHeader.click();
+ }
+ dialogBoxCreate("Congratulations! You just self-funded your own corporation. You can visit " +
+ "and manage your company in the City");
+ removeElementById(popupId);
+ return false;
+ }
+ });
+
+ const seedMoneyButton = createElement("button", {
+ class: "popup-box-button",
+ innerText: "Use Seed Money",
+ clickListener: () => {
+ const companyName = nameInput.value;
+ if (companyName == null || companyName == "") {
+ dialogBoxCreate("Invalid company name!");
+ return false;
+ }
+
+ p.startCorporation(companyName, 500e6);
+
+ const worldHeader = document.getElementById("world-menu-header");
+ if (worldHeader instanceof HTMLElement) {
+ worldHeader.click(); worldHeader.click();
+ }
+ dialogBoxCreate("Congratulations! You just started your own corporation with government seed money. " +
+ "You can visit and manage your company in the City");
+ removeElementById(popupId);
+ return false;
+ }
+ })
+
+ const cancelBtn = createPopupCloseButton(popupId, { class: "popup-box-button" });
+
+ createPopup(popupId, [txt, nameInput, cancelBtn, selfFundedButton, seedMoneyButton]);
+ nameInput.focus();
+}
+
+/**
+ * Create a popup that lets the player upgrade the cores on his/her home computer
+ * @param p - Player object
+ */
+export function createUpgradeHomeCoresPopup(p: IPlayer) {
+ const currentCores = p.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
+ const allCosts = [0,
+ 10e9, // 1->2 Cores - 10 bn
+ 250e9, // 2->3 Cores - 250 bn
+ 5e12, // 3->4 Cores - 5 trillion
+ 100e12, // 4->5 Cores - 100 trillion
+ 1e15, // 5->6 Cores - 1 quadrillion
+ 20e15, // 6->7 Cores - 20 quadrillion
+ 200e15]; // 7->8 Cores - 200 quadrillion
+ const cost: number = allCosts[currentCores];
+
+ const yesBtn = yesNoBoxGetYesButton();
+ const noBtn = yesNoBoxGetNoButton();
+ if (yesBtn == null || noBtn == null) { return; }
+
+ yesBtn.innerHTML = "Purchase";
+ yesBtn.addEventListener("click", ()=>{
+ if (!p.canAfford(cost)) {
+ dialogBoxCreate("You do not have enough money to purchase an additional CPU Core for your home computer!");
+ } else {
+ p.loseMoney(cost);
+ p.getHomeComputer().cpuCores++;
+ dialogBoxCreate("You purchased an additional CPU Core for your home computer! It now has " +
+ p.getHomeComputer().cpuCores + " cores.");
+ }
+ yesNoBoxClose();
+ });
+
+ noBtn.innerHTML = "Cancel";
+ noBtn.addEventListener("click", ()=>{
+ yesNoBoxClose();
+ });
+
+ 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.
" +
+ "Purchasing an additional core (for a total of " + (p.getHomeComputer().cpuCores + 1) + ") will " +
+ "cost " + numeralWrapper.formatMoney(cost));
+}
+
+/**
+ * Create a popup that lets the player upgrade the RAM on his/her home computer
+ * @param p - Player object
+ */
+export function createUpgradeHomeRamPopup(p: IPlayer) {
+ const cost: number = p.getUpgradeHomeRamCost();
+ const ram: number = p.getHomeComputer().maxRam;
+
+ const yesBtn = yesNoBoxGetYesButton();
+ const noBtn = yesNoBoxGetNoButton();
+ if (yesBtn == null || noBtn == null) { return; }
+
+ yesBtn.innerText = "Purchase";
+ yesBtn.addEventListener("click", ()=>{
+ purchaseRamForHomeComputer(cost, p);
+ yesNoBoxClose();
+ });
+
+ noBtn.innerText = "Cancel";
+ noBtn.addEventListener("click", ()=>{
+ yesNoBoxClose();
+ });
+
+ yesNoBoxCreate("Would you like to purchase additional RAM for your home computer?
" +
+ "This will upgrade your RAM from " + ram + "GB to " + ram*2 + "GB.
- You have entered the Slums, a poverty-ridden district filled with gangs, criminals, and
- other shadowy entities. The city's government and police have neglected this area for years...
-
- In the Slums, you can commit crimes to earn money and experience. Crime attempts are not always
- successful. Your chance at successfully committing a crime is determined by your stats.
-