/**
  * Return true if t0 and t1 are neighbours.
  *
  * @param t0 tile 1.
  * @param t1 tile 2.
  * @return true if t0 and t1 are next to each other.
  */
 public boolean isNeighbour(Tile t0, Tile t1) {
   if (Math.abs(t0.getX() - t1.getX()) == 1 && Math.abs(t0.getY() - t1.getY()) == 0) {
     return true;
   }
   if (Math.abs(t0.getX() - t1.getX()) == 0 && Math.abs(t0.getY() - t1.getY()) == 1) {
     return true;
   }
   return false;
 }
 /**
  * Gets the tiles that need to be deleted due to the detonating of the flame gem.
  *
  * @param tile the flame gem
  * @return tiles, the list of tiles to be deleted.
  */
 public List<Tile> getTilesToDeleteFlame(Tile tile) {
   final Point[] translations = {
     new Point(-1, 0),
     new Point(1, 1),
     new Point(0, 1),
     new Point(-1, 1),
     new Point(1, 0),
     new Point(-1, -1),
     new Point(0, -1),
     new Point(1, -1)
   };
   tile.detonate = true;
   List<Tile> tiles =
       Arrays.stream(translations)
           .map(p -> new Point(tile.getX() + p.x, tile.getY() + p.y))
           .filter(p -> board.validBorders(p.x, p.y))
           .map(p -> board.getTileAt(p.x, p.y))
           .filter(t -> !t.detonate)
           .collect(Collectors.toList());
   checkForSpecialTile(tiles);
   if (!tiles.contains(tile)) {
     tiles.add(tile);
   }
   return tiles;
 }
  /**
   * Switch tile t0 and t1 on the board.
   *
   * @param t0 first tile to swap
   * @param t1 second tile to swap
   */
  public void swappedTiles(Tile t0, Tile t1) {
    Tile temp = board.getTileAt(t0.getX(), t0.getY());
    board.setTileAt(board.getTileAt(t1.getX(), t1.getY()), t0.getX(), t0.getY());
    board.setTileAt(temp, t1.getX(), t1.getY());

    int xc = t0.getX();
    int yc = t0.getY();
    t0.setLoc(t1.getX(), t1.getY());
    t1.setLoc(xc, yc);

    swappedTiles[0] = t0;
    swappedTiles[1] = t1;
  }
  /**
   * Gets the tiles that need to be deleted due to the detonating of the hypercube gem.
   *
   * @param tile the hypercube gem
   * @return tiles, the list of tiles to be deleted.
   */
  public List<Tile> getTilesToDeleteStar(Tile tile) {
    List<Tile> tiles = new ArrayList<Tile>();
    tile.detonate = true;
    tiles.add(tile);

    int tx = tile.getX();
    int ty = tile.getY();
    for (int col = 0; col < board.getHeight(); col++) {
      if (col != tx && !board.getTileAt(col, ty).detonate) {
        tiles.add(board.getTileAt(col, ty));
      }
    }
    for (int row = 0; row < board.getWidth(); row++) {
      if (row != ty && !board.getTileAt(tx, row).detonate) {
        tiles.add(board.getTileAt(tx, row));
      }
    }
    checkForSpecialTile(tiles);
    return tiles;
  }