Monsters can move

This commit is contained in:
Joachim Lusiardi 2023-12-03 09:36:58 +01:00
parent 1ba1ed7de4
commit 209a277684
1 changed files with 21 additions and 1 deletions

View File

@ -178,3 +178,23 @@ fn test_discover_get_monster() {
m.decrease_life(2); m.decrease_life(2);
assert_eq!(l.get_element(10, 10).1.unwrap().get_life(), 21); assert_eq!(l.get_element(10, 10).1.unwrap().get_life(), 21);
} }
#[test]
fn test_discover_get_monster_can_move() {
let mut l = Level::new(0);
let p = Position::new(0, 10, 10);
l.discover(&p);
let mut m = Monster::new(23);
m.get_position().set(0, 10, 10);
l.add_monster(m).expect("Panic because of");
let m = l.get_element(10, 10).1.unwrap();
m.get_position().change(1, 1);
let m = l.get_element(10, 10).1;
assert!(m.is_none());
let m = l.get_element(11, 11).1;
assert!(m.is_some());
assert_eq!(m.unwrap().get_life(), 23);
}