mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-19 04:35:46 +01:00
Fix save corruptions from invalid types
This commit is contained in:
parent
65cd14e33b
commit
387c0c2786
@ -8,6 +8,7 @@ import { Factions } from "../../../Faction/Factions";
|
||||
import { calculateFactionExp, calculateFactionRep } from "../../../Work/Formulas";
|
||||
import { Faction } from "../../../Faction/Faction";
|
||||
import { scaleWorkStats, WorkStats } from "../../../Work/WorkStats";
|
||||
import { findEnumMember } from "../../../utils/helpers/enum";
|
||||
|
||||
interface SleeveFactionWorkParams {
|
||||
factionWorkType: FactionWorkType;
|
||||
@ -65,7 +66,10 @@ export class SleeveFactionWork extends Work {
|
||||
|
||||
/** Initializes a FactionWork object from a JSON save state. */
|
||||
static fromJSON(value: IReviverValue): SleeveFactionWork {
|
||||
return Generic_fromJSON(SleeveFactionWork, value.data);
|
||||
const factionWork = Generic_fromJSON(SleeveFactionWork, value.data);
|
||||
factionWork.factionWorkType =
|
||||
findEnumMember(FactionWorkType, factionWork.factionWorkType) ?? FactionWorkType.hacking;
|
||||
return factionWork;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,7 +1,7 @@
|
||||
import { Reviver, Generic_toJSON, Generic_fromJSON, IReviverValue } from "../utils/JSONReviver";
|
||||
import { Crime } from "../Crime/Crime";
|
||||
import { CONSTANTS } from "../Constants";
|
||||
import { determineCrimeSuccess } from "../Crime/CrimeHelpers";
|
||||
import { determineCrimeSuccess, findCrime } from "../Crime/CrimeHelpers";
|
||||
import { Crimes } from "../Crime/Crimes";
|
||||
import { Player } from "@player";
|
||||
import { dialogBoxCreate } from "../ui/React/DialogBox";
|
||||
@ -100,7 +100,9 @@ export class CrimeWork extends Work {
|
||||
|
||||
/** Initializes a CrimeWork object from a JSON save state. */
|
||||
static fromJSON(value: IReviverValue): CrimeWork {
|
||||
return Generic_fromJSON(CrimeWork, value.data);
|
||||
const crimeWork = Generic_fromJSON(CrimeWork, value.data);
|
||||
crimeWork.crimeType = findCrime(crimeWork.crimeType)?.type ?? CrimeType.shoplift;
|
||||
return crimeWork;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,6 +12,7 @@ import { CONSTANTS } from "../Constants";
|
||||
import { AugmentationNames } from "../Augmentation/data/AugmentationNames";
|
||||
import { calculateFactionExp, calculateFactionRep } from "./Formulas";
|
||||
import { FactionWorkType } from "../utils/enums";
|
||||
import { findEnumMember } from "../utils/helpers/enum";
|
||||
|
||||
interface FactionWorkParams {
|
||||
singularity: boolean;
|
||||
@ -93,7 +94,8 @@ export class FactionWork extends Work {
|
||||
/** Initializes a FactionWork object from a JSON save state. */
|
||||
static fromJSON(value: IReviverValue): FactionWork {
|
||||
const factionWork = Generic_fromJSON(FactionWork, value.data);
|
||||
factionWork.factionWorkType = factionWork.factionWorkType.toLowerCase() as FactionWorkType;
|
||||
factionWork.factionWorkType =
|
||||
findEnumMember(FactionWorkType, factionWork.factionWorkType) ?? FactionWorkType.hacking;
|
||||
return factionWork;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user