mrkwnzl / cyphersystem-foundryvtt

The Cypher System for Foundry VTT
Other
21 stars 14 forks source link

Add hook for when tag or recursion is enabled or disabled #312

Closed farling42 closed 10 months ago

farling42 commented 1 year ago

In order for my active effects module to be able to manage effects on tags and recursions properly, it would be nice if the core cyphersystem generated a hook.callAll when the user enables or disables a specific recursion.

For mutually exclusive tags and recursions, it would be nice if the hook was called with "enabled=false" for the old selected tag/recursion (if any), and "enabled=true" for the newly selected tag/recursion (if any).

Example hooks:

updateTag(actor, tagItem, enabled)
updateRecursion(actor, recursionItem, enabled)

or if it is best to avoid hook names that begin with "update" (since core Foundry can in theory do an update on any type of document):

toggleTag(actor, tagItem, enabled)
toggleRecursion(actor, recursionItem, enabled)
mrkwnzl commented 1 year ago

Yes, I’ll do that, but I’ll have to refactor how recursions work first and integrate them into the tagging engine. Also, would two hooks per exclusive tag/recursion be useful? It’s at least easier for me to implement, as I only call one update for those.

enableTag(actor, item);
disableTag(actor, item);
farling42 commented 1 year ago

Two hooks would be fine.

Is the "item" parameter the tag item?

farling42 commented 1 year ago

The rollEngine hook performs this correctly :-)

mrkwnzl commented 1 year ago

Wait, what? I don't even go through the roll engine when I toggle a tag or recursion, do I?

farling42 commented 1 year ago

Oops - I got the wrong issue. I thought that this was the one that introduced the rollEngine hook - but I'm wrong on that count.