protected override int ParseDealerPosition(List <string> header)
        {
            var line   = header[1];
            var dealer = FastInt.Parse(line, line.IndexOf('#') + 1);

            return(dealer);
        }
        static bool IsPlayerLineDealer(string playerLine)
        {
            int dealerOffset = playerLine.IndexOfFast(" d") + 9;
            int dealerValue  = FastInt.Parse(playerLine[dealerOffset]);

            return(dealerValue == 1);
        }
        private static int ParsePlayerCount(string[] handLines)
        {
            int start     = GetHandStartIndex(handLines);
            int seatCount = FastInt.Parse(NumPlayersRegex.Match(handLines[start + 4]).Value);

            return(seatCount);
        }
        protected override SeatType ParseSeatType(List <string> header)
        {
            var line       = header[1];
            var maxPlayers = FastInt.Parse(line, line.IndexOf(' '));

            return(SeatType.FromMaxPlayers(maxPlayers));
        }
Ejemplo n.º 5
0
        protected override int ParseDealerPosition(string[] handLines)
        {
            // Expect the 6th line to look like this:
            // "Seat 4 is the button"

            const int startIndex = 5;

            return(FastInt.Parse(handLines[3], startIndex));
        }
Ejemplo n.º 6
0
        protected override int ParseDealerPosition(string[] handLines)
        {
            // Expect the 2nd line to look like this:
            // Table 'Alemannia IV' 6-max Seat #2 is the button

            int startIndex = handLines[1].LastIndexOf('#') + 1;

            return(FastInt.Parse(handLines[1], startIndex));
        }
Ejemplo n.º 7
0
        static int GetActionNumberFromActionLine(string actionLine)
        {
            int sequenceStartIndex = actionLine.IndexOfFast(" seq=", 7);

            if (sequenceStartIndex == -1)
            {
                return(-1);
            }

            return(FastInt.Parse(actionLine, sequenceStartIndex));
        }
        static Player ParseSeatLine(string line, int stackEndIndex, bool sitout)
        {
            bool sitOut = line.EndsWith('t');

            int seat         = FastInt.Parse(line, 5);
            int nameEndIndex = line.LastIndexOfFast(" (", stackEndIndex);
            var name         = line.SubstringBetween(line.IndexOf(':') + 2, nameEndIndex);
            var stack        = line.SubstringBetween(nameEndIndex + 2, stackEndIndex);

            return(new Player(name, stack.ParseAmount(), seat)
            {
                IsSittingOut = sitOut,
            });
        }
Ejemplo n.º 9
0
        protected override SeatType ParseSeatType(string[] handLines)
        {
            // line 5 looks like :
            // "Total number of players : 2/6 "
            int maxPlayerIndex = handLines[4].LastIndexOf('/') + 1;

            // 2-max, 6-max or 9-max
            int maxPlayers = FastInt.Parse(handLines[4][maxPlayerIndex]);

            // can't have 1max so must be 10max
            if (maxPlayers == 1)
            {
                maxPlayers = 10;
            }

            return(SeatType.FromMaxPlayers(maxPlayers));
        }
Ejemplo n.º 10
0
        private static DateTime ParseDateFromText(string dateText)
        {
            var splittedDate = dateText.Split(' ');

            if (splittedDate.Length < 2)
            {
                throw new ParseHandDateException(dateText, "Date is in wrong format.");
            }

            var dateParts = splittedDate[0].Split('/');
            var timeParts = splittedDate[1].Split(':');

            var dateTime = new DateTime(FastInt.Parse(dateParts[0]), FastInt.Parse(dateParts[1]), FastInt.Parse(dateParts[2]),
                                        FastInt.Parse(timeParts[0]), FastInt.Parse(timeParts[1]), FastInt.Parse(timeParts[2]));

            return(DateTime.SpecifyKind(dateTime, DateTimeKind.Utc));
        }
Ejemplo n.º 11
0
        protected override SeatType ParseSeatType(string[] handLines)
        {
            // line two looks like :
            // Table 'Alcor V' 6-max Seat #4 is the button
            int secondDash = handLines[1].LastIndexOf('\'');

            // 2-max, 6-max or 9-max
            int maxPlayers = FastInt.Parse(handLines[1][secondDash + 2]);

            // can't have 1max so must be 10max
            if (maxPlayers == 1)
            {
                maxPlayers = 10;
            }

            return(SeatType.FromMaxPlayers(maxPlayers));
        }
Ejemplo n.º 12
0
        protected override SeatType ParseSeatType(List <string> header)
        {
            // line 5 looks like :
            // "Total number of players : 2/6 "
            var line           = header[4];
            int maxPlayerIndex = line.LastIndexOf('/') + 1;

            // 2-max, 6-max or 9-max
            int maxPlayers = FastInt.Parse(line[maxPlayerIndex]);

            // can't have 1max so must be 10max
            if (maxPlayers == 1)
            {
                maxPlayers = 10;
            }

            return(SeatType.FromMaxPlayers(maxPlayers));
        }
Ejemplo n.º 13
0
        protected override DateTime ParseDateUtc(string[] handLines)
        {
            // Full Tilt Poker Game #26862429938: Table Adornment (6 max, shallow) - $0.50/$1 - No Limit Hold'em - 16:07:17 ET - 2010/12/31

            string [] split      = handLines[0].Split('-');
            string    timeString = split[3]; // ' 16:07:17 ET '
            string    dateString = split[4]; //  ' 2010/12/31 '

            int year  = FastInt.Parse(dateString.Substring(1, 4));
            int month = FastInt.Parse(dateString.Substring(6, 2));
            int day   = FastInt.Parse(dateString.Substring(9, 2));

            int hour   = FastInt.Parse(timeString.Substring(1, 2));
            int minute = FastInt.Parse(timeString.Substring(4, 2));
            int second = FastInt.Parse(timeString.Substring(7, 2));

            DateTime dateTime  = new DateTime(year, month, day, hour, minute, second);
            DateTime converted = TimeZoneInfo.ConvertTimeToUtc(dateTime, TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time"));

            return(converted);
        }
Ejemplo n.º 14
0
        private int GetSeatNumberFromPlayerLine(string playerLine)
        {
            string seatNumberString = GetAttribute(playerLine, " num=\"");

            return(FastInt.Parse(seatNumberString));
        }
Ejemplo n.º 15
0
        protected override PlayerList ParsePlayers(string[] handLines)
        {
            PlayerList playerList = new PlayerList();

            int lastLineRead = -1;

            // We start on line index 2 as first 2 lines are table and limit info.
            for (int lineNumber = 2; lineNumber < handLines.Length - 1; lineNumber++)
            {
                string line = handLines[lineNumber];

                char startChar = line[0];
                char endChar   = line[line.Length - 1];

                //Seat 1: thaiJhonny ($16.08 in chips)
                if (endChar != ')')
                {
                    lastLineRead = lineNumber;
                    break;
                }

                // seat info expected in format:
                //Seat 1: thaiJhonny ($16.08 in chips)
                const int seatNumberStartIndex = 4;
                int       spaceIndex           = line.IndexOf(' ', seatNumberStartIndex);
                int       colonIndex           = line.IndexOf(':', spaceIndex + 1);
                int       seatNumber           = FastInt.Parse(line, spaceIndex + 1);

                // we need to find the ( before the number. players can have ( in their name so we need to go backwards and skip the last one
                int openParenIndex      = line.LastIndexOf('(');
                int spaceAfterOpenParen = line.IndexOf(' ', openParenIndex); // add 2 so we skip the $ and first # always

                string playerName = line.Substring(colonIndex + 2, (openParenIndex - 1) - (colonIndex + 2));

                string  stackString = line.Substring(openParenIndex + 2, spaceAfterOpenParen - (openParenIndex + 2));
                decimal stack       = decimal.Parse(stackString, System.Globalization.CultureInfo.InvariantCulture);

                playerList.Add(new Player(playerName, stack, seatNumber));
            }

            if (lastLineRead == -1)
            {
                throw new PlayersException(string.Empty, "Didn't break out of the seat reading block.");
            }

            // Looking for the showdown info which looks like this
            //*** SHOW DOWN ***
            //JokerTKD: shows [2s 3s Ah Kh] (HI: a pair of Sixes)
            //DOT19: shows [As 8h Ac Kd] (HI: two pair, Aces and Sixes)
            //DOT19 collected $24.45 from pot
            //No low hand qualified
            //*** SUMMARY ***

            int summaryIndex  = GetSummaryStartIndex(handLines, lastLineRead);
            int showDownIndex = GetShowDownStartIndex(handLines, lastLineRead, summaryIndex);

            //Starting from the bottom to parse faster
            if (showDownIndex != -1)
            {
                for (int lineNumber = showDownIndex + 1; lineNumber < summaryIndex; lineNumber++)
                {
                    //jimmyhoo: shows [7h 6h] (a full house, Sevens full of Jacks)
                    //EASSA: mucks hand
                    //jimmyhoo collected $562 from pot
                    string line = handLines[lineNumber];
                    //Skip when player mucks and collects
                    //EASSA: mucks hand
                    char lastChar = line[line.Length - 1];
                    if (lastChar == 'd' || lastChar == 't')
                    {
                        continue;
                    }

                    int lastSquareBracket = line.LastIndexLoopsBackward(']', line.Length - 1);

                    if (lastSquareBracket == -1)
                    {
                        continue;
                    }

                    int firstSquareBracket = line.LastIndexOf('[', lastSquareBracket);

                    // can show single cards:
                    // Zaza5573: shows [Qc]
                    if (line[firstSquareBracket + 3] == ']')
                    {
                        continue;
                    }

                    int colonIndex = line.LastIndexOf(':', firstSquareBracket);

                    if (colonIndex == -1)
                    {
                        // players with [ in their name
                        // [PS_UA]Tarik collected $18.57 from pot
                        continue;
                    }

                    string playerName = line.Substring(0, colonIndex);

                    string cards = line.Substring(firstSquareBracket + 1, lastSquareBracket - (firstSquareBracket + 1));

                    playerList[playerName].HoleCards = HoleCards.FromCards(cards);
                }
            }

            return(playerList);
        }
Ejemplo n.º 16
0
        static int GetPlayerSeatNumber(string line)
        {
            int startIndex = line.IndexOfFast(" num=\"") + 6;

            return(FastInt.Parse(line, startIndex));
        }
Ejemplo n.º 17
0
        protected override PlayerList ParsePlayers(string[] handLines)
        {
            PlayerList playerList = new PlayerList();

            int lastLineRead = -1;

            // We start on line index 5 as first 5 lines are table and limit info.
            const int playerListStart = 5;
            const int playerListEnd   = playerListStart + 10; //there may at most be 10 players

            for (int lineNumber = playerListStart; lineNumber < playerListEnd; lineNumber++)
            {
                string line = handLines[lineNumber];

                char startChar = line[0];
                char endChar   = line[line.Length - 1];

                //Seat 4: thaiJhonny ( $1,404 USD )
                if (endChar != ')')
                {
                    lastLineRead = lineNumber;
                    break;
                }

                // seat info expected in format:
                //Seat 4: thaiJhonny ( $1,404 USD )
                const int seatNumberStartIndex = 5;

                int seatNumber = FastInt.Parse(line, seatNumberStartIndex);

                int playerNameStartIndex = line.IndexOf(':', seatNumberStartIndex) + 2;

                // we need to find the ( before the number. players can have ( in their name so we need to go backwards and skip the last one
                int openParenIndex = line.LastIndexOf('(');

                string  playerName = line.Substring(playerNameStartIndex, openParenIndex - playerNameStartIndex - 1);
                decimal stack      = ParseDecimal(line, openParenIndex + 3);

                playerList.Add(new Player(playerName, stack, seatNumber));
            }

            if (lastLineRead == -1)
            {
                throw new PlayersException(string.Empty, "Didn't break out of the seat reading block.");
            }

            // Looking for the showdown info which looks like this
            // Player1 checks
            // Player2 shows [ 8h, 5h, Ad, 3d ]high card Ace.
            // Player1 shows [ 9h, Qd, Qs, 6d ]three of a kind, Queens.
            // Player1 wins $72 USD from the main pot with three of a kind, Queens.

            for (int lineNumber = handLines.Length - 1; lineNumber > 0; lineNumber--)
            {
                //jimmyhoo: shows [7h 6h] (a full house, Sevens full of Jacks)
                //EASSA: mucks hand
                //jimmyhoo collected $562 from pot
                string line = handLines[lineNumber];
                //Skip when player mucks and collects
                //EASSA: mucks hand
                char lastChar = line[line.Length - 1];
                if (lastChar != '.')
                {
                    break;
                }

                if (!line.Contains(" show"))
                {
                    continue;
                }

                int lastSquareBracket = line.LastIndexOf(']');

                if (lastSquareBracket == -1)
                {
                    continue;
                }

                int firstSquareBracket = line.LastIndexOf('[', lastSquareBracket);

                // can show single cards:
                // Zaza5573: shows [Qc]
                if (line[firstSquareBracket + 3] == ']')
                {
                    continue;
                }

                int nameEndIndex = GetNameEndIndex(line);// line.IndexOf(' ');

                string playerName = line.Remove(nameEndIndex);

                string cards = line.Substring(firstSquareBracket + 1, lastSquareBracket - (firstSquareBracket + 1));

                playerList[playerName].HoleCards = HoleCards.FromCards(cards);
            }

            return(playerList);
        }
Ejemplo n.º 18
0
        protected override PlayerList ParsePlayers(string[] handLines)
        {
            int        currentLine = 1;
            PlayerList plist       = new PlayerList();

            //Parsing playerlist
            for (int i = 0; i < 10; i++)
            {
                //<PLAYER NAME="fatima1975" SEAT="6" AMOUNT="4.27"></PLAYER>
                string Line = handLines[i + 1];
                if (Line[1] != 'P')
                {
                    currentLine = i + 1;
                    break;
                }

                const int playerNameStartIndex = 14;
                int       playerNameEndIndex   = Line.IndexOf('\"', playerNameStartIndex);
                string    playerName           = Line.Substring(playerNameStartIndex, playerNameEndIndex - playerNameStartIndex);
                playerName = WebUtility.HtmlDecode(playerName);

                if (playerName == "UNKNOWN" || playerName == "")
                {
                    continue;
                }

                int seatStartIndex = playerNameEndIndex + 8;
                int seatEndIndex   = Line.IndexOf('\"', seatStartIndex);
                int seatNumber     = FastInt.Parse(Line, seatStartIndex);

                int     stackStartIndex = seatEndIndex + 10;
                int     stackEndIndex   = Line.IndexOf('\"', stackStartIndex);
                decimal stack           = decimal.Parse(Line.Substring(stackStartIndex, stackEndIndex - stackStartIndex), provider);

                var state = GetXMLAttributeValue(Line, "STATE");

                bool sitout = IsSitOutState(state);

                plist.Add(new Player(playerName, stack, seatNumber)
                {
                    IsSittingOut = sitout
                });
            }

            //Parsing dealt cards
            for (int i = currentLine; i < handLines.Length; i++)
            {
                string Line      = handLines[i];
                char   firstChar = Line[1];
                if (firstChar == 'A')
                {
                    //<ACTION TYPE="HAND_BLINDS" PLAYER="ItalyToast" KIND="HAND_BB" VALUE="200.00"></ACTION>
                    //<ACTION TYPE="HAND_DEAL" PLAYER="AllinAnna">
                    const int actionTypeCharIndex = 19;
                    char      actionTypeChar      = Line[actionTypeCharIndex];
                    if (actionTypeChar == 'D')
                    {
                        string playerName = GetPlayerXMLAttributeValue(Line);
                        ParseDealtHand(handLines, i, plist[playerName]);
                    }
                }
                if (firstChar == 'S')
                {
                    currentLine = i + 1;
                    break;
                }
            }

            //Parse Showdown cards
            int showDownIndex = GetShowdownStartIndex(handLines);

            if (showDownIndex != -1)
            {
                Player currentPlayer = null;
                for (int i = showDownIndex; i < handLines.Length; i++)
                {
                    string Line      = handLines[i];
                    char   firstChar = Line[1];

                    //<SHOWDOWN NAME="HAND_SHOWDOWN" POT="895.02" RAKE="15.00" MAINPOT="895.02" LEFTPOT="" RIGHTPOT="" STARTING="Player4">
                    //<RESULT PLAYER="Player4" WIN="0.00" HAND="$(STR_G_WIN_PAIR) $(STR_G_CARDS_DEUCES)" WINCARDS="40 1 0 9 45 ">
                    //<CARD LINK="46"></CARD>
                    //<CARD LINK="1"></CARD>
                    //<CARD LINK="9"></CARD>
                    //<CARD LINK="47"></CARD></RESULT>
                    if (firstChar == 'R')
                    {
                        string playerName = GetPlayerXMLAttributeValue(Line);
                        var    player     = plist[playerName];
                        if (!player.hasHoleCards)
                        {
                            currentPlayer = player;
                        }
                        else
                        {
                            currentPlayer = null;
                        }
                        continue;
                    }

                    //<CARD LINK="9"></CARD>
                    if (firstChar == 'C' && currentPlayer != null)
                    {
                        Card?parsedCard = ParseCard(Line);
                        if (parsedCard.HasValue)
                        {
                            if (currentPlayer.HoleCards == null)
                            {
                                currentPlayer.HoleCards = HoleCards.NoHolecards();
                            }
                            currentPlayer.HoleCards.AddCard(parsedCard.Value);
                        }
                    }
                }
            }

            return(plist);
        }
        static int GetActionNumberFromActionLine(string actionLine)
        {
            int actionStartPos = actionLine.IndexOfFast(" n") + 5;

            return(FastInt.Parse(actionLine, actionStartPos));
        }
Ejemplo n.º 20
0
        protected override PlayerList ParsePlayers(string[] handLines)
        {
            PlayerList playerList = new PlayerList();

            int lastLineRead = -1;

            // We start on line index 5 as first 5 lines are table and limit info.
            const int playerListStart = 5;

            for (int lineNumber = playerListStart; lineNumber < handLines.Length; lineNumber++)
            {
                string line = handLines[lineNumber];

                char lastChar = line[line.Length - 1];

                // leave the loop if we spot a summary/hand start of line
                if (line.StartsWith("** "))
                {
                    break;
                }

                // players can also seat at the table after the seat info, post a big blind and be immediately involved in the hand
                const int seatNumberStartIndex = 5;

                int playerNameStartIndex = line.IndexOf(':', seatNumberStartIndex) + 2;

                // seat info expected in format:
                // Seat 4: thaiJhonny ( $1,404 USD )
                if (playerNameStartIndex > 1 && lastChar == ')' && line.StartsWith("Seat "))
                {
                    int seatNumber = FastInt.Parse(line, seatNumberStartIndex);

                    // we need to find the ( before the number. players can have ( in their name so we need to go backwards and skip the last one
                    int openParenIndex = line.LastIndexOf('(');

                    string  playerName = line.Substring(playerNameStartIndex, openParenIndex - playerNameStartIndex - 1);
                    decimal stack      = ParseDecimal(line, openParenIndex + 3);

                    playerList.Add(new Player(playerName, stack, seatNumber));
                }

                // post blind
                // kpark1996 posts big blind [$1 USD].
                else if (lastChar == '.')
                {
                    // they don't have a known seatNumber
                    int     seatNumber = -1;
                    decimal stack      = 999999.00m; // we make the stacksize very high so bettings can never result in a "negative stack"

                    int nameEndIndex = line.IndexOf(" posts ", StringComparison.Ordinal);
                    if (nameEndIndex == -1)
                    {
                        continue;
                    }

                    string playerName = line.Substring(0, nameEndIndex);

                    // only add if the player is unknown
                    if (!playerList.Any(p => p.PlayerName.Equals(playerName)))
                    {
                        playerList.Add(new Player(playerName, stack, seatNumber));
                    }
                }
            }

            // Looking for the showdown info which looks like this
            // Player1 checks
            // Player2 shows [ 8h, 5h, Ad, 3d ]high card Ace.
            // Player1 shows [ 9h, Qd, Qs, 6d ]three of a kind, Queens.
            // Player1 wins $72 USD from the main pot with three of a kind, Queens.

            for (int lineNumber = handLines.Length - 1; lineNumber > 0; lineNumber--)
            {
                //jimmyhoo: shows [7h 6h] (a full house, Sevens full of Jacks)
                //EASSA: mucks hand
                //jimmyhoo collected $562 from pot
                string line = handLines[lineNumber];
                //Skip when player mucks and collects
                //EASSA: mucks hand
                char lastChar = line[line.Length - 1];
                if (lastChar != '.')
                {
                    break;
                }

                if (!line.Contains(" show"))
                {
                    continue;
                }

                int lastSquareBracket = line.LastIndexOf(']');

                if (lastSquareBracket == -1)
                {
                    continue;
                }

                int firstSquareBracket = line.LastIndexOf('[', lastSquareBracket);

                // can show single cards:
                // Zaza5573: shows [Qc]
                if (line[firstSquareBracket + 3] == ']')
                {
                    continue;
                }

                int nameEndIndex = GetNameEndIndex(line);// line.IndexOf(' ');

                string playerName = line.Remove(nameEndIndex);

                string cards = line.Substring(firstSquareBracket + 1, lastSquareBracket - (firstSquareBracket + 1));

                playerList[playerName].HoleCards = HoleCards.FromCards(cards);
            }

            return(playerList);
        }
        /*
         *  <player seat="3" name="RodriDiaz3" chips="$2.25" dealer="0" win="$0" bet="$0.08" rebuy="0" addon="0" />
         *  <player seat="8" name="Kristi48ru" chips="$6.43" dealer="1" win="$0.23" bet="$0.16" rebuy="0" addon="0" />
         */

        static int GetSeatNumberFromPlayerLine(string playerLine)
        {
            int seatOffset = playerLine.IndexOfFast(" s") + 7;

            return(FastInt.Parse(playerLine, seatOffset));
        }
        static int GetActionTypeFromActionLine(string actionLine)
        {
            int actionStartPos = actionLine.IndexOfFast(" t") + 7;

            return(FastInt.Parse(actionLine, actionStartPos));
        }
Ejemplo n.º 23
0
        protected override PlayerList ParsePlayers(List <string> seats)
        {
            PlayerList playerList = new PlayerList();

            foreach (var line in seats)
            {
                char lastChar = line[line.Length - 1];

                // players can also seat at the table after the seat info, post a big blind and be immediately involved in the hand
                const int seatNumberStartIndex = 5;

                int playerNameStartIndex = line.IndexOf(':', seatNumberStartIndex) + 2;

                // seat info expected in format:
                // Seat 4: thaiJhonny ( $1,404 USD )
                if (playerNameStartIndex > 1 && lastChar == ')' && line.StartsWithFast("Seat "))
                {
                    int seatNumber = FastInt.Parse(line, seatNumberStartIndex);

                    // we need to find the ( before the number. players can have ( in their name so we need to go backwards and skip the last one
                    int openParenIndex = line.LastIndexOf('(');

                    string  playerName = line.Substring(playerNameStartIndex, openParenIndex - playerNameStartIndex - 1);
                    decimal stack      = ParseDecimal(line, openParenIndex + 2);

                    playerList.Add(new Player(playerName, stack, seatNumber));
                }
                else if (line.EndsWithFast(" is sitting out"))
                {
                    string playerName = line.Remove(line.Length - 15); //" is sitting out".Length
                    playerList[playerName].IsSittingOut = true;
                }
            }

            //Parse Dealt to hero
            var heroCardsLine = Lines.Other.FirstOrDefault(isDealtToLine);

            if (heroCardsLine != null)
            {
                int openSquareIndex = heroCardsLine.LastIndexOf('[');

                string    cards     = heroCardsLine.SubstringBetween(openSquareIndex + 3, heroCardsLine.Length - 2);
                HoleCards holeCards = HoleCards.FromCards(cards.Replace(" ", ""));

                string playerName = heroCardsLine.SubstringBetween(9, openSquareIndex - 1);

                Player player = playerList.First(p => p.PlayerName.Equals(playerName));
                player.HoleCards = holeCards;
            }

            // Looking for the showdown info which looks like this
            // Player1 checks
            // Player2 shows [ 8h, 5h, Ad, 3d ]high card Ace.
            // Player1 shows [ 9h, Qd, Qs, 6d ]three of a kind, Queens.
            // Player1 wins $72 USD from the main pot with three of a kind, Queens.
            var actionlines = Lines.Action;

            for (int lineNumber = actionlines.Count - 1; lineNumber > 0; lineNumber--)
            {
                //jimmyhoo: shows [7h 6h] (a full house, Sevens full of Jacks)
                //EASSA: mucks hand
                //jimmyhoo collected $562 from pot
                string line = actionlines[lineNumber];
                //Skip when player mucks and collects
                //EASSA: mucks hand
                char lastChar = line[line.Length - 1];

                if (lastChar != '.')
                {
                    break;
                }
                if (!line.Contains(" show"))
                {
                    continue;
                }

                int lastSquareBracket = line.LastIndexOf(']');
                if (lastSquareBracket == -1)
                {
                    continue;
                }

                int firstSquareBracket = line.LastIndexOf('[', lastSquareBracket);

                // can show single cards:
                // Zaza5573: shows [Qc]
                if (lastSquareBracket - firstSquareBracket <= 3)
                {
                    continue;
                }

                int nameEndIndex = line.IndexOfFast(" doesn't show [ ");
                if (nameEndIndex == -1)
                {
                    nameEndIndex = line.IndexOfFast(" shows [ ");
                }

                string playerName = line.Remove(nameEndIndex);
                string cards      = line.SubstringBetween(firstSquareBracket + 1, lastSquareBracket);

                playerList[playerName].HoleCards = HoleCards.FromCards(cards);
            }

            return(playerList);
        }
Ejemplo n.º 24
0
        static int GetPlayerSeatFromActionLine(string actionLine)
        {
            int seatStartIndex = actionLine.IndexOfFast(" seat=\"") + 7;

            return(FastInt.Parse(actionLine, seatStartIndex));
        }
Ejemplo n.º 25
0
        static int GetPlayerSeatFromActionLine(string actionLine)
        {
            string seat = GetAttribute(actionLine, " seat=\"");

            return(FastInt.Parse(seat));
        }
        protected override PlayerList ParsePlayers(List <string> seats)
        {
            PlayerList playerList = new PlayerList();

            foreach (var line in seats)
            {
                if (line.EndsWith('n'))
                {
                    int seat         = FastInt.Parse(line, 5);
                    int nameEndIndex = line.Length - 42;//" will be allowed to play after the button".Length
                    var name         = line.SubstringBetween(line.IndexOf(':') + 2, nameEndIndex);
                    playerList.Add(new Player(name, 0, seat)
                    {
                        IsSittingOut = true,
                    });
                }
                else if (line.EndsWith('d'))                  //<playername> waits for big blind
                {
                    var name = line.Remove(line.Length - 20); //" waits for big blind".Length
                    playerList[name].IsSittingOut = true;
                }
                else
                {
                    bool sitOut = line.EndsWith('t');
                    if (sitOut && !line.StartsWithFast("Seat"))
                    {
                        var name = line.Remove(line.Length - 9);
                        playerList[name].IsSittingOut = true;
                    }
                    else
                    {
                        var stackEndIndex = sitOut ? line.Length - 16 : line.Length - 1;
                        playerList.Add(ParseSeatLine(line, stackEndIndex, sitOut));
                    }
                }
            }

            //Parse Shows
            for (int i = Lines.Action.Count - 1; i > 0; i--)
            {
                var line     = Lines.Action[i];
                var lastchar = line[line.Length - 1];
                if (lastchar == '*')
                {
                    break;
                }
                if (lastchar != ')')
                {
                    continue;
                }

                var showIndex = line.LastIndexOfFast(" shows [");
                if (showIndex == -1)
                {
                    continue;
                }

                var name  = line.Remove(showIndex);
                var cards = line.SubstringBetween(showIndex + 8, line.IndexOf(']', showIndex));

                playerList[name].HoleCards = HoleCards.FromCards(cards);
            }

            //Parse Dealt to
            foreach (var line in Lines.Other.Where(isDealtToLine))//Dealt to <playername> [Ad Ad Kh Kd]
            {
                var cardStartIndex = line.LastIndexOf('[');
                var name           = line.SubstringBetween(9, cardStartIndex - 1);
                var cards          = line.SubstringBetween(cardStartIndex + 1, line.Length - 1);

                playerList[name].HoleCards = HoleCards.FromCards(cards);
            }

            //Parse Mucks
            foreach (var line in Lines.Summary.Where(line => line[0] == 'S' && line.EndsWith(']') && line.Contains(" mucked [")))
            {
                var muck = SummaryMuckRegex.Match(line);

                playerList[muck.Groups[1].Value].HoleCards = HoleCards.FromCards(muck.Groups[3].Value);
            }

            return(playerList);
        }
Ejemplo n.º 27
0
        /// <summary>
        /// Parses date (UTC) from hand history lines
        /// </summary>
        /// <param name="handLines">Lines of hand history to parse</param>
        /// <returns>Date and time of hand</returns>
        protected override DateTime ParseDateUtc(string[] handLines)
        {
            // possible formats:
            // 2018/04/18 - 15:53:10
            // 2018-04-18 - 15-53-10
            // 2018.04.18 - 15/53/10

            var dateIndex = handLines[0].LastIndexOf("-- ", StringComparison.OrdinalIgnoreCase);

            if (dateIndex < 0)
            {
                throw new ParseHandDateException(handLines[0], "Date couldn't be parsed.");
            }

            var dateString = handLines[0].Substring(dateIndex + 3).Trim();

            var splittedDate = dateString.Split(new[] { " - " }, StringSplitOptions.None);

            if (splittedDate.Length != 2)
            {
                throw new ParseHandDateException(handLines[0], "Date has wrong format.");
            }

            string[] dateParts;

            if (splittedDate[0].Contains("/"))
            {
                dateParts = splittedDate[0].Split('/');
            }
            else if (splittedDate[0].Contains("-"))
            {
                dateParts = splittedDate[0].Split('-');
            }
            else if (splittedDate[0].Contains("."))
            {
                dateParts = splittedDate[0].Split('.');
            }
            else
            {
                throw new ParseHandDateException(handLines[0], "Date part is in wrong format.");
            }

            string[] timeParts;

            if (splittedDate[1].Contains(":"))
            {
                timeParts = splittedDate[1].Split(':');
            }
            else if (splittedDate[1].Contains("-"))
            {
                timeParts = splittedDate[1].Split('-');
            }
            else if (splittedDate[1].Contains("/"))
            {
                timeParts = splittedDate[1].Split('/');
            }
            else
            {
                throw new ParseHandDateException(handLines[0], "Time part is in wrong format.");
            }

            var dateTime = new DateTime(FastInt.Parse(dateParts[0]), FastInt.Parse(dateParts[1]), FastInt.Parse(dateParts[2]),
                                        FastInt.Parse(timeParts[0]), FastInt.Parse(timeParts[1]), FastInt.Parse(timeParts[2]));

            var dateTimeUtc = TimeZoneInfo.ConvertTimeToUtc(dateTime);

            return(DateTime.SpecifyKind(dateTimeUtc, DateTimeKind.Utc));
        }
Ejemplo n.º 28
0
 protected override int ParseDealerPosition(List <string> header)
 {
     // Expect the 6th line to look like this:
     // "Seat 4 is the button"
     return(FastInt.Parse(header[3], 5));
 }