mirror of
https://github.com/Foundryborne/daggerheart.git
synced 2026-06-06 04:44:16 +02:00
Fixed so that ORIGIN effect values are handled differently depending on if they target the item or the origin
This commit is contained in:
parent
da11510e02
commit
610d263e19
2 changed files with 68 additions and 44 deletions
|
|
@ -172,24 +172,33 @@ export default class DhActiveEffect extends foundry.documents.ActiveEffect {
|
|||
static getChangeValue(model, change, effect) {
|
||||
let key = change.value.toString();
|
||||
const isOriginTarget = key.toLowerCase().includes('origin.@');
|
||||
let parseModel = model;
|
||||
let actorModel = model;
|
||||
let itemModel = effect.parent;
|
||||
if (isOriginTarget && effect.origin) {
|
||||
key = change.key.replaceAll(/origin\.@/gi, '@');
|
||||
try {
|
||||
const originEffect = foundry.utils.fromUuidSync(effect.origin);
|
||||
const doc =
|
||||
originEffect.parent?.parent instanceof game.system.api.documents.DhpActor
|
||||
? originEffect.parent
|
||||
: originEffect.parent.parent;
|
||||
if (doc) parseModel = doc;
|
||||
if (doc) {
|
||||
if (doc instanceof game.system.api.documents.DHItem) {
|
||||
itemModel = doc;
|
||||
key = key.replaceAll(/origin\.@/gi, '');
|
||||
} else {
|
||||
actorModel = doc;
|
||||
key = key.replaceAll(/origin\.@/gi, '@');
|
||||
}
|
||||
|
||||
}
|
||||
} catch (_) {}
|
||||
}
|
||||
|
||||
const stackingParsedValue = effect.system.stacking
|
||||
? Roll.replaceFormulaData(key, { stacks: effect.system.stacking.value })
|
||||
: key;
|
||||
const evalValue = itemAbleRollParse(stackingParsedValue, parseModel, effect.parent);
|
||||
return evalValue ?? key;
|
||||
const evalValue = itemAbleRollParse(stackingParsedValue, actorModel, itemModel);
|
||||
return evalValue ? evalValue : key;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue