eliot-dev
[Top][All Lists]
Advanced

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

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


From: eliot-dev
Subject: [Eliot-dev] eliot/game game.cpp player.cpp player.h
Date: Tue, 27 Dec 2005 01:06:54 +0000

CVSROOT:        /cvsroot/eliot
Module name:    eliot
Branch:         
Changes by:     Antoine Fraboulet <address@hidden>      05/12/27 01:06:54

Modified files:
        game           : game.cpp player.cpp player.h 

Log message:
        - correct bug in Game::back
        - add regression test for this case

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/game.cpp.diff?tr1=1.24&tr2=1.25&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/player.cpp.diff?tr1=1.11&tr2=1.12&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/player.h.diff?tr1=1.15&tr2=1.16&r1=text&r2=text

Patches:
Index: eliot/game/game.cpp
diff -u eliot/game/game.cpp:1.24 eliot/game/game.cpp:1.25
--- eliot/game/game.cpp:1.24    Mon Dec 26 22:58:58 2005
+++ eliot/game/game.cpp Tue Dec 27 01:06:54 2005
@@ -417,17 +417,20 @@
     int i, j;
     Player *player;
 
+    if (n < 0)
+    {
+       debug("Game::back negative argument\n");
+       n = -n;
+    }
+    debug("Game::back %d\n",n);
     for (i = 0; i < n; i++)
     {
-        if (m_history.getSize())
+        if (m_history.getSize() > 0)
         {
             prevPlayer();
             player = m_players[m_currPlayer];
             const Round &lastround = m_history.getPreviousTurn().getRound();
-
-            /* Remove the points of this round */
-            player->addPoints(- lastround.getPoints());
-            m_points -= lastround.getPoints();
+           debug("Game::back last round %s\n",lastround.toString().c_str());
             /* Remove the word from the board, and put its letters back
              * into the bag */
             m_board.removeRound(*m_dic, lastround);
@@ -441,7 +444,11 @@
                         m_bag.replaceTile(lastround.getTile(j));
                 }
             }
-            delete &lastround;
+            /* Remove the points of this round */
+            player->addPoints(- lastround.getPoints());
+            m_points -= lastround.getPoints();
+           /* Remove the turns */
+           player->removeLastTurn();
             m_history.removeLastTurn();
         }
         else
@@ -841,3 +848,11 @@
     return 0;
 }
 
+/****************************************************************/
+/****************************************************************/
+
+/// Local Variables:
+/// mode: c++
+/// mode: hs-minor
+/// c-basic-offset: 4
+/// End:
Index: eliot/game/player.cpp
diff -u eliot/game/player.cpp:1.11 eliot/game/player.cpp:1.12
--- eliot/game/player.cpp:1.11  Mon Dec 26 22:52:38 2005
+++ eliot/game/player.cpp       Tue Dec 27 01:06:54 2005
@@ -71,6 +71,10 @@
     m_history.playRound(m_id,iTurn,iRound);
 }
 
+void Player::removeLastTurn()
+{
+    m_history.removeLastTurn();
+}
 
 const string Player::toString() const
 {
Index: eliot/game/player.h
diff -u eliot/game/player.h:1.15 eliot/game/player.h:1.16
--- eliot/game/player.h:1.15    Mon Dec 26 22:52:38 2005
+++ eliot/game/player.h Tue Dec 27 01:06:54 2005
@@ -54,6 +54,8 @@
     void setCurrentRack(const PlayedRack &iPld);
 
     const History& getHistory() const { return m_history; }
+    /// Remove last turn
+    void removeLastTurn();
 
     /**************************
      * Acessors for the score of the player




reply via email to

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