[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Eliot-dev] eliot/game training.h training.cpp
From: |
eliot-dev |
Subject: |
[Eliot-dev] eliot/game training.h training.cpp |
Date: |
Mon, 26 Dec 2005 22:53:27 +0000 |
CVSROOT: /cvsroot/eliot
Module name: eliot
Branch:
Changes by: Antoine Fraboulet <address@hidden> 05/12/26 22:53:27
Modified files:
game : training.h training.cpp
Log message:
- modified to use History
- add setRack wrapper for both manual and random
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/training.h.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
http://cvs.savannah.gnu.org/viewcvs/eliot/eliot/game/training.cpp.diff?tr1=1.12&tr2=1.13&r1=text&r2=text
Patches:
Index: eliot/game/training.cpp
diff -u eliot/game/training.cpp:1.12 eliot/game/training.cpp:1.13
--- eliot/game/training.cpp:1.12 Mon Dec 26 18:07:26 2005
+++ eliot/game/training.cpp Mon Dec 26 22:53:26 2005
@@ -38,32 +38,6 @@
{
}
-
-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 @@
return res;
}
-
int Training::setRackManual(bool iCheck, const string &iLetters)
{
int res;
@@ -101,6 +74,48 @@
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 @@
return 0;
}
-
int Training::endTurn()
{
// Nothing to do?
@@ -126,7 +140,8 @@
// 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 @@
/* 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 @@
return m_testRound.getWord();
}
+/****************************************************************/
+/****************************************************************/
+
+/// Local Variables:
+/// mode: c++
+/// mode: hs-minor
+/// c-basic-offset: 4
+/// End:
Index: eliot/game/training.h
diff -u eliot/game/training.h:1.12 eliot/game/training.h:1.13
--- eliot/game/training.h:1.12 Mon Dec 26 18:07:26 2005
+++ eliot/game/training.h Mon Dec 26 22:53:26 2005
@@ -47,12 +47,14 @@
* 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