Skip to content

Commit

Permalink
fix #22 Add guards for a null event
Browse files Browse the repository at this point in the history
I thought the default value event was set to would work but Midi was passing in null and the default isn't used there. I also added defaults on my wrapper methods for options since those base methods do work without passing options.
  • Loading branch information
kaelad02 committed Feb 8, 2022
1 parent 845a876 commit 80a40f6
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 11 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 1.2

- bug fix: [#22](https://github.com/kaelad02/adv-reminder/issues/22) Error during damage rolls when Midi-QOL auto-rolls damage

# 1.1

- bug fix: damage roll wrapper wasn't checking `options.fastForward`
Expand Down
22 changes: 11 additions & 11 deletions src/module.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ Hooks.once("ready", () => {
}
});

async function onRollAttack(wrapped, options) {
async function onRollAttack(wrapped, options = {}) {
debug("onRollAttack method called");

// check for adv/dis flags unless the user pressed a fast-forward key
Expand All @@ -137,7 +137,7 @@ async function onRollAttack(wrapped, options) {
return wrapped(options);
}

async function onRollAbilitySave(wrapped, abilityId, options) {
async function onRollAbilitySave(wrapped, abilityId, options = {}) {
debug("onRollAbilitySave method called");

// check if an effect says to fail this roll
Expand All @@ -159,7 +159,7 @@ async function onRollAbilitySave(wrapped, abilityId, options) {
return wrapped(abilityId, options);
}

async function onRollAbilityTest(wrapped, abilityId, options) {
async function onRollAbilityTest(wrapped, abilityId, options = {}) {
debug("onRollAbilityTest method called");

// check for adv/dis flags unless the user pressed a fast-forward key
Expand All @@ -177,7 +177,7 @@ async function onRollAbilityTest(wrapped, abilityId, options) {
return wrapped(abilityId, options);
}

async function onRollSkill(wrapped, skillId, options) {
async function onRollSkill(wrapped, skillId, options = {}) {
debug("onRollSkill method called");

// check for adv/dis flags unless the user pressed a fast-forward key
Expand All @@ -195,7 +195,7 @@ async function onRollSkill(wrapped, skillId, options) {
return wrapped(skillId, options);
}

async function onRollToolCheck(wrapped, options) {
async function onRollToolCheck(wrapped, options = {}) {
debug("onRollToolCheck method called");

// check for adv/dis flags unless the user pressed a fast-forward key
Expand All @@ -219,7 +219,7 @@ async function onRollToolCheck(wrapped, options) {
return wrapped(options);
}

async function onRollDeathSave(wrapped, options) {
async function onRollDeathSave(wrapped, options = {}) {
debug("onRollDeathSave method called");

// check for adv/dis flags unless the user pressed a fast-forward key
Expand All @@ -237,7 +237,7 @@ async function onRollDeathSave(wrapped, options) {
return wrapped(options);
}

async function onRollDamage(wrapped, options) {
async function onRollDamage(wrapped, options = {}) {
debug("onRollDamage method called");

// check for critical flags unless the user pressed a fast-forward key
Expand Down Expand Up @@ -266,10 +266,10 @@ async function onRollDamage(wrapped, options) {
function isFastForwarding({ fastForward = false, event = {} }) {
return !!(
fastForward ||
event.shiftKey ||
event.altKey ||
event.ctrlKey ||
event.metaKey
event?.shiftKey ||
event?.altKey ||
event?.ctrlKey ||
event?.metaKey
);
}

Expand Down

0 comments on commit 80a40f6

Please sign in to comment.