private void EndPhase() { // Clean up the pots CleanUpPots(); ResetChecks(); if (ActivePlayers.Length > 0) { switch (CurrentPhase) { // Ending the draw phase, moving to flop case Phase.Draw: if (ActivePlayers.Length > 1) { CurrentPhase = CurrentPhase + 1; Deck.Draw(); Table.Add(Deck.Draw()); Table.Add(Deck.Draw()); Table.Add(Deck.Draw()); ReportCards(); CheckStatuses(); } else { EndGame(); } break; // Ending the flop/turn phase, moving to turn case Phase.Flop: case Phase.Turn: if (ActivePlayers.Length > 1) { CurrentPhase = CurrentPhase + 1; DrawNext(); CheckStatuses(); } else { EndGame(); } break; // Ending the river phase, moving to gameend case Phase.River: EndGame(); break; } } else { NotEnoughPlayers(); } if (CurrentPhase != Phase.Over) { // If there are still any active players who are not allin. if (ActivePlayers.Any(x => !x.Allin)) { // Set next active player to the next player after the dealer. CurrentPlayerIndex = NextActivePlayerIndex(CurrentDealerIndex); } else { // Go through the rest of the phases. EndPhase(); } } }