mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-18 10:26:15 +01:00
Let the PlayerMoveCmd decide whether it is human independent.
It fixes problems when trying to replay turns on a loaded game.
This commit is contained in:
parent
74d4572a0a
commit
58c88a3078
5 changed files with 7 additions and 12 deletions
|
@ -221,7 +221,6 @@ void Duplicate::recordPlayerMove(Player &ioPlayer, const Move &iMove)
|
||||||
if (cmd == 0)
|
if (cmd == 0)
|
||||||
{
|
{
|
||||||
Command *pCmd = new PlayerMoveCmd(ioPlayer, iMove, isArbitrationGame());
|
Command *pCmd = new PlayerMoveCmd(ioPlayer, iMove, isArbitrationGame());
|
||||||
pCmd->setHumanIndependent(!ioPlayer.isHuman());
|
|
||||||
accessNavigation().addAndExecute(pCmd);
|
accessNavigation().addAndExecute(pCmd);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -231,7 +230,6 @@ void Duplicate::recordPlayerMove(Player &ioPlayer, const Move &iMove)
|
||||||
if (!isArbitrationGame() && !getNavigation().isLastTurn())
|
if (!isArbitrationGame() && !getNavigation().isLastTurn())
|
||||||
throw GameException("Cannot add a command to an old turn");
|
throw GameException("Cannot add a command to an old turn");
|
||||||
Command *pCmd = new PlayerMoveCmd(ioPlayer, iMove, isArbitrationGame());
|
Command *pCmd = new PlayerMoveCmd(ioPlayer, iMove, isArbitrationGame());
|
||||||
pCmd->setHumanIndependent(!ioPlayer.isHuman());
|
|
||||||
accessNavigation().replaceCommand(*cmd, pCmd);
|
accessNavigation().replaceCommand(*cmd, pCmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -431,7 +429,6 @@ void Duplicate::setGameAndPlayersRack(const PlayedRack &iRack)
|
||||||
BOOST_FOREACH(Player *player, m_players)
|
BOOST_FOREACH(Player *player, m_players)
|
||||||
{
|
{
|
||||||
Command *pCmd = new PlayerMoveCmd(*player, Move(), true);
|
Command *pCmd = new PlayerMoveCmd(*player, Move(), true);
|
||||||
pCmd->setHumanIndependent(!player->isHuman());
|
|
||||||
accessNavigation().addAndExecute(pCmd);
|
accessNavigation().addAndExecute(pCmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -71,7 +71,7 @@ int FreeGame::play(const wstring &iCoord, const wstring &iWord)
|
||||||
Move move(round);
|
Move move(round);
|
||||||
|
|
||||||
// Update the rack and the score of the current player
|
// Update the rack and the score of the current player
|
||||||
recordPlayerMove(move, *m_players[m_currPlayer], true);
|
recordPlayerMove(move, *m_players[m_currPlayer]);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -81,7 +81,7 @@ int FreeGame::play(const wstring &iCoord, const wstring &iWord)
|
||||||
Move move(dispWord, iCoord);
|
Move move(dispWord, iCoord);
|
||||||
|
|
||||||
// Record the invalid move of the player
|
// Record the invalid move of the player
|
||||||
recordPlayerMove(move, *m_players[m_currPlayer], true);
|
recordPlayerMove(move, *m_players[m_currPlayer]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Next turn
|
// Next turn
|
||||||
|
@ -107,18 +107,16 @@ void FreeGame::playAI(unsigned int p)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update the rack and the score of the current player
|
// Update the rack and the score of the current player
|
||||||
recordPlayerMove(move, *player, false);
|
recordPlayerMove(move, *player);
|
||||||
|
|
||||||
endTurn();
|
endTurn();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void FreeGame::recordPlayerMove(const Move &iMove, Player &ioPlayer,
|
void FreeGame::recordPlayerMove(const Move &iMove, Player &ioPlayer)
|
||||||
bool isForHuman)
|
|
||||||
{
|
{
|
||||||
LOG_INFO("Player " << ioPlayer.getId() << " plays: " << lfw(iMove.toString()));
|
LOG_INFO("Player " << ioPlayer.getId() << " plays: " << lfw(iMove.toString()));
|
||||||
Command *pCmd = new PlayerMoveCmd(ioPlayer, iMove);
|
Command *pCmd = new PlayerMoveCmd(ioPlayer, iMove);
|
||||||
pCmd->setHumanIndependent(!isForHuman);
|
|
||||||
accessNavigation().addAndExecute(pCmd);
|
accessNavigation().addAndExecute(pCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -312,7 +310,7 @@ int FreeGame::pass(const wstring &iToChange)
|
||||||
|
|
||||||
Move move(iToChange);
|
Move move(iToChange);
|
||||||
// End the player's turn
|
// End the player's turn
|
||||||
recordPlayerMove(move, player, true);
|
recordPlayerMove(move, player);
|
||||||
|
|
||||||
// Next game turn
|
// Next game turn
|
||||||
endTurn();
|
endTurn();
|
||||||
|
|
|
@ -88,7 +88,7 @@ private:
|
||||||
void playAI(unsigned int p);
|
void playAI(unsigned int p);
|
||||||
|
|
||||||
/// Record a player move
|
/// Record a player move
|
||||||
void recordPlayerMove(const Move &iMove, Player &ioPlayer, bool isForHuman);
|
void recordPlayerMove(const Move &iMove, Player &ioPlayer);
|
||||||
|
|
||||||
/// Finish the current turn
|
/// Finish the current turn
|
||||||
int endTurn();
|
int endTurn();
|
||||||
|
|
|
@ -31,6 +31,7 @@ PlayerMoveCmd::PlayerMoveCmd(Player &ioPlayer, const Move &iMove, bool iAutoExec
|
||||||
: m_player(ioPlayer), m_move(iMove)
|
: m_player(ioPlayer), m_move(iMove)
|
||||||
{
|
{
|
||||||
setAutoExecutable(iAutoExec || iMove.isNull());
|
setAutoExecutable(iAutoExec || iMove.isNull());
|
||||||
|
setHumanIndependent(!ioPlayer.isHuman());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -123,7 +123,6 @@ void Training::recordPlayerMove(const Move &iMove, Player &ioPlayer)
|
||||||
// (called in this class in endTurn()).
|
// (called in this class in endTurn()).
|
||||||
// See the big comment in game.cpp, line 96
|
// See the big comment in game.cpp, line 96
|
||||||
Command *pCmd = new PlayerMoveCmd(ioPlayer, iMove);
|
Command *pCmd = new PlayerMoveCmd(ioPlayer, iMove);
|
||||||
pCmd->setHumanIndependent(false);
|
|
||||||
accessNavigation().addAndExecute(pCmd);
|
accessNavigation().addAndExecute(pCmd);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue