Ejemplo n.º 1
0
        static void HandleXmlMatch(StreamReader input, Match xmlStart, List <Song> songList)
        {
            string line     = "";
            Song   songInfo = songList.Last();

            Song.Score scoreInfo = songInfo.Scores.Last();
            Match      xmlInfo, nextEntry;
            bool       xmlEnd = false;

            Scoreboard scoreBoard = new Scoreboard();              // Instantiate the scoreboard

            scoreBoard.Global = new Scoreboard.Category();         // Instantiate the global entry
            Scoreboard.Category boardCategory = scoreBoard.Global; // Set the global entry
            Scoreboard.Entry    scoreEntry;

            songInfo.SongID     = xmlStart.Groups[7].Value; // Set the song ID
            songInfo.UserID     = xmlStart.Groups[1].Value; // Set the user
            songInfo.UserRegion = xmlStart.Groups[2].Value; // Set user region
            songInfo.UserEmail  = xmlStart.Groups[3].Value; // Set user email
            scoreInfo.Mode      = xmlStart.Groups[6].Value; // Set song mode

            songInfo.SetCanPost(xmlStart.Groups[4].Value);  // Set if cheats were detected

            while (!xmlEnd)                                 // While we aren't done parsing the scoreboard
            {
                line = input.ReadLine();                    // Read the next line of scoreboard

                nextEntry = Regex.Match(line, "</scoreboard>");

                if (nextEntry.Success) // Check if we need to change entries
                {
                    if (scoreBoard.Regional != null)
                    {
                        xmlEnd = true;                      // We're done parsing
                        songInfo.AddScoreboard(scoreBoard); // Add the scoreboard to the song
                        break;
                    }

                    if (boardCategory == scoreBoard.Global)
                    {
                        scoreBoard.Friends = new Scoreboard.Category(); // Instantiate the friends entry
                        boardCategory      = scoreBoard.Friends;        // Set the friends entry
                    }
                    else
                    {
                        scoreBoard.Regional = new Scoreboard.Category(); // Instantiate the regional entry
                        boardCategory       = scoreBoard.Regional;       // Set the regional entry
                    }

                    for (int i = 0; i < 2; i++)
                    {
                        line = input.ReadLine();
                        //Console.WriteLine(line);
                    }
                }

                xmlInfo = Regex.Match(line, "<ride userid='(.+)' steamid='(.+)' score='(.+)' charid='(.+)' ridetime='(.+)'>(<comment>(.+)</comment>)?<modename>(.+)</modename><username>(.+)</username>");

                scoreEntry = new Scoreboard.Entry();

                scoreEntry.UserID   = xmlInfo.Groups[1].Value;
                scoreEntry.SteamID  = xmlInfo.Groups[2].Value;
                scoreEntry.Score    = xmlInfo.Groups[3].Value;
                scoreEntry.RideTime = xmlInfo.Groups[5].Value;
                scoreEntry.Mode     = xmlInfo.Groups[8].Value;
                scoreEntry.Username = xmlInfo.Groups[9].Value;

                scoreEntry.Comment = " "; // Instantiate the comment field
                if (!String.IsNullOrEmpty(xmlInfo.Groups[7].Value))
                {
                    scoreEntry.Comment = xmlInfo.Groups[7].Value;
                }

                boardCategory.Entries.Add(scoreEntry);
            }
        }
Ejemplo n.º 2
0
 public void AddScoreboard(Scoreboard _scoreboard)
 {
     this.Scoreboard = _scoreboard;
 }