diff --git a/game/duplicate.cpp b/game/duplicate.cpp index 4ac370a..5151fcc 100644 --- a/game/duplicate.cpp +++ b/game/duplicate.cpp @@ -43,7 +43,6 @@ #include "cmd/player_rack_cmd.h" #include "cmd/player_event_cmd.h" #include "cmd/game_move_cmd.h" -#include "cmd/game_rack_cmd.h" #include "cmd/master_move_cmd.h" #include "ai_player.h" #include "navigation.h" @@ -383,32 +382,6 @@ bool Duplicate::isArbitrationGame() const } -void Duplicate::setGameAndPlayersRack(const PlayedRack &iRack) -{ - // Set the game rack - Command *pCmd = new GameRackCmd(*this, iRack); - accessNavigation().addAndExecute(pCmd); - LOG_INFO("Setting players rack to '" + lfw(iRack.toString()) + "'"); - // All the players have the same rack - BOOST_FOREACH(Player *player, m_players) - { - Command *pCmd = new PlayerRackCmd(*player, iRack); - accessNavigation().addAndExecute(pCmd); - } - - // 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". - // This is also practical to know at which turn the warnings, penalties - // and solos should be assigned. - BOOST_FOREACH(Player *player, m_players) - { - Command *pCmd = new PlayerMoveCmd(*player, Move()); - accessNavigation().addAndExecute(pCmd); - } -} - - void Duplicate::setSoloAuto(unsigned int minNbPlayers, int iSoloValue) { // Remove all existing solos diff --git a/game/duplicate.h b/game/duplicate.h index 904be0c..b9300a2 100644 --- a/game/duplicate.h +++ b/game/duplicate.h @@ -26,7 +26,6 @@ #include "logging.h" class Player; -class PlayedRack; class Move; class PlayerEventCmd; @@ -113,9 +112,6 @@ protected: /// Record a player move void recordPlayerMove(Player &ioPlayer, const Move &iMove); - /// Helper function to set the game rack and the players rack at the same time - void setGameAndPlayersRack(const PlayedRack &iRack); - /** * This function does not terminate the turn itself, but performs some * checks to know whether or not it should be terminated (with a call to diff --git a/game/game.cpp b/game/game.cpp index 8e7e21f..68d3d32 100644 --- a/game/game.cpp +++ b/game/game.cpp @@ -43,6 +43,9 @@ #include "encoding.h" #include "game_exception.h" #include "turn.h" +#include "cmd/player_rack_cmd.h" +#include "cmd/player_move_cmd.h" +#include "cmd/game_rack_cmd.h" #include "debug.h" @@ -611,6 +614,33 @@ int Game::checkPlayedWord(const wstring &iCoord, } +void Game::setGameAndPlayersRack(const PlayedRack &iRack) +{ + // Set the game rack + Command *pCmd = new GameRackCmd(*this, iRack); + accessNavigation().addAndExecute(pCmd); + LOG_INFO("Setting players rack to '" + lfw(iRack.toString()) + "'"); + // All the players have the same rack + BOOST_FOREACH(Player *player, m_players) + { + Command *pCmd = new PlayerRackCmd(*player, iRack); + accessNavigation().addAndExecute(pCmd); + } + + // 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". + // This is also practical to know at which turn the warnings, penalties + // and solos should be assigned. + BOOST_FOREACH(Player *player, m_players) + { + Command *pCmd = new PlayerMoveCmd(*player, Move()); + accessNavigation().addAndExecute(pCmd); + } +} + + + Game::CurrentPlayerCmd::CurrentPlayerCmd(Game &ioGame, unsigned int iPlayerId) : m_game(ioGame), m_newPlayerId(iPlayerId), m_oldPlayerId(0) diff --git a/game/game.h b/game/game.h index b773a0e..8c9712d 100644 --- a/game/game.h +++ b/game/game.h @@ -278,6 +278,12 @@ protected: */ PlayedRack helperSetRackManual(bool iCheck, const wstring &iLetters) const; + /** + * 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 nextPlayer(); /**