function showdown() { // Determine winner with proper hand evaluation const activePlayers = gameState.activePlayers.filter(p => !p.folded); if (activePlayers.length === 1) { // Only one player left const winner = activePlayers[0]; winner.chips += gameState.pot; winner.action = 'Wins!'; if (winner.isUser) { gameState.userStats.handsWon++; } showWinnerAnnouncement(winner, 'Everyone else folded', []); } else { // Multiple players - evaluate hands gameState.userStats.showdownsTotal++; let bestScore = -1; let winner = null; let winningHand = ''; let allResults = []; activePlayers.forEach(player => { const result = evaluatePokerHand(player.cards, gameState.communityCards); allResults.push({ player, ...result }); if (result.score > bestScore) { bestScore = result.score; winner = player; winningHand = result.handName; } }); if (winner) { winner.chips += gameState.pot; winner.action = 'Wins!'; if (winner.isUser) { gameState.userStats.handsWon++; gameState.userStats.showdownsWon++; } showWinnerAnnouncement(winner, winningHand, allResults); } } updateUI(); } function showWinnerAnnouncement(winner, handName, allResults) { // Create showdown results display let showdownHtml = `
Master No-Limit Texas Hold'em
Great job! Here are some ways to improve your game:
• Consider playing more hands in late position
• Work on your bet sizing for value
• Practice reading opponent tendencies