blob: 1d3a853213025a110856d4b9aed95d7b203e2756 (
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
|
#include "situation.h"
#include "astbranch.h"
#include "gamestate.h"
#include <bu/formatter.h>
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**";
}
|