Fixed effect stacking

This commit is contained in:
WBHarry 2026-02-17 21:15:36 +01:00
parent 79057b0718
commit 617f1d64c1
7 changed files with 37 additions and 28 deletions

View file

@ -75,8 +75,7 @@ export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
nullable: false,
label: 'DAGGERHEART.GENERAL.value'
}),
max: new fields.NumberField({ label: 'DAGGERHEART.GENERAL.max' })
// max: new fields.StringField({ required: true, nullable: false }),
max: new fields.NumberField({ integer: true, label: 'DAGGERHEART.GENERAL.max' })
})
};
}

View file

@ -106,22 +106,11 @@ export default class EffectsField extends fields.ArrayField {
}
/**
* Apply an Effect to a target or enable it if already on it
* Apply an Effect to a target
* @param {object} effect Effect object containing ActiveEffect UUID
* @param {object} actor Actor Document
*/
static async applyEffect(effect, actor) {
const existingEffect = actor.effects.find(e => e.origin === effect.uuid);
if (existingEffect) {
return effect.update(
foundry.utils.mergeObject({
...effect.constructor.getInitialDuration(),
disabled: false
})
);
}
// Otherwise, create a new effect on the target
const effectData = foundry.utils.mergeObject({
...(effect.toObject?.() ?? effect),
disabled: false,