ScummVM API documentation
gamestate.h
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 modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation, either version 3 of the License, or
10 * (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, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22#ifndef TWINE_SCENE_GAMESTATE_H
23#define TWINE_SCENE_GAMESTATE_H
24
25#include "common/scummsys.h"
26#include "twine/menu/menu.h"
27#include "twine/shared.h"
28
29namespace TwinE {
30
32enum MagicballStrengthType {
33 kNoBallStrength = 2,
34 kYellowBallStrength = 3,
35 kGreenBallStrength = 4,
36 kRedBallStrength = 6,
37 kFireBallStrength = 8
38};
39
40class TwinEEngine;
41
42class GameState {
43private:
44 TwinEEngine *_engine;
45
46 void initGameStateVars();
47 void initHeroVars();
48
49 MenuSettings _gameChoicesSettings;
50
71 int16 _listFlagGame[NUM_GAME_FLAGS]; // ListVarGame
72 // only lba1 - lba2 uses 253 gameflag
73 int16 _gameChapter = 0;
74
75public:
76 GameState(TwinEEngine *engine);
77
97 void setChapter(int16 chapter);
98 int16 getChapter() const;
99
101 int16 _magicBall = 0;
103 int16 _magicBallType = 0;
105 int16 _magicBallCount = 0; // magicBallParam
107 int16 _magicLevelIdx = 0;
108
110 int16 _nbLittleKeys = 0;
112 int16 _goldPieces = 0;
113 int16 _zlitosPieces = 0;
119 int16 _magicPoint = 0;
122
124 bool _weapon = false;
125 bool _endGameItems = false;
126
131 uint8 _inventoryFlags[NUM_INVENTORY_ITEMS];
132
133 uint8 _holomapFlags[MAX_HOLO_POS_2];
134
135 char _sceneName[30] {};
136
137 TextId _gameListChoice[10]; // inGameMenuData
138 int32 _gameNbChoices = 0; // numOfOptionsInChoice
139 TextId _gameChoice = TextId::kNone; // inGameMenuAnswer
140
141 void setDarts(int16 value) {
142 setGameFlag(InventoryItems::kiDart, value);
143 }
144
145 void addDart() {
146 int16 old = _listFlagGame[InventoryItems::kiDart];
147 ++old;
148 setGameFlag(InventoryItems::kiDart, old);
149 }
150
151 inline bool inventoryDisabled() const {
152 return hasGameFlag(GAMEFLAG_INVENTORY_DISABLED) != 0;
153 }
154
155 inline bool hasOpenedFunfrocksSafe() const {
156 return hasGameFlag(30) != 0;
157 }
158
159 // Arrived on the hamalayi with the rebels
160 inline bool hasArrivedHamalayi() const {
161 return hasGameFlag(90) != 0;
162 }
163
164 inline bool hasItem(InventoryItems item) const {
165 return hasGameFlag(item) != 0;
166 }
167
168 inline void giveItem(InventoryItems item) {
169 setGameFlag(item, 1);
170 }
171
172 inline void removeItem(InventoryItems item) {
173 setGameFlag(item, 0);
174 }
175
176 void clearGameFlags();
177
178 int16 hasGameFlag(uint8 index) const;
179
180 void setGameFlag(uint8 index, int16 value);
181
182 int16 setKeys(int16 value);
183 int16 setGas(int16 value);
184 int16 setLeafs(int16 value);
185 int16 setKashes(int16 value);
186 int16 setZlitos(int16 value);
187 int16 setMagicPoints(int16 val);
188 int16 setMaxMagicPoints();
189 int16 setLeafBoxes(int16 val);
190
191 void handleLateGameItems();
192
193 void addGas(int16 value);
194 void addKeys(int16 val);
195 void addKashes(int16 val);
196 void addMagicPoints(int16 val);
197 void addLeafs(int16 val);
198 void addLeafBoxes(int16 val);
199
202
205
206 void doFoundObj(InventoryItems item);
207
208 void giveUp();
209 bool loadGame(Common::SeekableReadStream *file);
210 bool saveGame(Common::WriteStream *file);
211
212 void gameAskChoice(TextId choiceIdx);
213
214 void processGameoverAnimation();
215};
216
217} // namespace TwinE
218
219#endif
Definition: stream.h:745
Definition: stream.h:77
Definition: gamestate.h:42
int16 _nbLittleKeys
Definition: gamestate.h:110
int16 _magicBallType
Definition: gamestate.h:103
uint8 _inventoryFlags[NUM_INVENTORY_ITEMS]
Definition: gamestate.h:131
bool _weapon
Definition: gamestate.h:124
void setChapter(int16 chapter)
int16 _inventoryNumGas
Definition: gamestate.h:121
int16 _goldPieces
Definition: gamestate.h:112
int16 _magicBallCount
Definition: gamestate.h:105
int16 _magicLevelIdx
Definition: gamestate.h:107
int16 _magicPoint
Definition: gamestate.h:119
int16 _inventoryNumLeafsBox
Definition: gamestate.h:115
int16 _inventoryNumLeafs
Definition: gamestate.h:117
int16 _magicBall
Definition: gamestate.h:101
Definition: menu.h:39
Definition: twine.h:207