BUGFIX: BB Sleeves cannot be assigned to contract programmatically (#1314)

This commit is contained in:
Sphyxis 2024-05-27 19:32:21 -06:00 committed by GitHub
parent e674a177d6
commit bed66f980f
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -238,23 +238,24 @@ export function NetscriptSleeve(): InternalAPI<NetscriptSleeve> {
const action = helpers.string(ctx, "action", _action); const action = helpers.string(ctx, "action", _action);
checkSleeveAPIAccess(ctx); checkSleeveAPIAccess(ctx);
checkSleeveNumber(ctx, sleeveNumber); checkSleeveNumber(ctx, sleeveNumber);
let contractName = undefined;
if (action === "Take on contracts") { 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) { for (let i = 0; i < Player.sleeves.length; ++i) {
if (i === sleeveNumber) continue; if (i === sleeveNumber) continue;
const otherWork = Player.sleeves[i].currentWork; 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( throw helpers.errorMessage(
ctx, ctx,
`Sleeve ${sleeveNumber} cannot take on contracts because Sleeve ${i} is already performing that action.`, `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 })); Player.sleeves[sleeveNumber].startWork(new SleeveBladeburnerWork({ actionId }));
} }
return Player.sleeves[sleeveNumber].bladeburner(action, contractName);
return Player.sleeves[sleeveNumber].bladeburner(action);
}, },
}; };