summaryrefslogtreecommitdiff
path: root/src/situation.h
blob: 794b308452202c87d87d1a111dc79743da8c83e6 (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
#ifndef SITUATION_H
#define SITUATION_H

#include <bu/string.h>

#include "commandset.h"

class Situation
{
friend class GameBuilder;
public:
	enum InputType
	{
		inputCommand,
		inputOption,
	};

	Situation( const Bu::String &sName, InputType tInput );
	virtual ~Situation();

	Bu::String getName() const { return sName; }
	InputType getInputType() const { return tInput; }

	enum Mode
	{
		modeSetup,
		modeEnter,
	};

	void setAst( class AstBranch *pAst, Mode m );
	void exec( class GameState &gState, Mode m );

	void addCommand( Command *pCmd );
	bool execCommand( class GameState &gState, const Bu::StringList &lCmd );
	void execOption( class GameState &gState, int idx );
	const CommandSet &getCommandSet() const { return csLocal; }

private:
	Bu::String sName;
	InputType tInput;
	CommandSet csLocal;
	class AstBranch *pAstSetup;
	class AstBranch *pAstEnter;
};

Bu::Formatter &operator<<( Bu::Formatter &f, Situation::Mode m );

#endif