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,13 +759,13 @@ public class Board {
boolean occupiedLeftLine = true; boolean occupiedLeftLine = true;
boolean occupiedRightLine = true; boolean occupiedRightLine = true;
for(int i = 4; i > 0; i--) { for(int i1 = 3; i1 > 0; i1--) {
if (positionOccupied(i,pieces.get(indexPieceSelect).getY()) == true) { if (positionOccupied(i1,pieces.get(indexPieceSelect).getY()) == true) {
nbOccupied = nbOccupied + 1; 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 (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()) { if (kingWMoved == false && rookLWMoved == false && x==0 && y==7 && pieces.get(whatPiece(0,7)).isWhite() == pieces.get(indexPieceSelect).isWhite()) {
@ -783,13 +783,13 @@ public class Board {
} }
} }
nbOccupied = 0; nbOccupied = 0;
for(int i = 4; i < 7; i++) { for(int i2 = 5; i2 < 7; i2++) {
if (positionOccupied(i,pieces.get(indexPieceSelect).getY()) == true) { if (positionOccupied(i2,pieces.get(indexPieceSelect).getY()) == true) {
nbOccupied = nbOccupied + 1; 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 (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()) { if (kingWMoved == false && rookRWMoved == false && x==7 && y==7 && pieces.get(whatPiece(7,7)).isWhite() == pieces.get(indexPieceSelect).isWhite()) {