summaryrefslogtreecommitdiff
path: root/src/commandset.cpp
blob: a125541e8ed7e7d0b8e36ac7d5c01ec3e37407b0 (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
#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;
}