Implements HP loss HUD button
All checks were successful
Release Creation / build (release) Successful in 54s

This commit is contained in:
2025-04-27 22:11:10 +02:00
parent a043117ec7
commit 157163672c
31 changed files with 184 additions and 108 deletions

View File

@ -18,6 +18,37 @@ export default class LethalFantasyUtils {
options.push({ name: "Reset Progression", condition: true, icon: '<i class="fas fa-rotate-right"></i>', callback: target => { game.combat.resetProgression(target.data('combatant-id')); } })
}
/* -------------------------------------------- */
static setHookListeners() {
Hooks.on('renderTokenHUD', async (hud, html, token) => {
const lossHPButton = await renderTemplate('systems/fvtt-lethal-fantasy/templates/loss-hp-hud.hbs', {} )
html.find('div.left').append(lossHPButton);
html.find('img.lethal-hp-loss-hud').click((event) => {
event.preventDefault();
let hpMenu = html.find('.hp-loss-wrap')[0]
if (hpMenu.classList.contains("hp-loss-hud-disabled")) {
html.find('.hp-loss-wrap')[0].classList.add('hp-loss-hud-active');
html.find('.hp-loss-wrap')[0].classList.remove('hp-loss-hud-disabled');
} else {
html.find('.hp-loss-wrap')[0].classList.remove('hp-loss-hud-active');
html.find('.hp-loss-wrap')[0].classList.add('hp-loss-hud-disabled');
}
})
html.find('.loss-hp-hud-click').click((event) => {
event.preventDefault();
let hpLoss = event.currentTarget.dataset.hpValue;
if (token) {
let actor = game.actors.get(token.actorId);
actor.applyDamage(Number(hpLoss));
html.find('.hp-loss-wrap')[0].classList.remove('hp-loss-hud-active');
html.find('.hp-loss-wrap')[0].classList.add('hp-loss-hud-disabled');
}
})
})
}
/* -------------------------------------------- */
static handleSocketEvent(msg = {}) {
console.log(`handleSocketEvent !`, msg)
let actor