ScummVM API documentation
shops.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 ULTIMA3_VIEWS_INTERACTIONS_SHOPS_H
23#define ULTIMA3_VIEWS_INTERACTIONS_SHOPS_H
24
25#include "ultima/ultima3/views/interactions/log_input.h"
26
27namespace Ultima {
28namespace Ultima3 {
29namespace Views {
30namespace Interactions {
31
36class Shop : public Interaction {
37protected:
38 int _payer;
39
40 Data::RosterEntry &payer() const;
41
45 bool canAfford(int gold) const;
46
50 void spend(int gold);
51
55 void say(const char *text, int sound = 0);
56
57public:
58 Shop(int payer) : _payer(payer) {}
59};
60
64class Tavern : public Shop {
65private:
66 LogNumber _number;
67 LogYesNo _another;
68 bool _asking = false;
69
70 void askForPayment();
71
72public:
73 Tavern(int payer);
74 bool keypress(const KeypressMessage &msg) override;
75};
76
80class Grocer : public Shop {
81private:
82 LogNumber _number;
83
84public:
85 Grocer(int payer);
86 bool keypress(const KeypressMessage &msg) override;
87};
88
92class Temple : public Shop {
93private:
94 enum Stage {
95 CHOOSE_SERVICE,
96 CONFIRM,
97 CHOOSE_PLAYER
98 };
99
100 Stage _stage = CHOOSE_SERVICE;
101 int _service = 0;
102 LogMenu _menu;
103 LogYesNo _confirm;
104 PlayerChooser _chooser;
105
106 void farewell();
107 bool serve(int slot);
108
109public:
110 Temple(int payer);
111 bool keypress(const KeypressMessage &msg) override;
112};
113
117class EquipmentShop : public Shop {
118private:
119 enum Stage {
120 ASK_LIST,
121 LIST_PAGE,
122 ASK_ACTION,
123 CHOOSE_ITEM
124 };
125
126 bool _weapons;
127 Stage _stage = ASK_LIST;
128 int _page = 0;
129 bool _buying = false;
130 LogYesNo _list;
131 LogMenu _action;
132 LogMenu _item;
133 char _keys[20] = {};
134 const char *_words[20] = {};
135
139 bool isBestShop() const;
140
144 int itemCount() const;
145
146 void showPage();
147 void askAction();
148 void askItem();
149 bool buy(int item);
150 bool sell(int item);
151
152public:
153 EquipmentShop(int payer, bool weapons);
154 bool keypress(const KeypressMessage &msg) override;
155};
156
160class Guild : public Shop {
161private:
162 enum Stage {
163 CHOOSE_GOODS,
164 CHOOSE_AMOUNT,
165 ANYTHING_ELSE
166 };
167
168 Stage _stage = CHOOSE_GOODS;
169 int _goods = 0;
170 LogMenu _menu;
171 LogNumber _number;
172 LogYesNo _more;
173
174 void showGoods();
175
176public:
177 Guild(int payer);
178 bool keypress(const KeypressMessage &msg) override;
179};
180
184class Oracle : public Shop {
185private:
186 LogNumber _number;
187 LogYesNo _more;
188 bool _asking = false;
189
190 void askForOffering();
191
192public:
193 Oracle(int payer);
194 bool keypress(const KeypressMessage &msg) override;
195};
196
200class Stable : public Shop {
201private:
202 LogYesNo _buy;
203
204public:
205 Stable(int payer);
206 bool keypress(const KeypressMessage &msg) override;
207};
208
209} // namespace Interactions
210} // namespace Views
211} // namespace Ultima3
212} // namespace Ultima
213
214#endif
bool keypress(const KeypressMessage &msg) override
bool keypress(const KeypressMessage &msg) override
bool keypress(const KeypressMessage &msg) override
bool keypress(const KeypressMessage &msg) override
void say(const char *text, int sound=0)
bool keypress(const KeypressMessage &msg) override
bool keypress(const KeypressMessage &msg) override
bool keypress(const KeypressMessage &msg) override
Definition: messages.h:54
Definition: roster.h:66