mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-17 23:49:02 +01:00
Fixed so multiple statuses on an effect are still treated as active
This commit is contained in:
parent
c3e4f3922e
commit
cee4a07742
1 changed files with 40 additions and 5 deletions
|
|
@ -389,6 +389,41 @@ export default class DhpActor extends Actor {
|
||||||
return this.system.difficulty ?? 10;
|
return this.system.difficulty ?? 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** @inheritDoc */
|
||||||
|
async toggleStatusEffect(statusId, { active, overlay = false } = {}) {
|
||||||
|
const status = CONFIG.statusEffects.find(e => e.id === statusId);
|
||||||
|
if (!status) throw new Error(`Invalid status ID "${statusId}" provided to Actor#toggleStatusEffect`);
|
||||||
|
const existing = [];
|
||||||
|
|
||||||
|
// Find the effect with the static _id of the status effect
|
||||||
|
if (status._id) {
|
||||||
|
const effect = this.effects.get(status._id);
|
||||||
|
if (effect) existing.push(effect.id);
|
||||||
|
}
|
||||||
|
|
||||||
|
// If no static _id, find all effects that have this status
|
||||||
|
else {
|
||||||
|
for (const effect of this.effects) {
|
||||||
|
if (effect.statuses.has(status.id)) existing.push(effect.id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the existing effects unless the status effect is forced active
|
||||||
|
if (existing.length) {
|
||||||
|
if (active) return true;
|
||||||
|
await this.deleteEmbeddedDocuments('ActiveEffect', existing);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Create a new effect unless the status effect is forced inactive
|
||||||
|
if (!active && active !== undefined) return;
|
||||||
|
|
||||||
|
const ActiveEffect = getDocumentClass('ActiveEffect');
|
||||||
|
const effect = await ActiveEffect.fromStatusEffect(statusId);
|
||||||
|
if (overlay) effect.updateSource({ 'flags.core.overlay': true });
|
||||||
|
return ActiveEffect.implementation.create(effect, { parent: this, keepId: true });
|
||||||
|
}
|
||||||
|
|
||||||
getRollData() {
|
getRollData() {
|
||||||
const rollData = super.getRollData();
|
const rollData = super.getRollData();
|
||||||
rollData.system = this.system.getRollData();
|
rollData.system = this.system.getRollData();
|
||||||
|
|
@ -505,16 +540,16 @@ export default class DhpActor extends Actor {
|
||||||
Object.entries(healings).forEach(([key, healing]) => {
|
Object.entries(healings).forEach(([key, healing]) => {
|
||||||
healing.parts.forEach(part => {
|
healing.parts.forEach(part => {
|
||||||
const update = updates.find(u => u.key === key);
|
const update = updates.find(u => u.key === key);
|
||||||
if (update)
|
if (update) update.value += part.total;
|
||||||
update.value += part.total;
|
|
||||||
else updates.push({ value: part.total, key });
|
else updates.push({ value: part.total, key });
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
updates.forEach(
|
updates.forEach(
|
||||||
u =>
|
u =>
|
||||||
(u.value =
|
(u.value = !(u.key === 'fear' || this.system?.resources?.[u.key]?.isReversed === false)
|
||||||
!(u.key === 'fear' || this.system?.resources?.[u.key]?.isReversed === false) ? u.value * -1 : u.value)
|
? u.value * -1
|
||||||
|
: u.value)
|
||||||
);
|
);
|
||||||
|
|
||||||
await this.modifyResource(updates);
|
await this.modifyResource(updates);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue