Created
February 11, 2019 00:31
-
-
Save JayBazuzi/3d57714bfaf75ba235d78d0fb40b9ab6 to your computer and use it in GitHub Desktop.
A C++ interpretation of https://github.com/arlobelshee/LegacyCharExample/blob/kata-start-here/Data/DoEverything.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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