diff --git a/CHANGELOG.md b/CHANGELOG.md index c842878..acce0a9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/README.md b/README.md index 60ebeae..e811073 100644 --- a/README.md +++ b/README.md @@ -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: diff --git a/screenshot1.png b/screenshot1.png new file mode 100644 index 0000000..58a8300 Binary files /dev/null and b/screenshot1.png differ diff --git a/src/reminders.js b/src/reminders.js index c08b6b2..4c0c35c 100644 --- a/src/reminders.js +++ b/src/reminders.js @@ -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}}` @@ -173,6 +176,8 @@ export class SkillReminder extends AbilityCheckReminder { /** @type {string} */ this.skillId = skillId; + /** @type {Item5e[]} */ + this.items = actor.items; } /** @override */ @@ -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 {