Inventory Class Reference
#include <inventory.h>
List of all members.
Detailed Description
Definition at line 34 of file inventory.h.
|
Public Member Functions |
| Inventory (int size) |
| Constructor.
|
| ~Inventory () |
| Destructor.
|
int | getSize () const |
| Returns the size that this instance is configured for.
|
Item * | getItem (int index) const |
| Returns the item at the specified index.
|
Item * | findItem (int itemId) const |
| Searches for the specified item by it's id.
|
void | addItem (int id, int quantity, bool equipment=false) |
| Adds a new item in a free slot.
|
void | setItem (int index, int id, int quantity, bool equipment=false) |
| Sets the item at the given position.
|
void | removeItem (int id) |
| Remove a item from the inventory.
|
void | removeItemAt (int index) |
| Remove the item at the specified index from the inventory.
|
bool | contains (Item *item) const |
| Checks if the given item is in the inventory.
|
int | getFreeSlot () const |
| Returns id of next free slot or -1 if all occupied.
|
void | clear () |
| Reset all item slots.
|
int | getNumberOfSlotsUsed () const |
| Get the number of slots filled with an item.
|
int | getLastUsedSlot () const |
| Returns the index of the last occupied slot or 0 if none occupied.
|
Static Public Attributes |
static const int | NO_SLOT_INDEX = -1 |
| Slot has no index.
|
Protected Attributes |
Item ** | mItems |
| The holder of items.
|
int | mSize |
| The max number of inventory items.
|
Constructor & Destructor Documentation
Inventory::Inventory |
( |
int |
size |
) |
|
Constructor.
- Parameters:
-
| size | the number of items that fit in the inventory |
Definition at line 40 of file inventory.cpp.
Inventory::~Inventory |
( |
|
) |
|
Member Function Documentation
int Inventory::getSize |
( |
|
) |
const [inline] |
Returns the size that this instance is configured for.
Definition at line 52 of file inventory.h.
Item * Inventory::getItem |
( |
int |
index |
) |
const |
Returns the item at the specified index.
Definition at line 55 of file inventory.cpp.
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 67 of file inventory.cpp.
void Inventory::addItem |
( |
int |
id, |
|
|
int |
quantity, |
|
|
bool |
equipment = false | |
|
) |
| | |
Adds a new item in a free slot.
Definition at line 76 of file inventory.cpp.
void Inventory::setItem |
( |
int |
index, |
|
|
int |
id, |
|
|
int |
quantity, |
|
|
bool |
equipment = false | |
|
) |
| | |
Sets the item at the given position.
Definition at line 81 of file inventory.cpp.
void Inventory::removeItem |
( |
int |
id |
) |
|
void Inventory::removeItemAt |
( |
int |
index |
) |
|
Remove the item at the specified index from the inventory.
Definition at line 120 of file inventory.cpp.
bool Inventory::contains |
( |
Item * |
item |
) |
const |
Checks if the given item is in the inventory.
Definition at line 126 of file inventory.cpp.
int Inventory::getFreeSlot |
( |
|
) |
const |
Returns id of next free slot or -1 if all occupied.
Definition at line 135 of file inventory.cpp.
void Inventory::clear |
( |
|
) |
|
int Inventory::getNumberOfSlotsUsed |
( |
|
) |
const |
Get the number of slots filled with an item.
Definition at line 142 of file inventory.cpp.
int Inventory::getLastUsedSlot |
( |
|
) |
const |
Returns the index of the last occupied slot or 0 if none occupied.
Definition at line 147 of file inventory.cpp.
Member Data Documentation
The max number of inventory items.
Definition at line 116 of file inventory.h.
The documentation for this class was generated from the following files: