[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] Changes to eliot/game/history.cpp [antoine-1]
From: |
eliot-dev |
Subject: |
[Eliot-dev] Changes to eliot/game/history.cpp [antoine-1] |
Date: |
Sun, 23 Oct 2005 16:59:00 -0400 |
Index: eliot/game/history.cpp
diff -u eliot/game/history.cpp:1.2.2.1 eliot/game/history.cpp:1.2.2.2
--- eliot/game/history.cpp:1.2.2.1 Sun Oct 23 17:16:24 2005
+++ eliot/game/history.cpp Sun Oct 23 20:58:20 2005
@@ -17,8 +17,6 @@
/* along with this program; if not, write to the Free Software */
/* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
-/* $Id: history.cpp,v 1.2.2.1 2005/10/23 17:16:24 afrab Exp $ */
-
/**
* \file history.cpp
* \brief Game history system
@@ -29,6 +27,7 @@
#include <string>
#include "rack.h"
#include "history.h"
+#include "turn.h"
#include "debug.h"
/* ******************************************************** */
@@ -39,53 +38,53 @@
History::History()
{
Turn* t = new Turn ();
- history.push_back(t);
+ m_history.push_back(t);
}
History::~History()
{
- for (unsigned int i = 0; i < history.size(); i++)
- {
- if (history[i] != NULL)
- {
- delete history[i];
- history[i] = NULL;
- }
- }
+ for (unsigned int i = 0; i < m_history.size(); i++)
+ {
+ if (m_history[i] != NULL)
+ {
+ delete m_history[i];
+ m_history[i] = NULL;
+ }
+ }
}
int History::getSize() const
{
- return history.size();
+ return m_history.size();
}
-const PlayedRack History::getCurrentRack() const
+const PlayedRack& History::getCurrentRack() const
{
- return history.back()->getPlayedRack();
+ return m_history.back()->getPlayedRack();
}
void History::setCurrentRack(const PlayedRack &iPld)
{
- history.back()->setPlayedRack(iPld);
+ m_history.back()->setPlayedRack(iPld);
}
-const Turn History::getPreviousTurn() const
+const Turn& History::getPreviousTurn() const
{
- int idx = history.size() - 2;
+ int idx = m_history.size() - 2;
ASSERT(0 <= idx , "Wrong turn number");
- return *(history[ idx ]);
+ return *(m_history[idx]);
}
-const Turn History::getTurn(unsigned int n) const
+const Turn& History::getTurn(unsigned int n) const
{
- ASSERT(0 <= n && n < history.size(), "Wrong turn number");
- return *(history[ n ]);
+ ASSERT(0 <= n && n < m_history.size(), "Wrong turn number");
+ return *(m_history[n]);
}
@@ -93,8 +92,8 @@
{
Rack rack;
Turn * current_turn;
-
- current_turn = history.back();
+
+ current_turn = m_history.back();
/* set the number and the round */
current_turn->setNum(turn);
@@ -121,24 +120,24 @@
PlayedRack pldrack;
pldrack.setOld(rack);
next_turn->setPlayedRack(pldrack);
- history.push_back ( next_turn );
+ m_history.push_back(next_turn);
}
void History::removeLastTurn()
{
- int idx = history.size();
+ int idx = m_history.size();
ASSERT(0 < idx , "Wrong turn number");
-
+
if (idx > 1)
- {
- Turn *t = history.back();
- history.pop_back();
- delete t;
- }
+ {
+ Turn *t = m_history.back();
+ m_history.pop_back();
+ delete t;
+ }
// now we have the previous played round in back()
- Turn* t = history.back();
+ Turn* t = m_history.back();
t->setNum(0);
t->setPlayer(0);
t->setRound(Round());
@@ -148,21 +147,20 @@
}
-std::string
-History::toString() const
+std::string History::toString() const
{
- char buff[20];
unsigned int i;
- std::string rs("");
+ std::string rs = "";
#ifdef DEBUG
- sprintf(buff,"%d",history.size());
- rs = "hitory size = " + std::string(buff) + "\n\n";
+ char buff[20];
+ sprintf(buff,"%d",m_history.size());
+ rs = "history size = " + std::string(buff) + "\n\n";
#endif
- for ( i = 0; i < history.size(); i++)
- {
- Turn *t = history[i];
- rs += t->toString() + std::string("\n");
- }
+ for (i = 0; i < m_history.size(); i++)
+ {
+ Turn *t = m_history[i];
+ rs += t->toString() + std::string("\n");
+ }
return rs;
}
@@ -170,7 +168,7 @@
/* ******************************************************** */
/* ******************************************************** */
-
+
/// Local Variables:
/// mode: hs-minor
/// c-basic-offset: 4