diff options
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 |