diff options
author | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-01 17:32:53 +0100 |
---|---|---|
committer | Loek Le Blansch <loek@pipeframe.xyz> | 2024-11-01 17:32:53 +0100 |
commit | b20f46c15dce8b196dbb8890890978947745e094 (patch) | |
tree | d9defa84717ffa843fd11b05d0e856473d6d8d59 /backend/Player.cpp | |
parent | a7e84b60366c78b131d43157980fbe4c2df655e6 (diff) |
change flow architecture
Diffstat (limited to 'backend/Player.cpp')
-rw-r--r-- | backend/Player.cpp | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/backend/Player.cpp b/backend/Player.cpp index 4180458..f2bc526 100644 --- a/backend/Player.cpp +++ b/backend/Player.cpp @@ -16,15 +16,25 @@ unsigned Player::get_health() const { return this->health_points; } +bool Player::is_dead() const { + return this->health_points == 0; +} + void Player::take_damage(unsigned int dmg) { if (this->cheating) return; + if (this->is_dead()) return; dmg = min(dmg, this->health_points); if (this->armor != nullptr) dmg = max(0u, dmg - this->armor->get_protection()); this->health_points -= dmg; - lprtf("Je hebt nog %d levenspunten over.\n", this->health_points); + auto & hp = this->health_points; + lprtf("Je hebt %s%d levenspunt%s over.\n", hp > 0 ? "nog " : "", hp, hp == 1 ? "" : "en"); + + if (this->is_dead()) { + lprtf("Je bent dood gegaan!\n"); + } } Location & Player::get_location() const { |