more-hooks-itemroll-hooks

For those of you interested in such things, I have hacked together a way to inject hooks into the middle of larger 5e class methods and thus I'm starting to look in earnest at 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 version Good 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
C
Calego784d ago
I wanna hear 2 things from anyone with an idea that fits: 1. Where in this monstrosity would a hook help? 2. What is the specific use case you can imagine for such a hook? Use case: Allowing items to consume several different things. (Eg spell slots or multiple different charges from different items) The preItemConsumption (or the post one?) hook above would allow for a module to check if the item being used has a flag denoting some additional consumption, and if so fire off a server request for executing that consumption. I think ideally the consumption step would be fully contained in a different method but that's a different matter. Use case: checking some usage condition and cancelling the item workflow early. PreItemUsage firing after the ability use Dialog resolves to check for some additional cases which would cause the item to fail to be used. Use case: display animation automatically when an item is used based on what item is used. Existing Roll hook would allow this with some caveats regarding measured templates. I think ideally the roll flow would await the template placement but that's a different topic. I'm gonna go ahead and ping @more-hooks-5e in here, since there's only like a dozen of you. My apologies but I deeply desire your input
C
ccjmk784d ago
I a little a lot sleepy right now so I might be getting the idea wrong, but I would love some hooks wrapping the spell upcasting shenanigans I... can't think of a use case right now, but there's definitely mischief possible there
C
Calego784d ago
Do tell me more, you mean before the spell level is locked in, like after the ability use dialog but before the item is cloned? That would allow the hook to change the level of spell selected (though I'm not sure to what end, as the user just had the chance to select such a thing)
C
ccjmk783d ago
my main idea is allowing for implementing spell point variants, but I just noticed there's a module for that already. It does mention it leverages the "Roll" class, so I think this might be a better place for implementing such a feature 🤔
Want results from more Discord servers?
Add your server
More Posts
preHooks5eJSON.stringify jankI discovered that the problem is JSON.stringify, not parselayersTIL about CSS Layers. https://developer.mozilla.org/en-US/docs/Web/CSS/@layer ```css @layer utilitiHitDice hooks MRI just added my first merge request 😄 <https://gitlab.com/foundrynet/dnd5e/-/merge_requests/495>advantage shennaneginsdevmode extension brainstormhttps://github.com/mdn/webextensions-examples/tree/master/devtools-panelsSaving Functions as module settings@wasp I remember you asked about saving functions as settings (which quickly turned into stringifyinnew consumable typesTried adding localization strings for some new consumable types, but keep getting this ("`DND5E.Consspell-compendium-5e alpha1Overriding onDropItem & onSortItemYou'd override them in your sheet class.getter & setter wrapper for settingsI'm trying to use a getter & setter pair as an interface for `game.settings.get` and `game.settings.scrollable tab contentsIt is possible, and you're firmly in the css and DOM structure side of development with this line ofJr devI'm cleaning out my bookmarks and accidentally came back to this article. Potentially useful startinHTCPackage: `hero-creation-tool`System Specific CSSI'm not 100% about this, but it is worth watching out that your solution doesn't actually end up beiadvancement-wipCommander register apitalking about permissions, im working on the registering api for the Commander, and I wanted to ask Azgaars Blurry MapHey all. I'm taking a look at my importer for Azgaar's Fantasy Map Generator and wondering how I canccjmk overlaybut for what I wanted I think I *needed* to append it there so that I can overlay the whole screencliits very very early alpha demo