mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 03:31:07 +01:00
[Feature] 946 - Damage/Effect ChatMessages (#1089)
* Initial damage message * Added hover functionality to adversary damage cards * Added effect message * enhance chat messages styles * . * Fixed promise lockup * . * Fixed token path for message --------- Co-authored-by: moliloo <dev.murilobrito@gmail.com>
This commit is contained in:
parent
906c7ac853
commit
ff79dd19bf
17 changed files with 450 additions and 12 deletions
|
|
@ -81,6 +81,9 @@ export default class DamageField extends fields.SchemaField {
|
|||
static async applyDamage(config, targets = null, force = false) {
|
||||
targets ??= config.targets.filter(target => target.hit);
|
||||
if (!config.damage || !targets?.length || (!DamageField.getApplyAutomation() && !force)) return;
|
||||
|
||||
const targetDamage = [];
|
||||
const damagePromises = [];
|
||||
for (let target of targets) {
|
||||
const actor = fromUuidSync(target.actorId);
|
||||
if (!actor) continue;
|
||||
|
|
@ -95,9 +98,45 @@ export default class DamageField extends fields.SchemaField {
|
|||
});
|
||||
}
|
||||
|
||||
if (config.hasHealing) actor.takeHealing(config.damage);
|
||||
else actor.takeDamage(config.damage, config.isDirect);
|
||||
if (config.hasHealing)
|
||||
damagePromises.push(
|
||||
actor
|
||||
.takeHealing(config.damage)
|
||||
.then(updates => targetDamage.push({ token: actor.token ?? actor.prototypeToken, updates }))
|
||||
);
|
||||
else
|
||||
damagePromises.push(
|
||||
actor
|
||||
.takeDamage(config.damage, config.isDirect)
|
||||
.then(updates => targetDamage.push({ token: actor.token ?? actor.prototypeToken, updates }))
|
||||
);
|
||||
}
|
||||
|
||||
Promise.all(damagePromises).then(async _ => {
|
||||
const summaryMessageSettings = game.settings.get(
|
||||
CONFIG.DH.id,
|
||||
CONFIG.DH.SETTINGS.gameSettings.Automation
|
||||
).summaryMessages;
|
||||
if (!summaryMessageSettings.damage) return;
|
||||
|
||||
const cls = getDocumentClass('ChatMessage');
|
||||
const msg = {
|
||||
type: 'systemMessage',
|
||||
user: game.user.id,
|
||||
speaker: cls.getSpeaker(),
|
||||
title: game.i18n.localize(
|
||||
`DAGGERHEART.UI.Chat.damageSummary.${config.hasHealing ? 'healingTitle' : 'title'}`
|
||||
),
|
||||
content: await foundry.applications.handlebars.renderTemplate(
|
||||
'systems/daggerheart/templates/ui/chat/damageSummary.hbs',
|
||||
{
|
||||
targets: targetDamage
|
||||
}
|
||||
)
|
||||
};
|
||||
|
||||
cls.create(msg);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue