This commit is contained in:
WBHarry 2026-03-07 02:01:07 +01:00 committed by GitHub
commit 4176b1ca99
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
17 changed files with 319 additions and 228 deletions

View file

@ -1,5 +1,5 @@
import { itemAbleRollParse } from '../helpers/utils.mjs';
import { RefreshType, socketEvent } from '../systemRegistration/socket.mjs';
import { RefreshType } from '../systemRegistration/socket.mjs';
export default class DhActiveEffect extends foundry.documents.ActiveEffect {
/* -------------------------------------------- */
@ -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(
@ -182,10 +196,17 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
} catch (_) {}
}
const evalValue = this.effectSafeEval(itemAbleRollParse(key, parseModel, effect.parent));
const evalValue = this.effectSafeEval(this.effectRollParse(key, parseModel, effect.parent, effect));
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