Added code to clean up insured items data post-raid

This commit is contained in:
Dev 2024-08-29 17:36:31 +01:00
parent 60e82cf3f9
commit d7ce092a4a
2 changed files with 12 additions and 0 deletions

View File

@ -324,4 +324,14 @@ export class InsuranceService {
// Try to use the equipment id from the profile. I'm not sure this is strictly required, but it feels neat.
return this.saveServer.getProfile(sessionID)?.characters?.pmc?.Inventory?.equipment ?? this.hashUtil.generate();
}
/**
* Remove lost insurance items from profiles insuredItems array
* @param profile Profile to remove from
* @param itemsToRemove Items to remove
*/
public removeLostInsuranceFromProfile(profile: IPmcData, itemsToRemove: Item[]) {
const itemIdsToRemove = new Set(itemsToRemove.map((item) => item._id));
profile.InsuredItems = profile.InsuredItems.filter((insuredItem) => !itemIdsToRemove.has(insuredItem.itemId));
}
}

View File

@ -589,6 +589,8 @@ export class LocationLifecycleService {
this.insuranceService.storeGearLostInRaidToSendLater(sessionId, mappedItems);
this.insuranceService.sendInsuredItems(preRaidPmcProfile, sessionId, locationName);
this.insuranceService.removeLostInsuranceFromProfile(preRaidPmcProfile, request.lostInsuredItems);
}
}