Closed yoshisman8 closed 2 years ago
Pausing this Merge Request, I discovered a bug with the new code that prevents you from changing some field values on the sheet.
I have found the root of the problem. It was not my code but rather a flaw in how Active Effects work. It appears that you basically cannot change any field's value it is under the effect of an Active Effect. I'll look into how to fix this but until then this Merge Request is ready to go.
This merge request contains two important updates to Saved Rolls as well as an important fix to the data structure of the Actor document.
Saved Roll Quick-Rolling & Roll Editing
The buttons on the saved rolls have been changed to now be 3 rolls: A roll button that bypasses the roll dialog entirely. Making it a truly quick and saved roll. And edit button which opens the roll dialog (The Roll button also being replaced with a "Save" button which mirrors the functionality of the "Update" button on the dialog's header) and the Delete button which has been unchanged.
Saved Roll API
Two new methods under the Actor class have been added to go hand in hand with this saved roll improvements.
savedRoll()
This method allows the user to quickly roll any saved roll on the actor by providing the exact name of the saved roll. This method is asynchronous, which means the user can await it if they need to. This roll also bypasses the roll dialog by default. Usage is as follows:
getSavedRoll()
This method is almost identical to the savedRoll method, but it just returns the finished RollForm for the user to make any last-minute modifications. Usage is as follows:
API hotfixes
Several fields in the Actor document (namely those listing specialties, charms, and other items from the actor) were not being populated until the character sheet was opened for the first time. This is bad because it means that a user who just logs into foundry and tries to use the new API methods to roll dice without having opened their sheet at least once will find itself with silent errors on the console about fields not being defined.
To fix this, I simply mirrored the code on actor-sheet.js that initializes these fields onto actor.js's
_prepareCharacterData()
method. Making these fields initialized the moment the actor itself is loaded.