Add missing move checks

This commit is contained in:
Adrian Heine 2021-07-22 20:08:43 +02:00
parent 3b1db890b7
commit 6eb184c6ae

View file

@ -102,7 +102,10 @@ impl ActualWorld {
match mv {
Move::Noop => {}
Move::TryTag(other_id) => {
// FIXME check distance
let my_pos = self.state.agent_positions.get(&id).unwrap();
let other_pos = self.state.agent_positions.get(&other_id).unwrap();
assert!((my_pos.x - other_pos.x).abs() <= 1);
assert!((my_pos.y - other_pos.y).abs() <= 1);
assert_eq!(self.state.tagged, id);
assert_ne!(self.state.tagged_by, Some(*other_id));
assert!(
@ -111,7 +114,8 @@ impl ActualWorld {
);
}
Move::TryMove(dir) => {
// FIXME check speed
assert!(dir.x.abs() <= 1);
assert!(dir.y.abs() <= 1);
let pos = self.state.agent_positions.get(&id).unwrap();
let size = &self.size;
assert!(pos.x + dir.x > 0);