mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-18 10:26:15 +01:00
- modified to use History
- add setRack wrapper for both manual and random
This commit is contained in:
parent
28fcd062bf
commit
3f4c290745
2 changed files with 56 additions and 31 deletions
|
@ -38,32 +38,6 @@ Training::~Training()
|
|||
{
|
||||
}
|
||||
|
||||
|
||||
int Training::play(const string &iCoord, const string &iWord)
|
||||
{
|
||||
/* Perform all the validity checks, and fill a round */
|
||||
Round round;
|
||||
int res = checkPlayedWord(iCoord, iWord, round);
|
||||
if (res != 0)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Update the rack and the score of the current player */
|
||||
m_players[m_currPlayer]->addPoints(round.getPoints());
|
||||
m_players[m_currPlayer]->endTurn(round, getNTurns());
|
||||
|
||||
/* Everything is OK, we can play the word */
|
||||
helperPlayRound(round);
|
||||
|
||||
/* Next turn */
|
||||
// XXX: Should it be done by the interface instead?
|
||||
endTurn();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int Training::setRackRandom(int p, bool iCheck, set_rack_mode mode)
|
||||
{
|
||||
int res;
|
||||
|
@ -78,7 +52,6 @@ int Training::setRackRandom(int p, bool iCheck, set_rack_mode mode)
|
|||
return res;
|
||||
}
|
||||
|
||||
|
||||
int Training::setRackManual(bool iCheck, const string &iLetters)
|
||||
{
|
||||
int res;
|
||||
|
@ -101,6 +74,48 @@ int Training::setRackManual(bool iCheck, const string &iLetters)
|
|||
return res;
|
||||
}
|
||||
|
||||
int Training::setRack(set_rack_mode iMode, bool iCheck, const string &iLetters)
|
||||
{
|
||||
int res = 0;
|
||||
switch(iMode)
|
||||
{
|
||||
case RACK_MANUAL:
|
||||
res = setRackManual(iCheck, iLetters);
|
||||
break;
|
||||
case RACK_ALL:
|
||||
res = setRackRandom(m_currPlayer, iCheck, iMode);
|
||||
break;
|
||||
case RACK_NEW:
|
||||
res = setRackRandom(m_currPlayer, iCheck, iMode);
|
||||
break;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
int Training::play(const string &iCoord, const string &iWord)
|
||||
{
|
||||
/* Perform all the validity checks, and fill a round */
|
||||
Round round;
|
||||
int res = checkPlayedWord(iCoord, iWord, round);
|
||||
if (res != 0)
|
||||
{
|
||||
return res;
|
||||
}
|
||||
|
||||
/* Update the rack and the score of the current player */
|
||||
m_players[m_currPlayer]->addPoints(round.getPoints());
|
||||
m_players[m_currPlayer]->endTurn(round, m_history.getSize());
|
||||
|
||||
/* Everything is OK, we can play the word */
|
||||
helperPlayRound(round);
|
||||
|
||||
/* Next turn */
|
||||
// XXX: Should it be done by the interface instead?
|
||||
endTurn();
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int Training::start()
|
||||
{
|
||||
|
@ -113,7 +128,6 @@ int Training::start()
|
|||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int Training::endTurn()
|
||||
{
|
||||
// Nothing to do?
|
||||
|
@ -126,7 +140,8 @@ void Training::search()
|
|||
// Search for the current player
|
||||
Rack r;
|
||||
m_players[m_currPlayer]->getCurrentRack().getRack(r);
|
||||
m_results.search(*m_dic, m_board, r, getNTurns());
|
||||
debug("Training::search for %s\n",r.toString().c_str());
|
||||
m_results.search(*m_dic, m_board, r, m_history.getSize());
|
||||
}
|
||||
|
||||
|
||||
|
@ -139,7 +154,7 @@ int Training::playResult(int n)
|
|||
|
||||
/* Update the rack and the score of the current player */
|
||||
player->addPoints(round.getPoints());
|
||||
player->endTurn(round, getNTurns());
|
||||
player->endTurn(round, m_history.getSize());
|
||||
|
||||
int res = helperPlayRound(round);
|
||||
|
||||
|
@ -187,3 +202,11 @@ std::string Training::getTestPlayWord() const
|
|||
return m_testRound.getWord();
|
||||
}
|
||||
|
||||
/****************************************************************/
|
||||
/****************************************************************/
|
||||
|
||||
/// Local Variables:
|
||||
/// mode: c++
|
||||
/// mode: hs-minor
|
||||
/// c-basic-offset: 4
|
||||
/// End:
|
||||
|
|
|
@ -47,12 +47,14 @@ public:
|
|||
* Game handling
|
||||
*************************/
|
||||
virtual int start();
|
||||
virtual int setRackRandom(int, bool, set_rack_mode);
|
||||
virtual int play(const string &iCoord, const string &iWord);
|
||||
virtual int endTurn();
|
||||
void search();
|
||||
int playResult(int);
|
||||
|
||||
virtual int setRackRandom(int, bool, set_rack_mode);
|
||||
int setRackManual(bool iCheck, const string &iLetters);
|
||||
int setRack(set_rack_mode iMode, bool iCheck, const string &iLetters);
|
||||
|
||||
/*************************
|
||||
* Override the default behaviour of these methods, because in training
|
||||
|
|
Loading…
Reference in a new issue