Fixed edge case where custom traders without labs-specific failure messages would still return insured items

This commit is contained in:
Dev 2024-10-28 11:17:19 +00:00
parent 844616e3c4
commit 4346fadcbc

View File

@ -538,7 +538,7 @@ export class InsuranceController {
if (this.IsMapLabsAndInsuranceDisabled(insurance)) { if (this.IsMapLabsAndInsuranceDisabled(insurance)) {
// Trader has labs-specific messages // Trader has labs-specific messages
// Wipe out returnable items // Wipe out returnable items
this.handleLabsInsuranceMessaging(traderDialogMessages, insurance); this.handleLabsInsurance(traderDialogMessages, insurance);
} else if (insurance.items.length === 0) { } else if (insurance.items.length === 0) {
// Not labs and no items to return // Not labs and no items to return
const insuranceFailedTemplates = traderDialogMessages.insuranceFailed; const insuranceFailedTemplates = traderDialogMessages.insuranceFailed;
@ -564,18 +564,20 @@ export class InsuranceController {
); );
} }
protected handleLabsInsuranceMessaging( /**
traderDialogMessages: Record<string, string[]>, * Update IInsurance object with new messageTemplateId and wipe out items array data
insurance: IInsurance, */
): void { protected handleLabsInsurance(traderDialogMessages: Record<string, string[]>, insurance: IInsurance): void {
if (traderDialogMessages.insuranceFailedLabs?.length > 0) { // Use labs specific messages if available, otherwise use default
// Change message template id to a labs-specific one const responseMesageIds =
const insuranceFailedLabTemplates = traderDialogMessages.insuranceFailedLabs; traderDialogMessages.insuranceFailedLabs?.length > 0
insurance.messageTemplateId = this.randomUtil.getArrayValue(insuranceFailedLabTemplates); ? traderDialogMessages.insuranceFailedLabs
: traderDialogMessages.insuranceFailed;
// Remove all insured items taken into labs insurance.messageTemplateId = this.randomUtil.getArrayValue(responseMesageIds);
insurance.items = [];
} // Remove all insured items taken into labs
insurance.items = [];
} }
/** /**