castling bug really fixed

This commit is contained in:
gwitt 2025-05-22 18:25:03 +02:00
parent da59350569
commit 6cb9135501
1 changed files with 11 additions and 11 deletions

View File

@ -759,14 +759,14 @@ public class Board {
boolean occupiedLeftLine = true;
boolean occupiedRightLine = true;
for(int i = 4; i > 0; i--) {
if (positionOccupied(i,pieces.get(indexPieceSelect).getY()) == true) {
for(int i1 = 3; i1 > 0; i1--) {
if (positionOccupied(i1,pieces.get(indexPieceSelect).getY()) == true) {
nbOccupied = nbOccupied + 1;
}
if (nbOccupied == 0) {
occupiedLeftLine=false;
}
}
if (nbOccupied == 0) {
occupiedLeftLine=false;
}
if (occupiedLeftLine == false) {//check if the castling is possible with the rooks on the left
if (kingWMoved == false && rookLWMoved == false && x==0 && y==7 && pieces.get(whatPiece(0,7)).isWhite() == pieces.get(indexPieceSelect).isWhite()) {
toHighlight.get(0).add(x);
@ -783,14 +783,14 @@ public class Board {
}
}
nbOccupied = 0;
for(int i = 4; i < 7; i++) {
if (positionOccupied(i,pieces.get(indexPieceSelect).getY()) == true) {
for(int i2 = 5; i2 < 7; i2++) {
if (positionOccupied(i2,pieces.get(indexPieceSelect).getY()) == true) {
nbOccupied = nbOccupied + 1;
}
if (nbOccupied == 0) {
occupiedRightLine=false;
}
}
}
if (nbOccupied == 0) {
occupiedRightLine=false;
}
if (occupiedRightLine == false) {//check if the castling is possible with the rooks on the right
if (kingWMoved == false && rookRWMoved == false && x==7 && y==7 && pieces.get(whatPiece(7,7)).isWhite() == pieces.get(indexPieceSelect).isWhite()) {
toHighlight.get(0).add(x);