diff options
author | Mike Buland <eichlan@xagasoft.com> | 2011-12-29 14:13:21 -0700 |
---|---|---|
committer | Mike Buland <eichlan@xagasoft.com> | 2011-12-29 14:13:21 -0700 |
commit | 533310f646f1b1a00250a361f627967c420f1eef (patch) | |
tree | 0ade5ffb70259af7f4e2be56497e4e4707bc079a /src/situation.cpp | |
parent | 1bc10d1408eb29b0675a030e029155dd046b1dd8 (diff) | |
download | stage-533310f646f1b1a00250a361f627967c420f1eef.tar.gz stage-533310f646f1b1a00250a361f627967c420f1eef.tar.bz2 stage-533310f646f1b1a00250a361f627967c420f1eef.tar.xz stage-533310f646f1b1a00250a361f627967c420f1eef.zip |
Situations & their modes are built.
Diffstat (limited to 'src/situation.cpp')
-rw-r--r-- | src/situation.cpp | 52 |
1 files changed, 51 insertions, 1 deletions
diff --git a/src/situation.cpp b/src/situation.cpp index 0d24aa4..d7f98aa 100644 --- a/src/situation.cpp +++ b/src/situation.cpp | |||
@@ -1,10 +1,60 @@ | |||
1 | #include "situation.h" | 1 | #include "situation.h" |
2 | 2 | ||
3 | Situation::Situation() | 3 | #include "astbranch.h" |
4 | #include "gamestate.h" | ||
5 | |||
6 | #include <bu/formatter.h> | ||
7 | |||
8 | Situation::Situation( const Bu::String &sName ) : | ||
9 | sName( sName ), | ||
10 | pAstSetup( NULL ), | ||
11 | pAstEnter( NULL ) | ||
4 | { | 12 | { |
5 | } | 13 | } |
6 | 14 | ||
7 | Situation::~Situation() | 15 | Situation::~Situation() |
8 | { | 16 | { |
17 | delete pAstSetup; | ||
18 | delete pAstEnter; | ||
19 | } | ||
20 | |||
21 | void Situation::setAst( class AstBranch *pAst, Situation::Mode m ) | ||
22 | { | ||
23 | switch( m ) | ||
24 | { | ||
25 | case modeSetup: | ||
26 | pAstSetup = pAst; | ||
27 | break; | ||
28 | |||
29 | case modeEnter: | ||
30 | pAstEnter = pAst; | ||
31 | break; | ||
32 | } | ||
33 | } | ||
34 | |||
35 | void Situation::exec( class GameState &gState, Situation::Mode m ) | ||
36 | { | ||
37 | switch( m ) | ||
38 | { | ||
39 | case modeSetup: | ||
40 | gState.parse( pAstSetup ); | ||
41 | break; | ||
42 | |||
43 | case modeEnter: | ||
44 | gState.parse( pAstEnter ); | ||
45 | break; | ||
46 | } | ||
47 | } | ||
48 | |||
49 | Bu::Formatter &operator<<( Bu::Formatter &f, Situation::Mode m ) | ||
50 | { | ||
51 | switch( m ) | ||
52 | { | ||
53 | case Situation::modeSetup: | ||
54 | return f << "Setup"; | ||
55 | |||
56 | case Situation::modeEnter: | ||
57 | return f << "Enter"; | ||
58 | } | ||
9 | } | 59 | } |
10 | 60 | ||