private string GetRoundCards(IEnumerable <Command> roundCommands, HandPhaseEnum handPhase) { var communityCards = roundCommands.FilterCommands <CommunityCard>(CommandCodeEnum.CommunityCard).ToArray(); var expectedCardsAmount = (handPhase == HandPhaseEnum.PostFlop) ? 3 : 1; if (communityCards.Length != expectedCardsAmount) { throw new Exception(string.Format("Invalid community cards. Expected amount of cards: {0}, but was {1} [HandNumber = {2}, Phase = {3}]", expectedCardsAmount, communityCards.Length, handModel.HandNumber, handPhase)); } var cards = string.Join(PokerConfiguration.CardSeparator, communityCards.Select(x => x.Card).ToArray()); var convertedCards = converter.Convert(cards); return(convertedCards); }
/// <summary> /// Get round actions /// </summary> /// <param name="roundCommands">Round commands</param> /// <param name="roundDeltaStack">Round delta stacks</param> /// <param name="handPhase">Phase of hand</param> /// <returns>Round actions</returns> private List <Action> GetRoundActions(IEnumerable <Command> roundCommands, Dictionary <int, Queue <decimal> > roundDeltaStack, HandPhaseEnum handPhase) { if (roundCommands == null) { throw new ArgumentNullException("roundCommands"); } if (roundDeltaStack == null) { throw new ArgumentNullException("roundDeltaStack"); } var actions = new List <Action>(); // take all player action var playerActions = roundCommands.FilterCommands <PlayerAction>(CommandCodeEnum.PlayerAction); var invalidPlayerAction = playerActions.FirstOrDefault(x => !tableModel.PlayersOnTable.ContainsKey(x.SeatNumber)); if (invalidPlayerAction != null) { throw new Exception(string.Format("Invalid {0} commands [Action]. Couldn't find player's name on seat. [HandNumber = {1}, Seat = {2}]", handPhase.ToString().ToLower(), handModel.HandNumber, invalidPlayerAction.SeatNumber)); } foreach (var playerAction in playerActions) { if (!roundDeltaStack.ContainsKey(playerAction.SeatNumber) || roundDeltaStack[playerAction.SeatNumber].Count < 1) { throw new Exception(string.Format("Invalid {0} commands [Action, Stacks]. Couldn't find stack for player action [HandNumber = {1}, Seat = {2}, Action = {3}]", handPhase.ToString().ToLower(), handModel.HandNumber, playerAction.SeatNumber, playerAction.PlayerActionEnum)); } var sum = -((handModel.CashOrTournament == CashOrTournament.Tournament) ? roundDeltaStack[playerAction.SeatNumber].Dequeue() * 100 : roundDeltaStack[playerAction.SeatNumber].Dequeue()); var actionType = GetActionType(playerAction.PlayerActionEnum, sum); var action = new Action { No = actionNo++, Player = tableModel.PlayersOnTable[playerAction.SeatNumber], Sum = sum, SeatNumber = playerAction.SeatNumber, Type = actionType }; actions.Add(action); } return(actions); }
public HandPhaseV2() { this.HandPhaseID = -1; this.HandPhaseEnum = HandPhaseEnum.NotEnoughPlayers; }