mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-04-21 23:13: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
|
|
@ -109,15 +109,13 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
}
|
||||
|
||||
const existingEffect = this.actor.effects.find(x => x.origin === data.origin);
|
||||
const stacks = data.system?.stacking?.enabled;
|
||||
const stacks = Boolean(data.system?.stacking);
|
||||
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
|
||||
'system.stacking.value': Math.min(incrementedValue, existingEffect.system.stacking.max ?? Infinity)
|
||||
});
|
||||
return false;
|
||||
}
|
||||
|
|
@ -198,17 +196,13 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
} catch (_) {}
|
||||
}
|
||||
|
||||
const evalValue = this.effectSafeEval(this.effectRollParse(key, parseModel, effect.parent, effect));
|
||||
const stackingParsedValue = effect.system.stacking
|
||||
? Roll.replaceFormulaData(key, { stacks: effect.system.stacking.value })
|
||||
: key;
|
||||
const evalValue = itemAbleRollParse(stackingParsedValue, parseModel, effect.parent);
|
||||
return evalValue ?? key;
|
||||
}
|
||||
|
||||
static effectRollParse(value, actor, item, effect) {
|
||||
const stackingParsedValue = effect.system.stacking?.enabled
|
||||
? Roll.replaceFormulaData(value, { stacks: effect.system.stacking.value })
|
||||
: value;
|
||||
return itemAbleRollParse(stackingParsedValue, actor, item);
|
||||
}
|
||||
|
||||
/**
|
||||
* Altered Foundry safeEval to allow non-numeric return
|
||||
* @param {string} expression
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue