private static Collection <JsonCard> GetCardsForXmlDeck(XmlDeck deck, Collection <JsonCard> allJsonCards)
        {
            Collection <JsonCard> cards = new Collection <JsonCard>();

            foreach (XmlCard card in deck.Card)
            {
                for (int amount = 0; amount < card.Amount; ++amount)
                {
                    JsonCard foundCard = allJsonCards.Where(c => c.Set == card.Set && c.Id == card.Id).First().DeepCopy;
                    cards.Add(foundCard);
                }
            }
            return(cards);
        }
Beispiel #2
0
        /// <summary>
        /// Returns a card for card template.
        /// </summary>
        private static Card GetCardFromJsonCard(JsonCard jsonCard)
        {
            switch (jsonCard.CardType)
            {
            case CreatureText:
                return(new Creature(jsonCard.Name, jsonCard.Set, jsonCard.Id, jsonCard.Civilizations, jsonCard.Rarity, jsonCard.Cost, jsonCard.Text, jsonCard.Flavor, jsonCard.Illustrator, jsonCard.Power, jsonCard.Races));

            case SpellText:
                return(new Spell(jsonCard.Name, jsonCard.Set, jsonCard.Id, jsonCard.Civilizations, jsonCard.Rarity, jsonCard.Cost, jsonCard.Text, jsonCard.Flavor, jsonCard.Illustrator));

            case EvolutionCreatureText:
                return(new EvolutionCreature(jsonCard.Name, jsonCard.Set, jsonCard.Id, jsonCard.Civilizations, jsonCard.Rarity, jsonCard.Cost, jsonCard.Text, jsonCard.Flavor, jsonCard.Illustrator, jsonCard.Power, jsonCard.Races));

            case CrossGearText:
                return(new CrossGear(jsonCard.Name, jsonCard.Set, jsonCard.Id, jsonCard.Civilizations, jsonCard.Rarity, jsonCard.Cost, jsonCard.Text, jsonCard.Flavor, jsonCard.Illustrator));

            default:
                throw new ArgumentException("Unknown card type: " + jsonCard.CardType);
            }
        }