Esempio n. 1
0
        public static Deck ConvertDeck(Deck deck, Func <string, string> mapId)
        {
            var result = Deck.Create();

            addDeckZone(deck.MainDeck, result.MainDeck, mapId);
            addDeckZone(deck.Sideboard, result.Sideboard, mapId);
            addDeckZone(deck.Maybeboard, result.Maybeboard, mapId);

            result.File  = deck.File;
            result.Name  = deck.Name;
            result.Id    = deck.Id;
            result.Error = deck.Error;
            result.Saved = deck.Saved;

            return(result);
        }
Esempio n. 2
0
        public virtual Deck ImportDeck(string serialized, bool exact = false)
        {
            var result = Deck.Create();

            var lines = SplitToLines(serialized);

            var unmatched = new HashSet <string>();

            foreach (string line in lines)
            {
                var match = LineRegex.Match(line);

                bool isSideboard = IsSideboard(match, line);

                if (!match.Success)
                {
                    continue;
                }

                var count = int.Parse(match.Groups["count"].Value);
                var card  = GetCard(match);

                if (card == null)
                {
                    unmatched.Add(match.Value);
                    continue;
                }

                if (isSideboard)
                {
                    add(card, count, result.Sideboard);
                }
                else
                {
                    add(card, count, result.MainDeck);
                }

                // ignore maybeboard
            }

            _log.Info("Unmatched cards:\r\n{0}", string.Join("\r\n", unmatched));

            return(result);
        }
Esempio n. 3
0
        public Deck ImportDeck(string serialized, bool exact = false)
        {
            var result    = Deck.Create();
            var unmatched = new HashSet <string>();

            var csvCards = _fileHelperEngine.ReadStringAsList(serialized);

            foreach (CsvCardModel csvCard in csvCards)
            {
                var card = getCard(csvCard);

                if (card == null)
                {
                    unmatched.Add(csvCard.SimpleName);
                    continue;
                }

                add(card, csvCard.Quantity, result.MainDeck);
            }

            _log.Info($"Unmatched cards:{Str.Endl}{string.Join(Str.Endl, unmatched)}");
            return(result);
        }