Handle Softinsertslots when insuring armor (!401)

fixes SPT/Issues#765
Tested with Uptodate Bleedingedge

Reviewed-on: https://dev.sp-tarkov.com/SPT/Server/pulls/401
Co-authored-by: TetrisGG <dmiller2606@gmail.com>
Co-committed-by: TetrisGG <dmiller2606@gmail.com>
This commit is contained in:
TetrisGG 2024-08-23 16:35:17 +00:00 committed by chomp
parent 8d9a396914
commit 386b93e7e6

View File

@ -643,6 +643,10 @@ export class InsuranceController {
// add items to InsuredItems list once money has been paid
for (const key of body.items) {
pmcData.InsuredItems.push({ tid: body.tid, itemId: inventoryItemsHash[key]._id });
// If Item is Helmet or Body Armour -> Handle insurance of Softinserts
if (this.itemHelper.armorItemHasRemovableOrSoftInsertSlots(inventoryItemsHash[key]._tpl)) {
this.insureSoftInserts(inventoryItemsHash[key], pmcData, body);
}
}
this.profileHelper.addSkillPointsToPlayer(pmcData, SkillTypes.CHARISMA, itemsToInsureCount * 0.01);
@ -650,6 +654,22 @@ export class InsuranceController {
return output;
}
/**
* Insure softinserts of Armor that has softinsert slots
* @param item Armor item to be insured
* @param pmcData Player profile
* @param body Insurance request data
*/
public insureSoftInserts(item: Item, pmcData: IPmcData, body: IInsureRequestData): void {
const softInsertIds = this.itemHelper.getSoftInsertSlotIds();
const softInsertSlots = pmcData.Inventory.items.filter((x) => x.parentId === item._id && softInsertIds.includes(x.slotId.toLowerCase()));
for (const softInsertSlot of softInsertSlots) {
this.logger.debug(`SoftInsertSlots: ${softInsertSlot.slotId}`);
pmcData.InsuredItems.push({ tid: body.tid, itemId: softInsertSlot._id });
}
}
/**
* Handle client/insurance/items/list/cost
* Calculate insurance cost