diff --git a/markdown/bitburner.sleevebladeburnertask.md b/markdown/bitburner.sleevebladeburnertask.md index 798bab62e..1c5bec15c 100644 --- a/markdown/bitburner.sleevebladeburnertask.md +++ b/markdown/bitburner.sleevebladeburnertask.md @@ -13,5 +13,6 @@ type SleeveBladeburnerTask = { actionType: "General" | "Contracts"; actionName: string; cyclesWorked: number; + cyclesNeeded: number; }; ``` diff --git a/markdown/bitburner.sleevecrimetask.md b/markdown/bitburner.sleevecrimetask.md index e4ef12182..7f0cddbaa 100644 --- a/markdown/bitburner.sleevecrimetask.md +++ b/markdown/bitburner.sleevecrimetask.md @@ -8,7 +8,12 @@ **Signature:** ```typescript -type SleeveCrimeTask = { type: "CRIME"; crimeType: CrimeType | `${CrimeType}`; cyclesWorked: number }; +type SleeveCrimeTask = { + type: "CRIME"; + crimeType: CrimeType | `${CrimeType}`; + cyclesWorked: number; + cyclesNeeded: number; +}; ``` **References:** [CrimeType](./bitburner.crimetype.md) diff --git a/markdown/bitburner.sleeveinfiltratetask.md b/markdown/bitburner.sleeveinfiltratetask.md index c4076cbc3..ec850d5a4 100644 --- a/markdown/bitburner.sleeveinfiltratetask.md +++ b/markdown/bitburner.sleeveinfiltratetask.md @@ -8,5 +8,5 @@ **Signature:** ```typescript -type SleeveInfiltrateTask = { type: "INFILTRATE"; cyclesWorked: number }; +type SleeveInfiltrateTask = { type: "INFILTRATE"; cyclesWorked: number; cyclesNeeded: number }; ``` diff --git a/src/NetscriptFunctions/Sleeve.ts b/src/NetscriptFunctions/Sleeve.ts index 63770ec23..b2e6c40b5 100644 --- a/src/NetscriptFunctions/Sleeve.ts +++ b/src/NetscriptFunctions/Sleeve.ts @@ -150,7 +150,7 @@ export function NetscriptSleeve(): InternalAPI { const sl = Player.sleeves[sleeveNumber]; if (sl.currentWork === null) return null; - return sl.currentWork.APICopy(); + return sl.currentWork.APICopy(sl); }, getSleeve: (ctx) => (_sleeveNumber) => { const sleeveNumber = helpers.number(ctx, "sleeveNumber", _sleeveNumber); diff --git a/src/PersonObjects/Sleeve/Sleeve.ts b/src/PersonObjects/Sleeve/Sleeve.ts index 5a8f543bf..3aa515d31 100644 --- a/src/PersonObjects/Sleeve/Sleeve.ts +++ b/src/PersonObjects/Sleeve/Sleeve.ts @@ -286,7 +286,7 @@ export class Sleeve extends Person implements SleevePerson { if (company == null) return false; if (companyPosition == null) return false; - this.startWork(new SleeveCompanyWork({ companyName: companyName })); + this.startWork(new SleeveCompanyWork(companyName)); return true; } diff --git a/src/PersonObjects/Sleeve/Work/SleeveBladeburnerWork.ts b/src/PersonObjects/Sleeve/Work/SleeveBladeburnerWork.ts index cfcd3555b..6032c8446 100644 --- a/src/PersonObjects/Sleeve/Work/SleeveBladeburnerWork.ts +++ b/src/PersonObjects/Sleeve/Work/SleeveBladeburnerWork.ts @@ -32,7 +32,7 @@ export class SleeveBladeburnerWork extends Work { } process(sleeve: Sleeve, cycles: number) { - if (!Player.bladeburner) throw new Error("sleeve doing blade work without being a member"); + if (!Player.bladeburner) return sleeve.stopWork(); this.cyclesWorked += cycles; const actionIdent = Player.bladeburner.getActionIdFromTypeAndName(this.actionType, this.actionName); if (!actionIdent) throw new Error(`Error getting ${this.actionName} action`); @@ -62,12 +62,13 @@ export class SleeveBladeburnerWork extends Work { } } - APICopy() { + APICopy(sleeve: Sleeve) { return { type: WorkType.BLADEBURNER as "BLADEBURNER", actionType: this.actionType, actionName: this.actionName, cyclesWorked: this.cyclesWorked, + cyclesNeeded: this.cyclesNeeded(sleeve), }; } diff --git a/src/PersonObjects/Sleeve/Work/SleeveCompanyWork.ts b/src/PersonObjects/Sleeve/Work/SleeveCompanyWork.ts index 5df7fd808..da3bf2d9f 100644 --- a/src/PersonObjects/Sleeve/Work/SleeveCompanyWork.ts +++ b/src/PersonObjects/Sleeve/Work/SleeveCompanyWork.ts @@ -10,19 +10,15 @@ import { influenceStockThroughCompanyWork } from "../../../StockMarket/PlayerInf import { Player } from "@player"; import { CompanyPositions } from "../../../Company/CompanyPositions"; -interface SleeveCompanyWorkParams { - companyName: string; -} - export const isSleeveCompanyWork = (w: Work | null): w is SleeveCompanyWork => w !== null && w.type === WorkType.COMPANY; export class SleeveCompanyWork extends Work { companyName: string; - constructor(params?: SleeveCompanyWorkParams) { + constructor(companyName?: string) { super(WorkType.COMPANY); - this.companyName = params?.companyName ?? LocationName.NewTokyoNoodleBar; + this.companyName = companyName ?? LocationName.NewTokyoNoodleBar; } getCompany(): Company { diff --git a/src/PersonObjects/Sleeve/Work/SleeveCrimeWork.ts b/src/PersonObjects/Sleeve/Work/SleeveCrimeWork.ts index 9987910e1..cc03db12c 100644 --- a/src/PersonObjects/Sleeve/Work/SleeveCrimeWork.ts +++ b/src/PersonObjects/Sleeve/Work/SleeveCrimeWork.ts @@ -52,6 +52,7 @@ export class SleeveCrimeWork extends Work { type: WorkType.CRIME as "CRIME", crimeType: this.crimeType, cyclesWorked: this.cyclesWorked, + cyclesNeeded: this.cyclesNeeded(), }; } diff --git a/src/PersonObjects/Sleeve/Work/SleeveInfiltrateWork.ts b/src/PersonObjects/Sleeve/Work/SleeveInfiltrateWork.ts index 6a9396e81..0727f1556 100644 --- a/src/PersonObjects/Sleeve/Work/SleeveInfiltrateWork.ts +++ b/src/PersonObjects/Sleeve/Work/SleeveInfiltrateWork.ts @@ -20,8 +20,8 @@ export class SleeveInfiltrateWork extends Work { return infiltrateCycles; } - process(_sleeve: Sleeve, cycles: number) { - if (!Player.bladeburner) throw new Error("sleeve doing blade work without being a member"); + process(sleeve: Sleeve, cycles: number) { + if (!Player.bladeburner) return sleeve.stopWork(); this.cyclesWorked += cycles; if (this.cyclesWorked > this.cyclesNeeded()) { this.cyclesWorked -= this.cyclesNeeded(); @@ -33,6 +33,7 @@ export class SleeveInfiltrateWork extends Work { return { type: WorkType.INFILTRATE as "INFILTRATE", cyclesWorked: this.cyclesWorked, + cyclesNeeded: this.cyclesNeeded(), }; } diff --git a/src/PersonObjects/Sleeve/Work/SleeveRecoveryWork.ts b/src/PersonObjects/Sleeve/Work/SleeveRecoveryWork.ts index a27ca27b6..f886f5d6c 100644 --- a/src/PersonObjects/Sleeve/Work/SleeveRecoveryWork.ts +++ b/src/PersonObjects/Sleeve/Work/SleeveRecoveryWork.ts @@ -20,9 +20,7 @@ export class SleeveRecoveryWork extends Work { } APICopy() { - return { - type: WorkType.RECOVERY as "RECOVERY", - }; + return { type: WorkType.RECOVERY as "RECOVERY" }; } /** Serialize the current object to a JSON save state. */ diff --git a/src/PersonObjects/Sleeve/Work/SleeveSupportWork.ts b/src/PersonObjects/Sleeve/Work/SleeveSupportWork.ts index 995f4ad4f..f02a65711 100644 --- a/src/PersonObjects/Sleeve/Work/SleeveSupportWork.ts +++ b/src/PersonObjects/Sleeve/Work/SleeveSupportWork.ts @@ -20,9 +20,7 @@ export class SleeveSupportWork extends Work { } APICopy() { - return { - type: WorkType.SUPPORT as "SUPPORT", - }; + return { type: WorkType.SUPPORT as "SUPPORT" }; } /** Serialize the current object to a JSON save state. */ diff --git a/src/PersonObjects/Sleeve/Work/SleeveSynchroWork.ts b/src/PersonObjects/Sleeve/Work/SleeveSynchroWork.ts index c5ee7d097..791ae0171 100644 --- a/src/PersonObjects/Sleeve/Work/SleeveSynchroWork.ts +++ b/src/PersonObjects/Sleeve/Work/SleeveSynchroWork.ts @@ -21,9 +21,7 @@ export class SleeveSynchroWork extends Work { } APICopy() { - return { - type: WorkType.SYNCHRO as "SYNCHRO", - }; + return { type: WorkType.SYNCHRO as "SYNCHRO" }; } /** Serialize the current object to a JSON save state. */ diff --git a/src/PersonObjects/Sleeve/Work/Work.ts b/src/PersonObjects/Sleeve/Work/Work.ts index 3e31c35a5..4d4a8effb 100644 --- a/src/PersonObjects/Sleeve/Work/Work.ts +++ b/src/PersonObjects/Sleeve/Work/Work.ts @@ -22,7 +22,7 @@ export abstract class Work { } abstract process(sleeve: Sleeve, cycles: number): void; - abstract APICopy(): SleeveTask; + abstract APICopy(sleeve: Sleeve): SleeveTask; abstract toJSON(): IReviverValue; finish(): void { /* left for children to implement */ diff --git a/src/ScriptEditor/NetscriptDefinitions.d.ts b/src/ScriptEditor/NetscriptDefinitions.d.ts index 100e89ef0..b1378e821 100644 --- a/src/ScriptEditor/NetscriptDefinitions.d.ts +++ b/src/ScriptEditor/NetscriptDefinitions.d.ts @@ -878,6 +878,7 @@ type SleeveBladeburnerTask = { actionType: "General" | "Contracts"; actionName: string; cyclesWorked: number; + cyclesNeeded: number; }; /** @public */ @@ -891,7 +892,12 @@ type SleeveClassTask = { type SleeveCompanyTask = { type: "COMPANY"; companyName: string }; /** @public */ -type SleeveCrimeTask = { type: "CRIME"; crimeType: CrimeType | `${CrimeType}`; cyclesWorked: number }; +type SleeveCrimeTask = { + type: "CRIME"; + crimeType: CrimeType | `${CrimeType}`; + cyclesWorked: number; + cyclesNeeded: number; +}; /** @public */ type SleeveFactionTask = { @@ -901,7 +907,7 @@ type SleeveFactionTask = { }; /** @public */ -type SleeveInfiltrateTask = { type: "INFILTRATE"; cyclesWorked: number }; +type SleeveInfiltrateTask = { type: "INFILTRATE"; cyclesWorked: number; cyclesNeeded: number }; /** @public */ type SleeveRecoveryTask = { type: "RECOVERY" };