eliot-dev
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[Eliot-dev] eliot game/duplicate.cpp game/duplicate.h game/...


From: Olivier Teulière
Subject: [Eliot-dev] eliot game/duplicate.cpp game/duplicate.h game/...
Date: Sun, 30 Jan 2011 00:23:46 +0000

CVSROOT:        /cvsroot/eliot
Module name:    eliot
Changes by:     Olivier Teulière <ipkiss>       11/01/30 00:23:46

Modified files:
        game           : duplicate.cpp duplicate.h freegame.cpp 
                         freegame.h game.h public_game.cpp public_game.h 
                         training.cpp training.h 
        qt             : main_window.cpp 

Log message:
        Indicate the end of the game

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/game/duplicate.cpp?cvsroot=eliot&r1=1.35&r2=1.36
http://cvs.savannah.gnu.org/viewcvs/eliot/game/duplicate.h?cvsroot=eliot&r1=1.24&r2=1.25
http://cvs.savannah.gnu.org/viewcvs/eliot/game/freegame.cpp?cvsroot=eliot&r1=1.34&r2=1.35
http://cvs.savannah.gnu.org/viewcvs/eliot/game/freegame.h?cvsroot=eliot&r1=1.19&r2=1.20
http://cvs.savannah.gnu.org/viewcvs/eliot/game/game.h?cvsroot=eliot&r1=1.53&r2=1.54
http://cvs.savannah.gnu.org/viewcvs/eliot/game/public_game.cpp?cvsroot=eliot&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/eliot/game/public_game.h?cvsroot=eliot&r1=1.6&r2=1.7
http://cvs.savannah.gnu.org/viewcvs/eliot/game/training.cpp?cvsroot=eliot&r1=1.36&r2=1.37
http://cvs.savannah.gnu.org/viewcvs/eliot/game/training.h?cvsroot=eliot&r1=1.27&r2=1.28
http://cvs.savannah.gnu.org/viewcvs/eliot/qt/main_window.cpp?cvsroot=eliot&r1=1.40&r2=1.41

Patches:
Index: game/duplicate.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/duplicate.cpp,v
retrieving revision 1.35
retrieving revision 1.36
diff -u -b -r1.35 -r1.36
--- game/duplicate.cpp  29 Jan 2011 23:47:21 -0000      1.35
+++ game/duplicate.cpp  30 Jan 2011 00:23:45 -0000      1.36
@@ -151,6 +151,12 @@
 }
 
 
+bool Duplicate::isFinished() const
+{
+    return m_finished;
+}
+
+
 void Duplicate::tryEndTurn()
 {
     for (unsigned int i = 0; i < getNPlayers(); i++)

Index: game/duplicate.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/duplicate.h,v
retrieving revision 1.24
retrieving revision 1.25
diff -u -b -r1.24 -r1.25
--- game/duplicate.h    29 Jan 2011 23:47:21 -0000      1.24
+++ game/duplicate.h    30 Jan 2011 00:23:45 -0000      1.25
@@ -73,6 +73,8 @@
      */
     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

Index: game/freegame.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/freegame.cpp,v
retrieving revision 1.34
retrieving revision 1.35
diff -u -b -r1.34 -r1.35
--- game/freegame.cpp   29 Jan 2011 23:47:21 -0000      1.34
+++ game/freegame.cpp   30 Jan 2011 00:23:45 -0000      1.35
@@ -148,6 +148,12 @@
 }
 
 
+bool FreeGame::isFinished() const
+{
+    return m_finished;
+}
+
+
 int FreeGame::endTurn()
 {
     const Move &move = getCurrentPlayer().getLastMove();

Index: game/freegame.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/freegame.h,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -b -r1.19 -r1.20
--- game/freegame.h     29 Jan 2011 23:47:21 -0000      1.19
+++ game/freegame.h     30 Jan 2011 00:23:45 -0000      1.20
@@ -57,6 +57,8 @@
      */
     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

Index: game/game.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/game.h,v
retrieving revision 1.53
retrieving revision 1.54
diff -u -b -r1.53 -r1.54
--- game/game.h 29 Jan 2011 23:47:21 -0000      1.53
+++ game/game.h 30 Jan 2011 00:23:45 -0000      1.54
@@ -148,6 +148,13 @@
     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)
      * Possible return values:

Index: game/public_game.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/public_game.cpp,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- game/public_game.cpp        29 Nov 2009 16:01:32 -0000      1.6
+++ game/public_game.cpp        30 Jan 2011 00:23:45 -0000      1.7
@@ -144,6 +144,12 @@
 }
 
 
+bool PublicGame::isFinished() const
+{
+    return m_game.isFinished();
+}
+
+
 int PublicGame::play(const wstring &iWord, const wstring &iCoord)
 {
     return m_game.play(iCoord, iWord);

Index: game/public_game.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/public_game.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -b -r1.6 -r1.7
--- game/public_game.h  29 Nov 2009 16:01:32 -0000      1.6
+++ game/public_game.h  30 Jan 2011 00:23:45 -0000      1.7
@@ -135,6 +135,13 @@
     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)
      * Possible return values:

Index: game/training.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/game/training.cpp,v
retrieving revision 1.36
retrieving revision 1.37
diff -u -b -r1.36 -r1.37
--- game/training.cpp   29 Jan 2011 23:47:21 -0000      1.36
+++ game/training.cpp   30 Jan 2011 00:23:45 -0000      1.37
@@ -131,6 +131,14 @@
 }
 
 
+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();

Index: game/training.h
===================================================================
RCS file: /cvsroot/eliot/eliot/game/training.h,v
retrieving revision 1.27
retrieving revision 1.28
diff -u -b -r1.27 -r1.28
--- game/training.h     29 Jan 2011 23:47:21 -0000      1.27
+++ game/training.h     30 Jan 2011 00:23:45 -0000      1.28
@@ -56,6 +56,8 @@
      *************************/
     virtual void start();
 
+    virtual bool isFinished() const;
+
     /// See description of Game::play()
     virtual int play(const wstring &iCoord, const wstring &iWord);
 

Index: qt/main_window.cpp
===================================================================
RCS file: /cvsroot/eliot/eliot/qt/main_window.cpp,v
retrieving revision 1.40
retrieving revision 1.41
diff -u -b -r1.40 -r1.41
--- qt/main_window.cpp  29 Jan 2011 23:47:21 -0000      1.40
+++ qt/main_window.cpp  30 Jan 2011 00:23:46 -0000      1.41
@@ -223,6 +223,8 @@
         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



reply via email to

[Prev in Thread] Current Thread [Next in Thread]