Only consume potions if they have an effect

This commit is contained in:
2023-12-30 16:44:23 +01:00
parent b3d64f7438
commit a69e89c806
2 changed files with 8 additions and 3 deletions

View File

@@ -68,8 +68,11 @@ impl Artifact for Potion {
}
fn get_immutable_position(&self) -> &Position { &self.position }
fn collect(&mut self, player: &mut Player) {
player.change_life(self.health.try_into().unwrap());
self.health = 0;
// only consume potion of the player can gain at least one health point
if !player.is_healthy() {
player.change_life(self.health.try_into().unwrap());
self.health = 0;
}
}
fn was_collected(&self) -> bool {