/[eliot]/eliot/game/player.cpp
ViewVC logotype

Diff of /eliot/game/player.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1.6 by ipkiss, Fri Nov 4 20:00:06 2005 UTC revision 1.7 by ipkiss, Sat Nov 5 23:57:41 2005 UTC
# Line 27  Line 27 
27    
28  #include "debug.h"  #include "debug.h"
29    
30  Player::Player():  
31      m_score(0)  Player::Player()
32  {  {
33      // Start with an empty rack      m_score = 0;
     m_playedRacks.push_back(new PlayedRack());  
34  }  }
35    
36    
# Line 46  Player::~Player() Line 45  Player::~Player()
45    
46  const PlayedRack & Player::getCurrentRack() const  const PlayedRack & Player::getCurrentRack() const
47  {  {
48      return *m_playedRacks.back();      return m_pldrack;
49  }  }
50    
51    
52  void Player::setCurrentRack(const PlayedRack &iPld)  void Player::setCurrentRack(const PlayedRack &iPld)
53  {  {
54      *m_playedRacks.back() = iPld;      m_pldrack = iPld;
55  }  }
56    
57    
58  const PlayedRack & Player::getLastRack() const  const PlayedRack & Player::getLastRack() const
59  {  {
60      return *m_playedRacks[m_playedRacks.size() - 2];      return *m_playedRacks.back();
61  }  }
62    
63    
# Line 77  void Player::endTurn(const Round &iRound Line 76  void Player::endTurn(const Round &iRound
76  {  {
77      m_turns.push_back(iTurn);      m_turns.push_back(iTurn);
78      m_rounds.push_back(new Round(iRound));      m_rounds.push_back(new Round(iRound));
79        m_playedRacks.push_back(new PlayedRack(m_pldrack));
80    
81      Rack rack;      Rack rack;
82      m_playedRacks.back()->getRack(rack);      m_pldrack.getRack(rack);
83    
84      /* We remove the played tiles from the rack */      // We remove the played tiles from the rack
85      for (int i = 0; i < iRound.getWordLen(); i++)      for (int i = 0; i < iRound.getWordLen(); i++)
86      {      {
87          if (iRound.isPlayedFromRack(i))          if (iRound.isPlayedFromRack(i))
# Line 93  void Player::endTurn(const Round &iRound Line 93  void Player::endTurn(const Round &iRound
93          }          }
94      }      }
95    
96      m_playedRacks.push_back(new PlayedRack());      // Now reinitialize the current rack with the remaining tiles
97      /* Now m_playedRacks.back() is the newly created PlayedRack object */      m_pldrack = PlayedRack();
98      m_playedRacks.back()->setOld(rack);      m_pldrack.setOld(rack);
99  }  }
100    

Legend:
Removed from v.1.6  
changed lines
  Added in v.1.7

savannah-hackers-public@gnu.org
ViewVC Help
Powered by ViewVC 1.1.26