import type { GameState } from '$lib/types/game-state'; export function getNextActivePlayer(state: GameState): number | null { const numPlayers = state.players.length; let next = (state.currentTurn + 1) % numPlayers; let checked = 0; while (checked < numPlayers) { const player = state.players[next]; if (player.status === 'active') { return next; } next = (next + 1) % numPlayers; checked++; } return null; } export function getFirstActivePlayerLeftOfDealer(state: GameState): number | null { const numPlayers = state.players.length; let pos = (state.dealerPosition + 1) % numPlayers; let checked = 0; while (checked < numPlayers) { if (state.players[pos].status === 'active') { return pos; } pos = (pos + 1) % numPlayers; checked++; } return null; }