/* * Copyright 2007-2008 Ben Boeckel * * This program 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 3 of the License, or * (at your option) any later version. * * This program 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 this program. If not, see . */ #ifndef __POKEMOD_ITEM__ #define __POKEMOD_ITEM__ // Pokemod includes #include "Object.h" // General includes #include "../general/Exception.h" // Qt includes #include // Forward declarations class ItemEffect; class Item : public Object { public: Item(const Item& item); Item(const Object* parent, const int id); Item(const Item& item, const Object* parent, const int id); Item(const QDomElement& xml, const Object* parent, const int id = INT_MAX); ~Item(); void load(const QDomElement& xml, int id = INT_MAX); QDomElement save() const; void setName(const QString& name); void setSellable(const bool sellable); void setType(const int type) throw(BoundsException); void setPrice(const int price) throw(BoundsException); void setDescription(const QString& description); QString name() const; bool sellable() const; int type() const; int price() const; QString description() const; const ItemEffect* effect(const int index) const throw(IndexException); ItemEffect* effect(const int index) throw(IndexException); const ItemEffect* effectById(const int id) const throw(IndexException); ItemEffect* effectById(const int id) throw(IndexException); int effectIndex(const int id) const; int effectCount() const; ItemEffect* newEffect(); ItemEffect* newEffect(const QDomElement& xml); ItemEffect* newEffect(const ItemEffect& effect); void deleteEffect(const int index) throw(IndexException); void deleteEffectById(const int index) throw(IndexException); Item& operator=(const Item& rhs); private: bool validate() const; int effectId() const; void clear() { while (effectCount()) deleteEffect(0); } QString m_name; bool m_sellable; int m_type; int m_price; QString m_description; QList m_effects; }; #endif