mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-11-10 01:33:54 +01:00
parent
cb92643c7e
commit
3afafe4454
@ -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<NetscriptSleeve> {
|
||||
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);
|
||||
},
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user