public ImageAble ReNew(ImageAble current, List <ImageAble> banned) { if (current as Card != null) { List <Card> banned_cards = new List <Card>(); if (banned != null) { banned_cards = banned.ConvertAll(x => (Card)x); } if (!banned_cards.Contains(current)) { banned_cards.Add(current as Card); } return(GetNewestCard(current.GetName(), banned_cards)); } if (current as Token != null) { List <Token> banned_cards = new List <Token>(); if (banned != null) { banned_cards = banned.ConvertAll(x => (Token)x); } if (!banned_cards.Contains(current)) { banned_cards.Add(current as Token); } return(GetNewestToken(current.GetName(), banned_cards)); } return(null); }
private static void ProcessCard(ImageAble card, int amount) { if (card == null) { return; } if (File.Exists(cache_image_dir + card.GetImageFileName())) { imaged_cards.Add(card, amount); card.SetCachedImage(cache_image_dir + card.GetImageFileName()); return; } List <ImageAble> banned = new List <ImageAble>(); bool downloaded = false; while (!downloaded) { foreach (string url in card.GetImageUrls()) { try { Thread.Sleep(100); Download(url, cache_image_dir + card.GetImageFileName()); imaged_cards.Add(card, amount); card.SetCachedImage(cache_image_dir + card.GetImageFileName()); downloaded = true; break; } catch (Exception) { continue; } } if (!downloaded) { banned.Add(card); card = manager.ReNew(card, banned); } if (card == null) { Console.WriteLine("[E] Error: Failed to download card \"" + card.GetName() + "\""); break; } } }