2019-07-01 19:08:37 +02:00
|
|
|
package dev.kske.chess;
|
|
|
|
|
2019-07-01 19:50:42 +02:00
|
|
|
import dev.kske.chess.piece.Bishop;
|
|
|
|
import dev.kske.chess.piece.King;
|
|
|
|
import dev.kske.chess.piece.Knight;
|
|
|
|
import dev.kske.chess.piece.Pawn;
|
|
|
|
import dev.kske.chess.piece.Piece;
|
|
|
|
import dev.kske.chess.piece.Piece.Color;
|
|
|
|
import dev.kske.chess.piece.Queen;
|
|
|
|
import dev.kske.chess.piece.Rook;
|
2019-07-01 19:37:15 +02:00
|
|
|
|
2019-07-01 19:08:37 +02:00
|
|
|
/**
|
|
|
|
* Project: <strong>Chess</strong><br>
|
|
|
|
* File: <strong>Board.java</strong><br>
|
|
|
|
* Created: <strong>01.07.2019</strong><br>
|
|
|
|
* Author: <strong>Kai S. K. Engelbart</strong>
|
|
|
|
*/
|
|
|
|
public class Board {
|
|
|
|
|
|
|
|
private Piece[][] boardArr;
|
|
|
|
|
|
|
|
public Board() {
|
2019-07-01 19:37:15 +02:00
|
|
|
boardArr = new Piece[8][8];
|
2019-07-01 19:08:37 +02:00
|
|
|
initializeDefaultPositions();
|
|
|
|
}
|
|
|
|
|
2019-07-01 19:50:42 +02:00
|
|
|
/**
|
|
|
|
* Initialized the board array with the default chess pieces and positions.
|
|
|
|
*/
|
2019-07-01 19:08:37 +02:00
|
|
|
private void initializeDefaultPositions() {
|
2019-07-01 19:37:15 +02:00
|
|
|
// Initialize pawns
|
|
|
|
for (int i = 0; i < 8; i++) {
|
|
|
|
boardArr[i][1] = new Pawn(Color.BLACK);
|
|
|
|
boardArr[i][6] = new Pawn(Color.WHITE);
|
|
|
|
}
|
2019-07-01 19:50:42 +02:00
|
|
|
|
|
|
|
// Initialize kings
|
|
|
|
boardArr[4][0] = new King(Color.BLACK);
|
|
|
|
boardArr[4][7] = new King(Color.WHITE);
|
|
|
|
|
|
|
|
// Initialize queens
|
|
|
|
boardArr[3][0] = new Queen(Color.BLACK);
|
|
|
|
boardArr[3][7] = new Queen(Color.WHITE);
|
|
|
|
|
|
|
|
// Initialize rooks
|
|
|
|
boardArr[0][0] = new Rook(Color.BLACK);
|
|
|
|
boardArr[0][7] = new Rook(Color.WHITE);
|
|
|
|
boardArr[7][0] = new Rook(Color.BLACK);
|
|
|
|
boardArr[7][7] = new Rook(Color.WHITE);
|
|
|
|
|
|
|
|
// Initialize knights
|
|
|
|
boardArr[1][0] = new Knight(Color.BLACK);
|
|
|
|
boardArr[1][7] = new Knight(Color.WHITE);
|
|
|
|
boardArr[6][0] = new Knight(Color.BLACK);
|
|
|
|
boardArr[6][7] = new Knight(Color.WHITE);
|
|
|
|
|
|
|
|
// Initialize bishops
|
|
|
|
boardArr[2][0] = new Bishop(Color.BLACK);
|
|
|
|
boardArr[2][7] = new Bishop(Color.WHITE);
|
|
|
|
boardArr[5][0] = new Bishop(Color.BLACK);
|
|
|
|
boardArr[5][7] = new Bishop(Color.WHITE);
|
2019-07-01 19:08:37 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @return the board array
|
|
|
|
*/
|
|
|
|
public Piece[][] getBoardArr() { return boardArr; }
|
|
|
|
}
|