public void StringToRoleTest()
        {
            string role1 = "Ranged";
            string role2 = "Banged";

            Assert.AreEqual(HeroInfo.ToRole(role1), HeroRoles.Ranged);
            Assert.AreEqual(HeroInfo.ToRole(role2), HeroRoles.NotARole);
        }
Beispiel #2
0
        public static void GetHeroRoles(string heroName, HashSet <HeroRoles> result)
        {
            HttpWebRequest request     = GetRequest("https://dotabuff.com/heroes/" + heroName.ToLower().Replace(" ", "-"));
            string         page        = GetPage(request);
            Match          match       = Regex.Match(page, @"<title>(.)+</title>");
            string         rolesString = match.Value;

            rolesString = Regex.Replace(rolesString, @"<title>", "");
            rolesString = Regex.Replace(rolesString, @"\s-\sDOTABUFF\s-\sDota\s2\sStats</title>", "");
            rolesString = Regex.Replace(rolesString, heroName + " - ", "");
            string[] roles = Regex.Split(rolesString, @",\s");
            foreach (string role in roles)
            {
                //Debug.WriteLine(heroName+" - "+HeroInfo.ToRole(role.ToLower()));
                result.Add(HeroInfo.ToRole(role.ToLower()));
                ;
            }
        }