Improvements to handling status amounts/values - #318
Open
Trantion897 wants to merge 5 commits into
Open
Conversation
Status values do not yet update in player view
Creature statuses are now stored as a map, not a set. This uses condition names as the key, and condition data as the value. The player screen and the logs now display the status amount (e.g. PF2's Dying or Stunned conditions), which previously only showed the condition name. Clicking + or - against a status amount on the GM screen triggers an update event, which causes the status to be added at the new amount, therefore updating the player screen. If the status is reduced to 0, the status is removed as before. The export function now saves creature status as an object mapping condition name to amount and 'hasAmount' (the latter because in my testing only the base D&D conditions were loaded while it was loading the current encounter). This means that you can quit Obsidian and come back to an existing encounter and the condition amounts will be saved. The import function still supports old-style array of condition names, so if someone updates the plugin while an encounter is running they shouldn't lose anything.
Commit 8238807 changed how conditions were logged, and seems to have stopped status removal being logged. This fix adds a call to log status removal from tracker.performCreatureUpdate(), and also logs status updates from the same method. This means changes to status amounts are added to the combat logs. Adding status is unchanged. It would have made the code more consistent if it was all logged during the mutator method (i.e. creature.addCondition or creature.removeCondition), but then it would be harder to put HP changes and status changes in the same log message.
Previously, if a status was added to multiple creatures, they stored pointers to the same status object. Therefore, changing the status amount for one creature changed it for all creatures with the same status. Cloning the object breaks this connection, so statuses can be modified for creatures independently
Trantion897
marked this pull request as ready for review
April 11, 2025 11:13
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Pull Request Description
This fixes a few bugs and missing features for support of status amounts, as used in Pathfinder 2nd Edition.
Changes Proposed
Related Issues
Fixes #305
Checklist
Screenshots (if applicable)
Status amounts shown in player view

Status changing in combat log

Additional Notes
I've put quite extensive notes about my design thinking in the code commits, I'm happy to answer any questions too.