mirror of
git://git.savannah.nongnu.org/eliot.git
synced 2025-01-18 10:26:15 +01:00
New "auto-executable" flag for commands, not yet used
This commit is contained in:
parent
de2d2777e2
commit
e915e5f2cf
4 changed files with 15 additions and 1 deletions
|
@ -26,7 +26,7 @@ INIT_LOGGER(game, Command);
|
||||||
|
|
||||||
|
|
||||||
Command::Command()
|
Command::Command()
|
||||||
: m_executed(false), m_humanIndependent(true)
|
: m_executed(false), m_humanIndependent(true), m_autoExecutable(true)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -61,6 +61,8 @@ class Command
|
||||||
* allowed to call undo()), false otherwise.
|
* allowed to call undo()), false otherwise.
|
||||||
*/
|
*/
|
||||||
bool isExecuted() const { return m_executed; }
|
bool isExecuted() const { return m_executed; }
|
||||||
|
/// Return true if the command is auto-executable
|
||||||
|
virtual bool isAutoExecutable() const { return m_autoExecutable; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark the command as human independent, which means that it will
|
* Mark the command as human independent, which means that it will
|
||||||
|
@ -82,9 +84,19 @@ class Command
|
||||||
virtual void doExecute() = 0;
|
virtual void doExecute() = 0;
|
||||||
virtual void doUndo() = 0;
|
virtual void doUndo() = 0;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark the command as auto-executable.
|
||||||
|
* When the commands history is set to a particular turn, all the
|
||||||
|
* auto-executable commands for this turn will be executed until
|
||||||
|
* the first non-auto-executable one (excluded).
|
||||||
|
* This allows replaying some actions (like setting the rack) at the beginning of a turn.
|
||||||
|
*/
|
||||||
|
void setAutoExecutable(bool autoExec) { m_autoExecutable = autoExec; }
|
||||||
|
|
||||||
private:
|
private:
|
||||||
bool m_executed;
|
bool m_executed;
|
||||||
bool m_humanIndependent;
|
bool m_humanIndependent;
|
||||||
|
bool m_autoExecutable;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -37,6 +37,7 @@ GameMoveCmd::GameMoveCmd(Game &ioGame, const Move &iMove,
|
||||||
m_moveRack(ioGame.getPlayer(iPlayerId).getHistory().getPreviousTurn().getPlayedRack()),
|
m_moveRack(ioGame.getPlayer(iPlayerId).getHistory().getPreviousTurn().getPlayedRack()),
|
||||||
m_playerId(iPlayerId)
|
m_playerId(iPlayerId)
|
||||||
{
|
{
|
||||||
|
setAutoExecutable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,7 @@ INIT_LOGGER(game, PlayerMoveCmd);
|
||||||
PlayerMoveCmd::PlayerMoveCmd(Player &ioPlayer, const Move &iMove)
|
PlayerMoveCmd::PlayerMoveCmd(Player &ioPlayer, const Move &iMove)
|
||||||
: m_player(ioPlayer), m_move(iMove)
|
: m_player(ioPlayer), m_move(iMove)
|
||||||
{
|
{
|
||||||
|
setAutoExecutable(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue