Skip to content

Commit

Permalink
fix #7 Support armor that imposes stealth disadvantage (#8)
Browse files Browse the repository at this point in the history
* update skill reminder to check for armor that imposes disadvantage on stealth checks
* update docs
  • Loading branch information
kaelad02 authored Jan 20, 2022
1 parent 580d5d4 commit 12ba61b
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
# 0.4

* feature: support armor that imposes stealth disadvantage

# 0.3

* bug fix: Active effects from unequipped items weren't being ignored
Expand Down
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,12 @@
# Advantage Reminder for dnd5e

This module uses the active effect keys defined by Midi QOL to set the default of certain die rolls to advantage/disadvantage/critical. This is useful if you want to be reminded of advantage on Strength saving throws while Raging, for example, but you do not want to use Midi QOL. Midi QOL is great at automating combat with its workflow, however not every game group wants that level of automation. This module provides a good compromise by changing the default to remind you to roll with advantage, disadvantage, or a critical hit.
Want to use active effects to give your barbarian advantage on strength ability checks and saving throws when Raging? Don't want to install Midi QOL to do it? Then this module might be for you.

It also makes some small CSS changes (bold text) in order to make the advantage, disadvantage, and critical hit buttons more obvious when they should be clicked.
![Saving Throw screenshot with advantage](screenshot1.png?raw=true)

The basic die roller the D&D 5e system uses provides a pop-up dialog to give the player a chance to add situational bonuses or make d20 rolls with advantage/disadvantage or damage rolls as critical hits. It does not change the default button to remind you when to roll with advantage, disadvantage, or a critical hit. This module uses the active effect keys defined by Midi QOL to change the default button. This is useful if you want to be reminded to roll with advantage on a Strength saving throw while Raging, for example, but you do not want to use Midi QOL. Midi QOL is great at automating combat with its workflow, however not every game group wants that level of automation. If all you want is a reminder but remain in control of the die rolls, then this module is for you.

In addition to the active effects, this module supports armor that imposes stealth disadvantage when equipped. It also makes some small CSS changes (bold text) in order to make the advantage, disadvantage, and critical hit buttons more obvious when they should be clicked.

Supports active effects on the following rolls:

Expand Down
Binary file added screenshot1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
37 changes: 37 additions & 0 deletions src/reminders.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ class BaseReminder {
if (disKeys.includes(key)) disadvantage = true;
});
},
disadvantage: (value) => {
if (value) disadvantage = true;
},
update: (options) => {
debug(
`updating options with {advantage: ${advantage}, disadvantage: ${disadvantage}}`
Expand Down Expand Up @@ -173,6 +176,8 @@ export class SkillReminder extends AbilityCheckReminder {

/** @type {string} */
this.skillId = skillId;
/** @type {Item5e[]} */
this.items = actor.items;
}

/** @override */
Expand All @@ -190,6 +195,38 @@ export class SkillReminder extends AbilityCheckReminder {
`flags.midi-qol.disadvantage.skill.${this.skillId}`,
]);
}

/** @override */
updateOptions(options) {
// get the active effect keys applicable for this roll
const advKeys = this.advantageKeys;
const disKeys = this.disadvantageKeys;
debug("advKeys", advKeys, "disKeys", disKeys);

// find matching keys and update options
const accumulator = this._accumulator();
accumulator.disadvantage(this._armorStealthDisadvantage());
accumulator.add(this.actorKeys, advKeys, disKeys);
accumulator.update(options);
}

/**
* Check if the actor is wearing armor that imposes stealth disadvantage.
* @returns true if they are wearing armor that imposes stealth disadvantage, false otherwise
*/
_armorStealthDisadvantage() {
if (this.skillId === "ste") {
const item = this.items.find(
(item) =>
item.type === "equipment" &&
item.data?.data?.equipped &&
item.data?.data?.stealth
);
debug("equiped item that imposes stealth disadvantage", item?.name);
return !!item;
}
return false;
}
}

export class DeathSaveReminder extends AbilityBaseReminder {
Expand Down

0 comments on commit 12ba61b

Please sign in to comment.