mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2024-12-20 05:05:47 +01:00
parent
cb92643c7e
commit
3afafe4454
@ -3,7 +3,7 @@ import type { Sleeve as NetscriptSleeve } from "@nsdefs";
|
|||||||
import type { ActionIdentifier } from "../Bladeburner/Types";
|
import type { ActionIdentifier } from "../Bladeburner/Types";
|
||||||
|
|
||||||
import { Player } from "@player";
|
import { Player } from "@player";
|
||||||
import { BladeActionType } from "@enums";
|
import { BladeActionType, type BladeContractName } from "@enums";
|
||||||
import { Augmentations } from "../Augmentation/Augmentations";
|
import { Augmentations } from "../Augmentation/Augmentations";
|
||||||
import { findCrime } from "../Crime/CrimeHelpers";
|
import { findCrime } from "../Crime/CrimeHelpers";
|
||||||
import { getEnumHelper } from "../utils/EnumHelper";
|
import { getEnumHelper } from "../utils/EnumHelper";
|
||||||
@ -238,24 +238,23 @@ 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;
|
let contract: BladeContractName | undefined = undefined;
|
||||||
if (action === "Take on contracts") {
|
if (action === "Take on contracts") {
|
||||||
const contractEnum = getEnumHelper("BladeContractName").nsGetMember(ctx, _contract);
|
contract = 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 === contractEnum) {
|
if (otherWork?.type === SleeveWorkType.BLADEBURNER && otherWork.actionId.name === contract) {
|
||||||
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: contractEnum };
|
const actionId: ActionIdentifier = { type: BladeActionType.contract, name: contract };
|
||||||
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, contract);
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user