From 9e5b6e8ebf4420d1d92f9fd7ae434825bad503a2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20Teuli=C3=A8re?= Date: Sun, 6 Nov 2005 14:53:15 +0000 Subject: [PATCH] Use Turn objects for the players history too --- game/player.cpp | 16 +++++++--------- game/player.h | 9 +++++---- 2 files changed, 12 insertions(+), 13 deletions(-) diff --git a/game/player.cpp b/game/player.cpp index a8e3dfc..05a1d70 100644 --- a/game/player.cpp +++ b/game/player.cpp @@ -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); diff --git a/game/player.h b/game/player.h index 12505c4..550dced 100644 --- a/game/player.h +++ b/game/player.h @@ -23,7 +23,7 @@ #include #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 m_playedRacks; - vector m_rounds; - vector m_turns; +// vector m_playedRacks; +// vector m_rounds; +// vector m_turns; + vector m_history; };