Borders: Don't rely on .inCombat to check combat status

When changing scenes, *a lot* of data is either empty or points to
the previous scene, preventing us from knowing whether a token is in
combat or not directly from the token.

To work around that, go through the list of combats directly and try
to match them with the scene and token we are drawing instead of using
`.inCombat`.
We cannot rely on `game.combats.active` either as it points to the
active combat in the previous scene.

This is far more work, but it is the only working solution I found.
It depends quite a bit on Fabula Ultima's system combat type which
lists combatants.

This leaves a more minor issue that the borders are not updated when
switching between encounters on the same scene, but this is a rarer
scenario.

Remove the issue from the README and mention the encounter switch issue.
This commit is contained in:
trotFunky 2025-06-01 23:42:22 +01:00
parent 73d2a08b88
commit 77ae01a7b3
2 changed files with 42 additions and 15 deletions

View file

@ -38,12 +38,11 @@ The module supports going back and forth in the combat rounds, as well as going
### Limitations
There are currently one main issue that need to be fixed :
1. The token borders will be incorrect when switching to a new scene
- It is unclear why, but apparently switching to another scene is very different from loading a new scene,
and the combat encounter of the scene is not available when tokens are created. This means that the combat status,
and thus the border type, cannot be properly determined on scene switch.
- This can be fixed by receiving a combat update, either from the players or the GM, on the scene.
There are currently one minor issue that might be fixed :
1. The token borders will be incorrect when switching between different encounters in the same scene
- Producing a combat event or switching away and back to the scene will fix it.
- It doesn't appear that there is an event on combat switch that could be hooked into, which makes fixing the
issue uncertain.
## Token UI adjustments