diff options
author | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-10-07 00:12:32 +0000 |
---|---|---|
committer | Bjørn Lindeijer <bjorn@lindeijer.nl> | 2005-10-07 00:12:32 +0000 |
commit | a246c08cef5e4d598fc07a681eb971bfbcf01519 (patch) | |
tree | ff1813b11379ddef2c5be627aafcf3329170a293 /src/item.h | |
parent | 09db562f2fca5c49fa1a92ba0b6dc60db479ae08 (diff) | |
download | mana-a246c08cef5e4d598fc07a681eb971bfbcf01519.tar.gz mana-a246c08cef5e4d598fc07a681eb971bfbcf01519.tar.bz2 mana-a246c08cef5e4d598fc07a681eb971bfbcf01519.tar.xz mana-a246c08cef5e4d598fc07a681eb971bfbcf01519.zip |
Modified finding NPC as by timonator's suggestion in order to allow NPCs to be
clicked on their heads too. Also made start to tile engine improvement by
adding the Sprite class that is now used by the floor items for being displayed
on the map. Finally added documentation to Item class and splitted out
Properties class from Map.
Diffstat (limited to 'src/item.h')
-rw-r--r-- | src/item.h | 185 |
1 files changed, 99 insertions, 86 deletions
@@ -21,99 +21,112 @@ * $Id$ */ -#ifndef _ITEM_H -#define _ITEM_H +#ifndef _ITEM_H_ +#define _ITEM_H_ -class ItemInfo; +#include "resources/itemmanager.h" +/** + * Represents one or more instances of a certain item type. + */ class Item { public: - Item(int id=-1, int quantity=0, - bool equipment=false, bool equipped=false); - - ~Item(); - - void setId(int id); - int getId(); - - void setQuantity(int quantity); - void increaseQuantity(int amount); - int getQuantity(); - - void setEquipment(bool equipment); - bool isEquipment(); - - void setEquipped(bool equipped); - bool isEquipped(); - - int getInvIndex(); - void setInvIndex(int index); - - ItemInfo* getInfo(); + /** + * Constructor. + */ + Item(int id = -1, int quantity = 0, + bool equipment = false, bool equipped = false): + mId(id), + mQuantity(quantity), + mEquipment(equipment), + mEquipped(equipped) + { + } + + /** + * Destructor. + */ + ~Item() {} + + /** + * Sets the item id, identifying the item type. + */ + void + setId(int id) { mId = id; } + + /** + * Returns the item id. + */ + int + getId() const { return mId; } + + /** + * Sets the number of items. + */ + void + setQuantity(int quantity) { mQuantity = quantity; } + + /** + * Increases the number of items by the given amount. + */ + void + increaseQuantity(int amount) { mQuantity += amount; } + + /** + * Returns the number of items. + */ + int + getQuantity() const { return mQuantity; } + + /** + * Sets wether this item is considered equipment. + */ + void + setEquipment(bool equipment) { mEquipment = equipment; } + + /** + * Returns wether this item is considered equipment. + */ + bool + isEquipment() const { return mEquipment; } + + /** + * Sets wether this item is equipped. + */ + void + setEquipped(bool equipped) { mEquipped = equipped; } + + /** + * Returns wether this item is equipped. + */ + bool + isEquipped() const { return mEquipped; } + + /** + * Sets the inventory index of this item. + */ + void + setInvIndex(int index) { mInvIndex = index; } + + /** + * Returns the inventory index of this item. + */ + int + getInvIndex() const { return mInvIndex; } + + /** + * Returns information about this item type. + */ + ItemInfo* + getInfo() const { return itemDb->getItemInfo(mId); } protected: - int id; - int quantity; - bool equipment; - bool equipped; - - int invIndex; + int mId; /**< Item type id. */ + int mQuantity; /**< Number of items. */ + bool mEquipment; /**< Item is equipment. */ + bool mEquipped; /**< Item is equipped. */ + int mInvIndex; /**< Inventory index. */ }; -inline void Item::setId(int id) -{ - this->id = id; -} - -inline int Item::getId() -{ - return id; -} - -inline void Item::setQuantity(int quantity) -{ - this->quantity = quantity; -} - -inline void Item::increaseQuantity(int amount) -{ - this->quantity += amount; -} - -inline int Item::getQuantity() -{ - return quantity; -} - -inline void Item::setEquipment(bool equipment) -{ - this->equipment = equipment; -} - -inline bool Item::isEquipment() -{ - return equipment; -} - -inline void Item::setEquipped(bool equipped) -{ - this->equipped = equipped; -} - -inline bool Item::isEquipped() -{ - return equipped; -} - -inline int Item::getInvIndex() -{ - return invIndex; -} - -inline void Item::setInvIndex(int index) -{ - this->invIndex = index; -} - #endif |