- Completed the enPassant method

This commit is contained in:
willo 2025-05-15 22:45:54 +02:00
parent 6b0cc0e0c4
commit d44c79b817
1 changed files with 12 additions and 11 deletions

View File

@ -11,13 +11,13 @@ public class MovementCapabilities {
boolean isWhite = piece.isWhite();
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) {
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) {
Piece lastMoved = last.getPieceMoved();
@ -29,16 +29,17 @@ public class MovementCapabilities {
boolean sameX = last.getNewX()== x;
boolean sameY = last.getNewY()== currentY;
System.out.println("🔍 isPawn: " + isPawn);
System.out.println("🔍 isEnemy: " + isOpp);
System.out.println("🔍 movedTwo: " + movedTwo);
System.out.println("🔍 sameY: " + sameY);
System.out.println("🔍 sameX: " + sameX);
/*
* System.out.println(" isPawn: " + isPawn); System.out.println(" isEnemy: " +
* isOpp); System.out.println(" movedTwo: " + movedTwo);
* System.out.println(" sameY: " + sameY); System.out.println(" sameX: " +
* sameX);
*/
// to check if each condition is valid in the console
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.setPiece(false, null, x, currentY);
//board.setPiece(false, null, x, currentY); // DIDN'T WORK --> instead used removePiece method
board.removePiece(x, currentY);
return true;
}