From 220a89b915dca211d4cf0824620eb4d72ac72005 Mon Sep 17 00:00:00 2001 From: Dev Date: Sun, 29 Oct 2023 20:45:35 +0000 Subject: [PATCH] Default value to false if not found intead of letting it be undefined --- project/src/generators/BotEquipmentModGenerator.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/project/src/generators/BotEquipmentModGenerator.ts b/project/src/generators/BotEquipmentModGenerator.ts index ed5ac046..673710a1 100644 --- a/project/src/generators/BotEquipmentModGenerator.ts +++ b/project/src/generators/BotEquipmentModGenerator.ts @@ -185,7 +185,7 @@ export class BotEquipmentModGenerator const botWeaponSightWhitelist = this.botEquipmentFilterService.getBotWeaponSightWhitelist(botEquipmentRole); const randomisationSettings = this.botHelper.getBotRandomizationDetails(botLevel, botEquipConfig); - // Iterate over mod pool and choose mods to add to item + // Iterate over mod pool and choose mods to attach const sortedModKeys = this.sortModKeys(Object.keys(compatibleModsPool)); for (const modSlot of sortedModKeys) { @@ -204,7 +204,7 @@ export class BotEquipmentModGenerator continue; } - const isRandomisableSlot = randomisationSettings?.randomisedWeaponModSlots?.includes(modSlot); + const isRandomisableSlot = randomisationSettings?.randomisedWeaponModSlots?.includes(modSlot) ?? false; const modToAdd = this.chooseModToPutIntoSlot(modSlot, isRandomisableSlot, botWeaponSightWhitelist, botEquipBlacklist, compatibleModsPool, weapon, ammoTpl, parentTemplate); // Compatible mod not found @@ -213,13 +213,12 @@ export class BotEquipmentModGenerator continue; } - const modToAddTemplate = modToAdd[1]; - if (!this.isModValidForSlot(modToAdd, modsParentSlot, modSlot, parentTemplate)) { continue; } + const modToAddTemplate = modToAdd[1]; // Skip adding mod to weapon if type limit reached if (this.botWeaponModLimitService.weaponModHasReachedLimit(botEquipmentRole, modToAddTemplate, modLimits, parentTemplate, weapon)) { @@ -562,6 +561,7 @@ export class BotEquipmentModGenerator if (!modCompatibilityResult.incompatible) { found = true; + break; } }