aboutsummaryrefslogtreecommitdiff
path: root/oop2eindopdr
diff options
context:
space:
mode:
Diffstat (limited to 'oop2eindopdr')
-rw-r--r--oop2eindopdr/Pokedex.cpp8
-rw-r--r--oop2eindopdr/PokemonCard.cpp1
2 files changed, 5 insertions, 4 deletions
diff --git a/oop2eindopdr/Pokedex.cpp b/oop2eindopdr/Pokedex.cpp
index ee66f4c..9418a41 100644
--- a/oop2eindopdr/Pokedex.cpp
+++ b/oop2eindopdr/Pokedex.cpp
@@ -44,15 +44,14 @@ void Pokedex::load_collection_local() {
}
void Pokedex::verify_collection() {
- std::fstream* index = nullptr;
- if (!cache->cache_exists("index")) index = cache->cache_get("index");
+ std::fstream& index = *cache->cache_get("index");
for (PokemonCard* card : this->cards) {
card->verify_files();
- if (index != nullptr) *index << card->id << "\n";
+ index << card->id << "\n";
}
- if (index != nullptr) index->close();
+ index.close();
cache->update_cache();
}
@@ -69,6 +68,7 @@ std::vector<PokemonCard*> Pokedex::search_cards_by_id_local(std::string query) {
}
std::vector<PokemonCard*> Pokedex::search_cards_by_id_remote(std::string query) {
+ std::cout << "couldn't find card in cache, trying api..." << std::endl;
std::vector<PokemonCard*> api_cards = api->get_cards_by_query((std::string("name:\"") + query + "\" OR id:\"" + query + "\"").c_str());
std::vector<PokemonCard*> out;
diff --git a/oop2eindopdr/PokemonCard.cpp b/oop2eindopdr/PokemonCard.cpp
index 8ce18a8..51e7f59 100644
--- a/oop2eindopdr/PokemonCard.cpp
+++ b/oop2eindopdr/PokemonCard.cpp
@@ -80,6 +80,7 @@ void PokemonCard::raw_load_json(nlohmann::json raw_data) {
}
void PokemonCard::raw_load_cache(const char* cache_path) {
+ this->id = cache_path;
this->verify_files();
std::fstream& info_json_file = *this->pokedex->cache->cache_get(std::string(cache_path) + "/info.json");
std::stringstream info_json_content;