prb fix 1

This commit is contained in:
martinbst 2025-05-01 13:04:24 +02:00
parent b6d2dc4045
commit 5afdd7a5b3
6 changed files with 39 additions and 6 deletions

View File

@ -10,7 +10,13 @@ public class Bishop extends Piece {
@Override
public ArrayList<ArrayList<Boolean>> getPossibleMoves(ArrayList<ArrayList<Piece>> board) {
ArrayList<ArrayList<Boolean>> moves = new ArrayList<>();
// Delegate to the full method with null lastMove
return getPossibleMoves(board, null);
}
@Override
public ArrayList<ArrayList<Boolean>> getPossibleMoves(ArrayList<ArrayList<Piece>> board, Move lastMove) {
ArrayList<ArrayList<Boolean>> moves = new ArrayList<>();;
// Initialize 8x8 move grid with false
for (int i = 0; i < 8; i++) {

View File

@ -134,6 +134,8 @@ public class Board {
if (pieceToMove instanceof Pawn && x != xm && board.get(y).get(x) == null) {
// En passant capture
board.get(ym).set(x, null);
lastMove = new Move(xm, ym, x, y);
}
@ -211,6 +213,8 @@ public class Board {
select = true;
possibleMoves = kingCheck.getLegalMoves(board.get(y).get(x), board);
// possibleMoves = board.get(y).get(x).getPossibleMoves(board);
possibleMoves = board.get(y).get(x).getPossibleMoves(board, lastMove);//same as kingCheck
}
else if (select == true && this.xm != x || this.ym != y){
if (isHighlighted(x,y)) {
@ -225,7 +229,6 @@ public class Board {
select = false;
}
possibleMoves = board.get(y).get(x).getPossibleMoves(board, lastMove);//same as kingCheck
}

View File

@ -10,7 +10,13 @@ public class King extends Piece {
@Override
public ArrayList<ArrayList<Boolean>> getPossibleMoves(ArrayList<ArrayList<Piece>> board) {
ArrayList<ArrayList<Boolean>> moves = new ArrayList<>();
// Delegate to the full method with null lastMove
return getPossibleMoves(board, null);
}
@Override
public ArrayList<ArrayList<Boolean>> getPossibleMoves(ArrayList<ArrayList<Piece>> board, Move lastMove) {
ArrayList<ArrayList<Boolean>> moves = new ArrayList<>();
// Initialize 8x8 move grid with false
for (int i = 0; i < 8; i++) {

View File

@ -10,7 +10,13 @@ public class Knight extends Piece {
@Override
public ArrayList<ArrayList<Boolean>> getPossibleMoves(ArrayList<ArrayList<Piece>> board) {
ArrayList<ArrayList<Boolean>> moves = new ArrayList<>();
// Delegate to the full method with null lastMove
return getPossibleMoves(board, null);
}
@Override
public ArrayList<ArrayList<Boolean>> getPossibleMoves(ArrayList<ArrayList<Piece>> board, Move lastMove) {
ArrayList<ArrayList<Boolean>> moves = new ArrayList<>();
// Initialize empty move grid
for (int i = 0; i < 8; i++) {

View File

@ -10,7 +10,13 @@ public class Queen extends Piece {
@Override
public ArrayList<ArrayList<Boolean>> getPossibleMoves(ArrayList<ArrayList<Piece>> board) {
ArrayList<ArrayList<Boolean>> moves = new ArrayList<>();
// Delegate to the full method with null lastMove
return getPossibleMoves(board, null);
}
@Override
public ArrayList<ArrayList<Boolean>> getPossibleMoves(ArrayList<ArrayList<Piece>> board, Move lastMove) {
ArrayList<ArrayList<Boolean>> moves = new ArrayList<>();
// Initialize 8x8 move grid with false
for (int i = 0; i < 8; i++) {

View File

@ -10,7 +10,13 @@ public class Rook extends Piece {
@Override
public ArrayList<ArrayList<Boolean>> getPossibleMoves(ArrayList<ArrayList<Piece>> board) {
ArrayList<ArrayList<Boolean>> moves = new ArrayList<>();
// Delegate to the full method with null lastMove
return getPossibleMoves(board, null);
}
@Override
public ArrayList<ArrayList<Boolean>> getPossibleMoves(ArrayList<ArrayList<Piece>> board, Move lastMove) {
ArrayList<ArrayList<Boolean>> moves = new ArrayList<>();
// Initialize empty move grid
for (int i = 0; i < 8; i++) {