#include "commandset.h" #include "command.h" #include using namespace Bu; CommandSet::CommandSet() { } CommandSet::~CommandSet() { for( CommandList::iterator i = lCommand.begin(); i; i++ ) { delete (*i); } } void CommandSet::addCommand( class Command *pCmd ) { lCommand.append( pCmd ); } bool CommandSet::dispatch( class GameState &gState, const Bu::StringList &lCmd ) { for( CommandList::iterator i = lCommand.begin(); i; i++ ) { if( (*i)->matches( lCmd ) ) { (*i)->exec( gState, lCmd ); return true; } } return false; } void CommandSet::exec( class GameState &gState, int idx ) { CommandList::iterator i = lCommand.begin()+idx; (*i)->exec( gState, Bu::StringList() ); }