mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-05-09 09:07:47 +02:00
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:
@@ -5,6 +5,8 @@ import { LocationName } from "../../../Locations/data/LocationNames";
|
||||
import { calculateClassEarnings } from "../../../Work/Formulas";
|
||||
import { Sleeve } from "../Sleeve";
|
||||
import { scaleWorkStats, WorkStats } from "../../../Work/WorkStats";
|
||||
import { GymType, UniversityClassType } from "../../../utils/enums";
|
||||
import { checkEnum } from "../../../utils/helpers/enum";
|
||||
|
||||
export const isSleeveClassWork = (w: Work | null): w is SleeveClassWork => w !== null && w.type === WorkType.CLASS;
|
||||
|
||||
@@ -19,7 +21,7 @@ export class SleeveClassWork extends Work {
|
||||
|
||||
constructor(params?: ClassWorkParams) {
|
||||
super(WorkType.CLASS);
|
||||
this.classType = params?.classType ?? ClassType.StudyComputerScience;
|
||||
this.classType = params?.classType ?? UniversityClassType.computerScience;
|
||||
this.location = params?.location ?? LocationName.Sector12RothmanUniversity;
|
||||
}
|
||||
|
||||
@@ -28,9 +30,7 @@ export class SleeveClassWork extends Work {
|
||||
}
|
||||
|
||||
isGym(): boolean {
|
||||
return [ClassType.GymAgility, ClassType.GymDefense, ClassType.GymDexterity, ClassType.GymStrength].includes(
|
||||
this.classType,
|
||||
);
|
||||
return checkEnum(GymType, this.classType);
|
||||
}
|
||||
|
||||
process(sleeve: Sleeve, cycles: number) {
|
||||
|
||||
@@ -2,13 +2,14 @@ import { Player } from "@player";
|
||||
import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../../../utils/JSONReviver";
|
||||
import { Sleeve } from "../Sleeve";
|
||||
import { applySleeveGains, Work, WorkType } from "./Work";
|
||||
import { CrimeType } from "../../../utils/WorkType";
|
||||
import { CrimeType } from "../../../utils/enums";
|
||||
import { Crimes } from "../../../Crime/Crimes";
|
||||
import { Crime } from "../../../Crime/Crime";
|
||||
import { scaleWorkStats, WorkStats } from "../../../Work/WorkStats";
|
||||
import { CONSTANTS } from "../../../Constants";
|
||||
import { checkEnum } from "../../../utils/helpers/checkEnum";
|
||||
import { checkEnum } from "../../../utils/helpers/enum";
|
||||
import { calculateCrimeWorkStats } from "../../../Work/Formulas";
|
||||
import { findCrime } from "../../../Crime/CrimeHelpers";
|
||||
|
||||
export const isSleeveCrimeWork = (w: Work | null): w is SleeveCrimeWork => w !== null && w.type === WorkType.CRIME;
|
||||
|
||||
@@ -17,7 +18,7 @@ export class SleeveCrimeWork extends Work {
|
||||
cyclesWorked = 0;
|
||||
constructor(crimeType?: CrimeType) {
|
||||
super(WorkType.CRIME);
|
||||
this.crimeType = crimeType ?? CrimeType.SHOPLIFT;
|
||||
this.crimeType = crimeType ?? CrimeType.shoplift;
|
||||
}
|
||||
|
||||
getCrime(): Crime {
|
||||
@@ -60,7 +61,9 @@ export class SleeveCrimeWork extends Work {
|
||||
|
||||
/** Initializes a RecoveryWork object from a JSON save state. */
|
||||
static fromJSON(value: IReviverValue): SleeveCrimeWork {
|
||||
return Generic_fromJSON(SleeveCrimeWork, value.data);
|
||||
const crimeWork = Generic_fromJSON(SleeveCrimeWork, value.data);
|
||||
crimeWork.crimeType = findCrime(crimeWork.crimeType)?.type ?? CrimeType.shoplift;
|
||||
return crimeWork;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Player } from "@player";
|
||||
import { Generic_fromJSON, Generic_toJSON, IReviverValue, Reviver } from "../../../utils/JSONReviver";
|
||||
import { Sleeve } from "../Sleeve";
|
||||
import { applySleeveGains, Work, WorkType } from "./Work";
|
||||
import { FactionWorkType } from "../../../Work/data/FactionWorkType";
|
||||
import { FactionWorkType } from "../../../utils/enums";
|
||||
import { FactionNames } from "../../../Faction/data/FactionNames";
|
||||
import { Factions } from "../../../Faction/Factions";
|
||||
import { calculateFactionExp, calculateFactionRep } from "../../../Work/Formulas";
|
||||
@@ -23,7 +23,7 @@ export class SleeveFactionWork extends Work {
|
||||
|
||||
constructor(params?: SleeveFactionWorkParams) {
|
||||
super(WorkType.FACTION);
|
||||
this.factionWorkType = params?.factionWorkType ?? FactionWorkType.HACKING;
|
||||
this.factionWorkType = params?.factionWorkType ?? FactionWorkType.hacking;
|
||||
this.factionName = params?.factionName ?? FactionNames.Sector12;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user