Move some renderChatMessage handlers to other hooks #176
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
These handlers were acting on old chat messages when scrolling back in the chat history as if they were current.
Also fixes a few bugs.
Use isThaumaturge() instead of checking translated class name. Fixes an issue where dual-class thaum didn't update weakness.
The check for the EW save being used didn't take into account that the EW modifier will show up in the save context for saves where it wasn't used, but with enabled set to false. This caused the EW save to get removed on the first save rolled, even if it wasn't against the EV target.
Move the update vulnerability and esoteric warden attack handlers to createChatMessage. They only run on new messages this way. They both have a different user take an action than the one who created the message, so need to run for all users on each chat message.
For the esoteric warden save handler, it's the same user who rolls the save as will update the EW effect, so it's done in preCreateChatMessage and only the rolling user will run the hook.
Get target of strike from message.target, instead of doing lookup from thaum module specific flag.
The esoteric warden check would iterate over every item of every target of every attack and save message. Speed this up by doing the fast checks first. I.e., don't look at the targets if the message isn't an attack. Then just look at the effects on the attacker to see if they are an EV target of anyone. And then see if thaum(s) that has them as EV target is in the message target list.