give different artifacts differen looks

This commit is contained in:
Joachim Lusiardi 2023-12-09 20:05:39 +01:00
parent 4a024a47d9
commit 6e2441aad1
1 changed files with 9 additions and 0 deletions

View File

@ -1,8 +1,10 @@
use ratatui::style::Color;
use crate::position::Position;
use crate::player::Player;
pub trait Artifact {
//! An artifact that can be collected by the player
fn get_representation(&self) -> (&str, Color);
/// get the position of the artifact in the level
fn get_immutable_position(&self) -> &Position;
/// call to apply the effects of the artifact to the player
@ -25,6 +27,10 @@ impl Chest {
}
impl Artifact for Chest {
fn get_representation(&self) -> (&str, Color) {
("C", Color::Blue)
}
fn get_immutable_position(&self) -> &Position { &self.position }
fn collect(&mut self, player: &mut Player) {
player.retrieve_gold(self.gold);
@ -48,6 +54,9 @@ impl Potion {
}
impl Artifact for Potion {
fn get_representation(&self) -> (&str, Color) {
("P", Color::Green)
}
fn get_immutable_position(&self) -> &Position { &self.position }
fn collect(&mut self, player: &mut Player) {
player.change_life(self.health.try_into().unwrap());