summaryrefslogtreecommitdiffstats
path: root/pokemod/ItemEffect.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-15 18:57:00 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-15 18:57:00 +0000
commite1b5d7bc705810ac15ed36924617af52abdc8e81 (patch)
tree0dae5af4e2737372ec479bb9ccdd2201edf684a8 /pokemod/ItemEffect.cpp
parent12d5161318a4d8d781f896812f5a95fa7b46d8a8 (diff)
[FIX] Object::mid -> m_id
[FIX] XML is now used [FIX] Images are stored in the XML file and classes rather than relying on external images [FIX] Frac no longer keeps track of its type; the class should do it [ADD] pokemod/Object.cpp git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@97 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/ItemEffect.cpp')
-rw-r--r--pokemod/ItemEffect.cpp77
1 files changed, 34 insertions, 43 deletions
diff --git a/pokemod/ItemEffect.cpp b/pokemod/ItemEffect.cpp
index 5d663cf3..8520548f 100644
--- a/pokemod/ItemEffect.cpp
+++ b/pokemod/ItemEffect.cpp
@@ -51,10 +51,10 @@ ItemEffect::ItemEffect(const Pokemod* pokemod, const ItemEffect& effect, const i
*this = effect;
}
-ItemEffect::ItemEffect(const Pokemod* pokemod, const QString& fileName, const int id) :
+ItemEffect::ItemEffect(const Pokemod* pokemod, const QDomElement& xml, const int id) :
Object("ItemEffect", pokemod, id)
{
- load(fileName, id);
+ load(xml, id);
}
bool ItemEffect::validate() const
@@ -296,40 +296,31 @@ bool ItemEffect::validate() const
return valid;
}
-void ItemEffect::load(const QString& fileName, int id) throw(Exception)
+void ItemEffect::load(const QDomElement& xml, int id)
{
- Ini ini(fileName);
- if (id == INT_MAX)
- ini.getValue("id", id);
- setId(id);
- int i;
- int j;
- ini.getValue("overworld", m_overworld, false);
- ini.getValue("battle", m_battle, false);
- ini.getValue("held", m_held, false);
- ini.getValue("effect", m_effect);
- ini.getValue("value1", m_value1);
- ini.getValue("value2", m_value2);
- ini.getValue("value3", m_value3);
- ini.getValue("value4-n", i, 1);
- ini.getValue("value4-n", j, 1);
- m_value4.set(i, j);
+ LOAD_ID();
+ LOAD(bool, overworld);
+ LOAD(bool, battle);
+ LOAD(bool, held);
+ LOAD(int, effect);
+ LOAD(int, value1);
+ LOAD(int, value2);
+ LOAD(int, value3);
+ LOAD(Frac, value4);
}
-void ItemEffect::save(const QString& item) const throw(Exception)
+QDomElement ItemEffect::save() const
{
- Ini ini;
- ini.addField("id", id());
- ini.addField("overworld", m_overworld);
- ini.addField("battle", m_battle);
- ini.addField("held", m_held);
- ini.addField("effect", m_effect);
- ini.addField("value1", m_value1);
- ini.addField("value2", m_value2);
- ini.addField("value3", m_value3);
- ini.addField("value4-n", m_value4.numerator());
- ini.addField("value4-d", m_value4.denominator());
- ini.save(QString("%1/item/%2/effect/%3.pini").arg(pokemod()->path()).arg(item).arg(id()));
+ SAVE_CREATE();
+ SAVE(bool, overworld);
+ SAVE(bool, battle);
+ SAVE(bool, held);
+ SAVE(int, effect);
+ SAVE(int, value1);
+ SAVE(int, value2);
+ SAVE(int, value3);
+ SAVE(Frac, value4);
+ return xml;
}
void ItemEffect::setOverworld(const bool overworld) throw(Exception)
@@ -425,7 +416,7 @@ void ItemEffect::setEffect(const int effect) throw(Exception)
m_value1 = 0;
m_value2 = INT_MAX;
m_value3 = INT_MAX;
- m_value4.set(1, 1, ((E_TypeBoost == effect) || (E_PPBoost == effect)) ? Frac::Over1 : Frac::Proper);
+ m_value4.set(1, 1); //, ((E_TypeBoost == effect) || (E_PPBoost == effect)) ? Frac::Over1 : Frac::Proper);
}
void ItemEffect::setValue1(const int value1) throw(Exception)
@@ -623,7 +614,7 @@ void ItemEffect::setValue3(const int value3) throw(Exception)
m_value3 = value3;
}
-void ItemEffect::setValue4(const int numerator, const int denominator) throw(Exception)
+void ItemEffect::setValue4(const Frac& value4) throw(Exception)
{
switch (m_effect)
{
@@ -653,7 +644,7 @@ void ItemEffect::setValue4(const int numerator, const int denominator) throw(Exc
throw(UnusedException(className(), "value4"));
break;
}
- m_value4.set(numerator, denominator);
+ m_value4 = value4;
}
bool ItemEffect::overworld() const
@@ -700,13 +691,13 @@ ItemEffect& ItemEffect::operator=(const ItemEffect& rhs)
{
if (this == &rhs)
return *this;
- m_overworld = rhs.m_overworld;
- m_battle = rhs.m_battle;
- m_held = rhs.m_held;
- m_effect = rhs.m_effect;
- m_value1 = rhs.m_value1;
- m_value2 = rhs.m_value2;
- m_value3 = rhs.m_value3;
- m_value4 = rhs.m_value4;
+ COPY(overworld);
+ COPY(battle);
+ COPY(held);
+ COPY(effect);
+ COPY(value1);
+ COPY(value2);
+ COPY(value3);
+ COPY(value4);
return *this;
}