Git commit b8117482d3a6401fdcdcfd51ea3306fe8689d4cb by Miha Čančula. Committed on 06/03/2011 at 20:21. Pushed by mihac into branch 'master'. Set the Move::Check flag in checkSpecialMoves() M +1 -0 src/gamemanager.cpp M +21 -0 src/rules/chessrules.cpp http://commits.kde.org/knights/b8117482d3a6401fdcdcfd51ea3306fe8689d4cb diff --git a/src/gamemanager.cpp b/src/gamemanager.cpp index 4195f23..c6dd58b 100644 --- a/src/gamemanager.cpp +++ b/src/gamemanager.cpp @@ -602,6 +602,7 @@ void Manager::sendPendingMove() Protocol::byColor ( oppositeColor ( d->activePlayer ) )->move ( pendingMove ); emit pieceMoved ( pendingMove ); rules()->moveMade ( pendingMove ); + if ( Settings::speakOpponentsMoves() && !Protocol::byColor(d->activePlayer)->isLocal() && Protocol::byColor(oppositeColor(d->activePlayer))->isLocal() ) diff --git a/src/rules/chessrules.cpp b/src/rules/chessrules.cpp index d500377..48cabc9 100644 --- a/src/rules/chessrules.cpp +++ b/src/rules/chessrules.cpp @@ -496,6 +496,27 @@ void ChessRules::checkSpecialFlags ( Move* move, Color color ) } } } + + /** + * Check for check after the move has been made + */ + Grid afterMoveGrid = *m_grid; + afterMoveGrid.insert(move->to(), afterMoveGrid.take(move->from())); + + Grid::ConstIterator it = afterMoveGrid.constBegin(); + Grid::ConstIterator end = afterMoveGrid.constEnd(); + + const Color kingColor = oppositeColor ( color ); + + for ( ; it != end; ++it ) + { + + if ( it.value()->color() == color && + legalAttackMoves ( it.key(), &afterMoveGrid ).contains ( Move ( it.key(), kingPos[kingColor] ) ) ) + { + move->setFlag ( Move::Check, true ); + } + } if ( move->flag(Move::Take) ) {