Skip to content

Commit

Permalink
[foundryvtt#3911] Move effect getter into AppliedEffectData initializ…
Browse files Browse the repository at this point in the history
…ation
  • Loading branch information
arbron committed Aug 5, 2024
1 parent 6b4e97d commit a46bc36
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 5 deletions.
5 changes: 0 additions & 5 deletions module/data/activity/base-activity.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 }));
}

Expand Down
15 changes: 15 additions & 0 deletions module/data/activity/fields/applied-effect-field.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}

0 comments on commit a46bc36

Please sign in to comment.