Exemplo n.º 1
0
 public static boolean isLineAvailableBetweenBoxes(Board board, Box box1, Box box2) {
   if (!areNeighborBoxes(box1, box2)) return false;
   int x = (box1.getColumn() + box2.getColumn()) / 2;
   int y = (box1.getRow() + box2.getRow()) / 2;
   Line line = board.getLineByCoordinate(x, y);
   return line != null && line.getOwner() == null;
 }
Exemplo n.º 2
0
  public static List<Line> getLinesSurroundingBox(Board board, Box box) {
    int x = box.getColumn();
    int y = box.getRow();

    int surroundingLines[][] = {
      {x - 1, y},
      {x + 1, y},
      {x, y - 1},
      {x, y + 1}
    };

    return Arrays.stream(surroundingLines)
        .map(coords -> board.getLineByCoordinate(coords[0], coords[1]))
        .filter(line -> line != null)
        .collect(Collectors.toList());
  }