Commit ce7a9b46 authored by David Kaye's avatar David Kaye Committed by Alexander Semke
Browse files

Don't allow to perform castling if the non-moved rook was already

captured and its position is occupied by another piece.

BUG: 430403
FIXED-IN: 22.08
parent d7880a9a
Pipeline #164400 passed with stage
in 2 minutes and 5 seconds
......@@ -460,9 +460,9 @@ QList< Move > ChessRules::castlingMoves ( const Pos& pos ) {
Color color = m_grid->value ( pos )->color();
if ( hasKingMoved ( color ) )
return QList<Move>();
if ( !hasRookMoved ( color, Move::QueenSide ) && isPathClearForCastling ( pos, queenRookStartPos[color] ) )
if ( !hasRookMoved ( color, Move::QueenSide ) && isPathClearForCastling ( pos, queenRookStartPos[color] ) && ( m_grid->value ( queenRookStartPos[color] )->pieceType() == Rook ) )
moves << Move::castling ( Move::QueenSide, color );
if ( !hasRookMoved ( color, Move::KingSide ) && isPathClearForCastling ( pos, kingRookStartPos[color] ) )
if ( !hasRookMoved ( color, Move::KingSide ) && isPathClearForCastling ( pos, kingRookStartPos[color] ) && ( m_grid->value ( kingRookStartPos[color] )->pieceType() == Rook ) )
moves << Move::castling ( Move::KingSide, color );
return moves;
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment