mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-30 21:07:04 +02:00
ENUMS: Initial Enum Helper rework + Reorganization (#596)
This commit is contained in:
@@ -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;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user