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 = `
🏆 ${winner.name} Wins!
${handName}
Pot: ${gameState.pot}
`; // Show all player hands if multiple players if (allResults.length > 1) { showdownHtml += '
All Hands:
'; allResults.forEach(result => { const cardIcons = result.player.cards.map(card => `${card.rank}${card.suit}` ).join(' '); showdownHtml += `
${result.player.name}: ${cardIcons} - ${result.handName}
`; }); } else { // Show winner's cards const cardIcons = winner.cards.map(card => `${card.rank}${card.suit}` ).join(' '); showdownHtml += `
Winner's Hand: ${cardIcons}
`; } showdownHtml += '
'; // Add to table document.getElementById('poker-table').insertAdjacentHTML('beforeend', showdownHtml); // Remove after 4 seconds setTimeout(() => { const resultsDiv = document.getElementById('showdown-results'); if (resultsDiv) { resultsDiv.remove(); } // Continue game continueAfterShowdown(); }, 4000); } function continueAfterShowdown() { // Remove eliminated players gameState.activePlayers = gameState.activePlayers.filter(p => p.chips > 0); // Update stats gameState.userStats.handsPlayed++; // Check for tournament end if (gameState.activePlayers.length <= 1) { endTournament(); } else { // Increase blinds if needed gameState.handsUntilBlindIncrease--; if (gameState.handsUntilBlindIncrease <= 0) { gameState.smallBlind *= 2; gameState.bigBlind *= 2; gameState.handsUntilBlindIncrease = 5; } gameState.handNumber++; startNewHand(); } } function evaluatePokerHand(playerCards, communityCards) { const allCards = [...playerCards, ...communityCards]; if (allCards.length < 5) { return { score: Math.random() * 1000, handName: 'High Card' }; } // Count ranks and suits const rankCounts = {}; const suitCounts = {}; const ranks = []; allCards.forEach(card => { rankCounts[card.value] = (rankCounts[card.value] || 0) + 1; suitCounts[card.suit] = (suitCounts[card.suit] || 0) + 1; ranks.push(card.value); }); ranks.sort((a, b) => b - a); const uniqueRanks = [...new Set(ranks)].sort((a, b) => b - a); // Check for flush const isFlush = Object.values(suitCounts).some(count => count >= 5); // Check for straight let isStraight = false; let straightHigh = 0; // Check normal straight for (let i = 0; i <= uniqueRanks.length - 5; i++) { if (uniqueRanks[i] - uniqueRanks[i + 4] === 4) { isStraight = true; straightHigh = uniqueRanks[i]; break; } } // Check wheel straight (A-2-3-4-5) if (!isStraight && uniqueRanks.includes(14) && uniqueRanks.includes(5) && uniqueRanks.includes(4) && uniqueRanks.includes(3) && uniqueRanks.includes(2)) { isStraight = true; straightHigh = 5; } // Count pairs, trips, quads const counts = Object.values(rankCounts).sort((a, b) => b - a); // Determine hand ranking let score = 0; let handName = ''; if (isStraight && isFlush) { if (straightHigh === 14) { score = 9000 + straightHigh; handName = 'Royal Flush'; } else { score = 8000 + straightHigh; handName = 'Straight Flush'; } } else if (counts[0] === 4) { score = 7000 + Math.max(...Object.keys(rankCounts).filter(k => rankCounts[k] === 4).map(Number)); handName = 'Four of a Kind'; } else if (counts[0] === 3 && counts[1] === 2) { score = 6000 + Math.max(...Object.keys(rankCounts).filter(k => rankCounts[k] === 3).map(Number)); handName = 'Full House'; } else if (isFlush) { score = 5000 + Math.max(...ranks); handName = 'Flush'; } else if (isStraight) { score = 4000 + straightHigh; handName = 'Straight'; } else if (counts[0] === 3) { score = 3000 + Math.max(...Object.keys(rankCounts).filter(k => rankCounts[k] === 3).map(Number)); handName = 'Three of a Kind'; } else if (counts[0] === 2 && counts[1] === 2) { const pairs = Object.keys(rankCounts).filter(k => rankCounts[k] === 2).map(Number).sort((a,b) => b-a); score = 2000 + pairs[0] * 20 + pairs[1]; handName = 'Two Pair'; } else if (counts[0] === 2) { score = 1000 + Math.max(...Object.keys(rankCounts).filter(k => rankCounts[k] === 2).map(Number)); handName = 'One Pair'; } else { score = Math.max(...ranks); handName = 'High Car Poker Trainer Pro

♠️ Poker Trainer Pro ♠️

Master No-Limit Texas Hold'em

Tournament
Sit & Go
Players Left
9
Blinds
25/50
Next Blind
5 hands
Hand #
1
$0
POT
🎯 Post-Game Analysis
Tight Aggressive
You played a solid, selective style with well-timed aggression.
22%
VPIP (Hands Played)
18%
PFR (Pre-flop Raise)
2.1
Aggression Factor
65%
Showdowns Won
Final Position
Tournament Finish
0
Total Hands

💡 Improvement Tips

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