mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-01-12 11:41:08 +01:00
ActiveEffect values can now specify ORIGIN. to grab the value from the origin (#534)
This commit is contained in:
parent
ee5c3a9322
commit
5757db3f49
3 changed files with 42 additions and 23 deletions
|
|
@ -70,7 +70,17 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
|
||||
/**@inheritdoc*/
|
||||
static applyField(model, change, field) {
|
||||
const evalValue = this.effectSafeEval(itemAbleRollParse(change.value, model, change.effect.parent));
|
||||
const isOriginTarget = change.value.toLowerCase().includes('origin.@');
|
||||
let parseModel = model;
|
||||
if (isOriginTarget && change.effect.origin) {
|
||||
change.value = change.value.replaceAll(/origin\.@/gi, '@');
|
||||
try {
|
||||
const doc = foundry.utils.fromUuidSync(change.effect.origin);
|
||||
if (doc) parseModel = doc;
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
const evalValue = this.effectSafeEval(itemAbleRollParse(change.value, parseModel, change.effect.parent));
|
||||
change.value = evalValue ?? change.value;
|
||||
super.applyField(model, change, field);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue