1 |
|
|
/* |
2 |
|
|
* The ManaPlus Client |
3 |
|
|
* Copyright (C) 2010 The Mana Developers |
4 |
|
|
* Copyright (C) 2011-2019 The ManaPlus Developers |
5 |
|
|
* Copyright (C) 2019-2021 Andrei Karas |
6 |
|
|
* |
7 |
|
|
* This file is part of The ManaPlus Client. |
8 |
|
|
* |
9 |
|
|
* This program is free software; you can redistribute it and/or modify |
10 |
|
|
* it under the terms of the GNU General Public License as published by |
11 |
|
|
* the Free Software Foundation; either version 2 of the License, or |
12 |
|
|
* any later version. |
13 |
|
|
* |
14 |
|
|
* This program is distributed in the hope that it will be useful, |
15 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
16 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
17 |
|
|
* GNU General Public License for more details. |
18 |
|
|
* |
19 |
|
|
* You should have received a copy of the GNU General Public License |
20 |
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>. |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
#ifndef BEING_PLAYERINFO_H |
24 |
|
|
#define BEING_PLAYERINFO_H |
25 |
|
|
|
26 |
|
|
#include "equipment.h" |
27 |
|
|
|
28 |
|
|
#include "enums/guildpositionflags.h" |
29 |
|
|
#include "enums/state.h" |
30 |
|
|
|
31 |
|
|
#include "enums/being/attributes.h" |
32 |
|
|
|
33 |
|
|
#include "enums/simpletypes/beingid.h" |
34 |
|
|
#include "enums/simpletypes/keep.h" |
35 |
|
|
#include "enums/simpletypes/notify.h" |
36 |
|
|
#include "enums/simpletypes/sfx.h" |
37 |
|
|
#include "enums/simpletypes/trading.h" |
38 |
|
|
|
39 |
|
|
#include "utils/intmap.h" |
40 |
|
|
|
41 |
|
|
#include <string> |
42 |
|
|
|
43 |
|
|
/** |
44 |
|
|
* Stat information storage structure. |
45 |
|
|
*/ |
46 |
|
|
struct Stat final |
47 |
|
|
{ |
48 |
|
|
A_DEFAULT_COPY(Stat) |
49 |
|
|
|
50 |
|
|
int base; |
51 |
|
|
int mod; |
52 |
|
|
int exp; |
53 |
|
|
int expNeed; |
54 |
|
|
}; |
55 |
|
|
|
56 |
|
|
typedef std::map<AttributesT, int64_t> AtrIntMap; |
57 |
|
|
typedef std::map<AttributesT, Stat> StatMap; |
58 |
|
|
|
59 |
|
|
/** |
60 |
|
|
* Backend for core player information. |
61 |
|
|
*/ |
62 |
|
4 |
struct PlayerInfoBackend final |
63 |
|
|
{ |
64 |
|
1 |
PlayerInfoBackend() : |
65 |
|
|
mAttributes(), |
66 |
|
|
mStats(), |
67 |
|
4 |
mSkills() |
68 |
|
|
{ |
69 |
|
|
} |
70 |
|
|
|
71 |
|
|
A_DEFAULT_COPY(PlayerInfoBackend) |
72 |
|
|
|
73 |
|
|
AtrIntMap mAttributes; |
74 |
|
|
StatMap mStats; |
75 |
|
|
IntMap mSkills; |
76 |
|
|
}; |
77 |
|
|
|
78 |
|
|
class Being; |
79 |
|
|
class FloorItem; |
80 |
|
|
class Inventory; |
81 |
|
|
class Item; |
82 |
|
|
|
83 |
|
|
struct HomunculusInfo; |
84 |
|
|
struct MercenaryInfo; |
85 |
|
|
struct PetInfo; |
86 |
|
|
|
87 |
|
|
/** |
88 |
|
|
* A database like namespace which holds global info about the localplayer |
89 |
|
|
* |
90 |
|
|
*/ |
91 |
|
|
namespace PlayerInfo |
92 |
|
|
{ |
93 |
|
|
// --- Attributes ------------------------------------------------------------- |
94 |
|
|
|
95 |
|
|
/** |
96 |
|
|
* Returns the value of the given attribute. |
97 |
|
|
*/ |
98 |
|
|
int64_t getAttribute64(const AttributesT id) A_WARN_UNUSED; |
99 |
|
|
|
100 |
|
|
int32_t getAttribute(const AttributesT id) A_WARN_UNUSED; |
101 |
|
|
|
102 |
|
|
/** |
103 |
|
|
* Changes the value of the given attribute. |
104 |
|
|
*/ |
105 |
|
|
void setAttribute(const AttributesT id, |
106 |
|
|
const int64_t value, |
107 |
|
|
const Notify notify); |
108 |
|
|
|
109 |
|
|
int getSkillLevel(const int id) A_WARN_UNUSED; |
110 |
|
|
|
111 |
|
|
void setSkillLevel(const int id, const int value); |
112 |
|
|
|
113 |
|
|
// --- Stats ------------------------------------------------------------------ |
114 |
|
|
|
115 |
|
|
/** |
116 |
|
|
* Returns the base value of the given stat. |
117 |
|
|
*/ |
118 |
|
|
int getStatBase(const AttributesT id) A_WARN_UNUSED; |
119 |
|
|
|
120 |
|
|
/** |
121 |
|
|
* Changes the base value of the given stat. |
122 |
|
|
*/ |
123 |
|
|
void setStatBase(const AttributesT id, |
124 |
|
|
const int value, |
125 |
|
|
const Notify notify); |
126 |
|
|
|
127 |
|
|
/** |
128 |
|
|
* Returns the modifier for the given stat. |
129 |
|
|
*/ |
130 |
|
|
int getStatMod(const AttributesT id) A_WARN_UNUSED; |
131 |
|
|
|
132 |
|
|
/** |
133 |
|
|
* Changes the modifier for the given stat. |
134 |
|
|
*/ |
135 |
|
|
void setStatMod(const AttributesT id, |
136 |
|
|
const int value, |
137 |
|
|
const Notify notify); |
138 |
|
|
|
139 |
|
|
/** |
140 |
|
|
* Returns the current effective value of the given stat. Effective is base |
141 |
|
|
* + mod |
142 |
|
|
*/ |
143 |
|
|
int getStatEffective(const AttributesT id) A_WARN_UNUSED; |
144 |
|
|
|
145 |
|
|
/** |
146 |
|
|
* Returns the experience of the given stat. |
147 |
|
|
*/ |
148 |
|
|
const std::pair<int, int> getStatExperience(const AttributesT id) |
149 |
|
|
A_WARN_UNUSED; |
150 |
|
|
|
151 |
|
|
// --- Inventory / Equipment -------------------------------------------------- |
152 |
|
|
|
153 |
|
|
/** |
154 |
|
|
* Returns the player's inventory. |
155 |
|
|
*/ |
156 |
|
|
Inventory *getInventory() A_WARN_UNUSED; |
157 |
|
|
|
158 |
|
|
Inventory *getStorageInventory() A_WARN_UNUSED; |
159 |
|
|
|
160 |
|
|
Inventory *getCartInventory() A_WARN_UNUSED; |
161 |
|
|
|
162 |
|
|
/** |
163 |
|
|
* Clears the player's inventory and equipment. |
164 |
|
|
*/ |
165 |
|
|
void clearInventory(); |
166 |
|
|
|
167 |
|
|
void clear(); |
168 |
|
|
|
169 |
|
|
/** |
170 |
|
|
* Returns the player's equipment. |
171 |
|
|
*/ |
172 |
|
|
Equipment *getEquipment() A_WARN_UNUSED; |
173 |
|
|
|
174 |
|
|
/** |
175 |
|
|
* Returns the player's equipment at the given slot. |
176 |
|
|
*/ |
177 |
|
|
const Item *getEquipment(const unsigned int slot) A_WARN_UNUSED; |
178 |
|
|
|
179 |
|
|
// --- Misc ------------------------------------------------------------------- |
180 |
|
|
|
181 |
|
|
/** |
182 |
|
|
* Changes the internal PlayerInfoBackend reference; |
183 |
|
|
*/ |
184 |
|
|
void setBackend(const PlayerInfoBackend &backend); |
185 |
|
|
|
186 |
|
|
void setCharId(const int charId); |
187 |
|
|
|
188 |
|
|
int getCharId(); |
189 |
|
|
|
190 |
|
|
/** |
191 |
|
|
* Returns true if the player is involved in a trade at the moment, false |
192 |
|
|
* otherwise. |
193 |
|
|
*/ |
194 |
|
|
Trading isTrading(); |
195 |
|
|
|
196 |
|
|
/** |
197 |
|
|
* Sets whether the player is currently involved in trade or not. |
198 |
|
|
*/ |
199 |
|
|
void setTrading(const Trading trading); |
200 |
|
|
|
201 |
|
|
void updateAttrs(); |
202 |
|
|
|
203 |
|
|
/** |
204 |
|
|
* Initializes some internals. |
205 |
|
|
*/ |
206 |
|
|
void init(); |
207 |
|
|
|
208 |
|
|
void deinit(); |
209 |
|
|
|
210 |
|
|
void loadData(); |
211 |
|
|
|
212 |
|
|
bool isTalking(); |
213 |
|
|
|
214 |
|
|
void gameDestroyed(); |
215 |
|
|
|
216 |
|
|
void stateChange(const StateT state); |
217 |
|
|
|
218 |
|
|
void triggerAttr(const AttributesT id, |
219 |
|
|
const int64_t old); |
220 |
|
|
|
221 |
|
|
void triggerStat(const AttributesT id, |
222 |
|
|
const int old1, |
223 |
|
|
const int old2); |
224 |
|
|
|
225 |
|
|
void setEquipmentBackend(Equipment::Backend *const backend); |
226 |
|
|
|
227 |
|
|
void equipItem(const Item *const item, const Sfx sfx); |
228 |
|
|
|
229 |
|
|
void unequipItem(const Item *const item, const Sfx sfx); |
230 |
|
|
|
231 |
|
|
void useItem(const Item *const item, const Sfx sfx); |
232 |
|
|
|
233 |
|
|
void useEquipItem(const Item *const item, |
234 |
|
|
const int16_t useType, |
235 |
|
|
const Sfx sfx); |
236 |
|
|
|
237 |
|
|
void useEquipItem2(const Item *const item, |
238 |
|
|
const int16_t useType, |
239 |
|
|
const Sfx sfx); |
240 |
|
|
|
241 |
|
|
void dropItem(const Item *const item, const int amount, const Sfx sfx); |
242 |
|
|
|
243 |
|
|
void pickUpItem(const FloorItem *const item, const Sfx sfx); |
244 |
|
|
|
245 |
|
|
void protectItem(const int id); |
246 |
|
|
|
247 |
|
|
void unprotectItem(const int id); |
248 |
|
|
|
249 |
|
|
bool isItemProtected(const int id); |
250 |
|
|
|
251 |
|
|
MercenaryInfo *getMercenary(); |
252 |
|
|
|
253 |
|
|
void setMercenary(MercenaryInfo *const info); |
254 |
|
|
|
255 |
|
|
void setMercenaryBeing(Being *const being); |
256 |
|
|
|
257 |
|
|
PetInfo *getPet(); |
258 |
|
|
|
259 |
|
|
void setPet(PetInfo *const info); |
260 |
|
|
|
261 |
|
|
void setPetBeing(Being *const being); |
262 |
|
|
|
263 |
|
|
BeingId getPetBeingId(); |
264 |
|
|
|
265 |
|
|
HomunculusInfo *getHomunculus(); |
266 |
|
|
|
267 |
|
|
void setHomunculus(HomunculusInfo *const info); |
268 |
|
|
|
269 |
|
|
void setHomunculusBeing(Being *const being); |
270 |
|
|
|
271 |
|
|
void setElemental(const BeingId id); |
272 |
|
|
|
273 |
|
|
BeingId getHomunculusId(); |
274 |
|
|
|
275 |
|
|
BeingId getMercenaryId(); |
276 |
|
|
|
277 |
|
|
BeingId getElementalId(); |
278 |
|
|
|
279 |
|
|
void updateAttackAi(const BeingId targetId, |
280 |
|
|
const Keep keep); |
281 |
|
|
|
282 |
|
|
std::string getRoomName(); |
283 |
|
|
|
284 |
|
|
void setRoomName(const std::string &name); |
285 |
|
|
|
286 |
|
|
bool isInRoom(); |
287 |
|
|
|
288 |
|
|
void setGuildPositionFlags(const GuildPositionFlags::Type pos); |
289 |
|
|
|
290 |
|
|
GuildPositionFlags::Type getGuildPositionFlags(); |
291 |
|
|
|
292 |
|
|
void enableVending(const bool b); |
293 |
|
|
|
294 |
|
|
bool isVending() A_WARN_UNUSED; |
295 |
|
|
|
296 |
|
|
void setServerLanguage(const int lang); |
297 |
|
|
|
298 |
|
|
int getServerLanguage() A_WARN_UNUSED; |
299 |
|
|
} // namespace PlayerInfo |
300 |
|
|
|
301 |
|
|
#endif // BEING_PLAYERINFO_H |