mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-23 01:32:55 +02:00
TYPESAFETY: Strict internal typing for AugmentationName (#608)
This commit is contained in:
@@ -1,9 +1,9 @@
|
||||
import { Player } from "@player";
|
||||
import type { Augmentation } from "../Augmentation/Augmentation";
|
||||
import type { Sleeve as NetscriptSleeve } from "@nsdefs";
|
||||
import { StaticAugmentations } from "../Augmentation/StaticAugmentations";
|
||||
import { findCrime } from "../Crime/CrimeHelpers";
|
||||
import { Augmentation } from "../Augmentation/Augmentation";
|
||||
|
||||
import { Player } from "@player";
|
||||
import { Augmentations } from "../Augmentation/Augmentations";
|
||||
import { findCrime } from "../Crime/CrimeHelpers";
|
||||
import { getEnumHelper } from "../utils/EnumHelper";
|
||||
import { InternalAPI, NetscriptContext, removedFunction } from "../Netscript/APIWrapper";
|
||||
import { isSleeveBladeburnerWork } from "../PersonObjects/Sleeve/Work/SleeveBladeburnerWork";
|
||||
@@ -11,6 +11,7 @@ import { isSleeveFactionWork } from "../PersonObjects/Sleeve/Work/SleeveFactionW
|
||||
import { isSleeveCompanyWork } from "../PersonObjects/Sleeve/Work/SleeveCompanyWork";
|
||||
import { helpers } from "../Netscript/NetscriptHelpers";
|
||||
import { cloneDeep } from "lodash";
|
||||
import { getAugCost } from "../Augmentation/AugmentationHelpers";
|
||||
|
||||
export function NetscriptSleeve(): InternalAPI<NetscriptSleeve> {
|
||||
const checkSleeveAPIAccess = function (ctx: NetscriptContext) {
|
||||
@@ -198,7 +199,7 @@ export function NetscriptSleeve(): InternalAPI<NetscriptSleeve> {
|
||||
},
|
||||
purchaseSleeveAug: (ctx) => (_sleeveNumber, _augName) => {
|
||||
const sleeveNumber = helpers.number(ctx, "sleeveNumber", _sleeveNumber);
|
||||
const augName = helpers.string(ctx, "augName", _augName);
|
||||
const augName = getEnumHelper("AugmentationName").nsGetMember(ctx, _augName);
|
||||
checkSleeveAPIAccess(ctx);
|
||||
checkSleeveNumber(ctx, sleeveNumber);
|
||||
|
||||
@@ -206,7 +207,7 @@ export function NetscriptSleeve(): InternalAPI<NetscriptSleeve> {
|
||||
throw helpers.makeRuntimeErrorMsg(ctx, `Sleeve shock too high: Sleeve ${sleeveNumber}`);
|
||||
}
|
||||
|
||||
const aug = StaticAugmentations[augName];
|
||||
const aug = Augmentations[augName];
|
||||
if (!aug) {
|
||||
throw helpers.makeRuntimeErrorMsg(ctx, `Invalid aug: ${augName}`);
|
||||
}
|
||||
@@ -215,15 +216,15 @@ export function NetscriptSleeve(): InternalAPI<NetscriptSleeve> {
|
||||
},
|
||||
getSleeveAugmentationPrice: (ctx) => (_augName) => {
|
||||
checkSleeveAPIAccess(ctx);
|
||||
const augName = helpers.string(ctx, "augName", _augName);
|
||||
const aug: Augmentation = StaticAugmentations[augName];
|
||||
const augName = getEnumHelper("AugmentationName").nsGetMember(ctx, _augName);
|
||||
const aug: Augmentation = Augmentations[augName];
|
||||
return aug.baseCost;
|
||||
},
|
||||
getSleeveAugmentationRepReq: (ctx) => (_augName) => {
|
||||
checkSleeveAPIAccess(ctx);
|
||||
const augName = helpers.string(ctx, "augName", _augName);
|
||||
const aug: Augmentation = StaticAugmentations[augName];
|
||||
return aug.getCost().repCost;
|
||||
const augName = getEnumHelper("AugmentationName").nsGetMember(ctx, _augName);
|
||||
const aug: Augmentation = Augmentations[augName];
|
||||
return getAugCost(aug).repCost;
|
||||
},
|
||||
setToBladeburnerAction: (ctx) => (_sleeveNumber, _action, _contract?) => {
|
||||
const sleeveNumber = helpers.number(ctx, "sleeveNumber", _sleeveNumber);
|
||||
|
||||
Reference in New Issue
Block a user