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 /*
24  * This code is based on the original source code of Lord Avalot d'Argent version 1.3.
25  * Copyright (c) 1994-1995 Mike, Mark and Thomas Thurman.
26  */
27 
28 #ifndef AVALANCHE_PARSER_H
29 #define AVALANCHE_PARSER_H
30 
31 #include "avalanche/enums.h"
32 
33 #include "common/events.h"
34 #include "common/str.h"
35 #include "common/serializer.h"
36 
37 namespace Avalanche {
38 class AvalancheEngine;
39 
40 class Parser {
41 public:
42 	static const int16 kParserWordsNum = 277; // How many words does the parser know?
43 	static const int16 kFirstPassword = 88;   // words[kFirstPassword] should equal "TIROS".
44 	static const byte kPardon = 254;          // Didn't understand / wasn't given.
45 	static const byte kNothing = 250;
46 	static const byte kMoved = 0;             // This word was moved. (Usually because it was the subject of conversation.)
47 
48 	struct VocabEntry {
49 		byte _number;
50 		Common::String _word;
51 
initVocabEntry52 		void init(byte number, Common::String word) {
53 			_number = number;
54 			_word = word;
55 		}
56 	};
57 
58 	VocabEntry _vocabulary[kParserWordsNum];
59 
60 	Common::String _realWords[11];
61 	VerbCode _verb;
62 	byte _thing;
63 	People _person;
64 	bool _polite;
65 	Common::String _inputText;
66 	Common::String _inputTextBackup;
67 	byte _inputTextPos;
68 	bool _quote;
69 	bool _cursorState;
70 	bool _weirdWord;
71 
72 	byte _wearing; // what you're wearing
73 
74 	Parser(AvalancheEngine *vm);
75 	void init();
76 	void parse();
77 	void doThat();
78 	void verbOpt(byte verb, Common::String &answer, char &ansKey);
79 	void drink();
80 	void handleInputText(const Common::Event &event);
81 	void handleBackspace();
82 	void handleReturn();
83 	void handleFunctionKey(const Common::Event &event);
84 	void plotText();
85 	void cursorOn();
86 	void cursorOff();
87 	void tryDropdown();
88 	int16 getPos(const Common::String &crit, const Common::String &src);
89 	void doVerb(VerbCode id);
90 	Common::String rank();
91 	void resetVariables();
92 	void synchronize(Common::Serializer &sz);
93 
94 private:
95 	AvalancheEngine *_vm;
96 
97 	struct RankType {
98 		uint16 _score;
99 		char _title[20];
100 	};
101 
102 	static const char *kCopyright;
103 	static const char *kVersionNum;
104 
105 	Common::String _thats;
106 	byte _thing2;
107 	byte _sworeNum;     // number of times you've sworn
108 	byte _alcoholLevel; // Your blood alcohol level.
109 	bool _boughtOnion;  // Have you bought an onion yet?
110 
111 	byte wordNum(Common::String word);
112 	void replace(Common::String oldChars, byte newChar);
113 	Common::String totalTime();
114 	void clearWords();
115 	void cheatParse(Common::String codes);
116 	void stripPunctuation(Common::String &word);
117 	void displayWhat(byte target, bool animate, bool &ambiguous);
118 	bool doPronouns();
119 	void properNouns();
120 	void lookAround();
121 	void openDoor();
122 	void storeInterrogation(byte interrogation);
123 	void examineObject();
124 	bool isPersonHere();
125 	void exampers();
126 	bool isHolding();
127 	void openBox(bool isOpening);
128 	void examine();
129 	void inventory();
130 	void swallow();
131 	void peopleInRoom();
132 	void putProc();
133 	void notInOrder();
134 	void goToCauldron();
135 	bool giveToSpludwick();
136 	void cardiffClimbing();
137 	void already();
138 	void standUp();
139 	void getProc(char thing);
140 	void giveGeidaTheLute();
141 	void playHarp();
142 	void winSequence();
143 	void wipeText();
144 	void bossKey();
145 };
146 
147 } // End of namespace Avalanche
148 
149 #endif // AVALANCHE_PARSER_H
150