From 26a4a4ddfde04ae02964c434063d74d82e3a2143 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 21 Oct 2014 15:08:07 +0300 Subject: Add card fields into item. --- src/item.cpp | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'src/item.cpp') 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]; +} -- cgit v1.2.3-60-g2f50