From bcc2aedbff759a6222c5e17d855dfbec541f4028 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Fri, 5 Oct 2012 01:42:46 +0200 Subject: [PATCH] Improve the detection of finished games for duplicate and arbitration modes --- game/duplicate.cpp | 3 +-- game/freegame.cpp | 3 ++- game/freegame.h | 5 ++++- game/game.cpp | 1 - game/game.h | 2 -- qt/arbit_assignments.cpp | 5 +---- 6 files changed, 8 insertions(+), 11 deletions(-) diff --git a/game/duplicate.cpp b/game/duplicate.cpp index 926a480..a257044 100644 --- a/game/duplicate.cpp +++ b/game/duplicate.cpp @@ -160,7 +160,7 @@ void Duplicate::start() bool Duplicate::isFinished() const { - return m_finished; + return !canDrawRack(m_players[0]->getHistory().getCurrentRack(), true); } @@ -351,7 +351,6 @@ void Duplicate::endGame() LOG_INFO("End of the game"); // No more master move setMasterMove(Move()); - m_finished = true; } diff --git a/game/freegame.cpp b/game/freegame.cpp index 4bd457a..33fb83f 100644 --- a/game/freegame.cpp +++ b/game/freegame.cpp @@ -49,7 +49,7 @@ INIT_LOGGER(game, FreeGame); FreeGame::FreeGame(const GameParams &iParams) - : Game(iParams) + : Game(iParams), m_finished(false) { } @@ -150,6 +150,7 @@ void FreeGame::start() bool FreeGame::isFinished() const { + // FIXME: the flag is never reset to false! return m_finished; } diff --git a/game/freegame.h b/game/freegame.h index 930bd0a..c3ebd40 100644 --- a/game/freegame.h +++ b/game/freegame.h @@ -81,7 +81,10 @@ public: int pass(const wstring &iToChange); private: - // Private constructor to force using the GameFactory class + /// True if the game is finished, false otherwise + bool m_finished; + + /// Private constructor to force using the GameFactory class FreeGame(const GameParams &iParams); /// Make the AI player whose ID is p play its turn diff --git a/game/game.cpp b/game/game.cpp index 1c649e8..87ea4cc 100644 --- a/game/game.cpp +++ b/game/game.cpp @@ -54,7 +54,6 @@ Game::Game(const GameParams &iParams): { m_points = 0; m_currPlayer = 0; - m_finished = false; } diff --git a/game/game.h b/game/game.h index 5d3b149..4b5a6e0 100644 --- a/game/game.h +++ b/game/game.h @@ -230,8 +230,6 @@ protected: /// Bag Bag m_bag; - bool m_finished; - /********************************************************* * Helper functions *********************************************************/ diff --git a/qt/arbit_assignments.cpp b/qt/arbit_assignments.cpp index 276dd3e..aae7aeb 100644 --- a/qt/arbit_assignments.cpp +++ b/qt/arbit_assignments.cpp @@ -141,10 +141,7 @@ void ArbitAssignments::refresh() labelMasterMove->setText(label); } - if (m_game->isFinished()) - { - setEnabled(false); - } + setEnabled(!m_game->isFinished()); enableAssignmentButtons(); buttonSelectMaster->setEnabled(isAssignMasterAllowed());