fight monsters, collect artifacts
This commit is contained in:
@@ -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
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user