From bed66f980f6b94a2a3987a4406b1feb83400df81 Mon Sep 17 00:00:00 2001 From: Sphyxis <148732459+Sphyxis@users.noreply.github.com> Date: Mon, 27 May 2024 19:32:21 -0600 Subject: [PATCH] BUGFIX: BB Sleeves cannot be assigned to contract programmatically (#1314) --- src/NetscriptFunctions/Sleeve.ts | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/NetscriptFunctions/Sleeve.ts b/src/NetscriptFunctions/Sleeve.ts index 49260f4d7..144cb3938 100644 --- a/src/NetscriptFunctions/Sleeve.ts +++ b/src/NetscriptFunctions/Sleeve.ts @@ -238,23 +238,24 @@ export function NetscriptSleeve(): InternalAPI { const action = helpers.string(ctx, "action", _action); checkSleeveAPIAccess(ctx); checkSleeveNumber(ctx, sleeveNumber); + let contractName = undefined; if (action === "Take on contracts") { - const contract = getEnumHelper("BladeContractName").nsGetMember(ctx, _contract); + const contractEnum = getEnumHelper("BladeContractName").nsGetMember(ctx, _contract); + contractName = helpers.string(ctx, "contract", _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 === contract) { + if (otherWork?.type === SleeveWorkType.BLADEBURNER && otherWork.actionId.name === contractEnum) { 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: contract }; + const actionId: ActionIdentifier = { type: BladeActionType.contract, name: contractEnum }; Player.sleeves[sleeveNumber].startWork(new SleeveBladeburnerWork({ actionId })); } - - return Player.sleeves[sleeveNumber].bladeburner(action); + return Player.sleeves[sleeveNumber].bladeburner(action, contractName); }, };