Beispiel #1
0
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            for (int i = handLines.Length - 1; i >= 0; i--)
            {
                string handLine = handLines[i];

                if (string.IsNullOrWhiteSpace(handLine))
                {
                    continue;
                }

                if (handLine.StartsWith("Dealer:"))
                {
                    break;
                }

                if (handLine.StartsWith("River ") || handLine.StartsWith("Flop ") || handLine.StartsWith("Turn "))
                {
                    int    firstSpaceIndex = handLine.IndexOf(' ');
                    string board           = handLine.Substring(firstSpaceIndex, handLine.Length - firstSpaceIndex);

                    return(BoardCards.FromCards(board.Replace(" ", "").Replace("-", "")));
                }
            }

            return(BoardCards.ForPreflop());
        }
Beispiel #2
0
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            //<ACTION TYPE="HAND_BOARD" VALUE="BOARD_RIVER" POT="3.64">
            //<CARD LINK="30"></CARD>
            //<CARD LINK="35"></CARD>
            //<CARD LINK="20"></CARD>
            //<CARD LINK="8"></CARD>
            //<CARD LINK="44"></CARD></ACTION>
            BoardCards board = BoardCards.ForPreflop();

            for (int i = handLines.Length - 1; i > 1; i--)
            {
                string Line = handLines[i];
                if (Line[1] == 'A' && Line[14] == 'H' && Line[20] == 'O')
                {
                    const int maxCards = 5;
                    for (int cardIndex = i + 1; cardIndex <= i + maxCards; cardIndex++)
                    {
                        if (handLines[cardIndex][1] != 'C')
                        {
                            break;
                        }
                        board.AddCard(ParseCard(handLines[cardIndex]));
                    }
                    break;
                }
            }
            return(board);
        }
Beispiel #3
0
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            // Expect the end of the hand to have something like this:

            /**** SUMMARY ***
             * Total pot $7.75 | Rake $0.35
             * Board: [9h Ts 8h 6c]
             * Seat 1: hockenspit50 didn't bet (folded)
             * Seat 2: drc40 folded on the Turn
             * Seat 3: oggie the fox didn't bet (folded)
             * Seat 4: diknek (button) collected ($7.40), mucked
             * Seat 5: Naturalblow (small blind) folded before the Flop
             * Seat 6: BeerMySole (big blind) folded before the Flop*/

            for (int lineNumber = handLines.Length - 2; lineNumber >= 0; lineNumber--)
            {
                string line = handLines[lineNumber];
                if (line[0] == '*')
                {
                    return(BoardCards.ForPreflop());
                }

                if (line[0] != 'B')
                {
                    continue;
                }

                return(ParseBoard(line));
            }

            throw new CardException(string.Empty, "Read through hand backwards and didn't find a board or summary.");
        }
Beispiel #4
0
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            // Expect the end of the hand to have something like this:
            //------ Summary ------
            //Pot: 80. Rake 2
            //Board: [3d 6h 2c Ah]

            BoardCards boardCards = BoardCards.ForPreflop();

            for (int lineNumber = handLines.Length - 4; lineNumber >= 0; lineNumber--)
            {
                string line = handLines[lineNumber];
                if (line[0] == '-')
                {
                    return(boardCards);
                }

                if (line[0] != 'B')
                {
                    continue;
                }

                const int firstSquareBracketEnd = 8;
                int       lastSquareBracket     = line.Length - 1;

                return(BoardCards.FromCards(line.Substring(firstSquareBracketEnd, lastSquareBracket - firstSquareBracketEnd).Replace("10", "T")));
            }

            throw new CardException(string.Empty, "Read through hand backwards and didn't find a board or summary.");
        }
        /// <summary>
        /// Parses community cards
        /// </summary>
        /// <param name="handLines">Lines of hand history to parse</param>
        /// <returns>Community cards</returns>
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            var boardCards = BoardCards.ForPreflop();

            for (var i = handLines.Length - 1; i > 0; i--)
            {
                if (handLines[i].StartsWith("Board: ", StringComparison.OrdinalIgnoreCase))
                {
                    var cardText = handLines[i].TakeBetween("[", "]", true);

                    if (string.IsNullOrEmpty(cardText))
                    {
                        throw new CardException(handLines[i], "Could not parse community cards.");
                    }

                    boardCards.AddCards(BoardCards.FromCards(cardText));
                }
                else if (handLines[i].StartsWith("***", StringComparison.Ordinal))
                {
                    break;
                }
            }

            return(boardCards);
        }
Beispiel #6
0
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            // Expect the end of the hand to have something like this:
            //*** SUMMARY ***
            //Total pot $90 | Rake $2.80
            //Board [4s 7d Ad]
            //Seat 4: TopKat5757 (small blind) folded before Flop
            //Seat 5: Masic.Almir (big blind) folded before Flop

            BoardCards boardCards = BoardCards.ForPreflop();

            for (int lineNumber = handLines.Length - 2; lineNumber >= 0; lineNumber--)
            {
                string line = handLines[lineNumber];
                if (line[0] == '*')
                {
                    return(boardCards);
                }

                if (line[0] != 'B')
                {
                    continue;
                }

                int firstSquareBracket = 6;
                int lastSquareBracket  = line.Length - 1;

                return
                    (BoardCards.FromCards(line.Substring(firstSquareBracket + 1, lastSquareBracket - (firstSquareBracket + 1))));
            }

            throw new CardException(string.Empty, "Read through hand backwards and didn't find a board or summary.");
        }
        public HandHistory(GameDescriptor gameDescription) : base()
        {
            HandActions = new List <HandAction>();
            Players     = new PlayerList();

            ComumnityCards  = BoardCards.ForPreflop();
            GameDescription = gameDescription;
        }
Beispiel #8
0
 public void ParseCommunityCards_Preflop()
 {
     if (!testPreflop)
     {
         return;
     }
     TestBoard(BoardCards.ForPreflop());
 }
        protected override BoardCards ParseCommunityCards(List <string> summary)
        {
            var board = summary[1];

            if (!(board.StartsWithFast("Board [") && board.EndsWith(']')))
            {
                return(BoardCards.ForPreflop());
            }
            board = board.SubstringBetween(7, board.Length - 1);
            return(BoardCards.FromCards(board));
        }
Beispiel #10
0
        protected override BoardCards ParseCommunityCards(JObject JSON)
        {
            var handJSON    = JSON["history"][0];
            var actionsJSON = handJSON["action"];

            var lastBoardJSON = actionsJSON.LastOrDefault(p => p["type"].ToString() == "HAND_BOARD");

            if (lastBoardJSON == null)
            {
                return(BoardCards.ForPreflop());
            }

            var cards = lastBoardJSON["card"].Select(ParseCard);

            return(BoardCards.FromCards(cards.ToArray()));
        }
Beispiel #11
0
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            XDocument document    = GetXDocumentFromLines(handLines);
            XElement  gameElement = GetGameElementFromXDocument(document);
            IEnumerable <XElement> cardElements = gameElement.Elements("round").Elements("cards");

            //Find the last <card> element with type="community". This will have our board card list as its cards attribute value
            XElement lastCardElement = cardElements.LastOrDefault(element => element.Attribute("type").Value[0] == 'C');

            if (lastCardElement == null)
            {
                return(BoardCards.ForPreflop());
            }

            string boardCards = lastCardElement.Attribute("cards").Value;

            return(BoardCards.FromCards(boardCards));
        }
        protected BoardCards ParseAllCardsFromText(string text)
        {
            List <Card> commCards = new List <Card>();

            var cards = Regex.Match(text, CardRegex);

            if (!cards.Success)
            {
                return(BoardCards.ForPreflop());
            }

            do
            {
                commCards.Add(Card.Parse(cards.Value));
                cards = cards.NextMatch();
            } while (cards.Success);

            return(BoardCards.FromCards(commCards.ToArray()));
        }
Beispiel #13
0
        /// <summary>
        /// Parses community cards
        /// </summary>
        /// <param name="handLines">Lines of hand history to parse</param>
        /// <returns>Community cards</returns>
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            var boardCards = BoardCards.ForPreflop();

            foreach (var handLine in handLines)
            {
                if (handLine.StartsWith("*** FLOP *** ", StringComparison.OrdinalIgnoreCase) ||
                    handLine.StartsWith("*** TURN *** ", StringComparison.OrdinalIgnoreCase) ||
                    handLine.StartsWith("*** RIVER *** ", StringComparison.OrdinalIgnoreCase))
                {
                    var cardText = handLine.TakeBetween("[", "]", true);

                    if (string.IsNullOrEmpty(cardText))
                    {
                        throw new CardException(handLine, "Could not parse community cards.");
                    }

                    boardCards.AddCards(BoardCards.FromCards(cardText));
                }
            }

            return(boardCards);
        }
Beispiel #14
0
        protected override BoardCards ParseCommunityCards(string[] handLines)
        {
            // Expected board:
            // "** Dealing Flop ** [ Tc, 7c, Qc ]"
            // "** Dealing Turn ** [ Jc ]"
            // "** Dealing River ** [ 4h ]"

            string     cards      = "";
            BoardCards boardCards = BoardCards.ForPreflop();

            for (int lineNumber = 1; lineNumber < handLines.Length; lineNumber++)
            {
                string line = handLines[lineNumber];
                if (line[0] == '*' && line[line.Length - 1] == ']')
                {
                    int cardsStartIndex = line.IndexOf('[') + 2;
                    int cardsEndIndex   = line.IndexOf(']', cardsStartIndex);
                    cards += line.Substring(cardsStartIndex, cardsEndIndex - cardsStartIndex);
                }
            }

            return(BoardCards.FromCards(cards));
        }
 public void ParseCommunityCards_Preflop()
 {
     TestBoard(BoardCards.ForPreflop());
 }