give different artifacts differen looks
This commit is contained in:
		
							parent
							
								
									4a024a47d9
								
							
						
					
					
						commit
						6e2441aad1
					
				@ -1,8 +1,10 @@
 | 
				
			|||||||
 | 
					use ratatui::style::Color;
 | 
				
			||||||
use crate::position::Position;
 | 
					use crate::position::Position;
 | 
				
			||||||
use crate::player::Player;
 | 
					use crate::player::Player;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
pub trait Artifact {
 | 
					pub trait Artifact {
 | 
				
			||||||
    //! An artifact that can be collected by the player
 | 
					    //! An artifact that can be collected by the player
 | 
				
			||||||
 | 
					    fn get_representation(&self) -> (&str, Color);
 | 
				
			||||||
    /// get the position of the artifact in the level
 | 
					    /// get the position of the artifact in the level
 | 
				
			||||||
    fn get_immutable_position(&self) -> &Position;
 | 
					    fn get_immutable_position(&self) -> &Position;
 | 
				
			||||||
    /// call to apply the effects of the artifact to the player
 | 
					    /// call to apply the effects of the artifact to the player
 | 
				
			||||||
@ -25,6 +27,10 @@ impl Chest {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl Artifact for Chest {
 | 
					impl Artifact for Chest {
 | 
				
			||||||
 | 
					    fn get_representation(&self) -> (&str, Color) {
 | 
				
			||||||
 | 
					        ("C", Color::Blue)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    fn get_immutable_position(&self) -> &Position { &self.position }
 | 
					    fn get_immutable_position(&self) -> &Position { &self.position }
 | 
				
			||||||
    fn collect(&mut self, player: &mut Player) {
 | 
					    fn collect(&mut self, player: &mut Player) {
 | 
				
			||||||
        player.retrieve_gold(self.gold);
 | 
					        player.retrieve_gold(self.gold);
 | 
				
			||||||
@ -48,6 +54,9 @@ impl Potion {
 | 
				
			|||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
impl Artifact for Potion {
 | 
					impl Artifact for Potion {
 | 
				
			||||||
 | 
					    fn get_representation(&self) -> (&str, Color) {
 | 
				
			||||||
 | 
					        ("P", Color::Green)
 | 
				
			||||||
 | 
					    }
 | 
				
			||||||
    fn get_immutable_position(&self) -> &Position { &self.position }
 | 
					    fn get_immutable_position(&self) -> &Position { &self.position }
 | 
				
			||||||
    fn collect(&mut self, player: &mut Player) {
 | 
					    fn collect(&mut self, player: &mut Player) {
 | 
				
			||||||
        player.change_life(self.health.try_into().unwrap());
 | 
					        player.change_life(self.health.try_into().unwrap());
 | 
				
			||||||
 | 
				
			|||||||
		Loading…
	
		Reference in New Issue
	
	Block a user