summaryrefslogtreecommitdiffstats
path: root/pokemod/AbilityEffect.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-27 15:15:17 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-27 15:15:17 +0000
commit807071d35159de0660f9df31c48d5bf895ca3622 (patch)
treea1e9dbdc1e58b91cd2e4a5e472597b0204ccb41d /pokemod/AbilityEffect.cpp
parentf444f5a45e9325644a360f656176d47d7f540f52 (diff)
[FIX] Pokemod objects now know about parents
[FIX] Project includes are now relative [FIX] Headers included for better detection of invalid headers [FIX] Validation code commented out so it can be done better git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@111 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/AbilityEffect.cpp')
-rw-r--r--pokemod/AbilityEffect.cpp305
1 files changed, 153 insertions, 152 deletions
diff --git a/pokemod/AbilityEffect.cpp b/pokemod/AbilityEffect.cpp
index 2b571fe4..dba7a5e2 100644
--- a/pokemod/AbilityEffect.cpp
+++ b/pokemod/AbilityEffect.cpp
@@ -15,13 +15,13 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
+// Header include
+#include "AbilityEffect.h"
+
// Pokemod includes
#include "Ability.h"
-#include "Pokemod.h"
#include "Type.h"
-
-// Header include
-#include "AbilityEffect.h"
+#include "Pokemod.h"
const QStringList AbilityEffect::EffectStr = QStringList() << "Damage to HP" << "Prevent Damage" << "Auto Heal" << "Deal Damage" << "Wilds" << "Stat" << "Status" << "Ability" << "Accuracy/Power Trade" << "Bullseye" << "Item Effect" << "Type" << "Fast Hatch" << "Weather";
const QStringList AbilityEffect::TriggerStr = QStringList() << "Anything" << "Contact" << "Weather" << "Damage" << "Type" << "HP Boundary" << "Stat Change" << "Status";
@@ -34,13 +34,13 @@ const QStringList AbilityEffect::SideStr = QStringList() << "Above" << "Below";
AbilityEffect::AbilityEffect(const AbilityEffect& effect) :
- Object("AbilityEffect", effect.pokemod(), effect.id())
+ Object("AbilityEffect", effect.parent(), effect.id())
{
*this = effect;
}
-AbilityEffect::AbilityEffect(const Pokemod* pokemod, const int id) :
- Object("AbilityEffect", pokemod, id),
+AbilityEffect::AbilityEffect(const Object* parent, const int id) :
+ Object("AbilityEffect", parent, id),
m_chance(1, 1),
m_effect(INT_MAX),
m_value1(INT_MAX),
@@ -52,156 +52,157 @@ AbilityEffect::AbilityEffect(const Pokemod* pokemod, const int id) :
{
}
-AbilityEffect::AbilityEffect(const AbilityEffect& effect, const Pokemod* pokemod, const int id) :
- Object("AbilityEffect", pokemod, id)
+AbilityEffect::AbilityEffect(const AbilityEffect& effect, const Object* parent, const int id) :
+ Object("AbilityEffect", parent, id)
{
*this = effect;
}
-AbilityEffect::AbilityEffect(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("AbilityEffect", pokemod, id)
+AbilityEffect::AbilityEffect(const QDomElement& xml, const Object* parent, const int id) :
+ Object("AbilityEffect", parent, id)
{
load(xml, id);
}
bool AbilityEffect::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Effect with id %1---").arg(id()), Pokemod::V_Msg);
- if (m_effect < E_End)
- {
- bool ok = true;
- switch (m_effect)
- {
- case E_Stats:
- if ((Pokemod::ST_HP == m_value1) || (Pokemod::ST_End_Battle <= m_value1) || ((Pokemod::ST_SpecialDefense == m_value1) && !pokemod()->rules()->specialSplit()))
- ok = false;
- break;
- case E_Status:
- if (Pokemod::STS_End <= m_value1)
- ok = false;
- break;
- case E_Ability:
- if (pokemod()->abilityIndex(m_value1) == INT_MAX)
- ok = false;
- break;
- case E_AccuracyPowerTrade:
- if (PA_End <= m_value1)
- ok = false;
- break;
- case E_ItemEffect:
- if (IT_End <= m_value1)
- ok = false;
- break;
- case E_Type:
- if (pokemod()->typeIndex(m_value1) == INT_MAX)
- ok = false;
- break;
- case E_Weather:
- if (Pokemod::W_End_All <= m_value1)
- ok = false;
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid value 1");
- valid = false;
- ok = true;
- }
- switch (m_effect)
- {
- case E_Stats:
- if (Pokemod::BM_End <= m_value2)
- ok = false;
- break;
- case E_Status:
- case E_Weather:
- if (C_End <= m_value2)
- ok = false;
- break;
- case E_Ability:
- if (I_End <= m_value2)
- ok = false;
- break;
- case E_Type:
- if (B_End <= m_value2)
- ok = false;
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid value 2");
- valid = false;
- ok = true;
- }
- switch (m_effect)
- {
- case E_DamageToHP:
- case E_PreventDamage:
- case E_AutoHeal:
- case E_DealDamage:
- case E_Wilds:
- case E_AccuracyPowerTrade:
- case E_Type:
- case E_FastHatch:
- if ((m_value3 < 0) || (100 < m_value3))
- ok = false;
- break;
- case E_Stats:
- if ((m_value3 < -12) || (12 < m_value3))
- ok = false;
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid value 3");
- valid = false;
- ok = true;
- }
- }
- else
- {
- pokemod()->validationMsg("Invalid effect");
- valid = false;
- }
- if (m_trigger < T_End)
- {
- bool ok = true;
- switch (m_trigger)
- {
- case T_Weather:
- if (Pokemod::W_End_All <= m_triggerValue1)
- ok = false;
- break;
- case T_Type:
- if (pokemod()->typeIndex(m_triggerValue1) == INT_MAX)
- ok = false;
- break;
- case T_HPBoundary:
- if (S_End <= m_triggerValue1)
- ok = false;
- break;
- case T_StatChange:
- if ((Pokemod::ST_HP == m_triggerValue1) || (Pokemod::ST_End_Battle <= m_triggerValue1) || ((Pokemod::ST_SpecialDefense == m_triggerValue1) && !pokemod()->rules()->specialSplit()))
- ok = false;
- break;
- case T_Status:
- if (Pokemod::STS_End <= m_triggerValue1)
- ok = false;
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid trigger value 1");
- valid = false;
- }
- }
- else
- {
- pokemod()->validationMsg("Invalid trigger");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Effect with id %1---").arg(id()), Pokemod::V_Msg);
+// if (m_effect < E_End)
+// {
+// bool ok = true;
+// switch (m_effect)
+// {
+// case E_Stats:
+// if ((Pokemod::ST_HP == m_value1) || (Pokemod::ST_End_Battle <= m_value1) || ((Pokemod::ST_SpecialDefense == m_value1) && !static_cast<const Pokemod*>(pokemod())->rules()->specialSplit()))
+// ok = false;
+// break;
+// case E_Status:
+// if (Pokemod::STS_End <= m_value1)
+// ok = false;
+// break;
+// case E_Ability:
+// if (static_cast<const Pokemod*>(pokemod())->abilityIndex(m_value1) == INT_MAX)
+// ok = false;
+// break;
+// case E_AccuracyPowerTrade:
+// if (PA_End <= m_value1)
+// ok = false;
+// break;
+// case E_ItemEffect:
+// if (IT_End <= m_value1)
+// ok = false;
+// break;
+// case E_Type:
+// if (static_cast<const Pokemod*>(pokemod())->typeIndex(m_value1) == INT_MAX)
+// ok = false;
+// break;
+// case E_Weather:
+// if (Pokemod::W_End_All <= m_value1)
+// ok = false;
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid value 1");
+// valid = false;
+// ok = true;
+// }
+// switch (m_effect)
+// {
+// case E_Stats:
+// if (Pokemod::BM_End <= m_value2)
+// ok = false;
+// break;
+// case E_Status:
+// case E_Weather:
+// if (C_End <= m_value2)
+// ok = false;
+// break;
+// case E_Ability:
+// if (I_End <= m_value2)
+// ok = false;
+// break;
+// case E_Type:
+// if (B_End <= m_value2)
+// ok = false;
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid value 2");
+// valid = false;
+// ok = true;
+// }
+// switch (m_effect)
+// {
+// case E_DamageToHP:
+// case E_PreventDamage:
+// case E_AutoHeal:
+// case E_DealDamage:
+// case E_Wilds:
+// case E_AccuracyPowerTrade:
+// case E_Type:
+// case E_FastHatch:
+// if ((m_value3 < 0) || (100 < m_value3))
+// ok = false;
+// break;
+// case E_Stats:
+// if ((m_value3 < -12) || (12 < m_value3))
+// ok = false;
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid value 3");
+// valid = false;
+// ok = true;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid effect");
+// valid = false;
+// }
+// if (m_trigger < T_End)
+// {
+// bool ok = true;
+// switch (m_trigger)
+// {
+// case T_Weather:
+// if (Pokemod::W_End_All <= m_triggerValue1)
+// ok = false;
+// break;
+// case T_Type:
+// if (static_cast<const Pokemod*>(pokemod())->typeIndex(m_triggerValue1) == INT_MAX)
+// ok = false;
+// break;
+// case T_HPBoundary:
+// if (S_End <= m_triggerValue1)
+// ok = false;
+// break;
+// case T_StatChange:
+// if ((Pokemod::ST_HP == m_triggerValue1) || (Pokemod::ST_End_Battle <= m_triggerValue1) || ((Pokemod::ST_SpecialDefense == m_triggerValue1) && !static_cast<const Pokemod*>(pokemod())->rules()->specialSplit()))
+// ok = false;
+// break;
+// case T_Status:
+// if (Pokemod::STS_End <= m_triggerValue1)
+// ok = false;
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid trigger value 1");
+// valid = false;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid trigger");
+// valid = false;
+// }
+// return valid;
}
void AbilityEffect::load(const QDomElement& xml, int id)
@@ -253,7 +254,7 @@ void AbilityEffect::setValue1(const int value1) throw(Exception)
switch (m_effect)
{
case E_Stats:
- if ((Pokemod::ST_HP == value1) || (Pokemod::ST_End_Battle <= value1) || ((Pokemod::ST_SpecialDefense == value1) && !pokemod()->rules()->specialSplit()))
+ if ((Pokemod::ST_HP == value1) || (Pokemod::ST_End_Battle <= value1) || ((Pokemod::ST_SpecialDefense == value1) && !static_cast<const Pokemod*>(pokemod())->rules()->specialSplit()))
error<BoundsException>("value1");
break;
case E_Status:
@@ -261,7 +262,7 @@ void AbilityEffect::setValue1(const int value1) throw(Exception)
error<BoundsException>("value1");
break;
case E_Ability:
- if (pokemod()->abilityIndex(value1) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->abilityIndex(value1) == INT_MAX)
error<BoundsException>("value1");
break;
case E_AccuracyPowerTrade:
@@ -273,7 +274,7 @@ void AbilityEffect::setValue1(const int value1) throw(Exception)
error<BoundsException>("value1");
break;
case E_Type:
- if (pokemod()->typeIndex(value1) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->typeIndex(value1) == INT_MAX)
error<BoundsException>("value1");
break;
case E_Weather:
@@ -359,7 +360,7 @@ void AbilityEffect::setTriggerValue1(const int triggerValue1) throw(Exception)
error<BoundsException>("triggerValue1");
break;
case T_Type:
- if (pokemod()->typeIndex(triggerValue1) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->typeIndex(triggerValue1) == INT_MAX)
error<BoundsException>("triggerValue1");
break;
case T_HPBoundary:
@@ -367,7 +368,7 @@ void AbilityEffect::setTriggerValue1(const int triggerValue1) throw(Exception)
error<BoundsException>("triggerValue1");
break;
case T_StatChange:
- if ((Pokemod::ST_HP == triggerValue1) || (Pokemod::ST_End_Battle <= triggerValue1) || ((Pokemod::ST_SpecialDefense == triggerValue1) && !pokemod()->rules()->specialSplit()))
+ if ((Pokemod::ST_HP == triggerValue1) || (Pokemod::ST_End_Battle <= triggerValue1) || ((Pokemod::ST_SpecialDefense == triggerValue1) && !static_cast<const Pokemod*>(pokemod())->rules()->specialSplit()))
error<BoundsException>("triggerValue1");
break;
case T_Status: