diff --git a/src/Corporation/Actions.ts b/src/Corporation/Actions.ts index fa4d383a4..2492ac999 100644 --- a/src/Corporation/Actions.ts +++ b/src/Corporation/Actions.ts @@ -14,7 +14,6 @@ import { CorporationUpgrade } from "./data/CorporationUpgrades"; import { Cities } from "../Locations/Cities"; import { EmployeePositions } from "./EmployeePositions"; import { Employee } from "./Employee"; -import { IndustryUpgrades } from "./IndustryUpgrades"; import { ResearchMap } from "./ResearchMap"; import { isRelevantMaterial } from "./ui/Helpers"; @@ -334,7 +333,7 @@ export function UpgradeOfficeSize(corp: ICorporation, office: OfficeSpace, size: } export function BuyCoffee(corp: ICorporation, office: OfficeSpace): boolean { - const cost = 500e3 * office.employees.length; + const cost = office.getCoffeeCost(); if (corp.funds < cost) { return false; } if (!office.setCoffee()) { return false; } @@ -381,15 +380,11 @@ export function UpgradeWarehouse(corp: ICorporation, division: IIndustry, wareho corp.funds = corp.funds - sizeUpgradeCost; } -export function HireAdVert(corp: ICorporation, division: IIndustry, office: OfficeSpace): void { - const upgrade = IndustryUpgrades[1]; - const cost = upgrade[1] * Math.pow(upgrade[2], division.upgrades[1]); +export function HireAdVert(corp: ICorporation, division: IIndustry): void { + const cost = division.getAdVertCost(); if (corp.funds < cost) return; corp.funds = corp.funds - cost; - division.upgrade(upgrade, { - corporation: corp, - office: office, - }); + division.applyAdVert(corp); } export function MakeProduct( diff --git a/src/Corporation/IIndustry.ts b/src/Corporation/IIndustry.ts index 1cb5737ea..7b465720d 100644 --- a/src/Corporation/IIndustry.ts +++ b/src/Corporation/IIndustry.ts @@ -3,7 +3,6 @@ import { Warehouse } from "./Warehouse"; import { ICorporation } from "./ICorporation"; import { OfficeSpace } from "./OfficeSpace"; import { Product } from "./Product"; -import { IndustryUpgrade } from "./IndustryUpgrades"; export interface IIndustry { name: string; @@ -36,12 +35,11 @@ export interface IIndustry { thisCycleRevenue: number; thisCycleExpenses: number; - upgrades: number[]; - state: string; newInd: boolean; warehouses: { [key: string]: Warehouse | 0 }; offices: { [key: string]: OfficeSpace | 0 }; + numAdVerts: number; init(): void; getProductDescriptionText(): string; @@ -56,7 +54,8 @@ export interface IIndustry { processProducts(marketCycles: number, corporation: ICorporation): [number, number]; processProduct(marketCycles: number, product: Product, corporation: ICorporation): number; discontinueProduct(product: Product): void; - upgrade(upgrade: IndustryUpgrade, refs: { corporation: ICorporation; office: OfficeSpace }): void; + getAdVertCost(): number; + applyAdVert(corporation: ICorporation): void; getOfficeProductivity(office: OfficeSpace, params?: { forProduct?: boolean }): number; getBusinessFactor(office: OfficeSpace): number; getAdvertisingFactors(): [number, number, number, number]; diff --git a/src/Corporation/Industry.ts b/src/Corporation/Industry.ts index f2a12e129..3c00ae379 100644 --- a/src/Corporation/Industry.ts +++ b/src/Corporation/Industry.ts @@ -14,7 +14,6 @@ import { MaterialSizes } from "./MaterialSizes"; import { Warehouse } from "./Warehouse"; import { ICorporation } from "./ICorporation"; import { IIndustry } from "./IIndustry"; -import { IndustryUpgrade, IndustryUpgrades } from "./IndustryUpgrades"; interface IParams { name?: string; @@ -59,9 +58,6 @@ export class Industry implements IIndustry { thisCycleRevenue: number; thisCycleExpenses: number; - //Upgrades - upgrades: number[] = Array(Object.keys(IndustryUpgrades).length).fill(0); - state = "START"; newInd = true; @@ -81,6 +77,8 @@ export class Industry implements IIndustry { [CityName.Volhaven]: 0, }; + numAdVerts = 0; + constructor(params: IParams = {}) { this.name = params.name ? params.name : ""; this.type = params.type ? params.type : Industries.Agriculture; @@ -1262,38 +1260,19 @@ export class Industry implements IIndustry { } } - upgrade(upgrade: IndustryUpgrade, refs: { corporation: ICorporation; office: OfficeSpace }): void { - const corporation = refs.corporation; - const office = refs.office; - const upgN = upgrade[0]; - while (this.upgrades.length <= upgN) { - this.upgrades.push(0); - } - ++this.upgrades[upgN]; + getAdVertCost(): number { + return 1e9 * Math.pow(1.06, this.numAdVerts); + } - switch (upgN) { - case 0: { - //Coffee, 5% energy per employee - for (let i = 0; i < office.employees.length; ++i) { - office.employees[i].ene = Math.min(office.employees[i].ene * 1.05, office.maxEne); - } - break; - } - case 1: { - //AdVert.Inc, - const advMult = corporation.getAdvertisingMultiplier() * this.getAdvertisingMultiplier(); - const awareness = (this.awareness + 3 * advMult) * (1.01 * advMult); - this.awareness = Math.min(awareness, Number.MAX_VALUE); + applyAdVert(corporation: ICorporation): void { + const advMult = corporation.getAdvertisingMultiplier() * this.getAdvertisingMultiplier(); + const awareness = (this.awareness + 3 * advMult) * (1.01 * advMult); + this.awareness = Math.min(awareness, Number.MAX_VALUE); - const popularity = (this.popularity + 1 * advMult) * ((1 + getRandomInt(1, 3) / 100) * advMult); - this.popularity = Math.min(popularity, Number.MAX_VALUE); - break; - } - default: { - console.error(`Un-implemented function index: ${upgN}`); - break; - } - } + const popularity = (this.popularity + 1 * advMult) * ((1 + getRandomInt(1, 3) / 100) * advMult); + this.popularity = Math.min(popularity, Number.MAX_VALUE); + + ++this.numAdVerts; } // Returns how much of a material can be produced based of office productivity (employee stats) diff --git a/src/Corporation/IndustryUpgrades.ts b/src/Corporation/IndustryUpgrades.ts deleted file mode 100644 index 6190fabf4..000000000 --- a/src/Corporation/IndustryUpgrades.ts +++ /dev/null @@ -1,22 +0,0 @@ -import { IMap } from "../types"; - -export type IndustryUpgrade = [number, number, number, number, string, string]; - -// Industry upgrades -// The data structure is an array with the following format: -// [index in array, base price, price mult, benefit mult (if applicable), name, desc] -export const IndustryUpgrades: IMap = { - "0": [0, 500e3, 1, 1.05, "Coffee", "Provide your employees with coffee, increasing their energy by 5%."], - "1": [ - 1, - 1e9, - 1.06, - 1.03, - "AdVert.Inc", - "Hire AdVert.Inc to advertise your company. Each level of " + - "this upgrade grants your company a static increase of 3 and 1 to its awareness and " + - "popularity, respectively. It will then increase your company's awareness by 1%, and its popularity " + - "by a random percentage between 1% and 3%. These effects are increased by other upgrades " + - "that increase the power of your advertising.", - ], -}; diff --git a/src/Corporation/OfficeSpace.ts b/src/Corporation/OfficeSpace.ts index a299c37ea..7f662a769 100644 --- a/src/Corporation/OfficeSpace.ts +++ b/src/Corporation/OfficeSpace.ts @@ -251,6 +251,10 @@ export class OfficeSpace { return count === target; } + getCoffeeCost(): number { + return 500e3 * this.employees.length; + } + setCoffee(mult = 1.05): boolean { if (mult > 1 && this.coffeeMult === 0 && !this.autoCoffee && this.employees.length > 0) { this.coffeeMult = mult; diff --git a/src/Corporation/ui/IndustryOverview.tsx b/src/Corporation/ui/IndustryOverview.tsx index a0e687fb5..6c75830d1 100644 --- a/src/Corporation/ui/IndustryOverview.tsx +++ b/src/Corporation/ui/IndustryOverview.tsx @@ -2,11 +2,9 @@ // (top-left panel in the Industry UI) import React, { useState } from "react"; -import { BuyCoffee } from "../Actions"; - import { OfficeSpace } from "../OfficeSpace"; import { Industries } from "../IndustryData"; -import { IndustryUpgrades } from "../IndustryUpgrades"; +import { BuyCoffee, HireAdVert } from "../Actions"; import { numeralWrapper } from "../../ui/numeralFormat"; import { createProgressBarText } from "../../utils/helpers/createProgressBarText"; import { MakeProductModal } from "./modals/MakeProductModal"; @@ -209,69 +207,40 @@ function Text(): React.ReactElement { setResearchOpen(false)} industry={division} /> + + Purchases & Upgrades + + + + + + + + + Hire AdVert.Inc to advertise your company. Each level of + this upgrade grants your company a static increase of 3 and 1 to its awareness and + popularity, respectively. It will then increase your company's awareness by 1%, and its popularity + by a random percentage between 1% and 3%. These effects are increased by other upgrades + that increase the power of your advertising. + + }> + + + + + ); } -function Upgrades(props: { office: OfficeSpace; rerender: () => void }): React.ReactElement { - const corp = useCorporation(); - const division = useDivision(); - const upgrades = []; - for (const index of Object.keys(IndustryUpgrades)) { - const upgrade = IndustryUpgrades[index]; - - // AutoBrew research disables the Coffee upgrade - if (division.hasResearch("AutoBrew") && upgrade[4] === "Coffee") { - continue; - } - - const i = upgrade[0]; - const baseCost = upgrade[1]; - const priceMult = upgrade[2]; - - let cost = 0; - let disabled = false; - switch (i) { - case 0: //Coffee, cost is static per employee - cost = props.office.employees.length * baseCost; - disabled = cost > corp.funds || props.office.coffeeMult > 0; - break; - default: - cost = baseCost * Math.pow(priceMult, division.upgrades[i]); - disabled = cost > corp.funds; - break; - } - - function onClick(): void { - if (corp.funds < cost) return; - corp.funds = corp.funds - cost; - - if (i == 0) { - BuyCoffee(corp, props.office); - } else { - division.upgrade(upgrade, { - corporation: corp, - office: props.office, - }); - } - props.rerender(); - } - - upgrades.push( - - - - - , - ); - } - - return <>{upgrades}; -} - interface IProps { currentCity: string; office: OfficeSpace; @@ -285,8 +254,6 @@ export function IndustryOverview(props: IProps): React.ReactElement {
- Purchases & Upgrades -
{division.makesProducts && }
); diff --git a/src/NetscriptFunctions/Corporation.ts b/src/NetscriptFunctions/Corporation.ts index 0fc8804fc..212b7a3ff 100644 --- a/src/NetscriptFunctions/Corporation.ts +++ b/src/NetscriptFunctions/Corporation.ts @@ -64,7 +64,6 @@ import { calculateIntelligenceBonus } from "../PersonObjects/formulas/intelligen import { Industry } from "../Corporation/Industry"; import { IndustryResearchTrees, IndustryStartingCosts } from "../Corporation/IndustryData"; import { CorporationConstants } from "../Corporation/data/Constants"; -import { IndustryUpgrades } from "../Corporation/IndustryUpgrades"; import { ResearchMap } from "../Corporation/ResearchMap"; import { Factions } from "../Faction/Factions"; import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers"; @@ -303,7 +302,7 @@ export function NetscriptCorporation(player: IPlayer, workerScript: WorkerScript lastCycleExpenses: division.lastCycleExpenses, thisCycleRevenue: division.thisCycleRevenue, thisCycleExpenses: division.thisCycleExpenses, - upgrades: division.upgrades.slice(), + upgrades: [0, division.numAdVerts], cities: cities, products: division.products === undefined ? [] : Object.keys(division.products), makesProducts: division.makesProducts, @@ -659,8 +658,7 @@ export function NetscriptCorporation(player: IPlayer, workerScript: WorkerScript checkAccess(ctx, 8); const divisionName = ctx.helper.string("divisionName", _divisionName); const division = getDivision(divisionName); - const upgrade = IndustryUpgrades[1]; - return upgrade[1] * Math.pow(upgrade[2], division.upgrades[1]); + return division.getAdVertCost(); }, getHireAdVertCount: (ctx: NetscriptContext) => @@ -668,7 +666,7 @@ export function NetscriptCorporation(player: IPlayer, workerScript: WorkerScript checkAccess(ctx, 8); const divisionName = ctx.helper.string("divisionName", _divisionName); const division = getDivision(divisionName); - return division.upgrades[1]; + return division.numAdVerts; }, getResearchCost: (ctx: NetscriptContext) => @@ -802,7 +800,7 @@ export function NetscriptCorporation(player: IPlayer, workerScript: WorkerScript checkAccess(ctx, 8); const divisionName = ctx.helper.string("divisionName", _divisionName); const corporation = getCorporation(); - HireAdVert(corporation, getDivision(divisionName), getOffice(divisionName, "Sector-12")); + HireAdVert(corporation, getDivision(divisionName)); }, research: (ctx: NetscriptContext) =>