mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-29 20:34:56 +01:00
Indicate the end of the game
This commit is contained in:
parent
7bb432b954
commit
23771f3f71
10 changed files with 48 additions and 0 deletions
|
@ -151,6 +151,12 @@ void Duplicate::start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool Duplicate::isFinished() const
|
||||||
|
{
|
||||||
|
return m_finished;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
void Duplicate::tryEndTurn()
|
void Duplicate::tryEndTurn()
|
||||||
{
|
{
|
||||||
for (unsigned int i = 0; i < getNPlayers(); i++)
|
for (unsigned int i = 0; i < getNPlayers(); i++)
|
||||||
|
|
|
@ -73,6 +73,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void start();
|
virtual void start();
|
||||||
|
|
||||||
|
virtual bool isFinished() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See description of Game::play() for the possible return values.
|
* See description of Game::play() for the possible return values.
|
||||||
* Note that if the "duplicate-reject-invalid" setting is set to false
|
* Note that if the "duplicate-reject-invalid" setting is set to false
|
||||||
|
|
|
@ -148,6 +148,12 @@ void FreeGame::start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool FreeGame::isFinished() const
|
||||||
|
{
|
||||||
|
return m_finished;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int FreeGame::endTurn()
|
int FreeGame::endTurn()
|
||||||
{
|
{
|
||||||
const Move &move = getCurrentPlayer().getLastMove();
|
const Move &move = getCurrentPlayer().getLastMove();
|
||||||
|
|
|
@ -57,6 +57,8 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void start();
|
virtual void start();
|
||||||
|
|
||||||
|
virtual bool isFinished() const;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See description of Game::play() for the possible return values.
|
* See description of Game::play() for the possible return values.
|
||||||
* Note that if the "freegame-reject-invalid" setting is set to false
|
* Note that if the "freegame-reject-invalid" setting is set to false
|
||||||
|
|
|
@ -147,6 +147,13 @@ public:
|
||||||
*/
|
*/
|
||||||
virtual void start() = 0;
|
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
|
* Method used by human players to play the word iWord at coordinates
|
||||||
* iCoord, and end the turn (if possible)
|
* iCoord, and end the turn (if possible)
|
||||||
|
|
|
@ -144,6 +144,12 @@ void PublicGame::start()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
bool PublicGame::isFinished() const
|
||||||
|
{
|
||||||
|
return m_game.isFinished();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
int PublicGame::play(const wstring &iWord, const wstring &iCoord)
|
int PublicGame::play(const wstring &iWord, const wstring &iCoord)
|
||||||
{
|
{
|
||||||
return m_game.play(iCoord, iWord);
|
return m_game.play(iCoord, iWord);
|
||||||
|
|
|
@ -134,6 +134,13 @@ public:
|
||||||
*/
|
*/
|
||||||
void start();
|
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
|
* Method used by human players to play the word iWord at coordinates
|
||||||
* iCoord, and end the turn (if possible)
|
* iCoord, and end the turn (if possible)
|
||||||
|
|
|
@ -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()
|
void Training::endTurn()
|
||||||
{
|
{
|
||||||
m_results.clear();
|
m_results.clear();
|
||||||
|
|
|
@ -56,6 +56,8 @@ public:
|
||||||
*************************/
|
*************************/
|
||||||
virtual void start();
|
virtual void start();
|
||||||
|
|
||||||
|
virtual bool isFinished() const;
|
||||||
|
|
||||||
/// See description of Game::play()
|
/// See description of Game::play()
|
||||||
virtual int play(const wstring &iCoord, const wstring &iWord);
|
virtual int play(const wstring &iCoord, const wstring &iWord);
|
||||||
|
|
||||||
|
|
|
@ -223,6 +223,8 @@ void MainWindow::refresh()
|
||||||
m_actionHistoryNextTurn->setEnabled(!isLastTurn);
|
m_actionHistoryNextTurn->setEnabled(!isLastTurn);
|
||||||
m_actionHistoryLastTurn->setEnabled(!isLastTurn);
|
m_actionHistoryLastTurn->setEnabled(!isLastTurn);
|
||||||
m_actionHistoryReplayTurn->setEnabled(!isLastTurn);
|
m_actionHistoryReplayTurn->setEnabled(!isLastTurn);
|
||||||
|
if (m_game->isFinished())
|
||||||
|
displayInfoMsg(_q("End of the game"));
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
//m_game->printTurns();
|
//m_game->printTurns();
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Add table
Reference in a new issue