test promotion

This commit is contained in:
marce 2025-05-22 10:16:29 +02:00
parent 216d7cf153
commit dd8b55e2a3
2 changed files with 11 additions and 4 deletions

View File

@ -404,18 +404,16 @@ public class Board implements Cloneable {
// Remove the piece from its original location
pieces.remove(pieceToMove);
// --- Pawn Promotion Logic (Your existing logic is here and correct for your pawn setup) ---
if (pieceToMove.getType() == PieceType.Pawn) {
if ((pieceToMove.isWhite() && move.getToRow() == 0) || (!pieceToMove.isWhite() && move.getToRow() == 7)) {
// Promote the pawn to a queen
Piece promotedPiece = makeNewPiece(PieceType.Queen, pieceToMove.isWhite(), move.getToCol(), move.getToRow());
pieces.add(promotedPiece);
// Update turn info
turnIsWhite = !turnIsWhite;
turnNumber++;
// Play move sound if enabled
playMoveSound();
return;
}

View File

@ -0,0 +1,9 @@
BR,BN,BB,BQ,BK,BB,BN,BR
,BP,BP,BP,BP,BP,WP,BP
,,,,,,,
,,,,,,,
,,,,,,,
,,,,,,,
WP,BP,WP,WP,WP,WP,WP,
WR,WN,WB,WQ,WK,WB,WN,WR
W