Esempio n. 1
0
 private void initializeBaseBoard() {
   this.horizontal_size = baseBoard.getHorizontal_size();
   this.vertical_size = baseBoard.getVertical_size();
   this.board = new BasicBoardPiece[horizontal_size][vertical_size];
   this.size = this.horizontal_size * this.vertical_size;
   this.uuid = baseBoard.getUUID();
 }
Esempio n. 2
0
  @Override
  public boolean move(BoardPiece<T> piece, int horizontal, int vertical, Board<T> otherBoard) {
    BoardPiece<T> target = (BoardPiece<T>) otherBoard.getPieceAt(horizontal, vertical);

    if (piece.getUUID() != this.getUUID()) return false;

    if (target == null) return false;

    if (target.getMobilityStatus() != MobilityStatus.Free) return false;

    int tempHorizontal = piece.getHorizontal();
    int tempVertical = piece.getVertical();

    target.setValue(this.getDefaultValue());

    // swap the UUIDs
    UUID temp = target.getUUID();
    target.setUUID(piece.getUUID());
    piece.setUUID(temp);

    otherBoard.setPieceAt(horizontal, vertical, piece);
    this.setPieceAt(tempHorizontal, tempVertical, target);

    return true;
  }