From 7a3c18fcf2ccfbc3c119798453a52d2b04e8275d Mon Sep 17 00:00:00 2001 From: whiskeyfur Date: Sat, 17 May 2025 22:31:25 -0700 Subject: [PATCH] API: Renamed Division.type to Division.industry (#2079) --- ...type.md => bitburner.division.industry.md} | 6 ++-- markdown/bitburner.division.md | 2 +- src/Achievements/Achievements.ts | 2 +- src/Corporation/Actions.ts | 12 +++---- src/Corporation/Division.ts | 36 +++++++++---------- src/Corporation/Product.ts | 2 +- src/Corporation/ui/DivisionOverview.tsx | 6 ++-- .../ui/modals/MakeProductModal.tsx | 4 +-- src/Corporation/ui/modals/ResearchModal.tsx | 2 +- src/NetscriptFunctions/Corporation.ts | 16 ++++++--- src/ScriptEditor/NetscriptDefinitions.d.ts | 2 +- 11 files changed, 49 insertions(+), 41 deletions(-) rename markdown/{bitburner.division.type.md => bitburner.division.industry.md} (61%) diff --git a/markdown/bitburner.division.type.md b/markdown/bitburner.division.industry.md similarity index 61% rename from markdown/bitburner.division.type.md rename to markdown/bitburner.division.industry.md index 030e16fad..89730a004 100644 --- a/markdown/bitburner.division.type.md +++ b/markdown/bitburner.division.industry.md @@ -1,13 +1,13 @@ -[Home](./index.md) > [bitburner](./bitburner.md) > [Division](./bitburner.division.md) > [type](./bitburner.division.type.md) +[Home](./index.md) > [bitburner](./bitburner.md) > [Division](./bitburner.division.md) > [industry](./bitburner.division.industry.md) -## Division.type property +## Division.industry property Type of division, like Agriculture **Signature:** ```typescript -type: CorpIndustryName; +industry: CorpIndustryName; ``` diff --git a/markdown/bitburner.division.md b/markdown/bitburner.division.md index daa36f803..188a0179f 100644 --- a/markdown/bitburner.division.md +++ b/markdown/bitburner.division.md @@ -18,6 +18,7 @@ interface Division | --- | --- | --- | --- | | [awareness](./bitburner.division.awareness.md) | | number | Awareness of the division | | [cities](./bitburner.division.cities.md) | | [CityName](./bitburner.cityname.md)\[\] | Cities in which this division has expanded | +| [industry](./bitburner.division.industry.md) | | [CorpIndustryName](./bitburner.corpindustryname.md) | Type of division, like Agriculture | | [lastCycleExpenses](./bitburner.division.lastcycleexpenses.md) | | number | Expenses last cycle | | [lastCycleRevenue](./bitburner.division.lastcyclerevenue.md) | | number | Revenue last cycle | | [makesProducts](./bitburner.division.makesproducts.md) | | boolean | Whether the industry of this division is capable of developing and producing products | @@ -30,5 +31,4 @@ interface Division | [researchPoints](./bitburner.division.researchpoints.md) | | number | Amount of research in that division | | [thisCycleExpenses](./bitburner.division.thiscycleexpenses.md) | | number | Expenses this cycle | | [thisCycleRevenue](./bitburner.division.thiscyclerevenue.md) | | number | Revenue this cycle | -| [type](./bitburner.division.type.md) | | [CorpIndustryName](./bitburner.corpindustryname.md) | Type of division, like Agriculture | diff --git a/src/Achievements/Achievements.ts b/src/Achievements/Achievements.ts index 0c169afa4..abb1ec7e7 100644 --- a/src/Achievements/Achievements.ts +++ b/src/Achievements/Achievements.ts @@ -399,7 +399,7 @@ export const achievements: Record = { Condition: () => { if (!Player.corporation) return false; for (const division of Player.corporation.divisions.values()) { - if (division.type === IndustryType.RealEstate) return true; + if (division.industry === IndustryType.RealEstate) return true; } return false; }, diff --git a/src/Corporation/Actions.ts b/src/Corporation/Actions.ts index d8a597c78..1a768099c 100644 --- a/src/Corporation/Actions.ts +++ b/src/Corporation/Actions.ts @@ -88,7 +88,7 @@ export function createDivision(corporation: Corporation, industry: IndustryType, new Division({ corp: corporation, name: name, - type: industry, + industry: industry, }), ); corporation.numberOfOfficesAndWarehouses += 2; @@ -319,7 +319,7 @@ export function setSmartSupplyOption(warehouse: Warehouse, material: Material, u export function buyMaterial(division: Division, material: Material, amt: number): void { if (!isRelevantMaterial(material.name, division)) { - throw new Error(`${material.name} is not a relevant material for industry ${division.type}`); + throw new Error(`${material.name} is not a relevant material for industry ${division.industry}`); } if (!Number.isFinite(amt) || amt < 0) { throw new Error( @@ -337,7 +337,7 @@ export function bulkPurchase( amt: number, ): void { if (!isRelevantMaterial(material.name, division)) { - throw new Error(`${material.name} is not a relevant material for industry ${division.type}`); + throw new Error(`${material.name} is not a relevant material for industry ${division.industry}`); } const matSize = MaterialInfo[material.name].size; const maxAmount = (warehouse.size - warehouse.sizeUsed) / matSize; @@ -501,8 +501,8 @@ export function makeProduct( export function research(researchingDivision: Division, researchName: CorpResearchName): void { const corp = Player.corporation; if (!corp) return; - const researchTree = IndustryResearchTrees[researchingDivision.type]; - if (researchTree === undefined) throw new Error(`No research tree for industry '${researchingDivision.type}'`); + const researchTree = IndustryResearchTrees[researchingDivision.industry]; + if (researchTree === undefined) throw new Error(`No research tree for industry '${researchingDivision.industry}'`); const research = ResearchMap[researchName]; const researchNode = researchTree.findNode(researchName); const researchPreReq = researchNode?.parent?.researchName; @@ -524,7 +524,7 @@ export function research(researchingDivision: Division, researchName: CorpResear researchTree.research(researchName); // All divisions of the same type as the researching division get the new research. for (const division of corp.divisions.values()) { - if (division.type !== researchingDivision.type) continue; + if (division.industry !== researchingDivision.industry) continue; division.researched.add(researchName); // Handle researches that need to have their effects manually applied here. // Warehouse size needs to be updated here because it is not recalculated during normal processing. diff --git a/src/Corporation/Division.ts b/src/Corporation/Division.ts index 2a740d05f..8975cc347 100644 --- a/src/Corporation/Division.ts +++ b/src/Corporation/Division.ts @@ -22,12 +22,12 @@ import { throwIfReachable } from "../utils/helpers/throwIfReachable"; interface DivisionParams { name: string; corp: Corporation; - type: IndustryType; + industry: IndustryType; } export class Division { name = "DefaultDivisionName"; - type = IndustryType.Agriculture; + industry = IndustryType.Agriculture; researchPoints = 0; researched = new JSONSet(); requiredMaterials: PartialRecord = {}; @@ -86,7 +86,7 @@ export class Division { constructor(params: DivisionParams | null = null) { if (!params) return; // Must be initialized inside the constructor because it references the industry - this.type = params.type; + this.industry = params.industry; this.name = params.name; // Add default starting this.warehouses[CityName.Sector12] = new Warehouse({ @@ -100,7 +100,7 @@ export class Division { }); // Loading data based on this division's industry type - const data = IndustriesData[this.type]; + const data = IndustriesData[this.industry]; this.startingCost = data.startingCost; this.makesProducts = data.makesProducts; this.realEstateFactor = data.realEstateFactor ?? 0; @@ -261,9 +261,9 @@ export class Division { if (change === 0) continue; if ( - this.type === IndustryType.Pharmaceutical || - this.type === IndustryType.Software || - this.type === IndustryType.Robotics + this.industry === IndustryType.Pharmaceutical || + this.industry === IndustryType.Software || + this.industry === IndustryType.Robotics ) { change *= 3; } @@ -1063,7 +1063,7 @@ export class Division { updateResearchTree(): void { if (this.treeInitialized) return; - const researchTree = IndustryResearchTrees[this.type]; + const researchTree = IndustryResearchTrees[this.industry]; // Need to populate the tree in case we are loading a game. for (const research of this.researched) researchTree.research(research); // Also need to load researches from the tree in case we are making a new division. @@ -1073,61 +1073,61 @@ export class Division { // Get multipliers from Research getAdvertisingMultiplier(): number { - const researchTree = IndustryResearchTrees[this.type]; + const researchTree = IndustryResearchTrees[this.industry]; this.updateResearchTree(); return researchTree.getAdvertisingMultiplier(); } getEmployeeChaMultiplier(): number { - const researchTree = IndustryResearchTrees[this.type]; + const researchTree = IndustryResearchTrees[this.industry]; this.updateResearchTree(); return researchTree.getEmployeeChaMultiplier(); } getEmployeeCreMultiplier(): number { - const researchTree = IndustryResearchTrees[this.type]; + const researchTree = IndustryResearchTrees[this.industry]; this.updateResearchTree(); return researchTree.getEmployeeCreMultiplier(); } getEmployeeEffMultiplier(): number { - const researchTree = IndustryResearchTrees[this.type]; + const researchTree = IndustryResearchTrees[this.industry]; this.updateResearchTree(); return researchTree.getEmployeeEffMultiplier(); } getEmployeeIntMultiplier(): number { - const researchTree = IndustryResearchTrees[this.type]; + const researchTree = IndustryResearchTrees[this.industry]; this.updateResearchTree(); return researchTree.getEmployeeIntMultiplier(); } getProductionMultiplier(): number { - const researchTree = IndustryResearchTrees[this.type]; + const researchTree = IndustryResearchTrees[this.industry]; this.updateResearchTree(); return researchTree.getProductionMultiplier(); } getProductProductionMultiplier(): number { - const researchTree = IndustryResearchTrees[this.type]; + const researchTree = IndustryResearchTrees[this.industry]; this.updateResearchTree(); return researchTree.getProductProductionMultiplier(); } getSalesMultiplier(): number { - const researchTree = IndustryResearchTrees[this.type]; + const researchTree = IndustryResearchTrees[this.industry]; this.updateResearchTree(); return researchTree.getSalesMultiplier(); } getScientificResearchMultiplier(): number { - const researchTree = IndustryResearchTrees[this.type]; + const researchTree = IndustryResearchTrees[this.industry]; this.updateResearchTree(); return researchTree.getScientificResearchMultiplier(); } getStorageMultiplier(): number { - const researchTree = IndustryResearchTrees[this.type]; + const researchTree = IndustryResearchTrees[this.industry]; this.updateResearchTree(); return researchTree.getStorageMultiplier(); } diff --git a/src/Corporation/Product.ts b/src/Corporation/Product.ts index 2de76168a..02f4d3e96 100644 --- a/src/Corporation/Product.ts +++ b/src/Corporation/Product.ts @@ -213,7 +213,7 @@ export class Product { } calculateRating(industry: Division): void { - const weights = IndustriesData[industry.type].product?.ratingWeights; + const weights = IndustriesData[industry.industry].product?.ratingWeights; if (!weights) { return console.error(`Could not find product rating weights for: ${industry.name}`); } diff --git a/src/Corporation/ui/DivisionOverview.tsx b/src/Corporation/ui/DivisionOverview.tsx index b407f229b..cb38c7a47 100644 --- a/src/Corporation/ui/DivisionOverview.tsx +++ b/src/Corporation/ui/DivisionOverview.tsx @@ -41,7 +41,7 @@ function MakeProductButton(): React.ReactElement { } let createProductButtonText = ""; - switch (division.type) { + switch (division.industry) { case IndustryType.Restaurant: createProductButtonText = "Build Restaurant"; break; @@ -122,7 +122,7 @@ export function DivisionOverview(props: DivisionOverviewProps): React.ReactEleme return ( - Industry: {division.type} (Corp Funds: ) + Industry: {division.industry} (Corp Funds: )
Multiplier for this industry's sales due to its awareness and popularity.
- {`\\(\\text{${division.type} Industry: }\\alpha = ${division.advertisingFactor}\\)`} + {`\\(\\text{${division.industry} Industry: }\\alpha = ${division.advertisingFactor}\\)`} {`\\(\\text{multiplier} = \\left((\\text{awareness}+1)^{\\alpha} \\times (\\text{popularity}+1)^{\\alpha} \\times \\frac{\\text{popularity}+0.001}{\\text{awareness}}\\right)^{0.85}\\)`}
(NaN); const [marketing, setMarketing] = useState(NaN); - const data = IndustriesData[division.type]; + const data = IndustriesData[division.industry]; if (division.hasMaximumNumberProducts() || !data.product) return <>; function makeProduct(): void { @@ -87,7 +87,7 @@ export function MakeProductModal(props: IProps): React.ReactElement { ))} - +
diff --git a/src/Corporation/ui/modals/ResearchModal.tsx b/src/Corporation/ui/modals/ResearchModal.tsx index 7157c056a..27189efc3 100644 --- a/src/Corporation/ui/modals/ResearchModal.tsx +++ b/src/Corporation/ui/modals/ResearchModal.tsx @@ -137,7 +137,7 @@ interface IProps { // Create the Research Tree UI for this Industry export function ResearchModal(props: IProps): React.ReactElement { - const researchTree = IndustryResearchTrees[props.industry.type]; + const researchTree = IndustryResearchTrees[props.industry.industry]; if (researchTree === undefined) return <>; return ( diff --git a/src/NetscriptFunctions/Corporation.ts b/src/NetscriptFunctions/Corporation.ts index 6630e3257..5e78e351d 100644 --- a/src/NetscriptFunctions/Corporation.ts +++ b/src/NetscriptFunctions/Corporation.ts @@ -94,8 +94,8 @@ export function NetscriptCorporation(): InternalAPI { } function getResearchCost(division: Division, researchName: CorpResearchName): number { - const researchTree = IndustryResearchTrees[division.type]; - if (researchTree === undefined) throw new Error(`No research tree for industry '${division.type}'`); + const researchTree = IndustryResearchTrees[division.industry]; + if (researchTree === undefined) throw new Error(`No research tree for industry '${division.industry}'`); const allResearch = researchTree.getAllNodes(); if (!allResearch.includes(researchName)) throw new Error(`No research named '${researchName}'`); const research = ResearchMap[researchName]; @@ -157,9 +157,9 @@ export function NetscriptCorporation(): InternalAPI { function getSafeDivision(division: Division): NSDivision { const cities = getRecordKeys(division.offices); - return { + const data = { name: division.name, - type: division.type, + industry: division.industry, awareness: division.awareness, popularity: division.popularity, productionMult: division.productionMult, @@ -174,6 +174,14 @@ export function NetscriptCorporation(): InternalAPI { makesProducts: division.makesProducts, maxProducts: division.maxProducts, }; + setDeprecatedProperties(data, { + type: { + identifier: "ns.corporation.getDivision().type", + message: "Use ns.corporation.getDivision().industry instead.", + value: data.industry, + }, + }); + return data; } const warehouseAPI: InternalAPI = { diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index f2ba6e867..35f637480 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -10109,7 +10109,7 @@ interface Division { /** Name of the division */ name: string; /** Type of division, like Agriculture */ - type: CorpIndustryName; + industry: CorpIndustryName; /** Awareness of the division */ awareness: number; /** Popularity of the division */