ENUMS: Initial Enum Helper rework + Reorganization (#596)

This commit is contained in:
Snarling
2023-06-12 00:34:20 -04:00
committed by GitHub
parent 6ed8ea9796
commit 6732549196
224 changed files with 2126 additions and 2171 deletions
+13 -8
View File
@@ -26,7 +26,15 @@ import {
calculateGrowTime,
calculateWeakenTime,
} from "../Hacking";
import { CompletedProgramName } from "../Programs/Programs";
import {
CityName,
CompletedProgramName,
FactionWorkType,
GymType,
JobName,
LocationName,
UniversityClassType,
} from "@enums";
import { Formulas as IFormulas, Player as IPlayer, Person as IPerson } from "@nsdefs";
import {
calculateRespectGain,
@@ -45,11 +53,10 @@ import { calculateCompanyWorkStats } from "../Work/Formulas";
import { Companies } from "../Company/Companies";
import { calculateClassEarnings } from "../Work/Formulas";
import { calculateFactionExp, calculateFactionRep } from "../Work/Formulas";
import { FactionWorkType, GymType, UniversityClassType, LocationName, CityName } from "../Enums";
import { defaultMultipliers } from "../PersonObjects/Multipliers";
import { checkEnum, findEnumMember } from "../utils/helpers/enum";
import { JobName } from "../Enums";
import { findEnumMember } from "../utils/helpers/enum";
import { getEnumHelper } from "../utils/EnumHelper";
import { CompanyPositions } from "../Company/CompanyPositions";
import { findCrime } from "../Crime/CrimeHelpers";
@@ -384,8 +391,7 @@ export function NetscriptFormulas(): InternalAPI<IFormulas> {
const person = helpers.person(ctx, _person);
const classType = findEnumMember(GymType, helpers.string(ctx, "classType", _classType));
if (!classType) throw new Error(`Invalid gym training type: ${_classType}`);
const locationName = helpers.string(ctx, "locationName", _locationName);
if (!checkEnum(LocationName, locationName)) throw new Error(`Invalid location name: ${locationName}`);
const locationName = getEnumHelper("LocationName").nsGetMember(ctx, _locationName);
return calculateClassEarnings(person, classType, locationName);
},
universityGains: (ctx) => (_person, _classType, _locationName) => {
@@ -393,8 +399,7 @@ export function NetscriptFormulas(): InternalAPI<IFormulas> {
const person = helpers.person(ctx, _person);
const classType = findEnumMember(UniversityClassType, helpers.string(ctx, "classType", _classType));
if (!classType) throw new Error(`Invalid university class type: ${_classType}`);
const locationName = helpers.string(ctx, "locationName", _locationName);
if (!checkEnum(LocationName, locationName)) throw new Error(`Invalid location name: ${locationName}`);
const locationName = getEnumHelper("LocationName").nsGetMember(ctx, _locationName);
return calculateClassEarnings(person, classType, locationName);
},
factionGains: (ctx) => (_player, _workType, _favor) => {