Exemplo n.º 1
0
        private static HandActionType ParseHandActionType(NoticePlayerAction noticePlayerAction)
        {
            switch (noticePlayerAction.ActionType)
            {
            case ActionType.Allin:
                return(HandActionType.ALL_IN);

            case ActionType.Bet:
                return(HandActionType.BET);

            case ActionType.Call:
            case ActionType.CallMuck:
                return(HandActionType.CALL);

            case ActionType.Check:
                return(HandActionType.CHECK);

            case ActionType.Fold:
                return(HandActionType.FOLD);

            case ActionType.Post:
                return(HandActionType.POSTS);

            case ActionType.Raise:
                return(HandActionType.RAISE);

            default:
                return(HandActionType.UNKNOWN);
            }
        }
Exemplo n.º 2
0
        private void ProcessNoticePlayerAction(NoticePlayerAction noticePlayerAction, HandHistory handHistory)
        {
            var actionType = ParseHandActionType(noticePlayerAction);

            if (actionType == HandActionType.UNKNOWN)
            {
                return;
            }

            HandAction action;

            if (actionType == HandActionType.ALL_IN)
            {
                var player = GetPlayer(handHistory, noticePlayerAction.LastActionSeatId + 1);

                var playerPutInPot = Math.Abs(handHistory.HandActions.Where(x => x.PlayerName == player.PlayerName).Sum(x => x.Amount));
                var allInAmount    = player.StartingStack - playerPutInPot;

                action = new AllInAction(player.PlayerName,
                                         allInAmount,
                                         handHistory.CommunityCards.Street, false);
            }
            else if (actionType == HandActionType.RAISE ||
                     (actionType == HandActionType.BET && handHistory.CommunityCards.Street == Street.Preflop))
            {
                if (actionType == HandActionType.BET)
                {
                    actionType = HandActionType.RAISE;
                }

                var player = GetPlayer(handHistory, noticePlayerAction.LastActionSeatId + 1);

                var playerPutInPot = Math.Abs(handHistory.HandActions
                                              .Where(x => x.Street == handHistory.CommunityCards.Street && x.PlayerName == player.PlayerName && x.HandActionType != HandActionType.ANTE)
                                              .Sum(x => x.Amount));

                action = new HandAction(GetPlayerName(handHistory, noticePlayerAction.LastActionSeatId + 1),
                                        actionType,
                                        noticePlayerAction.Amount - playerPutInPot,
                                        handHistory.CommunityCards.Street);
            }
            else
            {
                action = new HandAction(GetPlayerName(handHistory, noticePlayerAction.LastActionSeatId + 1),
                                        actionType,
                                        noticePlayerAction.Amount,
                                        handHistory.CommunityCards.Street);
            }

            handHistory.HandActions.Add(action);
        }