This commit is contained in:
WBHarry 2025-07-11 22:49:03 +02:00
parent b6195127fe
commit 0c742eb91b
5 changed files with 200 additions and 131 deletions

View file

@ -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 = { export const abilityCosts = {
hp: { hp: {
id: 'hp', id: 'hp',
@ -366,36 +397,13 @@ export const abilityCosts = {
label: 'Armor Stack', label: 'Armor Stack',
group: 'TYPES.Actor.character' 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: { fear: {
id: 'fear', id: 'fear',
label: 'Fear', label: 'Fear',
group: 'TYPES.Actor.adversary' group: 'TYPES.Actor.adversary'
} },
...featureTokenTypes,
...featureDiceTypes
}; };
export const countdownTypes = { export const countdownTypes = {

View file

@ -29,7 +29,18 @@ export default class BaseDataItem extends foundry.abstract.TypeDataModel {
/** @inheritDoc */ /** @inheritDoc */
static defineSchema() { 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 }); if (this.metadata.hasDescription) schema.description = new fields.HTMLField({ required: true, nullable: true });

View file

@ -1,16 +1,20 @@
export default class RegisterHandlebarsHelpers { export default class RegisterHandlebarsHelpers {
static registerHelpers() { static registerHelpers() {
Handlebars.registerHelper({ Handlebars.registerHelper({
emptyObject: this.emptyObject,
add: this.add, add: this.add,
includes: this.includes, includes: this.includes,
times: this.times, times: this.times,
damageFormula: this.damageFormula, damageFormula: this.damageFormula,
damageSymbols: this.damageSymbols, damageSymbols: this.damageSymbols,
tertiary: this.tertiary, tertiary: this.tertiary
signedNumber: this.signedNumber
}); });
} }
static emptyObject(a) {
return !a || typeof a !== 'object' || Object.keys(a).length === 0;
}
static add(a, b) { static add(a, b) {
const aNum = Number.parseInt(a); const aNum = Number.parseInt(a);
const bNum = Number.parseInt(b); const bNum = Number.parseInt(b);

View file

@ -21,10 +21,19 @@
} }
} }
.item-label-wrapper {
display: grid;
grid-template-columns: 1fr 60px;
}
.item-label { .item-label {
font-family: @font-body; font-family: @font-body;
align-self: center; align-self: center;
&.fullWidth {
grid-column: span 2;
}
.item-name { .item-name {
font-size: 14px; 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 { .controls {
display: flex; display: flex;
align-items: center; align-items: center;

View file

@ -1,126 +1,138 @@
<li class="inventory-item" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}" data-type="{{type}}"> <li class="inventory-item" data-item-id="{{item.id}}" data-item-uuid="{{item.uuid}}" data-type="{{type}}">
<img src="{{item.img}}" class="item-img {{#if isActor}}actor-img{{/if}}" data-action="useItem" {{#if (not noTooltip)}}data-tooltip="{{concat "#item#" item.uuid}}"{{/if}} /> <img src="{{item.img}}" class="item-img {{#if isActor}}actor-img{{/if}}" data-action="useItem" {{#if (not noTooltip)}}data-tooltip="{{concat "#item#" item.uuid}}"{{/if}} />
<div class="item-label"> <div class="item-label-wrapper">
{{#if isCompanion}} <div class="item-label {{#if (emptyObject item.system.tokens)}}fullWidth{{/if}}">
<a class="item-name" data-action="attackRoll">{{item.name}}</a> {{#if isCompanion}}
{{else}} <a class="item-name" data-action="attackRoll">{{item.name}}</a>
<div class="item-name">{{item.name}}</div> {{else}}
{{/if}} <div class="item-name">{{item.name}}</div>
{{#if (eq type 'weapon')}} {{/if}}
<div class="item-tags"> {{#if (eq type 'weapon')}}
<div class="item-tags">
{{#if isSidebar}}
<div class="item-labels">
<div class="label">
{{!-- {{localize (concat 'DAGGERHEART.CONFIG.Traits.' item.system.attack.roll.trait '.short')}} --}}
{{localize (concat 'DAGGERHEART.CONFIG.Range.' item.system.attack.range '.short')}}
<span> - </span>
{{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}}
<i class="fa-solid {{this}}"></i>
{{/each}}
{{/with}}
</div>
</div>
{{else}}
<div class="tag">
{{localize (concat 'DAGGERHEART.CONFIG.Traits.' item.system.attack.roll.trait '.name')}}
</div>
<div class="tag">
{{localize (concat 'DAGGERHEART.CONFIG.Range.' item.system.attack.range '.name')}}
</div>
<div class="tag">
{{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')}})
</div>
<div class="tag">
{{localize (concat 'DAGGERHEART.CONFIG.Burden.' item.system.burden)}}
</div>
{{/if}}
</div>
{{/if}}
{{#if (eq type 'armor')}}
{{#if isSidebar}} {{#if isSidebar}}
<div class="item-labels"> <div class="item-labels">
<div class="label"> <div class="label">
{{!-- {{localize (concat 'DAGGERHEART.CONFIG.Traits.' item.system.attack.roll.trait '.short')}} --}} {{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}:
{{localize (concat 'DAGGERHEART.CONFIG.Range.' item.system.attack.range '.short')}} {{item.system.baseScore}}
<span> - </span>
{{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}}
<i class="fa-solid {{this}}"></i>
{{/each}}
{{/with}}
</div> </div>
</div> </div>
{{else}} {{else}}
<div class="tag"> <div class="item-tags">
{{localize (concat 'DAGGERHEART.CONFIG.Traits.' item.system.attack.roll.trait '.name')}} <div class="tag">
</div> {{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}:
<div class="tag"> {{item.system.baseScore}}
{{localize (concat 'DAGGERHEART.CONFIG.Range.' item.system.attack.range '.name')}} </div>
</div> <div class="tag">
<div class="tag"> {{localize "DAGGERHEART.ITEMS.Armor.baseThresholds.base"}}:
{{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}} {{item.system.baseThresholds.major}}
({{localize (concat 'DAGGERHEART.CONFIG.DamageType.' item.system.attack.damage.parts.0.type '.abbreviation')}}) <span>/</span>
</div> {{item.system.baseThresholds.severe}}
<div class="tag"> </div>
{{localize (concat 'DAGGERHEART.CONFIG.Burden.' item.system.burden)}}
</div> </div>
{{/if}} {{/if}}
</div> {{/if}}
{{/if}} {{#if (eq type 'domainCard')}}
{{#if (eq type 'armor')}} {{#if isSidebar}}
{{#if isSidebar}} <div class="item-labels">
<div class="item-labels"> <div class="label">
<div class="label"> {{localize (concat 'DAGGERHEART.CONFIG.DomainCardTypes.' item.system.type)}}
{{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}: <span> - </span>
{{item.system.baseScore}} {{localize (concat 'DAGGERHEART.GENERAL.Domain.' item.system.domain '.label')}}
<span> - </span>
<span class="recall-value">{{item.system.recallCost}}</span>
<i class="fa-solid fa-bolt"></i>
</div>
</div> </div>
</div> {{else}}
{{else}} <div class="item-tags">
<div class="tag">
{{localize (concat 'DAGGERHEART.CONFIG.DomainCardTypes.' item.system.type)}}
</div>
<div class="tag">
{{localize (concat 'DAGGERHEART.GENERAL.Domain.' item.system.domain '.label')}}
</div>
<div class="tag">
<span class="recall-label">{{localize "DAGGERHEART.ITEMS.DomainCard.recallCost"}}: </span>
<span class="recall-value">{{item.system.recallCost}}</span>
</div>
</div>
{{/if}}
{{/if}}
{{#if (eq type 'effect')}}
<div class="item-tags"> <div class="item-tags">
<div class="tag"> <div class="tag">
{{localize "DAGGERHEART.ITEMS.Armor.baseScore"}}: {{localize (concat 'TYPES.Item.' item.parent.type)}}
{{item.system.baseScore}} <span>: </span>
{{item.parent.name}}
</div> </div>
<div class="tag"> <div class="tag">
{{localize "DAGGERHEART.ITEMS.Armor.baseThresholds.base"}}: {{#if item.duration.duration}}
{{item.system.baseThresholds.major}} {{localize 'DAGGERHEART.EFFECTS.Duration.temporary'}}
<span>/</span> {{else}}
{{item.system.baseThresholds.severe}} {{localize 'DAGGERHEART.EFFECTS.Duration.passive'}}
{{/if}}
</div>
{{#each item.statuses as |status|}}
<div class="tag">
{{localize (concat 'DAGGERHEART.CONFIG.Condition.' status '.name')}}
</div>
{{/each}}
</div>
{{/if}}
{{#if (eq type 'action')}}
<div class="item-tags">
<div class="tag">
{{localize (concat 'DAGGERHEART.ACTIONS.TYPES.' item.type '.name')}}
</div>
<div class="tag">
{{localize (concat 'DAGGERHEART.CONFIG.ActionType.' item.actionType)}}
</div> </div>
</div> </div>
{{/if}} {{/if}}
{{/if}} </div>
{{#if (eq type 'domainCard')}} {{#unless (emptyObject item.system.tokens)}}
{{#if isSidebar}} <div class="item-tokens">
<div class="item-labels"> {{#each item.system.tokens as | token |}}
<div class="label"> <div class="item-token">
{{localize (concat 'DAGGERHEART.CONFIG.DomainCardTypes.' item.system.type)}} <i class="fa-solid fa-hashtag"></i>
<span> - </span> <input type="number" value="{{token.value}}" step="1" min="0" max="10" />
{{localize (concat 'DAGGERHEART.GENERAL.Domain.' item.system.domain '.label')}}
<span> - </span>
<span class="recall-value">{{item.system.recallCost}}</span>
<i class="fa-solid fa-bolt"></i>
</div>
</div>
{{else}}
<div class="item-tags">
<div class="tag">
{{localize (concat 'DAGGERHEART.CONFIG.DomainCardTypes.' item.system.type)}}
</div>
<div class="tag">
{{localize (concat 'DAGGERHEART.GENERAL.Domain.' item.system.domain '.label')}}
</div>
<div class="tag">
<span class="recall-label">{{localize "DAGGERHEART.ITEMS.DomainCard.recallCost"}}: </span>
<span class="recall-value">{{item.system.recallCost}}</span>
</div>
</div>
{{/if}}
{{/if}}
{{#if (eq type 'effect')}}
<div class="item-tags">
<div class="tag">
{{localize (concat 'TYPES.Item.' item.parent.type)}}
<span>: </span>
{{item.parent.name}}
</div>
<div class="tag">
{{#if item.duration.duration}}
{{localize 'DAGGERHEART.EFFECTS.Duration.temporary'}}
{{else}}
{{localize 'DAGGERHEART.EFFECTS.Duration.passive'}}
{{/if}}
</div>
{{#each item.statuses as |status|}}
<div class="tag">
{{localize (concat 'DAGGERHEART.CONFIG.Condition.' status '.name')}}
</div> </div>
{{/each}} {{/each}}
</div> </div>
{{/if}} {{/unless}}
{{#if (eq type 'action')}}
<div class="item-tags">
<div class="tag">
{{localize (concat 'DAGGERHEART.ACTIONS.TYPES.' item.type '.name')}}
</div>
<div class="tag">
{{localize (concat 'DAGGERHEART.CONFIG.ActionType.' item.actionType)}}
</div>
</div>
{{/if}}
</div> </div>
{{#unless hideControls}} {{#unless hideControls}}
{{#if isActor}} {{#if isActor}}