Renamed some methods

This commit is contained in:
Olivier Teulière 2012-02-19 16:23:58 +01:00
parent 038910e5df
commit 59fac223f4
8 changed files with 18 additions and 18 deletions

View file

@ -26,7 +26,7 @@ INIT_LOGGER(game, Command);
Command::Command() Command::Command()
: m_executed(false), m_autoExecution(true) : m_executed(false), m_humanIndependent(true)
{ {
} }

View file

@ -63,15 +63,15 @@ class Command
bool isExecuted() const { return m_executed; } bool isExecuted() const { return m_executed; }
/** /**
* Mark the command as auto-executable, which means that it will * Mark the command as human independent, which means that it will
* be automatically executed if the commands history is cleared * be automatically executed if the commands history is cleared
* just before this command. * just before this command.
* Auto-executable commands correspond to commands for AI players, * It is mostly useful in FreeGame mode, where a turn played by an AI
* for which the user cannot change the behaviour. * player should be re-executed, because the user cannot control it.
*/ */
void setAutoExecution(bool autoExec) { m_autoExecution = autoExec; } void setHumanIndependent(bool humanIndependent) { m_humanIndependent = humanIndependent; }
/// Return true if the command is auto-executable /// Return true if the command is human independent
virtual bool isAutoExecution() const { return m_autoExecution; } virtual bool isHumanIndependent() const { return m_humanIndependent; }
/** /**
* Description of the command, for debugging purposes * Description of the command, for debugging purposes
@ -84,7 +84,7 @@ class Command
private: private:
bool m_executed; bool m_executed;
bool m_autoExecution; bool m_humanIndependent;
}; };
#endif #endif

View file

@ -194,11 +194,11 @@ void Duplicate::recordPlayerMove(const Move &iMove, Player &ioPlayer, bool isFor
{ {
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->setAutoExecution(!isForHuman); pCmd->setHumanIndependent(!isForHuman);
accessNavigation().addAndExecute(pCmd); accessNavigation().addAndExecute(pCmd);
Command *pCmd2 = new MarkPlayedCmd(*this, ioPlayer.getId(), true); Command *pCmd2 = new MarkPlayedCmd(*this, ioPlayer.getId(), true);
pCmd2->setAutoExecution(!isForHuman); pCmd2->setHumanIndependent(!isForHuman);
accessNavigation().addAndExecute(pCmd2); accessNavigation().addAndExecute(pCmd2);
} }

View file

@ -118,7 +118,7 @@ void FreeGame::recordPlayerMove(const Move &iMove, Player &ioPlayer,
{ {
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->setAutoExecution(!isForHuman); pCmd->setHumanIndependent(!isForHuman);
accessNavigation().addAndExecute(pCmd); accessNavigation().addAndExecute(pCmd);
} }

View file

@ -158,7 +158,7 @@ void Navigation::clearFuture()
// Replay the auto-execution turns // Replay the auto-execution turns
// (i.e. turns where only the AI was involved) // (i.e. turns where only the AI was involved)
while (!isLastTurn() && m_turnCommands[m_currTurn]->isAutoExecution()) while (!isLastTurn() && m_turnCommands[m_currTurn]->isHumanIndependent())
nextTurn(); nextTurn();
// When there is no future, don't do anything // When there is no future, don't do anything

View file

@ -62,7 +62,7 @@ void Training::setRackRandom(bool iCheck, set_rack_mode mode)
const PlayedRack &newRack = const PlayedRack &newRack =
helperSetRackRandom(getCurrentPlayer().getCurrentRack(), iCheck, mode); helperSetRackRandom(getCurrentPlayer().getCurrentRack(), iCheck, mode);
Command *pCmd = new PlayerRackCmd(*m_players[m_currPlayer], newRack); Command *pCmd = new PlayerRackCmd(*m_players[m_currPlayer], newRack);
pCmd->setAutoExecution(false); pCmd->setHumanIndependent(false);
accessNavigation().addAndExecute(pCmd); accessNavigation().addAndExecute(pCmd);
} }
@ -78,7 +78,7 @@ void Training::setRackManual(bool iCheck, const wstring &iLetters)
upperLetters.begin(), towupper); upperLetters.begin(), towupper);
const PlayedRack &newRack = helperSetRackManual(iCheck, upperLetters); const PlayedRack &newRack = helperSetRackManual(iCheck, upperLetters);
Command *pCmd = new PlayerRackCmd(*m_players[m_currPlayer], newRack); Command *pCmd = new PlayerRackCmd(*m_players[m_currPlayer], newRack);
pCmd->setAutoExecution(false); pCmd->setHumanIndependent(false);
accessNavigation().addAndExecute(pCmd); accessNavigation().addAndExecute(pCmd);
// Clear the results if everything went well // Clear the results if everything went well
m_results.clear(); m_results.clear();
@ -116,7 +116,7 @@ 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->setAutoExecution(false); pCmd->setHumanIndependent(false);
accessNavigation().addAndExecute(pCmd); accessNavigation().addAndExecute(pCmd);
} }

View file

@ -72,11 +72,11 @@ void TurnCmd::doUndo()
} }
bool TurnCmd::isAutoExecution() const bool TurnCmd::isHumanIndependent() const
{ {
BOOST_FOREACH(Command *cmd, m_commands) BOOST_FOREACH(Command *cmd, m_commands)
{ {
if (!cmd->isAutoExecution()) if (!cmd->isHumanIndependent())
return false; return false;
} }
return true; return true;

View file

@ -51,7 +51,7 @@ class TurnCmd: public Command
const vector<Command *> & getCommands() const { return m_commands; } const vector<Command *> & getCommands() const { return m_commands; }
virtual bool isAutoExecution() const; virtual bool isHumanIndependent() const;
virtual wstring toString() const; virtual wstring toString() const;