diff --git a/src/Corporation/Employee.ts b/src/Corporation/Employee.ts index b69aae632..d5053ff24 100644 --- a/src/Corporation/Employee.ts +++ b/src/Corporation/Employee.ts @@ -3,6 +3,7 @@ import { getRandomInt } from "../../utils/helpers/getRandomInt"; import { Generic_fromJSON, Generic_toJSON, Reviver } from "../../utils/JSONReviver"; import { createElement } from "../../utils/uiHelpers/createElement"; import { EmployeePositions } from "./EmployeePositions"; +import { ICorporation } from "./ICorporation"; import { numeralWrapper } from "../ui/numeralFormat"; import { formatNumber } from "../../utils/StringHelperFunctions"; @@ -86,7 +87,7 @@ export class Employee { return salary; } - calculateProductivity(corporation: any, industry: any): number { + calculateProductivity(corporation: ICorporation, industry: any): number { const effCre = this.cre * corporation.getEmployeeCreMultiplier() * industry.getEmployeeCreMultiplier(), effCha = this.cha * corporation.getEmployeeChaMultiplier() * industry.getEmployeeChaMultiplier(), effInt = this.int * corporation.getEmployeeIntMultiplier() * industry.getEmployeeIntMultiplier(), @@ -137,7 +138,7 @@ export class Employee { } //'panel' is the DOM element on which to create the UI - createUI(panel: any, corporation: any, industry: any): void { + createUI(panel: any, corporation: ICorporation, industry: any): void { const effCre = this.cre * corporation.getEmployeeCreMultiplier() * industry.getEmployeeCreMultiplier(), effCha = this.cha * corporation.getEmployeeChaMultiplier() * industry.getEmployeeChaMultiplier(), effInt = this.int * corporation.getEmployeeIntMultiplier() * industry.getEmployeeIntMultiplier(), diff --git a/src/Corporation/Industry.ts b/src/Corporation/Industry.ts index ebdb96835..18e3dbd11 100644 --- a/src/Corporation/Industry.ts +++ b/src/Corporation/Industry.ts @@ -19,6 +19,7 @@ import { dialogBoxCreate } from "../../utils/DialogBox"; import { isString } from "../../utils/helpers/isString"; import { MaterialSizes } from "./MaterialSizes"; import { Warehouse } from "./Warehouse"; +import { ICorporation } from "./ICorporation"; import { IndustryUpgrade, IndustryUpgrades } from "./IndustryUpgrades"; @@ -401,7 +402,7 @@ export class Industry { } } - process(marketCycles=1, state: string, company: any): void { + process(marketCycles=1, state: string, corporation: ICorporation): void { this.state = state; //At the start of a cycle, store and reset revenue/expenses @@ -426,7 +427,7 @@ export class Industry { let employeeSalary = 0; for (const officeLoc in this.offices) { if (this.offices[officeLoc] instanceof OfficeSpace) { - employeeSalary += this.offices[officeLoc].process(marketCycles, {industry:this, corporation:company}); + employeeSalary += this.offices[officeLoc].process(marketCycles, {industry:this, corporation:corporation}); } } this.thisCycleExpenses = this.thisCycleExpenses.plus(employeeSalary); @@ -440,7 +441,7 @@ export class Industry { this.popularity = Math.max(0, this.popularity); // Process Dreamsense gains - const popularityGain = company.getDreamSenseGain(), awarenessGain = popularityGain * 4; + const popularityGain = corporation.getDreamSenseGain(), awarenessGain = popularityGain * 4; if (popularityGain > 0) { this.popularity += (popularityGain * marketCycles); this.awareness += (awarenessGain * marketCycles); @@ -450,14 +451,14 @@ export class Industry { } // Process production, purchase, and import/export of materials - let res = this.processMaterials(marketCycles, company); + let res = this.processMaterials(marketCycles, corporation); if (Array.isArray(res)) { this.thisCycleRevenue = this.thisCycleRevenue.plus(res[0]); this.thisCycleExpenses = this.thisCycleExpenses.plus(res[1]); } // Process creation, production & sale of products - res = this.processProducts(marketCycles, company); + res = this.processProducts(marketCycles, corporation); if (Array.isArray(res)) { this.thisCycleRevenue = this.thisCycleRevenue.plus(res[0]); this.thisCycleExpenses = this.thisCycleExpenses.plus(res[1]); @@ -518,7 +519,7 @@ export class Industry { } //Process production, purchase, and import/export of materials - processMaterials(marketCycles=1, company: any): [number, number] { + processMaterials(marketCycles=1, corporation: ICorporation): [number, number] { let revenue = 0, expenses = 0; this.calculateProductionFactors(); @@ -588,7 +589,7 @@ export class Industry { //on the office's productivity const maxProd = this.getOfficeProductivity(office) * this.prodMult // Multiplier from materials - * company.getProductionMultiplier() + * corporation.getProductionMultiplier() * this.getProductionMultiplier(); // Multiplier from Research let prod; @@ -700,7 +701,7 @@ export class Industry { const sqrtDenominator = ((mat.qlt + .001) * marketFactor * businessFactor - * company.getSalesMultiplier() + * corporation.getSalesMultiplier() * advertisingFactor * this.getSalesMultiplier()); const denominator = Math.sqrt(sqrtNumerator / sqrtDenominator); @@ -750,7 +751,7 @@ export class Industry { * marketFactor * markup * businessFactor - * company.getSalesMultiplier() + * corporation.getSalesMultiplier() * advertisingFactor * this.getSalesMultiplier(); let sellAmt; @@ -822,9 +823,9 @@ export class Industry { if (amt === 0) { break; //None left } - for (let foo = 0; foo < company.divisions.length; ++foo) { - if (company.divisions[foo].name === exp.ind) { - const expIndustry = company.divisions[foo]; + for (let foo = 0; foo < corporation.divisions.length; ++foo) { + if (corporation.divisions[foo].name === exp.ind) { + const expIndustry = corporation.divisions[foo]; const expWarehouse = expIndustry.warehouses[exp.city]; if (!(expWarehouse instanceof Warehouse)) { console.error(`Invalid export! ${expIndustry.name} ${exp.city}`); @@ -872,7 +873,7 @@ export class Industry { if (office instanceof OfficeSpace) { this.sciResearch.qty += (.004 * Math.pow(office.employeeProd[EmployeePositions.RandD], 0.5) - * company.getScientificResearchMultiplier() + * corporation.getScientificResearchMultiplier() * this.getScientificResearchMultiplier()); } } @@ -880,7 +881,7 @@ export class Industry { } //Process production & sale of this industry's FINISHED products (including all of their stats) - processProducts(marketCycles=1, corporation: any): [number, number] { + processProducts(marketCycles=1, corporation: ICorporation): [number, number] { let revenue = 0; const expenses = 0; @@ -926,7 +927,7 @@ export class Industry { } //Processes FINISHED products - processProduct(marketCycles=1, product: Product, corporation: any): number { + processProduct(marketCycles=1, product: Product, corporation: ICorporation): number { let totalProfit = 0; for (let i = 0; i < CorporationConstants.Cities.length; ++i) { const city = CorporationConstants.Cities[i], office = this.offices[city], warehouse = this.warehouses[city]; diff --git a/src/Corporation/ui/BribeFactionPopup.tsx b/src/Corporation/ui/BribeFactionPopup.tsx index e50ebfb11..3ded57c1c 100644 --- a/src/Corporation/ui/BribeFactionPopup.tsx +++ b/src/Corporation/ui/BribeFactionPopup.tsx @@ -5,10 +5,11 @@ import { CorporationConstants } from "../data/Constants"; import { numeralWrapper } from "../../ui/numeralFormat"; import { removePopup } from "../../ui/React/createPopup"; import { dialogBoxCreate } from "../../../utils/DialogBox"; +import { ICorporation } from "../ICorporation"; interface IProps { popupId: string; - corp: any; + corp: ICorporation; player: IPlayer; } @@ -39,7 +40,7 @@ export function BribeFactionPopup(props: IProps): React.ReactElement { return "ERROR: Invalid value(s) entered"; } else if (props.corp.funds.lt(money)) { return "ERROR: You do not have this much money to bribe with"; - } else if (props.corp.stock > props.corp.numShares) { + } else if (stock > props.corp.numShares) { return "ERROR: You do not have this many shares to bribe with"; } else { return "You will gain " + numeralWrapper.formatReputation(repGain(money, stock)) + diff --git a/src/Corporation/ui/BuybackSharesPopup.tsx b/src/Corporation/ui/BuybackSharesPopup.tsx index 6b45d87ac..eda57a330 100644 --- a/src/Corporation/ui/BuybackSharesPopup.tsx +++ b/src/Corporation/ui/BuybackSharesPopup.tsx @@ -3,11 +3,12 @@ import { IPlayer } from "../../PersonObjects/IPlayer"; import { removePopup } from "../../ui/React/createPopup"; import { numeralWrapper } from "../../ui/numeralFormat"; import { dialogBoxCreate } from "../../../utils/DialogBox"; +import { ICorporation } from "../ICorporation"; interface IProps { player: IPlayer; popupId: string; - corp: any; + corp: ICorporation; } // Create a popup that lets the player buyback shares @@ -39,7 +40,7 @@ export function BuybackSharesPopup(props: IProps): React.ReactElement { if (isNaN(props.corp.issuedShares)) { console.warn("Corporation issuedShares is NaN: " + props.corp.issuedShares); console.warn("Converting to number now"); - const res = parseInt(props.corp.issuedShares); + const res = props.corp.issuedShares; if (isNaN(res)) { props.corp.issuedShares = 0; } else { @@ -49,7 +50,7 @@ export function BuybackSharesPopup(props: IProps): React.ReactElement { props.corp.issuedShares -= shares; props.player.loseMoney(shares * buybackPrice); removePopup(props.popupId); - props.corp.rerender(); + props.corp.rerender(props.player); } } diff --git a/src/Corporation/ui/DiscontinueProductPopup.tsx b/src/Corporation/ui/DiscontinueProductPopup.tsx index d22b139f3..bc81a7567 100644 --- a/src/Corporation/ui/DiscontinueProductPopup.tsx +++ b/src/Corporation/ui/DiscontinueProductPopup.tsx @@ -1,11 +1,14 @@ import React from 'react'; import { removePopup } from "../../ui/React/createPopup"; +import { ICorporation } from "../ICorporation"; +import { IPlayer } from "../../PersonObjects/IPlayer"; interface IProps { product: any; industry: any; - corp: any; + corp: ICorporation; popupId: string; + player: IPlayer; } // Create a popup that lets the player discontinue a product @@ -13,7 +16,7 @@ export function DiscontinueProductPopup(props: IProps): React.ReactElement { function discontinue(): void { props.industry.discontinueProduct(props.product); removePopup(props.popupId); - props.corp.rerender(); + props.corp.rerender(props.player); } return (<> diff --git a/src/Corporation/ui/ExpandNewCityPopup.tsx b/src/Corporation/ui/ExpandNewCityPopup.tsx index c9d91087f..ba02f6c81 100644 --- a/src/Corporation/ui/ExpandNewCityPopup.tsx +++ b/src/Corporation/ui/ExpandNewCityPopup.tsx @@ -5,10 +5,11 @@ import { CorporationConstants } from "../data/Constants"; import { removePopup } from "../../ui/React/createPopup"; import { dialogBoxCreate } from "../../../utils/DialogBox"; import { OfficeSpace } from "../OfficeSpace"; +import { ICorporation } from "../ICorporation"; interface IProps { popupId: string; - corp: any; + corp: ICorporation; division: IDivision; cityStateSetter: (city: string) => void; } diff --git a/src/Corporation/ui/ExportPopup.tsx b/src/Corporation/ui/ExportPopup.tsx index d4fe7bca7..39e5936be 100644 --- a/src/Corporation/ui/ExportPopup.tsx +++ b/src/Corporation/ui/ExportPopup.tsx @@ -1,10 +1,11 @@ import React, { useState } from 'react'; import { dialogBoxCreate } from "../../../utils/DialogBox"; import { removePopup } from "../../ui/React/createPopup"; +import { ICorporation } from "../ICorporation"; interface IProps { mat: any; - corp: any; + corp: ICorporation; popupId: string; } diff --git a/src/Corporation/ui/FindInvestorsPopup.tsx b/src/Corporation/ui/FindInvestorsPopup.tsx index ee10eb87b..3c52331ba 100644 --- a/src/Corporation/ui/FindInvestorsPopup.tsx +++ b/src/Corporation/ui/FindInvestorsPopup.tsx @@ -2,10 +2,13 @@ import React from 'react'; import { removePopup } from "../../ui/React/createPopup"; import { numeralWrapper } from "../../ui/numeralFormat"; import { CorporationConstants } from "../data/Constants"; +import { ICorporation } from "../ICorporation"; +import { IPlayer } from "../../PersonObjects/IPlayer"; interface IProps { - corp: any; + corp: ICorporation; popupId: string; + player: IPlayer; } // Create a popup that lets the player manage exports @@ -40,7 +43,7 @@ export function FindInvestorsPopup(props: IProps): React.ReactElement { props.corp.fundingRound++; props.corp.addFunds(funding); props.corp.numShares -= investShares; - props.corp.rerender(); + props.corp.rerender(props.player); removePopup(props.popupId); } return (<> diff --git a/src/Corporation/ui/GoPublicPopup.tsx b/src/Corporation/ui/GoPublicPopup.tsx index 60f874d80..305c502d4 100644 --- a/src/Corporation/ui/GoPublicPopup.tsx +++ b/src/Corporation/ui/GoPublicPopup.tsx @@ -2,10 +2,13 @@ import React, { useState } from 'react'; import { dialogBoxCreate } from "../../../utils/DialogBox"; import { removePopup } from "../../ui/React/createPopup"; import { numeralWrapper } from "../../ui/numeralFormat"; +import { ICorporation } from "../ICorporation"; +import { IPlayer } from "../../PersonObjects/IPlayer"; interface IProps { - corp: any; + corp: ICorporation; popupId: string; + player: IPlayer; } // Create a popup that lets the player manage exports @@ -29,7 +32,7 @@ export function GoPublicPopup(props: IProps): React.ReactElement { props.corp.issuedShares = numShares; props.corp.numShares -= numShares; props.corp.addFunds(numShares * initialSharePrice); - props.corp.rerender(); + props.corp.rerender(props.player); dialogBoxCreate(`You took your ${props.corp.name} public and earned ` + `${numeralWrapper.formatMoney(numShares * initialSharePrice)} in your IPO`); removePopup(props.popupId); diff --git a/src/Corporation/ui/Industry.tsx b/src/Corporation/ui/Industry.tsx index 5254c3676..c96596212 100644 --- a/src/Corporation/ui/Industry.tsx +++ b/src/Corporation/ui/Industry.tsx @@ -7,11 +7,13 @@ import { IndustryOverview } from "./IndustryOverview"; import { IndustryWarehouse } from "./IndustryWarehouse"; import { ICorporation } from "../ICorporation"; import { CorporationRouting } from "./Routing"; +import { IPlayer } from "../../PersonObjects/IPlayer"; interface IProps { routing: CorporationRouting; corp: ICorporation; currentCity: string; + player: IPlayer; } export function Industry(props: IProps): React.ReactElement { @@ -19,16 +21,19 @@ export function Industry(props: IProps): React.ReactElement {