From f59041121b1e23751ecae82dee0050eaf48e0633 Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 9 Jan 2024 23:46:57 +0000 Subject: [PATCH] Fix plate filtering code not correctly handling when no plates of desired armor level are found --- project/src/generators/BotEquipmentModGenerator.ts | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/project/src/generators/BotEquipmentModGenerator.ts b/project/src/generators/BotEquipmentModGenerator.ts index 6cfacaa8..3a7d9438 100644 --- a/project/src/generators/BotEquipmentModGenerator.ts +++ b/project/src/generators/BotEquipmentModGenerator.ts @@ -212,11 +212,12 @@ export class BotEquipmentModGenerator // Filter plates to the chosen level based on its armorClass property const filteredPlates = platesFromDb.filter(x => x._props.armorClass === chosenArmorPlateLevel); - if (!filteredPlates) + if (filteredPlates.length === 0) { - this.logger.warning(`Plate filter was too restrictive, unable to find plates of level: ${chosenArmorPlateLevel}. Returning all ${modPool.length} plates instead`); + this.logger.warning(`Plate filter was too restrictive, unable to find plates of level: ${chosenArmorPlateLevel}. Using mods default`); - return modPool; + const relatedItemDbModSlot = armorItem._props.Slots.find(slot => slot._name.toLowerCase() === modSlot); + return [relatedItemDbModSlot._props.filters[0].Plate]; } // Only return the items ids