From 2a149df13e1f9739d8dba536235a75f73794d8b6 Mon Sep 17 00:00:00 2001 From: TheAimMan <147098375+TheAimMan@users.noreply.github.com> Date: Mon, 30 Oct 2023 03:11:51 -0400 Subject: [PATCH] BUGFIX: Contracts now fail if there are 0 of them remaining (#889) --- src/Bladeburner/Bladeburner.tsx | 8 +++++++- src/PersonObjects/Sleeve/Work/SleeveBladeburnerWork.ts | 4 ++-- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/src/Bladeburner/Bladeburner.tsx b/src/Bladeburner/Bladeburner.tsx index 70a31c916..325f383f8 100644 --- a/src/Bladeburner/Bladeburner.tsx +++ b/src/Bladeburner/Bladeburner.tsx @@ -1663,7 +1663,13 @@ export class Bladeburner { if (!this.action) { throw new Error("Bladeburner.action is not an ActionIdentifier Object"); } - + //Check to see if action is a contract, and then to verify a sleeve didn't finish it first + if (this.action.type === 2) { + const remainingActions = this.contracts[this.action.name].count; + if (remainingActions < 1) { + return this.resetAction(); + } + } // If the previous action went past its completion time, add to the next action // This is not added immediately in case the automation changes the action this.actionTimeCurrent += seconds + this.actionTimeOverflow; diff --git a/src/PersonObjects/Sleeve/Work/SleeveBladeburnerWork.ts b/src/PersonObjects/Sleeve/Work/SleeveBladeburnerWork.ts index a2513c501..708d4f2f4 100644 --- a/src/PersonObjects/Sleeve/Work/SleeveBladeburnerWork.ts +++ b/src/PersonObjects/Sleeve/Work/SleeveBladeburnerWork.ts @@ -40,14 +40,14 @@ export class SleeveBladeburnerWork extends SleeveWorkClass { if (this.actionType === "Contracts") { const action = Player.bladeburner.getActionObject(actionIdent); if (!action) throw new Error(`Error getting ${this.actionName} action object`); - if (action.count <= 0) return sleeve.stopWork(); + if (action.count < 1) return sleeve.stopWork(); } while (this.cyclesWorked > this.cyclesNeeded(sleeve)) { if (this.actionType === "Contracts") { const action = Player.bladeburner.getActionObject(actionIdent); if (!action) throw new Error(`Error getting ${this.actionName} action object`); - if (action.count <= 0) return sleeve.stopWork(); + if (action.count < 1) return sleeve.stopWork(); } const retValue = Player.bladeburner.completeAction(sleeve, actionIdent, false); if (this.actionType === "General") {