corp: classes are types

This commit is contained in:
Snarling 2022-09-20 06:47:54 -04:00
parent 557bc12562
commit bc7c15ad77
23 changed files with 100 additions and 244 deletions

@ -1,8 +1,6 @@
import { Player } from "../Player";
import { MaterialSizes } from "./MaterialSizes";
import { ICorporation } from "./ICorporation";
import { Corporation } from "./Corporation";
import { IIndustry } from "./IIndustry";
import { IndustryStartingCosts, IndustryResearchTrees } from "./IndustryData";
import { Industry } from "./Industry";
import { CorporationConstants } from "./data/Constants";
@ -17,7 +15,7 @@ import { EmployeePositions } from "./EmployeePositions";
import { ResearchMap } from "./ResearchMap";
import { isRelevantMaterial } from "./ui/Helpers";
export function NewIndustry(corporation: ICorporation, industry: string, name: string): void {
export function NewIndustry(corporation: Corporation, industry: string, name: string): void {
if (corporation.divisions.find(({ type }) => industry == type))
throw new Error(`You have already expanded into the ${industry} industry!`);
@ -47,7 +45,7 @@ export function NewIndustry(corporation: ICorporation, industry: string, name: s
}
}
export function NewCity(corporation: ICorporation, division: IIndustry, city: string): void {
export function NewCity(corporation: Corporation, division: Industry, city: string): void {
if (corporation.funds < CorporationConstants.OfficeInitialCost) {
throw new Error("You don't have enough company funds to open a new office!");
}
@ -61,7 +59,7 @@ export function NewCity(corporation: ICorporation, division: IIndustry, city: st
});
}
export function UnlockUpgrade(corporation: ICorporation, upgrade: CorporationUnlockUpgrade): void {
export function UnlockUpgrade(corporation: Corporation, upgrade: CorporationUnlockUpgrade): void {
if (corporation.funds < upgrade.price) {
throw new Error("Insufficient funds");
}
@ -71,7 +69,7 @@ export function UnlockUpgrade(corporation: ICorporation, upgrade: CorporationUnl
corporation.unlock(upgrade);
}
export function LevelUpgrade(corporation: ICorporation, upgrade: CorporationUpgrade): void {
export function LevelUpgrade(corporation: Corporation, upgrade: CorporationUpgrade): void {
const baseCost = upgrade.basePrice;
const priceMult = upgrade.priceMult;
const level = corporation.upgrades[upgrade.index];
@ -83,7 +81,7 @@ export function LevelUpgrade(corporation: ICorporation, upgrade: CorporationUpgr
}
}
export function IssueDividends(corporation: ICorporation, rate: number): void {
export function IssueDividends(corporation: Corporation, rate: number): void {
if (isNaN(rate) || rate < 0 || rate > CorporationConstants.DividendMaxRate) {
throw new Error(`Invalid value. Must be an number between 0 and ${CorporationConstants.DividendMaxRate}`);
}
@ -252,7 +250,7 @@ export function BuyMaterial(material: Material, amt: number): void {
material.buy = amt;
}
export function BulkPurchase(corp: ICorporation, warehouse: Warehouse, material: Material, amt: number): void {
export function BulkPurchase(corp: Corporation, warehouse: Warehouse, material: Material, amt: number): void {
const matSize = MaterialSizes[material.name];
const maxAmount = (warehouse.size - warehouse.sizeUsed) / matSize;
if (isNaN(amt) || amt < 0) {
@ -270,7 +268,7 @@ export function BulkPurchase(corp: ICorporation, warehouse: Warehouse, material:
}
}
export function SellShares(corporation: ICorporation, numShares: number): number {
export function SellShares(corporation: Corporation, numShares: number): number {
if (isNaN(numShares)) throw new Error("Invalid value for number of shares");
if (numShares < 0) throw new Error("Invalid value for number of shares");
if (numShares > corporation.numShares) throw new Error("You don't have that many shares to sell!");
@ -290,7 +288,7 @@ export function SellShares(corporation: ICorporation, numShares: number): number
return profit;
}
export function BuyBackShares(corporation: ICorporation, numShares: number): boolean {
export function BuyBackShares(corporation: Corporation, numShares: number): boolean {
if (isNaN(numShares)) throw new Error("Invalid value for number of shares");
if (numShares < 0) throw new Error("Invalid value for number of shares");
if (numShares > corporation.issuedShares) throw new Error("You don't have that many shares to buy!");
@ -318,7 +316,7 @@ export function AutoAssignJob(office: OfficeSpace, job: string, count: number):
return office.autoAssignJob(job, count);
}
export function UpgradeOfficeSize(corp: ICorporation, office: OfficeSpace, size: number): void {
export function UpgradeOfficeSize(corp: Corporation, office: OfficeSpace, size: number): void {
const initialPriceMult = Math.round(office.size / CorporationConstants.OfficeInitialSize);
const costMultiplier = 1.09;
// Calculate cost to upgrade size by 15 employees
@ -332,7 +330,7 @@ export function UpgradeOfficeSize(corp: ICorporation, office: OfficeSpace, size:
corp.funds = corp.funds - cost;
}
export function BuyCoffee(corp: ICorporation, office: OfficeSpace): boolean {
export function BuyCoffee(corp: Corporation, office: OfficeSpace): boolean {
const cost = office.getCoffeeCost();
if (corp.funds < cost) {
return false;
@ -346,7 +344,7 @@ export function BuyCoffee(corp: ICorporation, office: OfficeSpace): boolean {
return true;
}
export function ThrowParty(corp: ICorporation, office: OfficeSpace, costPerEmployee: number): number {
export function ThrowParty(corp: Corporation, office: OfficeSpace, costPerEmployee: number): number {
const mult = 1 + costPerEmployee / 10e6;
const cost = costPerEmployee * office.employees.length;
if (corp.funds < cost) {
@ -361,7 +359,7 @@ export function ThrowParty(corp: ICorporation, office: OfficeSpace, costPerEmplo
return mult;
}
export function PurchaseWarehouse(corp: ICorporation, division: IIndustry, city: string): void {
export function PurchaseWarehouse(corp: Corporation, division: Industry, city: string): void {
if (corp.funds < CorporationConstants.WarehouseInitialCost) return;
if (division.warehouses[city] instanceof Warehouse) return;
division.warehouses[city] = new Warehouse({
@ -380,7 +378,7 @@ export function UpgradeWarehouseCost(warehouse: Warehouse, amt: number): number
);
}
export function UpgradeWarehouse(corp: ICorporation, division: IIndustry, warehouse: Warehouse, amt = 1): void {
export function UpgradeWarehouse(corp: Corporation, division: Industry, warehouse: Warehouse, amt = 1): void {
const sizeUpgradeCost = UpgradeWarehouseCost(warehouse, amt);
if (corp.funds < sizeUpgradeCost) return;
warehouse.level += amt;
@ -388,7 +386,7 @@ export function UpgradeWarehouse(corp: ICorporation, division: IIndustry, wareho
corp.funds = corp.funds - sizeUpgradeCost;
}
export function HireAdVert(corp: ICorporation, division: IIndustry): void {
export function HireAdVert(corp: Corporation, division: Industry): void {
const cost = division.getAdVertCost();
if (corp.funds < cost) return;
corp.funds = corp.funds - cost;
@ -396,8 +394,8 @@ export function HireAdVert(corp: ICorporation, division: IIndustry): void {
}
export function MakeProduct(
corp: ICorporation,
division: IIndustry,
corp: Corporation,
division: Industry,
city: string,
productName: string,
designInvest: number,
@ -449,7 +447,7 @@ export function MakeProduct(
products[product.name] = product;
}
export function Research(division: IIndustry, researchName: string): void {
export function Research(division: Industry, researchName: string): void {
const researchTree = IndustryResearchTrees[division.type];
if (researchTree === undefined) throw new Error(`No research tree for industry '${division.type}'`);
const allResearch = researchTree.getAllNodes();

@ -2,8 +2,8 @@ import { CorporationConstants } from "./data/Constants";
import { getRandomInt } from "../utils/helpers/getRandomInt";
import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver";
import { EmployeePositions } from "./EmployeePositions";
import { ICorporation } from "./ICorporation";
import { IIndustry } from "./IIndustry";
import { Corporation } from "./Corporation";
import { Industry } from "./Industry";
interface IParams {
name?: string;
@ -77,7 +77,7 @@ export class Employee {
return salary;
}
calculateProductivity(corporation: ICorporation, industry: IIndustry): number {
calculateProductivity(corporation: Corporation, industry: Industry): number {
const effCre = this.cre * corporation.getEmployeeCreMultiplier() * industry.getEmployeeCreMultiplier(),
effCha = this.cha * corporation.getEmployeeChaMultiplier() * industry.getEmployeeChaMultiplier(),
effInt = this.int * corporation.getEmployeeIntMultiplier() * industry.getEmployeeIntMultiplier(),

@ -1,62 +0,0 @@
import { Industry } from "./Industry";
import { CorporationUnlockUpgrade } from "./data/CorporationUnlockUpgrades";
import { CorporationUpgrade } from "./data/CorporationUpgrades";
import { CorporationState } from "./CorporationState";
import { IReviverValue } from "../utils/JSONReviver";
export interface ICorporation {
name: string;
divisions: Industry[];
funds: number;
revenue: number;
expenses: number;
fundingRound: number;
public: boolean;
totalShares: number;
numShares: number;
shareSalesUntilPriceUpdate: number;
shareSaleCooldown: number;
issueNewSharesCooldown: number;
dividendRate: number;
dividendTax: number;
issuedShares: number;
sharePrice: number;
storedCycles: number;
valuation: number;
unlockUpgrades: number[];
upgrades: number[];
upgradeMultipliers: number[];
state: CorporationState;
addFunds(amt: number): void;
getState(): string;
storeCycles(numCycles: number): void;
process(): void;
determineValuation(): void;
determineCycleValuation(): number;
getTargetSharePrice(): number;
updateSharePrice(): void;
immediatelyUpdateSharePrice(): void;
calculateShareSale(numShares: number): [number, number, number];
convertCooldownToString(cd: number): string;
unlock(upgrade: CorporationUnlockUpgrade): void;
upgrade(upgrade: CorporationUpgrade): void;
getProductionMultiplier(): number;
getStorageMultiplier(): number;
getDreamSenseGain(): number;
getAdvertisingMultiplier(): number;
getEmployeeCreMultiplier(): number;
getEmployeeChaMultiplier(): number;
getEmployeeIntMultiplier(): number;
getEmployeeEffMultiplier(): number;
getSalesMultiplier(): number;
getScientificResearchMultiplier(): number;
getStarterGuide(): void;
updateDividendTax(): void;
getCycleDividends(): number;
toJSON(): IReviverValue;
}

@ -1,78 +0,0 @@
import { Material } from "./Material";
import { Warehouse } from "./Warehouse";
import { ICorporation } from "./ICorporation";
import { OfficeSpace } from "./OfficeSpace";
import { Product } from "./Product";
import { IReviverValue } from "../utils/JSONReviver";
export interface IIndustry {
name: string;
type: string;
sciResearch: Material;
researched: { [key: string]: boolean | undefined };
reqMats: { [key: string]: number | undefined };
prodMats: string[];
products: { [key: string]: Product | undefined };
makesProducts: boolean;
awareness: number;
popularity: number;
startingCost: number;
reFac: number;
sciFac: number;
hwFac: number;
robFac: number;
aiFac: number;
advFac: number;
prodMult: number;
// Decimal
lastCycleRevenue: number;
lastCycleExpenses: number;
thisCycleRevenue: number;
thisCycleExpenses: number;
state: string;
newInd: boolean;
warehouses: { [key: string]: Warehouse | 0 };
offices: { [key: string]: OfficeSpace | 0 };
numAdVerts: number;
init(): void;
getProductDescriptionText(): string;
getMaximumNumberProducts(): number;
hasMaximumNumberProducts(): boolean;
calculateProductionFactors(): void;
updateWarehouseSizeUsed(warehouse: Warehouse): void;
process(marketCycles: number, state: string, corporation: ICorporation): void;
processMaterialMarket(): void;
processProductMarket(marketCycles: number): void;
processMaterials(marketCycles: number, corporation: ICorporation): [number, number];
processProducts(marketCycles: number, corporation: ICorporation): [number, number];
processProduct(marketCycles: number, product: Product, corporation: ICorporation): number;
resetImports(state: string): void;
discontinueProduct(product: Product): void;
getAdVertCost(): number;
applyAdVert(corporation: ICorporation): void;
getOfficeProductivity(office: OfficeSpace, params?: { forProduct?: boolean }): number;
getBusinessFactor(office: OfficeSpace): number;
getAdvertisingFactors(): [number, number, number, number];
getMarketFactor(mat: { dmd: number; cmp: number }): number;
hasResearch(name: string): boolean;
updateResearchTree(): void;
getAdvertisingMultiplier(): number;
getEmployeeChaMultiplier(): number;
getEmployeeCreMultiplier(): number;
getEmployeeEffMultiplier(): number;
getEmployeeIntMultiplier(): number;
getProductionMultiplier(): number;
getProductProductionMultiplier(): number;
getSalesMultiplier(): number;
getScientificResearchMultiplier(): number;
getStorageMultiplier(): number;
toJSON(): IReviverValue;
}

@ -12,16 +12,15 @@ import { dialogBoxCreate } from "../ui/React/DialogBox";
import { isString } from "../utils/helpers/isString";
import { MaterialSizes } from "./MaterialSizes";
import { Warehouse } from "./Warehouse";
import { ICorporation } from "./ICorporation";
import { IIndustry } from "./IIndustry";
import { Corporation } from "./Corporation";
interface IParams {
name?: string;
corp?: ICorporation;
corp?: Corporation;
type?: string;
}
export class Industry implements IIndustry {
export class Industry {
name = "";
type = Industries.Agriculture;
sciResearch = new Material({ name: "Scientific Research" });
@ -385,7 +384,7 @@ export class Industry implements IIndustry {
}
}
process(marketCycles = 1, state: string, corporation: ICorporation): void {
process(marketCycles = 1, state: string, corporation: Corporation): void {
this.state = state;
//At the start of a cycle, store and reset revenue/expenses
@ -518,7 +517,7 @@ export class Industry implements IIndustry {
}
//Process production, purchase, and import/export of materials
processMaterials(marketCycles = 1, corporation: ICorporation): [number, number] {
processMaterials(marketCycles = 1, corporation: Corporation): [number, number] {
let revenue = 0,
expenses = 0;
this.calculateProductionFactors();
@ -949,7 +948,7 @@ export class Industry implements IIndustry {
}
//Process production & sale of this industry's FINISHED products (including all of their stats)
processProducts(marketCycles = 1, corporation: ICorporation): [number, number] {
processProducts(marketCycles = 1, corporation: Corporation): [number, number] {
let revenue = 0;
const expenses = 0;
@ -985,7 +984,7 @@ export class Industry implements IIndustry {
}
//Processes FINISHED products
processProduct(marketCycles = 1, product: Product, corporation: ICorporation): number {
processProduct(marketCycles = 1, product: Product, corporation: Corporation): number {
let totalProfit = 0;
for (let i = 0; i < CorporationConstants.Cities.length; ++i) {
const city = CorporationConstants.Cities[i];
@ -1225,7 +1224,7 @@ export class Industry implements IIndustry {
return 1e9 * Math.pow(1.06, this.numAdVerts);
}
applyAdVert(corporation: ICorporation): void {
applyAdVert(corporation: Corporation): void {
const advMult = corporation.getAdvertisingMultiplier() * this.getAdvertisingMultiplier();
const awareness = (this.awareness + 3 * advMult) * (1.01 * advMult);
this.awareness = Math.min(awareness, Number.MAX_VALUE);

@ -1,6 +1,6 @@
import React from "react";
import { ResearchTree } from "./ResearchTree";
import { ICorporation } from "./ICorporation";
import { Corporation } from "./Corporation";
import { getBaseResearchTreeCopy, getProductIndustryResearchTreeCopy } from "./data/BaseResearchTree";
import { MoneyCost } from "./ui/MoneyCost";
@ -59,8 +59,8 @@ export const IndustryStartingCosts: IIndustryMap<number> = {
};
// Map of description for each industry
export const IndustryDescriptions: IIndustryMap<(corp: ICorporation) => React.ReactElement> = {
Energy: (corp: ICorporation) => (
export const IndustryDescriptions: IIndustryMap<(corp: Corporation) => React.ReactElement> = {
Energy: (corp: Corporation) => (
<>
Engage in the production and distribution of energy.
<br />
@ -70,7 +70,7 @@ export const IndustryDescriptions: IIndustryMap<(corp: ICorporation) => React.Re
Recommended starting Industry: NO
</>
),
Utilities: (corp: ICorporation) => (
Utilities: (corp: Corporation) => (
<>
Distribute water and provide wastewater services.
<br />
@ -80,7 +80,7 @@ export const IndustryDescriptions: IIndustryMap<(corp: ICorporation) => React.Re
Recommended starting Industry: NO
</>
),
Agriculture: (corp: ICorporation) => (
Agriculture: (corp: Corporation) => (
<>
Cultivate crops and breed livestock to produce food.
<br />
@ -90,7 +90,7 @@ export const IndustryDescriptions: IIndustryMap<(corp: ICorporation) => React.Re
Recommended starting Industry: YES
</>
),
Fishing: (corp: ICorporation) => (
Fishing: (corp: Corporation) => (
<>
Produce food through the breeding and processing of fish and fish products.
<br />
@ -100,7 +100,7 @@ export const IndustryDescriptions: IIndustryMap<(corp: ICorporation) => React.Re
Recommended starting Industry: NO
</>
),
Mining: (corp: ICorporation) => (
Mining: (corp: Corporation) => (
<>
Extract and process metals from the earth.
<br />
@ -110,7 +110,7 @@ export const IndustryDescriptions: IIndustryMap<(corp: ICorporation) => React.Re
Recommended starting Industry: NO
</>
),
Food: (corp: ICorporation) => (
Food: (corp: Corporation) => (
<>
Create your own restaurants all around the world.
<br />
@ -120,7 +120,7 @@ export const IndustryDescriptions: IIndustryMap<(corp: ICorporation) => React.Re
Recommended starting Industry: YES
</>
),
Tobacco: (corp: ICorporation) => (
Tobacco: (corp: Corporation) => (
<>
Create and distribute tobacco and tobacco-related products.
<br />
@ -130,7 +130,7 @@ export const IndustryDescriptions: IIndustryMap<(corp: ICorporation) => React.Re
Recommended starting Industry: YES
</>
),
Chemical: (corp: ICorporation) => (
Chemical: (corp: Corporation) => (
<>
Produce industrial chemicals.
<br />
@ -140,7 +140,7 @@ export const IndustryDescriptions: IIndustryMap<(corp: ICorporation) => React.Re
Recommended starting Industry: NO
</>
),
Pharmaceutical: (corp: ICorporation) => (
Pharmaceutical: (corp: Corporation) => (
<>
Discover, develop, and create new pharmaceutical drugs.
<br />
@ -150,7 +150,7 @@ export const IndustryDescriptions: IIndustryMap<(corp: ICorporation) => React.Re
Recommended starting Industry: NO
</>
),
Computer: (corp: ICorporation) => (
Computer: (corp: Corporation) => (
<>
Develop and manufacture new computer hardware and networking infrastructures.
<br />
@ -160,7 +160,7 @@ export const IndustryDescriptions: IIndustryMap<(corp: ICorporation) => React.Re
Recommended starting Industry: NO
</>
),
Robotics: (corp: ICorporation) => (
Robotics: (corp: Corporation) => (
<>
Develop and create robots.
<br />
@ -170,7 +170,7 @@ export const IndustryDescriptions: IIndustryMap<(corp: ICorporation) => React.Re
Recommended starting Industry: NO
</>
),
Software: (corp: ICorporation) => (
Software: (corp: Corporation) => (
<>
Develop computer software and create AI Cores.
<br />
@ -180,7 +180,7 @@ export const IndustryDescriptions: IIndustryMap<(corp: ICorporation) => React.Re
Recommended starting Industry: YES
</>
),
Healthcare: (corp: ICorporation) => (
Healthcare: (corp: Corporation) => (
<>
Create and manage hospitals.
<br />
@ -190,7 +190,7 @@ export const IndustryDescriptions: IIndustryMap<(corp: ICorporation) => React.Re
Recommended starting Industry: NO
</>
),
RealEstate: (corp: ICorporation) => (
RealEstate: (corp: Corporation) => (
<>
Develop and manage real estate properties.
<br />

@ -4,8 +4,8 @@ import { getRandomInt } from "../utils/helpers/getRandomInt";
import { generateRandomString } from "../utils/StringHelperFunctions";
import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver";
import { Employee } from "./Employee";
import { IIndustry } from "./IIndustry";
import { ICorporation } from "./ICorporation";
import { Industry } from "./Industry";
import { Corporation } from "./Corporation";
interface IParams {
loc?: string;
@ -68,7 +68,7 @@ export class OfficeSpace {
return this.employees.length >= this.size;
}
process(marketCycles = 1, corporation: ICorporation, industry: IIndustry): number {
process(marketCycles = 1, corporation: Corporation, industry: Industry): number {
// HRBuddy AutoRecruitment and training
if (industry.hasResearch("HRBuddy-Recruitment") && !this.atCapacity()) {
const emp = this.hireRandomEmployee();
@ -177,7 +177,7 @@ export class OfficeSpace {
}
}
calculateEmployeeProductivity(corporation: ICorporation, industry: IIndustry): void {
calculateEmployeeProductivity(corporation: Corporation, industry: Industry): void {
//Reset
for (const name of Object.keys(this.employeeProd)) {
this.employeeProd[name] = 0;

@ -1,6 +1,6 @@
import { EmployeePositions } from "./EmployeePositions";
import { MaterialSizes } from "./MaterialSizes";
import { IIndustry } from "./IIndustry";
import { Industry } from "./Industry";
import { ProductRatingWeights, IProductRatingWeight } from "./ProductRatingWeights";
import { createCityMap } from "../Locations/createCityMap";
@ -157,7 +157,7 @@ export class Product {
}
// @param industry - Industry object. Reference to industry that makes this Product
finishProduct(industry: IIndustry): void {
finishProduct(industry: Industry): void {
this.fin = true;
// Calculate properties
@ -248,7 +248,7 @@ export class Product {
}
}
calculateRating(industry: IIndustry): void {
calculateRating(industry: Industry): void {
const weights: IProductRatingWeight = ProductRatingWeights[industry.type];
if (weights == null) {
console.error(`Could not find product rating weights for: ${industry}`);

@ -1,14 +1,14 @@
import { Material } from "./Material";
import { ICorporation } from "./ICorporation";
import { IIndustry } from "./IIndustry";
import { Corporation } from "./Corporation";
import { Industry } from "./Industry";
import { MaterialSizes } from "./MaterialSizes";
import { IMap } from "../types";
import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../utils/JSONReviver";
import { exceptionAlert } from "../utils/helpers/exceptionAlert";
interface IConstructorParams {
corp?: ICorporation;
industry?: IIndustry;
corp?: Corporation;
industry?: Industry;
loc?: string;
size?: number;
}
@ -96,7 +96,7 @@ export class Warehouse {
}
}
updateSize(corporation: ICorporation, industry: IIndustry): void {
updateSize(corporation: Corporation, industry: Industry): void {
try {
this.size = this.level * 100 * corporation.getStorageMultiplier() * industry.getStorageMultiplier();
} catch (e: unknown) {

@ -1,14 +1,14 @@
import React, { useContext } from "react";
import { ICorporation } from "../ICorporation";
import { IIndustry } from "../IIndustry";
import { Corporation } from "../Corporation";
import { Industry } from "../Industry";
export const Context: {
Corporation: React.Context<ICorporation>;
Division: React.Context<IIndustry>;
Corporation: React.Context<Corporation>;
Division: React.Context<Industry>;
} = {
Corporation: React.createContext<ICorporation>({} as ICorporation),
Division: React.createContext<IIndustry>({} as IIndustry),
Corporation: React.createContext<Corporation>({} as Corporation),
Division: React.createContext<Industry>({} as Industry),
};
export const useCorporation = (): ICorporation => useContext(Context.Corporation);
export const useDivision = (): IIndustry => useContext(Context.Division);
export const useCorporation = (): Corporation => useContext(Context.Corporation);
export const useDivision = (): Industry => useContext(Context.Division);

@ -2,7 +2,7 @@
// These are the tabs at the top of the UI that let you switch to different
// divisions, see an overview of your corporation, or create a new industry
import React, { useState, useEffect } from "react";
import { IIndustry } from "../IIndustry";
import { Industry } from "../Industry";
import { MainPanel } from "./MainPanel";
import { Industries } from "../IndustryData";
import { ExpandIndustryTab } from "./ExpandIndustryTab";
@ -32,7 +32,7 @@ export function CorporationRoot(): React.ReactElement {
const canExpand =
Object.keys(Industries).filter(
(industryType: string) =>
corporation.divisions.find((division: IIndustry) => division.type === industryType) === undefined,
corporation.divisions.find((division: Industry) => division.type === industryType) === undefined,
).length > 0;
return (

@ -2,7 +2,7 @@ import React, { useState } from "react";
import { dialogBoxCreate } from "../../ui/React/DialogBox";
import { IndustryStartingCosts, Industries, IndustryDescriptions } from "../IndustryData";
import { useCorporation } from "./Context";
import { IIndustry } from "../IIndustry";
import { Industry } from "../Industry";
import { NewIndustry } from "../Actions";
import Typography from "@mui/material/Typography";
@ -23,7 +23,7 @@ export function ExpandIndustryTab(props: IProps): React.ReactElement {
const possibleIndustries = allIndustries
.filter(
(industryType: string) =>
corp.divisions.find((division: IIndustry) => division.type === industryType) === undefined,
corp.divisions.find((division: Industry) => division.type === industryType) === undefined,
)
.sort();
const [industry, setIndustry] = useState(possibleIndustries.length > 0 ? possibleIndustries[0] : "");

@ -1,8 +1,8 @@
import { IIndustry } from "../IIndustry";
import { Industry } from "../Industry";
// Returns a boolean indicating whether the given material is relevant for the
// current industry.
export function isRelevantMaterial(matName: string, division: IIndustry): boolean {
export function isRelevantMaterial(matName: string, division: Industry): boolean {
// Materials that affect Production multiplier
const prodMultiplierMats = ["Hardware", "Robots", "AICores", "RealEstate", "AI Cores", "Real Estate"];

@ -1,9 +1,9 @@
import React from "react";
import { IIndustry } from "../IIndustry";
import { Industry } from "../Industry";
import { MathJaxWrapper } from "../../MathJaxWrapper";
interface IProps {
division: IIndustry;
division: Industry;
}
export function IndustryProductEquation(props: IProps): React.ReactElement {

@ -13,8 +13,8 @@ import { MaterialSizes } from "../MaterialSizes";
import { numeralWrapper } from "../../ui/numeralFormat";
import { ICorporation } from "../ICorporation";
import { IIndustry } from "../IIndustry";
import { Corporation } from "../Corporation";
import { Industry } from "../Industry";
import { MoneyCost } from "./MoneyCost";
import { isRelevantMaterial } from "./Helpers";
import { IndustryProductEquation } from "./IndustryProductEquation";
@ -30,8 +30,8 @@ import makeStyles from "@mui/styles/makeStyles";
import createStyles from "@mui/styles/createStyles";
interface IProps {
corp: ICorporation;
division: IIndustry;
corp: Corporation;
division: Industry;
warehouse: Warehouse | 0;
currentCity: string;
rerender: () => void;

@ -4,7 +4,7 @@
import React from "react";
import { CityTabs } from "./CityTabs";
import { IIndustry } from "../IIndustry";
import { Industry } from "../Industry";
import { Context, useCorporation } from "./Context";
import { CityName } from "../../Locations/data/CityNames";
@ -18,7 +18,7 @@ export function MainPanel(props: IProps): React.ReactElement {
const corp = useCorporation();
const division =
props.divisionName !== "Overview"
? corp.divisions.find((division: IIndustry) => division.name === props.divisionName)
? corp.divisions.find((division: Industry) => division.name === props.divisionName)
: undefined; // use undefined because find returns undefined
if (division === undefined) throw new Error("Cannot find division");

@ -1,6 +1,6 @@
import * as React from "react";
import { numeralWrapper } from "../../ui/numeralFormat";
import { ICorporation } from "../ICorporation";
import { Corporation } from "../Corporation";
import { Theme } from "@mui/material/styles";
import makeStyles from "@mui/styles/makeStyles";
import createStyles from "@mui/styles/createStyles";
@ -18,7 +18,7 @@ const useStyles = makeStyles((theme: Theme) =>
interface IProps {
money: number;
corp: ICorporation;
corp: Corporation;
}
export function MoneyCost(props: IProps): React.ReactElement {

@ -2,7 +2,7 @@ import React, { useState } from "react";
import { dialogBoxCreate } from "../../../ui/React/DialogBox";
import { Material } from "../../Material";
import { Export } from "../../Export";
import { IIndustry } from "../../IIndustry";
import { Industry } from "../../Industry";
import { ExportMaterial } from "../../Actions";
import { Modal } from "../../../ui/React/Modal";
import { useCorporation } from "../Context";
@ -23,7 +23,7 @@ interface IProps {
// Create a popup that lets the player manage exports
export function ExportModal(props: IProps): React.ReactElement {
const corp = useCorporation();
const possibleDivisions = corp.divisions.filter((division: IIndustry) =>
const possibleDivisions = corp.divisions.filter((division: Industry) =>
isRelevantMaterial(props.mat.name, division),
);
if (possibleDivisions.length === 0) throw new Error("Export popup created with no divisions.");
@ -72,7 +72,7 @@ export function ExportModal(props: IProps): React.ReactElement {
rerender();
}
const currentDivision = corp.divisions.find((division: IIndustry) => division.name === industry);
const currentDivision = corp.divisions.find((division: Industry) => division.name === industry);
if (currentDivision === undefined)
throw new Error(`Export popup somehow ended up with undefined division '${currentDivision}'`);
const possibleCities = Object.keys(currentDivision.warehouses).filter(
@ -90,8 +90,8 @@ export function ExportModal(props: IProps): React.ReactElement {
</Typography>
<Select onChange={onIndustryChange} value={industry}>
{corp.divisions
.filter((division: IIndustry) => isRelevantMaterial(props.mat.name, division))
.map((division: IIndustry) => (
.filter((division: Industry) => isRelevantMaterial(props.mat.name, division))
.map((division: Industry) => (
<MenuItem key={division.name} value={division.name}>
{division.name}
</MenuItem>

@ -2,7 +2,7 @@ import React, { useState } from "react";
import { Modal } from "../../../ui/React/Modal";
import { IndustryResearchTrees } from "../../IndustryData";
import { CorporationConstants } from "../../data/Constants";
import { IIndustry } from "../../IIndustry";
import { Industry } from "../../Industry";
import { Research } from "../../Actions";
import { Node } from "../../ResearchTree";
import { ResearchMap } from "../../ResearchMap";
@ -20,7 +20,7 @@ import CheckIcon from "@mui/icons-material/Check";
interface INodeProps {
n: Node | null;
division: IIndustry;
division: Industry;
}
function Upgrade({ n, division }: INodeProps): React.ReactElement {
const [open, setOpen] = useState(false);
@ -129,7 +129,7 @@ function Upgrade({ n, division }: INodeProps): React.ReactElement {
interface IProps {
open: boolean;
onClose: () => void;
industry: IIndustry;
industry: Industry;
}
// Create the Research Tree UI for this Industry

@ -3,7 +3,7 @@ import { numeralWrapper } from "../../../ui/numeralFormat";
import { dialogBoxCreate } from "../../../ui/React/DialogBox";
import { Modal } from "../../../ui/React/Modal";
import { useCorporation } from "../Context";
import { ICorporation } from "../../ICorporation";
import { Corporation } from "../../Corporation";
import Typography from "@mui/material/Typography";
import Button from "@mui/material/Button";
import { Money } from "../../../ui/React/Money";
@ -24,7 +24,7 @@ export function SellSharesModal(props: IProps): React.ReactElement {
const disabled = isNaN(shares) || shares <= 0 || shares > corp.numShares;
function ProfitIndicator(props: { shares: number | null; corp: ICorporation }): React.ReactElement {
function ProfitIndicator(props: { shares: number | null; corp: Corporation }): React.ReactElement {
if (props.shares === null) return <></>;
let text = "";
if (isNaN(props.shares) || props.shares <= 0) {

@ -2,7 +2,7 @@ import React from "react";
import { numeralWrapper } from "../../../ui/numeralFormat";
import { CorporationConstants } from "../../data/Constants";
import { OfficeSpace } from "../../OfficeSpace";
import { ICorporation } from "../../ICorporation";
import { Corporation } from "../../Corporation";
import { UpgradeOfficeSize } from "../../Actions";
import { Modal } from "../../../ui/React/Modal";
import { useCorporation } from "../Context";
@ -14,7 +14,7 @@ import Box from "@mui/material/Box";
interface IUpgradeButton {
cost: number;
size: number;
corp: ICorporation;
corp: Corporation;
office: OfficeSpace;
onClose: () => void;
rerender: () => void;

@ -5,8 +5,8 @@ import { Employee } from "../Corporation/Employee";
import { Product } from "../Corporation/Product";
import { Material } from "../Corporation/Material";
import { Warehouse } from "../Corporation/Warehouse";
import { IIndustry } from "../Corporation/IIndustry";
import { ICorporation } from "../Corporation/ICorporation";
import { Industry } from "../Corporation/Industry";
import { Corporation } from "../Corporation/Corporation";
import {
Corporation as NSCorporation,
@ -59,7 +59,6 @@ import {
import { CorporationUnlockUpgrades } from "../Corporation/data/CorporationUnlockUpgrades";
import { CorporationUpgrades } from "../Corporation/data/CorporationUpgrades";
import { EmployeePositions } from "../Corporation/EmployeePositions";
import { Industry } from "../Corporation/Industry";
import { IndustryResearchTrees, IndustryStartingCosts } from "../Corporation/IndustryData";
import { CorporationConstants } from "../Corporation/data/Constants";
import { ResearchMap } from "../Corporation/ResearchMap";
@ -191,7 +190,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
return true;
}
function getResearchCost(division: IIndustry, researchName: string): number {
function getResearchCost(division: Industry, researchName: string): number {
const researchTree = IndustryResearchTrees[division.type];
if (researchTree === undefined) throw new Error(`No research tree for industry '${division.type}'`);
const allResearch = researchTree.getAllNodes();
@ -200,7 +199,7 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
return research.cost;
}
function hasResearched(division: IIndustry, researchName: string): boolean {
function hasResearched(division: Industry, researchName: string): boolean {
return division.researched[researchName] === undefined ? false : (division.researched[researchName] as boolean);
}
@ -223,13 +222,13 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
return true;
}
function getCorporation(): ICorporation {
function getCorporation(): Corporation {
const corporation = player.corporation;
if (corporation === null) throw new Error("cannot be called without a corporation");
return corporation;
}
function getDivision(divisionName: string): IIndustry {
function getDivision(divisionName: string): Industry {
const corporation = getCorporation();
const division = corporation.divisions.find((div) => div.name === divisionName);
if (division === undefined) throw new Error(`No division named '${divisionName}'`);

@ -13,7 +13,7 @@ import { Exploit } from "../../Exploits/Exploit";
import { LocationName } from "../../Locations/data/LocationNames";
import { IPlayerOwnedAugmentation } from "../../Augmentation/PlayerOwnedAugmentation";
import { ICorporation } from "../../Corporation/ICorporation";
import { Corporation } from "../../Corporation/Corporation";
import { IGang } from "../../Gang/IGang";
import { Bladeburner } from "../../Bladeburner/Bladeburner";
import { HacknetNode } from "../../Hacknet/HacknetNode";
@ -32,7 +32,7 @@ import { Person } from "../Person";
export class PlayerObject extends Person {
// Player-specific properties
bitNodeN = 1; //current bitnode
corporation: ICorporation | null = null;
corporation: Corporation | null = null;
gang: IGang | null = null;
bladeburner: Bladeburner | null = null;
currentServer = "";