Beispiel #1
0
        private static Dictionary <CardId, string> LoadCards(out IReadOnlyDictionary <CardId, ElementType> outFairyElements)
        {
            var xmlSerializer = new XmlSerializer(typeof(results));

            using var stringReader = new StringReader(Properties.Resources.cards);
            var results = (results)xmlSerializer.Deserialize(stringReader);

            var cards         = new Dictionary <CardId, string>();
            var fairyElements = new Dictionary <CardId, ElementType>();

            foreach (var row in results.rows)
            {
                var cardId = new CardId((CardType)int.Parse(row[0].Value), int.Parse(row[1].Value));
                cards.Add(cardId, row[2].Value);

                if (cardId.type == CardType.Fairy)
                {
                    fairyElements.Add(cardId, (ElementType)int.Parse(row[3].Value));
                }
            }
            outFairyElements = fairyElements;
            return(cards);
        }
Beispiel #2
0
 public Image GetIconFor(CardId cardId) => cardIcons.TryGetValue(cardId, out var image)
     ? image
     : SystemIcons.Question.ToBitmap();
Beispiel #3
0
 public string GetNameFor(CardId cardId) => Cards.TryGetValue(cardId, out var name) ? name : "<unknown>";