diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2005-04-13 18:47:04 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2005-04-13 18:47:04 +0000 |
commit | 4b7cbd2a0ade9f40714194d59dc5bc7836778344 (patch) | |
tree | 603c2622ee828c3d8765aed6b157b002918302c2 /src | |
parent | d741206cc1751ffbbf1909271d66558572358bfc (diff) | |
download | mana-client-4b7cbd2a0ade9f40714194d59dc5bc7836778344.tar.gz mana-client-4b7cbd2a0ade9f40714194d59dc5bc7836778344.tar.bz2 mana-client-4b7cbd2a0ade9f40714194d59dc5bc7836778344.tar.xz mana-client-4b7cbd2a0ade9f40714194d59dc5bc7836778344.zip |
Now getNumberOfSlotsUsed() return the number of different items a character has.
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/itemcontainer.cpp | 15 | ||||
-rw-r--r-- | src/gui/itemcontainer.h | 7 |
2 files changed, 21 insertions, 1 deletions
diff --git a/src/gui/itemcontainer.cpp b/src/gui/itemcontainer.cpp index 616eb0f5..1de08b57 100644 --- a/src/gui/itemcontainer.cpp +++ b/src/gui/itemcontainer.cpp @@ -216,3 +216,18 @@ void ItemContainer::setEquipment(int index, bool equipment) { items[index].equipment = equipment; } + +int ItemContainer::getNumberOfSlotsUsed() +{ + int NumberOfFilledSlot = 0; + for (int i = 0; i < INVENTORY_SIZE; i++) + { + if (items[i].quantity > 0) + { + NumberOfFilledSlot++; + } + } + + return NumberOfFilledSlot; +} + diff --git a/src/gui/itemcontainer.h b/src/gui/itemcontainer.h index 2cc0ed13..ed332345 100644 --- a/src/gui/itemcontainer.h +++ b/src/gui/itemcontainer.h @@ -106,7 +106,7 @@ class ItemContainer : public gcn::Widget int getQuantity(int index); /** - * Returns id of next free slot or -1 i all occupied. + * Returns id of next free slot or -1 if all occupied. */ int getFreeSlot(); @@ -144,6 +144,11 @@ class ItemContainer : public gcn::Widget void setEquipped(int index, bool equipped); void setEquipment(int index, bool equipment); + + /** + * Get the number of slots filled with an item + */ + int getNumberOfSlotsUsed(); }; #endif |