This commit is contained in:
MSI 2025-04-18 16:57:52 +02:00
commit c016777f75
2 changed files with 31 additions and 37 deletions

View File

@ -45,36 +45,35 @@ public class Board {
public void populateBoard() { public void populateBoard() {
//Black pieces populating (x,y,type,color) //Black pieces populating
Board[1][1] = new Piece(1,1,'R','B'); Board[1][1] = new Piece(1,1,PieceType.Rook,false);
Board[2][1] = new Piece(2,1,'N','B'); Board[2][1] = new Piece(2,1,PieceType.Knight,false);
Board[3][1] = new Piece(3,1,'B','B'); Board[3][1] = new Piece(3,1,PieceType.Bishop,false);
Board[4][1] = new Piece(4,1,'Q','B'); Board[4][1] = new Piece(4,1,PieceType.Queen,false);
Board[7][1] = new Piece(5,1,'K','B'); Board[7][1] = new Piece(5,1,PieceType.King,false);
Board[6][1] = new Piece(6,1,'B','B'); Board[6][1] = new Piece(6,1,PieceType.Bishop,false);
Board[8][1] = new Piece(7,1,'N','B'); Board[8][1] = new Piece(7,1,PieceType.Knight,false);
Board[9][1] = new Piece(8,1,'R','B'); Board[9][1] = new Piece(8,1,PieceType.Rook,false);
for (int x = 1; x < 8; x++) { for (int x = 1; x < 8; x++) {
Board[x][2] = new Piece(x,2,'P','B'); //8 Pawns on second line Board[x][2] = new Piece(x,2,PieceType.Pawn,false);
} }
//White pieces populating
//White pieces populating (x,y,type,color) Board[1][8] = new Piece(1,8,PieceType.Rook,true);
Board[1][8] = new Piece(1,8,'R','W'); Board[2][8] = new Piece(2,8,PieceType.Knight,true);
Board[2][8] = new Piece(2,8,'N','W'); Board[3][8] = new Piece(3,8,PieceType.Bishop,true);
Board[3][8] = new Piece(3,8,'B','W'); Board[4][8] = new Piece(4,8,PieceType.Queen,true);
Board[4][8] = new Piece(4,8,'Q','W'); Board[7][8] = new Piece(5,8,PieceType.King,true);
Board[7][8] = new Piece(5,8,'K','W'); Board[6][8] = new Piece(6,8,PieceType.Bishop,true);
Board[6][8] = new Piece(6,8,'B','W'); Board[8][8] = new Piece(7,8,PieceType.Knight,true);
Board[8][8] = new Piece(7,8,'N','W'); Board[9][8] = new Piece(8,8,PieceType.Rook,true);
Board[9][8] = new Piece(8,8,'R','W');
for (int x = 1; x < 8; x++) { for (int x = 1; x < 8; x++) {
Board[x][7] = new Piece(x,7,'P','W'); //8 Pawns on second line
} Board[x][7] = new Piece(x,7,PieceType.Pawn,true);
}
} }
public void cleanBoard() { public void cleanBoard() {
for (int y = 1; y < 7; y++) { for (int y = 1; y < 7; y++) {

View File

@ -4,10 +4,10 @@ public class Piece {
private int x; private int x;
private int y; private int y;
private char type; private PieceType type;
private char color; private boolean color;
public Piece(int xP, int yP, char type_P, char color_P) { public Piece(int xP, int yP, PieceType type_P, boolean color_P) {
x = xP; x = xP;
y = yP; y = yP;
type = type_P; type = type_P;
@ -23,16 +23,11 @@ public class Piece {
} }
public PieceType getType() { public PieceType getType() {
return PieceType.fromSummary(type); return type;
} }
public boolean isWhite() { public boolean isWhite() {
if(color =='w') { return color;
return true;
}
else {
return false;
}
} }
} }