#pragma once #include #include #include class Pokedex; /** @brief single pokemon card */ class PokemonCard { private: nlohmann::json raw_data; virtual void raw_load_json(nlohmann::json raw_data); virtual void raw_load_cache(const char* cache_path); Pokedex* pokedex = nullptr; /** @brief add cache path before filename */ virtual std::string prefix_cache_path(const char* filename); public: PokemonCard(Pokedex* pokedex = nullptr); virtual ~PokemonCard(); /** @brief string stream output (for printing card) */ friend std::ostream& operator << (std::ostream& output, const PokemonCard& card); std::string id = ""; /** @brief pokemon id (with set prefix) */ std::string name = ""; /** @brief pokemon name */ unsigned hp = 0; /** @brief pokemon max health points */ double value = 0.f; /** @brief pokemon card current market value */ std::vector attacks = {}; /** @brief list of possible attacks */ virtual std::string short_identifier(); /** @brief use API to fetch `this->hp` */ virtual void fetch_market_value(); /** @brief check if all files are downloaded */ virtual void verify_files(); /** @brief download images */ virtual void download_files(); struct from_json; // named constructors (defined below) struct from_cache; /** @brief set cache */ virtual void set_pokedex(Pokedex* pokedex); }; struct PokemonCard::from_json : public PokemonCard { from_json(nlohmann::json json_data) : PokemonCard() { PokemonCard::raw_load_json(json_data); } }; struct PokemonCard::from_cache : public PokemonCard { from_cache(Pokedex* pokedex, std::string cache_path) : PokemonCard(pokedex) { PokemonCard::raw_load_cache(cache_path.c_str()); } };