mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-30 20:34:27 +01:00
Move Duplicate::setGameAndPlayersRack() to Game
This commit is contained in:
parent
c775682881
commit
c138947138
4 changed files with 36 additions and 31 deletions
|
@ -43,7 +43,6 @@
|
||||||
#include "cmd/player_rack_cmd.h"
|
#include "cmd/player_rack_cmd.h"
|
||||||
#include "cmd/player_event_cmd.h"
|
#include "cmd/player_event_cmd.h"
|
||||||
#include "cmd/game_move_cmd.h"
|
#include "cmd/game_move_cmd.h"
|
||||||
#include "cmd/game_rack_cmd.h"
|
|
||||||
#include "cmd/master_move_cmd.h"
|
#include "cmd/master_move_cmd.h"
|
||||||
#include "ai_player.h"
|
#include "ai_player.h"
|
||||||
#include "navigation.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)
|
void Duplicate::setSoloAuto(unsigned int minNbPlayers, int iSoloValue)
|
||||||
{
|
{
|
||||||
// Remove all existing solos
|
// Remove all existing solos
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
#include "logging.h"
|
#include "logging.h"
|
||||||
|
|
||||||
class Player;
|
class Player;
|
||||||
class PlayedRack;
|
|
||||||
class Move;
|
class Move;
|
||||||
class PlayerEventCmd;
|
class PlayerEventCmd;
|
||||||
|
|
||||||
|
@ -113,9 +112,6 @@ protected:
|
||||||
/// Record a player move
|
/// Record a player move
|
||||||
void recordPlayerMove(Player &ioPlayer, const Move &iMove);
|
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
|
* 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
|
* checks to know whether or not it should be terminated (with a call to
|
||||||
|
|
|
@ -43,6 +43,9 @@
|
||||||
#include "encoding.h"
|
#include "encoding.h"
|
||||||
#include "game_exception.h"
|
#include "game_exception.h"
|
||||||
#include "turn.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"
|
#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,
|
Game::CurrentPlayerCmd::CurrentPlayerCmd(Game &ioGame,
|
||||||
unsigned int iPlayerId)
|
unsigned int iPlayerId)
|
||||||
: m_game(ioGame), m_newPlayerId(iPlayerId), m_oldPlayerId(0)
|
: m_game(ioGame), m_newPlayerId(iPlayerId), m_oldPlayerId(0)
|
||||||
|
|
|
@ -278,6 +278,12 @@ protected:
|
||||||
*/
|
*/
|
||||||
PlayedRack helperSetRackManual(bool iCheck, const wstring &iLetters) const;
|
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();
|
void nextPlayer();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Add table
Reference in a new issue