Monsters can move
This commit is contained in:
parent
1ba1ed7de4
commit
209a277684
22
src/level.rs
22
src/level.rs
@ -169,7 +169,7 @@ fn test_discover_get_monster() {
|
||||
m.get_position().set(0, 10, 10);
|
||||
assert_eq!(l.add_monster(m), Ok(()));
|
||||
|
||||
let elem =l.get_element(10, 10);
|
||||
let elem = l.get_element(10, 10);
|
||||
assert_eq!(elem.0.unwrap(), StructureElement::Floor);
|
||||
assert!(elem.1.is_some());
|
||||
let m = elem.1.unwrap();
|
||||
@ -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
Block a user