ScummVM API documentation
logic.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 ULTIMA2_LOGIC_LOGIC_H
23#define ULTIMA2_LOGIC_LOGIC_H
24
25#include "ultima/ultima2/data/data.h"
26#include "ultima/shared/engine/messages.h"
27
28namespace Ultima {
29namespace Ultima2 {
30namespace Logic {
31
38class Logic {
39protected:
40 // Which command is waiting on the Direction interaction's result
41 enum class DirectionPurpose { ATTACK, FIRE, STEAL, UNLOCK, OFFER, TRANSACT };
42 DirectionPurpose _directionPurpose = DirectionPurpose::ATTACK;
43
44 // Flips on every successful step and clears on any other command; while
45 // set and riding a horse, most monsters skip their turn
46 bool _monstersSkipTurn = false;
47
51 void writeString(const Common::String &msg);
52 void writeString(const char *format, ...);
53
57 void prompt();
58
64 void alertTownGuards(int extraSlot = -1);
65
69 void redrawMap();
70
75
79 int getRandomNumber(int minNumber, int maxNumber);
80 int getRandomNumber(int maxNumber);
81
85 byte randByte();
86
92 void showAttackTile(int x, int y);
93
97 void playFX(Data::SoundEffect fx);
98
102 virtual void endOfTurn();
103
107 virtual void updateCreatures() {
108 }
109
110 /*--- Fallback player command handlers. Each returns true if end of
111 * turn processing should happen immediately afterward, or false if
112 * that's being deferred - typically because a sub-dialog was opened
113 * that will only complete the action once it closes ---*/
114
115 virtual bool move(Data::Direction) {
116 return false;
117 }
118 virtual bool board();
119 virtual bool cast();
120
124 virtual bool castSpell(Data::SpellType spell);
125
126 virtual bool descend();
127 virtual bool enter();
128 virtual bool get();
129 virtual bool hyper();
130 virtual bool igniteTorch();
131 virtual bool jump();
132 virtual bool klimb();
133 virtual bool launch();
134 virtual bool magic();
135 virtual bool negateTime();
136 virtual bool pass();
137 virtual bool quit();
138 virtual bool ready();
139 virtual bool view();
140 virtual bool wearArmor();
141 virtual bool xit();
142 virtual bool yell();
143 virtual bool zstats();
144
145 /*---------------------------------------*/
146public:
147 virtual ~Logic() {
148 }
149
150 virtual void action(int action);
151 virtual void keypress(const Graphics::Views::KeypressMessage &msg);
152 virtual void entering() {
153 }
154
155 /*--- Commands needing a direction first read via the Direction
156 * interaction. Each is called once with dir == DIR_UNSPECIFIED (from
157 * action()'s dispatch) to kick off the prompt, then again with the
158 * resolved direction once chosen - public since Direction calls back
159 * into these directly ---*/
160
161 virtual bool attack(Data::Direction dir = Data::DIR_UNSPECIFIED);
162 virtual bool fire(Data::Direction dir = Data::DIR_UNSPECIFIED);
163 virtual bool steal(Data::Direction dir = Data::DIR_UNSPECIFIED);
164 virtual bool unlock(Data::Direction dir = Data::DIR_UNSPECIFIED);
165 virtual bool offer(Data::Direction dir = Data::DIR_UNSPECIFIED);
166 virtual bool transact(Data::Direction dir = Data::DIR_UNSPECIFIED);
167
173 void resolveDirection(Data::Direction dir);
174
178 virtual void completeOffer(int) {
179 }
180
185 virtual void completeStatBoost(int) {
186 }
187
191 virtual void tick() {
192 }
193
198 bool eatFood(int amount);
199
204 void playerDied(bool showDied = true);
205
210 void resumeTurn() {
211 endOfTurn();
212 prompt();
213 }
214
220 bool trySpendGold(int amount);
221};
222
223} // namespace Logic
224} // namespace Ultima2
225} // namespace Ultima
226
227#endif
Definition: str.h:59
Definition: logic.h:38
void alertTownGuards(int extraSlot=-1)
bool trySpendGold(int amount)
virtual void completeOffer(int)
Definition: logic.h:178
virtual void tick()
Definition: logic.h:191
void writeString(const Common::String &msg)
void playerDied(bool showDied=true)
void playFX(Data::SoundEffect fx)
int getRandomNumber(int minNumber, int maxNumber)
void resumeTurn()
Definition: logic.h:210
virtual void updateCreatures()
Definition: logic.h:107
virtual bool castSpell(Data::SpellType spell)
void resolveDirection(Data::Direction dir)
virtual void completeStatBoost(int)
Definition: logic.h:185
void showAttackTile(int x, int y)
Definition: messages.h:54