Beispiel #1
0
        public UnovaZone GetZoneById(int id)
        {
            //TODO: unsafe, add error checking
            var cmd = Web.Xajax(Urls.UrlMap, "loadZone", 1).First(a => a.Command == "as");

            string html = cmd.Value.Text;

            if (html.Contains("leader-list"))
            {
                throw new NotImplementedException("Elite 4 and Battle Frontier are not supported yet");
            }

            //extract from html
            return(UnovaZone.FromHtml(html));
        }
Beispiel #2
0
        internal static UnovaZone FromHtml(string html)
        {
            var uz = new UnovaZone();

            //get name
            uz.Name = RegexName.Match(html).Groups[1].Value;

            //get all maps
            foreach (Match m in RegexMaps.Matches(html))
            {
                uz._maps.Add(new UnovaMap {
                    MapId       = int.Parse(m.Groups["mapid"].Value),
                    ZoneId      = int.Parse(m.Groups["zoneid"].Value),
                    Name        = m.Groups["name"].Value,
                    Description = m.Groups["desc"].Value,
                    Players     = int.Parse(m.Groups["players"].Value)
                });
            }

            return(uz);
        }