Skip to content

Conversation

@Trantion897
Copy link
Contributor

@Trantion897 Trantion897 commented Apr 11, 2025

Pull Request Description

This fixes a few bugs and missing features for support of status amounts, as used in Pathfinder 2nd Edition.

Changes Proposed

  • Status amounts are displayed in player view and update correctly
  • Status amounts are now stored when saving and restored when loading (previously only the status name was saved)
  • Status amount changes are written to the combat log
  • Fix logging status removal
  • Changes to status amount for one creature don't affect other creatures

Related Issues

Fixes #305

Checklist

  • I have read the contribution guidelines and code of conduct.
  • I have tested the changes locally and they are working as expected.
  • I have added appropriate comments and documentation for the code changes.
  • My code follows the coding style and standards of this project.
  • I have rebased my branch on the latest main (or master) branch.
  • All tests (if applicable) have passed successfully.
  • I have run linters and fixed any issues.
  • I have checked for any potential security issues or vulnerabilities.

Screenshots (if applicable)

Status amounts shown in player view
image

Status changing in combat log
image

Additional Notes

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

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 Trantion897 marked this pull request as ready for review April 11, 2025 11:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

🐞 Status with amount is linked when applied to more than one creature

1 participant