#include <inventory.h>
Definition at line 42 of file inventory.h.
◆ Type
Enumerator |
---|
INVENTORY | |
STORAGE | |
TRADE | |
TYPE_END | |
Definition at line 47 of file inventory.h.
◆ Inventory()
Inventory::Inventory |
( |
Type |
type, |
|
|
int |
size = -1 |
|
) |
| |
Constructor.
- Parameters
-
size | the number of items that fit in the inventory |
Definition at line 36 of file inventory.cpp.
◆ ~Inventory()
Inventory::~Inventory |
( |
| ) |
|
|
default |
◆ addInventoryListener()
◆ addItem()
void Inventory::addItem |
( |
int |
id, |
|
|
int |
quantity |
|
) |
| |
Adds a new item in a free slot.
Definition at line 61 of file inventory.cpp.
◆ clear()
void Inventory::clear |
( |
| ) |
|
◆ contains()
bool Inventory::contains |
( |
Item * |
item | ) |
const |
Checks if the given item is in the inventory.
Definition at line 113 of file inventory.cpp.
◆ distributeSlotsChangedEvent()
void Inventory::distributeSlotsChangedEvent |
( |
| ) |
|
|
protected |
◆ findItem()
Item * Inventory::findItem |
( |
int |
itemId | ) |
const |
Searches for the specified item by it's id.
- Parameters
-
itemId | The id of the item to be searched. |
- Returns
- Item found on success, NULL on failure.
Definition at line 52 of file inventory.cpp.
◆ getFreeSlot()
int Inventory::getFreeSlot |
( |
| ) |
const |
Returns id of next free slot or -1 if all occupied.
Definition at line 122 of file inventory.cpp.
◆ getItem()
Item * Inventory::getItem |
( |
int |
index | ) |
const |
Returns the item at the specified index.
Definition at line 44 of file inventory.cpp.
◆ getLastUsedSlot()
int Inventory::getLastUsedSlot |
( |
| ) |
const |
Returns the index of the last occupied slot or 0 if none occupied.
Definition at line 131 of file inventory.cpp.
◆ getNumberOfSlotsUsed()
int Inventory::getNumberOfSlotsUsed |
( |
| ) |
const |
|
inline |
Get the number of slots filled with an item.
Definition at line 115 of file inventory.h.
◆ getSize()
int Inventory::getSize |
( |
| ) |
const |
|
inline |
Returns the size that this instance is configured for.
Definition at line 67 of file inventory.h.
◆ getType()
int Inventory::getType |
( |
| ) |
const |
|
inline |
◆ isMainInventory()
bool Inventory::isMainInventory |
( |
| ) |
const |
|
inline |
◆ removeInventoryListener()
◆ removeItemAt()
void Inventory::removeItemAt |
( |
int |
index | ) |
|
Remove the item at the specified index from the inventory.
Definition at line 104 of file inventory.cpp.
◆ setItem()
void Inventory::setItem |
( |
int |
index, |
|
|
int |
id, |
|
|
int |
quantity |
|
) |
| |
Sets the item at the given position.
Definition at line 66 of file inventory.cpp.
◆ mInventoryListeners
◆ mItems
std::vector<std::unique_ptr<Item> > Inventory::mItems |
|
protected |
◆ mType
◆ mUsed
The number of slots in use.
Definition at line 139 of file inventory.h.
◆ NO_SLOT_INDEX
const int Inventory::NO_SLOT_INDEX = -1 |
|
static |
The documentation for this class was generated from the following files: