ScummVM API documentation
fight.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 LASTEXPRESS_FIGHT_H
23 #define LASTEXPRESS_FIGHT_H
24 
25 /*
26  Fight structure
27  ---------------
28  uint32 {4} - player struct
29  uint32 {4} - opponent struct
30  uint32 {4} - hasLost flag
31 
32  byte {1} - isRunning
33 
34  Fight participant structure
35  ---------------------------
36  uint32 {4} - function pointer
37  uint32 {4} - pointer to fight structure
38  uint32 {4} - pointer to opponent (fight participant structure)
39  uint32 {4} - array of sequences
40  uint32 {4} - number of sequences
41  uint32 {4} - ??
42  uint32 {4} - ??
43  uint32 {4} - ??
44  uint32 {4} - ??
45  uint32 {4} - ??
46  uint32 {4} - ??
47  uint32 {4} - ??
48  uint32 {4} - ??
49  uint16 {2} - ??
50  uint16 {2} - ?? - only for opponent structure
51  uint32 {4} - ?? - only for opponent structure
52 
53 */
54 
55 #include "lastexpress/shared.h"
56 
57 #include "lastexpress/eventhandler.h"
58 
59 namespace LastExpress {
60 
61 class LastExpressEngine;
62 class Sequence;
63 
64 class Fighter;
65 class Opponent;
66 
67 class Fight : public EventHandler {
68 public:
69  enum FightEndType {
70  kFightEndWin = 0,
71  kFightEndLost = 1,
72  kFightEndExit = 2
73  };
74 
75  Fight(LastExpressEngine *engine);
76  ~Fight() override;
77 
78  FightEndType setup(FightType type);
79 
80  void eventMouse(const Common::Event &ev) override;
81  void eventTick(const Common::Event &ev) override;
82 
83  // State
84  bool isRunning() { return _data->isFightRunning; }
85  void setRunningState(bool state) { _data->isFightRunning = state; }
86  void bailout(FightEndType type);
87  void setStopped();
88  void resetState() { _state = 0; }
89  void setEndType(FightEndType endType) { _endType = endType; }
90 
91 private:
92  struct FightData {
93  Fighter *player;
94  Opponent *opponent;
95  int32 index;
96 
97  Sequence *sequences[20];
98  Common::String names[20];
99 
100  bool isFightRunning;
101 
102  FightData();
103  ~FightData();
104  };
105 
106  LastExpressEngine *_engine;
107  FightData *_data;
108  FightEndType _endType;
109  int _state;
110 
111  bool _handleTimer;
112 
113  // Events
114  void handleTick(const Common::Event &ev, bool unknown);
115 
116  // Data
117  void loadData(FightType type);
118  void clearData();
119  void setOpponents();
120 };
121 
122 } // End of namespace LastExpress
123 
124 #endif // LASTEXPRESS_FIGHT_H
Definition: str.h:59
Definition: lastexpress.h:69
Definition: fighter.h:35
Definition: eventhandler.h:36
Definition: animation.h:45
Definition: fight.h:67
Definition: sequence.h:151
Definition: events.h:199
Definition: fighter.h:105