示例#1
0
 public Card(sCard sf, int num, bool t = false)
 {
     cardName      = sf.name;
     filePathFront = sf.localLinkFront;
     filePathBack  = sf.localLinkBack;
     cardQty       = num;
     set           = sf.set;
     twin          = t;
 }
示例#2
0
 public double getPrice(string cardname)
 {
     try
     {
         string resp = wb.DownloadString("https://api.scryfall.com/cards/named?fuzzy=" + cardname);
         sCard  card = jss.Deserialize <sCard>(resp);
         return(card.usd == 0 ? 100 : card.usd);
     }
     catch // Probably a 404 error
     {
         return(100);
     }
 }
示例#3
0
        public sCard downloadImage(string cardname)
        {
            string query, set;

            if (cardname.Contains(":"))
            {
                // We're looking for a specific art...
                set      = cardname.Split(':')[1].Trim();
                cardname = cardname.Split(':')[0].Trim().Replace(" ", "+");
                query    = "https://api.scryfall.com/cards/named?fuzzy=" + cardname + "&set=" + set;
            }
            else
            {
                cardname = cardname.Replace(" ", "+");
                query    = "https://api.scryfall.com/cards/named?fuzzy=" + cardname;
            }

            string resp = wb.DownloadString(query);
            sCard  card = jss.Deserialize <sCard>(resp);

            if (card.status == 404)
            {
                throw new ArgumentException();
            }
            if (card.card_faces != null && card.image_uris == null)
            {
                wb.DownloadFile(card.card_faces[0].image_uris.png, "art\\scryfall\\" + card.id + "-front.png");
                card.localLinkFront = "art\\scryfall\\" + card.id + "-front.png";
                wb.DownloadFile(card.card_faces[1].image_uris.png, "art\\scryfall\\" + card.id + "-back.png");
                card.localLinkBack = "art\\scryfall\\" + card.id + "-back.png";
            }
            else
            {
                wb.DownloadFile(card.image_uris.png, "art\\scryfall\\" + card.id + ".png");
                card.localLinkFront = "art\\scryfall\\" + card.id + ".png";
            }

            return(card);
        }