summaryrefslogtreecommitdiff
path: root/src/game.cpp
blob: 37989bda28855e5fbd03beb470b8502113cf4883 (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
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
#include "game.h"

#include "functiondisplay.h"
#include "functionexists.h"
#include "functiondelete.h"
#include "functionexit.h"
#include "functionrandom.h"
#include "functioninteger.h"
#include "functionfloat.h"
#include "functiondebugstring.h"
#include "functionstring.h"
#include "functionjoin.h"
#include "functionkeys.h"

Game::Game()
{
	hGlobalParam.insert("start", Variable::newSituationName("start") );
	addFunction( new FunctionDisplay() );
	addFunction( new FunctionExists() );
	addFunction( new FunctionDelete() );
	addFunction( new FunctionExit() );
	addFunction( new FunctionRandom() );
	addFunction( new FunctionInteger() );
	addFunction( new FunctionFloat() );
	addFunction( new FunctionDebugString() );
	addFunction( new FunctionString() );
	addFunction( new FunctionJoin() );
	addFunction( new FunctionKeys() );
}

Game::~Game()
{
	for( FunctionHash::iterator i = hFunction.begin(); i; i++ )
	{
		delete (*i);
	}
	for( SituationHash::iterator i = hSituation.begin(); i; i++ )
	{
		delete (*i);
	}
}

Function *Game::getFunction( const Bu::String &sName )
{
	return hFunction.get( sName );
}

Variable Game::getParam( const Bu::String &sName ) const
{
	return hGlobalParam.get( sName );
}

Situation *Game::getSituation( const Bu::String &sName )
{
	return hSituation.get( sName );
}

bool Game::execCommand( class GameState &gState, const Bu::StringList &lCmd )
{
	return csGlobal.dispatch( gState, lCmd );
}

void Game::addFunction( Function *pFunc )
{
	hFunction.insert( pFunc->getName(), pFunc );
}