aboutsummaryrefslogtreecommitdiff
path: root/backend/Enemy.cpp
diff options
context:
space:
mode:
authorLoek Le Blansch <loek@pipeframe.xyz>2024-11-01 10:18:22 +0100
committerLoek Le Blansch <loek@pipeframe.xyz>2024-11-01 10:18:22 +0100
commit798948dbe6f012e194f053c4e862cf697f30b793 (patch)
tree32c71420d1188f98cfb41b6f0d9536c5fa4bf5a7 /backend/Enemy.cpp
parentd7012045bb61f117fb7b9c51ddd03e4c54f25fe6 (diff)
more WIP (move some Player things to backend)
Diffstat (limited to 'backend/Enemy.cpp')
-rw-r--r--backend/Enemy.cpp23
1 files changed, 14 insertions, 9 deletions
diff --git a/backend/Enemy.cpp b/backend/Enemy.cpp
index 15e66ed..9eadf01 100644
--- a/backend/Enemy.cpp
+++ b/backend/Enemy.cpp
@@ -1,4 +1,5 @@
#include "Enemy.h"
+#include "util.h"
Enemy::Enemy(const String & name, const String & description) : name(name), description(description) { }
@@ -8,20 +9,24 @@ const String & Enemy::get_name() const { return this->name; }
void Enemy::set_description(const String & description) { this->description = description; }
const String & Enemy::get_description() const { return this->description; }
-unsigned Enemy::get_health() const { return this->health_points; }
+void Enemy::set_attack(float attack_chance) { this->attack_chance = attack_chance; }
+float Enemy::get_attack() const { return this->attack_chance; }
-const String & Enemy::get_displayname() const {
- static String displayname;
- displayname = String::fmt("%s%s", this->name.c_str(), this->health_points == 0 ? " [verslagen]" : "");
- return displayname;
-}
+void Enemy::set_damage_min(int damage_min) { this->damage_min = damage_min; }
+int Enemy::get_damage_min() const { return this->damage_min; }
-static inline unsigned min(unsigned a, unsigned b) {
- return a < b ? a : b;
-}
+void Enemy::set_damage_max(int damage_max) { this->damage_max = damage_max; }
+int Enemy::get_damage_max() const { return this->damage_max; }
+unsigned Enemy::get_health() const { return this->health_points; }
void Enemy::take_damage(unsigned int dmg) {
dmg = min(dmg, this->health_points);
this->health_points -= dmg;
}
+const String & Enemy::get_displayname() const {
+ static String displayname;
+ displayname = String::fmt("%s%s", this->name.c_str(), this->health_points == 0 ? " [verslagen]" : "");
+ return displayname;
+}
+