Commit graph

7 commits

Author SHA1 Message Date
cc7db632d1 Borders: Fix borders on active combat change
A scene can have multiple combat encounters, but only one
can be active at a time.
Changing from one to the other does not trigger any of the regular
combat hooks, but it can be detected using a combat /document/ hook.

Register on the combat document update hook and update the borders
when the active state of the encounter is changed.

Both the previous and new active combats produce an update, and
the previous combat becoming inactive always comes first.
This means that we can safely set all token borders from the
previous document to the default border and they will be
updated accordingly by the new combat becoming active.

Update the comment of the data member for
`combat_hook_update_token_borders()`, as we re-use it for
the combat switch and we didn't use the `turn` member anymore.
2025-06-02 22:26:21 +01:00
9bc73100f3 Borders: Move main call in init hook
The main function is called at script invocation, which is nice and early
but everything we do is done in hooks.
This makes it not really useful, and harder to properly disable the module
with the settings.

So, register our `init` hook at script invocation and call the main function
from within.
This makes handling the disabling via the setting trivial, and ensures that
*everything* is properly disabled.

However, the `socketlib.ready` hook fires earlier than the `init` one, so
register the socket at invocation as well, but only register the remote
methods in the main function.
2025-06-02 00:00:42 +01:00
95bb1c3445 Borders: Clean up debug prints
A lot of console logs where left for debugging the scene switch issues.
Those issues being fixed now, they are not useful anymore : remove them.
2025-06-01 23:51:26 +01:00
77ae01a7b3 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.
2025-06-01 23:49:35 +01:00
73d2a08b88 Borders: Make clients check combat updates
In the Fabula Ultima system, the clients cannot
use the combat hooks, only the GM.
So the GM orchestrates the token visiblity changes
for all clients.

Currently, the GM checks the status of tokens when
they run the combat hook.
However, this doesn't work when the GM is on another
scene, as the tokens *do not exist* for their client
in this case, as only those in the current scene do.

To fix this, we need to do the token status check
on all clients, and verify that we are on the proper
scene : otherwise there won't be a token to update.

Change the method called on the clients by the GM
to be a wrapper around token_set_border_visibility()
which checks the scene and the token locally.

Introduce another method to manually set the border
status on clients via SocketLib, used for the end of
combat.

Remove the mentions of this issue in the README and
comments as this commit fixes it.
2025-06-01 22:17:36 +01:00
f617b26fe1 v0.2.0: Add setting to disable dynamic borders
The point of the module is to allow multiple functionalities
to support our campaign.
They might not be suited all the time or to all of them.
They might be buggy !

Add a toggle setting to the dynamic borders functionality,
so that we can keep the compendium while it is fixed.
2025-05-28 18:55:08 +01:00
6c3ce53101 Initial commit - v0.1.0
This initial version adds a custom compendium with a
macro for the tinkerer, and a dynamic token border
to track player turn status.

It has a couple of known major bugs but is needed for
an upcoming game, with fixes hopefully later.

It is only compatible with Foundry v12 at this time.
2025-05-12 22:55:13 +01:00