summaryrefslogtreecommitdiffstats
path: root/pokemod/CoinList.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-27 15:15:17 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-27 15:15:17 +0000
commit807071d35159de0660f9df31c48d5bf895ca3622 (patch)
treea1e9dbdc1e58b91cd2e4a5e472597b0204ccb41d /pokemod/CoinList.cpp
parentf444f5a45e9325644a360f656176d47d7f540f52 (diff)
[FIX] Pokemod objects now know about parents
[FIX] Project includes are now relative [FIX] Headers included for better detection of invalid headers [FIX] Validation code commented out so it can be done better git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@111 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/CoinList.cpp')
-rw-r--r--pokemod/CoinList.cpp145
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];
}