30 lines
802 B
C#
30 lines
802 B
C#
public class Enemy : IAttackable, IDescribable{
|
|
public string Name { get; }
|
|
public bool IsDead { get; private set; }
|
|
public int Damage { get; }
|
|
public EnemyType Type { get; }
|
|
private int _health;
|
|
|
|
public Enemy(string name, int health, int damage, EnemyType type) {
|
|
Name = name;
|
|
_health = health;
|
|
Damage = damage;
|
|
Type = type;
|
|
}
|
|
|
|
public void TakeDamage(int amount) {
|
|
_health -= amount;
|
|
if (_health <= 0)
|
|
IsDead = true;
|
|
}
|
|
|
|
public string GetLoot() {
|
|
return Name == "Dragon" ? "dragon_scale" : "gold";
|
|
}
|
|
|
|
public void Describe() {
|
|
Console.WriteLine($"--- " + Name + " (enemy) ---");
|
|
Console.WriteLine($"HP: {_health}");
|
|
Console.WriteLine($"Type: {Type}");
|
|
}
|
|
} |