summaryrefslogtreecommitdiffstats
path: root/pokemod/MoveEffect.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-05-02 08:42:08 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-05-02 08:42:08 +0000
commit822b5fcaa34b78b9668a58680f9e0d89aa3fd7bd (patch)
tree40dc605213eff20f62b16e5f54e5e5e03d744d63 /pokemod/MoveEffect.cpp
parent696414f1dc8bc419427efb6c1abe1bbae0a68a56 (diff)
downloadsigen-822b5fcaa34b78b9668a58680f9e0d89aa3fd7bd.tar.gz
sigen-822b5fcaa34b78b9668a58680f9e0d89aa3fd7bd.tar.xz
sigen-822b5fcaa34b78b9668a58680f9e0d89aa3fd7bd.zip
[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/MoveEffect.cpp')
-rw-r--r--pokemod/MoveEffect.cpp76
1 files changed, 53 insertions, 23 deletions
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<const Pokemod*>(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<BoundsException>("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<BoundsException>("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<BoundsException>("value1");
+ {
+ boundsError("value1");
+ return;
+ }
break;
case E_Status:
case E_NeedStatus:
if (Pokemod::STS_End <= value1)
- error<BoundsException>("value1");
+ {
+ boundsError("value1");
+ return;
+ }
throw;
case E_Stat:
if (Pokemod::ST_End_Battle <= value1)
- error<BoundsException>("value1");
+ {
+ boundsError("value1");
+ return;
+ }
break;
case E_Counter:
case E_Shield:
if (MT_End <= value1)
- error<BoundsException>("value1");
+ {
+ boundsError("value1");
+ return;
+ }
break;
case E_Recoil:
if (R_End <= value1)
- error<BoundsException>("value1");
+ {
+ boundsError("value1");
+ return;
+ }
break;
default:
- error<BoundsException>("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<BoundsException>("value2");
+ {
+ boundsError("value2");
+ return;
+ }
break;
default:
- error<BoundsException>("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<BoundsException>("value4");
+ {
+ boundsError("value4");
+ return;
+ }
m_value4 = value4;
}