import type { GameState, BettingRound } from '$lib/types/game-state'; import type { PlayerSeat } from '$lib/types/player'; import type { ActionRecord } from '$lib/types/action'; export function createInitialState(numPlayers: number, startingStack: number): GameState { const players: PlayerSeat[] = []; for (let i = 0; i < numPlayers; i++) { players.push({ id: `player-${i}`, name: i === 0 ? 'You' : `Bot ${i}`, chips: startingStack, currentBet: 0, status: 'active', holeCards: [], position: i }); } return { deck: [], players, communityCards: [], pot: 0, dealerPosition: Math.floor(Math.random() * numPlayers), currentTurn: 0, bettingRound: 'idle', actionHistory: [], currentBet: 0, lastRaiseAmount: 0, smallBlind: 10, bigBlind: 20 }; } export function rotateDealer(state: GameState): GameState { const nextDealer = (state.dealerPosition + 1) % state.players.length; return { ...state, dealerPosition: nextDealer }; } export function recordAction( state: GameState, playerId: string, type: ActionRecord['type'], amount?: number ): GameState { return { ...state, actionHistory: [ ...state.actionHistory, { playerId, type, amount, timestamp: Date.now() } ] }; }