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}"); } }
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}"); } }
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}"); } }
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); } } }
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); } }
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]; } }
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)}"); } }
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)) }); }
static bool isMalformed(DeckZone zone) => zone == null || zone.Order == null || zone.Count == null;
public void SetDeck(DeckZone deckZone) { CountById = deckZone.Count.ToDictionary(); Order = deckZone.Order.ToList(); }