ScummVM API documentation
logic.h
1
2/* ScummVM - Graphic Adventure Engine
3 *
4 * ScummVM is the legal property of its developers, whose names
5 * are too numerous to list here. Please refer to the COPYRIGHT
6 * file distributed with this source distribution.
7 *
8 * This program is free software: you can redistribute it and/or modify
9 * it under the terms of the GNU General Public License as published by
10 * the Free Software Foundation, either version 3 of the License, or
11 * (at your option) any later version.
12 *
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
17 *
18 * You should have received a copy of the GNU General Public License
19 * along with this program. If not, see <http://www.gnu.org/licenses/>.
20 *
21 */
22
23#ifndef ULTIMA1_LOGIC_H
24#define ULTIMA1_LOGIC_H
25
26#include "common/events.h"
27#include "common/ptr.h"
28#include "ultima/ultima1/data/map.h"
29
30namespace Ultima {
31namespace Ultima1 {
32namespace Logic {
33
34class DirectionLogic;
35
40class Logic {
41 friend class DirectionLogic;
42private:
43 void combatDir(Data::Direction direction, int effect);
44
45protected:
46 // Per-point-of-strength/readied-item scaling factor used by combatDir's
47 // weapon-attack strike roll - 8 for the main game, but MondainLogic
48 // overrides it to 3 to match the Mondain encounter's own weaker curve
49 int _weaponDamageScale = 8;
50
54 void writeString(const Common::String &msg);
55 void writeString(const char *format, ...);
56
61 void resetLine();
62
66 void prompt();
67
71 void playFX(int num);
72
76 int getRandomNumber(int minNumber, int maxNumber);
77 int getRandomNumber(int maxNumber);
78
82 void redrawMap();
83
90 void showAttackTile(int x, int y, int tileId);
91
96
103 void giveTreasure(int coins, int nameLen);
104
108 void combat(Data::Direction direction, int effect);
109
113 virtual bool attack(Data::Direction dir);
114
118 virtual void endOfTurn();
119
123 virtual void updateCreatures() {
124 }
125
129 virtual void castSpellAttack(Data::Direction) {
130 }
131
145 virtual void damage(Data::Direction /* dir */, int /* effectNum */, int /* maxDistance */, int /* strike */, int /* hitChance */, int /* tileId */) {
146 }
147
148 /*--- Fallback player action handlers. Each returns true if end of
149 * turn processing should happen immediately afterward, or false if
150 * that's being deferred - typically because a sub-dialog was opened
151 * that will only complete the action once it closes ---*/
152
153 virtual bool board();
154 virtual bool cast();
155 virtual bool climb();
156 virtual bool drop();
157 virtual bool enter();
158 virtual bool fire();
159 virtual bool get();
160 virtual bool hyperjump();
161 virtual bool inform();
162 virtual bool noise();
163 virtual bool open();
164 virtual bool quit();
165 virtual bool ready();
166 virtual bool steal();
167 virtual bool transact();
168 virtual bool unlock();
169 virtual bool view();
170 virtual bool xit();
171 virtual bool zstats();
172 virtual bool move(Data::Direction) {
173 return false;
174 }
175 virtual bool pass();
176
177 /*---------------------------------------*/
178public:
179 virtual ~Logic() {
180 }
181
182 virtual void action(int action);
183 virtual void keypress(Common::KeyCode keycode);
184 virtual void entering() {
185 }
186
190 virtual void tick() {}
191
196 virtual bool isPersisted() const {
197 return false;
198 }
199};
200
205class DirectionLogic : public Logic {
206public:
207 enum Mode {
208 SPELL, WEAPON, FIRE
209 };
210private:
211 Common::SharedPtr<Logic> _oldLogic;
212 Mode _mode;
213
214public:
215 DirectionLogic(Mode mode);
216 ~DirectionLogic() override {
217 }
218 void action(int action) override;
219};
220
221} // namespace Logic
222} // namespace Ultima1
223} // namespace Ultima
224
225#endif
Definition: ptr.h:159
Definition: str.h:59
Definition: logic.h:40
void giveTreasure(int coins, int nameLen)
virtual void damage(Data::Direction, int, int, int, int, int)
Definition: logic.h:145
void showAttackTile(int x, int y, int tileId)
int getRandomNumber(int minNumber, int maxNumber)
void writeString(const Common::String &msg)
virtual bool isPersisted() const
Definition: logic.h:196
virtual bool attack(Data::Direction dir)
virtual void updateCreatures()
Definition: logic.h:123
void combat(Data::Direction direction, int effect)
virtual void castSpellAttack(Data::Direction)
Definition: logic.h:129
virtual void tick()
Definition: logic.h:190
Out move(In first, In last, Out dst)
Definition: algorithm.h:109