#include "game.h" #include "functiondisplay.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" #include "functioncount.h" #include Game::Game() { hGlobalParam.insert("start", Variable::newSituationName("start") ); addFunction( new FunctionDisplay() ); addFunction( new FunctionExit() ); addFunction( new FunctionRandom() ); addFunction( new FunctionInteger() ); addFunction( new FunctionFloat() ); addFunction( new FunctionDebugString() ); addFunction( new FunctionString() ); addFunction( new FunctionJoin() ); addFunction( new FunctionKeys() ); addFunction( new FunctionCount() ); } 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 ) { try { return hSituation.get( sName ); } catch( Bu::HashException &e ) { throw Bu::ExceptionBase(("No such situation <<" + sName + ">>").getStr()); } } 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 ); }