From e0e62d8e47e8ebaa62d3985fb72cf16b7d4e89bc Mon Sep 17 00:00:00 2001 From: Mihai Date: Wed, 10 Jan 2024 08:44:03 +0000 Subject: [PATCH] This PR aims to resolves issue #280 (!190) Updated itemDelivery method in InraidController to filter out insured items from the items array using the insuranceService. Added logic to exclude insured items from being sent as part of the delivery message to the player. Co-authored-by: mihaicm93 <45673304+mihaicm93@users.noreply.github.com> Reviewed-on: https://dev.sp-tarkov.com/SPT-AKI/Server/pulls/190 Co-authored-by: Mihai Co-committed-by: Mihai --- project/src/controllers/InraidController.ts | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/project/src/controllers/InraidController.ts b/project/src/controllers/InraidController.ts index 454f6c87..ccab68c8 100644 --- a/project/src/controllers/InraidController.ts +++ b/project/src/controllers/InraidController.ts @@ -523,12 +523,27 @@ export class InraidController /** * Handle singleplayer/traderServices/itemDelivery */ - public itemDelivery(sessionId: string, traderId: string, items: Item[]): void + public itemDelivery(sessionId: string, traderId: string, items: Item[]): void { + const insuredItems: Item[] = items.filter(item => + this.insuranceService.getInsuranceItems(sessionId, Traders[traderId]).includes(item) + ); + + // Remove insured items from the insurance list + insuredItems.forEach(insuredItem => + { + const insuranceList = this.insuranceService.getInsuranceItems(sessionId, Traders[traderId]); + const index = insuranceList.indexOf(insuredItem); + if (index !== -1) + { + insuranceList.splice(index, 1); + } + }); + const dialogueTemplates = this.databaseServer.getTables().traders[traderId].dialogue; const messageId = this.randomUtil.getArrayValue(dialogueTemplates.itemsDelivered); const messageStoreTime = this.timeUtil.getHoursAsSeconds(this.traderConfig.fence.btrDeliveryExpireHours); - + this.mailSendService.sendLocalisedNpcMessageToPlayer( sessionId, this.traderHelper.getTraderById(traderId),