diff --git a/module/data/activity/base-activity.mjs b/module/data/activity/base-activity.mjs index 8fd9679123..9e2bd2e36b 100644 --- a/module/data/activity/base-activity.mjs +++ b/module/data/activity/base-activity.mjs @@ -156,11 +156,6 @@ export default class BaseActivityData extends foundry.abstract.DataModel { prepareData() { this.name = this.name || game.i18n.localize(this.metadata?.title); this.img = this.img || this.metadata?.img; - const item = this.item; - this.effects?.forEach(e => Object.defineProperty(e, "effect", { - get() { return item.effects.get(e._id); }, - configurable: true - })); UsesField.prepareData.call(this, this.getRollData({ deterministic: true })); } diff --git a/module/data/activity/fields/applied-effect-field.mjs b/module/data/activity/fields/applied-effect-field.mjs index f20e9023c6..269157bb38 100644 --- a/module/data/activity/fields/applied-effect-field.mjs +++ b/module/data/activity/fields/applied-effect-field.mjs @@ -12,4 +12,19 @@ export default class AppliedEffectField extends SchemaField { ...fields }, options); } + + /* -------------------------------------------- */ + + /** @inheritDoc */ + initialize(value, model, options={}) { + const obj = super.initialize(value, model, options); + const item = model.item; + + Object.defineProperty(obj, "effect", { + get() { return item?.effects.get(this._id); }, + configurable: true + }); + + return obj; + } }