#ifndef GAME_STATE_H #define GAME_STATE_H #include "astbranch.h" #include "variable.h" #include "scope.h" #include "enums.h" class Game; class Interface; namespace Gats { class Object; } class GameState { public: GameState( Game *pGame, Interface *pIface ); virtual ~GameState(); Gats::Object *toGats() const; Interface *getInterface() { return pIface; } void parse( class AstBranch *pAst ); void init(); void gotoSituation( const Bu::String &sName ); Variable pop() { return lStack.peekPop(); } Variable popDeref(); void push( const Variable &v ) { lStack.push( v ); } void callFunction( const Bu::String &sName ); void execCommand( const Bu::String &sCmd ); bool hasVariable( const Bu::String &sName, ScopeId id ); void delVariable( const Bu::String &sName, ScopeId id ); Variable &getVariable( const Bu::String &sName, ScopeId id=sidLocal ); void setVariable( const Bu::String &sName, const Variable &v, ScopeId id=sidLocal ); Variable &deref( Variable &src, bool bCreate=false ); Bu::StringList tokenize( const Bu::String &sSrc ); void exit(); bool isRunning() const { return bRunning; } Bu::String getPrompt() const { return sPrompt; } private: void parse( const AstBranch::NodeList &lCode ); private: typedef Bu::List ScopeList; typedef Bu::Hash ScopeHash; Game *pGame; Interface *pIface; Scope sGlobal; Scope sPlayer; ScopeList lsLocal; ScopeHash hsSituation; Bu::String sCurSituation; bool bEscape; bool bRunning; bool bReturnOnly; Bu::String sPrompt; VariableList lStack; }; #endif