From 6e2441aad1578f53ec74b3572838871be2935eae Mon Sep 17 00:00:00 2001 From: Joachim Lusiardi Date: Sat, 9 Dec 2023 20:05:39 +0100 Subject: [PATCH] give different artifacts differen looks --- src/artifacts.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/artifacts.rs b/src/artifacts.rs index 9c3043f..78f1123 100644 --- a/src/artifacts.rs +++ b/src/artifacts.rs @@ -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());