Skip to content

Commit

Permalink
fix(effects): handle DFreds Convenient Effects v4.y.z changes
Browse files Browse the repository at this point in the history
This removed the handy API method we were using to grab effects data, in
favour of a more standard Foundry document method (the effect interface
now returns proper `ActiveEffect` documents, so no custom antics are
needed).
  • Loading branch information
TheGiddyLimit committed Feb 25, 2023
1 parent 5b66f81 commit da6f131
Showing 1 changed file with 10 additions and 4 deletions.
14 changes: 10 additions & 4 deletions module/js/DataManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,10 +64,14 @@ export class DataManager {
const convEffect = game.dfreds.effectInterface.findEffectByName(eff.convenientEffect);
if (!convEffect) return eff;

const convEffectData = convEffect.convertToActiveEffectData({
includeAte: game.modules.get("ATL")?.active,
includeTokenMagic: game.modules.get("tokenmagic")?.active,
});
const convEffectData = convEffect.convertToActiveEffectData
// DCE < v4.0.0
? convEffect.convertToActiveEffectData({
includeAte: game.modules.get("ATL")?.active,
includeTokenMagic: game.modules.get("tokenmagic")?.active,
})
// DCE >= v4.0.0
: convEffect.toObject(true);

delete eff.convenientEffect;

Expand All @@ -80,9 +84,11 @@ export class DataManager {
img: convEffectData.icon,
// endregion
...eff,

// Override CE's built-in IDs, as they are not valid (e.g. `"id": "Convenient Effect: Invisible"`),
// which causes issues when creating temporary actors (e.g. when using Quick Insert to view a
// creature).
// (N.b.: No longer required as of CE v4.0.0)
id: foundry.utils.randomID(),
},
);
Expand Down

0 comments on commit da6f131

Please sign in to comment.