eliot-dev
[Top][All Lists]
Advanced

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

[Eliot-dev] eliot game/history.cpp game/history.h utils/ncu...


From: eliot-dev
Subject: [Eliot-dev] eliot game/history.cpp game/history.h utils/ncu...
Date: Tue, 27 Dec 2005 16:54:38 +0000

CVSROOT:        /cvsroot/eliot
Module name:    eliot
Branch:         
Changes by:     Olivier Teulière <address@hidden>      05/12/27 16:54:38

Modified files:
        game           : history.cpp history.h 
        utils          : ncurses.cpp 

Log message:
        - do not use std:: everywhere, it justs makes the code harder to read
        - history.h: use forward declarations to reduce dependencies
        - history.cpp: fixed a compilation warning

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/history.cpp.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/history.h.diff?tr1=1.7&tr2=1.8&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/utils/ncurses.cpp.diff?tr1=1.18&tr2=1.19&r1=text&r2=text

Patches:
Index: eliot/game/history.cpp
diff -u eliot/game/history.cpp:1.7 eliot/game/history.cpp:1.8
--- eliot/game/history.cpp:1.7  Tue Dec 27 00:06:23 2005
+++ eliot/game/history.cpp      Tue Dec 27 16:54:38 2005
@@ -39,7 +39,7 @@
 
 History::History()
 {
-    Turn* t = new Turn ();
+    Turn* t = new Turn();
     m_history.clear();
     m_history.push_back(t);
 }
@@ -143,7 +143,7 @@
         delete t;
     }
 
-    // now we have the previous played round in back()
+    // Now we have the previous played round in back()
     Turn* t = m_history.back();
     t->setNum(0);
     t->setPlayer(0);
@@ -154,19 +154,19 @@
 }
 
 
-std::string History::toString() const
+string History::toString() const
 {
     unsigned int i;
-    std::string rs = "";
+    string rs = "";
 #ifdef DEBUG
     char buff[20];
-    sprintf(buff,"%d",m_history.size());
-    rs = "history size = " + std::string(buff) + "\n\n";
+    sprintf(buff, "%ld", m_history.size());
+    rs = "history size = " + string(buff) + "\n\n";
 #endif
     for (i = 0; i < m_history.size(); i++)
     {
         Turn *t = m_history[i];
-        rs += t->toString() + std::string("\n");
+        rs += t->toString() + "\n";
     }
     return rs;
 }
Index: eliot/game/history.h
diff -u eliot/game/history.h:1.7 eliot/game/history.h:1.8
--- eliot/game/history.h:1.7    Tue Dec 27 00:06:23 2005
+++ eliot/game/history.h        Tue Dec 27 16:54:38 2005
@@ -27,10 +27,16 @@
 #ifndef _HISTORY_H
 #define _HISTORY_H
 
+#include <string>
 #include <vector>
-#include "pldrack.h"
-#include "round.h"
-#include "turn.h"
+
+using std::string;
+using std::vector;
+
+class Round;
+class Turn;
+class PlayedRack;
+
 
 /**
  * History stores all the turns that have been played
@@ -39,23 +45,23 @@
  *  - one for each of the players
  *
  * A History is never void (getSize() can be used as the is the current turn
- * number for the complete game history). 
+ * number for the complete game history).
  *
  * History starts at zero.
  *
  * The top of the history is an empty
  * Turn until it has been filled and game is up to a new round.
- * 
- * getCurrentRack() can/should be used to store the current played rack. 
+ *
+ * getCurrentRack() can/should be used to store the current played rack.
  * setCurrentRack must be called whenever the current played rack is
  * modified.
- * 
+ *
  * History owns the turns that it stores. Do not delete a turn referenced by 
History
  */
 
 class History
 {
- public:
+public:
     History();
     virtual ~History();
 
@@ -82,10 +88,10 @@
     void removeLastTurn();
 
     /// String handling
-    std::string toString() const;
+    string toString() const;
 
- private:
-    std::vector < Turn* > m_history;
+private:
+    vector<Turn*> m_history;
 };
 
 #endif
Index: eliot/utils/ncurses.cpp
diff -u eliot/utils/ncurses.cpp:1.18 eliot/utils/ncurses.cpp:1.19
--- eliot/utils/ncurses.cpp:1.18        Tue Dec 27 15:01:07 2005
+++ eliot/utils/ncurses.cpp     Tue Dec 27 16:54:38 2005
@@ -36,6 +36,8 @@
 #include "duplicate.h"
 #include "freegame.h"
 #include "player.h"
+#include "history.h"
+#include "turn.h"
 
 using namespace std;
 
@@ -272,7 +274,7 @@
                          i < m_boxStart + m_boxLines; i++)
     {
         const Turn& t = m_game->getHistory().getTurn(i);
-       const Round& r = t.getRound();
+        const Round& r = t.getRound();
         string word = r.getWord();
         string coord = r.getCoord().toString();
         boxPrint(win, i + 2, x + 2,
@@ -280,7 +282,7 @@
                  i + 1, t.getPlayedRack().toString().c_str(), word.c_str(),
                  string(15 - word.size(), ' ').c_str(),
                  coord.c_str(), r.getPoints(),
-                t.getPlayer(), r.getBonus() ? '*' : ' ');
+                 t.getPlayer(), r.getBonus() ? '*' : ' ');
     }
     mvwvline(win, y + 1, x + 5,  ACS_VLINE, min(i + 2 - m_boxStart, 
m_boxLines));
     mvwvline(win, y + 1, x + 16, ACS_VLINE, min(i + 2 - m_boxStart, 
m_boxLines));




reply via email to

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