示例#1
0
        private HandAction ParseActionFromActionLine(string handLine, Street street, PlayerList playerList, List <HandAction> actions)
        {
            bool AllIn      = false;
            var  actionType = GetActionTypeFromActionLine(handLine);

            decimal value = GetValueFromActionLine(handLine);

            int actionNumber = GetActionNumberFromActionLine(handLine);

            if (actionNumber == -1 || actionType == HandActionType.UNKNOWN)
            {
                return(null);
            }

            int    playerSeat = GetPlayerSeatFromActionLine(handLine);
            string playerName = playerList.First(p => p.SeatNumber == playerSeat).PlayerName;

            if (actionType == HandActionType.ALL_IN)
            {
                AllIn      = true;
                actionType = AllInActionHelper.GetAllInActionType(playerName, value, street, actions);
            }

            return(new HandAction(playerName, actionType, value, street, AllIn, actionNumber));
        }
示例#2
0
        public static HandAction ParseActionFromActionLine(string handLine, Street street, PlayerList playerList, List <HandAction> actions)
        {
            bool AllIn      = false;
            var  actionType = GetActionTypeFromActionLine(handLine);

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

            int actionNumber = GetActionNumberFromActionLine(handLine);

            if (actionNumber == -1)
            {
                return(null);
            }

            decimal value = GetValueFromActionLine(handLine);

            int    playerSeat = GetPlayerSeatFromActionLine(handLine);
            string playerName = playerList.First(p => p.SeatNumber == playerSeat).PlayerName;

            if (actionType == HandActionType.ALL_IN)
            {
                AllIn = true;
                bool BBposted = actions.FirstOrDefault(p => p.HandActionType == HandActionType.BIG_BLIND) != null;
                if (!BBposted)
                {
                    actionType = HandActionType.BIG_BLIND;
                }
                bool SBposted = actions.FirstOrDefault(p => p.HandActionType == HandActionType.SMALL_BLIND) != null;
                if (!SBposted)
                {
                    actionType = HandActionType.SMALL_BLIND;
                }

                if (SBposted && BBposted)
                {
                    actionType = AllInActionHelper.GetAllInActionType(playerName, value, street, actions);
                }
            }

            //Bet may occur during preflop, we need to change that to a raise
            if (street == Street.Preflop && actionType == HandActionType.BET)
            {
                actionType = HandActionType.RAISE;
            }

            return(new HandAction(playerName, actionType, value, street, AllIn, actionNumber));
        }
示例#3
0
        public static HandAction ParseRegularAction(string line, Street currentStreet, PlayerList playerList, List <HandAction> actions, bool PlayerWithSpaces)
        {
            string PlayerName = PlayerWithSpaces ?
                                GetPlayerNameWithSpaces(line, playerList) :
                                GetPlayerNameWithoutSpaces(line);

            int  actionIDIndex = actionPlayerNameStartIndex + PlayerName.Length + 1;
            char actionID      = line[actionIDIndex];

            switch (actionID)
            {
            //Player PersnicketyBeagle folds
            case 'f':
                return(new HandAction(PlayerName, HandActionType.FOLD, 0, currentStreet));

            case 'r':
                return(new HandAction(PlayerName, HandActionType.RAISE, ParseActionAmountAfterPlayer(line), currentStreet));

            //checks or calls
            case 'c':
                //Player butta21 calls (20)
                //Player jayslowplay caps (3.50)
                //Player STOPCRYINGB79 checks
                char actionID2 = line[actionIDIndex + 2];
                if (actionID2 == 'e')
                {
                    return(new HandAction(PlayerName, HandActionType.CHECK, 0, currentStreet));
                }
                else if (actionID2 == 'l')
                {
                    return(new HandAction(PlayerName, HandActionType.CALL, ParseActionAmountAfterPlayer(line), currentStreet));
                }
                else if (actionID2 == 'p')
                {
                    var capAmount     = ParseActionAmountAfterPlayer(line);
                    var capActionType = AllInActionHelper.GetAllInActionType(PlayerName, capAmount, currentStreet, actions);
                    return(new HandAction(PlayerName, capActionType, capAmount, currentStreet, true));
                }
                else
                {
                    throw new NotImplementedException("HandActionType: " + line);
                }

            case 'b':
                if (currentStreet == Street.Preflop)
                {
                    return(new HandAction(PlayerName, HandActionType.RAISE, ParseActionAmountAfterPlayer(line), currentStreet));
                }
                else
                {
                    return(new HandAction(PlayerName, HandActionType.BET, ParseActionAmountAfterPlayer(line), currentStreet));
                }

            //Player PersnicketyBeagle allin (383)
            case 'a':
                var allinAmount     = ParseActionAmountAfterPlayer(line);
                var allinActionType = AllInActionHelper.GetAllInActionType(PlayerName, allinAmount, currentStreet, actions);
                return(new HandAction(PlayerName, allinActionType, allinAmount, currentStreet, true));

            case 'm':    //Player PersnicketyBeagle mucks cards
            case 'i':    //Player ECU7184 is timed out.
                return(null);
            }
            throw new HandActionException(line, "HandActionType: " + line);
        }
        void TestAllInActionHelper(string playerName, decimal amount, Street street, List <HandAction> actions, HandActionType expectedAllInActionType)
        {
            var result = AllInActionHelper.GetAllInActionType(playerName, amount, street, actions);

            Assert.AreEqual(expectedAllInActionType, result);
        }
        private HandAction ParseAction(string Line, Street currentStreet, List <HandAction> actions)
        {
            const int playerHandActionStartIndex = 21;
            const int fixedAmountDistance        = 9;

            char   handActionType = Line[playerHandActionStartIndex];
            int    playerNameStartIndex;
            string playerName;

            switch (handActionType)
            {
            //<ACTION TYPE="ACTION_ALLIN" PLAYER="SAMERRRR" VALUE="15972.51"></ACTION>
            case 'A':
                playerNameStartIndex = playerHandActionStartIndex + 15;
                playerName           = GetActionPlayerName(Line, playerNameStartIndex);
                decimal        amount    = GetActionAmount(Line, playerNameStartIndex + playerName.Length + fixedAmountDistance);
                HandActionType allInType = AllInActionHelper.GetAllInActionType(playerName, amount, currentStreet, actions);
                if (allInType == HandActionType.CALL)
                {
                    amount = AllInActionHelper.GetAdjustedCallAllInAmount(amount, actions.Player(playerName));
                }

                return(new HandAction(playerName, allInType, amount, currentStreet, true));

            //<ACTION TYPE="ACTION_BET" PLAYER="ItalyToast" VALUE="600.00"></ACTION>
            case 'B':
                playerNameStartIndex = playerHandActionStartIndex + 13;
                playerName           = GetActionPlayerName(Line, playerNameStartIndex);
                return(new HandAction(
                           playerName,
                           HandActionType.BET,
                           GetActionAmount(Line, playerNameStartIndex + playerName.Length + fixedAmountDistance),
                           currentStreet
                           ));

            //<ACTION TYPE="ACTION_CHECK" PLAYER="gasmandean"></ACTION>
            //<ACTION TYPE="ACTION_CALL" PLAYER="fatima1975" VALUE="0.04"></ACTION>
            case 'C':
                if (Line[playerHandActionStartIndex + 1] == 'H')
                {
                    playerNameStartIndex = playerHandActionStartIndex + 15;
                    playerName           = GetActionPlayerName(Line, playerNameStartIndex);
                    return(new HandAction(
                               playerName,
                               HandActionType.CHECK,
                               0,
                               currentStreet
                               ));
                }
                else
                {
                    playerNameStartIndex = playerHandActionStartIndex + 14;
                    playerName           = GetActionPlayerName(Line, playerNameStartIndex);
                    return(new HandAction(
                               playerName,
                               HandActionType.CALL,
                               GetActionAmount(Line, playerNameStartIndex + playerName.Length + fixedAmountDistance),
                               currentStreet
                               ));
                }

            //<ACTION TYPE="ACTION_FOLD" PLAYER="Belanak"></ACTION>
            case 'F':
                playerNameStartIndex = playerHandActionStartIndex + 14;
                playerName           = GetActionPlayerName(Line, playerNameStartIndex);
                return(new HandAction(
                           playerName,
                           HandActionType.FOLD,
                           0,
                           currentStreet
                           ));

            //<ACTION TYPE="ACTION_RAISE" PLAYER="ItalyToast" VALUE="400.00"></ACTION>
            case 'R':
                playerNameStartIndex = playerHandActionStartIndex + 15;
                playerName           = GetActionPlayerName(Line, playerNameStartIndex);
                return(new HandAction(
                           playerName,
                           HandActionType.RAISE,
                           GetActionAmount(Line, playerNameStartIndex + playerName.Length + fixedAmountDistance),
                           currentStreet
                           ));

            default:
                throw new ArgumentOutOfRangeException("Unkown hand action: " + handActionType + " - " + Line);
            }
        }