From 163ff38c8791b5916b2404305d6ce0dc9f3f1668 Mon Sep 17 00:00:00 2001 From: Kim Mantas Date: Thu, 5 Dec 2024 19:08:53 +0000 Subject: [PATCH] [#4809] Fix base item choices when enchanted. --- module/applications/item/item-sheet.mjs | 5 +++-- module/applications/item/sheet-v2-mixin.mjs | 4 +++- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/module/applications/item/item-sheet.mjs b/module/applications/item/item-sheet.mjs index c752f0fd46..99b8428ce2 100644 --- a/module/applications/item/item-sheet.mjs +++ b/module/applications/item/item-sheet.mjs @@ -262,17 +262,18 @@ export default class ItemSheet5e extends ItemSheet { /** * Get the base weapons and tools based on the selected type. + * @param {object} [context] Sheet preparation context. * @returns {Promise} Object with base items for this type formatted for selectOptions. * @protected */ - async _getItemBaseTypes() { + async _getItemBaseTypes(context) { const baseIds = this.item.type === "equipment" ? { ...CONFIG.DND5E.armorIds, ...CONFIG.DND5E.shieldIds } : CONFIG.DND5E[`${this.item.type}Ids`]; if ( baseIds === undefined ) return null; - const baseType = this.item.system.type.value; + const baseType = context?.source.type.value ?? this.item.system.type.value; const items = {}; for ( const [name, id] of Object.entries(baseIds) ) { diff --git a/module/applications/item/sheet-v2-mixin.mjs b/module/applications/item/sheet-v2-mixin.mjs index e0eafc4877..d7035b299b 100644 --- a/module/applications/item/sheet-v2-mixin.mjs +++ b/module/applications/item/sheet-v2-mixin.mjs @@ -119,7 +119,6 @@ export default function ItemSheetV2Mixin(Base) { user: game.user, // Physical items - baseItems: await this._getItemBaseTypes(), isPhysical: "quantity" in this.item.system, // Identified state @@ -144,6 +143,9 @@ export default function ItemSheetV2Mixin(Base) { context.fields = schema.fields; if ( !context.editable ) context.source = context.system; + // Physical items + context.baseItems = await this._getItemBaseTypes(context); + // Set some default collapsed states on first open. if ( foundry.utils.isEmpty(this._collapsed) ) Object.assign(this._collapsed, { "system.description.chat": true,