From e7b227ed268e8570518f9d1452b5e7d0d0a0ee32 Mon Sep 17 00:00:00 2001 From: Luis Ferro Date: Tue, 12 Nov 2019 14:23:00 +0100 Subject: Add player character in the map --- src/character.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'src/character.rs') diff --git a/src/character.rs b/src/character.rs index 3e6c4a7..a62c51f 100644 --- a/src/character.rs +++ b/src/character.rs @@ -6,12 +6,13 @@ pub struct Character { pub name: String, pub class: String, pub health: i32, + pub level: i32, + pub location: Point, max_health: i32, attack: i32, dodge: i32, luck: i32, xp: i32, - location: Point } pub trait Player { @@ -22,6 +23,7 @@ pub trait Player { attack: i32, dodge: i32, luck: i32, + level: i32, location: Point ) -> Character; @@ -59,6 +61,7 @@ impl Player for Character { attack: i32, dodge: i32, luck: i32, + level: i32, location: Point ) -> Character { Character { @@ -70,6 +73,7 @@ impl Player for Character { dodge: dodge, luck: luck, xp: 0, + level: 0, location: location } } @@ -86,6 +90,7 @@ impl Player for Character { self.attack, self.dodge, self.luck + player_luck, + 0, (0,0) ) } @@ -139,7 +144,7 @@ mod tests { use super::*; fn test_attack() { - let player = Character::new("".to_string(), "Rogue".to_string(), 1, 4, 1, 4, (0,0)); + let player = Character::new("".to_string(), "Rogue".to_string(), 1, 4, 1, 4, 0,(0,0)); assert_eq!(player.attack(), 6); } -- cgit v1.2.3