|
|
@ -10,6 +10,58 @@ const auto ERROR = fmt::emphasis::bold | fg(fmt::color::red); |
|
|
|
using namespace fmt; |
|
|
|
using namespace fmt; |
|
|
|
using namespace std; |
|
|
|
using namespace std; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GameEngine::GameEngine(int hp) : starting_hp(hp) { |
|
|
|
|
|
|
|
hit_points = starting_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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GameEngine::start_round() { |
|
|
|
|
|
|
|
hits_taken = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GameEngine::end_round() { |
|
|
|
|
|
|
|
++rounds; |
|
|
|
|
|
|
|
if(hits_taken == 0) { |
|
|
|
|
|
|
|
++streak; |
|
|
|
|
|
|
|
heal(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GameEngine::reset() { |
|
|
|
|
|
|
|
rounds = 0; |
|
|
|
|
|
|
|
streak = 0; |
|
|
|
|
|
|
|
hit_points = starting_hp; |
|
|
|
|
|
|
|
hits_taken = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool GameEngine::hit(string &type) { |
|
|
|
|
|
|
|
int damage = determine_damage(type); |
|
|
|
|
|
|
|
hit_points -= damage; |
|
|
|
|
|
|
|
++hits_taken; |
|
|
|
|
|
|
|
streak = 0; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return is_dead(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GameEngine::heal() { |
|
|
|
|
|
|
|
hit_points = hit_points * 1.10; |
|
|
|
|
|
|
|
if(hit_points > 100) hit_points = 100; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool GameEngine::is_dead() { |
|
|
|
|
|
|
|
return hit_points <= 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Brainfucker::Brainfucker() { |
|
|
|
Brainfucker::Brainfucker() { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -124,42 +176,3 @@ void Brainfucker::reset() { |
|
|
|
string Brainfucker::to_string() { |
|
|
|
string Brainfucker::to_string() { |
|
|
|
return out.str(); |
|
|
|
return out.str(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
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; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GameEngine::start_round() { |
|
|
|
|
|
|
|
hits_taken = 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GameEngine::end_round() { |
|
|
|
|
|
|
|
if(hits_taken == 0) { |
|
|
|
|
|
|
|
heal(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool GameEngine::hit(string &type) { |
|
|
|
|
|
|
|
int damage = determine_damage(type); |
|
|
|
|
|
|
|
hit_points -= damage; |
|
|
|
|
|
|
|
++hits_taken; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// super dumb but I'll clean it up later
|
|
|
|
|
|
|
|
return is_dead(); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void GameEngine::heal() { |
|
|
|
|
|
|
|
hit_points = hit_points * 1.10; |
|
|
|
|
|
|
|
if(hit_points > 100) hit_points = 100; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool GameEngine::is_dead() { |
|
|
|
|
|
|
|
return hit_points <= 0; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|