#include "Enemy.h" #include "util.h" Enemy::Enemy(const String & name, const String & description) : name(name), description(description) { } void Enemy::set_name(const String & name) { this->name = name; } 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; } void Enemy::set_attack(float attack_chance) { this->attack_chance = attack_chance; } float Enemy::get_attack() const { return this->attack_chance; } void Enemy::set_damage(const Range & range) { this->damage_min = range.min; this->damage_max = range.max; } Range Enemy::get_damage() const { return { this->damage_min, this->damage_max }; } void Enemy::set_health(unsigned health_points) { this->health_points = health_points; } 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; } bool Enemy::is_dead() const { return this->health_points == 0; } void Enemy::add_hidden_object(Object * object) { this->hidden_objects.push_back(object); } void Enemy::remove_hidden_object(Object * object) { this->hidden_objects.remove(object); } ListRange Enemy::get_hidden_objects() { return this->hidden_objects.range(); } String Enemy::get_displayname() const { return String::fmt("%s%s", this->name.c_str(), this->health_points == 0 ? " [verslagen]" : ""); }