Refactor inRaidHelper.removeSpawnedInSessionProeprtyFromitems()

This commit is contained in:
Dev 2023-04-22 16:30:57 +01:00
parent fae6c57bfa
commit c45c9185a6

View File

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