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
+9 -13
View File
@@ -1,13 +1,13 @@
import type { Bladeburner as INetscriptBladeburner } from "@nsdefs";
import type { Action } from "../Bladeburner/Action";
import type { InternalAPI, NetscriptContext } from "../Netscript/APIWrapper";
import { Player } from "@player";
import { Bladeburner } from "../Bladeburner/Bladeburner";
import { BitNodeMultipliers } from "../BitNode/BitNodeMultipliers";
import { Bladeburner as INetscriptBladeburner } from "@nsdefs";
import { Action } from "src/Bladeburner/Action";
import { InternalAPI, NetscriptContext } from "src/Netscript/APIWrapper";
import { BlackOperation } from "../Bladeburner/BlackOperation";
import { helpers } from "../Netscript/NetscriptHelpers";
import { checkEnum } from "../utils/helpers/enum";
import { CityName } from "../Enums";
import { getEnumHelper } from "../utils/EnumHelper";
export function NetscriptBladeburner(): InternalAPI<INetscriptBladeburner> {
const checkBladeburnerAccess = function (ctx: NetscriptContext): void {
@@ -266,20 +266,17 @@ export function NetscriptBladeburner(): InternalAPI<INetscriptBladeburner> {
},
getCityEstimatedPopulation: (ctx) => (_cityName) => {
const bladeburner = getBladeburner(ctx);
const cityName = helpers.string(ctx, "cityName", _cityName);
if (!checkEnum(CityName, cityName)) throw new Error(`Invalid city: ${cityName}`);
const cityName = getEnumHelper("CityName").nsGetMember(ctx, _cityName);
return bladeburner.cities[cityName].popEst;
},
getCityCommunities: (ctx) => (_cityName) => {
const bladeburner = getBladeburner(ctx);
const cityName = helpers.string(ctx, "cityName", _cityName);
if (!checkEnum(CityName, cityName)) throw new Error(`Invalid city: ${cityName}`);
const cityName = getEnumHelper("CityName").nsGetMember(ctx, _cityName);
return bladeburner.cities[cityName].comms;
},
getCityChaos: (ctx) => (_cityName) => {
const bladeburner = getBladeburner(ctx);
const cityName = helpers.string(ctx, "cityName", _cityName);
if (!checkEnum(CityName, cityName)) throw new Error(`Invalid city: ${cityName}`);
const cityName = getEnumHelper("CityName").nsGetMember(ctx, _cityName);
return bladeburner.cities[cityName].chaos;
},
getCity: (ctx) => () => {
@@ -288,8 +285,7 @@ export function NetscriptBladeburner(): InternalAPI<INetscriptBladeburner> {
},
switchCity: (ctx) => (_cityName) => {
const bladeburner = getBladeburner(ctx);
const cityName = helpers.string(ctx, "cityName", _cityName);
if (!checkEnum(CityName, cityName)) throw new Error(`Invalid city: ${cityName}`);
const cityName = getEnumHelper("CityName").nsGetMember(ctx, _cityName);
bladeburner.city = cityName;
return true;
},