fight monsters, collect artifacts

This commit is contained in:
2023-12-17 16:14:17 +01:00
parent 643f3b76f9
commit 8b21e179c2
5 changed files with 105 additions and 52 deletions

View File

@@ -9,6 +9,7 @@ pub trait Artifact {
fn get_immutable_position(&self) -> &Position;
/// call to apply the effects of the artifact to the player
fn collect(&mut self, player: &mut Player);
fn was_collected(&self) -> bool;
}
pub struct Chest {
@@ -36,6 +37,10 @@ impl Artifact for Chest {
player.retrieve_gold(self.gold);
self.gold = 0;
}
fn was_collected(&self) -> bool {
self.gold == 0
}
}
pub struct Potion {
@@ -62,4 +67,8 @@ impl Artifact for Potion {
player.change_life(self.health.try_into().unwrap());
self.health = 0;
}
fn was_collected(&self) -> bool {
self.health == 0
}
}