18 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
19 |
*****************************************************************************/ |
*****************************************************************************/ |
20 |
|
|
|
/* $Id$ */ |
|
|
|
|
21 |
/** |
/** |
22 |
* \file game.cpp |
* \file game.cpp |
23 |
* \brief Eliot game class |
* \brief Eliot game class |
53 |
{ |
{ |
54 |
} |
} |
55 |
|
|
56 |
const Player& |
const Player& Game::getPlayer(int num) const |
|
Game::getPlayer(int num) const |
|
57 |
{ |
{ |
58 |
ASSERT(0 <= num && num < (int)m_players.size(),"Wrong player number"); |
ASSERT(0 <= num && num < (int)m_players.size(),"Wrong player number"); |
59 |
return *(m_players[num]); |
return *(m_players[num]); |
69 |
m_players.push_back(new AIPercent(0)); |
m_players.push_back(new AIPercent(0)); |
70 |
} |
} |
71 |
|
|
72 |
int Game::play(int player, const std::string iCoord, const std::string iWord) |
int Game::play(int player, const std::string &iCoord, const std::string &iWord) |
73 |
{ |
{ |
74 |
return play(player,Coord(iCoord),iWord); |
return play(player, Coord(iCoord), iWord); |
75 |
} |
} |
76 |
|
|
77 |
int Game::play(int player, const Coord& iCoord, const std::string &iWord) |
int Game::play(int player, const Coord& iCoord, const std::string &iWord) |
78 |
{ |
{ |
79 |
Round round; |
Round round; |
80 |
checkPlayedWord(iCoord,iWord,round); |
checkPlayedWord(iCoord, iWord, round); |
81 |
return play(player,round); |
return play(player, round); |
82 |
} |
} |
83 |
|
|
84 |
int Game::back(int n) |
int Game::back(int n) |
85 |
{ |
{ |
86 |
int i; |
int i; |
87 |
for(i=0; i<n; i++) |
for (i = 0; i < n; i++) |
88 |
{ |
{ |
89 |
back(); |
back(); |
90 |
} |
} |
91 |
return 0; |
return 0; |
92 |
} |
} |
93 |
|
|
122 |
* and specify the origin of each letter (board or rack) */ |
* and specify the origin of each letter (board or rack) */ |
123 |
res = m_board.checkRound(oRound, m_history.getSize() == 1); |
res = m_board.checkRound(oRound, m_history.getSize() == 1); |
124 |
if (res != 0) |
if (res != 0) |
125 |
return res + 4; |
return res + 4; |
126 |
|
|
127 |
/* Check that the word can be formed with the tiles in the rack: |
/* Check that the word can be formed with the tiles in the rack: |
128 |
* we first create a copy of the rack, then we remove the tiles |
* we first create a copy of the rack, then we remove the tiles |
158 |
return checkPlayedWord(oRound); |
return checkPlayedWord(oRound); |
159 |
} |
} |
160 |
|
|
161 |
int Game::setRack(int player, PlayedRack::set_rack_mode mode, bool check, std::string rack) |
int Game::setRack(int player, PlayedRack::set_rack_mode mode, bool check, const std::string &iRack) |
162 |
{ |
{ |
163 |
int result; |
PlayedRack newrack = m_players[player]->getCurrentRack(); |
164 |
PlayedRack newrack; |
int result = newrack.replace(m_bag,mode, iRack); |
|
|
|
|
newrack = m_players[player]->getCurrentRack(); |
|
|
result = newrack.replace(m_bag,mode,rack); |
|
165 |
m_players[player]->setCurrentRack(newrack); |
m_players[player]->setCurrentRack(newrack); |
166 |
return result; |
return result; |
167 |
} |
} |
168 |
|
|
169 |
|
|
170 |
/// Local Variables: |
/// Local Variables: |
171 |
/// mode: hs-minor |
/// mode: hs-minor |
172 |
/// c-basic-offset: 4 |
/// c-basic-offset: 4 |