mirror of
https://github.com/bitburner-official/bitburner-src.git
synced 2026-04-17 23:08:36 +02:00
BUGFIX: Sleeve takes on contracts without checking availability (#1946)
This commit is contained in:
@@ -136,9 +136,10 @@ export class Bladeburner implements OperationTeam {
|
|||||||
this.resetAction();
|
this.resetAction();
|
||||||
return { success: true, message: "Stopped current Bladeburner action" };
|
return { success: true, message: "Stopped current Bladeburner action" };
|
||||||
}
|
}
|
||||||
if (!Player.hasAugmentation(AugmentationName.BladesSimulacrum, true)) Player.finishWork(true);
|
if (!Player.hasAugmentation(AugmentationName.BladesSimulacrum, true)) {
|
||||||
|
Player.finishWork(true);
|
||||||
|
}
|
||||||
const action = this.getActionObject(actionId);
|
const action = this.getActionObject(actionId);
|
||||||
// This switch statement is just for handling error cases, it does not have to be exhaustive
|
|
||||||
const availability = action.getAvailability(this);
|
const availability = action.getAvailability(this);
|
||||||
if (!availability.available) {
|
if (!availability.available) {
|
||||||
return { message: `Could not start action ${action.name}: ${availability.error}` };
|
return { message: `Could not start action ${action.name}: ${availability.error}` };
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ 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";
|
||||||
import { InternalAPI, NetscriptContext, setRemovedFunctions } from "../Netscript/APIWrapper";
|
import { InternalAPI, NetscriptContext, setRemovedFunctions } from "../Netscript/APIWrapper";
|
||||||
import { SleeveBladeburnerWork } from "../PersonObjects/Sleeve/Work/SleeveBladeburnerWork";
|
|
||||||
import { isSleeveFactionWork } from "../PersonObjects/Sleeve/Work/SleeveFactionWork";
|
import { isSleeveFactionWork } from "../PersonObjects/Sleeve/Work/SleeveFactionWork";
|
||||||
import { isSleeveCompanyWork } from "../PersonObjects/Sleeve/Work/SleeveCompanyWork";
|
import { isSleeveCompanyWork } from "../PersonObjects/Sleeve/Work/SleeveCompanyWork";
|
||||||
import { helpers } from "../Netscript/NetscriptHelpers";
|
import { helpers } from "../Netscript/NetscriptHelpers";
|
||||||
@@ -259,11 +258,17 @@ 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);
|
||||||
|
if (!Player.bladeburner) {
|
||||||
|
helpers.log(ctx, () => "You must be a member of the Bladeburner division to use this API.");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
let contract: BladeburnerContractName | undefined = undefined;
|
let contract: BladeburnerContractName | undefined = undefined;
|
||||||
if (action === "Take on contracts") {
|
if (action === "Take on contracts") {
|
||||||
contract = getEnumHelper("BladeburnerContractName").nsGetMember(ctx, _contract);
|
contract = getEnumHelper("BladeburnerContractName").nsGetMember(ctx, _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 === contract) {
|
||||||
throw helpers.errorMessage(
|
throw helpers.errorMessage(
|
||||||
@@ -273,7 +278,11 @@ export function NetscriptSleeve(): InternalAPI<NetscriptSleeve> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
const actionId: ActionIdentifier = { type: BladeburnerActionType.Contract, name: contract };
|
const actionId: ActionIdentifier = { type: BladeburnerActionType.Contract, name: contract };
|
||||||
Player.sleeves[sleeveNumber].startWork(new SleeveBladeburnerWork({ actionId }));
|
const availability = Player.bladeburner.getActionObject(actionId).getAvailability(Player.bladeburner);
|
||||||
|
if (!availability.available) {
|
||||||
|
helpers.log(ctx, () => `Could not start action ${contract}: ${availability.error}`);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return Player.sleeves[sleeveNumber].bladeburner(action, contract);
|
return Player.sleeves[sleeveNumber].bladeburner(action, contract);
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user