diff --git a/src/combat.mjs b/src/combat.mjs index 8883e13..266bd70 100644 --- a/src/combat.mjs +++ b/src/combat.mjs @@ -1,11 +1,21 @@ import {item_roll, Logger} from "./util.mjs"; -import {session_id, socket} from "./module.mjs"; +import {socket} from "./module.mjs"; import {ID_MAP, MODULE_ID} from "./constants.mjs"; -export function combat_hooks() { - Logger.info("Monk's Tokenbar found.") - socket.emit('combat', {session_id: session_id, id_to_xp: mtb.actors.map(a => ([a['id'], a['xp']]))}) +//TODO: Include some logic to set/remove these hooks when combat_tracking_enabled is changed +export function set_combat_hooks() { + Logger.info("Setting Combat Hooks.") + + Hooks.on("combatStart", async (combat, updateData) => { + socket.emit('combat', combat.toJSON()) + }) + Hooks.on("combatTurn", async (combat, updateData) => { + socket.emit('combat', combat.toJSON()) + }) + Hooks.on("combatRound", async (combat, updateData) => { + socket.emit('combat', combat.toJSON()) + }) } export function handle_incoming_rolls() { diff --git a/src/module.mjs b/src/module.mjs index ee54f32..6fe2343 100644 --- a/src/module.mjs +++ b/src/module.mjs @@ -29,8 +29,6 @@ Hooks.once("ready", async () => { if (game.user.isGM) { await registerSettings() open_socket_with_oronder() - monks_token_bar_hooks() - handle_incoming_rolls() } game.socket.on(SOCKET_NAME, data => { @@ -96,6 +94,9 @@ export function open_socket_with_oronder(update = false) { set_session(session) game.socket.emit(SOCKET_NAME, {action: 'session', session: session}) }) + + monks_token_bar_hooks() + handle_incoming_rolls() }