public void moveTo(int checkmobx, int checkmoby) {
   MapSquare oldms = currentMap.getMapSquare(mobx, moby);
   if (oldms != null) {
     oldms.setMobile(null);
   }
   mobx = checkmobx;
   moby = checkmoby;
   MapSquare newms = currentMap.getMapSquare(mobx, moby);
   newms.setMobile(this);
 }
  public boolean canMoveTo(int x, int y) {

    if (!currentMap.inBounds(x, y)) {
      return false;
    }

    // figure out if there's a wall in the way between our
    // map square and the map square at x,y
    MapSquare currentMS = currentMap.getMapSquare(mobx, moby);
    MapSquare checkMS = currentMap.getMapSquare(x, y);

    // NORTH and SOUTH movement isn't dependent on facing
    Wall w = currentMS.findWall(Dir.NORTH);
    if (w != null && y < moby) {
      if (w.hasDoor() && w.isDoorOpen()) {
        return true;
      } else {
        return false;
      }
    }
    w = currentMS.findWall(Dir.SOUTH);
    if (w != null && y > moby) {
      if (w.hasDoor() && w.isDoorOpen()) {
        return true;
      } else {
        return false;
      }
    }
    w = checkMS.findWall(Dir.SOUTH);
    if (w != null && y < moby) {
      if (w.hasDoor() && w.isDoorOpen()) {
        return true;
      } else {
        return false;
      }
    }
    w = checkMS.findWall(Dir.NORTH);
    if (w != null && y > moby) {
      if (w.hasDoor() && w.isDoorOpen()) {
        return true;
      } else {
        return false;
      }
    }

    // EAST and WEST movment is dependent on facing
    if (facing == Dir.EAST) {
      w = currentMS.findWall(Dir.EAST);
      if (w != null && x > mobx) {
        if (w.hasDoor() && w.isDoorOpen()) {
          return true;
        } else {
          return false;
        }
      }
      w = checkMS.findWall(Dir.WEST);
      if (w != null && x > mobx) {
        if (w.hasDoor() && w.isDoorOpen()) {
          return true;
        } else {
          return false;
        }
      }
    } else {
      w = currentMS.findWall(Dir.WEST);
      if (w != null && x < mobx) {
        if (w.hasDoor() && w.isDoorOpen()) {
          return true;
        } else {
          return false;
        }
      }
      w = checkMS.findWall(Dir.EAST);
      if (w != null && x < mobx) {
        if (w.hasDoor() && w.isDoorOpen()) {
          return true;
        } else {
          return false;
        }
      }
    }

    return currentMap.inBounds(x, y);
  }