public void Start() { Func <Action, bool> conductBettingRoungAndReportIfRoundIsOver = currentRound => { currentRound(); return(Ready.Count(x => x) < 2); }; Action setReadyPlayers = () => { for (int i = 0; i < 10; i++) { Ready[i] = PlayerBySeat.ContainsKey(i); } }; setReadyPlayers(); SetInitialRoles(); while (true) { CheckWinner(); if (Count < 2) { break; } Deck.Shuffle(); TableCards.Clear(); setReadyPlayers(); // Цикл раундов пока есть хотя бы 2 игрока if (conductBettingRoungAndReportIfRoundIsOver(PreFlop)) { continue; } if (conductBettingRoungAndReportIfRoundIsOver(Flop)) { continue; } if (conductBettingRoungAndReportIfRoundIsOver(Turn)) { continue; } if (conductBettingRoungAndReportIfRoundIsOver(River)) { continue; } ShowDown(); Update(); } }
public void CheckWinner() { if (Ready.Count(x => x) == 1) { // Определение кто это for (int i = 0; i < 10; i++) { if (Ready[i]) { Count = 0; Ready[i] = false; CollectMoney(); RewardWinner(i); CurrentBank = 0; return; } } } }