Skip to content

Commit

Permalink
Merge pull request #175 from vtt-lair/feat/fail_buttons
Browse files Browse the repository at this point in the history
fix double roller and don't use getName for module checks
  • Loading branch information
vtt-lair authored Jan 31, 2023
2 parents 6d77fd3 + 1c14de1 commit d9fc5c7
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 22 deletions.
2 changes: 1 addition & 1 deletion src/lmrtfy.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ class LMRTFY {
'</svg>';

// 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;
}

Expand Down
29 changes: 8 additions & 21 deletions src/roller.js
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit d9fc5c7

Please sign in to comment.