Exemplo n.º 1
0
        public static DominionSet GetSet(string setname)
        {
            DominionSet set = new DominionSet();

            set.Name = setname;
            List <DominionCard> cards  = new List <DominionCard>();
            HttpWebRequest      req    = HttpWebRequest.Create("http://dominion.diehrstraits.com/?set=" + setname) as HttpWebRequest;
            HttpWebResponse     rep    = req.GetResponse() as HttpWebResponse;
            StreamReader        reader = new StreamReader(rep.GetResponseStream());
            string site      = reader.ReadToEnd();
            string siteparse = site;

            // Get names
            while (siteparse.Contains(titletag))
            {
                string       leftovers = siteparse.Substring(siteparse.IndexOf(titletag) + titletag.Length);
                string       cardname  = leftovers.Substring(0, leftovers.IndexOf("\'"));
                DominionCard card      = new DominionCard();
                card.Name = cardname;
                cards.Add(card);
                card.Set = set;
                set.Cards.Add(card);
                PopulateCard(card);
                siteparse = leftovers;
            }

            return(set);
        }
Exemplo n.º 2
0
        public static DominionSet GetSet(string setname)
        {
            DominionSet set = new DominionSet();
            set.Name = setname;
            List<DominionCard> cards = new List<DominionCard>();
            HttpWebRequest req = HttpWebRequest.Create("http://dominion.diehrstraits.com/?set=" + setname) as HttpWebRequest;
            HttpWebResponse rep = req.GetResponse() as HttpWebResponse;
            StreamReader reader = new StreamReader(rep.GetResponseStream());
            string site = reader.ReadToEnd();
            string siteparse = site;
            // Get names
            while (siteparse.Contains(titletag))
            {
                string leftovers = siteparse.Substring(siteparse.IndexOf(titletag) + titletag.Length);
                string cardname = leftovers.Substring(0, leftovers.IndexOf("\'"));
                DominionCard card = new DominionCard();
                card.Name = cardname;
                cards.Add(card);
                card.Set = set;
                set.Cards.Add(card);
                PopulateCard(card);
                siteparse = leftovers;
            }

            return set;
        }
Exemplo n.º 3
0
        private static void PopulateCard(DominionCard card)
        {
            HttpWebRequest  req       = HttpWebRequest.Create("http://dominion.diehrstraits.com/?card=" + card.Name) as HttpWebRequest;
            HttpWebResponse rep       = req.GetResponse() as HttpWebResponse;
            StreamReader    reader    = new StreamReader(rep.GetResponseStream());
            string          site      = reader.ReadToEnd();
            string          siteparse = site;

            // Find the card image
            if (siteparse.Contains(cardimgtag))
            {
                // Then look for the image source. Otherwise it would just grab the first images source from the page.
                string leftovers = siteparse.Substring(siteparse.IndexOf(cardimgtag));
                if (leftovers.Contains(imgtag))
                {
                    card.ImgSrc = leftovers.Substring(leftovers.IndexOf(imgtag) + imgtag.Length, leftovers.IndexOf("'"));
                }
            }
        }
Exemplo n.º 4
0
        private static void PopulateCard(DominionCard card)
        {
            HttpWebRequest req = HttpWebRequest.Create("http://dominion.diehrstraits.com/?card=" + card.Name) as HttpWebRequest;
            HttpWebResponse rep = req.GetResponse() as HttpWebResponse;
            StreamReader reader = new StreamReader(rep.GetResponseStream());
            string site = reader.ReadToEnd();
            string siteparse = site;

            // Find the card image
            if (siteparse.Contains(cardimgtag))
            {
                // Then look for the image source. Otherwise it would just grab the first images source from the page.
                string leftovers = siteparse.Substring(siteparse.IndexOf(cardimgtag));
                if (leftovers.Contains(imgtag))
                {
                    card.ImgSrc = leftovers.Substring(leftovers.IndexOf(imgtag) + imgtag.Length, leftovers.IndexOf("'"));
                }

            }
        }