From bc92dec7f0aa80864719a07a25689a2546b8d54b Mon Sep 17 00:00:00 2001 From: WBHarry Date: Wed, 16 Jul 2025 22:15:00 +0200 Subject: [PATCH] Added advantage/disadvantageSource to Character model. It's shown from a tooltip icon on rolls --- module/data/actor/character.mjs | 2 ++ module/documents/tooltipManager.mjs | 18 ++++++++++++++++++ .../less/dialog/dice-roll/roll-selection.less | 4 ++++ templates/dialogs/dice-roll/rollSelection.hbs | 6 ++++++ templates/ui/tooltip/advantage.hbs | 5 +++++ 5 files changed, 35 insertions(+) create mode 100644 templates/ui/tooltip/advantage.hbs diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index 804eabec..6935b5ac 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -87,6 +87,8 @@ export default class DhCharacter extends BaseDataActor { value: new ForeignDocumentUUIDField({ type: 'Item', nullable: true }), subclass: new ForeignDocumentUUIDField({ type: 'Item', nullable: true }) }), + advantageSources: new fields.ArrayField(new fields.StringField()), + disadvantageSources: new fields.ArrayField(new fields.StringField()), levelData: new fields.EmbeddedDataField(DhLevelData), bonuses: new fields.SchemaField({ roll: new fields.SchemaField({ diff --git a/module/documents/tooltipManager.mjs b/module/documents/tooltipManager.mjs index d9444207..f24823f4 100644 --- a/module/documents/tooltipManager.mjs +++ b/module/documents/tooltipManager.mjs @@ -21,6 +21,24 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti this.tooltip.innerHTML = html; options.direction = this._determineItemTooltipDirection(element); } + } else { + const isAdvantage = element.dataset.tooltip?.startsWith('#advantage#'); + const isDisadvantage = element.dataset.tooltip?.startsWith('#disadvantage#'); + if (isAdvantage || isDisadvantage) { + const actorUuid = element.dataset.tooltip.slice(isAdvantage ? 11 : 14); + const actor = await foundry.utils.fromUuid(actorUuid); + + if (actor) { + html = await foundry.applications.handlebars.renderTemplate( + `systems/daggerheart/templates/ui/tooltip/advantage.hbs`, + { + sources: isAdvantage ? actor.system.advantageSources : actor.system.disadvantageSources + } + ); + + this.tooltip.innerHTML = html; + } + } } super.activate(element, { ...options, html: html }); diff --git a/styles/less/dialog/dice-roll/roll-selection.less b/styles/less/dialog/dice-roll/roll-selection.less index 55db8bb7..af6c3c20 100644 --- a/styles/less/dialog/dice-roll/roll-selection.less +++ b/styles/less/dialog/dice-roll/roll-selection.less @@ -100,6 +100,10 @@ font-size: 14px; line-height: 17px; } + + .advantage-chip-tooltip { + pointer-events: all; + } } .advantage-chip { diff --git a/templates/dialogs/dice-roll/rollSelection.hbs b/templates/dialogs/dice-roll/rollSelection.hbs index 0d2f3f48..0cc21030 100644 --- a/templates/dialogs/dice-roll/rollSelection.hbs +++ b/templates/dialogs/dice-roll/rollSelection.hbs @@ -98,6 +98,9 @@ {{/if}} {{localize "DAGGERHEART.GENERAL.Advantage.full"}} + {{#if @root.rollConfig.data.advantageSources.length}} + + {{/if}} {{#unless (eq @root.rollType 'D20Roll')}}