Пример #1
0
        public static HeroDetails ParseDetails(string HTMLHero)
        {
            HeroDetails hd = new HeroDetails(temp);

            try
            {
                CQ   cq = CQ.Create(HTMLHero);
                bool state;

                string buff = cq.Find(Selectors.GetDataSelector(4)).Elements.First().InnerText.Replace("\n", "");
                hd.Date = DateTime.Parse(buff);

                buff     = cq.Find(Selectors.GetDataSelector(5)).Elements.First().InnerText.Replace("\n", "");
                hd.Price = Int32.Parse(buff);

                hd.Title = cq.Find(Selectors.GetDataSelector(6)).Elements.First().InnerText.Replace("\n", "");

                buff  = cq.Find(Selectors.GetDataSelector(8)).Elements.First().InnerText.Replace("\n", "");
                state = Enum.TryParse(buff, out Franchise Fresult);
                if (state == false)
                {
                    Fresult = Franchise.Unknown;
                }
                hd.Franchise = Fresult;

                hd.Info = cq.Find(Selectors.GetDataSelector(9)).Elements.First().InnerHTML.Replace("\n", "");

                hd.Lore = cq.Find(Selectors.GetDataSelector(10)).Elements.First().InnerText.Replace("\n", "");

                buff  = cq.Find(Selectors.GetDataSelector(11)).Elements.First().InnerText.Replace("\n", "");
                state = Enum.TryParse(buff, out Difficulty Dresult);
                if (state == false)
                {
                    Dresult = Difficulty.Unknown;
                }
                hd.Difficulty = Dresult;

                if (hd.Franchise == Franchise.Vikings)
                {
                    return(hd);
                }
                if (Heroes.Find(temp).Name == "Greymane")
                {
                    Hero GreyCustom = new Hero(-1, "Greymane_(Human)", 0, 0);
                    Caching(GreyCustom);
                    string HTMLCustom = File.ReadAllText($"./Cache/{GreyCustom.Name}.html", Encoding.Default);
                    cq = CQ.Create(HTMLCustom);
                }
                if (Heroes.Find(temp).Name == "D.Va")
                {
                    Hero GreyCustom = new Hero(-1, "D.Va_(Pilot)", 0, 0);
                    Caching(GreyCustom);
                    string HTMLCustom = File.ReadAllText($"./Cache/{GreyCustom.Name}.html", Encoding.Default);
                    cq = CQ.Create(HTMLCustom);
                }

                buff     = cq.Find(Selectors.GetDataSelector(12)).Elements.First().InnerText.Replace("\n", "");
                hd.Melee = Boolean.Parse(buff);

                buff      = cq.Find(Selectors.GetDataSelector(13)).Elements.First().InnerText.Replace("\n", "").Replace(",", "");
                hd.Health = Int32.Parse(buff);

                buff           = cq.Find(Selectors.GetDataSelector(14)).Elements.First().InnerText.Replace("\n", "");
                hd.HealthRegen = buff.DoubleParseAdvanced();

                buff        = cq.Find(Selectors.GetDataSelector(15)).Elements.First().InnerText.Replace("\n", "");
                hd.Resource = Int32.Parse(buff);

                buff  = cq.Find(Selectors.GetDataSelector(16)).Elements.First().InnerText.Replace("\n", "");
                state = Enum.TryParse(buff, out ResourceType RTresult);
                if (state == false)
                {
                    RTresult = ResourceType.Unknown;
                }
                hd.ResourceType = RTresult;


                buff = cq.Find(Selectors.GetDataSelector(17)).Elements.First().InnerText.Replace("\n", "");
                if (buff.Contains("Spell"))
                {
                    var buff2 = buff.Split(new string[] { "Spell" }, StringSplitOptions.RemoveEmptyEntries)[0];
                    hd.SpellArmor = Int32.Parse(buff2);
                }

                if (buff.Contains("Physical"))
                {
                    buff             = buff.Split(new string[] { "Physical" }, StringSplitOptions.RemoveEmptyEntries)[0];
                    hd.PhysicalArmor = Int32.Parse(buff);
                }


                buff           = cq.Find(Selectors.GetDataSelector(18)).Elements.First().InnerText.Replace("\n", "");
                hd.AttackSpeed = buff.DoubleParseAdvanced();

                buff           = cq.Find(Selectors.GetDataSelector(19)).Elements.First().InnerText.Replace("\n", "");
                hd.AttackRange = buff.DoubleParseAdvanced();

                buff            = cq.Find(Selectors.GetDataSelector(20)).Elements.First().InnerText.Replace("\n", "");
                hd.AttackDamage = Int32.Parse(buff);
            }
            catch (Exception e)
            {
                Console.WriteLine(e);
            }
            return(hd);
        }