public void PlayHand(HandHistory handHistory) { #region Hand Setup seats = handHistory.Players; handHistory.HoleCards = new ulong[seats.Length]; handHistory.DealtCards = 0UL; handHistory.Flop = 0UL; handHistory.Turn = 0UL; handHistory.River = 0UL; //Setup the hand history this.history = handHistory; //Create a new map from player names to player chips for the BetManager Dictionary <string, double> namesToChips = new Dictionary <string, double>(); //Create a new list of players for the PlayerManager playerIndices = new CircularList <int>(); playerIndices.Loop = true; //Create a map of player names to their seat numbers //seatNumbers = new Dictionary<string, int>(); for (int i = 0; i < seats.Length; i++) { namesToChips[seats[i].Name] = seats[i].Chips; if (seats[i].SeatNumber == history.Button) { buttonIdx = i; utgIdx = (i + 1) % seats.Length; } } for (int i = (buttonIdx + 1) % seats.Length; playerIndices.Count < seats.Length;) { playerIndices.Add(i); i = (i + 1) % seats.Length; } betManager = new BetManager(namesToChips, history.BettingStructure, history.AllBlinds, history.Ante); potManager = new PotManager(seats); #endregion if (betManager.In > 1) { GetBlinds(); DealHoleCards(); } history.CurrentRound = Round.Preflop; if (betManager.CanStillBet > 1) { GetBets(history.PreflopActions); } if (betManager.In <= 1) { payWinners(); return; } DealFlop(); history.CurrentRound = Round.Flop; if (betManager.CanStillBet > 1) { GetBets(history.FlopActions); } if (betManager.In <= 1) { payWinners(); return; } DealTurn(); history.CurrentRound = Round.Turn; if (betManager.CanStillBet > 1) { GetBets(history.TurnActions); } if (betManager.In <= 1) { payWinners(); return; } DealRiver(); history.CurrentRound = Round.River; if (betManager.CanStillBet > 1) { GetBets(history.RiverActions); } if (betManager.In <= 1) { payWinners(); return; } payWinners(); history.ShowDown = true; history.CurrentRound = Round.Over; }
public void PlayHand(HandHistory handHistory, CachedHand cachedHand) { cache = cachedHand; PlayHand(handHistory); }