mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 22:46:12 +01:00
Fixed effect stacking
This commit is contained in:
parent
79057b0718
commit
617f1d64c1
7 changed files with 37 additions and 28 deletions
|
|
@ -95,7 +95,10 @@ export default class DhEffectsDisplay extends HandlebarsApplicationMixin(Applica
|
|||
|
||||
if (!effect.system.stacking?.enabled) return;
|
||||
|
||||
const newValue = Math.min(effect.system.stacking.value + 1, effect.system.stacking.max);
|
||||
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();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,7 +52,7 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
|
|||
const icon = new PIXI.Sprite(tex);
|
||||
icon.tint = tint ?? 0xffffff;
|
||||
|
||||
if (effect?.system?.stacking?.enabled) {
|
||||
if (effect?.system?.stacking?.enabled && effect.system.stacking.value > 1) {
|
||||
const stackOverlay = new PIXI.Text(effect.system.stacking.value, {
|
||||
fill: '#f3c267',
|
||||
stroke: '#000000',
|
||||
|
|
|
|||
|
|
@ -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' })
|
||||
})
|
||||
};
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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,
|
||||
|
|
|
|||
|
|
@ -106,6 +106,20 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
update.img = 'icons/magic/life/heart-cross-blue.webp';
|
||||
}
|
||||
|
||||
const existingEffect = this.actor.effects.find(x => x.origin === data.origin);
|
||||
const stacks = data.system?.stacking?.enabled;
|
||||
if (existingEffect && !stacks) return false;
|
||||
|
||||
if (existingEffect && stacks) {
|
||||
const incrementedValue = existingEffect.system.stacking.value + 1;
|
||||
await existingEffect.update({
|
||||
'system.stacking.value': existingEffect.system.stacking.max
|
||||
? Math.min(incrementedValue, existingEffect.system.stacking.max)
|
||||
: incrementedValue
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
||||
const statuses = Object.keys(data.statuses ?? {});
|
||||
const immuneStatuses =
|
||||
statuses.filter(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue