Browse Source

Add missing move checks

main
Adrian Heine 3 years ago
parent
commit
6eb184c6ae
  1. 8
      src/world.rs

8
src/world.rs

@ -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);

Loading…
Cancel
Save