diff --git a/src/NetscriptFunctions/Sleeve.ts b/src/NetscriptFunctions/Sleeve.ts index 144cb3938..253a09d3b 100644 --- a/src/NetscriptFunctions/Sleeve.ts +++ b/src/NetscriptFunctions/Sleeve.ts @@ -3,7 +3,7 @@ import type { Sleeve as NetscriptSleeve } from "@nsdefs"; import type { ActionIdentifier } from "../Bladeburner/Types"; import { Player } from "@player"; -import { BladeActionType } from "@enums"; +import { BladeActionType, type BladeContractName } from "@enums"; import { Augmentations } from "../Augmentation/Augmentations"; import { findCrime } from "../Crime/CrimeHelpers"; import { getEnumHelper } from "../utils/EnumHelper"; @@ -238,24 +238,23 @@ export function NetscriptSleeve(): InternalAPI { const action = helpers.string(ctx, "action", _action); checkSleeveAPIAccess(ctx); checkSleeveNumber(ctx, sleeveNumber); - let contractName = undefined; + let contract: BladeContractName | undefined = undefined; if (action === "Take on contracts") { - const contractEnum = getEnumHelper("BladeContractName").nsGetMember(ctx, _contract); - contractName = helpers.string(ctx, "contract", _contract); + contract = getEnumHelper("BladeContractName").nsGetMember(ctx, _contract); for (let i = 0; i < Player.sleeves.length; ++i) { if (i === sleeveNumber) continue; const otherWork = Player.sleeves[i].currentWork; - if (otherWork?.type === SleeveWorkType.BLADEBURNER && otherWork.actionId.name === contractEnum) { + if (otherWork?.type === SleeveWorkType.BLADEBURNER && otherWork.actionId.name === contract) { throw helpers.errorMessage( ctx, `Sleeve ${sleeveNumber} cannot take on contracts because Sleeve ${i} is already performing that action.`, ); } } - const actionId: ActionIdentifier = { type: BladeActionType.contract, name: contractEnum }; + const actionId: ActionIdentifier = { type: BladeActionType.contract, name: contract }; Player.sleeves[sleeveNumber].startWork(new SleeveBladeburnerWork({ actionId })); } - return Player.sleeves[sleeveNumber].bladeburner(action, contractName); + return Player.sleeves[sleeveNumber].bladeburner(action, contract); }, };