コード例 #1
0
        public override RunItTwice ParseRunItTwice(string[] handLines)
        {
            bool isRunItTwiceHand = false;
            int RITScanIndex = -1;

            for (int i = handLines.Length - 1; i > 0; i--)
            {
                string line = handLines[i];

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

                if (line == "*** SUMMARY 2 ***")
                {
                    RITScanIndex = i;
                    break;
                }
                else
                {
                    //this is not a run it twice hand
                    return null;
                }
            }

            RunItTwice RIT = new RunItTwice();
            //Parsing run it twice board
            for (int i = RITScanIndex; i < handLines.Length; i++)
            {
                string line = handLines[i];

                if (line[0] == 'B')
                {
                    RIT.Board = ParseBoard(line);
                    break;
                }
            }

            //Parsing run it twice showdown actions
            for (int i = RITScanIndex; i > 0; i--)
            {
                string line = handLines[i];

                if (line == "*** SHOW DOWN 2 ***")
                {
                    RITScanIndex = i;
                }
            }

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

                if (line == "*** SUMMARY ***")
                {
                    break;
                }
                int nameEndIndex = line.IndexOf(" wins pot 2 (", StringComparison.Ordinal);
                if (nameEndIndex != -1)
                {
                    string playerName = line.Remove(nameEndIndex);

                    int amountStartIndex = line.IndexOf('(', nameEndIndex) + 2;
                    int amountEndString = line.IndexOf(')', amountStartIndex);

                    string amountString = line.Substring(amountStartIndex, amountEndString - amountStartIndex);
                    decimal amount = decimal.Parse(amountString, NumberFormatInfo);

                    RIT.Actions.Add(new WinningsAction(playerName, HandActionType.WINS, amount, 0));
                }
            }

            return RIT;
        }
コード例 #2
0
        public override RunItTwice ParseRunItTwice(string[] handLines)
        {
            RunItTwice rit = null;
            bool isRunItTwiceHand = false;
            int secondShowDownIndex = 0;
            for (int i = handLines.Length - 1; i > 0; i--)
            {
                string line = handLines[i];

                switch (line[1])
                {
                    //*** SUMMARY ***
                    case '*':
                        if (isRunItTwiceHand)
                        {
                            secondShowDownIndex = i - 1;
                            i = 0;
                            break;
                        }
                        //no run it twice hand
                        return null;

                    //SECOND Board [3d Kd 9h 8h Kc]
                    //run it twice hand found
                    case 'E':
                        isRunItTwiceHand = true;
                        rit = new RunItTwice
                              {
                                  Board = ParseBoard(line, 14, line.Length - 1)
                              };
                        break;
                    default:
                        continue;
                }
            }

            for (int i = secondShowDownIndex; i > 0; i--)
            {
                string line = handLines[i];
                //*** SECOND SHOW DOWN ***
                if (line[0] == '*' && line[line.Length - 1] == '*')
                {
                    secondShowDownIndex = i + 1;
                    break;
                }
            }

            ParseShowDown(handLines, ref rit.Actions, secondShowDownIndex, GameType.Unknown);

            return rit;
        }