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

Diff of /eliot/game/history.cpp

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

revision 1.2 by ipkiss, Sun Oct 23 14:53:43 2005 UTC revision 1.2.2.1 by afrab, Sun Oct 23 17:16:24 2005 UTC
# Line 73  void History::setCurrentRack(const Playe Line 73  void History::setCurrentRack(const Playe
73      history.back()->setPlayedRack(iPld);      history.back()->setPlayedRack(iPld);
74  }  }
75    
 // vector  
 // size : number of elements  
 // back : last element  
 // pop_back : remove at the end  
 // push_back : add at the end  
76    
77  const Turn History::getPreviousTurn() const  const Turn History::getPreviousTurn() const
78  {  {
# Line 87  const Turn History::getPreviousTurn() co Line 82  const Turn History::getPreviousTurn() co
82  }  }
83    
84    
85    const Turn History::getTurn(unsigned int n) const
86    {
87        ASSERT(0 <= n && n < history.size(), "Wrong turn number");
88        return *(history[ n ]);
89    }
90    
91    
92  void History::playRound(int player, int turn, const Round& round)  void History::playRound(int player, int turn, const Round& round)
93  {  {
94      Rack rack;      Rack rack;
95      Turn * current_turn;      Turn * current_turn;
     Turn * next_turn;  
96            
97      current_turn = history.back();      current_turn = history.back();
98    
# Line 116  void History::playRound(int player, int Line 117  void History::playRound(int player, int
117      }      }
118    
119      /* create a new turn */      /* create a new turn */
120      next_turn = new Turn();      Turn * next_turn = new Turn();
121      next_turn->getPlayedRack().setOld(rack);      PlayedRack pldrack;
122        pldrack.setOld(rack);
123        next_turn->setPlayedRack(pldrack);
124      history.push_back ( next_turn );      history.push_back ( next_turn );
125  }  }
126    
# Line 148  void History::removeLastTurn() Line 151  void History::removeLastTurn()
151  std::string  std::string
152  History::toString() const  History::toString() const
153  {  {
154      std::string rs = "";      char buff[20];
155      unsigned int i;      unsigned int i;
156        std::string rs("");
157    #ifdef DEBUG
158        sprintf(buff,"%d",history.size());
159        rs = "hitory size = " + std::string(buff) + "\n\n";
160    #endif
161      for ( i = 0; i < history.size(); i++)      for ( i = 0; i < history.size(); i++)
162          {          {
163              string pr,ro;              Turn *t = history[i];
164              pr = history[i]->getPlayedRack().toString();              rs += t->toString() + std::string("\n");
             ro = history[i]->getRound().toString();  
             rs += string(" ") + pr + string(" ") + ro + string("\n");  
165          }          }
166      return rs;      return rs;
167  }  }

Legend:
Removed from v.1.2  
changed lines
  Added in v.1.2.2.1

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