summaryrefslogtreecommitdiffstats
path: root/pokemod/Nature.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/Nature.cpp')
-rw-r--r--pokemod/Nature.cpp39
1 files changed, 18 insertions, 21 deletions
diff --git a/pokemod/Nature.cpp b/pokemod/Nature.cpp
index 62e14267..4ecbd337 100644
--- a/pokemod/Nature.cpp
+++ b/pokemod/Nature.cpp
@@ -48,22 +48,12 @@ Nature::Nature(const QDomElement& xml, const Object* parent, const int id) :
load(xml, id);
}
-bool Nature::validate() const
+void Nature::validate(QTextStream& stream)
{
- // TODO: validate
-// bool valid = true;
-// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Nature \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
-// if (m_name == "")
-// {
-// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is not defined");
-// valid = false;
-// }
-// if (!m_weight)
-// {
-// static_cast<const Pokemod*>(pokemod())->validationMsg("Weight is not valid");
-// valid = false;
-// }
-// return valid;
+ TEST_SETUP();
+ if (m_name.isEmpty())
+ error(stream, "Name is empty");
+ TEST(setWeight, weight);
}
void Nature::load(const QDomElement& xml, int id)
@@ -88,17 +78,23 @@ void Nature::setName(const QString& name)
m_name = name;
}
-void Nature::setStat(const int stat, const Fraction& multiplier) throw(BoundsException)
+void Nature::setStat(const int stat, const Fraction& multiplier)
{
if ((static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY) <= stat)
- error<BoundsException>("stat");
+ {
+ boundsError("stat");
+ return;
+ }
m_stat[stat] = multiplier;
}
-void Nature::setWeight(const int weight) throw(BoundsException)
+void Nature::setWeight(const int weight)
{
if (!weight)
- error<BoundsException>("weight");
+ {
+ boundsError("weight");
+ return;
+ }
m_weight = weight;
}
@@ -107,10 +103,11 @@ QString Nature::name() const
return m_name;
}
-Fraction Nature::stat(const int stat) const throw(BoundsException)
+Fraction Nature::stat(const int stat) const
{
+ // TODO: Message about fetching out-of-bounds
if (Pokemod::ST_End_GSC <= stat)
- warning<BoundsException>("stat");
+ return Fraction();
return m_stat[stat];
}