Example #1
0
        public CharacterData MakeAllTheViewModels(string fileName, string username,
                                                  string password)
        {
            var characterFile     = CharacterFile.From(fileName);
            var configFile        = ConfigFile.Matching(characterFile);
            var partialCards      = CharacterFile.PartialCards(characterFile);
            var localCards        = ConfigFile.ParseCards(configFile);
            var compendiumService = CompendiumService.Authenticate(Tuple.Create(username, password));
            var cardService       = CardService.Authenticate(Tuple.Create(username, password));

            var enrichedPartialCards = partialCards
                                       .Select(card => EnrichPartialCard(
                                                   Tuple.Create(Tuple.Create(cardService, compendiumService), card)))
                                       .ToArray();

            var allCardData         = localCards.Concat(enrichedPartialCards);
            var allResolvedCardData = new List <CardData>();

            foreach (var card in allCardData)
            {
                characterFile.ResolveFormulasToValues(card, configFile);
                allResolvedCardData.Add(card);
            }

            var cardViewModels = allResolvedCardData.Select(CardViewModel.From);

            return(new CharacterData(cardViewModels));
        }
        public CharacterData MakeAllTheViewModels(string fileName, string username,
                                                  string password)
        {
            var characterFile     = CharacterFile.From(fileName);
            var configFile        = ConfigFile.Matching(characterFile);
            var partialCards      = characterFile.ParseCards();
            var localCards        = configFile.ParseCards();
            var compendiumService = CompendiumService.Authenticate(username, password);
            var cardService       = CardService.Authenticate(username, password);

            foreach (var card in partialCards)
            {
                cardService.FetchDetailsInto(card);
                compendiumService.FillOutFlavorText(card);
                _LocateAndTranslateFormulas(card);
                cardService.ResolveReferencesToOtherCards(card);
            }
            foreach (var card in localCards.Concat(partialCards))
            {
                characterFile.ResolveFormulasToValues(card, configFile);
            }
            return(new CharacterData(localCards.Concat(partialCards).Select(CardViewModel.From)));
        }