CORPORATION: Rename division.type to division.industry (#2152)

This commit is contained in:
catloversg
2025-05-28 18:47:26 +07:00
committed by GitHub
parent e31b174137
commit 9824166dbf
11 changed files with 61 additions and 45 deletions

View File

@@ -1,13 +1,13 @@
<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Division](./bitburner.division.md) &gt; [type](./bitburner.division.type.md)
[Home](./index.md) &gt; [bitburner](./bitburner.md) &gt; [Division](./bitburner.division.md) &gt; [industry](./bitburner.division.industry.md)
## Division.type property
## Division.industry property
Type of division, like Agriculture
Industry of division, like Agriculture
**Signature:**
```typescript
type: CorpIndustryName;
industry: CorpIndustryName;
```

View File

@@ -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) | Industry 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 |

View File

@@ -445,7 +445,7 @@ export const achievements: Record<AchievementId, Achievement> = {
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;
},

View File

@@ -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.

View File

@@ -18,16 +18,17 @@ import { getKeyList } from "../utils/helpers/getKeyList";
import { calculateMarkupMultiplier } from "./helpers";
import { exceptionAlert } from "../utils/helpers/exceptionAlert";
import { throwIfReachable } from "../utils/helpers/throwIfReachable";
import { assertObject } from "../utils/TypeAssertion";
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<CorpResearchName>();
requiredMaterials: PartialRecord<CorpMaterialName, number> = {};
@@ -86,7 +87,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 +101,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 +262,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 +1064,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 +1074,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();
}
@@ -1137,9 +1138,15 @@ export class Division {
return Generic_toJSON("Division", this, Division.includedKeys);
}
/** Initializes a Industry object from a JSON save state. */
/** Initializes a Division object from a JSON save state. */
static fromJSON(value: IReviverValue): Division {
return Generic_fromJSON(Division, value.data, Division.includedKeys);
const division = Generic_fromJSON(Division, value.data, Division.includedKeys);
// division.type was renamed to division.industry in v3.0.0.
assertObject(value.data);
if ("type" in value.data) {
division.industry = value.data.type as IndustryType;
}
return division;
}
static includedKeys = getKeyList(Division, { removedKeys: ["treeInitialized"] });

View File

@@ -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}`);
}

View File

@@ -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 (
<Paper>
<Typography>
Industry: {division.type} (Corp Funds: <Money money={corp.funds} />)
Industry: {division.industry} (Corp Funds: <Money money={corp.funds} />)
</Typography>
<br />
<StatsTable
@@ -137,7 +137,7 @@ export function DivisionOverview(props: DivisionOverviewProps): React.ReactEleme
<>
<Typography>Multiplier for this industry's sales due to its awareness and popularity.</Typography>
<br />
<MathJax>{`\\(\\text{${division.type} Industry: }\\alpha = ${division.advertisingFactor}\\)`}</MathJax>
<MathJax>{`\\(\\text{${division.industry} Industry: }\\alpha = ${division.advertisingFactor}\\)`}</MathJax>
<MathJax>{`\\(\\text{multiplier} = \\left((\\text{awareness}+1)^{\\alpha} \\times (\\text{popularity}+1)^{\\alpha} \\times \\frac{\\text{popularity}+0.001}{\\text{awareness}}\\right)^{0.85}\\)`}</MathJax>
<br />
<StatsTable

View File

@@ -40,7 +40,7 @@ export function MakeProductModal(props: IProps): React.ReactElement {
const [name, setName] = useState("");
const [design, setDesign] = useState<number>(NaN);
const [marketing, setMarketing] = useState<number>(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 {
</MenuItem>
))}
</Select>
<TextField onChange={onProductNameChange} placeholder={productPlaceholder(division.type)} />
<TextField onChange={onProductNameChange} placeholder={productPlaceholder(division.industry)} />
<br />
<NumberInput onChange={setDesign} autoFocus={true} placeholder={"Design investment"} />
<NumberInput onChange={setMarketing} onKeyDown={onKeyDown} placeholder={"Marketing investment"} />

View File

@@ -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 (

View File

@@ -71,6 +71,7 @@ import {
} from "../Corporation/helpers";
import { PositiveInteger } from "../types";
import { getRecordKeys } from "../Types/Record";
import { setDeprecatedProperties } from "../utils/DeprecationHelper";
export function NetscriptCorporation(): InternalAPI<NSCorporation> {
function hasUnlock(unlockName: CorpUnlockName): boolean {
@@ -94,8 +95,8 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
}
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 +158,9 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
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 +175,14 @@ export function NetscriptCorporation(): InternalAPI<NSCorporation> {
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<WarehouseAPI> = {

View File

@@ -10000,8 +10000,8 @@ export interface Office {
interface Division {
/** Name of the division */
name: string;
/** Type of division, like Agriculture */
type: CorpIndustryName;
/** Industry of division, like Agriculture */
industry: CorpIndustryName;
/** Awareness of the division */
awareness: number;
/** Popularity of the division */