private void writeDeckZone(StringBuilder result, DeckZone zone, string prefix)
 {
     foreach (var id in zone.Order)
     {
         result.Append(prefix);
         result.AppendLine($"{zone.Count[id]} {Repo.CardsById[id].NameEn}");
     }
 }
Esempio n. 2
0
 private void writeCards(StringBuilder result, DeckZone deckZone)
 {
     foreach (var cardId in deckZone.Order)
     {
         var count = deckZone.Count[cardId];
         var card  = Repo.CardsById[cardId];
         var set   = _forgeSetRepo.ToForgeSet(card.SetCode);
         result.AppendLine($"{count} {card.NameNormalized}|{set}");
     }
 }
Esempio n. 3
0
        private void writeCards(StringBuilder result, DeckZone zone, string prefix)
        {
            foreach (var cardId in zone.Order)
            {
                var count = zone.Count[cardId];
                var card  = Repo.CardsById[cardId];

                result.AppendLine($"{prefix}{count} [{card.SetCode}:{0}] {card.NameNormalized}");
            }
        }
Esempio n. 4
0
 private static void addDeckZone(DeckZone source, DeckZone target, Func <string, string> mapId)
 {
     foreach (var originalId in source.Order)
     {
         var id = mapId(originalId);
         if (id != null)
         {
             add(target, id, source, originalId);
         }
     }
 }
Esempio n. 5
0
 private static void add(Card card, int count, DeckZone collection)
 {
     if (collection.Count.ContainsKey(card.Id))
     {
         collection.Count[card.Id] += count;
     }
     else
     {
         collection.Count[card.Id] = count;
         collection.Order.Add(card.Id);
     }
 }
Esempio n. 6
0
 private static void add(DeckZone target, string id, DeckZone old, string oldId)
 {
     if (target.Count.TryGetValue(id, out var count))
     {
         target.Count[id] = count + old.Count[oldId];
     }
     else
     {
         target.Order.Add(id);
         target.Count[id] = old.Count[oldId];
     }
 }
Esempio n. 7
0
        private void writeCards(StringBuilder result, DeckZone deckZone, bool exact = false)
        {
            foreach (var cardId in deckZone.Order)
            {
                var card = exact
                                        ? Repo.CardsById[cardId]
                                        : Repo.CardsById[cardId].Faces.Main;

                if (card == null)
                {
                    continue;
                }

                var count = deckZone.Count[cardId];
                result.AppendLine($"{count} {ToMtgoName(card)}");
            }
        }
Esempio n. 8
0
        private static DeckZone replace(DeckZone original, Dictionary <string, string> replacements)
        {
            // replacements are not guaranteed to be unique

            return(new DeckZone
            {
                Order = original.Order
                        .Select(_ => replacements[_])
                        .Distinct()
                        .ToList(),

                Count = original.Count
                        .GroupBy(_ => replacements[_.Key])
                        .ToDictionary(
                    gr => gr.Key,
                    gr => gr.Sum(_ => _.Value))
            });
        }
Esempio n. 9
0
 static bool isMalformed(DeckZone zone) =>
 zone == null || zone.Order == null || zone.Count == null;
Esempio n. 10
0
 public void SetDeck(DeckZone deckZone)
 {
     CountById = deckZone.Count.ToDictionary();
     Order     = deckZone.Order.ToList();
 }