mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-20 22:52:07 +02:00
CORPORATION: Prevent duplicate processing of boost materials (#2695)
This commit is contained in:
+16
-23
@@ -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 {
|
processMaterialMarket(): void {
|
||||||
//References to prodMats and reqMats
|
// Relevant materials:
|
||||||
const reqMats = this.requiredMaterials,
|
// - All materials this division requires or produces
|
||||||
prodMats = this.producedMaterials;
|
// - 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)) {
|
for (const city of Object.values(CityName)) {
|
||||||
//If this industry has a warehouse in this city, process the market
|
const warehouse = this.warehouses[city];
|
||||||
//for every material this industry requires or produces
|
// If this division has a warehouse in this city, process the relevant materials
|
||||||
if (this.warehouses[city]) {
|
if (warehouse == null) {
|
||||||
const wh = this.warehouses[city];
|
continue;
|
||||||
for (const name of Object.keys(reqMats) as CorpMaterialName[]) {
|
}
|
||||||
if (Object.hasOwn(reqMats, name)) {
|
for (const materialName of materials) {
|
||||||
wh.materials[name].processMarket();
|
warehouse.materials[materialName].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();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import {
|
|||||||
CorpBaseResearchName,
|
CorpBaseResearchName,
|
||||||
CorpProductResearchName,
|
CorpProductResearchName,
|
||||||
} from "@enums";
|
} from "@enums";
|
||||||
import { PositiveInteger } from "../../types";
|
import type { PositiveInteger } from "../../types";
|
||||||
|
|
||||||
/** Names of all corporation game states */
|
/** Names of all corporation game states */
|
||||||
export const stateNames: CorpStateName[] = ["START", "PURCHASE", "PRODUCTION", "EXPORT", "SALE"],
|
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),
|
industryNames: CorpIndustryName[] = Object.values(IndustryType),
|
||||||
/** Names of all materials */
|
/** Names of all materials */
|
||||||
materialNames: APIMaterialName[] = Object.values(CorpMaterialName),
|
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 */
|
/** Names of all one-time corporation-wide unlocks */
|
||||||
unlockNames: APIUnlockName[] = Object.values(CorpUnlockName),
|
unlockNames: APIUnlockName[] = Object.values(CorpUnlockName),
|
||||||
upgradeNames: APIUpgradeName[] = Object.values(CorpUpgradeName),
|
upgradeNames: APIUpgradeName[] = Object.values(CorpUpgradeName),
|
||||||
|
|||||||
@@ -1,15 +1,13 @@
|
|||||||
import { CorpMaterialName } from "@nsdefs";
|
import { CorpMaterialName } from "@nsdefs";
|
||||||
import { Division } from "../Division";
|
import { Division } from "../Division";
|
||||||
|
import { boostMaterials } from "../data/Constants";
|
||||||
|
|
||||||
// Returns a boolean indicating whether the given material is relevant for the
|
// Returns a boolean indicating whether the given material is relevant for the
|
||||||
// current industry.
|
// current industry.
|
||||||
export function isRelevantMaterial(matName: CorpMaterialName, division: Division): boolean {
|
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 (Object.keys(division.requiredMaterials).includes(matName)) return true;
|
||||||
if (division.producedMaterials.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;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user