mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-23 07:53:39 +02:00
Made baseEffect.stacking nullable instead of having an enabled property
This commit is contained in:
parent
0fbe027d7d
commit
5ff1d0c71f
14 changed files with 70 additions and 43 deletions
|
|
@ -151,6 +151,10 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
|
|||
});
|
||||
});
|
||||
|
||||
htmlElement
|
||||
.querySelector('.stacking-change-checkbox')
|
||||
?.addEventListener('change', this.stackingChangeToggle.bind(this));
|
||||
|
||||
htmlElement
|
||||
.querySelector('.armor-change-checkbox')
|
||||
?.addEventListener('change', this.armorChangeToggle.bind(this));
|
||||
|
|
@ -209,6 +213,16 @@ export default class DhActiveEffectConfig extends foundry.applications.sheets.Ac
|
|||
return partContext;
|
||||
}
|
||||
|
||||
stackingChangeToggle(event) {
|
||||
const stackingFields = this.document.system.schema.fields.stacking.fields;
|
||||
const systemData = {
|
||||
stacking: event.target.checked
|
||||
? { value: stackingFields.value.initial, max: stackingFields.max.initial }
|
||||
: null
|
||||
};
|
||||
return this.submit({ updateData: { system: systemData } });
|
||||
}
|
||||
|
||||
armorChangeToggle(event) {
|
||||
if (event.target.checked) {
|
||||
this.addArmorChange();
|
||||
|
|
|
|||
|
|
@ -89,12 +89,12 @@ export default class DhEffectsDisplay extends HandlebarsApplicationMixin(Applica
|
|||
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)) {
|
||||
if (!effect || (delta >= 0 && !effect.system.stacking)) {
|
||||
return;
|
||||
}
|
||||
|
||||
const maxValue = effect.system.stacking.max ?? Infinity;
|
||||
const newValue = Math.clamp((effect.system.stacking.value ?? 1) + delta, 0, maxValue);
|
||||
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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue