SINGULARITY: Allow being hospitalized while being busy (#1426)

This commit is contained in:
catloversg 2024-06-25 10:36:03 +07:00 committed by GitHub
parent 48bebeea2b
commit c0036b03d4
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 9 deletions

@ -611,11 +611,7 @@ export function NetscriptSingularity(): InternalAPI<ISingularity> {
},
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);

@ -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;
}