| 1 |
/* |
| 2 |
* The Mana World |
| 3 |
* Copyright (C) 2004 The Mana World Development Team |
| 4 |
* |
| 5 |
* This file is part of The Mana World. |
| 6 |
* |
| 7 |
* This program is free software; you can redistribute it and/or modify |
| 8 |
* it under the terms of the GNU General Public License as published by |
| 9 |
* the Free Software Foundation; either version 2 of the License, or |
| 10 |
* any later version. |
| 11 |
* |
| 12 |
* This program is distributed in the hope that it will be useful, |
| 13 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
| 14 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
| 15 |
* GNU General Public License for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General Public License |
| 18 |
* along with this program; if not, write to the Free Software |
| 19 |
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA |
| 20 |
*/ |
| 21 |
|
| 22 |
#ifndef INVENTORY_H |
| 23 |
#define INVENTORY_H |
| 24 |
|
| 25 |
class Item; |
| 26 |
|
| 27 |
#ifdef EATHENA_SUPPORT |
| 28 |
const int INVENTORY_SIZE = 100; |
| 29 |
#else |
| 30 |
const int INVENTORY_SIZE = 50; |
| 31 |
#endif |
| 32 |
const int STORAGE_SIZE = 301; |
| 33 |
|
| 34 |
class Inventory |
| 35 |
{ |
| 36 |
public: |
| 37 |
/** |
| 38 |
* Constructor. |
| 39 |
* |
| 40 |
* @param size the number of items that fit in the inventory |
| 41 |
*/ |
| 42 |
Inventory(int size); |
| 43 |
|
| 44 |
/** |
| 45 |
* Destructor. |
| 46 |
*/ |
| 47 |
~Inventory(); |
| 48 |
|
| 49 |
/** |
| 50 |
* Returns the size that this instance is configured for. |
| 51 |
*/ |
| 52 |
int getSize() const { return mSize; } |
| 53 |
|
| 54 |
/** |
| 55 |
* Returns the item at the specified index. |
| 56 |
*/ |
| 57 |
Item *getItem(int index) const; |
| 58 |
|
| 59 |
/** |
| 60 |
* Searches for the specified item by it's id. |
| 61 |
* |
| 62 |
* @param itemId The id of the item to be searched. |
| 63 |
* @return Item found on success, NULL on failure. |
| 64 |
*/ |
| 65 |
Item *findItem(int itemId) const; |
| 66 |
|
| 67 |
/** |
| 68 |
* Adds a new item in a free slot. |
| 69 |
*/ |
| 70 |
void addItem(int id, int quantity, bool equipment = false); |
| 71 |
|
| 72 |
/** |
| 73 |
* Sets the item at the given position. |
| 74 |
*/ |
| 75 |
void setItem(int index, int id, int quantity, bool equipment = false); |
| 76 |
|
| 77 |
/** |
| 78 |
* Remove a item from the inventory. |
| 79 |
*/ |
| 80 |
void removeItem(int id); |
| 81 |
|
| 82 |
/** |
| 83 |
* Remove the item at the specified index from the inventory. |
| 84 |
*/ |
| 85 |
void removeItemAt(int index); |
| 86 |
|
| 87 |
/** |
| 88 |
* Checks if the given item is in the inventory. |
| 89 |
*/ |
| 90 |
bool contains(Item *item) const; |
| 91 |
|
| 92 |
/** |
| 93 |
* Returns id of next free slot or -1 if all occupied. |
| 94 |
*/ |
| 95 |
int getFreeSlot() const; |
| 96 |
|
| 97 |
/** |
| 98 |
* Reset all item slots. |
| 99 |
*/ |
| 100 |
void clear(); |
| 101 |
|
| 102 |
/** |
| 103 |
* Get the number of slots filled with an item |
| 104 |
*/ |
| 105 |
int getNumberOfSlotsUsed() const; |
| 106 |
|
| 107 |
/** |
| 108 |
* Returns the index of the last occupied slot or 0 if none occupied. |
| 109 |
*/ |
| 110 |
int getLastUsedSlot() const; |
| 111 |
|
| 112 |
static const int NO_SLOT_INDEX = -1; /**< Slot has no index. */ |
| 113 |
|
| 114 |
protected: |
| 115 |
Item **mItems; /**< The holder of items */ |
| 116 |
int mSize; /**< The max number of inventory items */ |
| 117 |
}; |
| 118 |
|
| 119 |
#endif |