|
|
|
|
@ -16,17 +16,17 @@ public class Board {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getWidth() {
|
|
|
|
|
width = 8; // setting the width at 8 for the moment can be changed
|
|
|
|
|
//width = 8; // setting the width at 8 for the moment can be changed
|
|
|
|
|
return width;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getHeight() {
|
|
|
|
|
height = 8; // setting the height at 8 for the moment can be changed
|
|
|
|
|
//height = 8; // setting the height at 8 for the moment can be changed
|
|
|
|
|
return height;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int getTurnNumber() {
|
|
|
|
|
turn = 0; // initializing turn at 0
|
|
|
|
|
turn =-1; // initializing turn at 0
|
|
|
|
|
for (int i = 0; i<=n; i++) { // starting the loop for the counter
|
|
|
|
|
turn += 1; // Add +1 to turn for the counter after each pawns moved
|
|
|
|
|
} // end of the loops
|
|
|
|
|
@ -34,8 +34,7 @@ public class Board {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isTurnWhite() {
|
|
|
|
|
//TODO
|
|
|
|
|
return false;
|
|
|
|
|
return turn % 2 == 0; // White starts on turn 0 and only even turns
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void setPiece(boolean isWhite, PieceType type, int x, int y) {
|
|
|
|
|
@ -51,45 +50,38 @@ public class Board {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void populateBoard() {
|
|
|
|
|
/*
|
|
|
|
|
// Place Rooks
|
|
|
|
|
board[0][0] = new Rook(PieceColor.BLACK, new Position(0, 0));
|
|
|
|
|
board[0][7] = new Rook(PieceColor.BLACK, new Position(0, 7));
|
|
|
|
|
board[7][0] = new Rook(whitePiece, new Position(7, 0));
|
|
|
|
|
board[7][7] = new Rook(whitePiece, new Position(7, 7));
|
|
|
|
|
board[0][0] = new Piece(false, PieceType.Rook, 0, 0); //color, piece , x -> , y |
|
|
|
|
|
board[0][7] = new Piece(true, PieceType.Rook, 0, 7);
|
|
|
|
|
board[7][0] = new Piece(false, PieceType.Rook, 7, 0);
|
|
|
|
|
board[7][7] = new Piece(true, PieceType.Rook, 7, 7);
|
|
|
|
|
// Place Knights
|
|
|
|
|
board[0][1] = new Knight(PieceColor.BLACK, new Position(0, 1));
|
|
|
|
|
board[0][6] = new Knight(PieceColor.BLACK, new Position(0, 6));
|
|
|
|
|
board[7][1] = new Knight(whitePiece, new Position(7, 1));
|
|
|
|
|
board[7][6] = new Knight(whitePiece, new Position(7, 6));
|
|
|
|
|
board[1][0] = new Piece(false, PieceType.Knight, 1, 0);
|
|
|
|
|
board[1][7] = new Piece(true, PieceType.Knight, 1, 7);
|
|
|
|
|
board[6][0] = new Piece(false, PieceType.Knight, 6, 0);
|
|
|
|
|
board[6][7] = new Piece(true, PieceType.Knight, 6, 7);
|
|
|
|
|
// Place Bishops
|
|
|
|
|
board[0][2] = new Bishop(PieceColor.BLACK, new Position(0, 2));
|
|
|
|
|
board[0][5] = new Bishop(PieceColor.BLACK, new Position(0, 5));
|
|
|
|
|
board[7][2] = new Bishop(whitePiece, new Position(7, 2));
|
|
|
|
|
board[7][5] = new Bishop(whitePiece, new Position(7, 5));
|
|
|
|
|
board[2][0] = new Piece(false, PieceType.Bishop, 2, 0);
|
|
|
|
|
board[2][7] = new Piece(true, PieceType.Bishop, 2, 7);
|
|
|
|
|
board[5][0] = new Piece(false, PieceType.Bishop, 5, 0);
|
|
|
|
|
board[5][7] = new Piece(true, PieceType.Bishop, 5, 7);
|
|
|
|
|
// Place Queens
|
|
|
|
|
board[0][3] = new Queen(PieceColor.BLACK, new Position(0, 3));
|
|
|
|
|
board[7][3] = new Queen(whitePiece, new Position(7, 3));
|
|
|
|
|
board[4][0] = new Piece(false, PieceType.Queen, 4, 0);
|
|
|
|
|
board[4][7] = new Piece(true, PieceType.Queen, 4, 7);
|
|
|
|
|
// Place Kings
|
|
|
|
|
board[0][4] = new King(PieceColor.BLACK, new Position(0, 4));
|
|
|
|
|
board[7][4] = new King(whitePiece, new Position(7, 4));
|
|
|
|
|
board[3][0] = new Piece(false, PieceType.King, 3, 0);
|
|
|
|
|
board[3][7] = new Piece(true, PieceType.King, 3, 7);
|
|
|
|
|
// Place Pawns
|
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
|
board[1][i] = new Pawn(PieceColor.BLACK, new Position(1, i));
|
|
|
|
|
board[6][i] = new Pawn(whitePiece, new Position(6, i));
|
|
|
|
|
}*/
|
|
|
|
|
board[i][1] = new Piece(false, PieceType.Pawn, i, 1); //color, piece , x -> , y |
|
|
|
|
|
board[i][6] = new Piece(true, PieceType.Pawn, i, 6); //color, piece , x -> , y |
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void cleanBoard() {
|
|
|
|
|
//Cleaning the Board
|
|
|
|
|
for (int y = 0; y < 8; y++) {
|
|
|
|
|
for (int x = 0; x < 8; x++) {
|
|
|
|
|
board[y][x] = null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
public void cleanBoard() {
|
|
|
|
|
this.board = new Piece[width][height]; // should work ?
|
|
|
|
|
//this.isTurnWhite = true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
|
StringBuilder sb = new StringBuilder();
|
|
|
|
|
@ -118,7 +110,13 @@ public class Board {
|
|
|
|
|
|
|
|
|
|
public ArrayList<Piece> getPieces() {
|
|
|
|
|
ArrayList<Piece> pieces = new ArrayList<>();
|
|
|
|
|
//TODO
|
|
|
|
|
for (int i = 0; i < width; i++) {
|
|
|
|
|
for (int j = 0; j < height; j++) {
|
|
|
|
|
if (board[i][j] != null) {
|
|
|
|
|
pieces.add(board[i][j]);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return pieces;
|
|
|
|
|
}
|
|
|
|
|
|