void ChessGame::stop(bool emitMoveChanged) { if (m_finished) return; m_finished = true; emit humanEnabled(false); if (!m_gameInProgress) { m_result = Chess::Result(); finish(); return; } initializePgn(); m_gameInProgress = false; const QVector<PgnGame::MoveData>& moves(m_pgn->moves()); int plies = moves.size(); m_pgn->setTag("PlyCount", QString::number(plies)); m_pgn->setResult(m_result); m_pgn->setResultDescription(m_result.description()); if (emitMoveChanged && plies > 1) { const PgnGame::MoveData& md(moves.at(plies - 1)); emit moveChanged(plies - 1, md.move, md.moveString, md.comment); } m_player[Chess::Side::White]->endGame(m_result); m_player[Chess::Side::Black]->endGame(m_result); connect(this, SIGNAL(playersReady()), this, SLOT(finish()), Qt::QueuedConnection); syncPlayers(); }
void ChessGame::stop() { if (m_finished) return; m_finished = true; emit humanEnabled(false); if (!m_gameInProgress) { m_result = Chess::Result(); finish(); return; } m_gameInProgress = false; m_pgn->setTag("PlyCount", QString::number(m_pgn->moves().size())); m_pgn->setResult(m_result); m_pgn->setResultDescription(m_result.description()); m_player[Chess::Side::White]->endGame(m_result); m_player[Chess::Side::Black]->endGame(m_result); connect(this, SIGNAL(playersReady()), this, SLOT(finish()), Qt::QueuedConnection); syncPlayers(); }