remove of yCord variable, pawn promotion works !
This commit is contained in:
parent
32f43bed0d
commit
ab4e2b2d32
|
|
@ -20,19 +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();
|
||||
yCord = movingPiece.getY();
|
||||
|
||||
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) {
|
||||
if(type == PieceType.Pawn && color == true && toY == 0) {
|
||||
pawnPromotion(movingPiece);
|
||||
}
|
||||
if(type == PieceType.Pawn && color == false && toY == 7) {
|
||||
pawnPromotion(movingPiece);
|
||||
}
|
||||
movingPiece.setX(toX); // change coordinates to the new coordinate
|
||||
|
|
|
|||
Loading…
Reference in New Issue