mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-07-24 11:29:54 +02:00
Fix onRollSimple
This commit is contained in:
parent
32abcfb0c4
commit
7e5e722c5f
2 changed files with 8 additions and 16 deletions
|
|
@ -181,21 +181,13 @@ 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';
|
||||||
const total = message.rolls.reduce((a, c) => a + Roll.fromJSON(c).total, 0);
|
const total = message.rolls.reduce((a, c) => a + Roll.fromJSON(c).total, 0);
|
||||||
const damages = {
|
|
||||||
hitPoints: {
|
|
||||||
damageTypes: [],
|
|
||||||
roll: { total }
|
|
||||||
}
|
|
||||||
};
|
|
||||||
const targets = Array.from(game.user.targets);
|
const targets = Array.from(game.user.targets);
|
||||||
|
|
||||||
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'));
|
||||||
|
for (const target of targets) {
|
||||||
targets.forEach(target => {
|
if (buttonType === 'healing') target.actor.takeHealing({ hitPoints: total });
|
||||||
if (buttonType === 'healing') target.actor.takeHealing(damages);
|
else target.actor.takeDamage({ total });
|
||||||
else target.actor.takeDamage(damages);
|
}
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async abilityUseButton(event, message) {
|
async abilityUseButton(event, message) {
|
||||||
|
|
|
||||||
|
|
@ -747,11 +747,11 @@ export default class DhpActor extends Actor {
|
||||||
return updates;
|
return updates;
|
||||||
}
|
}
|
||||||
|
|
||||||
async takeHealing(healings) {
|
async takeHealing(args) {
|
||||||
if (Hooks.call(`${CONFIG.DH.id}.preTakeHealing`, this, healings) === false) return null;
|
args = this.#parseDamageArgs({ resources: 'resources' in args ? args.resources : args });
|
||||||
|
if (Hooks.call(`${CONFIG.DH.id}.preTakeHealing`, this, args) === false) return null;
|
||||||
|
|
||||||
const resources = 'resources' in healings ? healings.resources : healings;
|
const updates = args.resourceUpdates;
|
||||||
const updates = this.#parseDamageArgs({ resources }).resourceUpdates;
|
|
||||||
for (const u of updates) {
|
for (const u of updates) {
|
||||||
const shouldFlip = !(u.key === 'fear' || this.system?.resources?.[u.key]?.isReversed === false);
|
const shouldFlip = !(u.key === 'fear' || this.system?.resources?.[u.key]?.isReversed === false);
|
||||||
u.value = shouldFlip ? u.value * -1 : u.value;
|
u.value = shouldFlip ? u.value * -1 : u.value;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue