diff --git a/project/src/controllers/InraidController.ts b/project/src/controllers/InraidController.ts index 297892af..71ae5ed0 100644 --- a/project/src/controllers/InraidController.ts +++ b/project/src/controllers/InraidController.ts @@ -154,13 +154,23 @@ export class InraidController this.healthHelper.saveVitality(serverPmcProfile, postRaidRequest.health, sessionID); // Remove inventory if player died and send insurance items + let insuredItemsLostCount = 0; if (mapHasInsuranceEnabled) { - this.insuranceService.storeLostGear(serverPmcProfile, postRaidRequest, preRaidGear, sessionID, isDead); + insuredItemsLostCount = this.insuranceService.storeLostGear( + serverPmcProfile, + postRaidRequest, + preRaidGear, + sessionID, + isDead, + ); } else { - this.insuranceService.sendLostInsuranceMessage(sessionID, locationName); + if (insuredItemsLostCount > 0) + { + this.insuranceService.sendLostInsuranceMessage(sessionID, locationName); + } } // Edge case - Handle usec players leaving lighthouse with Rogues angry at them diff --git a/project/src/services/InsuranceService.ts b/project/src/services/InsuranceService.ts index fe24102f..d95a4517 100644 --- a/project/src/services/InsuranceService.ts +++ b/project/src/services/InsuranceService.ts @@ -218,6 +218,7 @@ export class InsuranceService * @param preRaidGear gear player wore prior to raid * @param sessionID Session id * @param playerDied did the player die in raid + * @returns Count of insured items lost in raid */ public storeLostGear( pmcData: IPmcData, @@ -225,8 +226,9 @@ export class InsuranceService preRaidGear: Item[], sessionID: string, playerDied: boolean, - ): void + ): number { + let itemsLostCount = 0; const preRaidGearHash = this.createItemHashTable(preRaidGear); const offRaidGearHash = this.createItemHashTable(offraidData.profile.Inventory.items); @@ -277,7 +279,10 @@ export class InsuranceService for (const gear of equipmentToSendToPlayer) { this.addGearToSend(gear); + itemsLostCount++; } + + return itemsLostCount; } /**