Refactor roll methods on actors
Summary
(Summarize the bug encountered concisely)
Steps to reproduce
(How one can reproduce the issue - this is very important)
- Do this
- Then do this
What is the current bug behavior?
Some of our roll methods on actors, such as rollAbility()
, currently make a lot of assumptions that prevent them from being used in other contexts than when the sheet is open.
Example
let a = game.actors.getName('My Actor');
a.rollAbility('str');
The above will return an error such as:
dice.js:138 Uncaught TypeError: Cannot read properties of undefined (reading 'shiftKey')
at Function.d20Roll (dice.js:138)
at ActorArchmage.rollAbilityTest (actor.js:881)
at ActorArchmage.rollAbility (actor.js:840)
at <anonymous>:1:3
What is the expected correct behavior?
Roll methods on actors that aren't prefixed with an underscore should be able to be called by other contexts, such as macros or code executed in the console.
Notes
It primarily seems to be the method for rolling dice that's affected by this, and is most reproducible when rolling ability scores. It seems to break down on a few different points: the event global, the html variable, and how the roll object is being handled.
This one is a soft blocker. It works totally fine in contexts most users will encounter, but I noticed it while I was trying to add support for Token Action HUD.