This commit is contained in:
@@ -28,6 +28,7 @@ export default class LethalFantasyUtils {
|
||||
static setHookListeners() {
|
||||
|
||||
Hooks.on('renderTokenHUD', async (hud, html, token) => {
|
||||
// HP Loss Button (existing)
|
||||
const lossHPButton = await foundry.applications.handlebars.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) => {
|
||||
@@ -65,6 +66,45 @@ export default class LethalFantasyUtils {
|
||||
$(html).find('.hp-loss-wrap')[2].classList.add('hp-loss-hud-disabled');
|
||||
}
|
||||
})
|
||||
|
||||
// HP Gain Button (new)
|
||||
const gainHPButton = await foundry.applications.handlebars.renderTemplate('systems/fvtt-lethal-fantasy/templates/gain-hp-hud.hbs', {})
|
||||
$(html).find('div.left').append(gainHPButton);
|
||||
$(html).find('img.lethal-hp-gain-hud').click((event) => {
|
||||
event.preventDefault();
|
||||
let hpMenu = $(html).find('.hp-gain-wrap')[0]
|
||||
if (hpMenu.classList.contains("hp-gain-hud-disabled")) {
|
||||
$(html).find('.hp-gain-wrap')[0].classList.add('hp-gain-hud-active');
|
||||
$(html).find('.hp-gain-wrap')[0].classList.remove('hp-gain-hud-disabled');
|
||||
$(html).find('.hp-gain-wrap')[1].classList.add('hp-gain-hud-active');
|
||||
$(html).find('.hp-gain-wrap')[1].classList.remove('hp-gain-hud-disabled');
|
||||
$(html).find('.hp-gain-wrap')[2].classList.add('hp-gain-hud-active');
|
||||
$(html).find('.hp-gain-wrap')[2].classList.remove('hp-gain-hud-disabled');
|
||||
} else {
|
||||
$(html).find('.hp-gain-wrap')[0].classList.remove('hp-gain-hud-active');
|
||||
$(html).find('.hp-gain-wrap')[0].classList.add('hp-gain-hud-disabled');
|
||||
$(html).find('.hp-gain-wrap')[1].classList.remove('hp-gain-hud-active');
|
||||
$(html).find('.hp-gain-wrap')[1].classList.add('hp-gain-hud-disabled');
|
||||
$(html).find('.hp-gain-wrap')[2].classList.remove('hp-gain-hud-active');
|
||||
$(html).find('.hp-gain-wrap')[2].classList.add('hp-gain-hud-disabled');
|
||||
}
|
||||
})
|
||||
$(html).find('.gain-hp-hud-click').click((event) => {
|
||||
event.preventDefault();
|
||||
let hpGain = event.currentTarget.dataset.hpValue;
|
||||
if (token) {
|
||||
let tokenFull = canvas.tokens.placeables.find(t => t.id === token._id);
|
||||
console.log(tokenFull, token)
|
||||
let actor = tokenFull.actor;
|
||||
actor.applyDamage(Number(hpGain)); // Positive value to add HP
|
||||
$(html).find('.hp-gain-wrap')[0].classList.remove('hp-gain-hud-active');
|
||||
$(html).find('.hp-gain-wrap')[0].classList.add('hp-gain-hud-disabled');
|
||||
$(html).find('.hp-gain-wrap')[1].classList.remove('hp-gain-hud-active');
|
||||
$(html).find('.hp-gain-wrap')[1].classList.add('hp-gain-hud-disabled');
|
||||
$(html).find('.hp-gain-wrap')[2].classList.remove('hp-gain-hud-active');
|
||||
$(html).find('.hp-gain-wrap')[2].classList.add('hp-gain-hud-disabled');
|
||||
}
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
@@ -168,7 +208,7 @@ export default class LethalFantasyUtils {
|
||||
|
||||
const isMonster = defender.type === "monster"
|
||||
|
||||
// Pour les monstres, récupérer les attaques activées
|
||||
// Pour les monstres, récupérer les attaques activées
|
||||
if (isMonster) {
|
||||
const enabledAttacks = Object.entries(defender.system.attacks).filter(([key, attack]) => attack.enabled)
|
||||
|
||||
@@ -527,9 +567,9 @@ export default class LethalFantasyUtils {
|
||||
</div>
|
||||
<div class="combat-result-text">
|
||||
${isAttackWin ?
|
||||
`<i class="fa-solid fa-circle-check"></i> <strong>${data.attackerName}</strong> hits <strong>${data.defenderName}</strong>!` :
|
||||
`<i class="fa-solid fa-shield-halved"></i> <strong>${data.defenderName}</strong> parries the attack!`
|
||||
}
|
||||
`<i class="fa-solid fa-circle-check"></i> <strong>${data.attackerName}</strong> hits <strong>${data.defenderName}</strong>!` :
|
||||
`<i class="fa-solid fa-shield-halved"></i> <strong>${data.defenderName}</strong> parries the attack!`
|
||||
}
|
||||
</div>
|
||||
${damageButton}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user