mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-18 10:26:15 +01:00
Rename Turn into TurnData (step 2)
This commit is contained in:
parent
fa345a9f7b
commit
471dcf90e1
12 changed files with 36 additions and 36 deletions
|
@ -37,7 +37,7 @@ class Player;
|
|||
class PlayedRack;
|
||||
class Round;
|
||||
class Rack;
|
||||
class Turn;
|
||||
class TurnData;
|
||||
|
||||
using namespace std;
|
||||
|
||||
|
|
|
@ -36,7 +36,7 @@ INIT_LOGGER(game, History);
|
|||
|
||||
History::History()
|
||||
{
|
||||
Turn* t = new Turn();
|
||||
TurnData *t = new TurnData();
|
||||
m_history.clear();
|
||||
m_history.push_back(t);
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ History::History()
|
|||
|
||||
History::~History()
|
||||
{
|
||||
BOOST_FOREACH(Turn *turn, m_history)
|
||||
BOOST_FOREACH(TurnData *turn, m_history)
|
||||
{
|
||||
delete turn;
|
||||
}
|
||||
|
@ -70,7 +70,7 @@ void History::setCurrentRack(const PlayedRack &iPld)
|
|||
}
|
||||
|
||||
|
||||
const Turn& History::getPreviousTurn() const
|
||||
const TurnData& History::getPreviousTurn() const
|
||||
{
|
||||
int idx = m_history.size() - 2;
|
||||
ASSERT(0 <= idx , "No previous turn");
|
||||
|
@ -78,7 +78,7 @@ const Turn& History::getPreviousTurn() const
|
|||
}
|
||||
|
||||
|
||||
const Turn& History::getTurn(unsigned int n) const
|
||||
const TurnData& History::getTurn(unsigned int n) const
|
||||
{
|
||||
ASSERT(n < m_history.size(), "Wrong turn number");
|
||||
return *(m_history[n]);
|
||||
|
@ -100,14 +100,14 @@ void History::playMove(unsigned int iPlayer,
|
|||
const Move &iMove,
|
||||
const PlayedRack &iNewRack)
|
||||
{
|
||||
Turn * current_turn = m_history.back();
|
||||
TurnData * current_turn = m_history.back();
|
||||
|
||||
// Set the number and the round
|
||||
current_turn->setPlayer(iPlayer);
|
||||
current_turn->setMove(iMove);
|
||||
|
||||
// Create a new turn
|
||||
Turn * next_turn = new Turn();
|
||||
TurnData * next_turn = new TurnData();
|
||||
next_turn->setPlayedRack(iNewRack);
|
||||
m_history.push_back(next_turn);
|
||||
}
|
||||
|
@ -120,13 +120,13 @@ void History::removeLastTurn()
|
|||
|
||||
if (idx > 1)
|
||||
{
|
||||
Turn *t = m_history.back();
|
||||
TurnData *t = m_history.back();
|
||||
m_history.pop_back();
|
||||
delete t;
|
||||
}
|
||||
|
||||
// Now we have the previous played round in back()
|
||||
Turn *t = m_history.back();
|
||||
TurnData *t = m_history.back();
|
||||
t->setPlayer(0);
|
||||
//t->setRound(Round());
|
||||
#ifdef BACK_REMOVE_RACK_NEW_PART
|
||||
|
@ -178,7 +178,7 @@ wstring History::toString() const
|
|||
_swprintf(buff, 4, L"%ld", m_history.size());
|
||||
rs = L"history size = " + wstring(buff) + L"\n\n";
|
||||
#endif
|
||||
BOOST_FOREACH(const Turn *turn, m_history)
|
||||
BOOST_FOREACH(const TurnData *turn, m_history)
|
||||
{
|
||||
rs += turn->toString() + L"\n";
|
||||
}
|
||||
|
|
|
@ -31,7 +31,7 @@ using std::wstring;
|
|||
using std::vector;
|
||||
|
||||
class Move;
|
||||
class Turn;
|
||||
class TurnData;
|
||||
class PlayedRack;
|
||||
|
||||
/**
|
||||
|
@ -40,7 +40,7 @@ class PlayedRack;
|
|||
* - one for the complete game
|
||||
* - one for each player
|
||||
*
|
||||
* The top of the history is an empty Turn until it has been filled
|
||||
* The top of the history is an empty TurnData until it has been filled
|
||||
* and the game is up to a new turn. So a History object is never empty.
|
||||
* However, the getSize() method only returns the number of complete
|
||||
* turns, and can therefore return 0.
|
||||
|
@ -69,10 +69,10 @@ public:
|
|||
void setCurrentRack(const PlayedRack &iPld);
|
||||
|
||||
/// Get the previous (complete) turn
|
||||
const Turn& getPreviousTurn() const;
|
||||
const TurnData& getPreviousTurn() const;
|
||||
|
||||
/// Get turn 'n' (starting at 0)
|
||||
const Turn& getTurn(unsigned int) const;
|
||||
const TurnData& getTurn(unsigned int) const;
|
||||
|
||||
/**
|
||||
* Return true if the history doesn't contain at least one move
|
||||
|
@ -102,7 +102,7 @@ public:
|
|||
wstring toString() const;
|
||||
|
||||
private:
|
||||
vector<Turn*> m_history;
|
||||
vector<TurnData*> m_history;
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -30,7 +30,7 @@
|
|||
|
||||
using std::wstring;
|
||||
|
||||
class Turn;
|
||||
class TurnData;
|
||||
class Rack;
|
||||
|
||||
|
||||
|
|
|
@ -24,19 +24,19 @@
|
|||
#include "turn_data.h"
|
||||
|
||||
|
||||
INIT_LOGGER(game, Turn);
|
||||
INIT_LOGGER(game, TurnData);
|
||||
|
||||
|
||||
// FIXME: move set to an arbitrary one (no move). It would be better to get rid of this
|
||||
// constructor completely
|
||||
Turn::Turn()
|
||||
TurnData::TurnData()
|
||||
: m_playerId(0), m_warningsNb(0),
|
||||
m_penaltyPoints(0), m_soloPoints(0), m_endGamePoints(0)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
Turn::Turn(unsigned int iPlayerId, const PlayedRack& iPldRack,
|
||||
TurnData::TurnData(unsigned int iPlayerId, const PlayedRack& iPldRack,
|
||||
const Move& iMove)
|
||||
: m_playerId(iPlayerId), m_pldrack(iPldRack), m_move(iMove),
|
||||
m_warningsNb(0), m_penaltyPoints(0), m_soloPoints(0), m_endGamePoints(0)
|
||||
|
@ -44,7 +44,7 @@ Turn::Turn(unsigned int iPlayerId, const PlayedRack& iPldRack,
|
|||
}
|
||||
|
||||
|
||||
wstring Turn::toString() const
|
||||
wstring TurnData::toString() const
|
||||
{
|
||||
wostringstream oss;
|
||||
oss << m_pldrack.toString() << L" " << m_move.toString()
|
||||
|
|
|
@ -19,8 +19,8 @@
|
|||
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*****************************************************************************/
|
||||
|
||||
#ifndef TURN_H_
|
||||
#define TURN_H_
|
||||
#ifndef TURN_DATA_H_
|
||||
#define TURN_DATA_H_
|
||||
|
||||
#include <string>
|
||||
#include "pldrack.h"
|
||||
|
@ -31,19 +31,19 @@ using std::wstring;
|
|||
|
||||
|
||||
/**
|
||||
* A Turn is the information about one 'move' done by a player.
|
||||
* A TurnData is the information about one 'move' done by a player.
|
||||
* It consists of the player who played, the rack, and the actual move.
|
||||
*
|
||||
* This class has no logic, it is merely there to aggregate corresponding
|
||||
* data.
|
||||
*/
|
||||
class Turn
|
||||
class TurnData
|
||||
{
|
||||
DEFINE_LOGGER();
|
||||
public:
|
||||
Turn();
|
||||
Turn(unsigned int iPlayerId,
|
||||
const PlayedRack& iPldRack, const Move& iMove);
|
||||
TurnData();
|
||||
TurnData(unsigned int iPlayerId,
|
||||
const PlayedRack& iPldRack, const Move& iMove);
|
||||
|
||||
void setPlayer(unsigned int iPlayerId) { m_playerId = iPlayerId; }
|
||||
void setPlayedRack(const PlayedRack& iPldRack) { m_pldrack = iPldRack; }
|
||||
|
|
|
@ -168,7 +168,7 @@ void HistoryWidget::updateModel()
|
|||
|
||||
QColor color = Qt::black;
|
||||
|
||||
const Turn& t = m_history->getTurn(i);
|
||||
const TurnData& t = m_history->getTurn(i);
|
||||
const Move& m = t.getMove();
|
||||
|
||||
// Set data common to all moves
|
||||
|
|
|
@ -950,7 +950,7 @@ void MainWindow::onGamePrint()
|
|||
nextHeight = curHeight + LINE_HEIGHT;
|
||||
for (unsigned int i = 0; i < history.getSize(); ++i)
|
||||
{
|
||||
const Turn &t = history.getTurn(i);
|
||||
const TurnData &t = history.getTurn(i);
|
||||
const Move &m = t.getMove();
|
||||
|
||||
curWidth = TEXT_OFFSET;
|
||||
|
|
|
@ -281,7 +281,7 @@ void StatsWidget::setModelText(const QModelIndex &iIndex,
|
|||
|
||||
|
||||
void StatsWidget::setModelTurnData(const QModelIndex &iIndex,
|
||||
const Turn &iTurn, const Turn &iGameTurn)
|
||||
const TurnData &iTurn, const TurnData &iGameTurn)
|
||||
{
|
||||
// Set the text (score for the turn)
|
||||
if (!iTurn.getMove().isNull())
|
||||
|
@ -327,7 +327,7 @@ void StatsWidget::setModelEventData(const QModelIndex &iIndex,
|
|||
}
|
||||
|
||||
|
||||
QString StatsWidget::getTooltip(const Turn &iTurn, const Turn &iGameTurn) const
|
||||
QString StatsWidget::getTooltip(const TurnData &iTurn, const TurnData &iGameTurn) const
|
||||
{
|
||||
QString tooltip = _q("Rack: %1").arg(qfw(iTurn.getPlayedRack().toString()));
|
||||
const Move &move = iTurn.getMove();
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
class PublicGame;
|
||||
class Player;
|
||||
class Turn;
|
||||
class TurnData;
|
||||
class QTableView;
|
||||
class QStandardItemModel;
|
||||
class QVariant;
|
||||
|
@ -70,7 +70,7 @@ private:
|
|||
|
||||
|
||||
QModelIndex getIndex(int row, int col) const;
|
||||
QString getTooltip(const Turn &iTurn, const Turn &iGameTurn) const;
|
||||
QString getTooltip(const TurnData &iTurn, const TurnData &iGameTurn) const;
|
||||
|
||||
void setSectionHidden(int index, bool iHide);
|
||||
void setModelSize(int rowCount, int colCount);
|
||||
|
@ -78,7 +78,7 @@ private:
|
|||
void setModelText(const QModelIndex &iIndex, const QVariant &iData,
|
||||
bool useBoldFont = false);
|
||||
void setModelTurnData(const QModelIndex &iIndex,
|
||||
const Turn &iTurn, const Turn &iGameTurn);
|
||||
const TurnData &iTurn, const TurnData &iGameTurn);
|
||||
void setModelEventData(const QModelIndex &iIndex,
|
||||
int iEvent, const Player &iPlayer);
|
||||
};
|
||||
|
|
|
@ -233,7 +233,7 @@ void GameIO::printGameDebug(ostream &out, const PublicGame &iGame)
|
|||
out << " ===|===|==========|================|=====|=====|======" << endl;
|
||||
for (unsigned int i = 0; i < iGame.getHistory().getSize(); ++i)
|
||||
{
|
||||
const Turn &turn = iGame.getHistory().getTurn(i);
|
||||
const TurnData &turn = iGame.getHistory().getTurn(i);
|
||||
const Move &move = turn.getMove();
|
||||
format fmter("%1% | %2% | %3% | %4% | %5% | %6% | %7%");
|
||||
fmter % padAndConvert(str(wformat(L"%1%") % (i + 1)), 5);
|
||||
|
|
|
@ -395,7 +395,7 @@ void CursesIntf::drawHistory(Box &ioBox) const
|
|||
for (i = ioBox.getFirstLine();
|
||||
i < (int)m_game->getHistory().getSize() && i < ioBox.getLastLine(); i++)
|
||||
{
|
||||
const Turn& t = m_game->getHistory().getTurn(i);
|
||||
const TurnData& t = m_game->getHistory().getTurn(i);
|
||||
const Move& m = t.getMove();
|
||||
if (m.isValid())
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue