diff --git a/src/Corporation/Division.ts b/src/Corporation/Division.ts index 343b6da91..807f851ab 100644 --- a/src/Corporation/Division.ts +++ b/src/Corporation/Division.ts @@ -215,32 +215,25 @@ export class Division { } } - // Process change in demand and competition for this industry's materials + // Process demand, competition, and market price changes for this division's materials processMaterialMarket(): void { - //References to prodMats and reqMats - const reqMats = this.requiredMaterials, - prodMats = this.producedMaterials; + // Relevant materials: + // - All materials this division requires or produces + // - Boost materials + const materials = new Set([ + ...getRecordKeys(this.requiredMaterials), + ...this.producedMaterials, + ...corpConstants.boostMaterials, + ]); - //Only 'process the market' for materials that this industry deals with for (const city of Object.values(CityName)) { - //If this industry has a warehouse in this city, process the market - //for every material this industry requires or produces - if (this.warehouses[city]) { - const wh = this.warehouses[city]; - for (const name of Object.keys(reqMats) as CorpMaterialName[]) { - if (Object.hasOwn(reqMats, name)) { - wh.materials[name].processMarket(); - } - } - - //Produced materials are stored in an array - for (const matName of prodMats) wh.materials[matName].processMarket(); - - //Process these twice because these boost production ?????? - wh.materials.Hardware.processMarket(); - wh.materials.Robots.processMarket(); - wh.materials["AI Cores"].processMarket(); - wh.materials["Real Estate"].processMarket(); + const warehouse = this.warehouses[city]; + // If this division has a warehouse in this city, process the relevant materials + if (warehouse == null) { + continue; + } + for (const materialName of materials) { + warehouse.materials[materialName].processMarket(); } } } diff --git a/src/Corporation/data/Constants.ts b/src/Corporation/data/Constants.ts index 1cc49d1d1..519059756 100644 --- a/src/Corporation/data/Constants.ts +++ b/src/Corporation/data/Constants.ts @@ -19,7 +19,7 @@ import { CorpBaseResearchName, CorpProductResearchName, } from "@enums"; -import { PositiveInteger } from "../../types"; +import type { PositiveInteger } from "../../types"; /** Names of all corporation game states */ export const stateNames: CorpStateName[] = ["START", "PURCHASE", "PRODUCTION", "EXPORT", "SALE"], @@ -30,6 +30,8 @@ export const stateNames: CorpStateName[] = ["START", "PURCHASE", "PRODUCTION", " industryNames: CorpIndustryName[] = Object.values(IndustryType), /** Names of all materials */ materialNames: APIMaterialName[] = Object.values(CorpMaterialName), + /** Names of all boost materials */ + boostMaterials: CorpMaterialName[] = ["Hardware", "Robots", "AI Cores", "Real Estate"], /** Names of all one-time corporation-wide unlocks */ unlockNames: APIUnlockName[] = Object.values(CorpUnlockName), upgradeNames: APIUpgradeName[] = Object.values(CorpUpgradeName), diff --git a/src/Corporation/ui/Helpers.tsx b/src/Corporation/ui/Helpers.tsx index 56d7b273d..caa74050e 100644 --- a/src/Corporation/ui/Helpers.tsx +++ b/src/Corporation/ui/Helpers.tsx @@ -1,15 +1,13 @@ import { CorpMaterialName } from "@nsdefs"; import { Division } from "../Division"; +import { boostMaterials } from "../data/Constants"; // Returns a boolean indicating whether the given material is relevant for the // current industry. export function isRelevantMaterial(matName: CorpMaterialName, division: Division): boolean { - // Materials that affect Production multiplier - const prodMultiplierMats: CorpMaterialName[] = ["Hardware", "Robots", "AI Cores", "Real Estate"]; - if (Object.keys(division.requiredMaterials).includes(matName)) return true; if (division.producedMaterials.includes(matName)) return true; - if (prodMultiplierMats.includes(matName)) return true; + if (boostMaterials.includes(matName)) return true; return false; }