blob: c2231d533ad3b1b7e3b07d8267efbafc45471869 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
#include "commandset.h"
#include "command.h"
#include <bu/sio.h>
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() );
}
|