diff options
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r-- | src/inventory.cpp | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp index d9bd79f8..f6cf04f4 100644 --- a/src/inventory.cpp +++ b/src/inventory.cpp @@ -91,7 +91,7 @@ void Inventory::removeItemIndex(int index) mItems[index].setQuantity(0); } -bool Inventory::contains(Item *item) +bool Inventory::contains(Item *item) const { for (int i = 0; i < INVENTORY_SIZE; i++) { if (mItems[i].getId() == item->getId()) { @@ -102,19 +102,19 @@ bool Inventory::contains(Item *item) return false; } -int Inventory::getFreeSlot() +int Inventory::getFreeSlot() const { Item *i = std::find_if(mItems, mItems + INVENTORY_SIZE, std::not1(SlotUsed())); return (i == mItems + INVENTORY_SIZE) ? -1 : (i - mItems); } -int Inventory::getNumberOfSlotsUsed() +int Inventory::getNumberOfSlotsUsed() const { return count_if(mItems, mItems + INVENTORY_SIZE, SlotUsed()); } -int Inventory::getLastUsedSlot() +int Inventory::getLastUsedSlot() const { for (int i = INVENTORY_SIZE - 1; i >= 0; i--) { if (SlotUsed()(mItems[i])) { |