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:
parent
a0ca83c1c1
commit
986621b73a
1 changed files with 4 additions and 0 deletions
|
@ -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) {
|
||||
|
|
Loading…
Add table
Reference in a new issue