Only consume potions if they have an effect
This commit is contained in:
@@ -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 {
|
||||
|
||||
Reference in New Issue
Block a user