// ─── Debug Bridge for E2E Testing ──────────────────────────────────────────────
// Exposes Zustand stores on window.__TEST__ so Playwright can call
// store actions via page.evaluate().  This file is a side-effect import;
// it runs once at module load time.

import { useGameStore } from './gameStore';
import { useManaStore } from './manaStore';
import { useCombatStore } from './combatStore';
import { useCraftingStore } from './craftingStore';
import { useAttunementStore } from './attunementStore';
import { usePrestigeStore } from './prestigeStore';
import { useDisciplineStore } from './discipline-slice';
import { useUIStore } from './uiStore';

if (typeof window !== 'undefined') {
  (window as any).__TEST__ = {
    useGameStore,
    useManaStore,
    useCombatStore,
    useCraftingStore,
    useAttunementStore,
    usePrestigeStore,
    useDisciplineStore,
    useUIStore,
    /**
     * Run n game ticks synchronously.
     * Each tick advances the game by HOURS_PER_TICK hours.
     * 50 ticks ≈ 1 in-game hour, 1200 ticks ≈ 1 in-game day.
     * Use this in E2E tests instead of waitForTimeout to speed up time-dependent assertions.
     */
    runTicks: (n: number) => {
      const store = useGameStore.getState();
      for (let i = 0; i < n; i++) {
        store.tick();
      }
    },
  };
}
