Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
CharacterData MakeAllTheViewModels(
const std::string& fileName, const std::string& username, const std::string& password)
{
auto characterFile = CharacterFile::From(fileName);
auto configFile = ConfigFile::Matching(characterFile);
auto partialCards = characterFile.ParseCards();
auto localCards = configFile.ParseCards();
auto compendiumService = CompendiumService::Authenticate(username, password);
auto cardService = CardService::Authenticate(username, password);
for (auto& card : partialCards)
{
cardService.FetchDetailsInto(card);
compendiumService.FillOutFlavorText(card);
_LocateAndTranslateFormulas(card);
cardService.ResolveReferencesToOtherCards(card);
}
for (auto& cards : {partialCards, localCards})
{
for (auto& card : cards)
{
characterFile.ResolveFormulasToValues(card, configFile);
}
}
std::vector<CardViewModel> cardViewModels;
for (auto& cards : {partialCards, localCards})
{
std::transform(cards.cbegin(), cards.cend(), std::back_inserter(cardViewModels), CardViewModel::From);
}
return CharacterData(cardViewModels);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment