diff --git a/module/applications/sheets/actors/character.mjs b/module/applications/sheets/actors/character.mjs index b291a4f0..f80f711b 100644 --- a/module/applications/sheets/actors/character.mjs +++ b/module/applications/sheets/actors/character.mjs @@ -180,6 +180,16 @@ export default class CharacterSheet extends DHBaseActorSheet { return acc; }, {}); + context.resources = Object.keys(this.document.system.resources).reduce((acc, key) => { + acc[key] = this.document.system.resources[key]; + return acc; + }, {}); + const maxResource = Math.max(context.resources.hitPoints.max, context.resources.stress.max); + context.resources.hitPoints.emptyPips = + context.resources.hitPoints.max < maxResource ? maxResource - context.resources.hitPoints.max : 0; + context.resources.stress.emptyPips = + context.resources.stress.max < maxResource ? maxResource - context.resources.stress.max : 0; + context.inventory = { currency: { title: game.i18n.localize('DAGGERHEART.CONFIG.Gold.title'), @@ -736,7 +746,8 @@ export default class CharacterSheet extends DHBaseActorSheet { */ static async #toggleHitPoints(_, button) { const hitPointsValue = Number.parseInt(button.dataset.value); - const newValue = this.document.system.resources.hitPoints.value >= hitPointsValue ? hitPointsValue - 1 : hitPointsValue; + const newValue = + this.document.system.resources.hitPoints.value >= hitPointsValue ? hitPointsValue - 1 : hitPointsValue; await this.document.update({ 'system.resources.hitPoints.value': newValue }); } @@ -754,7 +765,7 @@ export default class CharacterSheet extends DHBaseActorSheet { * Toggles ArmorScore resource value. * @type {ApplicationClickAction} */ - static async #toggleArmor(_, button,element) { + static async #toggleArmor(_, button, element) { const ArmorValue = Number.parseInt(button.dataset.value); const newValue = this.document.system.armor.system.marks.value >= ArmorValue ? ArmorValue - 1 : ArmorValue; await this.document.system.armor.update({ 'system.marks.value': newValue }); diff --git a/module/systemRegistration/handlebars.mjs b/module/systemRegistration/handlebars.mjs index dd19e429..7a2cf0ee 100644 --- a/module/systemRegistration/handlebars.mjs +++ b/module/systemRegistration/handlebars.mjs @@ -10,6 +10,7 @@ export const preloadHandlebarsTemplates = async function () { 'systems/daggerheart/templates/sheets/global/partials/domain-card-item.hbs', 'systems/daggerheart/templates/sheets/global/partials/item-resource.hbs', 'systems/daggerheart/templates/sheets/global/partials/resource-section.hbs', + 'systems/daggerheart/templates/sheets/global/partials/resource-bar.hbs', 'systems/daggerheart/templates/components/card-preview.hbs', 'systems/daggerheart/templates/levelup/parts/selectable-card-preview.hbs', 'systems/daggerheart/templates/sheets/global/partials/feature-section-item.hbs', diff --git a/styles/less/sheets/actors/character/sidebar.less b/styles/less/sheets/actors/character/sidebar.less index bd39131f..35443a08 100644 --- a/styles/less/sheets/actors/character/sidebar.less +++ b/styles/less/sheets/actors/character/sidebar.less @@ -209,6 +209,11 @@ background: light-dark(@dark-blue, @golden); } } + + .empty-slot { + width: 15px; + height: 10px; + } } .slot-label { display: flex; diff --git a/templates/sheets/actors/character/sidebar.hbs b/templates/sheets/actors/character/sidebar.hbs index e9bc1493..7f700b28 100644 --- a/templates/sheets/actors/character/sidebar.hbs +++ b/templates/sheets/actors/character/sidebar.hbs @@ -17,71 +17,8 @@
-
- {{#if useResourcePips}} -
-
- {{#times document.system.resources.hitPoints.max}} - - - {{/times}} -
-
- {{localize "DAGGERHEART.GENERAL.HitPoints.short"}} - {{document.system.resources.hitPoints.value}} / {{document.system.resources.hitPoints.max}} -
-
- {{else}} -
-

-

/

-

{{document.system.resources.hitPoints.max}}

-
- -
-

{{localize "DAGGERHEART.GENERAL.HitPoints.short"}}

-
- {{/if}} -
-
- {{#if useResourcePips}} -
-
- {{#times document.system.resources.stress.max}} - - - {{/times}} -
-
-
- {{localize "DAGGERHEART.GENERAL.stress"}} - {{document.system.resources.stress.value}} / {{document.system.resources.stress.max}} -
-
-
- {{else}} -
-

-

/

-

{{document.system.resources.stress.max}}

-
- -
-

{{localize "DAGGERHEART.GENERAL.stress"}}

-
- {{/if}} -
+ {{> "systems/daggerheart/templates/sheets/global/partials/resource-bar.hbs" resource=resources.hitPoints }} + {{> "systems/daggerheart/templates/sheets/global/partials/resource-bar.hbs" resource=resources.stress }}
diff --git a/templates/sheets/global/partials/resource-bar.hbs b/templates/sheets/global/partials/resource-bar.hbs new file mode 100644 index 00000000..41a97f99 --- /dev/null +++ b/templates/sheets/global/partials/resource-bar.hbs @@ -0,0 +1,35 @@ +
+ {{#if useResourcePips}} +
+
+ {{#times resource.max}} + + + {{/times}} + + {{#times resource.emptyPips}} + + {{/times}} +
+
+ {{localize "DAGGERHEART.GENERAL.HitPoints.short"}} + {{resource.value}} / {{resource.max}} +
+
+ {{else}} +
+

+

/

+

{{resource.max}}

+
+ +
+

{{localize "DAGGERHEART.GENERAL.HitPoints.short"}}

+
+ {{/if}} +
\ No newline at end of file