From c45c9185a678261ba461736ef1d32e7e374e6d20 Mon Sep 17 00:00:00 2001 From: Dev Date: Sat, 22 Apr 2023 16:30:57 +0100 Subject: [PATCH] Refactor inRaidHelper.removeSpawnedInSessionProeprtyFromitems() --- project/src/helpers/InRaidHelper.ts | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/project/src/helpers/InRaidHelper.ts b/project/src/helpers/InRaidHelper.ts index c60b437e..ffad3605 100644 --- a/project/src/helpers/InRaidHelper.ts +++ b/project/src/helpers/InRaidHelper.ts @@ -273,15 +273,17 @@ export class InRaidHelper */ public removeSpawnedInSessionPropertyFromItems(postRaidProfile: IPmcData): IPmcData { - const items = this.databaseServer.getTables().templates.items; - for (const offraidItem of postRaidProfile.Inventory.items) + const dbItems = this.databaseServer.getTables().templates.items; + const itemsToRemovePropertyFrom = postRaidProfile.Inventory.items.filter(x => { - // Remove the FIR status if the item marked FIR at raid start - if ("upd" in offraidItem && "SpawnedInSession" in offraidItem.upd && !items[offraidItem._tpl]._props.QuestItem) - { - delete offraidItem.upd.SpawnedInSession; - } - } + // Has upd object + upd.SpawnedInSession property + not a quest item + return "upd" in x && "SpawnedInSession" in x.upd && !dbItems[x._tpl]._props.QuestItem; + }); + + itemsToRemovePropertyFrom.forEach(item => + { + delete item.upd.SpawnedInSession; + }); return postRaidProfile; }