Monsters can attack player now

This commit is contained in:
2023-12-30 16:31:27 +01:00
parent b88bc67c50
commit b3d64f7438
3 changed files with 20 additions and 12 deletions

View File

@@ -28,9 +28,11 @@ impl Player {
pub fn change_life(&mut self, by: i16) {
self.life = max(0, min(self.max_life, self.life + by));
}
/// returns true if the player is dead (life <= 0)
pub fn get_life(&self) -> i16 {
self.life
}
pub fn is_dead(&self) -> bool { self.life <= 0 }
pub fn get_max_life(&self) -> i16 {
self.max_life
}