From 5e739c2a909b87366da2769d953a216b4b356b41 Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 21 Mar 2023 15:31:42 +0000 Subject: [PATCH] Fix: check for empty object when looking at key length --- project/src/generators/BotGenerator.ts | 2 +- project/src/generators/BotInventoryGenerator.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/project/src/generators/BotGenerator.ts b/project/src/generators/BotGenerator.ts index 8acde807..152b03c3 100644 --- a/project/src/generators/BotGenerator.ts +++ b/project/src/generators/BotGenerator.ts @@ -318,7 +318,7 @@ export class BotGenerator */ protected getSkillsWithRandomisedProgressValue(skills: IBaseSkill[]): IBaseSkill[] { - if (Object.keys(skills).length === 0) + if (Object.keys(skills ?? []).length === 0) { return; } diff --git a/project/src/generators/BotInventoryGenerator.ts b/project/src/generators/BotInventoryGenerator.ts index 576e0eea..03191485 100644 --- a/project/src/generators/BotInventoryGenerator.ts +++ b/project/src/generators/BotInventoryGenerator.ts @@ -258,7 +258,7 @@ export class BotInventoryGenerator protected getFilteredDynamicModsForItem(itemTpl: string, equipmentBlacklist: EquipmentFilterDetails[]): Record { const modPool = this.botEquipmentModPoolService.getModsForGearSlot(itemTpl); - for (const modSlot of Object.keys(modPool)) + for (const modSlot of Object.keys(modPool ?? [])) { const blacklistedMods = equipmentBlacklist[0].equipment[modSlot] || []; const filteredMods = modPool[modSlot].filter(x => !blacklistedMods.includes(x));