diff options
author | Yohann Ferreira <bertram@cegetel.net> | 2006-10-19 02:43:26 +0000 |
---|---|---|
committer | Yohann Ferreira <bertram@cegetel.net> | 2006-10-19 02:43:26 +0000 |
commit | c38af49bd66095b581e7eca10a91e100391201c3 (patch) | |
tree | 9fefeb60de43b3a8be3c21be965f3045088defeb /src/itemmanager.h | |
parent | b5857d43bfc4ac08ed99cb02a149d6cb63f13862 (diff) | |
download | manaserv-c38af49bd66095b581e7eca10a91e100391201c3.tar.gz manaserv-c38af49bd66095b581e7eca10a91e100391201c3.tar.bz2 manaserv-c38af49bd66095b581e7eca10a91e100391201c3.tar.xz manaserv-c38af49bd66095b581e7eca10a91e100391201c3.zip |
Added a backend to get item reference information. The xml file isn't ready yet.
Diffstat (limited to 'src/itemmanager.h')
-rw-r--r-- | src/itemmanager.h | 89 |
1 files changed, 89 insertions, 0 deletions
diff --git a/src/itemmanager.h b/src/itemmanager.h new file mode 100644 index 00000000..3a80db40 --- /dev/null +++ b/src/itemmanager.h @@ -0,0 +1,89 @@ +/* + * The Mana World + * Copyright 2004 The Mana World Development Team + * + * This file is part of The Mana World. + * + * The Mana World is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or + * any later version. + * + * The Mana World is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with The Mana World; if not, write to the Free Software + * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + * + * $Id: $ + */ + +#ifndef _TMW_ITEMMANAGER_H +#define _TMW_ITEMMANAGER_H + +#include "item.h" + +#include <map> + +/** + * The Item Manager loads the item reference database + * and also offers an API to items information, and more. + * For item objects, see the WorldItem class. + */ +class ItemManager +{ + public: + /** + * Constructor (loads item reference file) + */ + ItemManager(std::string itemReferenceFile); + + /** + * Destructor + */ + ~ItemManager(); + + /** + * Gives an Item having the demanded information. + */ + ItemPtr getItem(const unsigned int itemId) + { return mItemReference[itemId]; }; + + bool use(BeingPtr beingPtr, const unsigned int itemId) + { return mItemReference[itemId].get()->use(beingPtr); }; + + /** + * Return item Type + */ + unsigned short getItemType(const unsigned int itemId) + { return mItemReference[itemId].get()->getItemType(); }; + + /** + * Return Weight of item + */ + unsigned int getWeight(const unsigned int itemId) + { return mItemReference[itemId].get()->getWeight(); }; + + /** + * Return gold value of item + */ + unsigned int getGoldValue(const unsigned int itemId) + { return mItemReference[itemId].get()->getGoldValue(); }; + + /** + * Return item's modifiers + */ + Modifiers + getItemModifiers(const unsigned int itemId) + { return mItemReference[itemId].get()->getItemModifiers(); }; + + private: + std::map<unsigned int, ItemPtr> mItemReference; /**< Item reference */ +}; + +extern ItemManager *itemManager; + +#endif |