1
Fork 0
mirror of https://github.com/Quackster/Havana.git synced 2025-07-03 05:07:46 +00:00

Add queen promotion in chess

This commit is contained in:
Rafael Damasceno 2023-01-17 15:44:01 +00:00
parent a0ca83c1c1
commit 986621b73a

View file

@ -151,6 +151,10 @@ public class GameChess extends GamehallGame {
var moveList = MoveGenerator.generateLegalMoves(this.board);
isLegalMove = moveList.contains(move);//.stream().anyMatch(m -> m.getFrom() == fromSquare && m.getTo() == toSquare);
if (!isLegalMove && Board.isPromoRank(this.board.getSideToMove(), move)) { // if the move is not legal, check if pawn promotion is legal
move = new Move(fromSquare, toSquare, Piece.make(this.board.getSideToMove(), PieceType.QUEEN));
isLegalMove = moveList.contains(move);
}
} catch (MoveGeneratorException e) { }
if (isLegalMove) {