diff options
author | Andrei Karas <akaras@inbox.ru> | 2014-10-21 15:08:07 +0300 |
---|---|---|
committer | Andrei Karas <akaras@inbox.ru> | 2014-10-21 16:17:44 +0300 |
commit | 26a4a4ddfde04ae02964c434063d74d82e3a2143 (patch) | |
tree | 120b7d12002a53eaa40bfa2ebf3562ae231ccb27 /src | |
parent | 0875a6ddfda9ece1af4a818e38be1f99e578c59a (diff) | |
download | plus-26a4a4ddfde04ae02964c434063d74d82e3a2143.tar.gz plus-26a4a4ddfde04ae02964c434063d74d82e3a2143.tar.bz2 plus-26a4a4ddfde04ae02964c434063d74d82e3a2143.tar.xz plus-26a4a4ddfde04ae02964c434063d74d82e3a2143.zip |
Add card fields into item.
Diffstat (limited to 'src')
-rw-r--r-- | src/item.cpp | 28 | ||||
-rw-r--r-- | src/item.h | 9 |
2 files changed, 37 insertions, 0 deletions
diff --git a/src/item.cpp b/src/item.cpp index 1dcd2bbcc..3b4beacdc 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -52,6 +52,7 @@ Item::Item(const int id, mImage(nullptr), mDescription(), mTags(), + mCards(), mRefine(refine), mInvIndex(0), mEquipment(equipment), @@ -62,6 +63,8 @@ Item::Item(const int id, mFavorite(favorite) { setId(id, color); + for (int f = 0; f < 4; f ++) + mCards[f] = 0; } Item::~Item() @@ -130,3 +133,28 @@ std::string Item::getName() const else return info.getName(); } + +void Item::setCard(const int index, const int id) +{ + if (index < 0 || index >= maxCards) + return; + mCards[index] = id; +} + +int Item::getCard(const int index) const +{ + if (index < 0 || index >= maxCards) + return 0 ; + return mCards[index]; +} + +void Item::setCards(const int *const cards, const int size) +{ + if (size < 0 || !cards) + return; + int sz = size; + if (sz > maxCards) + sz = maxCards; + for (int f = 0; f < sz; f ++) + mCards[f] = cards[f]; +} diff --git a/src/item.h b/src/item.h index 842e0d79b..13f34499b 100644 --- a/src/item.h +++ b/src/item.h @@ -31,6 +31,8 @@ class Image; +const int maxCards = 4; + /** * Represents one or more instances of a certain item type. */ @@ -189,6 +191,12 @@ class Item notfinal bool getFavorite() const A_WARN_UNUSED { return mFavorite; } + void setCard(const int index, const int id); + + int getCard(const int index) const; + + void setCards(const int *const cards, const int size); + int mId; /**< Item type id. */ unsigned char mColor; int mQuantity; /**< Number of items. */ @@ -197,6 +205,7 @@ class Item notfinal Image *mImage; /**< Item image. */ std::string mDescription; std::map <int, int> mTags; + int mCards[maxCards]; uint8_t mRefine; /**< Item refine level. */ int mInvIndex; /**< Inventory index. */ bool mEquipment; /**< Item is equipment. */ |