[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot/game player.h player.cpp
From: |
eliot-dev |
Subject: |
[Eliot-dev] eliot/game player.h player.cpp |
Date: |
Mon, 26 Dec 2005 21:18:21 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Branch:
Changes by: Antoine Fraboulet <address@hidden> 05/12/26 21:18:21
Modified files:
game : player.h player.cpp
Log message:
- player now use History class for turn storage
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/player.h.diff?tr1=1.13&tr2=1.14&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/player.cpp.diff?tr1=1.9&tr2=1.10&r1=text&r2=text
Patches:
Index: eliot/game/player.cpp
diff -u eliot/game/player.cpp:1.9 eliot/game/player.cpp:1.10
--- eliot/game/player.cpp:1.9 Sun Nov 6 17:13:45 2005
+++ eliot/game/player.cpp Mon Dec 26 21:18:21 2005
@@ -25,6 +25,7 @@
#include "board.h"
#include "player.h"
#include "turn.h"
+#include "history.h"
#include "debug.h"
@@ -38,61 +39,43 @@
Player::~Player()
{
- for (unsigned int i = 0; i < m_history.size(); i++)
- delete m_history[i];
}
const PlayedRack & Player::getCurrentRack() const
{
- return m_pldrack;
+ return m_history.getCurrentRack();
}
void Player::setCurrentRack(const PlayedRack &iPld)
{
- m_pldrack = iPld;
+ m_history.setCurrentRack(iPld);
}
const PlayedRack & Player::getLastRack() const
{
- return m_history.back()->getPlayedRack();
+ return m_history.getPreviousTurn().getPlayedRack();
}
const Round & Player::getLastRound() const
{
- return m_history.back()->getRound();
+ return m_history.getPreviousTurn().getRound();
}
-/*
- * This function increments the number of racks, and fills the new rack
- * with the unplayed tiles from the previous one.
- * 03 sept 2000 : We have to sort the tiles according to the new rules
- */
void Player::endTurn(const Round &iRound, int iTurn)
{
- m_history.push_back(new Turn(iTurn, m_id, m_pldrack, iRound));
-
- Rack rack;
- m_pldrack.getRack(rack);
-
- // We remove the played tiles from the rack
- for (int i = 0; i < iRound.getWordLen(); i++)
- {
- if (iRound.isPlayedFromRack(i))
- {
- if (iRound.isJoker(i))
- rack.remove(Tile::Joker());
- else
- rack.remove(iRound.getTile(i));
- }
- }
-
- // Now reinitialize the current rack with the remaining tiles
- m_pldrack = PlayedRack();
- m_pldrack.setOld(rack);
+ m_history.playRound(m_id,iTurn,iRound);
}
+/****************************************************************/
+/****************************************************************/
+
+/// Local Variables:
+/// mode: c++
+/// mode: hs-minor
+/// c-basic-offset: 4
+/// End:
Index: eliot/game/player.h
diff -u eliot/game/player.h:1.13 eliot/game/player.h:1.14
--- eliot/game/player.h:1.13 Sun Nov 6 17:13:45 2005
+++ eliot/game/player.h Mon Dec 26 21:18:21 2005
@@ -22,6 +22,7 @@
#include <vector>
#include "pldrack.h"
+#include "history.h"
class Turn;
@@ -51,6 +52,8 @@
void setCurrentRack(const PlayedRack &iPld);
+ const History& getHistory() const { return m_history; }
+
/**************************
* Acessors for the score of the player
**************************/
@@ -70,14 +73,8 @@
/// Score of the player
int m_score;
- /// Current played rack of the player
- 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<Turn*> m_history;
+ History m_history;
};
- [Eliot-dev] eliot/game player.h player.cpp,
eliot-dev <=