From 822b5fcaa34b78b9668a58680f9e0d89aa3fd7bd Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 2 May 2008 08:42:08 +0000 Subject: [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 --- pokemod/MoveEffect.cpp | 76 +++++++++++++++++++++++++++++++++++--------------- 1 file changed, 53 insertions(+), 23 deletions(-) (limited to 'pokemod/MoveEffect.cpp') diff --git a/pokemod/MoveEffect.cpp b/pokemod/MoveEffect.cpp index e790d672..9847ffdf 100644 --- a/pokemod/MoveEffect.cpp +++ b/pokemod/MoveEffect.cpp @@ -52,12 +52,15 @@ MoveEffect::MoveEffect(const QDomElement& xml, const Object* parent, const int i load(xml, id); } -bool MoveEffect::validate() const +void MoveEffect::validate(QTextStream& stream) { - // TODO: validate -// bool valid = true; -// static_cast(pokemod())->validationMsg(QString("------Effect with id %1---").arg(id()), Pokemod::V_Msg); -// return valid; + TEST_SETUP(); + TEST(setChance, chance); + TEST(setEffect, effect); + TEST(setValue1, value1); + TEST(setValue2, value2); + TEST(setValue3, value3); + TEST(setValue4, value4); } void MoveEffect::load(const QDomElement& xml, int id) @@ -83,17 +86,23 @@ QDomElement MoveEffect::save() const return xml; } -void MoveEffect::setChance(const Fraction& chance) throw(BoundsException) +void MoveEffect::setChance(const Fraction& chance) { if (1 < chance) - error("chance"); + { + boundsError("chance"); + return; + } m_chance = chance; } -void MoveEffect::setEffect(const int effect) throw(BoundsException) +void MoveEffect::setEffect(const int effect) { if (E_End <= effect) - error("effect"); + { + boundsError("effect"); + return; + } m_effect = effect; m_value1 = INT_MAX; m_value2 = INT_MAX; @@ -101,50 +110,68 @@ void MoveEffect::setEffect(const int effect) throw(BoundsException) m_value4.set(1, 1); } -void MoveEffect::setValue1(const int value1) throw(Exception) +void MoveEffect::setValue1(const int value1) { switch (m_effect) { case E_Damage: if (D_End <= value1) - error("value1"); + { + boundsError("value1"); + return; + } break; case E_Status: case E_NeedStatus: if (Pokemod::STS_End <= value1) - error("value1"); + { + boundsError("value1"); + return; + } throw; case E_Stat: if (Pokemod::ST_End_Battle <= value1) - error("value1"); + { + boundsError("value1"); + return; + } break; case E_Counter: case E_Shield: if (MT_End <= value1) - error("value1"); + { + boundsError("value1"); + return; + } break; case E_Recoil: if (R_End <= value1) - error("value1"); + { + boundsError("value1"); + return; + } break; default: - error("value1"); - break; + unusedError("value1"); + return; } m_value1 = value1; } -void MoveEffect::setValue2(const int value2) throw(Exception) +void MoveEffect::setValue2(const int value2) { switch (m_effect) { case E_Damage: if ((D_Level <= m_value1) || !value2) - error("value2"); + { + boundsError("value2"); + return; + } break; default: - error("value2"); - break; + unusedError("value2"); + return; } m_value2 = value2; } @@ -160,10 +187,13 @@ void MoveEffect::setValue3(const int value3) m_value3 = value3; } -void MoveEffect::setValue4(const Fraction& value4) throw(BoundsException) +void MoveEffect::setValue4(const Fraction& value4) { if ((m_effect != E_StealHP) && (m_effect != E_Counter) && (m_effect != E_Selfdestruct) && (m_effect != E_Mirror) && (m_effect != E_GetMoney) && (m_effect != E_WaitAndReturn) && (m_effect != E_Recoil) && (1 < value4)) - error("value4"); + { + boundsError("value4"); + return; + } m_value4 = value4; } -- cgit