private Building[] InitializeArray(int length, Account acc) { Building[] array = new Building[length]; for (int i = 0; i < length; ++i) { var building = new Building(); building.Init(i + 1, 0, 0, false); array[i] = building; } array[39].Type = InfrastructureHelper.GetTribesWall(acc.AccInfo.Tribe); array[38].Type = Helpers.Classificator.BuildingEnum.RallyPoint; return(array); }
public static List <Building> GetBuildings(Account acc, HtmlAgilityPack.HtmlDocument htmlDoc) { var fields = htmlDoc.GetElementbyId("village_map").ChildNodes.Where(x => x.Name == "div").ToList(); List <Building> buildings = new List <Building>(); for (byte i = 0; i < fields.Count; i++) { var vals = fields[i].GetAttributeValue("class", "").Split(' '); var location = (int)Parser.RemoveNonNumeric(vals.FirstOrDefault(x => x.StartsWith("a"))); if (location <= 18 || location > 40) { continue; } var gid = Convert.ToByte(vals.FirstOrDefault(x => x.StartsWith("g")).Replace("g", "")); byte lvl; var lvlNode = fields[i].Descendants("div").FirstOrDefault(x => x.HasClass("labelLayer")); if (lvlNode == null) { lvl = 0; } else { lvl = Convert.ToByte(lvlNode.InnerText); } var uc = fields[i].Descendants("div").FirstOrDefault(x => x.HasClass("underConstruction")) != null; //var b = fields[i].Child var building = new Building(); buildings.Add(building.Init( location, lvl,//Convert.ToByte(vals[4].Replace("level", "")), gid, uc )); } buildings.FirstOrDefault(x => x.Id == 39).Type = Helpers.Classificator.BuildingEnum.RallyPoint; buildings.FirstOrDefault(x => x.Id == 40).Type = InfrastructureHelper.GetTribesWall(acc.AccInfo.Tribe); return(buildings); }