summaryrefslogtreecommitdiffstats
path: root/pokemod/CoinListObject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/CoinListObject.cpp')
-rw-r--r--pokemod/CoinListObject.cpp59
1 files changed, 21 insertions, 38 deletions
diff --git a/pokemod/CoinListObject.cpp b/pokemod/CoinListObject.cpp
index 499427a5..11b358f5 100644
--- a/pokemod/CoinListObject.cpp
+++ b/pokemod/CoinListObject.cpp
@@ -47,38 +47,12 @@ CoinListObject::CoinListObject(const QDomElement& xml, const Object* parent, con
load(xml, id);
}
-bool CoinListObject::validate() const
-{
- // TODO: validate
-// bool valid = true;
-// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Object with id %1---").arg(id()), Pokemod::V_Msg);
-// if (Item == m_type)
-// {
-// if (static_cast<const Pokemod*>(pokemod())->itemIndex(m_object) == INT_MAX)
-// {
-// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid item");
-// valid = false;
-// }
-// }
-// else if (Species == m_type)
-// {
-// if (static_cast<const Pokemod*>(pokemod())->speciesIndex(m_object) == INT_MAX)
-// {
-// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid Species");
-// valid = false;
-// }
-// }
-// else
-// {
-// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid type");
-// valid = false;
-// }
-// if (!m_amount || ((1 < m_amount) && (Species == m_type)))
-// {
-// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid amount");
-// valid = false;
-// }
-// return valid;
+void CoinListObject::validate(QTextStream& stream)
+{
+ TEST_SETUP();
+ TEST(setType, type);
+ TEST(setObject, object);
+ TEST(setAmount, amount);
}
void CoinListObject::load(const QDomElement& xml, int id)
@@ -100,25 +74,34 @@ QDomElement CoinListObject::save() const
return xml;
}
-void CoinListObject::setType(const int type) throw(BoundsException)
+void CoinListObject::setType(const int type)
{
if (End <= type)
- error<BoundsException>("type");
+ {
+ boundsError("type");
+ return;
+ }
m_type = type;
m_object = INT_MAX;
}
-void CoinListObject::setObject(const int object) throw(BoundsException)
+void CoinListObject::setObject(const int object)
{
if (((Item == m_type) && (static_cast<const Pokemod*>(pokemod())->itemIndex(object) == INT_MAX)) || ((Species == m_type) && (static_cast<const Pokemod*>(pokemod())->speciesIndex(object) == INT_MAX)))
- error<BoundsException>("object");
+ {
+ boundsError("object");
+ return;
+ }
m_object = object;
}
-void CoinListObject::setAmount(const int amount) throw(BoundsException)
+void CoinListObject::setAmount(const int amount)
{
if (!amount || ((Species == m_type) && (1 < amount)))
- error<BoundsException>("amount");
+ {
+ boundsError("amount");
+ return;
+ }
m_amount = amount;
}