Skip to content

Commit

Permalink
Scaffolding for initiative tracking.
Browse files Browse the repository at this point in the history
  • Loading branch information
ChunkLightTuna committed Mar 30, 2024
1 parent 606847f commit 7184311
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
18 changes: 14 additions & 4 deletions src/combat.mjs
Original file line number Diff line number Diff line change
@@ -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() {
Expand Down
5 changes: 3 additions & 2 deletions src/module.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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()
}


Expand Down

0 comments on commit 7184311

Please sign in to comment.