Beispiel #1
0
        public static ChallengeSongScore ParseFromElement(HtmlNode element)
        {
            ChallengeSongScore score = new ChallengeSongScore();

            HtmlNode missionDetail = element.ChildNodes[5];

            score.SongName   = HtmlEntity.DeEntitize(missionDetail.ChildNodes[1].InnerText.Trim());
            score.SongArtist = HtmlEntity.DeEntitize(missionDetail.ChildNodes[3].InnerText.Trim());
            if (missionDetail.ChildNodes.Count == 7)
            {
                score.IsSongFullCombo = true;
            }

            HtmlNode scoreList = element.ChildNodes[7];

            score.SongLevel     = int.Parse(scoreList.ChildNodes[3].InnerText.Trim());
            score.SongClearRate = int.Parse(scoreList.ChildNodes[7].InnerText.Trim().TrimEnd('%'));
            score.SongScore     = int.Parse(scoreList.ChildNodes[11].InnerText.Trim());

            HtmlNode gradeContainer = element.ChildNodes[9];
            string   gradeImageUrl  = gradeContainer.ChildNodes[1].Attributes["src"].Value;

            score.SongGradeValue = GradeHelper.GetGradeFromImageUrl(gradeImageUrl);

            return(score);
        }
        public ChallengeCourse GetChallengeCourse(Uri uri)
        {
            string id             = _idRegex.Match(uri.ToString()).Groups[1].Value;
            string responseString = DownloadString(uri);

            HtmlDocument document = new HtmlDocument();

            document.LoadHtml(responseString);

            HtmlNode        challengeCourseElement = document.DocumentNode.SelectNodes("//div[contains(@class, 'pdBlock')]")[0];
            ChallengeCourse challengeCourse        = ChallengeCourse.ParseFromElement(challengeCourseElement, id);

            HtmlNodeCollection songs = document.DocumentNode.SelectNodes("//div[contains(@class, 'chMissionBlock')]");

            foreach (HtmlNode songElement in songs)
            {
                ChallengeSongScore song = ChallengeSongScore.ParseFromElement(songElement);
                challengeCourse.Scores.Add(song);
            }

            return(challengeCourse);
        }