diff --git a/src/main.ts b/src/main.ts index 0c640ed..099d736 100644 --- a/src/main.ts +++ b/src/main.ts @@ -1,5 +1,7 @@ import "./styles.css"; +console.log("[DEBUG] Starting main.ts import..."); + import { ROOT_SHIFT_COST, ROUND_ANIMATION_BONUS_MS, @@ -52,16 +54,22 @@ import type { import { keyFor, parseKey, tint, wait } from "./utils"; const app = document.querySelector("#app"); +console.log("[DEBUG] App element found:", app); if (!(app instanceof HTMLElement)) { + console.error("[DEBUG] #app container not found or not HTMLElement"); throw new Error("#app container not found"); } +console.log("[DEBUG] Initializing state..."); let roundAnimationToken = 0; let setup: SetupState = createSetupState(); +console.log("[DEBUG] Setup created:", setup); let state: GameState = createInitialState(setup); +console.log("[DEBUG] Initial state created:", state); let isNewGameModalOpen = false; let previousScoreSnapshot: ScoreSnapshot[] | null = null; +console.log("[DEBUG] State initialized, proceeding to render..."); function rebuildSetup(overrides: Partial = {}) { setup = createSetupState( @@ -1422,24 +1430,35 @@ function attachEvents() { } function render() { - const playerCount = state.players.length; - app.innerHTML = ` -
-
- ${renderBoard()} -
- ${renderSidebar()} -
- ${renderScoreboard()} -
-
- ${renderNewGameModal()} - ${renderInitiativeModal()} - ${renderWeatherDraftModal()} - `; - - attachEvents(); - previousScoreSnapshot = getScoreSnapshot(); + console.log("[DEBUG] render() called, playerCount:", state?.players?.length); + try { + const playerCount = state.players.length; + console.log("[DEBUG] Building HTML..."); + app.innerHTML = ` +
+
+ ${renderBoard()} +
+ ${renderSidebar()} + +
+ ${renderNewGameModal()} + ${renderInitiativeModal()} + ${renderWeatherDraftModal()} + `; + console.log("[DEBUG] HTML rendered, attaching events..."); + attachEvents(); + console.log("[DEBUG] Events attached, getting score snapshot..."); + previousScoreSnapshot = getScoreSnapshot(); + console.log("[DEBUG] Render complete!"); + } catch (error) { + console.error("[DEBUG] Error in render():", error); + throw error; + } } +console.log("[DEBUG] About to call render()..."); render(); +console.log("[DEBUG] render() executed");