Fixed promise lockup

This commit is contained in:
WBHarry 2025-09-06 22:28:05 +02:00
parent 9e50f2b008
commit 9f53b42c41

View file

@ -163,6 +163,7 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
return ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelected')); return ui.notifications.info(game.i18n.localize('DAGGERHEART.UI.Notifications.noTargetsSelected'));
const targetDamage = []; const targetDamage = [];
const damagePromises = [];
for (let target of targets) { for (let target of targets) {
let damages = foundry.utils.deepClone(this.system.damage); let damages = foundry.utils.deepClone(this.system.damage);
if ( if (
@ -181,28 +182,36 @@ export default class DhpChatMessage extends foundry.documents.ChatMessage {
} }
this.consumeOnSuccess(); this.consumeOnSuccess();
const updates = this.system.hasHealing if (this.system.hasHealing)
? await target.actor.takeHealing(damages) damagePromises.push(
: await target.actor.takeDamage(damages, this.system.isDirect); target.actor.takeHealing(damages).then(updates => targetDamage.push({ token: target, updates }))
targetDamage.push({ token: target, updates: updates }); );
else
damagePromises.push(
target.actor
.takeDamage(damages, this.system.isDirect)
.then(updates => targetDamage.push({ token: target, updates }))
);
} }
const cls = getDocumentClass('ChatMessage'); Promise.all(damagePromises).then(async _ => {
const msg = { const cls = getDocumentClass('ChatMessage');
user: game.user.id, const msg = {
speaker: cls.getSpeaker(), user: game.user.id,
title: game.i18n.localize( speaker: cls.getSpeaker(),
`DAGGERHEART.UI.Chat.damageSummary.${this.system.hasHealing ? 'healingTitle' : 'title'}` title: game.i18n.localize(
), `DAGGERHEART.UI.Chat.damageSummary.${this.system.hasHealing ? 'healingTitle' : 'title'}`
content: await foundry.applications.handlebars.renderTemplate( ),
'systems/daggerheart/templates/ui/chat/damageSummary.hbs', content: await foundry.applications.handlebars.renderTemplate(
{ 'systems/daggerheart/templates/ui/chat/damageSummary.hbs',
targets: targetDamage {
} targets: targetDamage
) }
}; )
};
cls.create(msg); cls.create(msg);
});
} }
getAction(actor, itemId, actionId) { getAction(actor, itemId, actionId) {