mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-16 05:31:07 +01:00
Fixed promise lockup
This commit is contained in:
parent
9e50f2b008
commit
9f53b42c41
1 changed files with 28 additions and 19 deletions
|
|
@ -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) {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue