Fixed so Adversary features can be sent to chat. Fixed so ability-card.hbs works again (#525)

This commit is contained in:
WBHarry 2025-08-02 22:33:21 +02:00 committed by GitHub
parent 1df0852df3
commit af40f9d712
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
7 changed files with 28 additions and 26 deletions

View file

@ -480,7 +480,7 @@ export default function DHApplicationMixin(Base) {
*/ */
static async #toChat(_event, target) { static async #toChat(_event, target) {
let doc = await getDocFromElement(target); let doc = await getDocFromElement(target);
return doc.toChat(this.document.id); return doc.toChat(doc.uuid);
} }
/** /**

View file

@ -117,9 +117,7 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
async onRollAllSave(event, message) { async onRollAllSave(event, message) {
event.stopPropagation(); event.stopPropagation();
if (!game.user.isGM) return; if (!game.user.isGM) return;
const targets = event.target.parentElement.querySelectorAll( const targets = event.target.parentElement.querySelectorAll('[data-token] .target-save');
'[data-token] .target-save'
);
const actor = await this.getActor(message.system.source.actor), const actor = await this.getActor(message.system.source.actor),
action = this.getAction(actor, message.system.source.item, message.system.source.action); action = this.getAction(actor, message.system.source.item, message.system.source.action);
targets.forEach(async el => { targets.forEach(async el => {
@ -169,9 +167,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
async onRollSimple(event, message) { async onRollSimple(event, message) {
const buttonType = event.target.dataset.type ?? 'damage', const buttonType = event.target.dataset.type ?? 'damage',
total = message.rolls.reduce((a,c) => a + Roll.fromJSON(c).total, 0), total = message.rolls.reduce((a, c) => a + Roll.fromJSON(c).total, 0),
damages = { damages = {
'hitPoints': { hitPoints: {
parts: [ parts: [
{ {
applyTo: 'hitPoints', applyTo: 'hitPoints',
@ -186,20 +184,18 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo
if (targets.length === 0) if (targets.length === 0)
return ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelected')); return ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelected'));
targets.forEach(target => { targets.forEach(target => {
if(buttonType === 'healing') if (buttonType === 'healing') target.actor.takeHealing(damages);
target.actor.takeHealing(damages); else target.actor.takeDamage(damages);
else });
target.actor.takeDamage(damages);
})
} }
async abilityUseButton(event, message) { async abilityUseButton(event, message) {
event.stopPropagation(); event.stopPropagation();
const action = message.system.actions[Number.parseInt(event.currentTarget.dataset.index)]; const item = await foundry.utils.fromUuid(message.system.origin);
const actor = game.actors.get(message.system.source.actor); const action = item.system.actions.get(event.currentTarget.id);
await actor.use(action); await item.use(action);
} }
async actionUseButton(event, message) { async actionUseButton(event, message) {

View file

@ -132,6 +132,8 @@ export default class DHItem extends foundry.documents.Item {
async toChat(origin) { async toChat(origin) {
const cls = getDocumentClass('ChatMessage'); const cls = getDocumentClass('ChatMessage');
const item = await foundry.utils.fromUuid(origin);
const systemData = { const systemData = {
title: title:
this.type === 'ancestry' this.type === 'ancestry'
@ -148,13 +150,14 @@ export default class DHItem extends foundry.documents.Item {
img: this.img, img: this.img,
tags: this._getTags() tags: this._getTags()
}, },
description: this.system.description, actions: item.system.actions,
actions: this.system.actions description: this.system.description
}; };
const msg = { const msg = {
type: 'abilityUse', type: 'abilityUse',
user: game.user.id, user: game.user.id,
actor: game.actors.get(cls.getSpeaker().actor), actor: item.parent,
author: this.author, author: this.author,
speaker: cls.getSpeaker(), speaker: cls.getSpeaker(),
system: systemData, system: systemData,

View file

@ -2,12 +2,12 @@
data-group='{{tabs.features.group}}'> data-group='{{tabs.features.group}}'>
<div class="feature-section"> <div class="feature-section">
{{> 'daggerheart.inventory-items' {{> 'daggerheart.inventory-items'
title=tabs.features.label title=tabs.features.label
type='feature' type='feature'
collection=document.system.features collection=document.system.features
hideControls=true hideContextMenu=true
canCreate=true canCreate=true
showActions=true showActions=true
}} }}
</div> </div>
</section> </section>

View file

@ -55,6 +55,7 @@ Parameters:
item=item item=item
type=../type type=../type
hideControls=../hideControls hideControls=../hideControls
hideContextMenu=../hideContextMenu
isActor=../isActor isActor=../isActor
categoryAdversary=../categoryAdversary categoryAdversary=../categoryAdversary
hideTooltip=../hideTooltip hideTooltip=../hideTooltip

View file

@ -123,9 +123,11 @@ Parameters:
<i class="fa-regular fa-message"></i> <i class="fa-regular fa-message"></i>
</a> </a>
{{/if}} {{/if}}
{{#unless hideContextMenu}}
<a data-action="triggerContextMenu" data-tooltip="DAGGERHEART.UI.Tooltip.moreOptions"> <a data-action="triggerContextMenu" data-tooltip="DAGGERHEART.UI.Tooltip.moreOptions">
<i class="fa-solid fa-ellipsis-vertical"></i> <i class="fa-solid fa-ellipsis-vertical"></i>
</a> </a>
{{/unless}}
{{/if}} {{/if}}
</div> </div>
{{/unless}} {{/unless}}

View file

@ -15,8 +15,8 @@
<div class="description">{{{description}}}</div> <div class="description">{{{description}}}</div>
</details> </details>
<footer class="ability-card-footer"> <footer class="ability-card-footer">
{{#each actions as |action index|}} {{#each actions as |action|}}
<button class="ability-use-button" data-index="{{index}}"> <button class="ability-use-button" id="{{action.id}}">
{{action.name}} {{action.name}}
</button> </button>
{{#if action.cost.value}}<div class="ability-card-action-cost">{{action.cost.value}} {{action.cost.type}}</div>{{/if}} {{#if action.cost.value}}<div class="ability-card-action-cost">{{action.cost.value}} {{action.cost.type}}</div>{{/if}}