diff --git a/module/data/item/weapon.mjs b/module/data/item/weapon.mjs index 71d1e08d..0e266849 100644 --- a/module/data/item/weapon.mjs +++ b/module/data/item/weapon.mjs @@ -145,4 +145,69 @@ export default class DHWeapon extends AttachableItem { } } } + + /** + * Generates a list of localized tags based on this item's type-specific properties. + * @returns {string[]} An array of localized tag strings. + */ + getTags() { + const { attack, burden } = this; + const tags = []; + + const traitTag = game.i18n.localize(`DAGGERHEART.CONFIG.Traits.${attack.roll.trait}.name`); + const rangeTag = game.i18n.localize(`DAGGERHEART.CONFIG.Range.${attack.range}.name`); + const burdenTag = game.i18n.localize(`DAGGERHEART.CONFIG.Burden.${burden}`); + + tags.push(traitTag, rangeTag, burdenTag); + + for (const { value, type } of attack.damage.parts) { + const parts = [value.dice]; + if (value.bonus) parts.push(value.bonus.signedString()); + + if (type.size > 0) { + const typeTags = Array.from(type) + .map(t => game.i18n.localize(`DAGGERHEART.CONFIG.DamageType.${t}.abbreviation`)) + .join(" | "); + parts.push(` (${typeTags})`); // Add a space in front and put it inside a (). + } + + tags.push(parts.join("")); + } + + + return tags; + } + + /** + * Generate a localized label array for this item subtype. + * @returns {(string | { value: string, icons: string[] })[]} An array of localized strings and damage label objects. + */ + getLabels() { + const labels = []; + + const { roll, range, damage } = this.attack; + labels.push(game.i18n.localize(`DAGGERHEART.CONFIG.Traits.${roll.trait}.short`)); + labels.push(game.i18n.localize(`DAGGERHEART.CONFIG.Range.${range}.short`)); + + for (const { value, type } of damage.parts) { + const str = [value.dice]; + if (value.bonus) str.push(value.bonus.signedString()); + + const icons = Array.from(type) + .map(t => CONFIG.DH.GENERAL.damageTypes[t]?.icon) + .filter(Boolean); + + const labelValue = str.join(""); + if (icons.length === 0) { + labels.push(labelValue); + } else { + labels.push({ value: labelValue, icons }); + } + } + + return labels; + } + + + } diff --git a/module/documents/item.mjs b/module/documents/item.mjs index a05a7ff0..3e44e846 100644 --- a/module/documents/item.mjs +++ b/module/documents/item.mjs @@ -74,8 +74,8 @@ export default class DHItem extends foundry.documents.Item { isInventoryItem === true ? 'Inventory Items' //TODO localize : isInventoryItem === false - ? 'Character Items' //TODO localize - : 'Other'; //TODO localize + ? 'Character Items' //TODO localize + : 'Other'; //TODO localize return { value: type, label, group }; } @@ -96,6 +96,28 @@ export default class DHItem extends foundry.documents.Item { }); } + /* -------------------------------------------- */ + + /** + * Generate an array of localized tag. + * @returns {string[]} An array of localized tag strings. + */ + getTags() { + const tags = []; + if (this.system.getTags) tags.push(...this.system.getTags()); + return tags; + } + + /** + * Generate a localized label array for this item. + * @returns {(string | { value: string, icons: string[] })[]} An array of localized strings and damage label objects. + */ + getLabels() { + const labels = []; + if (this.system.getLabels) labels.push(...this.system.getLabels()); + return labels; + } + async use(event) { const actions = new Set(this.system.actionsList); if (actions?.size) { @@ -115,10 +137,10 @@ export default class DHItem extends foundry.documents.Item { this.type === 'ancestry' ? game.i18n.localize('DAGGERHEART.UI.Chat.foundationCard.ancestryTitle') : this.type === 'community' - ? game.i18n.localize('DAGGERHEART.UI.Chat.foundationCard.communityTitle') - : this.type === 'feature' - ? game.i18n.localize('TYPES.Item.feature') - : game.i18n.localize('DAGGERHEART.UI.Chat.foundationCard.subclassFeatureTitle'), + ? game.i18n.localize('DAGGERHEART.UI.Chat.foundationCard.communityTitle') + : this.type === 'feature' + ? game.i18n.localize('TYPES.Item.feature') + : game.i18n.localize('DAGGERHEART.UI.Chat.foundationCard.subclassFeatureTitle'), origin: origin, img: this.img, name: this.name, diff --git a/styles/less/global/inventory-item.less b/styles/less/global/inventory-item.less index 452d997b..6a820a31 100644 --- a/styles/less/global/inventory-item.less +++ b/styles/less/global/inventory-item.less @@ -105,6 +105,10 @@ align-items: center; justify-content: end; gap: 8px; + + .unequipped { + opacity: 0.5; + } } } diff --git a/templates/sheets/global/partials/inventory-item-V2.hbs b/templates/sheets/global/partials/inventory-item-V2.hbs index 10ff20eb..39f7d0b4 100644 --- a/templates/sheets/global/partials/inventory-item-V2.hbs +++ b/templates/sheets/global/partials/inventory-item-V2.hbs @@ -15,40 +15,33 @@ Parameters: - showActions {boolean} : If true show feature's actions. --}} -