diff --git a/scripts/token_combat_border.mjs b/scripts/token_combat_border.mjs index 6af32bf..9884a41 100644 --- a/scripts/token_combat_border.mjs +++ b/scripts/token_combat_border.mjs @@ -87,8 +87,7 @@ function create_new_border(type, width, height, visible) { function token_set_border_visibility(token, played) { // Get the borders we manually added in the `drawToken` hook, if it has any. let borders = token.children.filter((child) => child.borderType); - // console.debug("↓↓↓ set_border_visibility ↓↓↓"); - // console.debug(token) + for (let border of borders) { if (border.borderType === BorderTypes.Active) { border.visible = !played; @@ -96,7 +95,6 @@ function token_set_border_visibility(token, played) { border.visible = played; } } - // console.debug("↑↑↑ set_border_visibility ↑↑↑"); } /** @@ -127,8 +125,6 @@ function token_remote_set_border_visibility(scene_id, token_id, played) { * @returns {boolean} If the token has played in the current or requested round */ function token_has_played(token, round = -1) { - // console.debug("↓↓↓ token_has_played ↓↓↓"); - // console.debug(token.inCombat) /** * When we change scene, the token might not be updated with the combat * data, so we might need to go check ourselves if they are not set. @@ -166,15 +162,12 @@ function token_has_played(token, round = -1) { } let round_turns_taken = combat?.flags.projectfu.CombatantsTurnTaken[round < 0 ? combat?.round : round] - // console.debug(`Testing played for round : ${combat?.round}`) - console.debug(round_turns_taken) // No token has taken a turn, or all turns were reverted. if (!round_turns_taken || round_turns_taken.length === 0) { return false; } - // console.debug("↑↑↑ token_has_played ↑↑↑"); // Token might have played, let's search now. return round_turns_taken.includes(combatant.id) } @@ -210,7 +203,6 @@ function token_combat_visibility_remote_update(scene_id, token_id, round) { */ function combat_hook_update_token_borders(combat, data) { // Turns is the array of *tokens having turns in this encounter*. - // console.debug("↓↓↓ combat_hook_update_token_borders ↓↓↓"); for (let combatant of combat.turns) { // The combat passed by the hook is still on the previous round or turn, which would make the check // use the previous round rather than the new one. Use the round contained in data instead, @@ -218,7 +210,6 @@ function combat_hook_update_token_borders(combat, data) { socket.executeForEveryone(SocketMessages.CombatUpdateBorder, combatant.sceneId, combatant.tokenId, data.round).then(); } - // console.debug("↑↑↑ combat_hook_update_token_borders ↑↑↑"); } function combat_border_main() { @@ -279,18 +270,9 @@ function combat_border_main() { return; let has_played_turn = token_has_played(drawn_token); - // console.log(drawn_token) - // console.log(`Is in combat ? ${drawn_token.inCombat}`) - // console.log(`Combatant ? ${drawn_token.combatant}`) - // console.log(`Combat ?`) - // console.log(drawn_token.combatant.combat); - // console.log(game.combats.combats) - const token_size = drawn_token.getSize(); drawn_token.addChild(create_new_border(BorderTypes.Active, token_size.width, token_size.height, !has_played_turn)); drawn_token.addChild(create_new_border(BorderTypes.Played, token_size.width, token_size.height, has_played_turn)); - - // console.log("============") }) @@ -305,10 +287,8 @@ function combat_border_main() { return; } - // console.debug("↓↓↓ Registering ↓↓↓") Hooks.on("combatTurn", combat_hook_update_token_borders); Hooks.on("combatRound", combat_hook_update_token_borders); - // console.debug("↑↑↑ Registering ↑↑↑") // No Foundry hook on end of combat, so use Fabula Ultima's. Hooks.on(FUHooks.COMBAT_EVENT, (combat_event) => {