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/MoveEffect.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/MoveEffect.cpp')
| -rw-r--r-- | pokemod/MoveEffect.cpp | 77 |
1 files changed, 31 insertions, 46 deletions
diff --git a/pokemod/MoveEffect.cpp b/pokemod/MoveEffect.cpp index afdb3dcb..7b656803 100644 --- a/pokemod/MoveEffect.cpp +++ b/pokemod/MoveEffect.cpp @@ -40,61 +40,46 @@ MoveEffect::MoveEffect(const Pokemod* pokemod, const MoveEffect& effect, const i *this = effect; } -MoveEffect::MoveEffect(const Pokemod* pokemod, const QString& fileName, const int id) : +MoveEffect::MoveEffect(const Pokemod* pokemod, const QDomElement& xml, const int id) : Object("MoveEffect", pokemod, id) { - load(fileName, id); + load(xml, id); } bool MoveEffect::validate() const { bool valid = true; pokemod()->validationMsg(QString("------Effect with id %1---").arg(id()), Pokemod::V_Msg); - // TODO (Ben#1#): Move Effect validation + // TODO: Move Effect validation return valid; } -void MoveEffect::load(const QString& fileName, int id) throw(Exception) +void MoveEffect::load(const QDomElement& xml, int id) { - Ini ini(fileName); - if (id == INT_MAX) - ini.getValue("id", id); - setId(id); - int i; - int j; - int k; - 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("value4-n", i); - ini.getValue("value4-d", j); - ini.getValue("value4-t", k); - m_value4.set(i, j, k); + LOAD_ID(); + LOAD(Frac, chance); + LOAD(int, effect); + LOAD(int, value1); + LOAD(int, value2); + LOAD(int, value3); + LOAD(Frac, value4); } -void MoveEffect::save(const QString& move) const throw(Exception) +QDomElement MoveEffect::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("value4-n", m_value4.numerator()); - ini.addField("value4-d", m_value4.denominator()); - ini.addField("value4-t", m_value4.type()); - ini.save(QString("%1/move/%2/effect/%3.pini").arg(pokemod()->path()).arg(move).arg(id())); + SAVE_CREATE(); + SAVE(Frac, chance); + SAVE(int, effect); + SAVE(int, value1); + SAVE(int, value2); + SAVE(int, value3); + SAVE(Frac, value4); + return xml; } -void MoveEffect::setChance(const int numerator, const int denominator) throw(Exception) +void MoveEffect::setChance(const Frac& chance) throw(Exception) { - m_chance.set(numerator, denominator); + m_chance = chance; } void MoveEffect::setEffect(const int effect) throw(BoundsException) @@ -105,7 +90,7 @@ void MoveEffect::setEffect(const int effect) throw(BoundsException) m_value1 = INT_MAX; m_value2 = INT_MAX; m_value3 = 0; - m_value4.set(1, 1, ((effect == E_StealHP) || (effect == E_Counter) || (effect == E_Selfdestruct) || (effect == E_Mirror) || (effect == E_GetMoney) || (effect == E_WaitAndReturn) || (effect == E_Recoil)) ? Frac::Improper : Frac::Proper); + m_value4.set(1, 1);//, ((effect == E_StealHP) || (effect == E_Counter) || (effect == E_Selfdestruct) || (effect == E_Mirror) || (effect == E_GetMoney) || (effect == E_WaitAndReturn) || (effect == E_Recoil)) ? Frac::Improper : Frac::Proper); } void MoveEffect::setValue1(const int value1) throw(Exception) @@ -167,9 +152,9 @@ void MoveEffect::setValue3(const int value3) m_value3 = value3; } -void MoveEffect::setValue4(const int numerator, const int denominator) throw(Exception) +void MoveEffect::setValue4(const Frac& value4) throw(Exception) { - m_value4.set(numerator, denominator); + m_value4 = value4; } Frac MoveEffect::chance() const @@ -206,11 +191,11 @@ MoveEffect& MoveEffect::operator=(const MoveEffect& 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_value4 = rhs.m_value4; + COPY(chance); + COPY(effect); + COPY(value1); + COPY(value2); + COPY(value3); + COPY(value4); return *this; } |
