#include "situation.h" #include "astbranch.h" #include "gamestate.h" #include Situation::Situation( const Bu::String &sName, InputType tInput ) : sName( sName ), tInput( tInput ), pAstSetup( NULL ), pAstEnter( NULL ) { } Situation::~Situation() { delete pAstSetup; delete pAstEnter; } void Situation::setAst( class AstBranch *pAst, Situation::Mode m ) { switch( m ) { case modeSetup: pAstSetup = pAst; break; case modeEnter: pAstEnter = pAst; break; } } void Situation::exec( class GameState &gState, Situation::Mode m ) { switch( m ) { case modeSetup: if( pAstSetup ) gState.parse( pAstSetup ); break; case modeEnter: if( pAstEnter ) gState.parse( pAstEnter ); break; } } void Situation::addCommand( Command *pCmd ) { csLocal.addCommand( pCmd ); } bool Situation::execCommand( class GameState &gState, const Bu::StringList &lCmd ) { return csLocal.dispatch( gState, lCmd ); } void Situation::execOption( class GameState &gState, int idx ) { csLocal.exec( gState, idx ); } Bu::Formatter &operator<<( Bu::Formatter &f, Situation::Mode m ) { switch( m ) { case Situation::modeSetup: return f << "Setup"; case Situation::modeEnter: return f << "Enter"; } return f << "**ERROR**"; }