mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Feature] Advantage/Disadvantage Tooltips (#362)
* Added advantage/disadvantageSource to Character model. It's shown from a tooltip icon on rolls * Added support for beastform advantageOn
This commit is contained in:
parent
ad9e0aa558
commit
d7e024be02
6 changed files with 36 additions and 0 deletions
|
|
@ -87,6 +87,8 @@ export default class DhCharacter extends BaseDataActor {
|
||||||
value: new ForeignDocumentUUIDField({ type: 'Item', nullable: true }),
|
value: new ForeignDocumentUUIDField({ type: 'Item', nullable: true }),
|
||||||
subclass: 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),
|
levelData: new fields.EmbeddedDataField(DhLevelData),
|
||||||
bonuses: new fields.SchemaField({
|
bonuses: new fields.SchemaField({
|
||||||
roll: new fields.SchemaField({
|
roll: new fields.SchemaField({
|
||||||
|
|
|
||||||
|
|
@ -69,6 +69,7 @@ export default class DHBeastform extends BaseDataItem {
|
||||||
|
|
||||||
const beastformEffect = this.parent.effects.find(x => x.type === 'beastform');
|
const beastformEffect = this.parent.effects.find(x => x.type === 'beastform');
|
||||||
await beastformEffect.updateSource({
|
await beastformEffect.updateSource({
|
||||||
|
changes: [...beastformEffect.changes, { key: 'system.advantageSources', mode: 2, value: this.advantageOn }],
|
||||||
system: {
|
system: {
|
||||||
characterTokenData: {
|
characterTokenData: {
|
||||||
tokenImg: this.parent.parent.prototypeToken.texture.src,
|
tokenImg: this.parent.parent.prototypeToken.texture.src,
|
||||||
|
|
|
||||||
|
|
@ -21,6 +21,24 @@ export default class DhTooltipManager extends foundry.helpers.interaction.Toolti
|
||||||
this.tooltip.innerHTML = html;
|
this.tooltip.innerHTML = html;
|
||||||
options.direction = this._determineItemTooltipDirection(element);
|
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 });
|
super.activate(element, { ...options, html: html });
|
||||||
|
|
|
||||||
|
|
@ -100,6 +100,10 @@
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
line-height: 17px;
|
line-height: 17px;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
.advantage-chip-tooltip {
|
||||||
|
pointer-events: all;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
.advantage-chip {
|
.advantage-chip {
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,9 @@
|
||||||
<span><i class="fa-regular fa-circle"></i></span>
|
<span><i class="fa-regular fa-circle"></i></span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<span class="label">{{localize "DAGGERHEART.GENERAL.Advantage.full"}}</span>
|
<span class="label">{{localize "DAGGERHEART.GENERAL.Advantage.full"}}</span>
|
||||||
|
{{#if @root.rollConfig.data.advantageSources.length}}
|
||||||
|
<span class="advantage-chip-tooltip" data-tooltip="{{concat "#advantage#" @root.rollConfig.source.actor}}"><i class="fa-solid fa-circle-info"></i></span>
|
||||||
|
{{/if}}
|
||||||
</button>
|
</button>
|
||||||
<button class="disadvantage-chip flex1 {{#if (eq advantage -1)}}selected{{/if}}" data-action="updateIsAdvantage" data-advantage="-1">
|
<button class="disadvantage-chip flex1 {{#if (eq advantage -1)}}selected{{/if}}" data-action="updateIsAdvantage" data-advantage="-1">
|
||||||
{{#if (eq advantage -1)}}
|
{{#if (eq advantage -1)}}
|
||||||
|
|
@ -106,6 +109,9 @@
|
||||||
<span><i class="fa-regular fa-circle"></i></span>
|
<span><i class="fa-regular fa-circle"></i></span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
<span class="label">{{localize "DAGGERHEART.GENERAL.Disadvantage.full"}}</span>
|
<span class="label">{{localize "DAGGERHEART.GENERAL.Disadvantage.full"}}</span>
|
||||||
|
{{#if @root.rollConfig.data.disadvantageSources.length}}
|
||||||
|
<span class="advantage-chip-tooltip" data-tooltip="{{concat "#disadvantage#" @root.rollConfig.source.actor}}"><i class="fa-solid fa-circle-info"></i></span>
|
||||||
|
{{/if}}
|
||||||
</button>
|
</button>
|
||||||
</div>
|
</div>
|
||||||
{{#unless (eq @root.rollType 'D20Roll')}}
|
{{#unless (eq @root.rollType 'D20Roll')}}
|
||||||
|
|
|
||||||
5
templates/ui/tooltip/advantage.hbs
Normal file
5
templates/ui/tooltip/advantage.hbs
Normal file
|
|
@ -0,0 +1,5 @@
|
||||||
|
<div class="daggerheart dh-style tooltip">
|
||||||
|
{{#each sources as | source |}}
|
||||||
|
<div>{{{source}}}</div>
|
||||||
|
{{/each}}
|
||||||
|
</div>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue