Monsters can move
This commit is contained in:
parent
1ba1ed7de4
commit
209a277684
20
src/level.rs
20
src/level.rs
|
@ -178,3 +178,23 @@ fn test_discover_get_monster() {
|
|||
m.decrease_life(2);
|
||||
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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue