Skip to content

Commit

Permalink
Fix compatibility with DFreds Convenient Effects
Browse files Browse the repository at this point in the history
  • Loading branch information
dev7355608 committed Aug 4, 2023
1 parent 0df0f68 commit 35e87aa
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 17 deletions.
6 changes: 3 additions & 3 deletions module.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"email": "[email protected]"
}
],
"version": "1.8.0",
"version": "1.8.1",
"compatibility": {
"minimum": "11.299",
"verified": "11.307"
Expand Down Expand Up @@ -47,8 +47,8 @@
},
"url": "https://github.com/dev7355608/vision-5e",
"manifest": "https://github.com/dev7355608/vision-5e/releases/latest/download/module.json",
"download": "https://github.com/dev7355608/vision-5e/releases/download/v1.8.0/module.zip",
"changelog": "https://github.com/dev7355608/vision-5e/releases/tag/v1.8.0",
"download": "https://github.com/dev7355608/vision-5e/releases/download/v1.8.1/module.zip",
"changelog": "https://github.com/dev7355608/vision-5e/releases/tag/v1.8.1",
"bugs": "https://github.com/dev7355608/vision-5e/issues",
"readme": "https://raw.githubusercontent.com/dev7355608/vision-5e/main/README.md",
"license": "https://raw.githubusercontent.com/dev7355608/vision-5e/main/LICENSE"
Expand Down
36 changes: 22 additions & 14 deletions scripts/compatibility.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ Hooks.once("init", () => {
});
});

Hooks.once("setup", () => {
Hooks.once("init", () => {
if (!game.modules.get("dfreds-convenient-effects")?.active) {
return;
}
Expand Down Expand Up @@ -129,23 +129,31 @@ Hooks.once("setup", () => {
}
];

const EffectDefinitions = game.dfreds.effects.constructor;
function addConditions() {
const EffectDefinitions = game.dfreds.effects.constructor;

EffectDefinitions.prototype.initialize = ((initialize) => function () {
this._conditions = this.conditions;
EffectDefinitions.prototype.initialize = ((initialize) => function () {
this._conditions = this.conditions;

for (const { id, name, icon } of customStatusEffects) {
this._conditions.push(this._effectHelpers.createActiveEffect({
name,
icon,
statuses: [id]
}));
}
for (const { id, name, icon } of customStatusEffects) {
this._conditions.push(this._effectHelpers.createActiveEffect({
name,
icon,
statuses: [id]
}));
}

this._conditions.sort((e1, e2) => e1.name.localeCompare(e2.name, "en"));
this._conditions.sort((e1, e2) => e1.name.localeCompare(e2.name, "en"));

return initialize.call(this);
})(EffectDefinitions.prototype.initialize);
return initialize.call(this);
})(EffectDefinitions.prototype.initialize);
}

if (game.dfreds?.effects) {
addConditions();
} else {
Hooks.once("socketlib.ready", addConditions);
}

game.settings.register(
"vision-5e",
Expand Down

0 comments on commit 35e87aa

Please sign in to comment.