#include #include #include #include #include "game_engine.hpp" using namespace fmt; using namespace std; const auto ERROR = fmt::emphasis::bold | fg(fmt::color::red); GameEngine::GameEngine(int hp) : hit_points(hp) {}; int GameEngine::determine_damage(string &type) { try { return damage_types.at(type); } catch(std::out_of_range &err) { print(ERROR, "BAD DAMAGE TYPE {}\n", type); return 1000; } } bool GameEngine::hit(string &type) { int damage = determine_damage(type); hit_points -= damage; if(is_dead()) { print(ERROR, "YOU DIED!\n"); } else { println("DAMAGE {}, HP: {}", damage, hit_points); } // super dumb but I'll clean it up later return is_dead(); } bool GameEngine::is_dead() { return hit_points <= 0; }