1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU General Public License
9  * as published by the Free Software Foundation; either version 2
10  * of the License, or (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
20  *
21  */
22 
23 #ifndef MUTATIONOFJB_RANDOMCOMMAND_H
24 #define MUTATIONOFJB_RANDOMCOMMAND_H
25 
26 #include "mutationofjb/commands/command.h"
27 #include "common/array.h"
28 #include "common/scummsys.h"
29 
30 namespace MutationOfJB {
31 
32 class RandomCommandParser : public CommandParser {
33 public:
RandomCommandParser()34 	RandomCommandParser() {}
35 
36 	bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
37 };
38 
39 class RandomBlockStartParser : public CommandParser {
40 public:
RandomBlockStartParser()41 	RandomBlockStartParser() {}
42 
43 	bool parse(const Common::String &line, ScriptParseContext &parseCtx, Command *&command) override;
44 	void transition(ScriptParseContext &parseCtx, Command *oldCommand, Command *newCommand, CommandParser *newCommandParser) override;
45 };
46 
47 class RandomCommand : public Command {
48 	friend class RandomBlockStartParser;
49 
50 public:
51 	typedef Common::Array<Command *> Choices;
52 
53 	RandomCommand(uint numChoices);
54 
55 	ExecuteResult execute(ScriptExecutionContext &scriptExecCtx) override;
56 	Command *next() const override;
57 
58 	Common::String debugString() const override;
59 
60 	const Choices &getChoices() const;
61 
62 private:
63 	uint _numChoices;
64 	Choices _choices;
65 	Command *_chosenNext;
66 };
67 
68 }
69 
70 #endif
71