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/savefile.h"
26 #include "common/scummsys.h"
27 #include "twine/menu/menu.h"
28 
29 namespace TwinE {
30 
32 enum MagicballStrengthType {
33  kNoBallStrength = 2,
34  kYellowBallStrength = 3,
35  kGreenBallStrength = 4,
36  kRedBallStrength = 6,
37  kFireBallStrength = 8
38 };
39 
40 class TwinEEngine;
41 
42 class GameState {
43 private:
44  TwinEEngine *_engine;
45 
46  void initGameStateVars();
47  void initHeroVars();
48 
49  MenuSettings _gameChoicesSettings;
50 
71  uint8 _listFlagGame[NUM_GAME_FLAGS];
72  // only lba1 - lba2 uses 253 gameflag
73  int16 _gameChapter = 0;
74 
75 public:
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 _inventoryNumKeys = 0;
112  int16 _goldPieces = 0;
113  int16 _zlitosPieces = 0;
119  int16 _magicPoint = 0;
121  int16 _inventoryNumGas = 0;
122 
124  bool _usingSabre = false;
125  bool _endGameItems = false;
126 
131  uint8 _inventoryFlags[NUM_INVENTORY_ITEMS];
132 
133  uint8 _holomapFlags[NUM_LOCATIONS];
134 
135  char _sceneName[30] {};
136 
137  TextId _gameChoices[10]; // inGameMenuData
138  int32 _numChoices = 0; // numOfOptionsInChoice
139  TextId _choiceAnswer = TextId::kNone; // inGameMenuAnswer
140 
141  inline bool inventoryDisabled() const {
142  return hasGameFlag(GAMEFLAG_INVENTORY_DISABLED) != 0;
143  }
144 
145  inline bool hasOpenedFunfrocksSafe() const {
146  return hasGameFlag(30) != 0;
147  }
148 
149  // Arrived on the hamalayi with the rebels
150  inline bool hasArrivedHamalayi() const {
151  return hasGameFlag(90) != 0;
152  }
153 
154  inline bool hasItem(InventoryItems item) const {
155  return hasGameFlag(item) != 0;
156  }
157 
158  inline void giveItem(InventoryItems item) {
159  setGameFlag(item, 1);
160  }
161 
162  inline void removeItem(InventoryItems item) {
163  setGameFlag(item, 0);
164  }
165 
166  void clearGameFlags();
167 
168  uint8 hasGameFlag(uint8 index) const;
169 
170  void setGameFlag(uint8 index, uint8 value);
171 
172  int16 setKeys(int16 value);
173  int16 setGas(int16 value);
174  int16 setLeafs(int16 value);
175  int16 setKashes(int16 value);
176  int16 setMagicPoints(int16 val);
177  int16 setMaxMagicPoints();
178  int16 setLeafBoxes(int16 val);
179 
180  void handleLateGameItems();
181 
182  void addGas(int16 value);
183  void addKeys(int16 val);
184  void addKashes(int16 val);
185  void addMagicPoints(int16 val);
186  void addLeafs(int16 val);
187  void addLeafBoxes(int16 val);
188 
190  void initEngineVars();
191 
193  void init3DGame();
194 
195  void doFoundObj(InventoryItems item);
196 
197  void giveUp();
198  bool loadGame(Common::SeekableReadStream *file);
199  bool saveGame(Common::WriteStream *file);
200 
201  void processGameChoices(TextId choiceIdx);
202 
203  void processGameoverAnimation();
204 };
205 
206 } // namespace TwinE
207 
208 #endif
int16 _magicBallCount
Definition: gamestate.h:105
int16 _magicBallType
Definition: gamestate.h:103
bool _usingSabre
Definition: gamestate.h:124
Definition: stream.h:77
int16 _inventoryNumLeafs
Definition: gamestate.h:117
Definition: stream.h:745
int16 _magicLevelIdx
Definition: gamestate.h:107
Definition: menu.h:38
int16 _inventoryNumKeys
Definition: gamestate.h:110
void setChapter(int16 chapter)
int16 _inventoryNumGas
Definition: gamestate.h:121
uint8 _inventoryFlags[NUM_INVENTORY_ITEMS]
Definition: gamestate.h:131
int16 _inventoryNumLeafsBox
Definition: gamestate.h:115
Definition: twine.h:200
Definition: achievements_tables.h:27
Definition: gamestate.h:42
int16 _magicPoint
Definition: gamestate.h:119
int16 _magicBall
Definition: gamestate.h:101
int16 _goldPieces
Definition: gamestate.h:112