mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-16 14:28:36 +02:00
Compare commits
2 Commits
v2.2.0
...
v2.2.0hotf
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6d72861304 | ||
|
|
3f850d71ba |
@@ -1145,11 +1145,24 @@ export class Industry {
|
||||
|
||||
/** Initializes a Industry object from a JSON save state. */
|
||||
static fromJSON(value: IReviverValue): Industry {
|
||||
//Gracefully load saves which have old names for industries
|
||||
if (value.data.type === "RealEstate") value.data.type = IndustryType.RealEstate;
|
||||
if (value.data.type === "Utilities") value.data.type = IndustryType.Utilities;
|
||||
if (value.data.type === "Computers") value.data.type = IndustryType.Computers;
|
||||
if (value.data.type === "Computer") value.data.type = IndustryType.Computers;
|
||||
const matNameMap = { AICores: "AI Cores", RealEstate: "Real Estate" };
|
||||
const indNameMap = {
|
||||
RealEstate: IndustryType.RealEstate,
|
||||
Utilities: IndustryType.Utilities,
|
||||
Computers: IndustryType.Computers,
|
||||
Computer: IndustryType.Computers,
|
||||
};
|
||||
for (const [key, val] of Object.entries(indNameMap)) if (value.data.type === key) value.data.type = val;
|
||||
value.data.prodMats = value.data.prodMats.map((matName: string) => {
|
||||
if (matName in matNameMap) return matNameMap[matName as keyof typeof matNameMap];
|
||||
return matName;
|
||||
});
|
||||
for (const matName of Object.keys(value.data.reqMats)) {
|
||||
if (matName in matNameMap) {
|
||||
value.data.reqMats[matNameMap[matName as keyof typeof matNameMap]] = value.data.reqMats[matName];
|
||||
delete value.data.reqMats[matName];
|
||||
}
|
||||
}
|
||||
return Generic_fromJSON(Industry, value.data);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -134,6 +134,8 @@ export class Material {
|
||||
static fromJSON(value: IReviverValue): Material {
|
||||
// Gracefully load save files from when Scientific Research was considered a Material (pre 2.2).
|
||||
if (value.data.name === "Scientific Research") return value.data.qty;
|
||||
if (value.data.name === "RealEstate") value.data.name = "Real Estate";
|
||||
if (value.data.name === "AICores") value.data.name = "AI Cores";
|
||||
return Generic_fromJSON(Material, value.data);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user