Topping: do not assign an empty move to the player immediately.

It is now done only after a timeout, to avoid the need to replace
this empty move when the player finds a top move.
This commit is contained in:
Olivier Teulière 2013-01-15 11:38:46 +01:00
parent 086b597f3e
commit 89b5f757ca
5 changed files with 18 additions and 19 deletions

View file

@ -51,7 +51,7 @@ void Arbitration::setRackRandom()
const PlayedRack &newRack =
helperSetRackRandom(getHistory().getCurrentRack(), true, RACK_NEW);
setGameAndPlayersRack(newRack);
setGameAndPlayersRack(newRack, true);
}
@ -68,7 +68,7 @@ void Arbitration::setRackManual(const wstring &iLetters)
// As a result, we simply make all the letters uppercase
const wstring &upperLetters = toUpper(iLetters);
const PlayedRack &newRack = helperSetRackManual(false, upperLetters);
setGameAndPlayersRack(newRack);
setGameAndPlayersRack(newRack, true);
}

View file

@ -132,12 +132,12 @@ void Duplicate::start()
bool fillRacks = Settings::Instance().getBool("arbitration.fill-rack");
if (isArbitrationGame() && !fillRacks && !hasMasterGame())
setGameAndPlayersRack(getHistory().getCurrentRack());
setGameAndPlayersRack(getHistory().getCurrentRack(), true);
else
{
const PlayedRack &newRack =
helperSetRackRandom(getHistory().getCurrentRack(), true, RACK_NEW);
setGameAndPlayersRack(newRack);
setGameAndPlayersRack(newRack, true);
}
}
catch (EndGameException &e)

View file

@ -682,7 +682,7 @@ int Game::checkPlayedWord(const wstring &iCoord,
}
void Game::setGameAndPlayersRack(const PlayedRack &iRack)
void Game::setGameAndPlayersRack(const PlayedRack &iRack, bool iWithNoMove)
{
// Set the game rack
Command *pCmd = new GameRackCmd(*this, iRack);
@ -695,9 +695,11 @@ void Game::setGameAndPlayersRack(const PlayedRack &iRack)
accessNavigation().addAndExecute(pCmd);
}
if (iWithNoMove)
{
// Assign a "no move" pseudo-move to all the players.
// This avoids the need to distinguish between "has not played yet"
// and "has played with no move".
// and "has played with no move" in duplicate and arbitration modes.
// This is also practical to know at which turn the warnings, penalties
// and solos should be assigned.
BOOST_FOREACH(Player *player, m_players)
@ -706,6 +708,7 @@ void Game::setGameAndPlayersRack(const PlayedRack &iRack)
accessNavigation().addAndExecute(pCmd);
}
}
}
Game::CurrentPlayerCmd::CurrentPlayerCmd(Game &ioGame,

View file

@ -324,7 +324,7 @@ protected:
* Helper function to set the game rack and the players rack at the same time.
* Shouldn't be used in free game mode.
*/
void setGameAndPlayersRack(const PlayedRack &iRack);
void setGameAndPlayersRack(const PlayedRack &iRack, bool iWithNoMove);
void nextPlayer();

View file

@ -65,7 +65,7 @@ void Topping::start()
{
const PlayedRack &newRack =
helperSetRackRandom(getHistory().getCurrentRack(), true, RACK_NEW);
setGameAndPlayersRack(newRack);
setGameAndPlayersRack(newRack, false);
}
catch (EndGameException &e)
{
@ -121,13 +121,9 @@ void Topping::turnTimeOut()
m_board.removeTestRound();
// Commented out, because the player already has
// an empty move by default
#if 0
// The player didn't find the move
Command *pCmd = new PlayerMoveCmd(*m_players[m_currPlayer], Move());
accessNavigation().addAndExecute(pCmd);
#endif
// Give a penalty to the player
// XXX: should we give the penalty directly in the NO_MOVE move?