Use Turn objects for the players history too

This commit is contained in:
Olivier Teulière 2005-11-06 14:53:15 +00:00
parent 966418bf98
commit 9e5b6e8ebf
2 changed files with 12 additions and 13 deletions

View file

@ -24,6 +24,7 @@
#include "results.h"
#include "board.h"
#include "player.h"
#include "turn.h"
#include "debug.h"
@ -36,10 +37,8 @@ Player::Player()
Player::~Player()
{
for (unsigned int i = 0; i < m_playedRacks.size(); i++)
delete m_playedRacks[i];
for (unsigned int i = 0; i < m_rounds.size(); i++)
delete m_rounds[i];
for (unsigned int i = 0; i < m_history.size(); i++)
delete m_history[i];
}
@ -57,13 +56,13 @@ void Player::setCurrentRack(const PlayedRack &iPld)
const PlayedRack & Player::getLastRack() const
{
return *m_playedRacks.back();
return m_history.back()->getPlayedRack();
}
const Round & Player::getLastRound() const
{
return *m_rounds.back();
return m_history.back()->getRound();
}
@ -74,9 +73,8 @@ const Round & Player::getLastRound() const
*/
void Player::endTurn(const Round &iRound, int iTurn)
{
m_turns.push_back(iTurn);
m_rounds.push_back(new Round(iRound));
m_playedRacks.push_back(new PlayedRack(m_pldrack));
// FIXME: the number of the player is wrong here!
m_history.push_back(new Turn(iTurn, iTurn, m_pldrack, iRound));
Rack rack;
m_pldrack.getRack(rack);

View file

@ -23,7 +23,7 @@
#include <vector>
#include "pldrack.h"
class Round;
class Turn;
/**
@ -71,9 +71,10 @@ private:
PlayedRack m_pldrack;
/// History of the racks and rounds for the player
vector<PlayedRack *> m_playedRacks;
vector<Round *> m_rounds;
vector<int> m_turns;
// vector<PlayedRack *> m_playedRacks;
// vector<Round *> m_rounds;
// vector<int> m_turns;
vector<Turn*> m_history;
};