#include #include #include "CacheManager.h" #include "Pokedex.h" Pokedex::Pokedex() { this->cache = new CacheManager("./cache"); this->api = new PokemonTCGAPIClient(); if (this->cache->cache_exists("index")) this->load_collection_local(); else this->load_collection_remote(); } Pokedex::~Pokedex() { delete this->cache; } void Pokedex::load_collection_remote() { std::cout << "no local cards found, building cache..." << std::endl; std::vector remote_cards = api->get_set_cards("swshp"); for (PokemonCard* card : remote_cards) { card->set_cache(this->cache); card->verify_files(); this->cards.push_back(card); } cache->update_cache(); } void Pokedex::load_collection_local() { std::fstream& cache_collection = *cache->cache_get("index"); std::string card; while (std::getline(cache_collection, card)) { this->cards.push_back(new PokemonCard::from_cache(this->cache, card)); } } void Pokedex::verify_collection() { for (PokemonCard* card : this->cards) card->verify_files(); } std::vector Pokedex::search_cards_by_id(std::string query) { return {}; }