From 0c742eb91bec3e2ede044f8f5652f416e3694de2 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Fri, 11 Jul 2025 22:49:03 +0200 Subject: [PATCH] Initial --- module/config/generalConfig.mjs | 60 ++--- module/data/item/base.mjs | 13 +- module/helpers/handlebarsHelper.mjs | 8 +- styles/less/global/inventory-item.less | 34 +++ .../sheets/global/partials/inventory-item.hbs | 216 +++++++++--------- 5 files changed, 200 insertions(+), 131 deletions(-) diff --git a/module/config/generalConfig.mjs b/module/config/generalConfig.mjs index 282a8c9c..d251a67e 100644 --- a/module/config/generalConfig.mjs +++ b/module/config/generalConfig.mjs @@ -345,6 +345,37 @@ export const refreshTypes = { } }; +export const featureTokenTypes = { + tide: { + id: 'tide', + label: 'Tide', + group: 'TYPES.Actor.character' + }, + chaos: { + id: 'chaos', + label: 'Chaos', + group: 'TYPES.Actor.character' + } +}; + +export const featureDiceTypes = { + prayer: { + id: 'prayer', + label: 'Prayer Dice', + group: 'TYPES.Actor.character' + }, + favor: { + id: 'favor', + label: 'Favor Points', + group: 'TYPES.Actor.character' + }, + slayer: { + id: 'slayer', + label: 'Slayer Dice', + group: 'TYPES.Actor.character' + } +}; + export const abilityCosts = { hp: { id: 'hp', @@ -366,36 +397,13 @@ export const abilityCosts = { label: 'Armor Stack', group: 'TYPES.Actor.character' }, - prayer: { - id: 'prayer', - label: 'Prayer Dice', - group: 'TYPES.Actor.character' - }, - favor: { - id: 'favor', - label: 'Favor Points', - group: 'TYPES.Actor.character' - }, - slayer: { - id: 'slayer', - label: 'Slayer Dice', - group: 'TYPES.Actor.character' - }, - tide: { - id: 'tide', - label: 'Tide', - group: 'TYPES.Actor.character' - }, - chaos: { - id: 'chaos', - label: 'Chaos', - group: 'TYPES.Actor.character' - }, fear: { id: 'fear', label: 'Fear', group: 'TYPES.Actor.adversary' - } + }, + ...featureTokenTypes, + ...featureDiceTypes }; export const countdownTypes = { diff --git a/module/data/item/base.mjs b/module/data/item/base.mjs index 9358a6b3..87812431 100644 --- a/module/data/item/base.mjs +++ b/module/data/item/base.mjs @@ -29,7 +29,18 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel { /** @inheritDoc */ static defineSchema() { - const schema = {}; + const schema = { + uses: new fields.SchemaField({ + value: new fields.NumberField({ nullable: true, initial: null }), + max: new fields.NumberField({ nullable: true, initial: null }), + icon: new fields.StringField({ initial: 'fa-solid fa-hashtag' }), + recovery: new fields.StringField({ + choices: CONFIG.DH.GENERAL.refreshTypes, + initial: null, + nullable: true + }) + }) + }; if (this.metadata.hasDescription) schema.description = new fields.HTMLField({ required: true, nullable: true }); diff --git a/module/helpers/handlebarsHelper.mjs b/module/helpers/handlebarsHelper.mjs index feeebbd2..1b6de2a5 100644 --- a/module/helpers/handlebarsHelper.mjs +++ b/module/helpers/handlebarsHelper.mjs @@ -1,16 +1,20 @@ export default class RegisterHandlebarsHelpers { static registerHelpers() { Handlebars.registerHelper({ + emptyObject: this.emptyObject, add: this.add, includes: this.includes, times: this.times, damageFormula: this.damageFormula, damageSymbols: this.damageSymbols, - tertiary: this.tertiary, - signedNumber: this.signedNumber + tertiary: this.tertiary }); } + static emptyObject(a) { + return !a || typeof a !== 'object' || Object.keys(a).length === 0; + } + static add(a, b) { const aNum = Number.parseInt(a); const bNum = Number.parseInt(b); diff --git a/styles/less/global/inventory-item.less b/styles/less/global/inventory-item.less index 24e53165..1786f6f9 100644 --- a/styles/less/global/inventory-item.less +++ b/styles/less/global/inventory-item.less @@ -21,10 +21,19 @@ } } + .item-label-wrapper { + display: grid; + grid-template-columns: 1fr 60px; + } + .item-label { font-family: @font-body; align-self: center; + &.fullWidth { + grid-column: span 2; + } + .item-name { font-size: 14px; } @@ -58,6 +67,31 @@ } } + .item-tokens { + display: flex; + flex-direction: column; + gap: 4px; + + .item-token { + display: flex; + align-items: center; + gap: 4px; + + i { + flex: none; + font-size: 14px; + } + + input { + flex: 1; + + &::-webkit-outer-spin-button { + opacity: 1; + } + } + } + } + .controls { display: flex; align-items: center; diff --git a/templates/sheets/global/partials/inventory-item.hbs b/templates/sheets/global/partials/inventory-item.hbs index eae3dd5f..41327096 100644 --- a/templates/sheets/global/partials/inventory-item.hbs +++ b/templates/sheets/global/partials/inventory-item.hbs @@ -1,126 +1,138 @@
  • -
    - {{#if isCompanion}} - {{item.name}} - {{else}} -
    {{item.name}}
    - {{/if}} - {{#if (eq type 'weapon')}} -
    +
    +
    + {{#if isCompanion}} + {{item.name}} + {{else}} +
    {{item.name}}
    + {{/if}} + {{#if (eq type 'weapon')}} +
    + {{#if isSidebar}} +
    +
    + {{!-- {{localize (concat 'DAGGERHEART.CONFIG.Traits.' item.system.attack.roll.trait '.short')}} --}} + {{localize (concat 'DAGGERHEART.CONFIG.Range.' item.system.attack.range '.short')}} + - + {{item.system.attack.damage.parts.0.value.dice}}{{#if item.system.attack.damage.parts.0.value.bonus}} + {{item.system.attack.damage.parts.0.value.bonus}}{{/if}} + {{!-- ({{localize (concat 'DAGGERHEART.CONFIG.DamageType.' item.system.attack.damage.parts.0.type '.abbreviation')}}) --}} + {{#with (lookup @root.config.GENERAL.damageTypes item.system.attack.damage.parts.0.type)}} + {{#each icon}} + + {{/each}} + {{/with}} +
    +
    + {{else}} +
    + {{localize (concat 'DAGGERHEART.CONFIG.Traits.' item.system.attack.roll.trait '.name')}} +
    +
    + {{localize (concat 'DAGGERHEART.CONFIG.Range.' item.system.attack.range '.name')}} +
    +
    + {{item.system.attack.damage.parts.0.value.dice}}{{#if item.system.attack.damage.parts.0.value.bonus}} + {{item.system.attack.damage.parts.0.value.bonus}}{{/if}} + ({{localize (concat 'DAGGERHEART.CONFIG.DamageType.' item.system.attack.damage.parts.0.type '.abbreviation')}}) +
    +
    + {{localize (concat 'DAGGERHEART.CONFIG.Burden.' item.system.burden)}} +
    + {{/if}} +
    + {{/if}} + {{#if (eq type 'armor')}} {{#if isSidebar}}
    - {{!-- {{localize (concat 'DAGGERHEART.CONFIG.Traits.' item.system.attack.roll.trait '.short')}} --}} - {{localize (concat 'DAGGERHEART.CONFIG.Range.' item.system.attack.range '.short')}} - - - {{item.system.attack.damage.parts.0.value.dice}}{{#if item.system.attack.damage.parts.0.value.bonus}} + {{item.system.attack.damage.parts.0.value.bonus}}{{/if}} - {{!-- ({{localize (concat 'DAGGERHEART.CONFIG.DamageType.' item.system.attack.damage.parts.0.type '.abbreviation')}}) --}} - {{#with (lookup @root.config.GENERAL.damageTypes item.system.attack.damage.parts.0.type)}} - {{#each icon}} - - {{/each}} - {{/with}} + {{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}: + {{item.system.baseScore}}
    {{else}} -
    - {{localize (concat 'DAGGERHEART.CONFIG.Traits.' item.system.attack.roll.trait '.name')}} -
    -
    - {{localize (concat 'DAGGERHEART.CONFIG.Range.' item.system.attack.range '.name')}} -
    -
    - {{item.system.attack.damage.parts.0.value.dice}}{{#if item.system.attack.damage.parts.0.value.bonus}} + {{item.system.attack.damage.parts.0.value.bonus}}{{/if}} - ({{localize (concat 'DAGGERHEART.CONFIG.DamageType.' item.system.attack.damage.parts.0.type '.abbreviation')}}) -
    -
    - {{localize (concat 'DAGGERHEART.CONFIG.Burden.' item.system.burden)}} +
    +
    + {{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}: + {{item.system.baseScore}} +
    +
    + {{localize "DAGGERHEART.ITEMS.Armor.baseThresholds.base"}}: + {{item.system.baseThresholds.major}} + / + {{item.system.baseThresholds.severe}} +
    {{/if}} -
    - {{/if}} - {{#if (eq type 'armor')}} - {{#if isSidebar}} -
    -
    - {{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}: - {{item.system.baseScore}} + {{/if}} + {{#if (eq type 'domainCard')}} + {{#if isSidebar}} +
    +
    + {{localize (concat 'DAGGERHEART.CONFIG.DomainCardTypes.' item.system.type)}} + - + {{localize (concat 'DAGGERHEART.GENERAL.Domain.' item.system.domain '.label')}} + - + {{item.system.recallCost}} + +
    -
    - {{else}} + {{else}} +
    +
    + {{localize (concat 'DAGGERHEART.CONFIG.DomainCardTypes.' item.system.type)}} +
    +
    + {{localize (concat 'DAGGERHEART.GENERAL.Domain.' item.system.domain '.label')}} +
    +
    + {{localize "DAGGERHEART.ITEMS.DomainCard.recallCost"}}: + {{item.system.recallCost}} +
    +
    + {{/if}} + {{/if}} + {{#if (eq type 'effect')}}
    - {{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}: - {{item.system.baseScore}} + {{localize (concat 'TYPES.Item.' item.parent.type)}} + : + {{item.parent.name}}
    - {{localize "DAGGERHEART.ITEMS.Armor.baseThresholds.base"}}: - {{item.system.baseThresholds.major}} - / - {{item.system.baseThresholds.severe}} + {{#if item.duration.duration}} + {{localize 'DAGGERHEART.EFFECTS.Duration.temporary'}} + {{else}} + {{localize 'DAGGERHEART.EFFECTS.Duration.passive'}} + {{/if}} +
    + {{#each item.statuses as |status|}} +
    + {{localize (concat 'DAGGERHEART.CONFIG.Condition.' status '.name')}} +
    + {{/each}} +
    + {{/if}} + {{#if (eq type 'action')}} +
    +
    + {{localize (concat 'DAGGERHEART.ACTIONS.TYPES.' item.type '.name')}} +
    +
    + {{localize (concat 'DAGGERHEART.CONFIG.ActionType.' item.actionType)}}
    {{/if}} - {{/if}} - {{#if (eq type 'domainCard')}} - {{#if isSidebar}} -
    -
    - {{localize (concat 'DAGGERHEART.CONFIG.DomainCardTypes.' item.system.type)}} - - - {{localize (concat 'DAGGERHEART.GENERAL.Domain.' item.system.domain '.label')}} - - - {{item.system.recallCost}} - -
    -
    - {{else}} -
    -
    - {{localize (concat 'DAGGERHEART.CONFIG.DomainCardTypes.' item.system.type)}} -
    -
    - {{localize (concat 'DAGGERHEART.GENERAL.Domain.' item.system.domain '.label')}} -
    -
    - {{localize "DAGGERHEART.ITEMS.DomainCard.recallCost"}}: - {{item.system.recallCost}} -
    -
    - {{/if}} - {{/if}} - {{#if (eq type 'effect')}} -
    -
    - {{localize (concat 'TYPES.Item.' item.parent.type)}} - : - {{item.parent.name}} -
    -
    - {{#if item.duration.duration}} - {{localize 'DAGGERHEART.EFFECTS.Duration.temporary'}} - {{else}} - {{localize 'DAGGERHEART.EFFECTS.Duration.passive'}} - {{/if}} -
    - {{#each item.statuses as |status|}} -
    - {{localize (concat 'DAGGERHEART.CONFIG.Condition.' status '.name')}} +
    + {{#unless (emptyObject item.system.tokens)}} +
    + {{#each item.system.tokens as | token |}} +
    + +
    {{/each}}
    - {{/if}} - {{#if (eq type 'action')}} -
    -
    - {{localize (concat 'DAGGERHEART.ACTIONS.TYPES.' item.type '.name')}} -
    -
    - {{localize (concat 'DAGGERHEART.CONFIG.ActionType.' item.actionType)}} -
    -
    - {{/if}} + {{/unless}}
    {{#unless hideControls}} {{#if isActor}}