diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2008-04-15 18:57:00 +0000 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2008-04-15 18:57:00 +0000 |
commit | e1b5d7bc705810ac15ed36924617af52abdc8e81 (patch) | |
tree | 0dae5af4e2737372ec479bb9ccdd2201edf684a8 /pokemod/AbilityEffect.cpp | |
parent | 12d5161318a4d8d781f896812f5a95fa7b46d8a8 (diff) | |
download | sigen-e1b5d7bc705810ac15ed36924617af52abdc8e81.tar.gz sigen-e1b5d7bc705810ac15ed36924617af52abdc8e81.tar.xz sigen-e1b5d7bc705810ac15ed36924617af52abdc8e81.zip |
[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/AbilityEffect.cpp')
-rw-r--r-- | pokemod/AbilityEffect.cpp | 84 |
1 files changed, 36 insertions, 48 deletions
diff --git a/pokemod/AbilityEffect.cpp b/pokemod/AbilityEffect.cpp index e9ae084e..369095d9 100644 --- a/pokemod/AbilityEffect.cpp +++ b/pokemod/AbilityEffect.cpp @@ -42,7 +42,7 @@ AbilityEffect::AbilityEffect(const Pokemod* pokemod, const int id) : m_value3(INT_MAX), m_trigger(INT_MAX), m_triggerValue1(INT_MAX), - m_triggerValue2(INT_MAX) + m_triggerValue2(1, 1) { } @@ -52,10 +52,10 @@ AbilityEffect::AbilityEffect(const Pokemod* pokemod, const AbilityEffect& effect *this = effect; } -AbilityEffect::AbilityEffect(const Pokemod* pokemod, const QString& fileName, const int id) : +AbilityEffect::AbilityEffect(const Pokemod* pokemod, const QDomElement& xml, const int id) : Object("AbilityEffect", pokemod, id) { - load(fileName, id); + load(xml, id); } bool AbilityEffect::validate() const @@ -198,48 +198,36 @@ bool AbilityEffect::validate() const return valid; } -void AbilityEffect::load(const QString& fileName, int id) throw(Exception) +void AbilityEffect::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("chance-n", i, 1); - ini.getValue("chance-d", j, 1); - m_chance.set(i, j); - ini.getValue("effect", m_effect); - ini.getValue("value1", m_value1); - ini.getValue("value2", m_value2); - ini.getValue("value3", m_value3); - ini.getValue("trigger", m_trigger); - ini.getValue("triggerValue1", m_triggerValue1); - ini.getValue("triggerValue2-n", i, 1); - ini.getValue("triggerValue2-d", j, 1); - m_triggerValue2.set(i, j); + LOAD_ID(); + LOAD(Frac, chance); + LOAD(int, effect); + LOAD(int, value1); + LOAD(int, value2); + LOAD(int, value3); + LOAD(int, trigger); + LOAD(int, triggerValue1); + LOAD(Frac, triggerValue2); } -void AbilityEffect::save(const QString& ability) const throw(Exception) +QDomElement AbilityEffect::save() const { - Ini ini; - ini.addField("id", id()); - ini.addField("chance-n", m_chance.numerator()); - ini.addField("chance-d", m_chance.denominator()); - ini.addField("effect", m_effect); - ini.addField("value1", m_value1); - ini.addField("value2", m_value2); - ini.addField("value3", m_value3); - ini.addField("trigger", m_trigger); - ini.addField("triggerValue1", m_triggerValue1); - ini.addField("triggerValue2-n", m_triggerValue2.numerator()); - ini.addField("triggerValue2-d", m_triggerValue2.denominator()); - ini.save(QString("%1/ability/%2/effect/%3.pini").arg(pokemod()->path()).arg(ability).arg(id())); + SAVE_CREATE(); + SAVE(Frac, chance); + SAVE(int, effect); + SAVE(int, value1); + SAVE(int, value2); + SAVE(int, value3); + SAVE(int, trigger); + SAVE(int, triggerValue1); + SAVE(Frac, triggerValue2); + return xml; } -void AbilityEffect::setChance(const int numerator, const int denominator) throw(Exception) +void AbilityEffect::setChance(const Frac& chance) throw(Exception) { - m_chance.set(numerator, denominator); + m_chance = chance; } void AbilityEffect::setEffect(const int effect) throw(BoundsException) @@ -385,11 +373,11 @@ void AbilityEffect::setTriggerValue1(const int triggerValue1) throw(Exception) m_triggerValue1 = triggerValue1; } -void AbilityEffect::setTriggerValue2(const int numerator, const int denominator) throw(Exception) +void AbilityEffect::setTriggerValue2(const Frac& triggerValue2) throw(Exception) { if (m_trigger != T_HPBoundary) throw(UnusedException(className(), "triggerValue2")); - m_triggerValue2.set(numerator, denominator); + m_triggerValue2 = triggerValue2; } Frac AbilityEffect::chance() const @@ -436,13 +424,13 @@ AbilityEffect& AbilityEffect::operator=(const AbilityEffect& rhs) { if (this == &rhs) return *this; - m_chance = rhs.m_chance; - m_effect = rhs.m_effect; - m_value1 = rhs.m_value1; - m_value2 = rhs.m_value2; - m_value3 = rhs.m_value3; - m_trigger = rhs.m_trigger; - m_triggerValue1 = rhs.m_triggerValue1; - m_triggerValue2 = rhs.m_triggerValue2; + COPY(chance); + COPY(effect); + COPY(value1); + COPY(value2); + COPY(value3); + COPY(trigger); + COPY(triggerValue1); + COPY(triggerValue2); return *this; } |