MISC: A bunch of enums stuff. (#212)

* Some game enums moved to utils/enums. Others can eventually be moved there as well.
* findEnumMember function for performing fuzzy matching of player input with enum members, without needing separate fuzzy functions for every enum.
* Also used findEnumMember for safely loading save games (allows case changes in enum values)
* Changed capitalization on some enums.
* BREAKING: removed classGains work formulas function
* Split ClassType enum into UniversityClassType and GymType.
* Added universityGains and gymGains work formulas functions
* Provided the new split enums to the player on ns.enums.
This commit is contained in:
Snarling
2022-11-20 08:37:11 -05:00
committed by GitHub
parent 629d610532
commit 88d51e9a7e
34 changed files with 346 additions and 432 deletions
+5 -3
View File
@@ -11,7 +11,7 @@ import { Reputation } from "../ui/React/Reputation";
import { CONSTANTS } from "../Constants";
import { AugmentationNames } from "../Augmentation/data/AugmentationNames";
import { calculateFactionExp, calculateFactionRep } from "./Formulas";
import { FactionWorkType } from "./data/FactionWorkType";
import { FactionWorkType } from "../utils/enums";
interface FactionWorkParams {
singularity: boolean;
@@ -27,7 +27,7 @@ export class FactionWork extends Work {
constructor(params?: FactionWorkParams) {
super(WorkType.FACTION, params?.singularity ?? true);
this.factionWorkType = params?.factionWorkType ?? FactionWorkType.HACKING;
this.factionWorkType = params?.factionWorkType ?? FactionWorkType.hacking;
this.factionName = params?.faction ?? FactionNames.Sector12;
}
@@ -92,7 +92,9 @@ export class FactionWork extends Work {
/** Initializes a FactionWork object from a JSON save state. */
static fromJSON(value: IReviverValue): FactionWork {
return Generic_fromJSON(FactionWork, value.data);
const factionWork = Generic_fromJSON(FactionWork, value.data);
factionWork.factionWorkType = factionWork.factionWorkType.toLowerCase() as FactionWorkType;
return factionWork;
}
}