mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-03-07 14:36:13 +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;
|
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 });
|
await effect.update({ 'system.stacking.value': newValue });
|
||||||
this.render();
|
this.render();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ export default class DhTokenPlaceable extends foundry.canvas.placeables.Token {
|
||||||
const icon = new PIXI.Sprite(tex);
|
const icon = new PIXI.Sprite(tex);
|
||||||
icon.tint = tint ?? 0xffffff;
|
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, {
|
const stackOverlay = new PIXI.Text(effect.system.stacking.value, {
|
||||||
fill: '#f3c267',
|
fill: '#f3c267',
|
||||||
stroke: '#000000',
|
stroke: '#000000',
|
||||||
|
|
|
||||||
|
|
@ -75,8 +75,7 @@ export default class BaseEffect extends foundry.data.ActiveEffectTypeDataModel {
|
||||||
nullable: false,
|
nullable: false,
|
||||||
label: 'DAGGERHEART.GENERAL.value'
|
label: 'DAGGERHEART.GENERAL.value'
|
||||||
}),
|
}),
|
||||||
max: new fields.NumberField({ label: 'DAGGERHEART.GENERAL.max' })
|
max: new fields.NumberField({ integer: true, label: 'DAGGERHEART.GENERAL.max' })
|
||||||
// max: new fields.StringField({ required: true, nullable: false }),
|
|
||||||
})
|
})
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -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} effect Effect object containing ActiveEffect UUID
|
||||||
* @param {object} actor Actor Document
|
* @param {object} actor Actor Document
|
||||||
*/
|
*/
|
||||||
static async applyEffect(effect, actor) {
|
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({
|
const effectData = foundry.utils.mergeObject({
|
||||||
...(effect.toObject?.() ?? effect),
|
...(effect.toObject?.() ?? effect),
|
||||||
disabled: false,
|
disabled: false,
|
||||||
|
|
|
||||||
|
|
@ -106,6 +106,20 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
||||||
update.img = 'icons/magic/life/heart-cross-blue.webp';
|
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 statuses = Object.keys(data.statuses ?? {});
|
||||||
const immuneStatuses =
|
const immuneStatuses =
|
||||||
statuses.filter(
|
statuses.filter(
|
||||||
|
|
|
||||||
|
|
@ -8,7 +8,7 @@
|
||||||
<a {{#if effect.condition}}disabled{{/if}}>
|
<a {{#if effect.condition}}disabled{{/if}}>
|
||||||
<img src="{{effect.img}}" />
|
<img src="{{effect.img}}" />
|
||||||
</a>
|
</a>
|
||||||
{{#if effect.system.stacking.enabled}}
|
{{#if (and effect.system.stacking.enabled (gt effect.system.stacking.value 1))}}
|
||||||
<span class="stacking-value">{{effect.system.stacking.value}}</span>
|
<span class="stacking-value">{{effect.system.stacking.value}}</span>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
{{#if effect.condition}}<i class="effect-locked fa-solid fa-lock"></i>{{/if}}
|
{{#if effect.condition}}<i class="effect-locked fa-solid fa-lock"></i>{{/if}}
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,7 @@
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
||||||
{{#if effect.system.stacking.enabled}}
|
{{#if (and effect.system.stacking.enabled effect.system.stacking.max)}}
|
||||||
<div class="effect-stacks-outer-container">
|
<div class="effect-stacks-outer-container">
|
||||||
<div class="effect-stacks-title">{{localize "Stacks"}}</div>
|
<div class="effect-stacks-title">{{localize "Stacks"}}</div>
|
||||||
<div class="effect-stacks-container">
|
<div class="effect-stacks-container">
|
||||||
|
|
@ -33,12 +33,10 @@
|
||||||
<span class="effect-stack-title">{{localize "Current"}}</span>
|
<span class="effect-stack-title">{{localize "Current"}}</span>
|
||||||
<span>{{effect.system.stacking.value}}</span>
|
<span>{{effect.system.stacking.value}}</span>
|
||||||
</div>
|
</div>
|
||||||
{{#if effect.system.stacking.max}}
|
|
||||||
<div class="effect-stacks-inner-container">
|
<div class="effect-stacks-inner-container">
|
||||||
<span class="effect-stack-title">{{localize "Max"}}</span>
|
<span class="effect-stack-title">{{localize "Max"}}</span>
|
||||||
<span>{{effect.system.stacking.max}}</span>
|
<span>{{effect.system.stacking.max}}</span>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
|
@ -49,6 +47,7 @@
|
||||||
<p class="close-hint">
|
<p class="close-hint">
|
||||||
<i class="fa-solid fa-computer-mouse"></i> {{localize "DAGGERHEART.UI.EffectsDisplay.increaseStacks"}}
|
<i class="fa-solid fa-computer-mouse"></i> {{localize "DAGGERHEART.UI.EffectsDisplay.increaseStacks"}}
|
||||||
</p>
|
</p>
|
||||||
|
{{#if (gt effect.system.stacking.value 1)}}
|
||||||
<p class="close-hint">
|
<p class="close-hint">
|
||||||
<i class="fa-solid fa-computer-mouse"></i> {{localize "DAGGERHEART.UI.EffectsDisplay.decreaseStacks"}}
|
<i class="fa-solid fa-computer-mouse"></i> {{localize "DAGGERHEART.UI.EffectsDisplay.decreaseStacks"}}
|
||||||
</p>
|
</p>
|
||||||
|
|
@ -57,6 +56,11 @@
|
||||||
<i class="fa-solid fa-computer-mouse"></i> {{localize "DAGGERHEART.UI.EffectsDisplay.removeThing" thing=(localize "DAGGERHEART.GENERAL.Effect.single")}}
|
<i class="fa-solid fa-computer-mouse"></i> {{localize "DAGGERHEART.UI.EffectsDisplay.removeThing" thing=(localize "DAGGERHEART.GENERAL.Effect.single")}}
|
||||||
</p>
|
</p>
|
||||||
{{/if}}
|
{{/if}}
|
||||||
|
{{else}}
|
||||||
|
<p class="close-hint">
|
||||||
|
<i class="fa-solid fa-computer-mouse"></i> {{localize "DAGGERHEART.UI.EffectsDisplay.removeThing" thing=(localize "DAGGERHEART.GENERAL.Effect.single")}}
|
||||||
|
</p>
|
||||||
|
{{/if}}
|
||||||
</div>
|
</div>
|
||||||
{{/unless}}
|
{{/unless}}
|
||||||
</div>
|
</div>
|
||||||
Loading…
Add table
Add a link
Reference in a new issue