ManaPlus
item.h
Go to the documentation of this file.
1 /*
2  * The ManaPlus Client
3  * Copyright (C) 2004-2009 The Mana World Development Team
4  * Copyright (C) 2009-2010 The Mana Developers
5  * Copyright (C) 2011-2019 The ManaPlus Developers
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 RESOURCES_ITEM_ITEM_H
24 #define RESOURCES_ITEM_ITEM_H
25 
27 
29 
36 
37 #include "resources/db/itemdb.h"
38 
39 #include "localconsts.h"
40 
41 class Image;
42 
43 struct ItemOptionsList;
44 
49 {
50  public:
54  Item(const int id,
55  const ItemTypeT type,
56  const int quantity,
57  const uint8_t refine,
58  const ItemColor color,
59  const Identified identified,
60  const Damaged damaged,
61  const Favorite favorite,
62  const Equipm equipment,
63  const Equipped equipped);
64 
66 
67 
70  virtual ~Item();
71 
75  void setId(const int id, const ItemColor color);
76 
81  { return mId; }
82 
87  { return mImage; }
88 
92  void setQuantity(const int quantity) noexcept2
93  { mQuantity = quantity; }
94 
98  void increaseQuantity(const int amount) noexcept2
99  { mQuantity += amount; }
100 
105  { return mQuantity; }
106 
110  void setEquipment(const Equipm equipment) noexcept2
111  { mEquipment = equipment; }
112 
117  { return mEquipment; }
118 
122  void setEquipped(const Equipped equipped) noexcept2
123  { mEquipped = equipped; }
124 
129  { return mEquipped; }
130 
134  void setRefine(const uint8_t refine) noexcept2
135  { mRefine = refine; }
136 
141  { return mRefine; }
142 
146  void setInEquipment(const bool inEquipment) noexcept2
147  { mInEquipment = inEquipment; }
148 
153  { return mInEquipment; }
154 
158  void setInvIndex(const int index) noexcept2
159  { mInvIndex = index; }
160 
165  { return mInvIndex; }
166 
171  { return ItemDB::get(mId); }
172 
173  std::string getName() const A_WARN_UNUSED;
174 
175  static Image *getImage(const int id,
176  const ItemColor color) A_WARN_UNUSED;
177 
178  bool isHaveTag(const int tagId) const A_WARN_UNUSED;
179 
181  { return mColor; }
182 
183  void setColor(const ItemColor color) noexcept2
184  { mColor = color; }
185 
186  const std::string &getDescription() const noexcept2 A_WARN_UNUSED
187  { return mDescription; }
188 
190  { mIdentified = b; }
191 
193  { return mIdentified; }
194 
196  { mDamaged = b; }
197 
199  { return mDamaged; }
200 
202  { mFavorite = b; }
203 
205  { return mFavorite; }
206 
207  void setCard(const int index, const int id);
208 
209  int getCard(const int index) const;
210 
211  void setCards(const int *const cards, const int size);
212 
213  const int *getCards() const noexcept2 A_WARN_UNUSED
214  { return mCards; }
215 
216  void setOptions(const ItemOptionsList *const options);
217 
219  { return mOptions; }
220 
221  void setType(const ItemTypeT type) noexcept2
222  { mType = type; }
223 
225  { return mType; }
226 
227  void setTag(const int tag) noexcept2
228  { mTag = tag; }
229 
231  { return mTag; }
232 
233  void addCard(const int card);
234 
235  void updateColor();
236 
237  static constexpr bool isItem(const int id) noexcept2 A_WARN_UNUSED
238  {
239  return id != 0 &&
240  id != CARD0_FORGE &&
241  id != CARD0_CREATE &&
242  id != CARD0_PET;
243  }
244 
245  int mId;
247  int mQuantity;
248  int mTag;
249 
250  protected:
252  std::string mDescription;
253  std::map <int, int> mTags;
256  uint8_t mRefine;
257  int mInvIndex;
265 };
266 
267 #endif // RESOURCES_ITEM_ITEM_H
CARD0_FORGE
#define CARD0_FORGE
Definition: cards.h:27
Item::mEquipment
Equipm mEquipment
Definition: item.h:259
Item
Definition: item.h:48
Item::~Item
virtual ~Item()
Definition: item.cpp:79
damaged.h
Item::getIdentified
Identified getIdentified() const
Definition: item.h:192
Item::getName
std::string getName() const
Definition: item.cpp:139
Item::setTag
void setTag(const int tag)
Definition: item.h:227
Item::isItem
static bool isItem(const int id)
Definition: item.h:237
itemdb.h
Item::mFavorite
Favorite mFavorite
Definition: item.h:264
Item::setQuantity
void setQuantity(const int quantity)
Definition: item.h:92
Item::getColor
ItemColor getColor() const
Definition: item.h:180
Item::mTag
int mTag
Definition: item.h:248
A_DELETE_COPY
#define A_DELETE_COPY(func)
Definition: localconsts.h:52
Item::setInvIndex
void setInvIndex(const int index)
Definition: item.h:158
Item::isEquipment
Equipm isEquipment() const
Definition: item.h:116
Item::mColor
ItemColor mColor
Definition: item.h:246
Item::getId
int getId() const
Definition: item.h:80
ItemTypeT
ItemType ::T ItemTypeT
Definition: itemtype.h:42
Image
Definition: image.h:67
Item::setEquipped
void setEquipped(const Equipped equipped)
Definition: item.h:122
notfinal
#define notfinal
Definition: localconsts.h:260
Item::mCards
int mCards[4]
Definition: item.h:254
Item::mIdentified
Identified mIdentified
Definition: item.h:262
localconsts.h
Item::increaseQuantity
void increaseQuantity(const int amount)
Definition: item.h:98
Item::getFavorite
Favorite getFavorite() const
Definition: item.h:204
Item::updateColor
void updateColor()
Definition: item.cpp:194
Item::getImage
Image * getImage() const
Definition: item.h:86
bool
ItemOptionsList
Definition: itemoptionslist.h:32
noexcept2
#define noexcept2
Definition: localconsts.h:49
Item::setCards
void setCards(const int *const cards, const int size)
Definition: item.cpp:165
Item::isHaveTag
bool isHaveTag(const int tagId) const
Definition: item.cpp:118
Item::mTags
std::map< int, int > mTags
Definition: item.h:253
Item::getType
ItemTypeT getType() const
Definition: item.h:224
Item::setColor
void setColor(const ItemColor color)
Definition: item.h:183
Item::isInEquipment
bool isInEquipment() const
Definition: item.h:152
cards.h
Item::mDamaged
Damaged mDamaged
Definition: item.h:263
Item::setRefine
void setRefine(const uint8_t refine)
Definition: item.h:134
itemcolor.h
ItemInfo
Definition: iteminfo.h:52
Item::getRefine
uint8_t getRefine() const
Definition: item.h:140
Item::getCard
int getCard(const int index) const
Definition: item.cpp:158
identified.h
Item::setId
void setId(const int id, const ItemColor color)
Definition: item.cpp:90
Item::setEquipment
void setEquipment(const Equipm equipment)
Definition: item.h:110
Item::setFavorite
void setFavorite(const Favorite b)
Definition: item.h:201
equipped.h
Item::Item
Item(const int id, const ItemTypeT type, const int quantity, const uint8_t refine, const ItemColor color, const Identified identified, const Damaged damaged, const Favorite favorite, const Equipm equipment, const Equipped equipped)
Definition: item.cpp:45
Item::getTag
int getTag() const
Definition: item.h:230
ItemColor
uint16_t ItemColor
Definition: itemcolor.h:29
Item::setIdentified
void setIdentified(const Identified b)
Definition: item.h:189
constexpr
#define constexpr
Definition: localconsts.h:47
Item::getDamaged
Damaged getDamaged() const
Definition: item.h:198
Item::getInvIndex
int getInvIndex() const
Definition: item.h:164
Item::getOptions
const ItemOptionsList * getOptions() const
Definition: item.h:218
maxCards
#define maxCards
Definition: cards.h:24
Item::mQuantity
int mQuantity
Definition: item.h:247
equipm.h
EmoteDB::size
int size()
Definition: emotedb.cpp:305
CARD0_CREATE
#define CARD0_CREATE
Definition: cards.h:28
Item::mType
ItemTypeT mType
Definition: item.h:258
Item::mInvIndex
int mInvIndex
Definition: item.h:257
itemtype.h
favorite.h
Item::setInEquipment
void setInEquipment(const bool inEquipment)
Definition: item.h:146
Item::setDamaged
void setDamaged(const Damaged b)
Definition: item.h:195
Item::getQuantity
int getQuantity() const
Definition: item.h:104
Item::mId
int mId
Definition: item.h:245
Item::isEquipped
Equipped isEquipped() const
Definition: item.h:128
Item::mDescription
std::string mDescription
Definition: item.h:252
Item::mEquipped
Equipped mEquipped
Definition: item.h:260
A_WARN_UNUSED
#define A_WARN_UNUSED
Definition: localconsts.h:160
Item::mOptions
const ItemOptionsList * mOptions
Definition: item.h:255
Item::mImage
Image * mImage
Definition: item.h:251
Item::setType
void setType(const ItemTypeT type)
Definition: item.h:221
ItemDB::get
const ItemInfo & get(const int id)
Definition: itemdb.cpp:792
Item::setOptions
void setOptions(const ItemOptionsList *const options)
Definition: item.cpp:188
Item::getDescription
const std::string & getDescription() const
Definition: item.h:186
CARD0_PET
#define CARD0_PET
Definition: cards.h:29
Item::getInfo
const ItemInfo & getInfo() const
Definition: item.h:170
Item::mInEquipment
bool mInEquipment
Definition: item.h:261
Item::setCard
void setCard(const int index, const int id)
Definition: item.cpp:151
Item::addCard
void addCard(const int card)
Definition: item.cpp:176
Item::mRefine
uint8_t mRefine
Definition: item.h:256
Item::getCards
const int * getCards() const
Definition: item.h:213