pawn promotion for white pawns progress, doesnt work
This commit is contained in:
parent
3e610d6fba
commit
a0573a5ef8
|
|
@ -20,15 +20,21 @@ public class Move {
|
|||
Piece movingPiece = null ; // initializing variable to work with and store it
|
||||
PieceType type = null;
|
||||
boolean color = true;
|
||||
|
||||
int yCord = -1;
|
||||
for (Piece piece : pieces) { // iterate trough all pieces
|
||||
|
||||
if(piece.getX() == selectX && piece.getY() == selectY) { // if the coordinates selected and the coordinate of a piece on the board matches, the loop will activate
|
||||
movingPiece = piece; //storing in memory the piece
|
||||
type = movingPiece.getType();
|
||||
color = movingPiece.isWhite();
|
||||
|
||||
|
||||
if (board.isAPieceThere(toX, toY)){//checking if a piece is at the arrival coordinates
|
||||
needPieceDeletion(toX, toY); //if a piece is at arrival coord, remove the piece
|
||||
}
|
||||
if(type == PieceType.Pawn && color == true && yCord == 0) {
|
||||
pawnPromotion(movingPiece);
|
||||
}
|
||||
movingPiece.setX(toX); // change coordinates to the new coordinate
|
||||
movingPiece.setY(toY);
|
||||
break;
|
||||
|
|
@ -46,7 +52,7 @@ public class Move {
|
|||
}
|
||||
}
|
||||
}
|
||||
private void pawnPromotion(int x) {
|
||||
|
||||
private void pawnPromotion(Piece piece) {
|
||||
piece.setType(PieceType.Queen);
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue