Exemplo n.º 1
0
        private ICard GetCard(Match m)
        {
            string cardName  = m.Groups["name"].Value.TrimEnd();
            string cardName2 = null;

            if (cardName.Contains("/"))
            {
                string[] c = cardName.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries);
                // Special case for Who / What / When / Where / Why that is considered as 1 card with no second card
                if (c.Length == 2)
                {
                    cardName  = c[0].Trim();
                    cardName2 = c[1].Trim();
                }
            }

            ICard card = MagicDatabase.GetCard(cardName, cardName2);

            if (card == null)
            {
                card = MagicDatabase.GetCard(cardName, null);
                if (card == null)
                {
                    throw new ParserException("Could not find Card with name " + cardName);
                }
            }

            return(card);
        }
Exemplo n.º 2
0
        private IEnumerable <AuditInfo> GetAudit()
        {
            foreach (IAudit audit in _allAudit.Where(a => a.OperationDate >= MinDate && a.OperationDate < MaxDate.AddDays(1)))
            {
                AuditInfo info = new AuditInfo
                {
                    Quantity      = audit.Quantity,
                    OperationDate = audit.OperationDate.ToLocalTime().ToString("G"),
                    IsFoil        = audit.IsFoil.HasValue && audit.IsFoil.Value,
                    IsAltArt      = audit.IsAltArt.HasValue && audit.IsAltArt.Value,
                };

                ICardCollection cardCollection = _magicDatabase.GetCollection(audit.IdCollection);
                info.CollectionName = cardCollection == null ? "(Deleted) " + audit.IdCollection : cardCollection.Name;

                if (audit.IdGatherer.HasValue)
                {
                    ICard card = _magicDatabase.GetCard(audit.IdGatherer.Value);
                    if (card == null)
                    {
                        info.CardName    = "(Not found) " + audit.IdGatherer.Value;
                        info.EditionName = "(Not found) " + audit.IdGatherer.Value;
                    }
                    else
                    {
                        info.CardName = card.Name;
                        IEdition edition = _magicDatabase.GetEdition(audit.IdGatherer.Value);
                        info.EditionName = edition == null ? "(Not found) " + audit.IdGatherer.Value : edition.Name;
                    }
                    if (audit.IdLanguage.HasValue)
                    {
                        ILanguage language = _magicDatabase.GetLanguage(audit.IdLanguage.Value);
                        info.Language = language == null ? "(Not found) " + audit.IdLanguage.Value : language.Name;
                    }
                    else
                    {
                        info.Language = "(Missing language)";
                    }
                }

                yield return(info);
            }
        }
Exemplo n.º 3
0
        private IEnumerable <PriceInfo> ExtractCardPrice(Card scryfallCard, DateTime updatedAt)
        {
            List <int> ids = scryfallCard.MultiverseIds;

            //Temporary fix
            if (scryfallCard.Id == "71ccc444-54c8-4f7c-a425-82bc3eea1eb0")
            {
                ids = new List <int> {
                    534954, 534953
                };
            }

            IList <ICard> cards = new List <ICard>();

            foreach (int id in ids)
            {
                ICard c = _magicDatabase.GetCard(id);
                if (c != null)
                {
                    cards.Add(c);
                }
            }

            if (cards.Count == 0)
            {
                yield break;
            }

            CheckCard(scryfallCard, cards);

            if (scryfallCard.Prices == null)
            {
                yield break;
            }
            foreach (int id in ids)
            {
                double price;
                int    p;
                if (double.TryParse(scryfallCard.Prices.Usd, out price))
                {
                    p = (int)(price * 100);
                    yield return(new PriceInfo {
                        UpdateDate = updatedAt, IdGatherer = id, PriceSource = PriceValueSource.TCGplayer, Foil = false, Value = p
                    });
                }
                if (double.TryParse(scryfallCard.Prices.UsdFoil, out price))
                {
                    p = (int)(price * 100);
                    yield return(new PriceInfo {
                        UpdateDate = updatedAt, IdGatherer = id, PriceSource = PriceValueSource.TCGplayer, Foil = true, Value = p
                    });
                }
                if (double.TryParse(scryfallCard.Prices.Eur, out price))
                {
                    p = (int)(price * 100);
                    yield return(new PriceInfo {
                        UpdateDate = updatedAt, IdGatherer = id, PriceSource = PriceValueSource.Cardmarket, Foil = false, Value = p
                    });
                }
                if (double.TryParse(scryfallCard.Prices.EurFoil, out price))
                {
                    p = (int)(price * 100);
                    yield return(new PriceInfo {
                        UpdateDate = updatedAt, IdGatherer = id, PriceSource = PriceValueSource.Cardmarket, Foil = true, Value = p
                    });
                }
            }
        }