Indicate the end of the game

This commit is contained in:
Olivier Teulière 2011-01-30 00:23:45 +00:00
parent 7bb432b954
commit 23771f3f71
10 changed files with 48 additions and 0 deletions

View file

@ -151,6 +151,12 @@ void Duplicate::start()
}
bool Duplicate::isFinished() const
{
return m_finished;
}
void Duplicate::tryEndTurn()
{
for (unsigned int i = 0; i < getNPlayers(); i++)

View file

@ -73,6 +73,8 @@ public:
*/
virtual void start();
virtual bool isFinished() const;
/**
* See description of Game::play() for the possible return values.
* Note that if the "duplicate-reject-invalid" setting is set to false

View file

@ -148,6 +148,12 @@ void FreeGame::start()
}
bool FreeGame::isFinished() const
{
return m_finished;
}
int FreeGame::endTurn()
{
const Move &move = getCurrentPlayer().getLastMove();

View file

@ -57,6 +57,8 @@ public:
*/
virtual void start();
virtual bool isFinished() const;
/**
* See description of Game::play() for the possible return values.
* Note that if the "freegame-reject-invalid" setting is set to false

View file

@ -147,6 +147,13 @@ public:
*/
virtual void start() = 0;
/**
* Indicate whether we reached the end of the game.
* This should be checked regularly.
* XXX: using a signal would be nice here...
*/
virtual bool isFinished() const = 0;
/**
* Method used by human players to play the word iWord at coordinates
* iCoord, and end the turn (if possible)

View file

@ -144,6 +144,12 @@ void PublicGame::start()
}
bool PublicGame::isFinished() const
{
return m_game.isFinished();
}
int PublicGame::play(const wstring &iWord, const wstring &iCoord)
{
return m_game.play(iCoord, iWord);

View file

@ -134,6 +134,13 @@ public:
*/
void start();
/**
* Indicate whether we reached the end of the game.
* This should be checked regularly.
* XXX: using a signal would be nice here...
*/
bool isFinished() const;
/**
* Method used by human players to play the word iWord at coordinates
* iCoord, and end the turn (if possible)

View file

@ -131,6 +131,14 @@ void Training::start()
}
bool Training::isFinished() const
{
// The game is finished when there is no more tile
// (in the bag or in the racks)
return getBag().getNbTiles() == 0;
}
void Training::endTurn()
{
m_results.clear();

View file

@ -56,6 +56,8 @@ public:
*************************/
virtual void start();
virtual bool isFinished() const;
/// See description of Game::play()
virtual int play(const wstring &iCoord, const wstring &iWord);

View file

@ -223,6 +223,8 @@ void MainWindow::refresh()
m_actionHistoryNextTurn->setEnabled(!isLastTurn);
m_actionHistoryLastTurn->setEnabled(!isLastTurn);
m_actionHistoryReplayTurn->setEnabled(!isLastTurn);
if (m_game->isFinished())
displayInfoMsg(_q("End of the game"));
#ifdef DEBUG
//m_game->printTurns();
#endif