diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-05-02 08:42:08 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-05-02 08:42:08 +0000 |
| commit | 822b5fcaa34b78b9668a58680f9e0d89aa3fd7bd (patch) | |
| tree | 40dc605213eff20f62b16e5f54e5e5e03d744d63 /pokemod/Nature.cpp | |
| parent | 696414f1dc8bc419427efb6c1abe1bbae0a68a56 (diff) | |
[FIX] Exceptions no longer used in pokemod
[DEL] Exception and BugCatcher are no longer needed
[ADD] Object.cpp added
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@119 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Nature.cpp')
| -rw-r--r-- | pokemod/Nature.cpp | 39 |
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]; } |
