Skip to content

Commit 7b512e3

Browse files
authored
Merge pull request #135 from vtt-lair/midiqol-fix
fix module to work with midi-qol
2 parents 4fa8ac3 + a2424aa commit 7b512e3

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

module.zip

2.64 MB
Binary file not shown.

src/roller.js

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ class LMRTFYRoller extends Application {
1414
this.chooseOne = data.chooseOne ?? false;
1515

1616
if (game.system.id === 'pf2e') {
17-
this.dc = data.dc;
17+
this.dc = data.dc;
18+
this.pf2Roll = '';
1819
}
1920

2021
if (data.title) {
@@ -135,7 +136,7 @@ class LMRTFYRoller extends Application {
135136
}
136137
}
137138

138-
async _makeRoll(event, rollMethod, rollId, rollFor) {
139+
async _makeRoll(event, rollMethod, ...args) {
139140
let fakeEvent = {}
140141
switch(this.advantage) {
141142
case -1:
@@ -162,21 +163,21 @@ class LMRTFYRoller extends Application {
162163
// system specific roll handling
163164
switch (game.system.id) {
164165
case "pf2e": {
165-
switch (rollFor) {
166+
switch (this.pf2Roll) {
166167
case this.pf2eRollFor.ABILITY:
167-
const modifier = LMRTFY.buildAbilityModifier(actor, rollId);
168+
const modifier = LMRTFY.buildAbilityModifier(actor, args[0]);
168169
game.pf2e.Check.roll(modifier, { type: 'skill-check', dc: this.dc, actor }, event);
169170
break;
170171

171172
case this.pf2eRollFor.SAVE:
172-
const save = actor.saves[rollId].check;
173+
const save = actor.saves[args[0]].check;
173174
const saveOptions = actor.getRollOptions(['all', `${save.ability}-based`, 'saving-throw', save.name]);
174175
save.roll({ event, saveOptions, dc: this.dc });
175176
break;
176177

177178
case this.pf2eRollFor.SKILL:
178179
// system specific roll handling
179-
const skill = actor.data.data.skills[rollId];
180+
const skill = actor.data.data.skills[args[0]];
180181
// roll lore skills only for actors who have them ...
181182
if (!skill) continue;
182183

@@ -194,7 +195,7 @@ class LMRTFYRoller extends Application {
194195
}
195196

196197
default: {
197-
await actor[rollMethod].call(actor, rollId, { event: fakeEvent });
198+
await actor[rollMethod].call(actor, ...args, { event: fakeEvent });
198199
}
199200
}
200201
}
@@ -346,19 +347,22 @@ class LMRTFYRoller extends Application {
346347
_onAbilityCheck(event) {
347348
event.preventDefault();
348349
const ability = event.currentTarget.dataset.ability;
349-
this._makeRoll(event, LMRTFY.abilityRollMethod, ability, (game.system.id === 'pf2e') ? this.pf2eRollFor.ABILITY : null);
350+
if (game.system.id === 'pf2e') this.pf2Roll = this.pf2eRollFor.ABILITY;
351+
this._makeRoll(event, LMRTFY.abilityRollMethod, ability);
350352
}
351353

352354
_onAbilitySave(event) {
353355
event.preventDefault();
354356
const saves = event.currentTarget.dataset.ability;
355-
this._makeRoll(event, LMRTFY.saveRollMethod, saves, (game.system.id === 'pf2e') ? this.pf2eRollFor.SAVE : null);
357+
if (game.system.id === 'pf2e') this.pf2Roll = this.pf2eRollFor.SAVE;
358+
this._makeRoll(event, LMRTFY.saveRollMethod, saves);
356359
}
357360

358361
_onSkillCheck(event) {
359362
event.preventDefault();
360363
const skill = event.currentTarget.dataset.skill;
361-
this._makeRoll(event, LMRTFY.skillRollMethod, skill, (game.system.id === 'pf2e') ? this.pf2eRollFor.SKILL : null);
364+
if (game.system.id === 'pf2e') this.pf2Roll = this.pf2eRollFor.SKILL;
365+
this._makeRoll(event, LMRTFY.skillRollMethod, skill);
362366
}
363367

364368
async _onCustomFormula(event) {

0 commit comments

Comments
 (0)