From 1c14de1621083c67ecc8e63e3d2d692009a4df24 Mon Sep 17 00:00:00 2001 From: Werner Date: Tue, 31 Jan 2023 19:44:34 +0100 Subject: [PATCH] fix double roller and don't use getName for module checks --- src/lmrtfy.js | 2 +- src/roller.js | 29 ++++++++--------------------- 2 files changed, 9 insertions(+), 22 deletions(-) diff --git a/src/lmrtfy.js b/src/lmrtfy.js index 765f833..379d6f1 100644 --- a/src/lmrtfy.js +++ b/src/lmrtfy.js @@ -232,7 +232,7 @@ class LMRTFY { ''; // for now we don't allow can fails until midi-qol has update patching.js - if (game.modules.getName("midi-qol")?.active && !isNewerVersion(game.modules.getName("midi-qol")?.version, "10.0.26")) { + if (game.modules.get("midi-qol")?.active && !isNewerVersion(game.modules.get("midi-qol")?.version, "10.0.26")) { LMRTFY.canFailChecks = false; } diff --git a/src/roller.js b/src/roller.js index 292de88..e1eb7f1 100644 --- a/src/roller.js +++ b/src/roller.js @@ -29,8 +29,8 @@ class LMRTFYRoller extends Application { PERCEPTION: "perception", } - this.hasMidi = game.modules.getName("midi-qol")?.active; - this.midiUseNewRoller = isNewerVersion(game.modules.getName("midi-qol")?.version, "10.0.26"); + this.hasMidi = game.modules.get("midi-qol")?.active; + this.midiUseNewRoller = isNewerVersion(game.modules.get("midi-qol")?.version, "10.0.26"); Handlebars.registerHelper('canFailAbilityChecks', function (name, ability) { if (LMRTFY.canFailChecks) { @@ -479,9 +479,7 @@ class LMRTFYRoller extends Application { if (game.system.id === 'pf2e') this.pf2Roll = this.pf2eRollFor.ABILITY; // until patching has been removed - if (!this.hasMidi) { - this._makeRoll(event, LMRTFY.abilityRollMethod, false, ability); - } else if (this.midiUseNewRoller) { + if (!this.hasMidi || this.midiUseNewRoller) { this._makeRoll(event, LMRTFY.abilityRollMethod, false, ability); } else { this._makeRoll(event, LMRTFY.abilityRollMethod, ability); @@ -494,9 +492,7 @@ class LMRTFYRoller extends Application { if (game.system.id === 'pf2e') this.pf2Roll = this.pf2eRollFor.ABILITY; // until patching has been removed - if (!this.hasMidi) { - this._makeRoll(event, LMRTFY.abilityRollMethod, true, ability); - } else if (this.midiUseNewRoller) { + if (!this.hasMidi || this.midiUseNewRoller) { this._makeRoll(event, LMRTFY.abilityRollMethod, true, ability); } else { this._makeRoll(event, LMRTFY.abilityRollMethod, ability); @@ -507,12 +503,9 @@ class LMRTFYRoller extends Application { event.preventDefault(); const saves = event.currentTarget.dataset.ability; if (game.system.id === 'pf2e') this.pf2Roll = this.pf2eRollFor.SAVE; - this._makeRoll(event, LMRTFY.saveRollMethod, false, saves); // until patching has been removed - if (!this.hasMidi) { - this._makeRoll(event, LMRTFY.saveRollMethod, false, saves); - } else if (this.midiUseNewRoller) { + if (!this.hasMidi || this.midiUseNewRoller) { this._makeRoll(event, LMRTFY.saveRollMethod, false, saves); } else { this._makeRoll(event, LMRTFY.saveRollMethod, saves); @@ -525,9 +518,7 @@ class LMRTFYRoller extends Application { if (game.system.id === 'pf2e') this.pf2Roll = this.pf2eRollFor.SAVE; // until patching has been removed - if (!this.hasMidi) { - this._makeRoll(event, LMRTFY.saveRollMethod, true, saves); - } else if (this.midiUseNewRoller) { + if (!this.hasMidi || this.midiUseNewRoller) { this._makeRoll(event, LMRTFY.saveRollMethod, true, saves); } else { this._makeRoll(event, LMRTFY.saveRollMethod, saves); @@ -540,9 +531,7 @@ class LMRTFYRoller extends Application { if (game.system.id === 'pf2e') this.pf2Roll = this.pf2eRollFor.SKILL; // until patching has been removed - if (!this.hasMidi) { - this._makeRoll(event, LMRTFY.skillRollMethod, false, skill); - } else if (this.midiUseNewRoller) { + if (!this.hasMidi || this.midiUseNewRoller) { this._makeRoll(event, LMRTFY.skillRollMethod, false, skill); } else { this._makeRoll(event, LMRTFY.skillRollMethod, skill); @@ -555,9 +544,7 @@ class LMRTFYRoller extends Application { if (game.system.id === 'pf2e') this.pf2Roll = this.pf2eRollFor.SKILL; // until patching has been removed - if (!this.hasMidi) { - this._makeRoll(event, LMRTFY.skillRollMethod, true, skill); - } else if (this.midiUseNewRoller) { + if (!this.hasMidi || this.midiUseNewRoller) { this._makeRoll(event, LMRTFY.skillRollMethod, true, skill); } else { this._makeRoll(event, LMRTFY.skillRollMethod, skill);