more-hooks-itemroll-hooks
pre hooks for the Item workflow.The biggest baddest of these is obviously
Item5e#roll. I can think of a a few places a hook might be a useful checkpoint in this frankly massive method but would like some input.First some assumptions and constraints:
- Hooks are only for Synchronous workflows, but may be used to interrupt a workflow in order to do something asynchronous.
- Hooks cannot return values (other than false to interrupt a workflow as mentioned above), but they are encouraged to mutate their arguments.
- Hooks are meant to be interacted with by potentially many modules at once.
Now the method itself, as it currently stands: https://gitlab.com/foundrynet/dnd5e/-/blob/master/module/item/entity.js#L492
This bad boi does the following:
- Sets up for the AbilityUseDialog (and determines if it is necessary)
- Normalizes the output of the AbilityUseDialog and feeds those inputs into the next steps.
- If a spell is being upcast,
clone that spell as its higher level versionGood Candidate for Hook:
Item5e.preItemUsage - Test if the item consumption requested by the AbilityUseDialog is possible and create the update objects.
Hook Candidate:
Item5e.preItemConsumption - Handle that consumption on both Actor and Items
Hook Candidate:
Item5e.itemConsumption - Begin creation of a measured template if necessary
- Begin the
displayCard process to actually output the Item to chat.Current Hook:
Item5e.roll 