Skip to content

Commit

Permalink
#53
Browse files Browse the repository at this point in the history
- #53: Add support for Dfred's toggleEffect.
  • Loading branch information
Larkinabout committed Jul 3, 2023
1 parent 3c91646 commit 107ce35
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 7 deletions.
21 changes: 15 additions & 6 deletions scripts/roll-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -238,18 +238,27 @@ Hooks.once('tokenActionHudCoreApiReady', async (coreModule) => {
* @param {object} actor The actor
* @param {object} token The token
* @param {string} actionId The action id
* @param {object} effect The effect
*/
async #toggleCondition (event, actor, token, actionId, effect = null) {
async #toggleCondition (event, actor, token, actionId) {
if (!token) return

const isRightClick = this.isRightClick(event)
if (game.dfreds && effect?.flags?.isConvenient) {
const effectLabel = effect.label
game.dfreds.effectInterface.#toggleEffect(effectLabel)
const statusEffect = CONFIG.statusEffects.find(statusEffect => statusEffect.id === actionId)
const isConvenient = (statusEffect?.flags)
? Object.hasOwn(statusEffect.flags, 'dfreds-convenient-effects')
? statusEffect.flags['dfreds-convenient-effects'].isConvenient
: null
: null ??
actionId.startsWith('Convenient Effect')

if (game.dfreds && isConvenient) {
isRightClick
? await game.dfreds.effectInterface.toggleEffect(statusEffect.name, { overlay: true })
: await game.dfreds.effectInterface.toggleEffect(statusEffect.name)
} else {
const condition = this.#findCondition(actionId)
const effect = this.#findEffect(actor, actionId)
if (!condition) return
const effect = this.#findEffect(actor, actionId)
if (effect?.disabled) { await effect.delete() }

isRightClick
Expand Down
Loading

0 comments on commit 107ce35

Please sign in to comment.