From c0036b03d475bc6dbf7bde94d0441b34c96163c0 Mon Sep 17 00:00:00 2001 From: catloversg <152669316+catloversg@users.noreply.github.com> Date: Tue, 25 Jun 2024 10:36:03 +0700 Subject: [PATCH] SINGULARITY: Allow being hospitalized while being busy (#1426) --- src/NetscriptFunctions/Singularity.ts | 6 +----- src/PersonObjects/Player/PlayerObjectGeneralMethods.ts | 9 +++++---- 2 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/NetscriptFunctions/Singularity.ts b/src/NetscriptFunctions/Singularity.ts index c35e2fa03..f11213d79 100644 --- a/src/NetscriptFunctions/Singularity.ts +++ b/src/NetscriptFunctions/Singularity.ts @@ -611,11 +611,7 @@ export function NetscriptSingularity(): InternalAPI { }, hospitalize: (ctx) => () => { helpers.checkSingularityAccess(ctx); - if (Player.currentWork || Router.page() === Page.Infiltration || Router.page() === Page.BitVerse) { - helpers.log(ctx, () => "Cannot go to the hospital because the player is busy."); - return; - } - Player.hospitalize(); + Player.hospitalize(true); }, isBusy: (ctx) => () => { helpers.checkSingularityAccess(ctx); diff --git a/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts b/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts index ac00f6532..32246477a 100644 --- a/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts +++ b/src/PersonObjects/Player/PlayerObjectGeneralMethods.ts @@ -256,19 +256,20 @@ export function takeDamage(this: PlayerObject, amt: number): boolean { this.hp.current -= amt; if (this.hp.current <= 0) { - this.hospitalize(); + this.hospitalize(false); return true; } else { return false; } } -export function hospitalize(this: PlayerObject): number { +export function hospitalize(this: PlayerObject, suppressNotification: boolean): number { const cost = getHospitalizationCost(); - SnackbarEvents.emit(`You've been Hospitalized for ${formatMoney(cost)}`, ToastVariant.SUCCESS, 2000); - this.loseMoney(cost, "hospitalization"); this.hp.current = this.hp.max; + if (!suppressNotification) { + SnackbarEvents.emit(`You've been Hospitalized for ${formatMoney(cost)}`, ToastVariant.SUCCESS, 2000); + } return cost; }