diff options
Diffstat (limited to 'pokemod/CoinList.cpp')
| -rw-r--r-- | pokemod/CoinList.cpp | 145 |
1 files changed, 73 insertions, 72 deletions
diff --git a/pokemod/CoinList.cpp b/pokemod/CoinList.cpp index 8c40db89..66086f94 100644 --- a/pokemod/CoinList.cpp +++ b/pokemod/CoinList.cpp @@ -15,39 +15,39 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -// Qt includes -#include <QMap> +// Header include +#include "CoinList.h" // Pokemod includes -#include "Pokemod.h" #include "CoinListObject.h" #include "Item.h" #include "ItemEffect.h" +#include "Pokemod.h" -// Header include -#include "CoinList.h" +// Qt includes +#include <QMap> CoinList::CoinList(const CoinList& coinList) : - Object("CoinList", coinList.pokemod(), coinList.id()) + Object("CoinList", coinList.parent(), coinList.id()) { *this = coinList; } -CoinList::CoinList(const Pokemod* pokemod, const int id) : - Object("CoinList", pokemod, id), +CoinList::CoinList(const Object* parent, const int id) : + Object("CoinList", parent, id), m_name(""), m_value(0) { } -CoinList::CoinList(const CoinList& coinList, const Pokemod* pokemod, const int id) : - Object("CoinList", pokemod, id) +CoinList::CoinList(const CoinList& coinList, const Object* parent, const int id) : + Object("CoinList", parent, id) { *this = coinList; } -CoinList::CoinList(const QDomElement& xml, const Pokemod* pokemod, const int id) : - Object("CoinList", pokemod, id) +CoinList::CoinList(const QDomElement& xml, const Object* parent, const int id) : + Object("CoinList", parent, id) { load(xml, id); } @@ -59,61 +59,62 @@ CoinList::~CoinList() bool CoinList::validate() const { - bool valid = true; - pokemod()->validationMsg(QString("---Coin List \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg); - if (m_name == "") - { - pokemod()->validationMsg("Name not defined"); - valid = false; - } - bool ok = false; - for (int i = 0; (i < pokemod()->itemCount()) && !ok; ++i) - { - const Item* item = pokemod()->item(i); - for (int j = 0; (j < item->effectCount()) && !ok; ++j) - { - const ItemEffect* effect = item->effect(j); - if (effect->effect() == ItemEffect::E_CoinCase) - ok = (effect->value1() == m_value); - } - } - if (!ok) - { - pokemod()->validationMsg("No coin cases which hold the right kind of coin"); - valid = false; - } - if (objectCount()) - { - QMap<int, bool> idChecker; - QMap<int, bool> itemChecker; - QMap<int, bool> speciesChecker; - foreach (CoinListObject* object, m_objects) - { - if (!object->isValid()) - valid = false; - if (idChecker[object->id()]) - pokemod()->validationMsg(QString("Duplicate object with id %1").arg(object->id())); - idChecker[object->id()] = true; - if (object->type() == CoinListObject::Item) - { - if (itemChecker[object->object()]) - pokemod()->validationMsg(QString("Duplicate object with item %1").arg(object->id())); - itemChecker[object->object()] = true; - } - else if (object->type() == CoinListObject::Species) - { - if (speciesChecker[object->object()]) - pokemod()->validationMsg(QString("Duplicate object with item %1").arg(object->id())); - speciesChecker[object->object()] = true; - } - } - } - else - { - pokemod()->validationMsg("There are no objects"); - valid = false; - } - return valid; + // TODO: validate +// bool valid = true; +// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Coin List \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg); +// if (m_name == "") +// { +// static_cast<const Pokemod*>(pokemod())->validationMsg("Name not defined"); +// valid = false; +// } +// bool ok = false; +// for (int i = 0; (i < static_cast<const Pokemod*>(pokemod())->itemCount()) && !ok; ++i) +// { +// const Item* item = static_cast<const Pokemod*>(pokemod())->item(i); +// for (int j = 0; (j < item->effectCount()) && !ok; ++j) +// { +// const ItemEffect* effect = item->effect(j); +// if (effect->effect() == ItemEffect::E_CoinCase) +// ok = (effect->value1() == m_value); +// } +// } +// if (!ok) +// { +// static_cast<const Pokemod*>(pokemod())->validationMsg("No coin cases which hold the right kind of coin"); +// valid = false; +// } +// if (objectCount()) +// { +// QMap<int, bool> idChecker; +// QMap<int, bool> itemChecker; +// QMap<int, bool> speciesChecker; +// foreach (CoinListObject* object, m_objects) +// { +// if (!object->isValid()) +// valid = false; +// if (idChecker[object->id()]) +// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate object with id %1").arg(object->id())); +// idChecker[object->id()] = true; +// if (object->type() == CoinListObject::Item) +// { +// if (itemChecker[object->object()]) +// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate object with item %1").arg(object->id())); +// itemChecker[object->object()] = true; +// } +// else if (object->type() == CoinListObject::Species) +// { +// if (speciesChecker[object->object()]) +// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate object with item %1").arg(object->id())); +// speciesChecker[object->object()] = true; +// } +// } +// } +// else +// { +// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no objects"); +// valid = false; +// } +// return valid; } void CoinList::load(const QDomElement& xml, int id) @@ -140,9 +141,9 @@ void CoinList::setName(const QString& name) void CoinList::setValue(const int value) throw(Exception) { - for (int i = 0; (i < pokemod()->itemCount()); ++i) + for (int i = 0; (i < static_cast<const Pokemod*>(pokemod())->itemCount()); ++i) { - const Item* item = pokemod()->item(i); + const Item* item = static_cast<const Pokemod*>(pokemod())->item(i); for (int j = 0; (j < item->effectCount()); ++j) { const ItemEffect* effect = item->effect(j); @@ -207,19 +208,19 @@ int CoinList::objectCount() const CoinListObject* CoinList::newObject() { - m_objects.append(new CoinListObject(pokemod(), objectId())); + m_objects.append(new CoinListObject(this, objectId())); return m_objects[objectCount() - 1]; } CoinListObject* CoinList::newObject(const QDomElement& xml) { - m_objects.append(new CoinListObject(xml, pokemod(), objectId())); + m_objects.append(new CoinListObject(xml, this, objectId())); return m_objects[objectCount() - 1]; } CoinListObject* CoinList::newObject(const CoinListObject& object) { - m_objects.append(new CoinListObject(object, pokemod(), objectId())); + m_objects.append(new CoinListObject(object, this, objectId())); return m_objects[objectCount() - 1]; } |
