Skip to content

Commit

Permalink
[#4809] Fix base item choices when enchanted.
Browse files Browse the repository at this point in the history
  • Loading branch information
Fyorl committed Dec 11, 2024
1 parent cf0c994 commit b9da4b6
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
5 changes: 3 additions & 2 deletions module/applications/item/item-sheet.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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|null>} 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) ) {
Expand Down
4 changes: 3 additions & 1 deletion module/applications/item/sheet-v2-mixin.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ export default function ItemSheetV2Mixin(Base) {
user: game.user,

// Physical items
baseItems: await this._getItemBaseTypes(),
isPhysical: "quantity" in this.item.system,

// Identified state
Expand All @@ -136,6 +135,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,
Expand Down

0 comments on commit b9da4b6

Please sign in to comment.