/[eliot]/eliot/utils/game_io.cpp
ViewVC logotype

Diff of /eliot/utils/game_io.cpp

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

revision 1.2 by ipkiss, Sun Oct 23 14:53:44 2005 UTC revision 1.2.2.1 by afrab, Sun Oct 23 17:16:24 2005 UTC
# Line 43  void GameIO::printBoard(ostream &out, co Line 43  void GameIO::printBoard(ostream &out, co
43          out << " " << (char)(row - BOARD_MIN + 'A') << " ";          out << " " << (char)(row - BOARD_MIN + 'A') << " ";
44          for (col = BOARD_MIN; col <= BOARD_MAX; col++)          for (col = BOARD_MIN; col <= BOARD_MAX; col++)
45          {          {
46              char l = iGame.getBoardChar(row, col);              char l = iGame.getBoard().getChar(row, col);
47              out << setw(3) << (l ? l : '-');              out << setw(3) << (l ? l : '-');
48          }          }
49          out << endl;          out << endl;
# Line 65  void GameIO::printBoardJoker(ostream &ou Line 65  void GameIO::printBoardJoker(ostream &ou
65          out << " " << (char)(row - BOARD_MIN + 'A') << " ";          out << " " << (char)(row - BOARD_MIN + 'A') << " ";
66          for (col = BOARD_MIN; col <= BOARD_MAX; col++)          for (col = BOARD_MIN; col <= BOARD_MAX; col++)
67          {          {
68              char l = iGame.getBoardChar(row, col);              char l = iGame.getBoard().getChar(row, col);
69              bool j = (iGame.getBoardCharAttr(row, col) & ATTR_JOKER);              bool j = (iGame.getBoard().getCharAttr(row, col) & ATTR_JOKER);
70    
71              out << " " << (j ? '.' : (l ? ' ' : '-'));              out << " " << (j ? '.' : (l ? ' ' : '-'));
72              out << (l ? l : '-');              out << (l ? l : '-');
# Line 90  void GameIO::printBoardMultipliers(ostre Line 90  void GameIO::printBoardMultipliers(ostre
90          out << " " << (char)(row - BOARD_MIN + 'A') << " ";          out << " " << (char)(row - BOARD_MIN + 'A') << " ";
91          for (col = BOARD_MIN; col <= BOARD_MAX; col++)          for (col = BOARD_MIN; col <= BOARD_MAX; col++)
92          {          {
93              char l = iGame.getBoardChar(row, col);              char l = iGame.getBoard().getChar(row, col);
94              if (l != 0)              if (l != 0)
95                  out << "  " << l;                  out << "  " << l;
96              else              else
97              {              {
98                  int wm = iGame.getBoardWordMultiplier(row, col);                  int wm = iGame.getBoard().getWordMultiplier(row, col);
99                  int tm = iGame.getBoardLetterMultiplier(row, col);                  int tm = iGame.getBoard().getLetterMultiplier(row, col);
100    
101                  if (wm > 1)                  if (wm > 1)
102                      out << "  " << ((wm == 3) ? '@' : '#');                      out << "  " << ((wm == 3) ? '@' : '#');
# Line 125  void GameIO::printBoardMultipliers2(ostr Line 125  void GameIO::printBoardMultipliers2(ostr
125          out << " " << (char)(row - BOARD_MIN + 'A') << " ";          out << " " << (char)(row - BOARD_MIN + 'A') << " ";
126          for (col = BOARD_MIN; col <= BOARD_MAX; col++)          for (col = BOARD_MIN; col <= BOARD_MAX; col++)
127          {          {
128              char l = iGame.getBoardChar(row, col);              char l = iGame.getBoard().getChar(row, col);
129              int wm = iGame.getBoardWordMultiplier(row, col);              int wm = iGame.getBoard().getWordMultiplier(row, col);
130              int tm = iGame.getBoardLetterMultiplier(row, col);              int tm = iGame.getBoard().getLetterMultiplier(row, col);
131    
132              if (wm > 1)              if (wm > 1)
133                  out << " " << ((wm == 3) ? '@' : '#');                  out << " " << ((wm == 3) ? '@' : '#');
# Line 149  void GameIO::printNonPlayed(ostream &out Line 149  void GameIO::printNonPlayed(ostream &out
149    
150      for (it = allTiles.begin(); it != allTiles.end(); it++)      for (it = allTiles.begin(); it != allTiles.end(); it++)
151      {      {
152          if (iGame.getNCharInBag(it->toChar()) > 9)          if (iGame.getBag().in(it->toChar()) > 9)
153              out << " ";              out << " ";
154          out << setw(2) << it->toChar();          out << setw(2) << it->toChar();
155      }      }
# Line 157  void GameIO::printNonPlayed(ostream &out Line 157  void GameIO::printNonPlayed(ostream &out
157    
158      for (it = allTiles.begin(); it != allTiles.end(); it++)      for (it = allTiles.begin(); it != allTiles.end(); it++)
159      {      {
160          out << " " << iGame.getNCharInBag(it->toChar());          out << " " << iGame.getBag().in(it->toChar());
161      }      }
162      out << endl;      out << endl;
163  }  }
# Line 165  void GameIO::printNonPlayed(ostream &out Line 165  void GameIO::printNonPlayed(ostream &out
165    
166  void GameIO::printPlayedRack(ostream &out, const Game &iGame, int n)  void GameIO::printPlayedRack(ostream &out, const Game &iGame, int n)
167  {  {
168      out << iGame.getPlayerRack(iGame.currPlayer()) << endl;      out << iGame.getCurrentPlayer().getCurrentRack().toString() << endl;
169  }  }
170    
171    
# Line 174  void GameIO::printAllRacks(ostream &out, Line 174  void GameIO::printAllRacks(ostream &out,
174      for (int j = 0; j < iGame.getNPlayers(); j++)      for (int j = 0; j < iGame.getNPlayers(); j++)
175      {      {
176          out << "Joueur " << j << ": ";          out << "Joueur " << j << ": ";
177          out << iGame.getPlayerRack(j) << endl;          out << iGame.getPlayer(j).getCurrentRack().toString() << endl;
178      }      }
179  }  }
180    
181    
182  static void searchResultLine(ostream &out, const Training &iGame, int num)  static void searchResultLine(ostream &out, const Training &iGame, int num)
183  {  {
184      string word = iGame.getSearchedWord(num);    Round r = iGame.getResults().get(num);
185      if (word.size() == 0)    string word = r.getWord();
186          return;    if (word.size() == 0)
187      out << word << string(16 - word.size(), ' ')      return;
188          << (iGame.getSearchedBonus(num) ? '*' : ' ')    out << word << string(16 - word.size(), ' ')
189          << setw(4) << iGame.getSearchedPoints(num)        << (r.getBonus() ? '*' : ' ')
190          << ' ' << iGame.getSearchedCoords(num);        << setw(4) << r.getPoints()
191          << ' ' << r.getCoord().toString();
192  }  }
193    
194    
195  void GameIO::printSearchResults(ostream &out, const Training &iGame, int num)  void GameIO::printSearchResults(ostream &out, const Training &iGame, int num)
196  {  {
197      for (int i = 0; i < num && i < iGame.getNResults(); i++)    Results r = iGame.getResults();
198      for (int i = 0; i < num && i < r.size(); i++)
199      {      {
200          out << setw(3) << i + 1 << ": ";          out << setw(3) << i + 1 << ": ";
201          searchResultLine(out, iGame, i);          searchResultLine(out, iGame, i);
# Line 204  void GameIO::printSearchResults(ostream Line 206  void GameIO::printSearchResults(ostream
206    
207  void GameIO::printPoints(ostream &out, const Game &iGame)  void GameIO::printPoints(ostream &out, const Game &iGame)
208  {  {
209      out << iGame.getPlayerPoints(0) << endl;      out << iGame.getPlayer(0).getPoints() << endl;
210  }  }
211    
212    
# Line 213  void GameIO::printAllPoints(ostream &out Line 215  void GameIO::printAllPoints(ostream &out
215      for (int i = 0; i < iGame.getNPlayers(); i++)      for (int i = 0; i < iGame.getNPlayers(); i++)
216      {      {
217          out << "Joueur " << i << ": "          out << "Joueur " << i << ": "
218              << setw(4) << iGame.getPlayerPoints(i) << endl;              << setw(4) << iGame.getPlayer(i).getPoints() << endl;
219      }      }
220  }  }
221    

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