ManaPlus
playerinfo.h
Go to the documentation of this file.
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 
29 #include "enums/state.h"
30 
31 #include "enums/being/attributes.h"
32 
34 #include "enums/simpletypes/keep.h"
36 #include "enums/simpletypes/sfx.h"
38 
39 #include "utils/intmap.h"
40 
41 #include <string>
42 
46 struct Stat final
47 {
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 
63 {
65  mAttributes(),
66  mStats(),
67  mSkills()
68  {
69  }
70 
72 
73  AtrIntMap mAttributes;
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 
91 namespace PlayerInfo
92 {
93 // --- Attributes -------------------------------------------------------------
94 
98  int64_t getAttribute64(const AttributesT id) A_WARN_UNUSED;
99 
100  int32_t getAttribute(const AttributesT id) A_WARN_UNUSED;
101 
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 
118  int getStatBase(const AttributesT id) A_WARN_UNUSED;
119 
123  void setStatBase(const AttributesT id,
124  const int value,
125  const Notify notify);
126 
130  int getStatMod(const AttributesT id) A_WARN_UNUSED;
131 
135  void setStatMod(const AttributesT id,
136  const int value,
137  const Notify notify);
138 
144 
148  const std::pair<int, int> getStatExperience(const AttributesT id)
150 
151 // --- Inventory / Equipment --------------------------------------------------
152 
157 
159 
161 
165  void clearInventory();
166 
167  void clear();
168 
173 
177  const Item *getEquipment(const unsigned int slot) A_WARN_UNUSED;
178 
179 // --- Misc -------------------------------------------------------------------
180 
184  void setBackend(const PlayerInfoBackend &backend);
185 
186  void setCharId(const int charId);
187 
188  int getCharId();
189 
194  Trading isTrading();
195 
199  void setTrading(const Trading trading);
200 
201  void updateAttrs();
202 
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 
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 
264 
266 
267  void setHomunculus(HomunculusInfo *const info);
268 
269  void setHomunculusBeing(Being *const being);
270 
271  void setElemental(const BeingId id);
272 
274 
276 
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 
289 
291 
292  void enableVending(const bool b);
293 
294  bool isVending() A_WARN_UNUSED;
295 
296  void setServerLanguage(const int lang);
297 
299 } // namespace PlayerInfo
300 
301 #endif // BEING_PLAYERINFO_H
Attributes ::T AttributesT
Definition: attributes.h:118
int BeingId
Definition: beingid.h:30
Definition: being.h:96
Definition: item.h:50
std::map< int, int > IntMap
Definition: intmap.h:27
bool Keep
Definition: keep.h:30
#define A_WARN_UNUSED
Definition: localconsts.h:161
#define final
Definition: localconsts.h:46
#define A_DEFAULT_COPY(func)
Definition: localconsts.h:41
bool unprotectItem(InputEvent &event)
Definition: actions.cpp:110
bool dropItem(InputEvent &event)
Definition: actions.cpp:38
bool useItem(InputEvent &event)
Definition: actions.cpp:104
bool protectItem(InputEvent &event)
Definition: actions.cpp:109
bool info(InputEvent &event)
Definition: commands.cpp:57
void notify(const unsigned int message)
void setServerLanguage(const int lang)
Definition: playerinfo.cpp:668
Trading isTrading()
Definition: playerinfo.cpp:391
void useEquipItem(const Item *const item, const int16_t useType, const Sfx sfx)
Definition: playerinfo.cpp:262
bool isInRoom()
Definition: playerinfo.cpp:643
int64_t getAttribute64(const AttributesT id)
Definition: playerinfo.cpp:94
Inventory * getInventory()
Definition: playerinfo.cpp:195
void setStatMod(const AttributesT id, const int value, const Notify notify)
Definition: playerinfo.cpp:159
int getStatBase(const AttributesT id)
Definition: playerinfo.cpp:135
void setPetBeing(Being *const being)
Definition: playerinfo.cpp:560
void stateChange(const StateT state)
Definition: playerinfo.cpp:470
BeingId getHomunculusId()
Definition: playerinfo.cpp:608
void setMercenaryBeing(Being *const being)
Definition: playerinfo.cpp:526
Inventory * getStorageInventory()
Definition: playerinfo.cpp:200
void useEquipItem2(const Item *const item, const int16_t useType, const Sfx sfx)
Definition: playerinfo.cpp:313
void setBackend(const PlayerInfoBackend &backend)
Definition: playerinfo.cpp:376
void equipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:238
void enableVending(const bool b)
Definition: playerinfo.cpp:658
BeingId getPetBeingId()
Definition: playerinfo.cpp:581
void loadData()
Definition: playerinfo.cpp:445
Equipment * getEquipment()
Definition: playerinfo.cpp:220
void pickUpItem(const FloorItem *const item, const Sfx sfx)
Definition: playerinfo.cpp:366
void setPet(PetInfo *const info)
Definition: playerinfo.cpp:554
int32_t getAttribute(const AttributesT id)
Definition: playerinfo.cpp:102
bool isTalking()
Definition: playerinfo.cpp:458
void setTrading(const Trading trading)
Definition: playerinfo.cpp:396
Inventory * getCartInventory()
Definition: playerinfo.cpp:207
std::string getRoomName()
Definition: playerinfo.cpp:633
void setElemental(const BeingId id)
Definition: playerinfo.cpp:539
bool isItemProtected(const int id)
Definition: playerinfo.cpp:515
HomunculusInfo * getHomunculus()
Definition: playerinfo.cpp:603
BeingId getElementalId()
Definition: playerinfo.cpp:544
void init()
Definition: playerinfo.cpp:434
void clear()
Definition: playerinfo.cpp:452
void setAttribute(const AttributesT id, const int64_t value, const Notify notify)
Definition: playerinfo.cpp:110
int getServerLanguage()
Definition: playerinfo.cpp:677
void setHomunculusBeing(Being *const being)
Definition: playerinfo.cpp:592
int getStatEffective(const AttributesT id)
Definition: playerinfo.cpp:167
int getSkillLevel(const int id)
Definition: playerinfo.cpp:120
BeingId getMercenaryId()
Definition: playerinfo.cpp:613
void unequipItem(const Item *const item, const Sfx sfx)
Definition: playerinfo.cpp:246
void clearInventory()
Definition: playerinfo.cpp:212
void setSkillLevel(const int id, const int value)
Definition: playerinfo.cpp:128
void setEquipmentBackend(Equipment::Backend *const backend)
Definition: playerinfo.cpp:232
const std::pair< int, int > getStatExperience(const AttributesT id)
Definition: playerinfo.cpp:175
void triggerStat(const AttributesT id, const int old1, const int old2)
Definition: playerinfo.cpp:85
void deinit()
Definition: playerinfo.cpp:438
void setGuildPositionFlags(const GuildPositionFlags::Type pos)
Definition: playerinfo.cpp:648
void updateAttrs()
Definition: playerinfo.cpp:420
int getStatMod(const AttributesT id)
Definition: playerinfo.cpp:151
void updateAttackAi(const BeingId targetId, const Keep keep)
Definition: playerinfo.cpp:618
void setStatBase(const AttributesT id, const int value, const Notify notify)
Definition: playerinfo.cpp:143
void setRoomName(const std::string &name)
Definition: playerinfo.cpp:638
MercenaryInfo * getMercenary()
Definition: playerinfo.cpp:549
void gameDestroyed()
Definition: playerinfo.cpp:463
PetInfo * getPet()
Definition: playerinfo.cpp:576
void setCharId(const int charId)
Definition: playerinfo.cpp:381
void setMercenary(MercenaryInfo *const info)
Definition: playerinfo.cpp:520
GuildPositionFlags::Type getGuildPositionFlags()
Definition: playerinfo.cpp:653
bool isVending()
Definition: playerinfo.cpp:663
void setHomunculus(HomunculusInfo *const info)
Definition: playerinfo.cpp:586
int getCharId()
Definition: playerinfo.cpp:386
void triggerAttr(const AttributesT id, const int64_t old)
Definition: playerinfo.cpp:78
std::map< std::string, std::vector< BasicStat > > mStats
Definition: statdb.cpp:40
bool Notify
Definition: notify.h:30
std::map< AttributesT, int64_t > AtrIntMap
Definition: playerinfo.h:56
std::map< AttributesT, Stat > StatMap
Definition: playerinfo.h:57
bool Sfx
Definition: sfx.h:30
State ::T StateT
Definition: state.h:71
int base
Definition: playerinfo.h:50
int mod
Definition: playerinfo.h:51
int expNeed
Definition: playerinfo.h:53
int exp
Definition: playerinfo.h:52
bool Trading
Definition: trading.h:30