- Completed the enPassant method
This commit is contained in:
parent
6b0cc0e0c4
commit
d44c79b817
|
|
@ -11,13 +11,13 @@ public class MovementCapabilities {
|
||||||
boolean isWhite = piece.isWhite();
|
boolean isWhite = piece.isWhite();
|
||||||
int direction = isWhite ? -1:1;
|
int direction = isWhite ? -1:1;
|
||||||
|
|
||||||
System.out.println("Checking en passant for pawn at " + currentX + "," + currentY + " to " + x + "," + y);
|
//System.out.println("Checking en passant for pawn at " + currentX + "," + currentY + " to " + x + "," + y);
|
||||||
|
// to check if the en passant conditions are met
|
||||||
|
|
||||||
if (Math.abs(x - currentX) == 1 && y == currentY + direction && board.getPiece(x, y)== null) {
|
if (Math.abs(x - currentX) == 1 && y == currentY + direction && board.getPiece(x, y)== null) {
|
||||||
Move last = board.getLastMove();
|
Move last = board.getLastMove();
|
||||||
|
|
||||||
System.out.println("Last move is " + last);
|
System.out.println("Last move is " + last); // Keeping record of the last move the
|
||||||
|
|
||||||
if (last != null) {
|
if (last != null) {
|
||||||
Piece lastMoved = last.getPieceMoved();
|
Piece lastMoved = last.getPieceMoved();
|
||||||
|
|
@ -29,16 +29,17 @@ public class MovementCapabilities {
|
||||||
boolean sameX = last.getNewX()== x;
|
boolean sameX = last.getNewX()== x;
|
||||||
boolean sameY = last.getNewY()== currentY;
|
boolean sameY = last.getNewY()== currentY;
|
||||||
|
|
||||||
System.out.println("🔍 isPawn: " + isPawn);
|
/*
|
||||||
System.out.println("🔍 isEnemy: " + isOpp);
|
* System.out.println(" isPawn: " + isPawn); System.out.println(" isEnemy: " +
|
||||||
System.out.println("🔍 movedTwo: " + movedTwo);
|
* isOpp); System.out.println(" movedTwo: " + movedTwo);
|
||||||
System.out.println("🔍 sameY: " + sameY);
|
* System.out.println(" sameY: " + sameY); System.out.println(" sameX: " +
|
||||||
System.out.println("🔍 sameX: " + sameX);
|
* sameX);
|
||||||
|
*/
|
||||||
|
// to check if each condition is valid in the console
|
||||||
if (isPawn && isOpp && movedTwo && sameX && sameY) {
|
if (isPawn && isOpp && movedTwo && sameX && sameY) {
|
||||||
System.out.println("✨ En passant conditions met!");
|
System.out.println(" En passant conditions met!");
|
||||||
board.movePiece(currentX, currentY, x, y);
|
board.movePiece(currentX, currentY, x, y);
|
||||||
//board.setPiece(false, null, x, currentY);
|
//board.setPiece(false, null, x, currentY); // DIDN'T WORK --> instead used removePiece method
|
||||||
board.removePiece(x, currentY);
|
board.removePiece(x, currentY);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue