From 564fb7f4cac7e28ae8235997a5b724b488d7941c Mon Sep 17 00:00:00 2001 From: Dev Date: Mon, 28 Oct 2024 10:24:30 +0000 Subject: [PATCH] Make overriding labs specific code easier inside `sendMail()` --- project/src/controllers/InsuranceController.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/project/src/controllers/InsuranceController.ts b/project/src/controllers/InsuranceController.ts index 3a3d748a..c34e3814 100644 --- a/project/src/controllers/InsuranceController.ts +++ b/project/src/controllers/InsuranceController.ts @@ -530,16 +530,12 @@ export class InsuranceController { * @returns void */ protected sendMail(sessionID: string, insurance: IInsurance): void { - const labsId = "laboratory"; // After all of the item filtering that we've done, if there are no items remaining, the insurance has // successfully "failed" to return anything and an appropriate message should be sent to the player. const traderDialogMessages = this.databaseService.getTrader(insurance.traderId).dialogue; // Map is labs + insurance is disabled in base.json - if ( - insurance.systemData?.location?.toLowerCase() === labsId && - !this.databaseService.getLocation(labsId).base.Insurance - ) { + if (this.IsMapLabsAndInsuranceDisabled(insurance)) { // Trader has labs-specific messages // Wipe out returnable items if (traderDialogMessages.insuranceFailedLabs?.length > 0) { @@ -565,6 +561,14 @@ export class InsuranceController { ); } + protected IsMapLabsAndInsuranceDisabled(insurance: IInsurance) { + const labsId = "laboratory"; + return ( + insurance.systemData?.location?.toLowerCase() === labsId && + !this.databaseService.getLocation(labsId).base.Insurance + ); + } + /** * Determines whether an insured item should be removed from the player's inventory based on a random roll and * trader-specific return chance.