mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-22 07:23:37 +02:00
Simplify effect click event (#1748)
* Fixed a bunch of deprecations * Corrected AgileScout Beastform json data * Updated TokenHUD to the new v14 * Removed DestroyOnEmpty from consumables * Fixed so that tooltips don't get stuck (#1745) * [Feature] TagTeam Partial Rendering (#1735) * I done did it, I think * Think I fixed the partial rendering bug for gm->player * [V14] 1743 - Damage Update Error (#1746) * Fixed DamageParts causing errors on update * Fixed ActionBaseConfig error when no damage present on the action * Fix removal of damage field * Removed unneccessary default value function for parts --------- Co-authored-by: Carlos Fernandez <cfern1990@gmail.com> * Simplify effect click event --------- Co-authored-by: WBHarry <williambjrklund@gmail.com> Co-authored-by: WBHarry <89362246+WBHarry@users.noreply.github.com>
This commit is contained in:
parent
b2a900db16
commit
4652ccefbc
85 changed files with 633 additions and 641 deletions
|
|
@ -49,12 +49,9 @@ export default class DhEffectsDisplay extends HandlebarsApplicationMixin(Applica
|
|||
|
||||
_attachPartListeners(partId, htmlElement, options) {
|
||||
super._attachPartListeners(partId, htmlElement, options);
|
||||
|
||||
if (this.element) {
|
||||
this.element.querySelectorAll('.effect-container a').forEach(element => {
|
||||
element.addEventListener('click', this.effectLeftclick.bind(this));
|
||||
element.addEventListener('contextmenu', this.effectRightclick.bind(this));
|
||||
});
|
||||
for (const element of this.element?.querySelectorAll('.effect-container a') ?? []) {
|
||||
element.addEventListener('click', e => this.#onClickEffect(e));
|
||||
element.addEventListener('contextmenu', e => this.#onClickEffect(e, -1));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -88,31 +85,21 @@ export default class DhEffectsDisplay extends HandlebarsApplicationMixin(Applica
|
|||
this.render();
|
||||
}
|
||||
|
||||
async effectLeftclick(event) {
|
||||
async #onClickEffect(event, delta = 1) {
|
||||
const element = event.target.closest('.effect-container');
|
||||
const effects = DhEffectsDisplay.getTokenEffects();
|
||||
const effect = effects.find(x => x.id === element.dataset.effectId);
|
||||
if (!effect || (delta >= 0 && !effect.system.stacking?.enabled)) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!effect.system.stacking?.enabled) return;
|
||||
|
||||
const incrementedValue = effect.system.stacking.value + 1;
|
||||
const newValue = effect.system.stacking.max
|
||||
? Math.min(incrementedValue, effect.system.stacking.max)
|
||||
: incrementedValue;
|
||||
await effect.update({ 'system.stacking.value': newValue });
|
||||
this.render();
|
||||
}
|
||||
|
||||
async effectRightclick(event) {
|
||||
const element = event.target.closest('.effect-container');
|
||||
const effects = DhEffectsDisplay.getTokenEffects();
|
||||
const effect = effects.find(x => x.id === element.dataset.effectId);
|
||||
if (effect.system.stacking?.enabled && effect.system.stacking.value > 1) {
|
||||
await effect.update({ 'system.stacking.value': effect.system.stacking.value - 1 });
|
||||
const maxValue = effect.system.stacking.max ?? Infinity;
|
||||
const newValue = Math.clamp((effect.system.stacking.value ?? 1) + delta, 0, maxValue);
|
||||
if (newValue > 0) {
|
||||
await effect.update({ 'system.stacking.value': newValue });
|
||||
} else {
|
||||
await effect.delete();
|
||||
}
|
||||
|
||||
this.render();
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue