mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-18 10:26:15 +01:00
- 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
This commit is contained in:
parent
9aeeafa61b
commit
3ecf740432
3 changed files with 28 additions and 20 deletions
|
@ -39,7 +39,7 @@
|
||||||
|
|
||||||
History::History()
|
History::History()
|
||||||
{
|
{
|
||||||
Turn* t = new Turn ();
|
Turn* t = new Turn();
|
||||||
m_history.clear();
|
m_history.clear();
|
||||||
m_history.push_back(t);
|
m_history.push_back(t);
|
||||||
}
|
}
|
||||||
|
@ -143,7 +143,7 @@ void History::removeLastTurn()
|
||||||
delete t;
|
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();
|
Turn* t = m_history.back();
|
||||||
t->setNum(0);
|
t->setNum(0);
|
||||||
t->setPlayer(0);
|
t->setPlayer(0);
|
||||||
|
@ -154,19 +154,19 @@ void History::removeLastTurn()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
std::string History::toString() const
|
string History::toString() const
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
std::string rs = "";
|
string rs = "";
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
char buff[20];
|
char buff[20];
|
||||||
sprintf(buff,"%d",m_history.size());
|
sprintf(buff, "%ld", m_history.size());
|
||||||
rs = "history size = " + std::string(buff) + "\n\n";
|
rs = "history size = " + string(buff) + "\n\n";
|
||||||
#endif
|
#endif
|
||||||
for (i = 0; i < m_history.size(); i++)
|
for (i = 0; i < m_history.size(); i++)
|
||||||
{
|
{
|
||||||
Turn *t = m_history[i];
|
Turn *t = m_history[i];
|
||||||
rs += t->toString() + std::string("\n");
|
rs += t->toString() + "\n";
|
||||||
}
|
}
|
||||||
return rs;
|
return rs;
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,10 +27,16 @@
|
||||||
#ifndef _HISTORY_H
|
#ifndef _HISTORY_H
|
||||||
#define _HISTORY_H
|
#define _HISTORY_H
|
||||||
|
|
||||||
|
#include <string>
|
||||||
#include <vector>
|
#include <vector>
|
||||||
#include "pldrack.h"
|
|
||||||
#include "round.h"
|
using std::string;
|
||||||
#include "turn.h"
|
using std::vector;
|
||||||
|
|
||||||
|
class Round;
|
||||||
|
class Turn;
|
||||||
|
class PlayedRack;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* History stores all the turns that have been played
|
* History stores all the turns that have been played
|
||||||
|
@ -55,7 +61,7 @@
|
||||||
|
|
||||||
class History
|
class History
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
History();
|
History();
|
||||||
virtual ~History();
|
virtual ~History();
|
||||||
|
|
||||||
|
@ -82,10 +88,10 @@ class History
|
||||||
void removeLastTurn();
|
void removeLastTurn();
|
||||||
|
|
||||||
/// String handling
|
/// String handling
|
||||||
std::string toString() const;
|
string toString() const;
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::vector < Turn* > m_history;
|
vector<Turn*> m_history;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -36,6 +36,8 @@
|
||||||
#include "duplicate.h"
|
#include "duplicate.h"
|
||||||
#include "freegame.h"
|
#include "freegame.h"
|
||||||
#include "player.h"
|
#include "player.h"
|
||||||
|
#include "history.h"
|
||||||
|
#include "turn.h"
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue