Пример #1
0
  public void addFreeSquares(ArrayList<Point> points) { // add all squares
    for (int i = 0; i < GRID_WIDTH; i++) {
      for (int j = 0; j < GRID_HEIGHT; j++) {
        points.add(new Point(i, j));
      }
    }

    // remove all pieces
    for (Piece piece : game.getPieces()) {
      if (!piece.isOut()) {
        points.remove(piece.getLocation());
      }
    }
  }
Пример #2
0
 void removeFriendsAndBorders(Piece piece, ArrayList<Point> points) {
   boolean up = piece.isUp();
   for (Iterator<Point> it = points.iterator(); it.hasNext(); ) {
     Point point = it.next();
     if (point != Poussin.PROMOTING
         && (point.x < 0 || point.y < 0 || point.x >= GRID_WIDTH || point.y >= GRID_HEIGHT)) {
       it.remove();
       continue;
     }
     Piece pieceOnSquare = getPosition().getPiece(point.x, point.y);
     if (pieceOnSquare != null && pieceOnSquare.isUp() == up) it.remove();
   }
 }