Advertisement
Guest User

Untitled

a guest
Jun 18th, 2019
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. function canMove(x,y){
  2. var direction = rovers[actualRover].direction;
  3.  
  4. switch(direction){
  5. case 'N':
  6. if(grid[x - 1][y] === 'obstacle'){
  7. console.log('Ups! You can't forward in this direction, there is a obstacle.');
  8. return false;
  9. }else if(grid[x - 1][y].includes('rover')){
  10. console.log('Ups! You can't forward in this direction, there is an another Rover.');
  11. return false;
  12. }else if(grid[x - 1] <= 0){
  13. console.log('Ups! You can't exit outside of area!');
  14. return false;
  15. }else if(grid[x - 1][y] === null){
  16. return true;
  17. }
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement