Fix processReward() incorrectly trying to add mods to armor items without slots

Add `itemHasSlots` to itemHelper and consolodate its use across code
This commit is contained in:
Dev 2024-02-03 11:00:30 +00:00
parent 47bedcb526
commit 12a9cb5ded
3 changed files with 13 additions and 4 deletions

View File

@ -269,7 +269,7 @@ export class BotInventoryGenerator
const tacVestsWithArmor = Object.entries(templateInventory.equipment.TacticalVest).reduce(
(newVestDictionary, [tplKey]) =>
{
if (this.itemHelper.getItem(tplKey)[1]._props.Slots?.length > 0)
if (this.itemHelper.itemHasSlots(tplKey))
{
newVestDictionary[tplKey] = templateInventory.equipment.TacticalVest[tplKey];
}
@ -290,7 +290,7 @@ export class BotInventoryGenerator
const tacVestsWithoutArmor = Object.entries(templateInventory.equipment.TacticalVest).reduce(
(newVestDictionary, [tplKey]) =>
{
if (this.itemHelper.getItem(tplKey)[1]._props.Slots?.length === 0)
if (this.itemHelper.itemHasSlots(tplKey))
{
newVestDictionary[tplKey] = templateInventory.equipment.TacticalVest[tplKey];
}

View File

@ -275,6 +275,11 @@ export class ItemHelper
return [false, undefined];
}
public itemHasSlots(itemTpl: string): boolean
{
return this.getItem(itemTpl)[1]._props.Slots?.length > 0;
}
public isItemInDb(tpl: string): boolean
{
const itemDetails = this.getItem(tpl);

View File

@ -270,8 +270,12 @@ export class QuestHelper
// Is armor item that may need inserts / plates
if (questReward.items.length === 1 && this.itemHelper.armorItemCanHoldMods(rootItem._tpl))
{
// Attempt to pull default preset from globals and add child items to reward
this.generateArmorRewardChildSlots(rootItem, questReward);
// Only process items with slots
if (this.itemHelper.itemHasSlots(rootItem._tpl))
{
// Attempt to pull default preset from globals and add child items to reward
this.generateArmorRewardChildSlots(rootItem, questReward);
}
}
for (const item of questReward.items)