diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-01-21 17:13:11 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-01-21 17:13:11 +0000 |
| commit | a1fff27395d1930820e6c007fdedd8e9dc58f0b3 (patch) | |
| tree | f61c6b86b4a415fdc2bd0f7d6ca9bfdbfd8e8b64 | |
| parent | 342fa6879e9fd8a757ebabe0a30370137b8d83a7 (diff) | |
| download | sigen-a1fff27395d1930820e6c007fdedd8e9dc58f0b3.tar.gz sigen-a1fff27395d1930820e6c007fdedd8e9dc58f0b3.tar.xz sigen-a1fff27395d1930820e6c007fdedd8e9dc58f0b3.zip | |
[FIX] PokeMod namespace removed
[ADD] MoveEffect editing form for PokéModr
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@38 6ecfd1a5-f3ed-3746-8530-beee90d26b22
67 files changed, 3398 insertions, 3258 deletions
@@ -1,4 +1,12 @@ ----------------- +Rev: 38 +Date: 21 January 2008 +User: MathStuf +----------------- +[FIX] PokeMod namespace removed +[ADD] MoveEffect editing form for PokéModr + +----------------- Rev: 37 Date: 21 January 2008 User: MathStuf diff --git a/pokemod/Ability.cpp b/pokemod/Ability.cpp index 2e29d76e..9e8b89bd 100644 --- a/pokemod/Ability.cpp +++ b/pokemod/Ability.cpp @@ -30,25 +30,25 @@ #include "Pokemod.h" #include "Ability.h" -PokeMod::Ability::Ability(const Pokemod& par, const unsigned _id) : +Ability::Ability(const Pokemod& par, const unsigned _id) : Object(par, _id), name("") { } -PokeMod::Ability::Ability(const Pokemod& par, const Ability& a, const unsigned _id) : +Ability::Ability(const Pokemod& par, const Ability& a, const unsigned _id) : Object(par, _id) { *this = a; } -PokeMod::Ability::Ability(const Pokemod& par, const QString& fname, const unsigned _id) : +Ability::Ability(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::Ability::validate() const +bool Ability::validate() const { bool valid = true; pokemod.validationMsg(QString("---Ability \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -83,7 +83,7 @@ bool PokeMod::Ability::validate() const return valid; } -unsigned PokeMod::Ability::getNewId() const +unsigned Ability::getNewId() const { unsigned i = 0; for (; (i < getEffectCount()) && (getEffectIndex(i) != UINT_MAX); ++i) @@ -91,7 +91,7 @@ unsigned PokeMod::Ability::getNewId() const return i; } -void PokeMod::Ability::load(const QString& fname, const unsigned _id) throw(Exception) +void Ability::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -110,7 +110,7 @@ void PokeMod::Ability::load(const QString& fname, const unsigned _id) throw(Exce } } -void PokeMod::Ability::save() const throw(Exception) +void Ability::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -120,41 +120,41 @@ void PokeMod::Ability::save() const throw(Exception) i.next().save(name); } -void PokeMod::Ability::setName(const QString& n) +void Ability::setName(const QString& n) { name = n; } -QString PokeMod::Ability::getName() const +QString Ability::getName() const { return name; } -const PokeMod::AbilityEffect& PokeMod::Ability::getEffect(const unsigned i) const throw(IndexException) +const AbilityEffect& Ability::getEffect(const unsigned i) const throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Ability")); return effects.at(i); } -PokeMod::AbilityEffect& PokeMod::Ability::getEffect(const unsigned i) throw(IndexException) +AbilityEffect& Ability::getEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Ability")); return effects[i]; } -const PokeMod::AbilityEffect& PokeMod::Ability::getEffectByID(const unsigned i) const throw(IndexException) +const AbilityEffect& Ability::getEffectByID(const unsigned i) const throw(IndexException) { return getEffect(getEffectIndex(i)); } -PokeMod::AbilityEffect& PokeMod::Ability::getEffectByID(const unsigned i) throw(IndexException) +AbilityEffect& Ability::getEffectByID(const unsigned i) throw(IndexException) { return getEffect(getEffectIndex(i)); } -unsigned PokeMod::Ability::getEffectIndex(const unsigned _id) const +unsigned Ability::getEffectIndex(const unsigned _id) const { for (unsigned i = 0; i < getEffectCount(); ++i) { @@ -164,37 +164,37 @@ unsigned PokeMod::Ability::getEffectIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Ability::getEffectCount() const +unsigned Ability::getEffectCount() const { return effects.size(); } -PokeMod::AbilityEffect& PokeMod::Ability::newEffect() +AbilityEffect& Ability::newEffect() { effects.append(AbilityEffect(pokemod, getNewId())); return effects[getEffectCount() - 1]; } -PokeMod::AbilityEffect& PokeMod::Ability::newEffect(const QString& fname) +AbilityEffect& Ability::newEffect(const QString& fname) { effects.append(AbilityEffect(pokemod, fname, getNewId())); return effects[getEffectCount() - 1]; } -PokeMod::AbilityEffect& PokeMod::Ability::newEffect(const AbilityEffect& e) +AbilityEffect& Ability::newEffect(const AbilityEffect& e) { effects.append(AbilityEffect(pokemod, e, getNewId())); return effects[getEffectCount() - 1]; } -void PokeMod::Ability::deleteEffect(const unsigned i) throw(IndexException) +void Ability::deleteEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Ability")); effects.removeAt(i); } -PokeMod::Ability& PokeMod::Ability::operator=(const Ability& rhs) +Ability& Ability::operator=(const Ability& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Ability.h b/pokemod/Ability.h index ff5bb82a..82bbeaf5 100644 --- a/pokemod/Ability.h +++ b/pokemod/Ability.h @@ -30,44 +30,41 @@ #include "Object.h" #include "AbilityEffect.h" -namespace PokeMod +class Pokemod; + +class Ability : public Object { - class Pokemod; - - class Ability : public Object - { - public: - Ability(const Pokemod& par, const unsigned _id); - Ability(const Pokemod& par, const Ability& a, const unsigned _id); - Ability(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - - QString getName() const; - - const AbilityEffect& getEffect(const unsigned i) const throw(IndexException); - AbilityEffect& getEffect(const unsigned i) throw(IndexException); - const AbilityEffect& getEffectByID(const unsigned i) const throw(IndexException); - AbilityEffect& getEffectByID(const unsigned i) throw(IndexException); - unsigned getEffectIndex(const unsigned _id) const; - unsigned getEffectCount() const; - AbilityEffect& newEffect(); - AbilityEffect& newEffect(const QString& fname); - AbilityEffect& newEffect(const AbilityEffect& a); - void deleteEffect(const unsigned i) throw(IndexException); - - Ability& operator=(const Ability& rhs); - private: - bool validate() const; - unsigned getNewId() const; - - QString name; - - QList<AbilityEffect> effects; - }; -} + public: + Ability(const Pokemod& par, const unsigned _id); + Ability(const Pokemod& par, const Ability& a, const unsigned _id); + Ability(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + + QString getName() const; + + const AbilityEffect& getEffect(const unsigned i) const throw(IndexException); + AbilityEffect& getEffect(const unsigned i) throw(IndexException); + const AbilityEffect& getEffectByID(const unsigned i) const throw(IndexException); + AbilityEffect& getEffectByID(const unsigned i) throw(IndexException); + unsigned getEffectIndex(const unsigned _id) const; + unsigned getEffectCount() const; + AbilityEffect& newEffect(); + AbilityEffect& newEffect(const QString& fname); + AbilityEffect& newEffect(const AbilityEffect& a); + void deleteEffect(const unsigned i) throw(IndexException); + + Ability& operator=(const Ability& rhs); + private: + bool validate() const; + unsigned getNewId() const; + + QString name; + + QList<AbilityEffect> effects; +}; #endif diff --git a/pokemod/AbilityEffect.cpp b/pokemod/AbilityEffect.cpp index edd84312..dd47c900 100644 --- a/pokemod/AbilityEffect.cpp +++ b/pokemod/AbilityEffect.cpp @@ -26,17 +26,17 @@ #include "Type.h" #include "AbilityEffect.h" -const QStringList PokeMod::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 PokeMod::AbilityEffect::TriggerStr = QStringList() << "Anything" << "Contact" << "Weather" << "Damage" << "Type" << "HP Boundary" << "Stat Change" << "Status"; -const QStringList PokeMod::AbilityEffect::InteractStr = QStringList() << "Trade" << "Shadow" << "Block"; -const QStringList PokeMod::AbilityEffect::PowerAccStr = QStringList() << "Boost Power" << "Boost Accuracy"; -const QStringList PokeMod::AbilityEffect::ItemStr = QStringList() << "Stat Modifier" << "Type Booster" << "Flinch" << "Go First"; -const QStringList PokeMod::AbilityEffect::CauseStr = QStringList() << "Prevent" << "Inflict"; -const QStringList PokeMod::AbilityEffect::BoostStr = QStringList() << "Boost" << "Hinder"; -const QStringList PokeMod::AbilityEffect::SideStr = QStringList() << "Above" << "Below"; +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"; +const QStringList AbilityEffect::InteractStr = QStringList() << "Trade" << "Shadow" << "Block"; +const QStringList AbilityEffect::PowerAccStr = QStringList() << "Boost Power" << "Boost Accuracy"; +const QStringList AbilityEffect::ItemStr = QStringList() << "Stat Modifier" << "Type Booster" << "Flinch" << "Go First"; +const QStringList AbilityEffect::CauseStr = QStringList() << "Prevent" << "Inflict"; +const QStringList AbilityEffect::BoostStr = QStringList() << "Boost" << "Hinder"; +const QStringList AbilityEffect::SideStr = QStringList() << "Above" << "Below"; -PokeMod::AbilityEffect::AbilityEffect(const Pokemod& par, const unsigned _id) : +AbilityEffect::AbilityEffect(const Pokemod& par, const unsigned _id) : Object(par, _id), chance(1, 1), effect(UINT_MAX), @@ -49,19 +49,19 @@ PokeMod::AbilityEffect::AbilityEffect(const Pokemod& par, const unsigned _id) : { } -PokeMod::AbilityEffect::AbilityEffect(const Pokemod& par, const AbilityEffect& e, const unsigned _id) : +AbilityEffect::AbilityEffect(const Pokemod& par, const AbilityEffect& e, const unsigned _id) : Object(par, _id) { *this = e; } -PokeMod::AbilityEffect::AbilityEffect(const Pokemod& par, const QString& fname, const unsigned _id) : +AbilityEffect::AbilityEffect(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::AbilityEffect::validate() const +bool AbilityEffect::validate() const { bool valid = true; pokemod.validationMsg(QString("------Effect with id %1---").arg(id), Pokemod::V_Msg); @@ -201,7 +201,7 @@ bool PokeMod::AbilityEffect::validate() const return valid; } -void PokeMod::AbilityEffect::load(const QString& fname, const unsigned _id) throw(Exception) +void AbilityEffect::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -224,7 +224,7 @@ void PokeMod::AbilityEffect::load(const QString& fname, const unsigned _id) thro tval2.set(i, j); } -void PokeMod::AbilityEffect::save(const QString& ability) const throw(Exception) +void AbilityEffect::save(const QString& ability) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -241,22 +241,22 @@ void PokeMod::AbilityEffect::save(const QString& ability) const throw(Exception) ini.save(QString("%1/ability/%2/effect/%3.pini").arg(pokemod.getPath()).arg(ability).arg(id)); } -void PokeMod::AbilityEffect::setChance(const unsigned n, const unsigned d) throw(Exception) +void AbilityEffect::setChance(const unsigned n, const unsigned d) throw(Exception) { chance.set(n, d); } -void PokeMod::AbilityEffect::setChanceNum(const unsigned n) throw(Exception) +void AbilityEffect::setChanceNum(const unsigned n) throw(Exception) { chance.setNum(n); } -void PokeMod::AbilityEffect::setChanceDenom(const unsigned d) throw(Exception) +void AbilityEffect::setChanceDenom(const unsigned d) throw(Exception) { chance.setDenom(d); } -void PokeMod::AbilityEffect::setEffect(const unsigned e) throw(BoundsException) +void AbilityEffect::setEffect(const unsigned e) throw(BoundsException) { if (E_End <= e) throw(BoundsException("AbilityEffect", "effect")); @@ -266,7 +266,7 @@ void PokeMod::AbilityEffect::setEffect(const unsigned e) throw(BoundsException) val3 = INT_MAX; } -void PokeMod::AbilityEffect::setVal1(const unsigned v1) throw(Exception) +void AbilityEffect::setVal1(const unsigned v1) throw(Exception) { switch (effect) { @@ -305,7 +305,7 @@ void PokeMod::AbilityEffect::setVal1(const unsigned v1) throw(Exception) val1 = v1; } -void PokeMod::AbilityEffect::setVal2(const unsigned v2) throw(Exception) +void AbilityEffect::setVal2(const unsigned v2) throw(Exception) { switch (effect) { @@ -333,7 +333,7 @@ void PokeMod::AbilityEffect::setVal2(const unsigned v2) throw(Exception) val2 = v2; } -void PokeMod::AbilityEffect::setVal3(const int v3) throw(Exception) +void AbilityEffect::setVal3(const int v3) throw(Exception) { switch (effect) { @@ -359,7 +359,7 @@ void PokeMod::AbilityEffect::setVal3(const int v3) throw(Exception) val3 = v3; } -void PokeMod::AbilityEffect::setTrigger(const unsigned t) throw(BoundsException) +void AbilityEffect::setTrigger(const unsigned t) throw(BoundsException) { if (T_End <= t) throw(BoundsException("AbilityEffect", "trigger")); @@ -368,7 +368,7 @@ void PokeMod::AbilityEffect::setTrigger(const unsigned t) throw(BoundsException) tval2.set(1, 1); } -void PokeMod::AbilityEffect::setTval1(const unsigned tv1) throw(Exception) +void AbilityEffect::setTval1(const unsigned tv1) throw(Exception) { switch (trigger) { @@ -399,68 +399,68 @@ void PokeMod::AbilityEffect::setTval1(const unsigned tv1) throw(Exception) tval1 = tv1; } -void PokeMod::AbilityEffect::setTval2(const unsigned n, const unsigned d) throw(Exception) +void AbilityEffect::setTval2(const unsigned n, const unsigned d) throw(Exception) { if (trigger != T_HPBoundary) throw(UnusedException("AbilityEffect", "tval2")); tval2.set(n, d); } -void PokeMod::AbilityEffect::setTval2Num(const unsigned n) throw(Exception) +void AbilityEffect::setTval2Num(const unsigned n) throw(Exception) { if (trigger != T_HPBoundary) throw(UnusedException("AbilityEffect", "tval2")); tval2.setNum(n); } -void PokeMod::AbilityEffect::setTval2Denom(const unsigned d) throw(Exception) +void AbilityEffect::setTval2Denom(const unsigned d) throw(Exception) { if (trigger != T_HPBoundary) throw(UnusedException("AbilityEffect", "tval2")); tval2.setDenom(d); } -Frac PokeMod::AbilityEffect::getChance() const +Frac AbilityEffect::getChance() const { return chance; } -unsigned PokeMod::AbilityEffect::getEffect() const +unsigned AbilityEffect::getEffect() const { return effect; } -unsigned PokeMod::AbilityEffect::getVal1() const +unsigned AbilityEffect::getVal1() const { return val1; } -unsigned PokeMod::AbilityEffect::getVal2() const +unsigned AbilityEffect::getVal2() const { return val2; } -int PokeMod::AbilityEffect::getVal3() const +int AbilityEffect::getVal3() const { return val3; } -unsigned PokeMod::AbilityEffect::getTrigger() const +unsigned AbilityEffect::getTrigger() const { return trigger; } -unsigned PokeMod::AbilityEffect::getTval1() const +unsigned AbilityEffect::getTval1() const { return tval1; } -Frac PokeMod::AbilityEffect::getTval2() const +Frac AbilityEffect::getTval2() const { return tval2; } -PokeMod::AbilityEffect& PokeMod::AbilityEffect::operator=(const AbilityEffect& rhs) +AbilityEffect& AbilityEffect::operator=(const AbilityEffect& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/AbilityEffect.h b/pokemod/AbilityEffect.h index 7ab155b9..dc41546c 100644 --- a/pokemod/AbilityEffect.h +++ b/pokemod/AbilityEffect.h @@ -29,140 +29,137 @@ #include "../general/Frac.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class AbilityEffect : public Object { - class Pokemod; - - class AbilityEffect : public Object - { - public: - enum Effect - { - E_DamageToHP = 0, - E_PreventDamage = 1, - E_AutoHeal = 2, - E_DealDamage = 3, - E_Wilds = 4, - E_Stats = 5, - E_Status = 6, - E_Ability = 7, - E_AccuracyPowerTrade = 8, - E_Bullseye = 9, - E_ItemEffect = 10, - E_Type = 11, - E_FastHatch = 12, - E_Weather = 13, - E_End = 14 - }; - static const QStringList EffectStr; - - enum Trigger - { - T_Anything = 0, - T_Contact = 1, - T_Weather = 2, - T_Damage = 3, - T_Type = 4, - T_HPBoundary = 5, - T_StatChange = 6, - T_Status = 7, - T_End = 8 - }; - static const QStringList TriggerStr; - - enum Interact - { - I_Trade = 0, - I_Shadow = 1, - I_Block = 2, - I_End = 3 - }; - static const QStringList InteractStr; - - enum PowerAccuracy - { - PA_Power = 0, - PA_Accuracy = 1, - PA_End = 2 - }; - static const QStringList PowerAccStr; - - enum Item - { - IT_Stat = 0, - IT_TypeBoost = 1, - IT_Flinch = 2, - IT_Quick = 3, - IT_End = 4 - }; - static const QStringList ItemStr; - - enum Cause - { - C_Prevent = 0, - C_Inflict = 1, - C_End = 2 - }; - static const QStringList CauseStr; - - enum Boost - { - B_Boost = 0, - B_Hinder = 1, - B_End = 2 - }; - static const QStringList BoostStr; - - enum Side - { - S_Above = 0, - S_Below = 1, - S_End = 2 - }; - static const QStringList SideStr; - - AbilityEffect(const Pokemod& par, const unsigned _id); - AbilityEffect(const Pokemod& par, const AbilityEffect& e, const unsigned _id); - AbilityEffect(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save(const QString& ability) const throw(Exception); - - void setChance(const unsigned n, const unsigned d) throw(Exception); - void setChanceNum(const unsigned n) throw(Exception); - void setChanceDenom(const unsigned d) throw(Exception); - void setEffect(const unsigned e) throw(BoundsException); - void setVal1(const unsigned v1) throw(Exception); - void setVal2(const unsigned v2) throw(Exception); - void setVal3(const int v3) throw(Exception); - void setTrigger(const unsigned t) throw(BoundsException); - void setTval1(const unsigned tv1) throw(Exception); - void setTval2(const unsigned n, const unsigned d) throw(Exception); - void setTval2Num(const unsigned n) throw(Exception); - void setTval2Denom(const unsigned d) throw(Exception); - - Frac getChance() const; - unsigned getEffect() const; - unsigned getVal1() const; - unsigned getVal2() const; - int getVal3() const; - unsigned getTrigger() const; - unsigned getTval1() const; - Frac getTval2() const; - - AbilityEffect& operator=(const AbilityEffect& rhs); - private: - bool validate() const; - - Frac chance; - unsigned effect; - unsigned val1; - unsigned val2; - int val3; - unsigned trigger; - unsigned tval1; - Frac tval2; - }; -} + public: + enum Effect + { + E_DamageToHP = 0, + E_PreventDamage = 1, + E_AutoHeal = 2, + E_DealDamage = 3, + E_Wilds = 4, + E_Stats = 5, + E_Status = 6, + E_Ability = 7, + E_AccuracyPowerTrade = 8, + E_Bullseye = 9, + E_ItemEffect = 10, + E_Type = 11, + E_FastHatch = 12, + E_Weather = 13, + E_End = 14 + }; + static const QStringList EffectStr; + + enum Trigger + { + T_Anything = 0, + T_Contact = 1, + T_Weather = 2, + T_Damage = 3, + T_Type = 4, + T_HPBoundary = 5, + T_StatChange = 6, + T_Status = 7, + T_End = 8 + }; + static const QStringList TriggerStr; + + enum Interact + { + I_Trade = 0, + I_Shadow = 1, + I_Block = 2, + I_End = 3 + }; + static const QStringList InteractStr; + + enum PowerAccuracy + { + PA_Power = 0, + PA_Accuracy = 1, + PA_End = 2 + }; + static const QStringList PowerAccStr; + + enum Item + { + IT_Stat = 0, + IT_TypeBoost = 1, + IT_Flinch = 2, + IT_Quick = 3, + IT_End = 4 + }; + static const QStringList ItemStr; + + enum Cause + { + C_Prevent = 0, + C_Inflict = 1, + C_End = 2 + }; + static const QStringList CauseStr; + + enum Boost + { + B_Boost = 0, + B_Hinder = 1, + B_End = 2 + }; + static const QStringList BoostStr; + + enum Side + { + S_Above = 0, + S_Below = 1, + S_End = 2 + }; + static const QStringList SideStr; + + AbilityEffect(const Pokemod& par, const unsigned _id); + AbilityEffect(const Pokemod& par, const AbilityEffect& e, const unsigned _id); + AbilityEffect(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save(const QString& ability) const throw(Exception); + + void setChance(const unsigned n, const unsigned d) throw(Exception); + void setChanceNum(const unsigned n) throw(Exception); + void setChanceDenom(const unsigned d) throw(Exception); + void setEffect(const unsigned e) throw(BoundsException); + void setVal1(const unsigned v1) throw(Exception); + void setVal2(const unsigned v2) throw(Exception); + void setVal3(const int v3) throw(Exception); + void setTrigger(const unsigned t) throw(BoundsException); + void setTval1(const unsigned tv1) throw(Exception); + void setTval2(const unsigned n, const unsigned d) throw(Exception); + void setTval2Num(const unsigned n) throw(Exception); + void setTval2Denom(const unsigned d) throw(Exception); + + Frac getChance() const; + unsigned getEffect() const; + unsigned getVal1() const; + unsigned getVal2() const; + int getVal3() const; + unsigned getTrigger() const; + unsigned getTval1() const; + Frac getTval2() const; + + AbilityEffect& operator=(const AbilityEffect& rhs); + private: + bool validate() const; + + Frac chance; + unsigned effect; + unsigned val1; + unsigned val2; + int val3; + unsigned trigger; + unsigned tval1; + Frac tval2; +}; #endif diff --git a/pokemod/Author.cpp b/pokemod/Author.cpp index e9e84a2c..6352bde5 100644 --- a/pokemod/Author.cpp +++ b/pokemod/Author.cpp @@ -24,7 +24,7 @@ #include "Pokemod.h" #include "Author.h" -PokeMod::Author::Author(const Pokemod& par, const unsigned _id) : +Author::Author(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), email(""), @@ -32,19 +32,19 @@ PokeMod::Author::Author(const Pokemod& par, const unsigned _id) : { } -PokeMod::Author::Author(const Pokemod& par, const Author& a, const unsigned _id) : +Author::Author(const Pokemod& par, const Author& a, const unsigned _id) : Object(par, _id) { *this = a; } -PokeMod::Author::Author(const Pokemod& par, const QString& fname, const unsigned _id) : +Author::Author(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::Author::validate() const +bool Author::validate() const { bool valid = true; pokemod.validationMsg(QString("---Author \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -68,7 +68,7 @@ bool PokeMod::Author::validate() const return valid; } -void PokeMod::Author::load(const QString& fname, const unsigned _id) throw(Exception) +void Author::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -80,7 +80,7 @@ void PokeMod::Author::load(const QString& fname, const unsigned _id) throw(Excep ini.getValue("role", role); } -void PokeMod::Author::save() const throw(Exception) +void Author::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -90,37 +90,37 @@ void PokeMod::Author::save() const throw(Exception) ini.save(QString("%1/author/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeMod::Author::setName(const QString& n) +void Author::setName(const QString& n) { name = n; } -void PokeMod::Author::setEmail(const QString& e) +void Author::setEmail(const QString& e) { email = e; } -void PokeMod::Author::setRole(const QString& r) +void Author::setRole(const QString& r) { role = r; } -QString PokeMod::Author::getName() const +QString Author::getName() const { return name; } -QString PokeMod::Author::getEmail() const +QString Author::getEmail() const { return email; } -QString PokeMod::Author::getRole() const +QString Author::getRole() const { return role; } -PokeMod::Author& PokeMod::Author::operator=(const Author& rhs) +Author& Author::operator=(const Author& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Author.h b/pokemod/Author.h index d8b28421..f29d03d8 100644 --- a/pokemod/Author.h +++ b/pokemod/Author.h @@ -26,36 +26,33 @@ #include <QString> #include "Object.h" -namespace PokeMod +class Pokemod; + +class Author : public Object { - class Pokemod; - - class Author : public Object - { - public: - Author(const Pokemod& par, const unsigned _id); - Author(const Pokemod& par, const Author& a, const unsigned _id); - Author(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - void setEmail(const QString& e); - void setRole(const QString& r); - - QString getName() const; - QString getEmail() const; - QString getRole() const; - - Author& operator=(const Author& rhs); - private: - bool validate() const; - - QString name; - QString email; - QString role; - }; -} + public: + Author(const Pokemod& par, const unsigned _id); + Author(const Pokemod& par, const Author& a, const unsigned _id); + Author(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + void setEmail(const QString& e); + void setRole(const QString& r); + + QString getName() const; + QString getEmail() const; + QString getRole() const; + + Author& operator=(const Author& rhs); + private: + bool validate() const; + + QString name; + QString email; + QString role; +}; #endif diff --git a/pokemod/Badge.cpp b/pokemod/Badge.cpp index 0f780de5..8b41d456 100644 --- a/pokemod/Badge.cpp +++ b/pokemod/Badge.cpp @@ -24,7 +24,7 @@ #include "Pokemod.h" #include "Badge.h" -PokeMod::Badge::Badge(const Pokemod& par, const unsigned _id) : +Badge::Badge(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), obey(0) @@ -35,19 +35,19 @@ PokeMod::Badge::Badge(const Pokemod& par, const unsigned _id) : hm[i] = false; } -PokeMod::Badge::Badge(const Pokemod& par, const Badge& b, const unsigned _id) : +Badge::Badge(const Pokemod& par, const Badge& b, const unsigned _id) : Object(par, _id) { *this = b; } -PokeMod::Badge::Badge(const Pokemod& par, const QString& fname, const unsigned _id) : +Badge::Badge(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::Badge::validate() const +bool Badge::validate() const { bool valid = true; pokemod.validationMsg(QString("---Badge \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -74,7 +74,7 @@ bool PokeMod::Badge::validate() const return valid; } -void PokeMod::Badge::load(const QString& fname, const unsigned _id) throw(Exception) +void Badge::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -95,7 +95,7 @@ void PokeMod::Badge::load(const QString& fname, const unsigned _id) throw(Except ini.getValue(QString("hm-%1").arg(i), hm[i], false); } -void PokeMod::Badge::save() const throw(Exception) +void Badge::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -111,12 +111,12 @@ void PokeMod::Badge::save() const throw(Exception) ini.save(QString("%1/badge/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeMod::Badge::setName(const QString& n) +void Badge::setName(const QString& n) { name = n; } -void PokeMod::Badge::setFace(const QString& f) throw(Exception) +void Badge::setFace(const QString& f) throw(Exception) { QFile file(QString("%1/badge/%2/face.png").arg(pokemod.getPath()).arg(name)); if (file.exists() && !file.remove()) @@ -125,7 +125,7 @@ void PokeMod::Badge::setFace(const QString& f) throw(Exception) throw(SaveException("Badge", file.fileName())); } -void PokeMod::Badge::setBadge(const QString& b) throw(Exception) +void Badge::setBadge(const QString& b) throw(Exception) { QFile file(QString("%1/badge/%2/badge.png").arg(pokemod.getPath()).arg(name)); if (file.exists() && !file.remove()) @@ -134,66 +134,66 @@ void PokeMod::Badge::setBadge(const QString& b) throw(Exception) throw(SaveException("Badge", file.fileName())); } -void PokeMod::Badge::setObey(const unsigned o) throw(BoundsException) +void Badge::setObey(const unsigned o) throw(BoundsException) { if (pokemod.getRules().getMaxLevel() < o) throw(BoundsException("Badge", "obey")); obey = o; } -void PokeMod::Badge::setStat(const unsigned s, const unsigned n, const unsigned d) throw(Exception) +void Badge::setStat(const unsigned s, const unsigned n, const unsigned d) throw(Exception) { if ((pokemod.getRules().getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) throw(BoundsException("Badge", "stat")); stats[s].set(n, d); } -void PokeMod::Badge::setStatNum(const unsigned s, const unsigned n) throw(Exception) +void Badge::setStatNum(const unsigned s, const unsigned n) throw(Exception) { if ((pokemod.getRules().getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) throw(BoundsException("Badge", "stat")); stats[s].setNum(n); } -void PokeMod::Badge::setStatDenom(const unsigned s, const unsigned d) throw(Exception) +void Badge::setStatDenom(const unsigned s, const unsigned d) throw(Exception) { if ((pokemod.getRules().getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) throw(BoundsException("Badge", "stat")); stats[s].setDenom(d); } -void PokeMod::Badge::setHm(const unsigned h, const bool hb) throw(BoundsException) +void Badge::setHm(const unsigned h, const bool hb) throw(BoundsException) { if (HM_End_All <= h) throw(BoundsException("Badge", "hm")); hm[h] = hb; } -QString PokeMod::Badge::getName() const +QString Badge::getName() const { return name; } -unsigned PokeMod::Badge::getObey() const +unsigned Badge::getObey() const { return obey; } -Frac PokeMod::Badge::getStat(const unsigned s) const throw(BoundsException) +Frac Badge::getStat(const unsigned s) const throw(BoundsException) { if ((pokemod.getRules().getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) throw(BoundsException("Badge", "stat")); return stats[s]; } -bool PokeMod::Badge::getHm(const unsigned h) const throw(BoundsException) +bool Badge::getHm(const unsigned h) const throw(BoundsException) { if (HM_End_All <= h) throw(BoundsException("Badge", "hm")); return hm[h]; } -PokeMod::Badge& PokeMod::Badge::operator=(const Badge& rhs) +Badge& Badge::operator=(const Badge& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Badge.h b/pokemod/Badge.h index 36827749..b37f90a3 100644 --- a/pokemod/Badge.h +++ b/pokemod/Badge.h @@ -31,43 +31,40 @@ #include "../general/Ref.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class Badge : public Object { - class Pokemod; - - class Badge : public Object - { - public: - Badge(const Pokemod& par, const unsigned _id); - Badge(const Pokemod& par, const Badge& b, const unsigned _id); - Badge(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - void setFace(const QString& f) throw(Exception); - void setBadge(const QString& b) throw(Exception); - void setObey(const unsigned o) throw(BoundsException); - void setStat(const unsigned s, const unsigned n, const unsigned d) throw(Exception); - void setStatNum(const unsigned s, const unsigned n) throw(Exception); - void setStatDenom(const unsigned s, const unsigned d) throw(Exception); - void setHm(const unsigned h, const bool hb) throw(BoundsException); - - QString getName() const; - unsigned getObey() const; - Frac getStat(const unsigned s) const throw(BoundsException); - bool getHm(const unsigned h) const throw(BoundsException); - - Badge& operator=(const Badge& rhs); - private: - bool validate() const; - - QString name; - unsigned obey; - Frac stats[ST_End_GSC]; - bool hm[HM_End_All]; - }; -} + public: + Badge(const Pokemod& par, const unsigned _id); + Badge(const Pokemod& par, const Badge& b, const unsigned _id); + Badge(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + void setFace(const QString& f) throw(Exception); + void setBadge(const QString& b) throw(Exception); + void setObey(const unsigned o) throw(BoundsException); + void setStat(const unsigned s, const unsigned n, const unsigned d) throw(Exception); + void setStatNum(const unsigned s, const unsigned n) throw(Exception); + void setStatDenom(const unsigned s, const unsigned d) throw(Exception); + void setHm(const unsigned h, const bool hb) throw(BoundsException); + + QString getName() const; + unsigned getObey() const; + Frac getStat(const unsigned s) const throw(BoundsException); + bool getHm(const unsigned h) const throw(BoundsException); + + Badge& operator=(const Badge& rhs); + private: + bool validate() const; + + QString name; + unsigned obey; + Frac stats[ST_End_GSC]; + bool hm[HM_End_All]; +}; #endif diff --git a/pokemod/CoinList.cpp b/pokemod/CoinList.cpp index 78f33ac9..581f0d6e 100644 --- a/pokemod/CoinList.cpp +++ b/pokemod/CoinList.cpp @@ -31,26 +31,26 @@ #include "ItemEffect.h" #include "CoinList.h" -PokeMod::CoinList::CoinList(const Pokemod& par, const unsigned _id) : +CoinList::CoinList(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), value(0) { } -PokeMod::CoinList::CoinList(const Pokemod& par, const CoinList& c, const unsigned _id) : +CoinList::CoinList(const Pokemod& par, const CoinList& c, const unsigned _id) : Object(par, _id) { *this = c; } -PokeMod::CoinList::CoinList(const Pokemod& par, const QString& fname, const unsigned _id) : +CoinList::CoinList(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::CoinList::validate() const +bool CoinList::validate() const { bool valid = true; pokemod.validationMsg(QString("---Coin List \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -121,7 +121,7 @@ bool PokeMod::CoinList::validate() const return valid; } -unsigned PokeMod::CoinList::getNewId() const +unsigned CoinList::getNewId() const { unsigned i = 0; for (; (i < getItemCount()) && (getItemIndex(i) != UINT_MAX); ++i) @@ -129,7 +129,7 @@ unsigned PokeMod::CoinList::getNewId() const return i; } -void PokeMod::CoinList::load(const QString& fname, const unsigned _id) throw(Exception) +void CoinList::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -149,7 +149,7 @@ void PokeMod::CoinList::load(const QString& fname, const unsigned _id) throw(Exc } } -void PokeMod::CoinList::save() const throw(Exception) +void CoinList::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -160,12 +160,12 @@ void PokeMod::CoinList::save() const throw(Exception) i.next().save(name); } -void PokeMod::CoinList::setName(const QString& n) +void CoinList::setName(const QString& n) { name = n; } -void PokeMod::CoinList::setValue(const unsigned v) throw(Exception) +void CoinList::setValue(const unsigned v) throw(Exception) { for (unsigned i = 0; (i < pokemod.getItemCount()); ++i) { @@ -181,41 +181,41 @@ void PokeMod::CoinList::setValue(const unsigned v) throw(Exception) throw(Exception("CoinList", "no compatable coin cases")); } -QString PokeMod::CoinList::getName() const +QString CoinList::getName() const { return name; } -unsigned PokeMod::CoinList::getValue() const +unsigned CoinList::getValue() const { return value; } -const PokeMod::CoinListObject& PokeMod::CoinList::getItem(const unsigned i) const throw(IndexException) +const CoinListObject& CoinList::getItem(const unsigned i) const throw(IndexException) { if (getItemCount() <= i) throw(IndexException("CoinList")); return items.at(i); } -PokeMod::CoinListObject& PokeMod::CoinList::getItem(const unsigned i) throw(IndexException) +CoinListObject& CoinList::getItem(const unsigned i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException("CoinList")); return items[i]; } -const PokeMod::CoinListObject& PokeMod::CoinList::getItemByID(const unsigned i) const throw(IndexException) +const CoinListObject& CoinList::getItemByID(const unsigned i) const throw(IndexException) { return getItem(getItemIndex(i)); } -PokeMod::CoinListObject& PokeMod::CoinList::getItemByID(const unsigned i) throw(IndexException) +CoinListObject& CoinList::getItemByID(const unsigned i) throw(IndexException) { return getItem(getItemIndex(i)); } -unsigned PokeMod::CoinList::getItemIndex(const unsigned _id) const +unsigned CoinList::getItemIndex(const unsigned _id) const { for (unsigned i = 0; i < getItemCount(); ++i) { @@ -225,37 +225,37 @@ unsigned PokeMod::CoinList::getItemIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::CoinList::getItemCount() const +unsigned CoinList::getItemCount() const { return items.size(); } -PokeMod::CoinListObject& PokeMod::CoinList::newItem() +CoinListObject& CoinList::newItem() { items.append(CoinListObject(pokemod, getNewId())); return items[getItemCount() - 1]; } -PokeMod::CoinListObject& PokeMod::CoinList::newItem(const QString& fname) +CoinListObject& CoinList::newItem(const QString& fname) { items.append(CoinListObject(pokemod, fname, getNewId())); return items[getItemCount() - 1]; } -PokeMod::CoinListObject& PokeMod::CoinList::newItem(const CoinListObject& o) +CoinListObject& CoinList::newItem(const CoinListObject& o) { items.append(CoinListObject(pokemod, o, getNewId())); return items[getItemCount() - 1]; } -void PokeMod::CoinList::deleteItem(const unsigned i) throw(IndexException) +void CoinList::deleteItem(const unsigned i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException("CoinList")); items.removeAt(i); } -PokeMod::CoinList& PokeMod::CoinList::operator=(const CoinList& rhs) +CoinList& CoinList::operator=(const CoinList& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/CoinList.h b/pokemod/CoinList.h index 05e29712..fdf29c28 100644 --- a/pokemod/CoinList.h +++ b/pokemod/CoinList.h @@ -30,47 +30,44 @@ #include "Object.h" #include "CoinListObject.h" -namespace PokeMod +class Pokemod; + +class CoinList : public Object { - class Pokemod; - - class CoinList : public Object - { - public: - CoinList(const Pokemod& par, const unsigned _id); - CoinList(const Pokemod& par, const CoinList& c, const unsigned _id); - CoinList(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - void setValue(const unsigned v) throw(Exception); - - QString getName() const; - unsigned getValue() const; - - const CoinListObject& getItem(const unsigned i) const throw(IndexException); - CoinListObject& getItem(const unsigned i) throw(IndexException); - const CoinListObject& getItemByID(const unsigned i) const throw(IndexException); - CoinListObject& getItemByID(const unsigned i) throw(IndexException); - unsigned getItemIndex(const unsigned _id) const; - unsigned getItemCount() const; - CoinListObject& newItem(); - CoinListObject& newItem(const QString& fname); - CoinListObject& newItem(const CoinListObject& c); - void deleteItem(const unsigned i) throw(IndexException); - - CoinList& operator=(const CoinList& rhs); - private: - bool validate() const; - unsigned getNewId() const; - - QString name; - unsigned value; - - QList<CoinListObject> items; - }; -} + public: + CoinList(const Pokemod& par, const unsigned _id); + CoinList(const Pokemod& par, const CoinList& c, const unsigned _id); + CoinList(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + void setValue(const unsigned v) throw(Exception); + + QString getName() const; + unsigned getValue() const; + + const CoinListObject& getItem(const unsigned i) const throw(IndexException); + CoinListObject& getItem(const unsigned i) throw(IndexException); + const CoinListObject& getItemByID(const unsigned i) const throw(IndexException); + CoinListObject& getItemByID(const unsigned i) throw(IndexException); + unsigned getItemIndex(const unsigned _id) const; + unsigned getItemCount() const; + CoinListObject& newItem(); + CoinListObject& newItem(const QString& fname); + CoinListObject& newItem(const CoinListObject& c); + void deleteItem(const unsigned i) throw(IndexException); + + CoinList& operator=(const CoinList& rhs); + private: + bool validate() const; + unsigned getNewId() const; + + QString name; + unsigned value; + + QList<CoinListObject> items; +}; #endif diff --git a/pokemod/CoinListObject.cpp b/pokemod/CoinListObject.cpp index b6dae50f..fcc4579a 100644 --- a/pokemod/CoinListObject.cpp +++ b/pokemod/CoinListObject.cpp @@ -23,9 +23,9 @@ #include "Pokemod.h" #include "CoinListObject.h" -const QStringList PokeMod::CoinListObject::TypeStr = QStringList() << "Item" << "Pokémon"; +const QStringList CoinListObject::TypeStr = QStringList() << "Item" << "Pokémon"; -PokeMod::CoinListObject::CoinListObject(const Pokemod& par, const unsigned _id) : +CoinListObject::CoinListObject(const Pokemod& par, const unsigned _id) : Object(par, _id), type(Item), object(UINT_MAX), @@ -34,19 +34,19 @@ PokeMod::CoinListObject::CoinListObject(const Pokemod& par, const unsigned _id) { } -PokeMod::CoinListObject::CoinListObject(const Pokemod& par, const CoinListObject& o, const unsigned _id) : +CoinListObject::CoinListObject(const Pokemod& par, const CoinListObject& o, const unsigned _id) : Object(par, _id) { *this = o; } -PokeMod::CoinListObject::CoinListObject(const Pokemod& par, const QString& fname, const unsigned _id) : +CoinListObject::CoinListObject(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::CoinListObject::validate() const +bool CoinListObject::validate() const { bool valid = true; pokemod.validationMsg(QString("------Object with id %1---").arg(id), Pokemod::V_Msg); @@ -79,7 +79,7 @@ bool PokeMod::CoinListObject::validate() const return valid; } -void PokeMod::CoinListObject::load(const QString& fname, const unsigned _id) throw(Exception) +void CoinListObject::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -92,7 +92,7 @@ void PokeMod::CoinListObject::load(const QString& fname, const unsigned _id) thr ini.getValue("cost", cost, 0); } -void PokeMod::CoinListObject::save(const QString& coinList) const throw(Exception) +void CoinListObject::save(const QString& coinList) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -103,7 +103,7 @@ void PokeMod::CoinListObject::save(const QString& coinList) const throw(Exceptio ini.save(QString("%1/coinlist/%2/item/%3.pini").arg(pokemod.getPath()).arg(coinList).arg(id)); } -void PokeMod::CoinListObject::setType(const unsigned t) throw(BoundsException) +void CoinListObject::setType(const unsigned t) throw(BoundsException) { if (End <= t) throw(BoundsException("CoinListObject", "type")); @@ -111,46 +111,46 @@ void PokeMod::CoinListObject::setType(const unsigned t) throw(BoundsException) object = UINT_MAX; } -void PokeMod::CoinListObject::setObject(const unsigned o) throw(BoundsException) +void CoinListObject::setObject(const unsigned o) throw(BoundsException) { if (((type == Item) && (pokemod.getItemIndex(object) == UINT_MAX)) || ((type == Pokemon) && (pokemod.getSpeciesIndex(object) == UINT_MAX))) throw(BoundsException("CoinListObject", "object")); object = o; } -void PokeMod::CoinListObject::setAmount(const unsigned a) throw(BoundsException) +void CoinListObject::setAmount(const unsigned a) throw(BoundsException) { if (!a) throw(BoundsException("CoinListObject", "amount")); amount = a; } -void PokeMod::CoinListObject::setCost(const unsigned c) +void CoinListObject::setCost(const unsigned c) { cost = c; } -unsigned PokeMod::CoinListObject::getType() const +unsigned CoinListObject::getType() const { return type; } -unsigned PokeMod::CoinListObject::getObject() const +unsigned CoinListObject::getObject() const { return object; } -unsigned PokeMod::CoinListObject::getAmount() const +unsigned CoinListObject::getAmount() const { return amount; } -unsigned PokeMod::CoinListObject::getCost() const +unsigned CoinListObject::getCost() const { return cost; } -PokeMod::CoinListObject& PokeMod::CoinListObject::operator=(const CoinListObject& rhs) +CoinListObject& CoinListObject::operator=(const CoinListObject& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/CoinListObject.h b/pokemod/CoinListObject.h index 3cb69609..d3bc1240 100644 --- a/pokemod/CoinListObject.h +++ b/pokemod/CoinListObject.h @@ -28,47 +28,44 @@ #include "../general/Exception.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class CoinListObject : public Object { - class Pokemod; - - class CoinListObject : public Object - { - public: - enum - { - Item = 0, - Pokemon = 1, - End = 2 - }; - static const QStringList TypeStr; - - CoinListObject(const Pokemod& par, const unsigned _id); - CoinListObject(const Pokemod& par, const CoinListObject& o, const unsigned _id = UINT_MAX); - CoinListObject(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save(const QString& coinList) const throw(Exception); - - void setType(const unsigned t) throw(BoundsException); - void setObject(const unsigned o) throw(BoundsException); - void setAmount(const unsigned a) throw(BoundsException); - void setCost(const unsigned c); - - unsigned getType() const; - unsigned getObject() const; - unsigned getAmount() const; - unsigned getCost() const; - - CoinListObject& operator=(const CoinListObject& o); - private: - bool validate() const; - - unsigned type; - unsigned object; - unsigned amount; - unsigned cost; - }; -} + public: + enum + { + Item = 0, + Pokemon = 1, + End = 2 + }; + static const QStringList TypeStr; + + CoinListObject(const Pokemod& par, const unsigned _id); + CoinListObject(const Pokemod& par, const CoinListObject& o, const unsigned _id = UINT_MAX); + CoinListObject(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save(const QString& coinList) const throw(Exception); + + void setType(const unsigned t) throw(BoundsException); + void setObject(const unsigned o) throw(BoundsException); + void setAmount(const unsigned a) throw(BoundsException); + void setCost(const unsigned c); + + unsigned getType() const; + unsigned getObject() const; + unsigned getAmount() const; + unsigned getCost() const; + + CoinListObject& operator=(const CoinListObject& o); + private: + bool validate() const; + + unsigned type; + unsigned object; + unsigned amount; + unsigned cost; +}; #endif diff --git a/pokemod/Dialog.cpp b/pokemod/Dialog.cpp index 5ea0e44d..829a53f7 100644 --- a/pokemod/Dialog.cpp +++ b/pokemod/Dialog.cpp @@ -31,29 +31,29 @@ #include "Species.h" #include "Dialog.h" -const QStringList PokeMod::Dialog::CommandStr = QStringList() << "Flip Flag" << "Set Flag" << "Unset Flag" << "Randomize Flag" << "Test Flag" << "Dialog" << "Yes/No" << "Item Shop" << "Give Item" << "Take Item" << "Check Item" << "Coin List" << "Teach Move" << "Delete Move" << "Give Pokemon" << "Take Pokemon" << "Show Pokemon" << "View Pokemon" << "Give Money" << "Take Money" << "Move Effect" << "Turn Effect" << "Check Direction" << "Check Roster" << "Check Levels" << "Check Species" << "Check Held Items" << "Check Money" << "Trade" << "Daycare" << "Battle" << "Badge" << "Warp" << "Name" << "Music" << "Sound Effect" << "Timer" << "Map Sign" << "Wild Scope" << "Safari" << "Heal Party" << "Refresh" << "Clear" << "Pause" << "New Line" << "Exit" << "Menu"; -const QStringList PokeMod::Dialog::CommandAbbrStr = QStringList() << "FF" << "SF" << "UF" << "RF" << "TF" << "D" << "YN" << "ItS" << "GIt" << "TIt" << "CIt" << "CL" << "TMv" << "DMv" << "GPk" << "TPk" << "SPk" << "VPk" << "G$" << "T$" << "MvEf" << "TEf" << "CD" << "CR" << "CLv" << "CS" << "CHIt" << "C$" << "T" << "Dc" << "Bat" << "Bdg" << "W" << "N" << "Ms" << "SFX" << "Tmr" << "MS" << "WS" << "S" << "HP" << "R" << "C" << "P" << "NL" << "X" << "M"; -const QList<unsigned> PokeMod::Dialog::CommandNumArgs = QList<unsigned>() << 1 << 1 << 1 << 1 << 3 << 2 << 2 << 1 << 4 << 4 << 4 << 1 << 5 << 3 << 7 << 4 << 1 << 4 << 1 << 4 << 6 << 3 << 6 << 5 << 5 << 4 << 4 << 5 << 6 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 3 << 1 << 1 << 3 << 0 << 0 << 0 << 0 << 0 << 0; +const QStringList Dialog::CommandStr = QStringList() << "Flip Flag" << "Set Flag" << "Unset Flag" << "Randomize Flag" << "Test Flag" << "Dialog" << "Yes/No" << "Item Shop" << "Give Item" << "Take Item" << "Check Item" << "Coin List" << "Teach Move" << "Delete Move" << "Give Pokemon" << "Take Pokemon" << "Show Pokemon" << "View Pokemon" << "Give Money" << "Take Money" << "Move Effect" << "Turn Effect" << "Check Direction" << "Check Roster" << "Check Levels" << "Check Species" << "Check Held Items" << "Check Money" << "Trade" << "Daycare" << "Battle" << "Badge" << "Warp" << "Name" << "Music" << "Sound Effect" << "Timer" << "Map Sign" << "Wild Scope" << "Safari" << "Heal Party" << "Refresh" << "Clear" << "Pause" << "New Line" << "Exit" << "Menu"; +const QStringList Dialog::CommandAbbrStr = QStringList() << "FF" << "SF" << "UF" << "RF" << "TF" << "D" << "YN" << "ItS" << "GIt" << "TIt" << "CIt" << "CL" << "TMv" << "DMv" << "GPk" << "TPk" << "SPk" << "VPk" << "G$" << "T$" << "MvEf" << "TEf" << "CD" << "CR" << "CLv" << "CS" << "CHIt" << "C$" << "T" << "Dc" << "Bat" << "Bdg" << "W" << "N" << "Ms" << "SFX" << "Tmr" << "MS" << "WS" << "S" << "HP" << "R" << "C" << "P" << "NL" << "X" << "M"; +const QList<unsigned> Dialog::CommandNumArgs = QList<unsigned>() << 1 << 1 << 1 << 1 << 3 << 2 << 2 << 1 << 4 << 4 << 4 << 1 << 5 << 3 << 7 << 4 << 1 << 4 << 1 << 4 << 6 << 3 << 6 << 5 << 5 << 4 << 4 << 5 << 6 << 1 << 2 << 1 << 2 << 1 << 2 << 1 << 3 << 1 << 1 << 3 << 0 << 0 << 0 << 0 << 0 << 0; -PokeMod::Dialog::Dialog(const Pokemod& par, const unsigned _id) : +Dialog::Dialog(const Pokemod& par, const unsigned _id) : Object(par, _id), dialog("") { } -PokeMod::Dialog::Dialog(const Pokemod& par, const Dialog& d, const unsigned _id) : +Dialog::Dialog(const Pokemod& par, const Dialog& d, const unsigned _id) : Object(par, _id) { *this = d; } -PokeMod::Dialog::Dialog(const Pokemod& par, const QString& fname, const unsigned _id) : +Dialog::Dialog(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::Dialog::validate() const +bool Dialog::validate() const { bool valid = true; pokemod.validationMsg(QString("---Dialog with id %1---").arg(id), Pokemod::V_Msg); @@ -120,7 +120,7 @@ bool PokeMod::Dialog::validate() const unsigned tempU = arg.toUInt(&okU); unsigned long tempUL = arg.toULong(&okUL); unsigned invError = 0; - const Map* map = NULL; + const Map* map; ++numArgs; switch (curCmd) { @@ -376,7 +376,7 @@ bool PokeMod::Dialog::validate() const if (!okU || (pokemod.getMapIndex(tempU) == UINT_MAX)) invError = 2; else - map = &pokemod.getMap(pokemod.getMapIndex(tempU)); + map = &pokemod.getMapByID(tempU); break; case 3: if (map) @@ -405,7 +405,7 @@ bool PokeMod::Dialog::validate() const if (!okU || (pokemod.getMapIndex(tempU) == UINT_MAX)) invError = 1; else - map = &pokemod.getMap(pokemod.getMapIndex(tempU)); + map = &pokemod.getMapByID(tempU); break; case 2: if (map) @@ -504,7 +504,7 @@ bool PokeMod::Dialog::validate() const if (!okU || (pokemod.getMapIndex(tempU) == UINT_MAX)) invError = 1; else - map = &pokemod.getMap(pokemod.getMapIndex(tempU)); + map = &pokemod.getMapByID(tempU); } else if (numArgs == 2) { @@ -531,7 +531,7 @@ bool PokeMod::Dialog::validate() const if (!okU || (pokemod.getMapIndex(tempU) == UINT_MAX)) invError = 1; else - map = &pokemod.getMap(pokemod.getMapIndex(tempU)); + map = &pokemod.getMapByID(tempU); } else if (numArgs == 2) { @@ -602,7 +602,7 @@ bool PokeMod::Dialog::validate() const case 1: if (okU && (pokemod.getItemIndex(tempU) != UINT_MAX)) { - const Item& item = pokemod.getItem(pokemod.getItemIndex(tempU)); + const Item& item = pokemod.getItemByID(tempU); bool temp = false; for (unsigned i = 0; (i < item.getEffectCount()) || !temp; ++i) { @@ -661,7 +661,7 @@ bool PokeMod::Dialog::validate() const return valid; } -void PokeMod::Dialog::load(const QString& fname, const unsigned _id) throw(Exception) +void Dialog::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -671,7 +671,7 @@ void PokeMod::Dialog::load(const QString& fname, const unsigned _id) throw(Excep ini.getValue("dialog", dialog); } -void PokeMod::Dialog::save() const throw(Exception) +void Dialog::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -679,24 +679,24 @@ void PokeMod::Dialog::save() const throw(Exception) ini.save(QString("%1/dialog/%2.pini").arg(pokemod.getPath()).arg(id)); } -void PokeMod::Dialog::setDialog(const QString& d) +void Dialog::setDialog(const QString& d) { dialog = d; } -QString PokeMod::Dialog::getDialog() const +QString Dialog::getDialog() const { return dialog; } -void PokeMod::Dialog::insertDialogCommand(const QString& cmd, const long pos) throw(BoundsException) +void Dialog::insertDialogCommand(const QString& cmd, const long pos) throw(BoundsException) { if (dialog.length() < pos) throw(BoundsException("Dialog" , "command")); dialog.insert(pos, cmd); } -PokeMod::Dialog& PokeMod::Dialog::operator=(const Dialog& rhs) +Dialog& Dialog::operator=(const Dialog& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Dialog.h b/pokemod/Dialog.h index a2cfb0a6..4efc88f5 100644 --- a/pokemod/Dialog.h +++ b/pokemod/Dialog.h @@ -29,88 +29,85 @@ #include "../general/Exception.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class Dialog : public Object { - class Pokemod; - - class Dialog : public Object - { - public: - enum - { - FlipFlag = 0, - SetFlag = 1, - UnsetFlag = 2, - RandomizeFlag = 3, - TestFlag = 4, - DialogC = 5, - YesNo = 6, - ItemShop = 7, - GiveItem = 8, - TakeItem = 9, - CheckItem = 10, - CoinList = 11, - TeachMove = 12, - CheckMove = 13, - DeleteMove = 14, - GivePokemon = 15, - TakePokemon = 16, - ShowPokemon = 17, - ViewPokemon = 18, - GiveMoney = 19, - TakeMoney = 20, - MoveEffect = 21, - TurnEffect = 22, - CheckDirection = 23, - CheckRoster = 24, - CheckLevels = 25, - CheckSpecies = 26, - CheckHeldItems = 27, - CheckMoney = 28, - Trade = 29, - Daycare = 30, - Battle = 31, - Badge = 32, - Warp = 33, - Name = 34, - Music = 35, - SoundEffect = 36, - Timer = 37, - MapSign = 38, - WildScope = 39, - Safari = 40, - HealParty = 41, - Refresh = 42, - Clear = 43, - Pause = 44, - NewLine = 45, - Exit = 46, - Menu = 47, - End = 48 - }; - static const QStringList CommandStr; - static const QStringList CommandAbbrStr; - static const QList<unsigned> CommandNumArgs; - - Dialog(const Pokemod& par, const unsigned _id); - Dialog(const Pokemod& par, const Dialog& d, const unsigned _id); - Dialog(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setDialog(const QString& d); - - QString getDialog() const; - - void insertDialogCommand(const QString& cmd, const long pos) throw(BoundsException); - - Dialog& operator=(const Dialog& rhs); - private: - bool validate() const; - - QString dialog; - }; -} + public: + enum + { + FlipFlag = 0, + SetFlag = 1, + UnsetFlag = 2, + RandomizeFlag = 3, + TestFlag = 4, + DialogC = 5, + YesNo = 6, + ItemShop = 7, + GiveItem = 8, + TakeItem = 9, + CheckItem = 10, + CoinList = 11, + TeachMove = 12, + CheckMove = 13, + DeleteMove = 14, + GivePokemon = 15, + TakePokemon = 16, + ShowPokemon = 17, + ViewPokemon = 18, + GiveMoney = 19, + TakeMoney = 20, + MoveEffect = 21, + TurnEffect = 22, + CheckDirection = 23, + CheckRoster = 24, + CheckLevels = 25, + CheckSpecies = 26, + CheckHeldItems = 27, + CheckMoney = 28, + Trade = 29, + Daycare = 30, + Battle = 31, + Badge = 32, + Warp = 33, + Name = 34, + Music = 35, + SoundEffect = 36, + Timer = 37, + MapSign = 38, + WildScope = 39, + Safari = 40, + HealParty = 41, + Refresh = 42, + Clear = 43, + Pause = 44, + NewLine = 45, + Exit = 46, + Menu = 47, + End = 48 + }; + static const QStringList CommandStr; + static const QStringList CommandAbbrStr; + static const QList<unsigned> CommandNumArgs; + + Dialog(const Pokemod& par, const unsigned _id); + Dialog(const Pokemod& par, const Dialog& d, const unsigned _id); + Dialog(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setDialog(const QString& d); + + QString getDialog() const; + + void insertDialogCommand(const QString& cmd, const long pos) throw(BoundsException); + + Dialog& operator=(const Dialog& rhs); + private: + bool validate() const; + + QString dialog; +}; #endif diff --git a/pokemod/EggGroup.cpp b/pokemod/EggGroup.cpp index 86032eec..90d10b14 100644 --- a/pokemod/EggGroup.cpp +++ b/pokemod/EggGroup.cpp @@ -23,25 +23,25 @@ #include "Pokemod.h" #include "EggGroup.h" -PokeMod::EggGroup::EggGroup(const Pokemod& par, const unsigned _id) : +EggGroup::EggGroup(const Pokemod& par, const unsigned _id) : Object(par, _id), name("") { } -PokeMod::EggGroup::EggGroup(const Pokemod& par, const EggGroup& e, const unsigned _id) : +EggGroup::EggGroup(const Pokemod& par, const EggGroup& e, const unsigned _id) : Object(par, _id) { *this = e; } -PokeMod::EggGroup::EggGroup(const Pokemod& par, const QString& fname, const unsigned _id) : +EggGroup::EggGroup(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::EggGroup::validate() const +bool EggGroup::validate() const { bool valid = true; pokemod.validationMsg(QString("---Egg Group \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -53,7 +53,7 @@ bool PokeMod::EggGroup::validate() const return valid; } -void PokeMod::EggGroup::load(const QString& fname, const unsigned _id) throw(Exception) +void EggGroup::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -63,7 +63,7 @@ void PokeMod::EggGroup::load(const QString& fname, const unsigned _id) throw(Exc ini.getValue("name", name); } -void PokeMod::EggGroup::save() const throw(Exception) +void EggGroup::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -71,17 +71,17 @@ void PokeMod::EggGroup::save() const throw(Exception) ini.save(QString("%1/egggroup/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeMod::EggGroup::setName(const QString& n) +void EggGroup::setName(const QString& n) { name = n; } -QString PokeMod::EggGroup::getName() const +QString EggGroup::getName() const { return name; } -PokeMod::EggGroup& PokeMod::EggGroup::operator=(const EggGroup& rhs) +EggGroup& EggGroup::operator=(const EggGroup& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/EggGroup.h b/pokemod/EggGroup.h index 7908174f..3bcb7e54 100644 --- a/pokemod/EggGroup.h +++ b/pokemod/EggGroup.h @@ -27,30 +27,27 @@ #include "../general/Exception.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class EggGroup : public Object { - class Pokemod; - - class EggGroup : public Object - { - public: - EggGroup(const Pokemod& par, const unsigned _id); - EggGroup(const Pokemod& par, const EggGroup& e, const unsigned _id); - EggGroup(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - - QString getName() const; - - EggGroup& operator=(const EggGroup& rhs); - private: - bool validate() const; - - QString name; - }; -} + public: + EggGroup(const Pokemod& par, const unsigned _id); + EggGroup(const Pokemod& par, const EggGroup& e, const unsigned _id); + EggGroup(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + + QString getName() const; + + EggGroup& operator=(const EggGroup& rhs); + private: + bool validate() const; + + QString name; +}; #endif diff --git a/pokemod/Item.cpp b/pokemod/Item.cpp index f6658329..43e7066b 100644 --- a/pokemod/Item.cpp +++ b/pokemod/Item.cpp @@ -29,7 +29,7 @@ #include "Pokemod.h" #include "Item.h" -PokeMod::Item::Item(const Pokemod& par, const unsigned _id) : +Item::Item(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), sellable(false), @@ -39,19 +39,19 @@ PokeMod::Item::Item(const Pokemod& par, const unsigned _id) : { } -PokeMod::Item::Item(const Pokemod& par, const Item& i, const unsigned _id) : +Item::Item(const Pokemod& par, const Item& i, const unsigned _id) : Object(par, _id) { *this = i; } -PokeMod::Item::Item(const Pokemod& par, const QString& fname, const unsigned _id) : +Item::Item(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::Item::validate() const +bool Item::validate() const { bool valid = true; pokemod.validationMsg(QString("---Item \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -91,7 +91,7 @@ bool PokeMod::Item::validate() const return valid; } -unsigned PokeMod::Item::getNewId() const +unsigned Item::getNewId() const { unsigned i = 0; for (; (i < getEffectCount()) && (getEffectIndex(i) != UINT_MAX); ++i) @@ -99,7 +99,7 @@ unsigned PokeMod::Item::getNewId() const return i; } -void PokeMod::Item::load(const QString& fname, const unsigned _id) throw(Exception) +void Item::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -122,7 +122,7 @@ void PokeMod::Item::load(const QString& fname, const unsigned _id) throw(Excepti } } -void PokeMod::Item::save() const throw(Exception) +void Item::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -136,83 +136,83 @@ void PokeMod::Item::save() const throw(Exception) i.next().save(name); } -void PokeMod::Item::setName(const QString& n) +void Item::setName(const QString& n) { name = n; } -void PokeMod::Item::setSellable(const bool s) +void Item::setSellable(const bool s) { sellable = s; } -void PokeMod::Item::setType(const unsigned t) throw(BoundsException) +void Item::setType(const unsigned t) throw(BoundsException) { if (pokemod.getItemTypeIndex(t) == UINT_MAX) throw(BoundsException("Item", "type")); type = t; } -void PokeMod::Item::setPrice(const unsigned p) +void Item::setPrice(const unsigned p) { price = p; } -void PokeMod::Item::setDescription(const QString& d) +void Item::setDescription(const QString& d) { description = d; } -QString PokeMod::Item::getName() const +QString Item::getName() const { return name; } -bool PokeMod::Item::getSellable() const +bool Item::getSellable() const { return sellable; } -unsigned PokeMod::Item::getType() const +unsigned Item::getType() const { return type; } -unsigned PokeMod::Item::getPrice() const +unsigned Item::getPrice() const { return price; } -QString PokeMod::Item::getDescription() const +QString Item::getDescription() const { return description; } -const PokeMod::ItemEffect& PokeMod::Item::getEffect(const unsigned i) const throw(IndexException) +const ItemEffect& Item::getEffect(const unsigned i) const throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Item")); return effects.at(i); } -PokeMod::ItemEffect& PokeMod::Item::getEffectByID(const unsigned i) throw(IndexException) +ItemEffect& Item::getEffectByID(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Item")); return effects[i]; } -const PokeMod::ItemEffect& PokeMod::Item::getEffectByID(const unsigned i) const throw(IndexException) +const ItemEffect& Item::getEffectByID(const unsigned i) const throw(IndexException) { return getEffect(getEffectIndex(i)); } -PokeMod::ItemEffect& PokeMod::Item::getEffect(const unsigned i) throw(IndexException) +ItemEffect& Item::getEffect(const unsigned i) throw(IndexException) { return getEffect(getEffectIndex(i)); } -unsigned PokeMod::Item::getEffectIndex(const unsigned _id) const +unsigned Item::getEffectIndex(const unsigned _id) const { for (unsigned i = 0; i < getEffectCount(); ++i) { @@ -222,37 +222,37 @@ unsigned PokeMod::Item::getEffectIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Item::getEffectCount() const +unsigned Item::getEffectCount() const { return effects.size(); } -PokeMod::ItemEffect& PokeMod::Item::newEffect() +ItemEffect& Item::newEffect() { effects.append(ItemEffect(pokemod, getNewId())); return effects[getEffectCount() - 1]; } -PokeMod::ItemEffect& PokeMod::Item::newEffect(const QString& fname) +ItemEffect& Item::newEffect(const QString& fname) { effects.append(ItemEffect(pokemod, fname, getNewId())); return effects[getEffectCount() - 1]; } -PokeMod::ItemEffect& PokeMod::Item::newEffect(const ItemEffect& e) +ItemEffect& Item::newEffect(const ItemEffect& e) { effects.append(ItemEffect(pokemod, e, getNewId())); return effects[getEffectCount() - 1]; } -void PokeMod::Item::deleteEffect(const unsigned i) throw(IndexException) +void Item::deleteEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Item")); effects.removeAt(i); } -PokeMod::Item& PokeMod::Item::operator=(const Item& rhs) +Item& Item::operator=(const Item& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Item.h b/pokemod/Item.h index e8499105..db146f92 100644 --- a/pokemod/Item.h +++ b/pokemod/Item.h @@ -29,56 +29,53 @@ #include "Object.h" #include "ItemEffect.h" -namespace PokeMod +class Pokemod; + +class Item : public Object { - class Pokemod; - - class Item : public Object - { - public: - Item(const Pokemod& par, const unsigned _id); - Item(const Pokemod& par, const Item& i, const unsigned _id); - Item(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - void setSellable(const bool s); - void setType(const unsigned t) throw(BoundsException); - void setPrice(const unsigned p); - void setDescription(const QString& d); - - QString getName() const; - bool getSellable() const; - unsigned getType() const; - unsigned getPrice() const; - QString getDescription() const; - - const ItemEffect& getEffect(const unsigned i) const throw(IndexException); - ItemEffect& getEffect(const unsigned i) throw(IndexException); - const ItemEffect& getEffectByID(const unsigned i) const throw(IndexException); - ItemEffect& getEffectByID(const unsigned i) throw(IndexException); - unsigned getEffectIndex(const unsigned _id) const; - unsigned getEffectCount() const; - ItemEffect& newEffect(); - ItemEffect& newEffect(const QString& fname); - ItemEffect& newEffect(const ItemEffect& e); - void deleteEffect(const unsigned i) throw(IndexException); - - Item& operator=(const Item& rhs); - private: - bool validate() const; - unsigned getNewId() const; - - QString name; - bool sellable; - unsigned type; - unsigned price; - QString description; - - QList<ItemEffect> effects; - }; -} + public: + Item(const Pokemod& par, const unsigned _id); + Item(const Pokemod& par, const Item& i, const unsigned _id); + Item(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + void setSellable(const bool s); + void setType(const unsigned t) throw(BoundsException); + void setPrice(const unsigned p); + void setDescription(const QString& d); + + QString getName() const; + bool getSellable() const; + unsigned getType() const; + unsigned getPrice() const; + QString getDescription() const; + + const ItemEffect& getEffect(const unsigned i) const throw(IndexException); + ItemEffect& getEffect(const unsigned i) throw(IndexException); + const ItemEffect& getEffectByID(const unsigned i) const throw(IndexException); + ItemEffect& getEffectByID(const unsigned i) throw(IndexException); + unsigned getEffectIndex(const unsigned _id) const; + unsigned getEffectCount() const; + ItemEffect& newEffect(); + ItemEffect& newEffect(const QString& fname); + ItemEffect& newEffect(const ItemEffect& e); + void deleteEffect(const unsigned i) throw(IndexException); + + Item& operator=(const Item& rhs); + private: + bool validate() const; + unsigned getNewId() const; + + QString name; + bool sellable; + unsigned type; + unsigned price; + QString description; + + QList<ItemEffect> effects; +}; #endif diff --git a/pokemod/ItemEffect.cpp b/pokemod/ItemEffect.cpp index 8c8a04f5..47ff017f 100644 --- a/pokemod/ItemEffect.cpp +++ b/pokemod/ItemEffect.cpp @@ -25,16 +25,16 @@ #include "MapWildList.h" #include "ItemEffect.h" -const QStringList PokeMod::ItemEffect::EffectStr = QStringList() << "HP Cure" << "Revive" << "Cure Status" << "Level Boost" << "Stat Boost" << "Flinch" << "Go First" << "Keep Alive" << "Modify Stat (Battle Only)" << "Shield (Battle Only)" << "Run (Battle Only)" << "PP Boost" << "Type Boost" << "PP Restore" << "Experience Share" << "Fishing Rod" << "Repel" << "Escape" << "TM" << "HM" << "Map" << "Ball" << "Itemfinder" << "Bike" << "Scope" << "Coin" << "Coin Case" << "Berry" << "Acorn"; -const QStringList PokeMod::ItemEffect::RelativeStr = QStringList() << "Absolute" << "Relative"; -const QStringList PokeMod::ItemEffect::EscapeStr = QStringList() << "Anywhere" << "Dungeon"; -const QStringList PokeMod::ItemEffect::RepelStr = QStringList() << "First" << "Max" << "All"; -const QStringList PokeMod::ItemEffect::AmountStr = QStringList() << "All" << "One"; -const QStringList PokeMod::ItemEffect::SpecialPhysicalStr = QStringList() << "Special" << "Physical"; -const QStringList PokeMod::ItemEffect::BallTypeStr = QStringList() << "Regular" << "Master" << "Level" << "Love" << "Area" << "Time" << "Battle" << "Friend" << "Stat" << "Type" << "Weight"; -const QStringList PokeMod::ItemEffect::BerryTypeStr = QStringList() << "HP Cure" << "Status Cure"; +const QStringList ItemEffect::EffectStr = QStringList() << "HP Cure" << "Revive" << "Cure Status" << "Level Boost" << "Stat Boost" << "Flinch" << "Go First" << "Keep Alive" << "Modify Stat (Battle Only)" << "Shield (Battle Only)" << "Run (Battle Only)" << "PP Boost" << "Type Boost" << "PP Restore" << "Experience Share" << "Fishing Rod" << "Repel" << "Escape" << "TM" << "HM" << "Map" << "Ball" << "Itemfinder" << "Bike" << "Scope" << "Coin" << "Coin Case" << "Berry" << "Acorn"; +const QStringList ItemEffect::RelativeStr = QStringList() << "Absolute" << "Relative"; +const QStringList ItemEffect::EscapeStr = QStringList() << "Anywhere" << "Dungeon"; +const QStringList ItemEffect::RepelStr = QStringList() << "First" << "Max" << "All"; +const QStringList ItemEffect::AmountStr = QStringList() << "All" << "One"; +const QStringList ItemEffect::SpecialPhysicalStr = QStringList() << "Special" << "Physical"; +const QStringList ItemEffect::BallTypeStr = QStringList() << "Regular" << "Master" << "Level" << "Love" << "Area" << "Time" << "Battle" << "Friend" << "Stat" << "Type" << "Weight"; +const QStringList ItemEffect::BerryTypeStr = QStringList() << "HP Cure" << "Status Cure"; -PokeMod::ItemEffect::ItemEffect(const Pokemod& par, const unsigned _id) : +ItemEffect::ItemEffect(const Pokemod& par, const unsigned _id) : Object(par, _id), overworld(false), battle(false), @@ -47,19 +47,19 @@ PokeMod::ItemEffect::ItemEffect(const Pokemod& par, const unsigned _id) : { } -PokeMod::ItemEffect::ItemEffect(const Pokemod& par, const ItemEffect& e, const unsigned _id) : +ItemEffect::ItemEffect(const Pokemod& par, const ItemEffect& e, const unsigned _id) : Object(par, _id) { *this = e; } -PokeMod::ItemEffect::ItemEffect(const Pokemod& par, const QString& fname, const unsigned _id) : +ItemEffect::ItemEffect(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::ItemEffect::validate() const +bool ItemEffect::validate() const { bool valid = true; pokemod.validationMsg(QString("------Effect with id %1---").arg(id), Pokemod::V_Msg); @@ -298,7 +298,7 @@ bool PokeMod::ItemEffect::validate() const return valid; } -void PokeMod::ItemEffect::load(const QString& fname, const unsigned _id) throw(Exception) +void ItemEffect::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -319,7 +319,7 @@ void PokeMod::ItemEffect::load(const QString& fname, const unsigned _id) throw(E val4.set(i, j); } -void PokeMod::ItemEffect::save(const QString& item) const throw(Exception) +void ItemEffect::save(const QString& item) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -335,7 +335,7 @@ void PokeMod::ItemEffect::save(const QString& item) const throw(Exception) ini.save(QString("%1/item/%2/effect/%3.pini").arg(pokemod.getPath()).arg(item).arg(id)); } -void PokeMod::ItemEffect::setOverworld(const bool o) throw(Exception) +void ItemEffect::setOverworld(const bool o) throw(Exception) { switch (effect) { @@ -376,17 +376,17 @@ void PokeMod::ItemEffect::setOverworld(const bool o) throw(Exception) overworld = o; } -void PokeMod::ItemEffect::setBattle(const bool b) +void ItemEffect::setBattle(const bool b) { battle = b; } -void PokeMod::ItemEffect::setHeld(const bool h) +void ItemEffect::setHeld(const bool h) { held = h; } -void PokeMod::ItemEffect::setEffect(const unsigned e) throw(Exception) +void ItemEffect::setEffect(const unsigned e) throw(Exception) { if (E_End <= e) throw(BoundsException("ItemEffect", "effect out-of-bounds")); @@ -433,7 +433,7 @@ void PokeMod::ItemEffect::setEffect(const unsigned e) throw(Exception) val4.set(1, 1, ((e == E_TypeBoost) || (e == E_PPBoost)) ? Frac::Over1 : Frac::Proper); } -void PokeMod::ItemEffect::setVal1(const int v1) throw(Exception) +void ItemEffect::setVal1(const int v1) throw(Exception) { switch (effect) { @@ -494,7 +494,7 @@ void PokeMod::ItemEffect::setVal1(const int v1) throw(Exception) val1 = v1; } -void PokeMod::ItemEffect::setVal2(const unsigned v2) throw(Exception) +void ItemEffect::setVal2(const unsigned v2) throw(Exception) { switch (effect) { @@ -566,7 +566,7 @@ void PokeMod::ItemEffect::setVal2(const unsigned v2) throw(Exception) val2 = v2; } -void PokeMod::ItemEffect::setVal3(const unsigned v3) throw(Exception) +void ItemEffect::setVal3(const unsigned v3) throw(Exception) { switch (effect) { @@ -628,7 +628,7 @@ void PokeMod::ItemEffect::setVal3(const unsigned v3) throw(Exception) val3 = v3; } -void PokeMod::ItemEffect::setVal4(const unsigned n, const unsigned d) throw(Exception) +void ItemEffect::setVal4(const unsigned n, const unsigned d) throw(Exception) { switch (effect) { @@ -661,7 +661,7 @@ void PokeMod::ItemEffect::setVal4(const unsigned n, const unsigned d) throw(Exce val4.set(n, d); } -void PokeMod::ItemEffect::setVal4Num(const unsigned n) throw(Exception) +void ItemEffect::setVal4Num(const unsigned n) throw(Exception) { switch (effect) { @@ -694,7 +694,7 @@ void PokeMod::ItemEffect::setVal4Num(const unsigned n) throw(Exception) val4.setNum(n); } -void PokeMod::ItemEffect::setVal4Denom(const unsigned d) throw(Exception) +void ItemEffect::setVal4Denom(const unsigned d) throw(Exception) { switch (effect) { @@ -727,47 +727,47 @@ void PokeMod::ItemEffect::setVal4Denom(const unsigned d) throw(Exception) val4.setDenom(d); } -bool PokeMod::ItemEffect::getOverworld() const +bool ItemEffect::getOverworld() const { return overworld; } -bool PokeMod::ItemEffect::getBattle() const +bool ItemEffect::getBattle() const { return battle; } -bool PokeMod::ItemEffect::getHeld() const +bool ItemEffect::getHeld() const { return held; } -unsigned PokeMod::ItemEffect::getEffect() const +unsigned ItemEffect::getEffect() const { return effect; } -int PokeMod::ItemEffect::getVal1() const +int ItemEffect::getVal1() const { return val1; } -unsigned PokeMod::ItemEffect::getVal2() const +unsigned ItemEffect::getVal2() const { return val2; } -unsigned PokeMod::ItemEffect::getVal3() const +unsigned ItemEffect::getVal3() const { return val3; } -Frac PokeMod::ItemEffect::getVal4() const +Frac ItemEffect::getVal4() const { return val4; } -PokeMod::ItemEffect& PokeMod::ItemEffect::operator=(const ItemEffect& rhs) +ItemEffect& ItemEffect::operator=(const ItemEffect& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/ItemEffect.h b/pokemod/ItemEffect.h index 951966a8..e602e597 100644 --- a/pokemod/ItemEffect.h +++ b/pokemod/ItemEffect.h @@ -28,157 +28,154 @@ #include "../general/Exception.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class ItemEffect : public Object { - class Pokemod; - - class ItemEffect : public Object - { - public: - enum Effect - { - E_HPCure = 0, - E_Revive = 1, - E_CureStatus = 2, - E_LevelBoost = 3, - E_StatBoost = 4, - E_Flinch = 5, - E_First = 6, - E_KeepAlive = 7, - E_ModifyStatBattle = 8, - E_ShieldBattle = 9, - E_RunBattle = 10, - E_PPBoost = 11, - E_TypeBoost = 12, - E_PPRestore = 13, - E_ExpShare = 14, - E_Fish = 15, - E_Repel = 16, - E_Escape = 17, - E_TM = 18, - E_HM = 19, - E_Map = 20, - E_Ball = 21, - E_Itemfinder = 22, - E_Bike = 23, - E_Scope = 24, - E_Coin = 25, - E_CoinCase = 26, - E_Berry = 27, - E_Acorn = 28, - E_Evolution = 29, - E_End = 30 - }; - static const QStringList EffectStr; - - enum Relative - { - R_Absolute = 0, - R_Relative = 1, - R_End = 2 - }; - static const QStringList RelativeStr; - - enum Escape - { - ES_Anywhere = 0, - ES_Dungeon = 1, - ES_End = 2 - }; - static const QStringList EscapeStr; - - enum Repel - { - RP_First = 0, - RP_Max = 1, - RP_All = 2, - RP_End = 3 - }; - static const QStringList RepelStr; - - enum Amount - { - A_All = 0, - A_One = 1, - A_End = 2 - }; - static const QStringList AmountStr; - - enum SpecialPhysical - { - SP_Special = 0, - SP_Physical = 1, - SP_End = 2 - }; - static const QStringList SpecialPhysicalStr; - - enum BallType - { - B_Regular = 0, - B_Master = 1, - B_Level = 2, - B_Love = 3, - B_Area = 4, - B_Time = 5, - B_Battle = 6, - B_Friend = 7, - B_Stat = 8, - B_Type = 9, - B_Weight = 10, - B_End = 11 - }; - static const QStringList BallTypeStr; - - enum BerryType - { - B2_HPCure = 0, - B2_StatusCure = 1, - B2_End = 2 - }; - static const QStringList BerryTypeStr; - - ItemEffect(const Pokemod& par, const unsigned _id); - ItemEffect(const Pokemod& par, const ItemEffect& e, const unsigned _id); - ItemEffect(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save(const QString& item) const throw(Exception); - - void setOverworld(const bool o) throw(Exception); - void setBattle(const bool b); - void setHeld(const bool h); - void setEffect(const unsigned e) throw(Exception); - void setVal1(const int v1) throw(Exception); - void setVal2(const unsigned v2) throw(Exception); - void setVal3(const unsigned v3) throw(Exception); - void setVal4(const unsigned n, const unsigned d) throw(Exception); - void setVal4Num(const unsigned n) throw(Exception); - void setVal4Denom(const unsigned d) throw(Exception); - - bool getOverworld() const; - bool getBattle() const; - bool getHeld() const; - unsigned getEffect() const; - int getVal1() const; - unsigned getVal2() const; - unsigned getVal3() const; - Frac getVal4() const; - unsigned getVal4Num() const; - unsigned getVal4Denom() const; - - ItemEffect& operator=(const ItemEffect& rhs); - private: - bool validate() const; - - bool overworld; - bool battle; - bool held; - unsigned effect; - int val1; - unsigned val2; - unsigned val3; - Frac val4; - }; -} + public: + enum Effect + { + E_HPCure = 0, + E_Revive = 1, + E_CureStatus = 2, + E_LevelBoost = 3, + E_StatBoost = 4, + E_Flinch = 5, + E_First = 6, + E_KeepAlive = 7, + E_ModifyStatBattle = 8, + E_ShieldBattle = 9, + E_RunBattle = 10, + E_PPBoost = 11, + E_TypeBoost = 12, + E_PPRestore = 13, + E_ExpShare = 14, + E_Fish = 15, + E_Repel = 16, + E_Escape = 17, + E_TM = 18, + E_HM = 19, + E_Map = 20, + E_Ball = 21, + E_Itemfinder = 22, + E_Bike = 23, + E_Scope = 24, + E_Coin = 25, + E_CoinCase = 26, + E_Berry = 27, + E_Acorn = 28, + E_Evolution = 29, + E_End = 30 + }; + static const QStringList EffectStr; + + enum Relative + { + R_Absolute = 0, + R_Relative = 1, + R_End = 2 + }; + static const QStringList RelativeStr; + + enum Escape + { + ES_Anywhere = 0, + ES_Dungeon = 1, + ES_End = 2 + }; + static const QStringList EscapeStr; + + enum Repel + { + RP_First = 0, + RP_Max = 1, + RP_All = 2, + RP_End = 3 + }; + static const QStringList RepelStr; + + enum Amount + { + A_All = 0, + A_One = 1, + A_End = 2 + }; + static const QStringList AmountStr; + + enum SpecialPhysical + { + SP_Special = 0, + SP_Physical = 1, + SP_End = 2 + }; + static const QStringList SpecialPhysicalStr; + + enum BallType + { + B_Regular = 0, + B_Master = 1, + B_Level = 2, + B_Love = 3, + B_Area = 4, + B_Time = 5, + B_Battle = 6, + B_Friend = 7, + B_Stat = 8, + B_Type = 9, + B_Weight = 10, + B_End = 11 + }; + static const QStringList BallTypeStr; + + enum BerryType + { + B2_HPCure = 0, + B2_StatusCure = 1, + B2_End = 2 + }; + static const QStringList BerryTypeStr; + + ItemEffect(const Pokemod& par, const unsigned _id); + ItemEffect(const Pokemod& par, const ItemEffect& e, const unsigned _id); + ItemEffect(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save(const QString& item) const throw(Exception); + + void setOverworld(const bool o) throw(Exception); + void setBattle(const bool b); + void setHeld(const bool h); + void setEffect(const unsigned e) throw(Exception); + void setVal1(const int v1) throw(Exception); + void setVal2(const unsigned v2) throw(Exception); + void setVal3(const unsigned v3) throw(Exception); + void setVal4(const unsigned n, const unsigned d) throw(Exception); + void setVal4Num(const unsigned n) throw(Exception); + void setVal4Denom(const unsigned d) throw(Exception); + + bool getOverworld() const; + bool getBattle() const; + bool getHeld() const; + unsigned getEffect() const; + int getVal1() const; + unsigned getVal2() const; + unsigned getVal3() const; + Frac getVal4() const; + unsigned getVal4Num() const; + unsigned getVal4Denom() const; + + ItemEffect& operator=(const ItemEffect& rhs); + private: + bool validate() const; + + bool overworld; + bool battle; + bool held; + unsigned effect; + int val1; + unsigned val2; + unsigned val3; + Frac val4; +}; #endif diff --git a/pokemod/ItemType.cpp b/pokemod/ItemType.cpp index dba68618..6caa0a41 100644 --- a/pokemod/ItemType.cpp +++ b/pokemod/ItemType.cpp @@ -24,7 +24,7 @@ #include "Pokemod.h" #include "ItemType.h" -PokeMod::ItemType::ItemType(const Pokemod& par, const unsigned _id) : +ItemType::ItemType(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), computer(0), @@ -32,19 +32,19 @@ PokeMod::ItemType::ItemType(const Pokemod& par, const unsigned _id) : { } -PokeMod::ItemType::ItemType(const Pokemod& par, const ItemType& i, const unsigned _id) : +ItemType::ItemType(const Pokemod& par, const ItemType& i, const unsigned _id) : Object(par, _id) { *this = i; } -PokeMod::ItemType::ItemType(const Pokemod& par, const QString& fname, const unsigned _id) : +ItemType::ItemType(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::ItemType::validate() const +bool ItemType::validate() const { bool valid = true; pokemod.validationMsg(QString("---Item Type \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -61,7 +61,7 @@ bool PokeMod::ItemType::validate() const return valid; } -void PokeMod::ItemType::load(const QString& fname, const unsigned _id) throw(Exception) +void ItemType::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -73,7 +73,7 @@ void PokeMod::ItemType::load(const QString& fname, const unsigned _id) throw(Exc ini.getValue("player", player, 1); } -void PokeMod::ItemType::save() const throw(Exception) +void ItemType::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -83,39 +83,39 @@ void PokeMod::ItemType::save() const throw(Exception) ini.save(QString("%1/itemtype/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeMod::ItemType::setName(const QString& n) +void ItemType::setName(const QString& n) { name = n; } -void PokeMod::ItemType::setComputer(const unsigned c) +void ItemType::setComputer(const unsigned c) { computer = c; } -void PokeMod::ItemType::setPlayer(const unsigned p) throw(BoundsException) +void ItemType::setPlayer(const unsigned p) throw(BoundsException) { if (!p) throw(BoundsException("ItemType", "player")); player = p; } -QString PokeMod::ItemType::getName() const +QString ItemType::getName() const { return name; } -unsigned PokeMod::ItemType::getComputer() const +unsigned ItemType::getComputer() const { return computer; } -unsigned PokeMod::ItemType::getPlayer() const +unsigned ItemType::getPlayer() const { return player; } -PokeMod::ItemType& PokeMod::ItemType::operator=(const ItemType& rhs) +ItemType& ItemType::operator=(const ItemType& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/ItemType.h b/pokemod/ItemType.h index e5bf1909..2ebee3f3 100644 --- a/pokemod/ItemType.h +++ b/pokemod/ItemType.h @@ -27,36 +27,33 @@ #include "../general/Exception.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class ItemType : public Object { - class Pokemod; - - class ItemType : public Object - { - public: - ItemType(const Pokemod& par, const unsigned _id); - ItemType(const Pokemod& par, const ItemType& i, const unsigned _id); - ItemType(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - void setComputer(const unsigned c); - void setPlayer(const unsigned p) throw(BoundsException); - - QString getName() const; - unsigned getComputer() const; - unsigned getPlayer() const; - - ItemType& operator=(const ItemType& rhs); - private: - bool validate() const; - - QString name; - unsigned computer; - unsigned player; - }; -} + public: + ItemType(const Pokemod& par, const unsigned _id); + ItemType(const Pokemod& par, const ItemType& i, const unsigned _id); + ItemType(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + void setComputer(const unsigned c); + void setPlayer(const unsigned p) throw(BoundsException); + + QString getName() const; + unsigned getComputer() const; + unsigned getPlayer() const; + + ItemType& operator=(const ItemType& rhs); + private: + bool validate() const; + + QString name; + unsigned computer; + unsigned player; +}; #endif diff --git a/pokemod/Map.cpp b/pokemod/Map.cpp index fda0a7e9..e3d90465 100644 --- a/pokemod/Map.cpp +++ b/pokemod/Map.cpp @@ -27,9 +27,9 @@ #include "Pokemod.h" #include "Map.h" -const QStringList PokeMod::Map::TypeStr = QStringList() << "Outdoor" << "Dungeon" << "Building"; +const QStringList Map::TypeStr = QStringList() << "Outdoor" << "Dungeon" << "Building"; -PokeMod::Map::Map(const Pokemod& par, const unsigned _id) : +Map::Map(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), flyWarp(UINT_MAX), @@ -37,19 +37,19 @@ PokeMod::Map::Map(const Pokemod& par, const unsigned _id) : { } -PokeMod::Map::Map(const Pokemod& par, const Map& m, const unsigned _id) : +Map::Map(const Pokemod& par, const Map& m, const unsigned _id) : Object(par, _id) { *this = m; } -PokeMod::Map::Map(const Pokemod& par, const QString& fname, const unsigned _id) : +Map::Map(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::Map::validate() const +bool Map::validate() const { bool valid = true; pokemod.validationMsg(QString("---Map \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -227,7 +227,7 @@ bool PokeMod::Map::validate() const return valid; } -unsigned PokeMod::Map::getNewEffectId() const +unsigned Map::getNewEffectId() const { unsigned i = 0; for (; (i < getEffectCount()) && (getEffectIndex(i) != UINT_MAX); ++i) @@ -235,7 +235,7 @@ unsigned PokeMod::Map::getNewEffectId() const return i; } -unsigned PokeMod::Map::getNewTrainerId() const +unsigned Map::getNewTrainerId() const { unsigned i = 0; for (; (i < getTrainerCount()) && (getTrainerIndex(i) != UINT_MAX); ++i) @@ -243,7 +243,7 @@ unsigned PokeMod::Map::getNewTrainerId() const return i; } -unsigned PokeMod::Map::getNewWarpId() const +unsigned Map::getNewWarpId() const { unsigned i = 0; for (; (i < getWarpCount()) && (getWarpIndex(i) != UINT_MAX); ++i) @@ -251,7 +251,7 @@ unsigned PokeMod::Map::getNewWarpId() const return i; } -unsigned PokeMod::Map::getNewWildListId() const +unsigned Map::getNewWildListId() const { unsigned i = 0; for (; (i < getWarpCount()) && (getWarpIndex(i) != UINT_MAX); ++i) @@ -259,7 +259,7 @@ unsigned PokeMod::Map::getNewWildListId() const return i; } -void PokeMod::Map::load(const QString& fname, const unsigned _id) throw(Exception) +void Map::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -311,7 +311,7 @@ void PokeMod::Map::load(const QString& fname, const unsigned _id) throw(Exceptio } } -void PokeMod::Map::save() const throw(Exception) +void Map::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -336,117 +336,117 @@ void PokeMod::Map::save() const throw(Exception) i.next().save(name); } -void PokeMod::Map::setName(const QString& n) +void Map::setName(const QString& n) { name = n; } -void PokeMod::Map::setFlyWarp(const unsigned f) throw(BoundsException) +void Map::setFlyWarp(const unsigned f) throw(BoundsException) { if (getWarpIndex(f) == UINT_MAX) throw(BoundsException("Map", "warp")); flyWarp = f; } -void PokeMod::Map::setType(const unsigned t) throw(BoundsException) +void Map::setType(const unsigned t) throw(BoundsException) { if (End <= t) throw(BoundsException("Map", "type")); type = t; } -QString PokeMod::Map::getName() const +QString Map::getName() const { return name; } -unsigned PokeMod::Map::getFlyWarp() const +unsigned Map::getFlyWarp() const { return flyWarp; } -unsigned PokeMod::Map::getType() const +unsigned Map::getType() const { return type; } -void PokeMod::Map::setTile(unsigned x, unsigned y, unsigned _id) throw(BoundsException) +void Map::setTile(unsigned x, unsigned y, unsigned _id) throw(BoundsException) { if (pokemod.getTileIndex(_id) == UINT_MAX) throw(BoundsException("Map", "tile")); tiles(x, y) = _id; } -void PokeMod::Map::insertColumn(unsigned x) +void Map::insertColumn(unsigned x) { tiles.insertCol(x, 0); } -void PokeMod::Map::insertRow(unsigned y) +void Map::insertRow(unsigned y) { tiles.insertRow(y, 0); } -void PokeMod::Map::addColumn() +void Map::addColumn() { tiles.addCol(0); } -void PokeMod::Map::addRow() +void Map::addRow() { tiles.addRow(0); } -void PokeMod::Map::deleteColumn(unsigned x) +void Map::deleteColumn(unsigned x) { tiles.deleteCol(x); } -void PokeMod::Map::deleteRow(unsigned y) +void Map::deleteRow(unsigned y) { tiles.deleteRow(y); } -unsigned PokeMod::Map::getTile(unsigned x, unsigned y) const +unsigned Map::getTile(unsigned x, unsigned y) const { return tiles(x, y); } -unsigned PokeMod::Map::getWidth() const +unsigned Map::getWidth() const { return tiles.getWidth(); } -unsigned PokeMod::Map::getHeight() const +unsigned Map::getHeight() const { return tiles.getHeight(); } -const PokeMod::MapEffect& PokeMod::Map::getEffect(const unsigned i) const throw(IndexException) +const MapEffect& Map::getEffect(const unsigned i) const throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Map")); return effects.at(i); } -PokeMod::MapEffect& PokeMod::Map::getEffect(const unsigned i) throw(IndexException) +MapEffect& Map::getEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Map")); return effects[i]; } -const PokeMod::MapEffect& PokeMod::Map::getEffectByID(const unsigned i) const throw(IndexException) +const MapEffect& Map::getEffectByID(const unsigned i) const throw(IndexException) { return getEffect(getEffectIndex(i)); } -PokeMod::MapEffect& PokeMod::Map::getEffectByID(const unsigned i) throw(IndexException) +MapEffect& Map::getEffectByID(const unsigned i) throw(IndexException) { return getEffect(getEffectIndex(i)); } -unsigned PokeMod::Map::getEffectIndex(const unsigned _id) const +unsigned Map::getEffectIndex(const unsigned _id) const { for (unsigned i = 0; i < getEffectCount(); ++i) { @@ -456,61 +456,61 @@ unsigned PokeMod::Map::getEffectIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Map::getEffectCount() const +unsigned Map::getEffectCount() const { return effects.size(); } -PokeMod::MapEffect& PokeMod::Map::newEffect() +MapEffect& Map::newEffect() { effects.append(MapEffect(pokemod, getNewEffectId())); return effects[getEffectCount() - 1]; } -PokeMod::MapEffect& PokeMod::Map::newEffect(const QString& fname) +MapEffect& Map::newEffect(const QString& fname) { effects.append(MapEffect(pokemod, fname, getNewEffectId())); return effects[getEffectCount() - 1]; } -PokeMod::MapEffect& PokeMod::Map::newEffect(const MapEffect& e) +MapEffect& Map::newEffect(const MapEffect& e) { effects.append(MapEffect(pokemod, e, getNewEffectId())); return effects[getEffectCount() - 1]; } -void PokeMod::Map::deleteEffect(const unsigned i) throw(IndexException) +void Map::deleteEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Map")); effects.removeAt(i); } -const PokeMod::MapTrainer& PokeMod::Map::getTrainer(const unsigned i) const throw(IndexException) +const MapTrainer& Map::getTrainer(const unsigned i) const throw(IndexException) { if (getTrainerCount() <= i) throw(IndexException("Map")); return trainers.at(i); } -PokeMod::MapTrainer& PokeMod::Map::getTrainer(const unsigned i) throw(IndexException) +MapTrainer& Map::getTrainer(const unsigned i) throw(IndexException) { if (getTrainerCount() <= i) throw(IndexException("Map")); return trainers[i]; } -const PokeMod::MapTrainer& PokeMod::Map::getTrainerByID(const unsigned i) const throw(IndexException) +const MapTrainer& Map::getTrainerByID(const unsigned i) const throw(IndexException) { return getTrainer(getTrainerIndex(i)); } -PokeMod::MapTrainer& PokeMod::Map::getTrainerByID(const unsigned i) throw(IndexException) +MapTrainer& Map::getTrainerByID(const unsigned i) throw(IndexException) { return getTrainer(getTrainerIndex(i)); } -unsigned PokeMod::Map::getTrainerIndex(const unsigned _id) const +unsigned Map::getTrainerIndex(const unsigned _id) const { for (unsigned i = 0; i < getTrainerCount(); ++i) { @@ -520,61 +520,61 @@ unsigned PokeMod::Map::getTrainerIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Map::getTrainerCount() const +unsigned Map::getTrainerCount() const { return trainers.size(); } -PokeMod::MapTrainer& PokeMod::Map::newTrainer() +MapTrainer& Map::newTrainer() { trainers.append(MapTrainer(pokemod, getNewTrainerId())); return trainers[getTrainerCount() - 1]; } -PokeMod::MapTrainer& PokeMod::Map::newTrainer(const QString& fname) +MapTrainer& Map::newTrainer(const QString& fname) { trainers.append(MapTrainer(pokemod, fname, getNewTrainerId())); return trainers[getTrainerCount() - 1]; } -PokeMod::MapTrainer& PokeMod::Map::newTrainer(const MapTrainer& t) +MapTrainer& Map::newTrainer(const MapTrainer& t) { trainers.append(MapTrainer(pokemod, t, getNewTrainerId())); return trainers[getTrainerCount() - 1]; } -void PokeMod::Map::deleteTrainer(const unsigned i) throw(IndexException) +void Map::deleteTrainer(const unsigned i) throw(IndexException) { if (getTrainerCount() <= i) throw(IndexException("Map")); trainers.removeAt(i); } -const PokeMod::MapWarp& PokeMod::Map::getWarp(const unsigned i) const throw(IndexException) +const MapWarp& Map::getWarp(const unsigned i) const throw(IndexException) { if (getWarpCount() <= i) throw(IndexException("Map")); return warps.at(i); } -PokeMod::MapWarp& PokeMod::Map::getWarp(const unsigned i) throw(IndexException) +MapWarp& Map::getWarp(const unsigned i) throw(IndexException) { if (getWarpCount() <= i) throw(IndexException("Map")); return warps[i]; } -const PokeMod::MapWarp& PokeMod::Map::getWarpByID(const unsigned i) const throw(IndexException) +const MapWarp& Map::getWarpByID(const unsigned i) const throw(IndexException) { return getWarp(getWarpIndex(i)); } -PokeMod::MapWarp& PokeMod::Map::getWarpByID(const unsigned i) throw(IndexException) +MapWarp& Map::getWarpByID(const unsigned i) throw(IndexException) { return getWarp(getWarpIndex(i)); } -unsigned PokeMod::Map::getWarpIndex(const unsigned _id) const +unsigned Map::getWarpIndex(const unsigned _id) const { for (unsigned i = 0; i < getWarpCount(); ++i) { @@ -584,61 +584,61 @@ unsigned PokeMod::Map::getWarpIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Map::getWarpCount() const +unsigned Map::getWarpCount() const { return warps.size(); } -PokeMod::MapWarp& PokeMod::Map::newWarp() +MapWarp& Map::newWarp() { warps.append(MapWarp(pokemod, getNewWarpId())); return warps[getWarpCount() - 1]; } -PokeMod::MapWarp& PokeMod::Map::newWarp(const QString& fname) +MapWarp& Map::newWarp(const QString& fname) { warps.append(MapWarp(pokemod, fname, getNewWarpId())); return warps[getWarpCount() - 1]; } -PokeMod::MapWarp& PokeMod::Map::newWarp(const MapWarp& w) +MapWarp& Map::newWarp(const MapWarp& w) { warps.append(MapWarp(pokemod, w, getNewWarpId())); return warps[getWarpCount() - 1]; } -void PokeMod::Map::deleteWarp(const unsigned i) throw(IndexException) +void Map::deleteWarp(const unsigned i) throw(IndexException) { if (getWarpCount() <= i) throw(IndexException("Map")); warps.removeAt(i); } -const PokeMod::MapWildList& PokeMod::Map::getWildList(const unsigned i) const throw(IndexException) +const MapWildList& Map::getWildList(const unsigned i) const throw(IndexException) { if (getWildListCount() <= i) throw(IndexException("Map")); return wildLists.at(i); } -PokeMod::MapWildList& PokeMod::Map::getWildList(const unsigned i) throw(IndexException) +MapWildList& Map::getWildList(const unsigned i) throw(IndexException) { if (getWildListCount() <= i) throw(IndexException("Map")); return wildLists[i]; } -const PokeMod::MapWildList& PokeMod::Map::getWildListByID(const unsigned i) const throw(IndexException) +const MapWildList& Map::getWildListByID(const unsigned i) const throw(IndexException) { return getWildList(getWildListIndex(i)); } -PokeMod::MapWildList& PokeMod::Map::getWildListByID(const unsigned i) throw(IndexException) +MapWildList& Map::getWildListByID(const unsigned i) throw(IndexException) { return getWildList(getWildListIndex(i)); } -unsigned PokeMod::Map::getWildListIndex(const unsigned _id) const +unsigned Map::getWildListIndex(const unsigned _id) const { for (unsigned i = 0; i < getWildListCount(); ++i) { @@ -648,37 +648,37 @@ unsigned PokeMod::Map::getWildListIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Map::getWildListCount() const +unsigned Map::getWildListCount() const { return wildLists.size(); } -PokeMod::MapWildList& PokeMod::Map::newWildList() +MapWildList& Map::newWildList() { wildLists.append(MapWildList(pokemod, getNewWildListId())); return wildLists[getWildListCount() - 1]; } -PokeMod::MapWildList& PokeMod::Map::newWildList(const QString& fname) +MapWildList& Map::newWildList(const QString& fname) { wildLists.append(MapWildList(pokemod, fname, getNewWildListId())); return wildLists[getWildListCount() - 1]; } -PokeMod::MapWildList& PokeMod::Map::newWildList(const MapWildList& w) +MapWildList& Map::newWildList(const MapWildList& w) { wildLists.append(MapWildList(pokemod, w, getNewWildListId())); return wildLists[getWildListCount() - 1]; } -void PokeMod::Map::deleteWildList(const unsigned i) throw(IndexException) +void Map::deleteWildList(const unsigned i) throw(IndexException) { if (getWildListCount() <= i) throw(IndexException("Map")); wildLists.removeAt(i); } -PokeMod::Map& PokeMod::Map::operator=(const Map& rhs) +Map& Map::operator=(const Map& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Map.h b/pokemod/Map.h index 9a77dbef..24371003 100644 --- a/pokemod/Map.h +++ b/pokemod/Map.h @@ -34,111 +34,108 @@ #include "MapWarp.h" #include "MapWildList.h" -namespace PokeMod +class Pokemod; + +class Map : public Object { - class Pokemod; - - class Map : public Object - { - public: - enum - { - Outdoor = 0, - Dungeon = 1, - Building = 2, - End = 3 - }; - static const QStringList TypeStr; - - Map(const Pokemod& par, const unsigned _id); - Map(const Pokemod& par, const Map& m, const unsigned _id); - Map(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - void setFlyWarp(const unsigned f) throw(BoundsException); - void setType(const unsigned t) throw(BoundsException); - - QString getName() const; - unsigned getFlyWarp() const; - unsigned getType() const; - - void setTile(unsigned x, unsigned y, unsigned _id) throw(BoundsException); - void insertColumn(unsigned x); - void insertRow(unsigned y); - void addColumn(); - void addRow(); - void deleteColumn(unsigned x); - void deleteRow(unsigned y); - - unsigned getTile(unsigned x, unsigned y) const; - unsigned getWidth() const; - unsigned getHeight() const; - - const MapEffect& getEffect(const unsigned i) const throw(IndexException); - MapEffect& getEffect(const unsigned i) throw(IndexException); - const MapEffect& getEffectByID(const unsigned i) const throw(IndexException); - MapEffect& getEffectByID(const unsigned i) throw(IndexException); - unsigned getEffectIndex(const unsigned _id) const; - unsigned getEffectCount() const; - MapEffect& newEffect(); - MapEffect& newEffect(const QString& fname); - MapEffect& newEffect(const MapEffect& e); - void deleteEffect(const unsigned i) throw(IndexException); - - const MapTrainer& getTrainer(const unsigned i) const throw(IndexException); - MapTrainer& getTrainer(const unsigned i) throw(IndexException); - const MapTrainer& getTrainerByID(const unsigned i) const throw(IndexException); - MapTrainer& getTrainerByID(const unsigned i) throw(IndexException); - unsigned getTrainerIndex(const unsigned _id) const; - unsigned getTrainerCount() const; - MapTrainer& newTrainer(); - MapTrainer& newTrainer(const QString& fname); - MapTrainer& newTrainer(const MapTrainer& t); - void deleteTrainer(const unsigned i) throw(IndexException); - - const MapWarp& getWarp(const unsigned i) const throw(IndexException); - MapWarp& getWarp(const unsigned i) throw(IndexException); - const MapWarp& getWarpByID(const unsigned i) const throw(IndexException); - MapWarp& getWarpByID(const unsigned i) throw(IndexException); - unsigned getWarpIndex(const unsigned _id) const; - unsigned getWarpCount() const; - MapWarp& newWarp(); - MapWarp& newWarp(const QString& fname); - MapWarp& newWarp(const MapWarp& w); - void deleteWarp(const unsigned i) throw(IndexException); - - const MapWildList& getWildList(const unsigned i) const throw(IndexException); - MapWildList& getWildList(const unsigned i) throw(IndexException); - const MapWildList& getWildListByID(const unsigned i) const throw(IndexException); - MapWildList& getWildListByID(const unsigned i) throw(IndexException); - unsigned getWildListIndex(const unsigned _id) const; - unsigned getWildListCount() const; - MapWildList& newWildList(); - MapWildList& newWildList(const QString& fname); - MapWildList& newWildList(const MapWildList& w); - void deleteWildList(const unsigned i) throw(IndexException); - - Map& operator=(const Map& rhs); - private: - bool validate() const; - unsigned getNewEffectId() const; - unsigned getNewTrainerId() const; - unsigned getNewWarpId() const; - unsigned getNewWildListId() const; - - QString name; - unsigned flyWarp; - unsigned type; - Matrix<unsigned> tiles; - - QList<MapEffect> effects; - QList<MapTrainer> trainers; - QList<MapWarp> warps; - QList<MapWildList> wildLists; - }; -} + public: + enum + { + Outdoor = 0, + Dungeon = 1, + Building = 2, + End = 3 + }; + static const QStringList TypeStr; + + Map(const Pokemod& par, const unsigned _id); + Map(const Pokemod& par, const Map& m, const unsigned _id); + Map(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + void setFlyWarp(const unsigned f) throw(BoundsException); + void setType(const unsigned t) throw(BoundsException); + + QString getName() const; + unsigned getFlyWarp() const; + unsigned getType() const; + + void setTile(unsigned x, unsigned y, unsigned _id) throw(BoundsException); + void insertColumn(unsigned x); + void insertRow(unsigned y); + void addColumn(); + void addRow(); + void deleteColumn(unsigned x); + void deleteRow(unsigned y); + + unsigned getTile(unsigned x, unsigned y) const; + unsigned getWidth() const; + unsigned getHeight() const; + + const MapEffect& getEffect(const unsigned i) const throw(IndexException); + MapEffect& getEffect(const unsigned i) throw(IndexException); + const MapEffect& getEffectByID(const unsigned i) const throw(IndexException); + MapEffect& getEffectByID(const unsigned i) throw(IndexException); + unsigned getEffectIndex(const unsigned _id) const; + unsigned getEffectCount() const; + MapEffect& newEffect(); + MapEffect& newEffect(const QString& fname); + MapEffect& newEffect(const MapEffect& e); + void deleteEffect(const unsigned i) throw(IndexException); + + const MapTrainer& getTrainer(const unsigned i) const throw(IndexException); + MapTrainer& getTrainer(const unsigned i) throw(IndexException); + const MapTrainer& getTrainerByID(const unsigned i) const throw(IndexException); + MapTrainer& getTrainerByID(const unsigned i) throw(IndexException); + unsigned getTrainerIndex(const unsigned _id) const; + unsigned getTrainerCount() const; + MapTrainer& newTrainer(); + MapTrainer& newTrainer(const QString& fname); + MapTrainer& newTrainer(const MapTrainer& t); + void deleteTrainer(const unsigned i) throw(IndexException); + + const MapWarp& getWarp(const unsigned i) const throw(IndexException); + MapWarp& getWarp(const unsigned i) throw(IndexException); + const MapWarp& getWarpByID(const unsigned i) const throw(IndexException); + MapWarp& getWarpByID(const unsigned i) throw(IndexException); + unsigned getWarpIndex(const unsigned _id) const; + unsigned getWarpCount() const; + MapWarp& newWarp(); + MapWarp& newWarp(const QString& fname); + MapWarp& newWarp(const MapWarp& w); + void deleteWarp(const unsigned i) throw(IndexException); + + const MapWildList& getWildList(const unsigned i) const throw(IndexException); + MapWildList& getWildList(const unsigned i) throw(IndexException); + const MapWildList& getWildListByID(const unsigned i) const throw(IndexException); + MapWildList& getWildListByID(const unsigned i) throw(IndexException); + unsigned getWildListIndex(const unsigned _id) const; + unsigned getWildListCount() const; + MapWildList& newWildList(); + MapWildList& newWildList(const QString& fname); + MapWildList& newWildList(const MapWildList& w); + void deleteWildList(const unsigned i) throw(IndexException); + + Map& operator=(const Map& rhs); + private: + bool validate() const; + unsigned getNewEffectId() const; + unsigned getNewTrainerId() const; + unsigned getNewWarpId() const; + unsigned getNewWildListId() const; + + QString name; + unsigned flyWarp; + unsigned type; + Matrix<unsigned> tiles; + + QList<MapEffect> effects; + QList<MapTrainer> trainers; + QList<MapWarp> warps; + QList<MapWildList> wildLists; +}; #endif diff --git a/pokemod/MapEffect.cpp b/pokemod/MapEffect.cpp index 28571fa0..df59f432 100644 --- a/pokemod/MapEffect.cpp +++ b/pokemod/MapEffect.cpp @@ -24,10 +24,10 @@ #include "Dialog.h" #include "MapEffect.h" -const QStringList PokeMod::MapEffect::MapEffectStr = QStringList() << "Item" << "PC" << "Strength Block" << "Button" << "Slot Machine" << "Card Flip Game"; -const QStringList PokeMod::MapEffect::PCTypeStr = QStringList() << "Item" << "Pokémon" << "PokéDex" << "Hall of Fame" << "All"; +const QStringList MapEffect::MapEffectStr = QStringList() << "Item" << "PC" << "Strength Block" << "Button" << "Slot Machine" << "Card Flip Game"; +const QStringList MapEffect::PCTypeStr = QStringList() << "Item" << "Pokémon" << "PokéDex" << "Hall of Fame" << "All"; -PokeMod::MapEffect::MapEffect(const Pokemod& par, const unsigned _id) : +MapEffect::MapEffect(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), coordinate(0, 0), @@ -43,19 +43,19 @@ PokeMod::MapEffect::MapEffect(const Pokemod& par, const unsigned _id) : { } -PokeMod::MapEffect::MapEffect(const Pokemod& par, const MapEffect& e, const unsigned _id) : +MapEffect::MapEffect(const Pokemod& par, const MapEffect& e, const unsigned _id) : Object(par, _id) { *this = e; } -PokeMod::MapEffect::MapEffect(const Pokemod& par, const QString& fname, const unsigned _id) : +MapEffect::MapEffect(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::MapEffect::validate() const +bool MapEffect::validate() const { bool valid = true; pokemod.validationMsg(QString("------Effect \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -117,7 +117,7 @@ bool PokeMod::MapEffect::validate() const return valid; } -void PokeMod::MapEffect::load(const QString& fname, const unsigned _id) throw(Exception) +void MapEffect::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -143,7 +143,7 @@ void PokeMod::MapEffect::load(const QString& fname, const unsigned _id) throw(Ex ini.getValue("dialog", dialog); } -void PokeMod::MapEffect::save(const QString& map) const throw(Exception) +void MapEffect::save(const QString& map) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -163,49 +163,49 @@ void PokeMod::MapEffect::save(const QString& map) const throw(Exception) ini.save(QString("%1/map/%2/effect/%3.pini").arg(pokemod.getPath()).arg(map).arg(name)); } -void PokeMod::MapEffect::setName(const QString& n) +void MapEffect::setName(const QString& n) { name = n; } -void PokeMod::MapEffect::setCoordinate(const unsigned x, const unsigned y) +void MapEffect::setCoordinate(const unsigned x, const unsigned y) { coordinate.set(x, y); } -void PokeMod::MapEffect::setCoordinateX(const unsigned x) +void MapEffect::setCoordinateX(const unsigned x) { coordinate.setX(x); } -void PokeMod::MapEffect::setCoordinateY(const unsigned y) +void MapEffect::setCoordinateY(const unsigned y) { coordinate.setY(y); } -void PokeMod::MapEffect::setExistFlag(const unsigned f, const unsigned s) +void MapEffect::setExistFlag(const unsigned f, const unsigned s) { existFlag.set(f, s); } -void PokeMod::MapEffect::setExistFlagFlag(const unsigned f) +void MapEffect::setExistFlagFlag(const unsigned f) { existFlag.setFlag(f); } -void PokeMod::MapEffect::setExistFlagStatus(const unsigned s) +void MapEffect::setExistFlagStatus(const unsigned s) { existFlag.setStatus(s); } -void PokeMod::MapEffect::setSkin(const QString& s) throw(Exception) +void MapEffect::setSkin(const QString& s) throw(Exception) { if (!QFile::exists(QString("%1/image/skin/%2.png").arg(pokemod.getPath()).arg(s))) throw(Exception("MapEffect", "skin does not exist")); skin = s; } -void PokeMod::MapEffect::setEffect(const unsigned e) throw(BoundsException) +void MapEffect::setEffect(const unsigned e) throw(BoundsException) { if (E_End <= e) throw(BoundsException("MapEffect", "effect")); @@ -214,14 +214,14 @@ void PokeMod::MapEffect::setEffect(const unsigned e) throw(BoundsException) val2 = UINT_MAX; } -void PokeMod::MapEffect::setVal1(const unsigned v1) throw(UnusedException) +void MapEffect::setVal1(const unsigned v1) throw(UnusedException) { if ((effect != E_StrengthBlock) && (effect != E_Button)) throw(UnusedException("MapEffect", "val1")); val1 = v1; } -void PokeMod::MapEffect::setVal2(const unsigned v2) throw(Exception) +void MapEffect::setVal2(const unsigned v2) throw(Exception) { switch (effect) { @@ -245,86 +245,86 @@ void PokeMod::MapEffect::setVal2(const unsigned v2) throw(Exception) val2 = v2; } -void PokeMod::MapEffect::setDirection(const unsigned d) throw(BoundsException) +void MapEffect::setDirection(const unsigned d) throw(BoundsException) { if (D_End_None <= d) throw(BoundsException("MapEffect", "direction")); direction = d; } -void PokeMod::MapEffect::setIsGhost(const bool i) +void MapEffect::setIsGhost(const bool i) { isGhost = i; } -void PokeMod::MapEffect::setCanMove(const bool c) +void MapEffect::setCanMove(const bool c) { canMove = c; } -void PokeMod::MapEffect::setDialog(const unsigned d) throw(BoundsException) +void MapEffect::setDialog(const unsigned d) throw(BoundsException) { if (pokemod.getDialogIndex(d) == UINT_MAX) throw(BoundsException("MapEffect", "dialog")); dialog = d; } -QString PokeMod::MapEffect::getName() const +QString MapEffect::getName() const { return name; } -Point PokeMod::MapEffect::getCoordinate() const +Point MapEffect::getCoordinate() const { return coordinate; } -Flag PokeMod::MapEffect::getExistFlag() const +Flag MapEffect::getExistFlag() const { return existFlag; } -QString PokeMod::MapEffect::getSkin() const +QString MapEffect::getSkin() const { return skin; } -unsigned PokeMod::MapEffect::getEffect() const +unsigned MapEffect::getEffect() const { return effect; } -unsigned PokeMod::MapEffect::getVal1() const +unsigned MapEffect::getVal1() const { return val1; } -unsigned PokeMod::MapEffect::getVal2() const +unsigned MapEffect::getVal2() const { return val2; } -unsigned PokeMod::MapEffect::getDirection() const +unsigned MapEffect::getDirection() const { return direction; } -bool PokeMod::MapEffect::getIsGhost() const +bool MapEffect::getIsGhost() const { return isGhost; } -bool PokeMod::MapEffect::getCanMove() const +bool MapEffect::getCanMove() const { return canMove; } -unsigned PokeMod::MapEffect::getDialog() const +unsigned MapEffect::getDialog() const { return dialog; } -PokeMod::MapEffect& PokeMod::MapEffect::operator=(const MapEffect& rhs) +MapEffect& MapEffect::operator=(const MapEffect& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/MapEffect.h b/pokemod/MapEffect.h index 4933f409..ccf105ea 100644 --- a/pokemod/MapEffect.h +++ b/pokemod/MapEffect.h @@ -30,87 +30,84 @@ #include "../general/Point.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class MapEffect : public Object { - class Pokemod; - - class MapEffect : public Object - { - public: - enum Effect - { - E_Item = 0, - E_PC = 1, - E_StrengthBlock = 2, - E_Button = 3, - E_SlotMachine = 4, - E_CardFlipGame = 5, - E_End = 6 - }; - static const QStringList MapEffectStr; - - enum PC - { - PC_Item = 0, - PC_Pokemon = 1, - PC_Pokedex = 2, - PC_HallOfFame = 3, - PC_All = 4, - PC_End = 5, - }; - static const QStringList PCTypeStr; - - MapEffect(const Pokemod& par, const unsigned _id); - MapEffect(const Pokemod& par, const MapEffect& e, const unsigned _id); - MapEffect(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save(const QString& map) const throw(Exception); - - void setName(const QString& n); - void setCoordinate(const unsigned x, const unsigned y); - void setCoordinateX(const unsigned x); - void setCoordinateY(const unsigned y); - void setExistFlag(const unsigned f, const unsigned s); - void setExistFlagFlag(const unsigned f); - void setExistFlagStatus(const unsigned s); - void setSkin(const QString& s) throw(Exception); - void setEffect(const unsigned e) throw(BoundsException); - void setVal1(const unsigned v1) throw(UnusedException); - void setVal2(const unsigned v2) throw(Exception); - void setDirection(const unsigned d) throw(BoundsException); - void setIsGhost(const bool i); - void setCanMove(const bool c); - void setDialog(const unsigned d) throw(BoundsException); - - QString getName() const; - Point getCoordinate() const; - Flag getExistFlag() const; - QString getSkin() const; - unsigned getEffect() const; - unsigned getVal1() const; - unsigned getVal2() const; - unsigned getDirection() const; - bool getIsGhost() const; - bool getCanMove() const; - unsigned getDialog() const; - - MapEffect& operator=(const MapEffect& rhs); - private: - bool validate() const; - - QString name; - Point coordinate; - Flag existFlag; - QString skin; - unsigned effect; - unsigned val1; - unsigned val2; - unsigned direction; - bool isGhost; - bool canMove; - unsigned dialog; - }; -} + public: + enum Effect + { + E_Item = 0, + E_PC = 1, + E_StrengthBlock = 2, + E_Button = 3, + E_SlotMachine = 4, + E_CardFlipGame = 5, + E_End = 6 + }; + static const QStringList MapEffectStr; + + enum PC + { + PC_Item = 0, + PC_Pokemon = 1, + PC_Pokedex = 2, + PC_HallOfFame = 3, + PC_All = 4, + PC_End = 5, + }; + static const QStringList PCTypeStr; + + MapEffect(const Pokemod& par, const unsigned _id); + MapEffect(const Pokemod& par, const MapEffect& e, const unsigned _id); + MapEffect(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save(const QString& map) const throw(Exception); + + void setName(const QString& n); + void setCoordinate(const unsigned x, const unsigned y); + void setCoordinateX(const unsigned x); + void setCoordinateY(const unsigned y); + void setExistFlag(const unsigned f, const unsigned s); + void setExistFlagFlag(const unsigned f); + void setExistFlagStatus(const unsigned s); + void setSkin(const QString& s) throw(Exception); + void setEffect(const unsigned e) throw(BoundsException); + void setVal1(const unsigned v1) throw(UnusedException); + void setVal2(const unsigned v2) throw(Exception); + void setDirection(const unsigned d) throw(BoundsException); + void setIsGhost(const bool i); + void setCanMove(const bool c); + void setDialog(const unsigned d) throw(BoundsException); + + QString getName() const; + Point getCoordinate() const; + Flag getExistFlag() const; + QString getSkin() const; + unsigned getEffect() const; + unsigned getVal1() const; + unsigned getVal2() const; + unsigned getDirection() const; + bool getIsGhost() const; + bool getCanMove() const; + unsigned getDialog() const; + + MapEffect& operator=(const MapEffect& rhs); + private: + bool validate() const; + + QString name; + Point coordinate; + Flag existFlag; + QString skin; + unsigned effect; + unsigned val1; + unsigned val2; + unsigned direction; + bool isGhost; + bool canMove; + unsigned dialog; +}; #endif diff --git a/pokemod/MapTrainer.cpp b/pokemod/MapTrainer.cpp index b9846b33..14a964fc 100644 --- a/pokemod/MapTrainer.cpp +++ b/pokemod/MapTrainer.cpp @@ -30,7 +30,7 @@ #include "Dialog.h" #include "MapTrainer.h" -PokeMod::MapTrainer::MapTrainer(const Pokemod& par, const unsigned _id) : +MapTrainer::MapTrainer(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), coordinate(0, 0), @@ -47,19 +47,19 @@ PokeMod::MapTrainer::MapTrainer(const Pokemod& par, const unsigned _id) : { } -PokeMod::MapTrainer::MapTrainer(const Pokemod& par, const MapTrainer& t, const unsigned _id) : +MapTrainer::MapTrainer(const Pokemod& par, const MapTrainer& t, const unsigned _id) : Object(par, _id) { *this = t; } -PokeMod::MapTrainer::MapTrainer(const Pokemod& par, const QString& fname, const unsigned _id) : +MapTrainer::MapTrainer(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::MapTrainer::validate() const +bool MapTrainer::validate() const { bool valid = true; pokemod.validationMsg(QString("------Trainer \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -134,7 +134,7 @@ bool PokeMod::MapTrainer::validate() const return valid; } -unsigned PokeMod::MapTrainer::getNewId() const +unsigned MapTrainer::getNewId() const { unsigned i = 0; for (; i < getTeamMemberCount(); ++i) @@ -145,7 +145,7 @@ unsigned PokeMod::MapTrainer::getNewId() const return UINT_MAX; } -void PokeMod::MapTrainer::load(const QString& fname, const unsigned _id) throw(Exception) +void MapTrainer::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -181,7 +181,7 @@ void PokeMod::MapTrainer::load(const QString& fname, const unsigned _id) throw(E } } -void PokeMod::MapTrainer::save(const QString& map) const throw(Exception) +void MapTrainer::save(const QString& map) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -205,187 +205,187 @@ void PokeMod::MapTrainer::save(const QString& map) const throw(Exception) i.next().save(map, name); } -void PokeMod::MapTrainer::setName(const QString& n) +void MapTrainer::setName(const QString& n) { name = n; } -void PokeMod::MapTrainer::setCoordinate(const unsigned x, const unsigned y) +void MapTrainer::setCoordinate(const unsigned x, const unsigned y) { coordinate.set(x, y); } -void PokeMod::MapTrainer::setCoordinateX(const unsigned x) +void MapTrainer::setCoordinateX(const unsigned x) { coordinate.setX(x); } -void PokeMod::MapTrainer::setCoordinateY(const unsigned y) +void MapTrainer::setCoordinateY(const unsigned y) { coordinate.setY(y); } -void PokeMod::MapTrainer::setSkin(const QString& s) throw(OpenException) +void MapTrainer::setSkin(const QString& s) throw(OpenException) { if (!QFile::exists(QString("%1/image/skin/%2.png").arg(pokemod.getPath()).arg(s))) throw(OpenException("MapTrainer", QString("%1/image/skin/%2.png").arg(pokemod.getPath()).arg(s))); skin = s; } -void PokeMod::MapTrainer::setSight(const unsigned s) +void MapTrainer::setSight(const unsigned s) { sight = s; } -void PokeMod::MapTrainer::setDirection(const unsigned d) throw(BoundsException) +void MapTrainer::setDirection(const unsigned d) throw(BoundsException) { if (D_End_None <= d) throw(BoundsException("MapTrainer", "direction")); direction = d; } -void PokeMod::MapTrainer::setNumFight(const unsigned n) throw(BoundsException) +void MapTrainer::setNumFight(const unsigned n) throw(BoundsException) { if (!n || (pokemod.getRules().getMaxFight() < n)) throw(BoundsException("MapTrainer", "numFight")); numFight = n; } -void PokeMod::MapTrainer::setAI(const QString& a) throw(OpenException) +void MapTrainer::setAI(const QString& a) throw(OpenException) { if (!QFile::exists(QString("%1/ai/%2.pai").arg(pokemod.getPath()).arg(a))) throw(OpenException("MapTrainer", QString("%1/ai/%2.pai").arg(pokemod.getPath()).arg(a))); ai = a; } -void PokeMod::MapTrainer::setAppearFlag(const unsigned f, const unsigned s) +void MapTrainer::setAppearFlag(const unsigned f, const unsigned s) { appearFlag.set(f, s); } -void PokeMod::MapTrainer::setAppearFlagFlag(const unsigned f) +void MapTrainer::setAppearFlagFlag(const unsigned f) { appearFlag.setFlag(f); } -void PokeMod::MapTrainer::setAppearFlagStatus(const unsigned s) +void MapTrainer::setAppearFlagStatus(const unsigned s) { appearFlag.setStatus(s); } -void PokeMod::MapTrainer::setOverworldDialog(const unsigned o) throw(BoundsException) +void MapTrainer::setOverworldDialog(const unsigned o) throw(BoundsException) { if (pokemod.getDialogIndex(o) == UINT_MAX) throw(BoundsException("MapTrainer", "overworldDialog")); overworldDialog = o; } -void PokeMod::MapTrainer::setWinDialog(const unsigned w) throw(BoundsException) +void MapTrainer::setWinDialog(const unsigned w) throw(BoundsException) { if (pokemod.getDialogIndex(w) == UINT_MAX) throw(BoundsException("MapTrainer", "winDialog")); winDialog = w; } -void PokeMod::MapTrainer::setLoseDialog(const unsigned l) throw(BoundsException) +void MapTrainer::setLoseDialog(const unsigned l) throw(BoundsException) { if (pokemod.getDialogIndex(l) == UINT_MAX) throw(BoundsException("MapTrainer", "loseDialog")); loseDialog = l; } -void PokeMod::MapTrainer::setLeadTeamMember(const unsigned l) throw(BoundsException) +void MapTrainer::setLeadTeamMember(const unsigned l) throw(BoundsException) { if (getTeamMemberCount() <= l) throw(BoundsException("MapTrainer", "leadTeamMember")); leadTeamMember = l; } -QString PokeMod::MapTrainer::getName() const +QString MapTrainer::getName() const { return name; } -Point PokeMod::MapTrainer::getCoordinate() const +Point MapTrainer::getCoordinate() const { return coordinate; } -QString PokeMod::MapTrainer::getSkin() const +QString MapTrainer::getSkin() const { return skin; } -unsigned PokeMod::MapTrainer::getSight() const +unsigned MapTrainer::getSight() const { return sight; } -unsigned PokeMod::MapTrainer::getDirection() const +unsigned MapTrainer::getDirection() const { return direction; } -unsigned PokeMod::MapTrainer::getNumFight() const +unsigned MapTrainer::getNumFight() const { return numFight; } -QString PokeMod::MapTrainer::getAI() const +QString MapTrainer::getAI() const { return ai; } -Flag PokeMod::MapTrainer::getAppearFlag() const +Flag MapTrainer::getAppearFlag() const { return appearFlag; } -unsigned PokeMod::MapTrainer::getOverworldDialog() const +unsigned MapTrainer::getOverworldDialog() const { return overworldDialog; } -unsigned PokeMod::MapTrainer::getWinDialog() const +unsigned MapTrainer::getWinDialog() const { return winDialog; } -unsigned PokeMod::MapTrainer::getLoseDialog() const +unsigned MapTrainer::getLoseDialog() const { return loseDialog; } -unsigned PokeMod::MapTrainer::getLeadTeamMember() const +unsigned MapTrainer::getLeadTeamMember() const { return leadTeamMember; } -const PokeMod::MapTrainerTeamMember& PokeMod::MapTrainer::getTeamMember(const unsigned i) const throw(IndexException) +const MapTrainerTeamMember& MapTrainer::getTeamMember(const unsigned i) const throw(IndexException) { if (getTeamMemberCount() <= i) throw(IndexException("MapTrainer")); return teamMembers.at(i); } -PokeMod::MapTrainerTeamMember& PokeMod::MapTrainer::getTeamMember(const unsigned i) throw(IndexException) +MapTrainerTeamMember& MapTrainer::getTeamMember(const unsigned i) throw(IndexException) { if (getTeamMemberCount() <= i) throw(IndexException("MapTrainer")); return teamMembers[i]; } -const PokeMod::MapTrainerTeamMember& PokeMod::MapTrainer::getTeamMemberByID(const unsigned i) const throw(IndexException) +const MapTrainerTeamMember& MapTrainer::getTeamMemberByID(const unsigned i) const throw(IndexException) { return getTeamMember(getTeamMemberIndex(i)); } -PokeMod::MapTrainerTeamMember& PokeMod::MapTrainer::getTeamMemberByID(const unsigned i) throw(IndexException) +MapTrainerTeamMember& MapTrainer::getTeamMemberByID(const unsigned i) throw(IndexException) { return getTeamMember(getTeamMemberIndex(i)); } -unsigned PokeMod::MapTrainer::getTeamMemberIndex(const unsigned _id) const +unsigned MapTrainer::getTeamMemberIndex(const unsigned _id) const { for (unsigned i = 0; i < getTeamMemberCount(); ++i) { @@ -395,37 +395,37 @@ unsigned PokeMod::MapTrainer::getTeamMemberIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::MapTrainer::getTeamMemberCount() const +unsigned MapTrainer::getTeamMemberCount() const { return teamMembers.size(); } -PokeMod::MapTrainerTeamMember& PokeMod::MapTrainer::newTeamMember() +MapTrainerTeamMember& MapTrainer::newTeamMember() { teamMembers.append(MapTrainerTeamMember(pokemod, getNewId())); return teamMembers[getTeamMemberCount() - 1]; } -PokeMod::MapTrainerTeamMember& PokeMod::MapTrainer::newTeamMember(const QString& fname) +MapTrainerTeamMember& MapTrainer::newTeamMember(const QString& fname) { teamMembers.append(MapTrainerTeamMember(pokemod, fname, getNewId())); return teamMembers[getTeamMemberCount() - 1]; } -PokeMod::MapTrainerTeamMember& PokeMod::MapTrainer::newTeamMember(const MapTrainerTeamMember& p) +MapTrainerTeamMember& MapTrainer::newTeamMember(const MapTrainerTeamMember& p) { teamMembers.append(MapTrainerTeamMember(pokemod, p, getNewId())); return teamMembers[getTeamMemberCount() - 1]; } -void PokeMod::MapTrainer::deleteTeamMember(const unsigned i) throw(IndexException) +void MapTrainer::deleteTeamMember(const unsigned i) throw(IndexException) { if (getTeamMemberCount() <= i) throw(IndexException("MapTrainer")); teamMembers.removeAt(i); } -PokeMod::MapTrainer& PokeMod::MapTrainer::operator=(const MapTrainer& rhs) +MapTrainer& MapTrainer::operator=(const MapTrainer& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/MapTrainer.h b/pokemod/MapTrainer.h index 8ee93b56..c092770c 100644 --- a/pokemod/MapTrainer.h +++ b/pokemod/MapTrainer.h @@ -31,83 +31,80 @@ #include "Object.h" #include "MapTrainerTeamMember.h" -namespace PokeMod +class Pokemod; + +class MapTrainer : public Object { - class Pokemod; - - class MapTrainer : public Object - { - public: - MapTrainer(const Pokemod& par, const unsigned _id); - MapTrainer(const Pokemod& par, const MapTrainer& t, const unsigned _id); - MapTrainer(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save(const QString& map) const throw(Exception); - - void setName(const QString& n); - void setCoordinate(const unsigned x, const unsigned y); - void setCoordinateX(const unsigned x); - void setCoordinateY(const unsigned y); - void setSkin(const QString& s) throw(OpenException); - void setSight(const unsigned s); - void setDirection(const unsigned d) throw(BoundsException); - void setNumFight(const unsigned n) throw(BoundsException); - void setAI(const QString& a) throw(OpenException); - void setAppearFlag(const unsigned f, const unsigned s); - void setAppearFlagFlag(const unsigned f); - void setAppearFlagStatus(const unsigned s); - void setOverworldDialog(const unsigned o) throw(BoundsException); - void setWinDialog(const unsigned w) throw(BoundsException); - void setLoseDialog(const unsigned l) throw(BoundsException); - void setLeadTeamMember(const unsigned l) throw(BoundsException); - - QString getName() const; - Point getCoordinate() const; - QString getSkin() const; - bool getSkinExists() const; - unsigned getSight() const; - unsigned getDirection() const; - unsigned getNumFight() const; - bool getAIExists() const; - QString getAI() const; - Flag getAppearFlag() const; - unsigned getOverworldDialog() const; - unsigned getWinDialog() const; - unsigned getLoseDialog() const; - unsigned getLeadTeamMember() const; - - const MapTrainerTeamMember& getTeamMember(const unsigned i) const throw(IndexException); - MapTrainerTeamMember& getTeamMember(const unsigned i) throw(IndexException); - const MapTrainerTeamMember& getTeamMemberByID(const unsigned i) const throw(IndexException); - MapTrainerTeamMember& getTeamMemberByID(const unsigned i) throw(IndexException); - unsigned getTeamMemberIndex(const unsigned _id) const; - unsigned getTeamMemberCount() const; - MapTrainerTeamMember& newTeamMember(); - MapTrainerTeamMember& newTeamMember(const QString& fname); - MapTrainerTeamMember& newTeamMember(const MapTrainerTeamMember& t); - void deleteTeamMember(const unsigned i) throw(IndexException); - - MapTrainer& operator=(const MapTrainer& rhs); - private: - bool validate() const; - unsigned getNewId() const; - - QString name; - Point coordinate; - QString skin; - unsigned sight; - unsigned direction; - unsigned numFight; - QString ai; - Flag appearFlag; - unsigned overworldDialog; - unsigned winDialog; - unsigned loseDialog; - unsigned leadTeamMember; - - QList<MapTrainerTeamMember> teamMembers; - }; -} + public: + MapTrainer(const Pokemod& par, const unsigned _id); + MapTrainer(const Pokemod& par, const MapTrainer& t, const unsigned _id); + MapTrainer(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save(const QString& map) const throw(Exception); + + void setName(const QString& n); + void setCoordinate(const unsigned x, const unsigned y); + void setCoordinateX(const unsigned x); + void setCoordinateY(const unsigned y); + void setSkin(const QString& s) throw(OpenException); + void setSight(const unsigned s); + void setDirection(const unsigned d) throw(BoundsException); + void setNumFight(const unsigned n) throw(BoundsException); + void setAI(const QString& a) throw(OpenException); + void setAppearFlag(const unsigned f, const unsigned s); + void setAppearFlagFlag(const unsigned f); + void setAppearFlagStatus(const unsigned s); + void setOverworldDialog(const unsigned o) throw(BoundsException); + void setWinDialog(const unsigned w) throw(BoundsException); + void setLoseDialog(const unsigned l) throw(BoundsException); + void setLeadTeamMember(const unsigned l) throw(BoundsException); + + QString getName() const; + Point getCoordinate() const; + QString getSkin() const; + bool getSkinExists() const; + unsigned getSight() const; + unsigned getDirection() const; + unsigned getNumFight() const; + bool getAIExists() const; + QString getAI() const; + Flag getAppearFlag() const; + unsigned getOverworldDialog() const; + unsigned getWinDialog() const; + unsigned getLoseDialog() const; + unsigned getLeadTeamMember() const; + + const MapTrainerTeamMember& getTeamMember(const unsigned i) const throw(IndexException); + MapTrainerTeamMember& getTeamMember(const unsigned i) throw(IndexException); + const MapTrainerTeamMember& getTeamMemberByID(const unsigned i) const throw(IndexException); + MapTrainerTeamMember& getTeamMemberByID(const unsigned i) throw(IndexException); + unsigned getTeamMemberIndex(const unsigned _id) const; + unsigned getTeamMemberCount() const; + MapTrainerTeamMember& newTeamMember(); + MapTrainerTeamMember& newTeamMember(const QString& fname); + MapTrainerTeamMember& newTeamMember(const MapTrainerTeamMember& t); + void deleteTeamMember(const unsigned i) throw(IndexException); + + MapTrainer& operator=(const MapTrainer& rhs); + private: + bool validate() const; + unsigned getNewId() const; + + QString name; + Point coordinate; + QString skin; + unsigned sight; + unsigned direction; + unsigned numFight; + QString ai; + Flag appearFlag; + unsigned overworldDialog; + unsigned winDialog; + unsigned loseDialog; + unsigned leadTeamMember; + + QList<MapTrainerTeamMember> teamMembers; +}; #endif diff --git a/pokemod/MapTrainerTeamMember.cpp b/pokemod/MapTrainerTeamMember.cpp index 89097ef6..8097766f 100644 --- a/pokemod/MapTrainerTeamMember.cpp +++ b/pokemod/MapTrainerTeamMember.cpp @@ -27,7 +27,7 @@ #include "Species.h" #include "MapTrainerTeamMember.h" -PokeMod::MapTrainerTeamMember::MapTrainerTeamMember(const Pokemod& par, const unsigned _id) : +MapTrainerTeamMember::MapTrainerTeamMember(const Pokemod& par, const unsigned _id) : Object(par, _id), species(UINT_MAX), level(UINT_MAX), @@ -35,13 +35,13 @@ PokeMod::MapTrainerTeamMember::MapTrainerTeamMember(const Pokemod& par, const un { } -PokeMod::MapTrainerTeamMember::MapTrainerTeamMember(const Pokemod& par, const QString& fname, const unsigned _id) : +MapTrainerTeamMember::MapTrainerTeamMember(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::MapTrainerTeamMember::validate() const +bool MapTrainerTeamMember::validate() const { bool valid = true; pokemod.validationMsg(QString("---------Team Member with id %1---").arg(id), Pokemod::V_Msg); @@ -92,7 +92,7 @@ bool PokeMod::MapTrainerTeamMember::validate() const return valid; } -void PokeMod::MapTrainerTeamMember::load(const QString& fname, const unsigned _id) throw(Exception) +void MapTrainerTeamMember::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -114,7 +114,7 @@ void PokeMod::MapTrainerTeamMember::load(const QString& fname, const unsigned _i } } -void PokeMod::MapTrainerTeamMember::save(const QString& map, const QString& trainer) const throw(Exception) +void MapTrainerTeamMember::save(const QString& map, const QString& trainer) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -127,21 +127,21 @@ void PokeMod::MapTrainerTeamMember::save(const QString& map, const QString& trai ini.save(QString("%1/map/%2/trainer/%3/team/%4.pini").arg(pokemod.getPath()).arg(map).arg(trainer).arg(id)); } -void PokeMod::MapTrainerTeamMember::setSpecies(const unsigned s) throw(BoundsException) +void MapTrainerTeamMember::setSpecies(const unsigned s) throw(BoundsException) { if (pokemod.getSpeciesIndex(s) == UINT_MAX) throw(BoundsException("MapTrainerTeamMember", "species")); species = s; } -void PokeMod::MapTrainerTeamMember::setLevel(const unsigned l) throw(BoundsException) +void MapTrainerTeamMember::setLevel(const unsigned l) throw(BoundsException) { if (pokemod.getRules().getMaxLevel() < l) throw(BoundsException("MapTrainerTeamMember", "level")); level = l; } -void PokeMod::MapTrainerTeamMember::setItem(const unsigned itm, const bool it) throw(Exception) +void MapTrainerTeamMember::setItem(const unsigned itm, const bool it) throw(Exception) { if (pokemod.getItemIndex(itm) == UINT_MAX) throw(BoundsException("MpTrainerPokemon", "item")); @@ -162,29 +162,29 @@ void PokeMod::MapTrainerTeamMember::setItem(const unsigned itm, const bool it) t items.append(itm); } -void PokeMod::MapTrainerTeamMember::setNature(const unsigned n) throw(BoundsException) +void MapTrainerTeamMember::setNature(const unsigned n) throw(BoundsException) { if (!pokemod.getRules().getNatureAllowed() || (pokemod.getNatureIndex(n) == UINT_MAX)) throw(BoundsException("MapTrainerTeamMember", "nature")); nature = n; } -unsigned PokeMod::MapTrainerTeamMember::getSpecies() const +unsigned MapTrainerTeamMember::getSpecies() const { return species; } -unsigned PokeMod::MapTrainerTeamMember::getLevel() const +unsigned MapTrainerTeamMember::getLevel() const { return level; } -unsigned PokeMod::MapTrainerTeamMember::getNature() const +unsigned MapTrainerTeamMember::getNature() const { return nature; } -bool PokeMod::MapTrainerTeamMember::getItem(const unsigned itm) const +bool MapTrainerTeamMember::getItem(const unsigned itm) const { for (QListIterator<unsigned> i(items); i.hasNext(); ) { @@ -194,7 +194,7 @@ bool PokeMod::MapTrainerTeamMember::getItem(const unsigned itm) const return false; } -PokeMod::MapTrainerTeamMember& PokeMod::MapTrainerTeamMember::operator=(const MapTrainerTeamMember& rhs) +MapTrainerTeamMember& MapTrainerTeamMember::operator=(const MapTrainerTeamMember& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/MapTrainerTeamMember.h b/pokemod/MapTrainerTeamMember.h index 2da483ff..95c4463b 100644 --- a/pokemod/MapTrainerTeamMember.h +++ b/pokemod/MapTrainerTeamMember.h @@ -27,39 +27,36 @@ #include "../general/Exception.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class MapTrainerTeamMember : public Object { - class Pokemod; - - class MapTrainerTeamMember : public Object - { - public: - MapTrainerTeamMember(const Pokemod& par, const unsigned _id); - MapTrainerTeamMember(const Pokemod& par, const MapTrainerTeamMember& p, const unsigned _id); - MapTrainerTeamMember(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save(const QString& map, const QString& trainer) const throw(Exception); - - void setSpecies(const unsigned s) throw(BoundsException); - void setLevel(const unsigned l) throw(BoundsException); - void setNature(const unsigned n) throw(BoundsException); - void setItem(const unsigned itm, const bool it) throw(Exception); - - unsigned getSpecies() const; - unsigned getLevel() const; - unsigned getNature() const; - bool getItem(const unsigned itm) const; - - MapTrainerTeamMember& operator=(const MapTrainerTeamMember& p); - private: - bool validate() const; - - unsigned species; - unsigned level; - unsigned nature; - QList<unsigned> items; - }; -} + public: + MapTrainerTeamMember(const Pokemod& par, const unsigned _id); + MapTrainerTeamMember(const Pokemod& par, const MapTrainerTeamMember& p, const unsigned _id); + MapTrainerTeamMember(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save(const QString& map, const QString& trainer) const throw(Exception); + + void setSpecies(const unsigned s) throw(BoundsException); + void setLevel(const unsigned l) throw(BoundsException); + void setNature(const unsigned n) throw(BoundsException); + void setItem(const unsigned itm, const bool it) throw(Exception); + + unsigned getSpecies() const; + unsigned getLevel() const; + unsigned getNature() const; + bool getItem(const unsigned itm) const; + + MapTrainerTeamMember& operator=(const MapTrainerTeamMember& p); + private: + bool validate() const; + + unsigned species; + unsigned level; + unsigned nature; + QList<unsigned> items; +}; #endif diff --git a/pokemod/MapWarp.cpp b/pokemod/MapWarp.cpp index dc48c64e..733b66c5 100644 --- a/pokemod/MapWarp.cpp +++ b/pokemod/MapWarp.cpp @@ -25,9 +25,9 @@ #include "Map.h" #include "MapWarp.h" -const QStringList PokeMod::MapWarp::TypeStr = QStringList() << "Door/Stair" << "Warp Pad" << "Hole" << "Boundary"; +const QStringList MapWarp::TypeStr = QStringList() << "Door/Stair" << "Warp Pad" << "Hole" << "Boundary"; -PokeMod::MapWarp::MapWarp(const Pokemod& par, const unsigned _id) : +MapWarp::MapWarp(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), coordinate(0, 0), @@ -45,19 +45,19 @@ PokeMod::MapWarp::MapWarp(const Pokemod& par, const unsigned _id) : from[i] = false; } -PokeMod::MapWarp::MapWarp(const Pokemod& par, const MapWarp& w, const unsigned _id) : +MapWarp::MapWarp(const Pokemod& par, const MapWarp& w, const unsigned _id) : Object(par, _id) { *this = w; } -PokeMod::MapWarp::MapWarp(const Pokemod& par, const QString& fname, const unsigned _id) : +MapWarp::MapWarp(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::MapWarp::validate() const +bool MapWarp::validate() const { bool valid = true; pokemod.validationMsg(QString("------Warp \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -102,7 +102,7 @@ bool PokeMod::MapWarp::validate() const return valid; } -void PokeMod::MapWarp::load(const QString& fname, const unsigned _id) throw(Exception) +void MapWarp::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -132,7 +132,7 @@ void PokeMod::MapWarp::load(const QString& fname, const unsigned _id) throw(Exce ini.getValue("dialog", dialog); } -void PokeMod::MapWarp::save(const QString& map) const throw(Exception) +void MapWarp::save(const QString& map) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -155,63 +155,63 @@ void PokeMod::MapWarp::save(const QString& map) const throw(Exception) ini.save(QString("%1/map/%2/warp/%3.pini").arg(pokemod.getPath()).arg(map).arg(name)); } -void PokeMod::MapWarp::setName(const QString& n) +void MapWarp::setName(const QString& n) { name = n; } -void PokeMod::MapWarp::setCoordinate(const unsigned x, const unsigned y) +void MapWarp::setCoordinate(const unsigned x, const unsigned y) { coordinate.set(x, y); } -void PokeMod::MapWarp::setCoordinateX(const unsigned x) +void MapWarp::setCoordinateX(const unsigned x) { coordinate.setX(x); } -void PokeMod::MapWarp::setCoordinateY(const unsigned y) +void MapWarp::setCoordinateY(const unsigned y) { coordinate.setY(y); } -void PokeMod::MapWarp::setFrom(const unsigned d, const bool f) throw(BoundsException) +void MapWarp::setFrom(const unsigned d, const bool f) throw(BoundsException) { if (D_End <= d) throw(BoundsException("MapWarp", "direction")); from[d] = f; } -void PokeMod::MapWarp::setDirectionOut(const unsigned d) throw(BoundsException) +void MapWarp::setDirectionOut(const unsigned d) throw(BoundsException) { if (D_End <= d) throw(BoundsException("MapWarp", "direction")); directionOut = d; } -void PokeMod::MapWarp::setWarpType(const unsigned w) throw(BoundsException) +void MapWarp::setWarpType(const unsigned w) throw(BoundsException) { if (End <= w) throw(BoundsException("MapWarp", "warpType")); warpType = w; } -void PokeMod::MapWarp::setIsBiking(const bool i) +void MapWarp::setIsBiking(const bool i) { isBiking = i; } -void PokeMod::MapWarp::setIsFlash(const bool i) +void MapWarp::setIsFlash(const bool i) { isFlash = i; } -void PokeMod::MapWarp::setIsFoggy(const bool i) +void MapWarp::setIsFoggy(const bool i) { isFoggy = i; } -void PokeMod::MapWarp::setToMap(const unsigned t) throw(BoundsException) +void MapWarp::setToMap(const unsigned t) throw(BoundsException) { if (pokemod.getMapIndex(t) == UINT_MAX) throw(BoundsException("MapWarp", "toMap")); @@ -219,7 +219,7 @@ void PokeMod::MapWarp::setToMap(const unsigned t) throw(BoundsException) toWarp = UINT_MAX; } -void PokeMod::MapWarp::setToWarp(const unsigned t) throw(BoundsException) +void MapWarp::setToWarp(const unsigned t) throw(BoundsException) { if (pokemod.getMapIndex(toMap) == UINT_MAX) throw(BoundsException("MapWarp", "toMap")); @@ -227,91 +227,91 @@ void PokeMod::MapWarp::setToWarp(const unsigned t) throw(BoundsException) throw(BoundsException("MapWarp", "toWarp")); } -void PokeMod::MapWarp::setWorkingFlag(const unsigned f, const unsigned s) +void MapWarp::setWorkingFlag(const unsigned f, const unsigned s) { workingFlag.set(f, s); } -void PokeMod::MapWarp::setWorkingFlagFlag(const unsigned f) +void MapWarp::setWorkingFlagFlag(const unsigned f) { workingFlag.setFlag(f); } -void PokeMod::MapWarp::setWorkingFlagStatus(const unsigned s) +void MapWarp::setWorkingFlagStatus(const unsigned s) { workingFlag.setStatus(s); } -void PokeMod::MapWarp::setDialog(const unsigned d) throw(BoundsException) +void MapWarp::setDialog(const unsigned d) throw(BoundsException) { if (pokemod.getDialogIndex(d) == UINT_MAX) throw(BoundsException("MapWarp", "dialog")); dialog = d; } -QString PokeMod::MapWarp::getName() const +QString MapWarp::getName() const { return name; } -Point PokeMod::MapWarp::getCoordinate() const +Point MapWarp::getCoordinate() const { return coordinate; } -bool PokeMod::MapWarp::getFrom(const unsigned d) const throw(BoundsException) +bool MapWarp::getFrom(const unsigned d) const throw(BoundsException) { if (D_End <= d) throw(BoundsException("MapWarp", "direction")); return from[d]; } -unsigned PokeMod::MapWarp::getDirectionOut() const +unsigned MapWarp::getDirectionOut() const { return directionOut; } -unsigned PokeMod::MapWarp::getWarpType() const +unsigned MapWarp::getWarpType() const { return warpType; } -bool PokeMod::MapWarp::getIsBiking() const +bool MapWarp::getIsBiking() const { return isBiking; } -bool PokeMod::MapWarp::getIsFlash() const +bool MapWarp::getIsFlash() const { return isFlash; } -bool PokeMod::MapWarp::getIsFoggy() const +bool MapWarp::getIsFoggy() const { return isFoggy; } -unsigned PokeMod::MapWarp::getToMap() const +unsigned MapWarp::getToMap() const { return toMap; } -unsigned PokeMod::MapWarp::getToWarp() const +unsigned MapWarp::getToWarp() const { return toWarp; } -Flag PokeMod::MapWarp::getWorkingFlag() const +Flag MapWarp::getWorkingFlag() const { return workingFlag; } -unsigned PokeMod::MapWarp::getDialog() const +unsigned MapWarp::getDialog() const { return dialog; } -PokeMod::MapWarp& PokeMod::MapWarp::operator=(const MapWarp& rhs) +MapWarp& MapWarp::operator=(const MapWarp& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/MapWarp.h b/pokemod/MapWarp.h index 8abc3ffd..7ce03f51 100644 --- a/pokemod/MapWarp.h +++ b/pokemod/MapWarp.h @@ -30,77 +30,74 @@ #include "../general/Point.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class MapWarp : public Object { - class Pokemod; - - class MapWarp : public Object - { - public: - enum - { - DoorStair = 0, - WarpPad = 1, - Hole = 2, - Boundary = 3, - End = 4 - }; - static const QStringList TypeStr; - - MapWarp(const Pokemod& par, const unsigned _id); - MapWarp(const Pokemod& par, const MapWarp& w, const unsigned _id); - MapWarp(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save(const QString& map) const throw(Exception); - - void setName(const QString& n); - void setCoordinate(const unsigned x, const unsigned y); - void setCoordinateX(const unsigned x); - void setCoordinateY(const unsigned y); - void setFrom(const unsigned d, const bool f) throw(BoundsException); - void setDirectionOut(const unsigned d) throw(BoundsException); - void setWarpType(const unsigned w) throw(BoundsException); - void setIsBiking(const bool i); - void setIsFlash(const bool i); - void setIsFoggy(const bool i); - void setToMap(const unsigned t) throw(BoundsException); - void setToWarp(const unsigned t) throw(BoundsException); - void setWorkingFlag(const unsigned f, const unsigned s); - void setWorkingFlagFlag(const unsigned f); - void setWorkingFlagStatus(const unsigned s); - void setDialog(const unsigned d) throw(BoundsException); - - QString getName() const; - Point getCoordinate() const; - bool getFrom(const unsigned d) const throw(BoundsException); - unsigned getDirectionOut() const; - unsigned getWarpType() const; - bool getIsBiking() const; - bool getIsFlash() const; - bool getIsFoggy() const; - unsigned getToMap() const; - unsigned getToWarp() const; - Flag getWorkingFlag() const; - unsigned getDialog() const; - - MapWarp& operator=(const MapWarp& rhs); - private: - bool validate() const; - - QString name; - Point coordinate; - bool from[D_End]; - unsigned directionOut; - unsigned warpType; - bool isBiking; - bool isFlash; - bool isFoggy; - unsigned toMap; - unsigned toWarp; - Flag workingFlag; - unsigned dialog; - }; -} + public: + enum + { + DoorStair = 0, + WarpPad = 1, + Hole = 2, + Boundary = 3, + End = 4 + }; + static const QStringList TypeStr; + + MapWarp(const Pokemod& par, const unsigned _id); + MapWarp(const Pokemod& par, const MapWarp& w, const unsigned _id); + MapWarp(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save(const QString& map) const throw(Exception); + + void setName(const QString& n); + void setCoordinate(const unsigned x, const unsigned y); + void setCoordinateX(const unsigned x); + void setCoordinateY(const unsigned y); + void setFrom(const unsigned d, const bool f) throw(BoundsException); + void setDirectionOut(const unsigned d) throw(BoundsException); + void setWarpType(const unsigned w) throw(BoundsException); + void setIsBiking(const bool i); + void setIsFlash(const bool i); + void setIsFoggy(const bool i); + void setToMap(const unsigned t) throw(BoundsException); + void setToWarp(const unsigned t) throw(BoundsException); + void setWorkingFlag(const unsigned f, const unsigned s); + void setWorkingFlagFlag(const unsigned f); + void setWorkingFlagStatus(const unsigned s); + void setDialog(const unsigned d) throw(BoundsException); + + QString getName() const; + Point getCoordinate() const; + bool getFrom(const unsigned d) const throw(BoundsException); + unsigned getDirectionOut() const; + unsigned getWarpType() const; + bool getIsBiking() const; + bool getIsFlash() const; + bool getIsFoggy() const; + unsigned getToMap() const; + unsigned getToWarp() const; + Flag getWorkingFlag() const; + unsigned getDialog() const; + + MapWarp& operator=(const MapWarp& rhs); + private: + bool validate() const; + + QString name; + Point coordinate; + bool from[D_End]; + unsigned directionOut; + unsigned warpType; + bool isBiking; + bool isFlash; + bool isFoggy; + unsigned toMap; + unsigned toWarp; + Flag workingFlag; + unsigned dialog; +}; #endif diff --git a/pokemod/MapWildList.cpp b/pokemod/MapWildList.cpp index 8c85c72b..b55e06c2 100644 --- a/pokemod/MapWildList.cpp +++ b/pokemod/MapWildList.cpp @@ -31,9 +31,9 @@ #include "ItemEffect.h" #include "MapWildList.h" -const QStringList PokeMod::MapWildList::ControlStr = QStringList() << "Grass" << "Surfing" << "Fishing" << "Dive" << "Headbutt" << "Rock Smash"; +const QStringList MapWildList::ControlStr = QStringList() << "Grass" << "Surfing" << "Fishing" << "Dive" << "Headbutt" << "Rock Smash"; -PokeMod::MapWildList::MapWildList(const Pokemod& par, const unsigned _id) : +MapWildList::MapWildList(const Pokemod& par, const unsigned _id) : Object(par, _id), control(UINT_MAX), value(INT_MAX), @@ -41,19 +41,19 @@ PokeMod::MapWildList::MapWildList(const Pokemod& par, const unsigned _id) : { } -PokeMod::MapWildList::MapWildList(const Pokemod& par, const MapWildList& w, const unsigned _id) : +MapWildList::MapWildList(const Pokemod& par, const MapWildList& w, const unsigned _id) : Object(par, _id) { *this = w; } -PokeMod::MapWildList::MapWildList(const Pokemod& par, const QString& fname, const unsigned _id) : +MapWildList::MapWildList(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::MapWildList::validate() const +bool MapWildList::validate() const { bool valid = true; pokemod.validationMsg(QString("------Wild List with id %1---").arg(id), Pokemod::V_Msg); @@ -117,7 +117,7 @@ bool PokeMod::MapWildList::validate() const return valid; } -unsigned PokeMod::MapWildList::getNewId() const +unsigned MapWildList::getNewId() const { unsigned i = 0; for (; (i < getEncounterCount()) && (getEncounterIndex(i) != UINT_MAX); ++i) @@ -125,7 +125,7 @@ unsigned PokeMod::MapWildList::getNewId() const return i; } -void PokeMod::MapWildList::load(const QString& fname, const unsigned _id) throw(Exception) +void MapWildList::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -156,7 +156,7 @@ void PokeMod::MapWildList::load(const QString& fname, const unsigned _id) throw( } } -void PokeMod::MapWildList::save(const QString& map) const throw(Exception) +void MapWildList::save(const QString& map) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -171,19 +171,19 @@ void PokeMod::MapWildList::save(const QString& map) const throw(Exception) i.next().save(map, id); } -void PokeMod::MapWildList::setControl(const unsigned c) throw(BoundsException) +void MapWildList::setControl(const unsigned c) throw(BoundsException) { if (End <= c) throw(BoundsException("MapWildList", "control")); control = c; } -void PokeMod::MapWildList::setValue(const unsigned v) +void MapWildList::setValue(const unsigned v) { value = v; } -void PokeMod::MapWildList::setTime(const unsigned ts, const bool t) throw(Exception) +void MapWildList::setTime(const unsigned ts, const bool t) throw(Exception) { for (QMutableListIterator<unsigned> i(times); i.hasNext(); ) { @@ -200,22 +200,22 @@ void PokeMod::MapWildList::setTime(const unsigned ts, const bool t) throw(Except times.append(ts); } -void PokeMod::MapWildList::setScope(const unsigned s) +void MapWildList::setScope(const unsigned s) { scope = s; } -unsigned PokeMod::MapWildList::getControl() const +unsigned MapWildList::getControl() const { return control; } -int PokeMod::MapWildList::getValue() const +int MapWildList::getValue() const { return value; } -bool PokeMod::MapWildList::getTime(const unsigned ts) const +bool MapWildList::getTime(const unsigned ts) const { for (QListIterator<unsigned> i(times); i.hasNext(); ) { @@ -225,36 +225,36 @@ bool PokeMod::MapWildList::getTime(const unsigned ts) const return false; } -int PokeMod::MapWildList::getScope() const +int MapWildList::getScope() const { return scope; } -const PokeMod::MapWildListEncounter& PokeMod::MapWildList::getEncounter(const unsigned i) const throw(IndexException) +const MapWildListEncounter& MapWildList::getEncounter(const unsigned i) const throw(IndexException) { if (getEncounterCount() <= i) throw(IndexException("MapWildList")); return encounters.at(i); } -PokeMod::MapWildListEncounter& PokeMod::MapWildList::getEncounter(const unsigned i) throw(IndexException) +MapWildListEncounter& MapWildList::getEncounter(const unsigned i) throw(IndexException) { if (getEncounterCount() <= i) throw(IndexException("MapWildList")); return encounters[i]; } -const PokeMod::MapWildListEncounter& PokeMod::MapWildList::getEncounterByID(const unsigned i) const throw(IndexException) +const MapWildListEncounter& MapWildList::getEncounterByID(const unsigned i) const throw(IndexException) { return getEncounter(getEncounterIndex(i)); } -PokeMod::MapWildListEncounter& PokeMod::MapWildList::getEncounterByID(const unsigned i) throw(IndexException) +MapWildListEncounter& MapWildList::getEncounterByID(const unsigned i) throw(IndexException) { return getEncounter(getEncounterIndex(i)); } -unsigned PokeMod::MapWildList::getEncounterIndex(const unsigned _id) const +unsigned MapWildList::getEncounterIndex(const unsigned _id) const { for (unsigned i = 0; i < getEncounterCount(); ++i) { @@ -264,37 +264,37 @@ unsigned PokeMod::MapWildList::getEncounterIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::MapWildList::getEncounterCount() const +unsigned MapWildList::getEncounterCount() const { return encounters.size(); } -PokeMod::MapWildListEncounter& PokeMod::MapWildList::newEncounter() +MapWildListEncounter& MapWildList::newEncounter() { encounters.append(MapWildListEncounter(pokemod, getNewId())); return encounters[getEncounterCount() - 1]; } -PokeMod::MapWildListEncounter& PokeMod::MapWildList::newEncounter(const QString& fname) +MapWildListEncounter& MapWildList::newEncounter(const QString& fname) { encounters.append(MapWildListEncounter(pokemod, fname, getNewId())); return encounters[getEncounterCount() - 1]; } -PokeMod::MapWildListEncounter& PokeMod::MapWildList::newEncounter(const MapWildListEncounter& p) +MapWildListEncounter& MapWildList::newEncounter(const MapWildListEncounter& p) { encounters.append(MapWildListEncounter(pokemod, p, getNewId())); return encounters[getEncounterCount() - 1]; } -void PokeMod::MapWildList::deleteEncounter(const unsigned i) throw(IndexException) +void MapWildList::deleteEncounter(const unsigned i) throw(IndexException) { if (getEncounterCount() <= i) throw(IndexException("MapWildList")); encounters.removeAt(i); } -PokeMod::MapWildList& PokeMod::MapWildList::operator=(const MapWildList& rhs) +MapWildList& MapWildList::operator=(const MapWildList& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/MapWildList.h b/pokemod/MapWildList.h index f922eef4..8a88e163 100644 --- a/pokemod/MapWildList.h +++ b/pokemod/MapWildList.h @@ -30,65 +30,62 @@ #include "Object.h" #include "MapWildListEncounter.h" -namespace PokeMod +class Pokemod; + +class MapWildList : public Object { - class Pokemod; - - class MapWildList : public Object - { - public: - enum - { - Grass = 0, - Surfing = 1, - Fishing = 2, - Dive = 3, - Headbutt = 4, - RockSmash = 5, - End = 6 - }; - static const QStringList ControlStr; - - MapWildList(const Pokemod& par, const unsigned _id); - MapWildList(const Pokemod& par, const MapWildList& w, const unsigned _id); - MapWildList(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save(const QString& map) const throw(Exception); - - void setControl(const unsigned c) throw(BoundsException); - void setValue(const unsigned v); - void setTime(const unsigned ts, const bool t) throw(Exception); - void setScope(const unsigned s); - - unsigned getControl() const; - int getValue() const; - bool getTime(const unsigned ts) const; - int getScope() const; - - const MapWildListEncounter& getEncounter(const unsigned i) const throw(IndexException); - MapWildListEncounter& getEncounter(const unsigned i) throw(IndexException); - const MapWildListEncounter& getEncounterByID(const unsigned i) const throw(IndexException); - MapWildListEncounter& getEncounterByID(const unsigned i) throw(IndexException); - unsigned getEncounterIndex(const unsigned _id) const; - unsigned getEncounterCount() const; - MapWildListEncounter& newEncounter(); - MapWildListEncounter& newEncounter(const QString& fname); - MapWildListEncounter& newEncounter(const MapWildListEncounter& w); - void deleteEncounter(const unsigned i) throw(IndexException); - - MapWildList& operator=(const MapWildList& rhs); - private: - bool validate() const; - unsigned getNewId() const; - - unsigned control; - unsigned value; - QList<unsigned> times; - unsigned scope; - - QList<MapWildListEncounter> encounters; - }; -} + public: + enum + { + Grass = 0, + Surfing = 1, + Fishing = 2, + Dive = 3, + Headbutt = 4, + RockSmash = 5, + End = 6 + }; + static const QStringList ControlStr; + + MapWildList(const Pokemod& par, const unsigned _id); + MapWildList(const Pokemod& par, const MapWildList& w, const unsigned _id); + MapWildList(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save(const QString& map) const throw(Exception); + + void setControl(const unsigned c) throw(BoundsException); + void setValue(const unsigned v); + void setTime(const unsigned ts, const bool t) throw(Exception); + void setScope(const unsigned s); + + unsigned getControl() const; + int getValue() const; + bool getTime(const unsigned ts) const; + int getScope() const; + + const MapWildListEncounter& getEncounter(const unsigned i) const throw(IndexException); + MapWildListEncounter& getEncounter(const unsigned i) throw(IndexException); + const MapWildListEncounter& getEncounterByID(const unsigned i) const throw(IndexException); + MapWildListEncounter& getEncounterByID(const unsigned i) throw(IndexException); + unsigned getEncounterIndex(const unsigned _id) const; + unsigned getEncounterCount() const; + MapWildListEncounter& newEncounter(); + MapWildListEncounter& newEncounter(const QString& fname); + MapWildListEncounter& newEncounter(const MapWildListEncounter& w); + void deleteEncounter(const unsigned i) throw(IndexException); + + MapWildList& operator=(const MapWildList& rhs); + private: + bool validate() const; + unsigned getNewId() const; + + unsigned control; + unsigned value; + QList<unsigned> times; + unsigned scope; + + QList<MapWildListEncounter> encounters; +}; #endif diff --git a/pokemod/MapWildListEncounter.cpp b/pokemod/MapWildListEncounter.cpp index 8cdc72b0..d3960262 100644 --- a/pokemod/MapWildListEncounter.cpp +++ b/pokemod/MapWildListEncounter.cpp @@ -24,7 +24,7 @@ #include "Species.h" #include "MapWildListEncounter.h" -PokeMod::MapWildListEncounter::MapWildListEncounter(const Pokemod& par, const unsigned _id) : +MapWildListEncounter::MapWildListEncounter(const Pokemod& par, const unsigned _id) : Object(par, _id), species(UINT_MAX), level(1), @@ -32,19 +32,19 @@ PokeMod::MapWildListEncounter::MapWildListEncounter(const Pokemod& par, const un { } -PokeMod::MapWildListEncounter::MapWildListEncounter(const Pokemod& par, const MapWildListEncounter& p, const unsigned _id) : +MapWildListEncounter::MapWildListEncounter(const Pokemod& par, const MapWildListEncounter& p, const unsigned _id) : Object(par, _id) { *this = p; } -PokeMod::MapWildListEncounter::MapWildListEncounter(const Pokemod& par, const QString& fname, const unsigned _id) : +MapWildListEncounter::MapWildListEncounter(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::MapWildListEncounter::validate() const +bool MapWildListEncounter::validate() const { bool valid = true; pokemod.validationMsg(QString("---------Encounter with id %1---").arg(id), Pokemod::V_Msg); @@ -66,7 +66,7 @@ bool PokeMod::MapWildListEncounter::validate() const return valid; } -void PokeMod::MapWildListEncounter::load(const QString& fname, const unsigned _id) throw(Exception) +void MapWildListEncounter::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -78,7 +78,7 @@ void PokeMod::MapWildListEncounter::load(const QString& fname, const unsigned _i ini.getValue("weight", weight, 1); } -void PokeMod::MapWildListEncounter::save(const QString& map, const unsigned listId) const throw(Exception) +void MapWildListEncounter::save(const QString& map, const unsigned listId) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -88,43 +88,43 @@ void PokeMod::MapWildListEncounter::save(const QString& map, const unsigned list ini.save(QString("%1/map/%2/wildlist/%3/encounter/%4.pini").arg(pokemod.getPath()).arg(map).arg(listId).arg(id)); } -void PokeMod::MapWildListEncounter::setSpecies(const unsigned s) throw(BoundsException) +void MapWildListEncounter::setSpecies(const unsigned s) throw(BoundsException) { if (pokemod.getSpeciesIndex(s) == UINT_MAX) throw(BoundsException("MapWildListEncounter", "species")); species = s; } -void PokeMod::MapWildListEncounter::setLevel(const unsigned l) throw(BoundsException) +void MapWildListEncounter::setLevel(const unsigned l) throw(BoundsException) { if (!level || (pokemod.getRules().getMaxLevel() <= level)) throw(BoundsException("MapWildListEncounter", "level")); level = l; } -void PokeMod::MapWildListEncounter::setWeight(const unsigned w) throw(BoundsException) +void MapWildListEncounter::setWeight(const unsigned w) throw(BoundsException) { if (!w) throw(BoundsException("MapWildListEncounter", "weight")); weight = w; } -unsigned PokeMod::MapWildListEncounter::getSpecies() const +unsigned MapWildListEncounter::getSpecies() const { return species; } -unsigned PokeMod::MapWildListEncounter::getLevel() const +unsigned MapWildListEncounter::getLevel() const { return level; } -unsigned PokeMod::MapWildListEncounter::getWeight() const +unsigned MapWildListEncounter::getWeight() const { return weight; } -PokeMod::MapWildListEncounter& PokeMod::MapWildListEncounter::operator=(const MapWildListEncounter& rhs) +MapWildListEncounter& MapWildListEncounter::operator=(const MapWildListEncounter& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/MapWildListEncounter.h b/pokemod/MapWildListEncounter.h index 1029808e..abd9f4bb 100644 --- a/pokemod/MapWildListEncounter.h +++ b/pokemod/MapWildListEncounter.h @@ -27,36 +27,33 @@ #include "../general/Exception.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class MapWildListEncounter: public Object { - class Pokemod; - - class MapWildListEncounter: public Object - { - public: - MapWildListEncounter(const Pokemod& par, const unsigned _id); - MapWildListEncounter(const Pokemod& par, const MapWildListEncounter& p, const unsigned _id); - MapWildListEncounter(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save(const QString& map, const unsigned listId) const throw(Exception); - - void setSpecies(const unsigned s) throw(BoundsException); - void setLevel(const unsigned l) throw(BoundsException); - void setWeight(const unsigned w) throw(BoundsException); - - unsigned getSpecies() const; - unsigned getLevel() const; - unsigned getWeight() const; - - MapWildListEncounter& operator=(const MapWildListEncounter& rhs); - private: - bool validate() const; - - unsigned species; - unsigned level; - unsigned weight; - }; -} + public: + MapWildListEncounter(const Pokemod& par, const unsigned _id); + MapWildListEncounter(const Pokemod& par, const MapWildListEncounter& p, const unsigned _id); + MapWildListEncounter(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save(const QString& map, const unsigned listId) const throw(Exception); + + void setSpecies(const unsigned s) throw(BoundsException); + void setLevel(const unsigned l) throw(BoundsException); + void setWeight(const unsigned w) throw(BoundsException); + + unsigned getSpecies() const; + unsigned getLevel() const; + unsigned getWeight() const; + + MapWildListEncounter& operator=(const MapWildListEncounter& rhs); + private: + bool validate() const; + + unsigned species; + unsigned level; + unsigned weight; +}; #endif diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp index 4eecccb1..326a0368 100644 --- a/pokemod/Move.cpp +++ b/pokemod/Move.cpp @@ -28,10 +28,10 @@ #include "Pokemod.h" #include "Move.h" -const QStringList PokeMod::Move::TargetStr = QStringList() << "Player" << "Enemy" << "Both" << "Random"; -const QStringList PokeMod::Move::ChoiceStr = QStringList() << "Player" << "Enemy" << "Random"; +const QStringList Move::TargetStr = QStringList() << "Player" << "Enemy" << "Both" << "Random"; +const QStringList Move::ChoiceStr = QStringList() << "Player" << "Enemy" << "Random"; -PokeMod::Move::Move(const Pokemod& par, const unsigned _id) : +Move::Move(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), accuracy(1, 1), @@ -50,19 +50,19 @@ PokeMod::Move::Move(const Pokemod& par, const unsigned _id) : { } -PokeMod::Move::Move(const Pokemod& par, const Move& m, const unsigned _id) : +Move::Move(const Pokemod& par, const Move& m, const unsigned _id) : Object(par, _id) { *this = m; } -PokeMod::Move::Move(const Pokemod& par, const QString& fname, const unsigned _id) : +Move::Move(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::Move::validate() const +bool Move::validate() const { bool valid = true; pokemod.validationMsg(QString("---Move \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -122,7 +122,7 @@ bool PokeMod::Move::validate() const return valid; } -unsigned PokeMod::Move::getNewId() const +unsigned Move::getNewId() const { unsigned i = 0; for (; (i < getEffectCount()) && (getEffectIndex(i) != UINT_MAX); ++i) @@ -130,7 +130,7 @@ unsigned PokeMod::Move::getNewId() const return i; } -void PokeMod::Move::load(const QString& fname, const unsigned _id) throw(Exception) +void Move::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -167,7 +167,7 @@ void PokeMod::Move::load(const QString& fname, const unsigned _id) throw(Excepti } } -void PokeMod::Move::save() const throw(Exception) +void Move::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -192,186 +192,186 @@ void PokeMod::Move::save() const throw(Exception) i.next().save(name); } -void PokeMod::Move::setName(const QString& n) +void Move::setName(const QString& n) { name = n; } -void PokeMod::Move::setAccuracy(const unsigned n, const unsigned d) throw(Exception) +void Move::setAccuracy(const unsigned n, const unsigned d) throw(Exception) { accuracy.set(n, d); } -void PokeMod::Move::setAccuracyNum(const unsigned n) throw(Exception) +void Move::setAccuracyNum(const unsigned n) throw(Exception) { accuracy.setNum(n); } -void PokeMod::Move::setAccuracyDenom(const unsigned d) throw(Exception) +void Move::setAccuracyDenom(const unsigned d) throw(Exception) { accuracy.setDenom(d); } -void PokeMod::Move::setType(const unsigned t) throw(BoundsException) +void Move::setType(const unsigned t) throw(BoundsException) { if (pokemod.getTypeIndex(t) == UINT_MAX) throw(BoundsException("Move", "type")); type = t; } -void PokeMod::Move::setSpecial(const bool s) +void Move::setSpecial(const bool s) { special = s; } -void PokeMod::Move::setPowerPoints(const unsigned p) throw(BoundsException) +void Move::setPowerPoints(const unsigned p) throw(BoundsException) { if (!p) throw(BoundsException("Move", "powerPoints")); powerPoints = p; } -void PokeMod::Move::setTarget(const unsigned t) throw(BoundsException) +void Move::setTarget(const unsigned t) throw(BoundsException) { if (T_End <= t) throw(BoundsException("Move", "target")); target = t; } -void PokeMod::Move::setNumTargets(const unsigned n) throw(BoundsException) +void Move::setNumTargets(const unsigned n) throw(BoundsException) { if (!n || ((pokemod.getRules().getMaxFight() << 1) < n)) throw(BoundsException("Move", "numTargets")); numTargets = n; } -void PokeMod::Move::setTargetChoice(const unsigned t) throw(BoundsException) +void Move::setTargetChoice(const unsigned t) throw(BoundsException) { if (C_End <= t) throw(BoundsException("Move", "targetChoice")); targetChoice = t; } -void PokeMod::Move::setIgnoreAccuracy(const bool i) +void Move::setIgnoreAccuracy(const bool i) { ignoreAccuracy = i; } -void PokeMod::Move::setCanFlinch(const bool c) +void Move::setCanFlinch(const bool c) { canFlinch = c; } -void PokeMod::Move::setCanRandom(const bool c) +void Move::setCanRandom(const bool c) { canRandom = c; } -void PokeMod::Move::setCanSnatch(const bool c) +void Move::setCanSnatch(const bool c) { canSnatch = c; } -void PokeMod::Move::setSound(const bool s) +void Move::setSound(const bool s) { sound = s; } -QString PokeMod::Move::getName() const +QString Move::getName() const { return name; } -Frac PokeMod::Move::getAccuracy() const +Frac Move::getAccuracy() const { return accuracy; } -unsigned PokeMod::Move::getType() const +unsigned Move::getType() const { return type; } -bool PokeMod::Move::getSpecial() const +bool Move::getSpecial() const { return special; } -unsigned PokeMod::Move::getPowerPoints() const +unsigned Move::getPowerPoints() const { return powerPoints; } -unsigned PokeMod::Move::getTarget() const +unsigned Move::getTarget() const { return target; } -unsigned PokeMod::Move::getNumTargets() const +unsigned Move::getNumTargets() const { return numTargets; } -unsigned PokeMod::Move::getTargetChoice() const +unsigned Move::getTargetChoice() const { return targetChoice; } -bool PokeMod::Move::getIgnoreAccuracy() const +bool Move::getIgnoreAccuracy() const { return ignoreAccuracy; } -bool PokeMod::Move::getCanFlinch() const +bool Move::getCanFlinch() const { return canFlinch; } -bool PokeMod::Move::getCanRandom() const +bool Move::getCanRandom() const { return canRandom; } -bool PokeMod::Move::getCanSnatch() const +bool Move::getCanSnatch() const { return canSnatch; } -bool PokeMod::Move::getSound() const +bool Move::getSound() const { return sound; } -QString PokeMod::Move::getDescription() const +QString Move::getDescription() const { return description; } -const PokeMod::MoveEffect& PokeMod::Move::getEffect(const unsigned i) const throw(IndexException) +const MoveEffect& Move::getEffect(const unsigned i) const throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Move")); return effects.at(i); } -PokeMod::MoveEffect& PokeMod::Move::getEffect(const unsigned i) throw(IndexException) +MoveEffect& Move::getEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Move")); return effects[i]; } -const PokeMod::MoveEffect& PokeMod::Move::getEffectByID(const unsigned i) const throw(IndexException) +const MoveEffect& Move::getEffectByID(const unsigned i) const throw(IndexException) { return getEffect(getEffectIndex(i)); } -PokeMod::MoveEffect& PokeMod::Move::getEffectByID(const unsigned i) throw(IndexException) +MoveEffect& Move::getEffectByID(const unsigned i) throw(IndexException) { return getEffect(getEffectIndex(i)); } -unsigned PokeMod::Move::getEffectIndex(const unsigned _id) const +unsigned Move::getEffectIndex(const unsigned _id) const { for (unsigned i = 0; i < getEffectCount(); ++i) { @@ -381,37 +381,37 @@ unsigned PokeMod::Move::getEffectIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Move::getEffectCount() const +unsigned Move::getEffectCount() const { return effects.size(); } -PokeMod::MoveEffect& PokeMod::Move::newEffect() +MoveEffect& Move::newEffect() { effects.append(MoveEffect(pokemod, getNewId())); return effects[getEffectCount() - 1]; } -PokeMod::MoveEffect& PokeMod::Move::newEffect(const QString& fname) +MoveEffect& Move::newEffect(const QString& fname) { effects.append(MoveEffect(pokemod, fname, getNewId())); return effects[getEffectCount() - 1]; } -PokeMod::MoveEffect& PokeMod::Move::newEffect(const MoveEffect& e) +MoveEffect& Move::newEffect(const MoveEffect& e) { effects.append(MoveEffect(pokemod, e, getNewId())); return effects[getEffectCount() - 1]; } -void PokeMod::Move::deleteEffect(const unsigned i) throw(IndexException) +void Move::deleteEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Move")); effects.removeAt(i); } -PokeMod::Move& PokeMod::Move::operator=(const Move& rhs) +Move& Move::operator=(const Move& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Move.h b/pokemod/Move.h index 4eb327a5..a26f3ccb 100644 --- a/pokemod/Move.h +++ b/pokemod/Move.h @@ -30,105 +30,102 @@ #include "Object.h" #include "MoveEffect.h" -namespace PokeMod +class Pokemod; + +class Move : public Object { - class Pokemod; - - class Move : public Object - { - public: - enum Target - { - T_Player = 0, - T_Enemy = 1, - T_Both = 2, - T_Random = 3, - T_End = 4 - }; - static const QStringList TargetStr; - - enum Choice - { - C_Player = 0, - C_Enemy = 1, - C_Random = 2, - C_End = 3 - }; - static const QStringList ChoiceStr; - - Move(const Pokemod& par, const unsigned _id); - Move(const Pokemod& par, const Move& m, const unsigned _id); - Move(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - void setAccuracy(const unsigned n, const unsigned d) throw(Exception); - void setAccuracyNum(const unsigned n) throw(Exception); - void setAccuracyDenom(const unsigned d) throw(Exception); - void setType(const unsigned t) throw(BoundsException); - void setSpecial(const bool s); - void setPowerPoints(const unsigned p) throw(BoundsException); - void setTarget(const unsigned t) throw(BoundsException); - void setNumTargets(const unsigned n) throw(BoundsException); - void setTargetChoice(const unsigned t) throw(BoundsException); - void setIgnoreAccuracy(const bool i); - void setCanFlinch(const bool c); - void setCanRandom(const bool c); - void setCanSnatch(const bool c); - void setSound(const bool s); - void setDescription(const QString& d); - - QString getName() const; - Frac getAccuracy() const; - unsigned getType() const; - bool getSpecial() const; - unsigned getPowerPoints() const; - unsigned getTarget() const; - unsigned getNumTargets() const; - unsigned getTargetChoice() const; - bool getIgnoreAccuracy() const; - bool getCanFlinch() const; - bool getCanRandom() const; - bool getCanSnatch() const; - bool getSound() const; - QString getDescription() const; - - const MoveEffect& getEffect(const unsigned i) const throw(IndexException); - MoveEffect& getEffect(const unsigned i) throw(IndexException); - const MoveEffect& getEffectByID(const unsigned i) const throw(IndexException); - MoveEffect& getEffectByID(const unsigned i) throw(IndexException); - unsigned getEffectIndex(const unsigned _id) const; - unsigned getEffectCount() const; - MoveEffect& newEffect(); - MoveEffect& newEffect(const QString& fname); - MoveEffect& newEffect(const MoveEffect& e); - void deleteEffect(const unsigned i) throw(IndexException); - - Move& operator=(const Move& rhs); - private: - bool validate() const; - unsigned getNewId() const; - - QString name; - Frac accuracy; - unsigned power; - unsigned type; - bool special; - unsigned powerPoints; - unsigned target; - unsigned numTargets; - unsigned targetChoice; - bool ignoreAccuracy; - bool canFlinch; - bool canRandom; - bool canSnatch; - bool sound; - QString description; - - QList<MoveEffect> effects; - }; -} + public: + enum Target + { + T_Player = 0, + T_Enemy = 1, + T_Both = 2, + T_Random = 3, + T_End = 4 + }; + static const QStringList TargetStr; + + enum Choice + { + C_Player = 0, + C_Enemy = 1, + C_Random = 2, + C_End = 3 + }; + static const QStringList ChoiceStr; + + Move(const Pokemod& par, const unsigned _id); + Move(const Pokemod& par, const Move& m, const unsigned _id); + Move(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + void setAccuracy(const unsigned n, const unsigned d) throw(Exception); + void setAccuracyNum(const unsigned n) throw(Exception); + void setAccuracyDenom(const unsigned d) throw(Exception); + void setType(const unsigned t) throw(BoundsException); + void setSpecial(const bool s); + void setPowerPoints(const unsigned p) throw(BoundsException); + void setTarget(const unsigned t) throw(BoundsException); + void setNumTargets(const unsigned n) throw(BoundsException); + void setTargetChoice(const unsigned t) throw(BoundsException); + void setIgnoreAccuracy(const bool i); + void setCanFlinch(const bool c); + void setCanRandom(const bool c); + void setCanSnatch(const bool c); + void setSound(const bool s); + void setDescription(const QString& d); + + QString getName() const; + Frac getAccuracy() const; + unsigned getType() const; + bool getSpecial() const; + unsigned getPowerPoints() const; + unsigned getTarget() const; + unsigned getNumTargets() const; + unsigned getTargetChoice() const; + bool getIgnoreAccuracy() const; + bool getCanFlinch() const; + bool getCanRandom() const; + bool getCanSnatch() const; + bool getSound() const; + QString getDescription() const; + + const MoveEffect& getEffect(const unsigned i) const throw(IndexException); + MoveEffect& getEffect(const unsigned i) throw(IndexException); + const MoveEffect& getEffectByID(const unsigned i) const throw(IndexException); + MoveEffect& getEffectByID(const unsigned i) throw(IndexException); + unsigned getEffectIndex(const unsigned _id) const; + unsigned getEffectCount() const; + MoveEffect& newEffect(); + MoveEffect& newEffect(const QString& fname); + MoveEffect& newEffect(const MoveEffect& e); + void deleteEffect(const unsigned i) throw(IndexException); + + Move& operator=(const Move& rhs); + private: + bool validate() const; + unsigned getNewId() const; + + QString name; + Frac accuracy; + unsigned power; + unsigned type; + bool special; + unsigned powerPoints; + unsigned target; + unsigned numTargets; + unsigned targetChoice; + bool ignoreAccuracy; + bool canFlinch; + bool canRandom; + bool canSnatch; + bool sound; + QString description; + + QList<MoveEffect> effects; +}; #endif diff --git a/pokemod/MoveEffect.cpp b/pokemod/MoveEffect.cpp index b7f7c61a..5fc53fc6 100644 --- a/pokemod/MoveEffect.cpp +++ b/pokemod/MoveEffect.cpp @@ -24,9 +24,9 @@ #include "Pokemod.h" #include "MoveEffect.h" -const QStringList PokeMod::MoveEffect::EffectStr = QStringList() << "Damage" << "Status" << "Confuse" << "Stat" << "StealHP" << "Counter" << "Selfdestruct" << "Need Status" << "Mirror" << "GetMoney" << "Never Miss" << "Steal Types" << "Clear Effects" << "Wait And Return" << "Self Confuse" << "Force Switch" << "Hit Multiple" << "Hit Multiple Turns" << "Flinch" << "One Hit K.O." << "Recoil" << "Recover" << "Rest" << "Sheild" << "Substitute" << "Recharge" << "Rage" << "Mimic" << "Random Move" << "Seed" << "Disable" << "Cut HM" << "Fly HM" << "Surf HM" << "Strength HM" << "Flash HM" << "Rock Smash HM" << "Rock Climb HM" << "Whirlpool HM" << "Waterfall HM" << "Share HP HM " << "Escape HM"; +const QStringList MoveEffect::EffectStr = QStringList() << "Damage" << "Status" << "Confuse" << "Stat" << "StealHP" << "Counter" << "Selfdestruct" << "Need Status" << "Mirror" << "GetMoney" << "Never Miss" << "Steal Types" << "Clear Effects" << "Wait And Return" << "Self Confuse" << "Force Switch" << "Hit Multiple" << "Hit Multiple Turns" << "Flinch" << "One Hit K.O." << "Recoil" << "Recover" << "Rest" << "Sheild" << "Substitute" << "Recharge" << "Rage" << "Mimic" << "Random Move" << "Seed" << "Disable" << "Cut HM" << "Fly HM" << "Surf HM" << "Strength HM" << "Flash HM" << "Rock Smash HM" << "Rock Climb HM" << "Whirlpool HM" << "Waterfall HM" << "Share HP HM " << "Escape HM"; -PokeMod::MoveEffect::MoveEffect(const Pokemod& par, const unsigned _id) : +MoveEffect::MoveEffect(const Pokemod& par, const unsigned _id) : Object(par, _id), chance(1, 1), effect(UINT_MAX), @@ -37,19 +37,19 @@ PokeMod::MoveEffect::MoveEffect(const Pokemod& par, const unsigned _id) : { } -PokeMod::MoveEffect::MoveEffect(const Pokemod& par, const MoveEffect& e, const unsigned _id) : +MoveEffect::MoveEffect(const Pokemod& par, const MoveEffect& e, const unsigned _id) : Object(par, _id) { *this = e; } -PokeMod::MoveEffect::MoveEffect(const Pokemod& par, const QString& fname, const unsigned _id) : +MoveEffect::MoveEffect(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::MoveEffect::validate() const +bool MoveEffect::validate() const { bool valid = true; pokemod.validationMsg(QString("------Effect with id %1---").arg(id), Pokemod::V_Msg); @@ -57,7 +57,7 @@ bool PokeMod::MoveEffect::validate() const return valid; } -void PokeMod::MoveEffect::load(const QString& fname, const unsigned _id) throw(Exception) +void MoveEffect::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -80,7 +80,7 @@ void PokeMod::MoveEffect::load(const QString& fname, const unsigned _id) throw(E val4.set(i, j, k); } -void PokeMod::MoveEffect::save(const QString& move) const throw(Exception) +void MoveEffect::save(const QString& move) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -96,22 +96,22 @@ void PokeMod::MoveEffect::save(const QString& move) const throw(Exception) ini.save(QString("%1/move/%2/effect/%3.pini").arg(pokemod.getPath()).arg(move).arg(id)); } -void PokeMod::MoveEffect::setChance(const unsigned n, const unsigned d) throw(Exception) +void MoveEffect::setChance(const unsigned n, const unsigned d) throw(Exception) { chance.set(n, d); } -void PokeMod::MoveEffect::setChanceNum(const unsigned n) throw(Exception) +void MoveEffect::setChanceNum(const unsigned n) throw(Exception) { chance.setNum(n); } -void PokeMod::MoveEffect::setChanceDenom(const unsigned d) throw(Exception) +void MoveEffect::setChanceDenom(const unsigned d) throw(Exception) { chance.setDenom(d); } -void PokeMod::MoveEffect::setEffect(const unsigned e) throw(BoundsException) +void MoveEffect::setEffect(const unsigned e) throw(BoundsException) { if (E_End <= e) throw(BoundsException("MoveEffect", "effect")); @@ -122,7 +122,7 @@ void PokeMod::MoveEffect::setEffect(const unsigned e) throw(BoundsException) val4.set(1, 1, ((e == E_StealHP) || (e == E_Counter) || (e == E_Selfdestruct) || (e == E_Mirror) || (e == E_GetMoney) || (e == E_WaitAndReturn) || (e == E_Recoil)) ? Frac::Improper : Frac::Proper); } -void PokeMod::MoveEffect::setVal1(const unsigned v1) throw(Exception) +void MoveEffect::setVal1(const unsigned v1) throw(Exception) { switch (effect) { @@ -155,7 +155,7 @@ void PokeMod::MoveEffect::setVal1(const unsigned v1) throw(Exception) val1 = v1; } -void PokeMod::MoveEffect::setVal2(const unsigned v2) throw(Exception) +void MoveEffect::setVal2(const unsigned v2) throw(Exception) { switch (effect) { @@ -170,7 +170,7 @@ void PokeMod::MoveEffect::setVal2(const unsigned v2) throw(Exception) val2 = v2; } -void PokeMod::MoveEffect::setVal3(const int v3) +void MoveEffect::setVal3(const int v3) { switch (effect) { @@ -181,52 +181,52 @@ void PokeMod::MoveEffect::setVal3(const int v3) val3 = v3; } -void PokeMod::MoveEffect::setVal4(const unsigned n, const unsigned d) throw(Exception) +void MoveEffect::setVal4(const unsigned n, const unsigned d) throw(Exception) { val4.set(n, d); } -void PokeMod::MoveEffect::setVal4Num(const unsigned n) throw(Exception) +void MoveEffect::setVal4Num(const unsigned n) throw(Exception) { val4.setNum(n); } -void PokeMod::MoveEffect::setVal4Denom(const unsigned d) throw(Exception) +void MoveEffect::setVal4Denom(const unsigned d) throw(Exception) { val4.setDenom(d); } -Frac PokeMod::MoveEffect::getChance() const +Frac MoveEffect::getChance() const { return chance; } -unsigned PokeMod::MoveEffect::getEffect() const +unsigned MoveEffect::getEffect() const { return effect; } -unsigned PokeMod::MoveEffect::getVal1() const +unsigned MoveEffect::getVal1() const { return val1; } -unsigned PokeMod::MoveEffect::getVal2() const +unsigned MoveEffect::getVal2() const { return val2; } -int PokeMod::MoveEffect::getVal3() const +int MoveEffect::getVal3() const { return val3; } -Frac PokeMod::MoveEffect::getVal4() const +Frac MoveEffect::getVal4() const { return val4; } -PokeMod::MoveEffect& PokeMod::MoveEffect::operator=(const MoveEffect& rhs) +MoveEffect& MoveEffect::operator=(const MoveEffect& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/MoveEffect.h b/pokemod/MoveEffect.h index 79919517..63087292 100644 --- a/pokemod/MoveEffect.h +++ b/pokemod/MoveEffect.h @@ -29,126 +29,123 @@ #include "../general/Frac.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class MoveEffect : public Object { - class Pokemod; - - class MoveEffect : public Object - { - public: - enum Effect - { - E_Damage = 0, - E_Status = 1, - E_Confuse = 2, - E_Stat = 3, - E_StealHP = 4, - E_Counter = 5, - E_Selfdestruct = 6, - E_NeedStatus = 7, - E_Mirror = 8, - E_GetMoney = 9, - E_NeverMiss = 10, - E_StealTypes = 11, - E_ClearEffects = 12, - E_WaitAndReturn = 13, - E_SelfConfuse = 14, - E_ForceSwitch = 15, - E_HitMultiple = 16, - E_HitMultipleTurns = 17, - E_Flinch = 18, - E_OneHitKO = 19, - E_Recoil = 20, - E_Recover = 21, - E_Rest = 22, - E_Shield = 23, - E_Substitute = 24, - E_Recharge = 25, - E_Rage = 26, - E_Mimic = 27, - E_RandomMove = 28, - E_Seed = 29, - E_Disable = 30, - // TODO: GSC, RSEFrLg, DP effects - E_End,// = , - E_CutHM = E_End, - E_FlyHM,// = , - E_SurfHM,// = , - E_StrengthHM,// = , - E_FlashHM,// = , - E_RockSmashHM,// = , - E_RockClimbHM,// = , - E_WhirlpoolHM,// = , - E_WaterfallHM,// = , - E_ShareHPHM,// = , - E_EscapeHM,// = , - E_End_Overworld// = - }; - static const QStringList EffectStr; - - enum Damage - { - D_Fixed = 0, - D_FixedRange = 1, - D_Relative = 2, - D_RelativeRange = 3, - D_Level = 4, - D_End = 5 - }; - static const QStringList DamageStr; - - enum MoveType - { - MT_Physical = 0, - MT_Special = 1, - MT_End = 2 - }; - static const QStringList MoveTypeStr; - - enum Recoil - { - R_Hit = 0, - R_Miss = 1, - R_End = 2 - }; - static const QStringList RecoilStr; - - MoveEffect(const Pokemod& par, const unsigned _id); - MoveEffect(const Pokemod& par, const MoveEffect& e, const unsigned _id); - MoveEffect(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save(const QString& move) const throw(Exception); - - void setChance(const unsigned n, const unsigned d) throw(Exception); - void setChanceNum(const unsigned n) throw(Exception); - void setChanceDenom(const unsigned d) throw(Exception); - void setEffect(const unsigned e) throw(BoundsException); - void setVal1(const unsigned v1) throw(Exception); - void setVal2(const unsigned v2) throw(Exception); - void setVal3(const int v3); - void setVal4(const unsigned n, const unsigned d) throw(Exception); - void setVal4Num(const unsigned n) throw(Exception); - void setVal4Denom(const unsigned d) throw(Exception); - - Frac getChance() const; - unsigned getEffect() const; - unsigned getVal1() const; - unsigned getVal2() const; - int getVal3() const; - Frac getVal4() const; - - MoveEffect& operator=(const MoveEffect& rhs); - private: - bool validate() const; - - Frac chance; - unsigned effect; - unsigned val1; - unsigned val2; - int val3; - Frac val4; - }; -} + public: + enum Effect + { + E_Damage = 0, + E_Status = 1, + E_Confuse = 2, + E_Stat = 3, + E_StealHP = 4, + E_Counter = 5, + E_Selfdestruct = 6, + E_NeedStatus = 7, + E_Mirror = 8, + E_GetMoney = 9, + E_NeverMiss = 10, + E_StealTypes = 11, + E_ClearEffects = 12, + E_WaitAndReturn = 13, + E_SelfConfuse = 14, + E_ForceSwitch = 15, + E_HitMultiple = 16, + E_HitMultipleTurns = 17, + E_Flinch = 18, + E_OneHitKO = 19, + E_Recoil = 20, + E_Recover = 21, + E_Rest = 22, + E_Shield = 23, + E_Substitute = 24, + E_Recharge = 25, + E_Rage = 26, + E_Mimic = 27, + E_RandomMove = 28, + E_Seed = 29, + E_Disable = 30, + // TODO: GSC, RSEFrLg, DP effects + E_End,// = , + E_CutHM = E_End, + E_FlyHM,// = , + E_SurfHM,// = , + E_StrengthHM,// = , + E_FlashHM,// = , + E_RockSmashHM,// = , + E_RockClimbHM,// = , + E_WhirlpoolHM,// = , + E_WaterfallHM,// = , + E_ShareHPHM,// = , + E_EscapeHM,// = , + E_End_Overworld// = + }; + static const QStringList EffectStr; + + enum Damage + { + D_Fixed = 0, + D_FixedRange = 1, + D_Relative = 2, + D_RelativeRange = 3, + D_Level = 4, + D_End = 5 + }; + static const QStringList DamageStr; + + enum MoveType + { + MT_Physical = 0, + MT_Special = 1, + MT_End = 2 + }; + static const QStringList MoveTypeStr; + + enum Recoil + { + R_Hit = 0, + R_Miss = 1, + R_End = 2 + }; + static const QStringList RecoilStr; + + MoveEffect(const Pokemod& par, const unsigned _id); + MoveEffect(const Pokemod& par, const MoveEffect& e, const unsigned _id); + MoveEffect(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save(const QString& move) const throw(Exception); + + void setChance(const unsigned n, const unsigned d) throw(Exception); + void setChanceNum(const unsigned n) throw(Exception); + void setChanceDenom(const unsigned d) throw(Exception); + void setEffect(const unsigned e) throw(BoundsException); + void setVal1(const unsigned v1) throw(Exception); + void setVal2(const unsigned v2) throw(Exception); + void setVal3(const int v3); + void setVal4(const unsigned n, const unsigned d) throw(Exception); + void setVal4Num(const unsigned n) throw(Exception); + void setVal4Denom(const unsigned d) throw(Exception); + + Frac getChance() const; + unsigned getEffect() const; + unsigned getVal1() const; + unsigned getVal2() const; + int getVal3() const; + Frac getVal4() const; + + MoveEffect& operator=(const MoveEffect& rhs); + private: + bool validate() const; + + Frac chance; + unsigned effect; + unsigned val1; + unsigned val2; + int val3; + Frac val4; +}; #endif diff --git a/pokemod/Nature.cpp b/pokemod/Nature.cpp index 02b434ad..1c6fc06d 100644 --- a/pokemod/Nature.cpp +++ b/pokemod/Nature.cpp @@ -24,7 +24,7 @@ #include "Pokemod.h" #include "Nature.h" -PokeMod::Nature::Nature(const Pokemod& par, const unsigned _id) : +Nature::Nature(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), weight(1) @@ -33,19 +33,19 @@ PokeMod::Nature::Nature(const Pokemod& par, const unsigned _id) : stats[i].set(1, 1, Frac::Improper); } -PokeMod::Nature::Nature(const Pokemod& par, const Nature& n, const unsigned _id) : +Nature::Nature(const Pokemod& par, const Nature& n, const unsigned _id) : Object(par, _id) { *this = n; } -PokeMod::Nature::Nature(const Pokemod& par, const QString& fname, const unsigned _id) : +Nature::Nature(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::Nature::validate() const +bool Nature::validate() const { bool valid = true; pokemod.validationMsg(QString("---Nature \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -62,7 +62,7 @@ bool PokeMod::Nature::validate() const return valid; } -void PokeMod::Nature::load(const QString& fname, const unsigned _id) throw(Exception) +void Nature::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -81,7 +81,7 @@ void PokeMod::Nature::load(const QString& fname, const unsigned _id) throw(Excep ini.getValue("weight", weight); } -void PokeMod::Nature::save() const throw(Exception) +void Nature::save() const throw(Exception) { Ini ini; ini.addField("name", name); @@ -94,57 +94,57 @@ void PokeMod::Nature::save() const throw(Exception) ini.save(QString("%1/nature/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeMod::Nature::setName(const QString& n) +void Nature::setName(const QString& n) { name = n; } -void PokeMod::Nature::setStat(const unsigned s, const unsigned n, const unsigned d) throw(Exception) +void Nature::setStat(const unsigned s, const unsigned n, const unsigned d) throw(Exception) { if ((pokemod.getRules().getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) throw(BoundsException("Nature", "stat")); stats[s].set(n, d); } -void PokeMod::Nature::setStatNum(const unsigned s, const unsigned n) throw(Exception) +void Nature::setStatNum(const unsigned s, const unsigned n) throw(Exception) { if ((pokemod.getRules().getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) throw(BoundsException("Nature", "stat")); stats[s].setNum(n); } -void PokeMod::Nature::setStatDenom(const unsigned s, const unsigned d) throw(Exception) +void Nature::setStatDenom(const unsigned s, const unsigned d) throw(Exception) { if ((pokemod.getRules().getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) throw(BoundsException("Nature", "stat")); stats[s].setDenom(d); } -void PokeMod::Nature::setWeight(const unsigned w) throw(BoundsException) +void Nature::setWeight(const unsigned w) throw(BoundsException) { if (!w) throw(BoundsException("Nature", "weight")); weight = w; } -QString PokeMod::Nature::getName() const +QString Nature::getName() const { return name; } -Frac PokeMod::Nature::getStat(const unsigned s) const throw(BoundsException) +Frac Nature::getStat(const unsigned s) const throw(BoundsException) { if ((pokemod.getRules().getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) throw(BoundsException("Nature", "stat")); return stats[s]; } -unsigned PokeMod::Nature::getWeight() const +unsigned Nature::getWeight() const { return weight; } -PokeMod::Nature& PokeMod::Nature::operator=(const Nature& rhs) +Nature& Nature::operator=(const Nature& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Nature.h b/pokemod/Nature.h index 33f5ecd8..6ade607f 100644 --- a/pokemod/Nature.h +++ b/pokemod/Nature.h @@ -28,38 +28,35 @@ #include "../general/Frac.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class Nature : public Object { - class Pokemod; - - class Nature : public Object - { - public: - Nature(const Pokemod& par, const unsigned _id); - Nature(const Pokemod& par, const Nature& n, const unsigned _id); - Nature(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - void setStat(const unsigned s, const unsigned n, const unsigned d) throw(Exception); - void setStatNum(const unsigned s, const unsigned n) throw(Exception); - void setStatDenom(const unsigned s, const unsigned d) throw(Exception); - void setWeight(const unsigned w) throw(BoundsException); - - QString getName() const; - Frac getStat(const unsigned s) const throw(BoundsException); - unsigned getWeight() const; - - Nature& operator=(const Nature& rhs); - private: - bool validate() const; - - QString name; - Frac stats[ST_End_GSC]; - unsigned weight; - }; -} + public: + Nature(const Pokemod& par, const unsigned _id); + Nature(const Pokemod& par, const Nature& n, const unsigned _id); + Nature(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + void setStat(const unsigned s, const unsigned n, const unsigned d) throw(Exception); + void setStatNum(const unsigned s, const unsigned n) throw(Exception); + void setStatDenom(const unsigned s, const unsigned d) throw(Exception); + void setWeight(const unsigned w) throw(BoundsException); + + QString getName() const; + Frac getStat(const unsigned s) const throw(BoundsException); + unsigned getWeight() const; + + Nature& operator=(const Nature& rhs); + private: + bool validate() const; + + QString name; + Frac stats[ST_End_GSC]; + unsigned weight; +}; #endif diff --git a/pokemod/Object.h b/pokemod/Object.h index 53908a45..60621756 100644 --- a/pokemod/Object.h +++ b/pokemod/Object.h @@ -25,42 +25,39 @@ #include "../general/Exception.h" -namespace PokeMod +class Pokemod; + +class Object { - class Pokemod; - - class Object - { - public: - Object(const Pokemod& par, const unsigned _id) : - id(_id), - pokemod(par) - { - } - virtual ~Object(); - virtual void load(const QString& fname, const unsigned _id) throw(Exception); - - unsigned getId() const - { - return id; - } - bool isValid() const - { - if (isGood()) - return validate(); - return false; - } - bool isGood() const - { - return (id != UINT_MAX); - } - protected: - virtual bool validate() const; - - unsigned id; - - const Pokemod& pokemod; - }; -} + public: + Object(const Pokemod& par, const unsigned _id) : + id(_id), + pokemod(par) + { + } + virtual ~Object(); + virtual void load(const QString& fname, const unsigned _id) throw(Exception); + + unsigned getId() const + { + return id; + } + bool isValid() const + { + if (isGood()) + return validate(); + return false; + } + bool isGood() const + { + return (id != UINT_MAX); + } + protected: + virtual bool validate() const; + + unsigned id; + + const Pokemod& pokemod; +}; #endif diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp index b59fefe4..ea8f7528 100644 --- a/pokemod/Pokemod.cpp +++ b/pokemod/Pokemod.cpp @@ -29,7 +29,7 @@ #include "../general/Ref.h" #include "Pokemod.h" -PokeMod::Pokemod::Pokemod(const QString& fname) : +Pokemod::Pokemod(const QString& fname) : Object(*this, 0), valstream(NULL), title(""), @@ -45,7 +45,7 @@ PokeMod::Pokemod::Pokemod(const QString& fname) : load(fname); } -bool PokeMod::Pokemod::validate() const +bool Pokemod::validate() const { bool valid = true; validationMsg(QString("Pokemod \"%1\"").arg(title), V_Msg); @@ -599,12 +599,12 @@ bool PokeMod::Pokemod::validate() const return valid; } -QString PokeMod::Pokemod::getPath() const +QString Pokemod::getPath() const { return path; } -void PokeMod::Pokemod::load(const QString& fname) throw(Exception) +void Pokemod::load(const QString& fname) throw(Exception) { Ini ini(fname); QStringList fpath = fname.split('\\', QString::SkipEmptyParts).join("/").split('\\', QString::SkipEmptyParts); @@ -744,7 +744,7 @@ void PokeMod::Pokemod::load(const QString& fname) throw(Exception) } } -void PokeMod::Pokemod::save() const throw(Exception) +void Pokemod::save() const throw(Exception) { Ini ini; ini.addField("title", title); @@ -798,34 +798,34 @@ void PokeMod::Pokemod::save() const throw(Exception) i.next().save(); } -unsigned PokeMod::Pokemod::maxCompatability(const Pokemod& p) const +unsigned Pokemod::maxCompatability(const Pokemod& p) const { // TODO (Ben #1#): MaxCompatability between two versions } -void PokeMod::Pokemod::setTitle(const QString& t) +void Pokemod::setTitle(const QString& t) { title = t; } -void PokeMod::Pokemod::setVersion(const QString& v) +void Pokemod::setVersion(const QString& v) { version = v; } -void PokeMod::Pokemod::setDescription(const QString& d) +void Pokemod::setDescription(const QString& d) { description = d; } -void PokeMod::Pokemod::setStartMap(const unsigned s) throw(BoundsException) +void Pokemod::setStartMap(const unsigned s) throw(BoundsException) { if (getMapIndex(s) == UINT_MAX) throw(BoundsException("Pokemod", "startMap")); startMap = s; } -void PokeMod::Pokemod::setStartWarp(const unsigned s) throw(BoundsException) +void Pokemod::setStartWarp(const unsigned s) throw(BoundsException) { if (getMapIndex(startMap) == UINT_MAX) throw(BoundsException("Pokemod", "startMap")); @@ -834,7 +834,7 @@ void PokeMod::Pokemod::setStartWarp(const unsigned s) throw(BoundsException) startWarp = s; } -void PokeMod::Pokemod::setWalkSkin(const QString& fname) throw(Exception) +void Pokemod::setWalkSkin(const QString& fname) throw(Exception) { QFile file(QString("%1/image/skin/walk.png").arg(getPath())); if (file.exists() && !file.remove()) @@ -843,7 +843,7 @@ void PokeMod::Pokemod::setWalkSkin(const QString& fname) throw(Exception) throw(SaveException("Pokemod", file.fileName())); } -void PokeMod::Pokemod::setBikeSkin(const QString& fname) throw(Exception) +void Pokemod::setBikeSkin(const QString& fname) throw(Exception) { QFile file(QString("%1/image/skin/bike.png").arg(getPath())); if (file.exists() && !file.remove()) @@ -852,7 +852,7 @@ void PokeMod::Pokemod::setBikeSkin(const QString& fname) throw(Exception) throw(SaveException("Pokemod", file.fileName())); } -void PokeMod::Pokemod::setSurfSkin(const QString& fname) throw(Exception) +void Pokemod::setSurfSkin(const QString& fname) throw(Exception) { QFile file(QString("%1/image/skin/surf.png").arg(getPath())); if (file.exists() && !file.remove()) @@ -861,7 +861,7 @@ void PokeMod::Pokemod::setSurfSkin(const QString& fname) throw(Exception) throw(SaveException("Pokemod", file.fileName())); } -void PokeMod::Pokemod::setFlySkin(const QString& fname) throw(Exception) +void Pokemod::setFlySkin(const QString& fname) throw(Exception) { QFile file(QString("%1/image/skin/fly.png").arg(getPath())); if (file.exists() && !file.remove()) @@ -870,7 +870,7 @@ void PokeMod::Pokemod::setFlySkin(const QString& fname) throw(Exception) throw(SaveException("Pokemod", file.fileName())); } -void PokeMod::Pokemod::setFishSkin(const QString& fname) throw(Exception) +void Pokemod::setFishSkin(const QString& fname) throw(Exception) { QFile file(QString("%1/image/skin/fish.png").arg(getPath())); if (file.exists() && !file.remove()) @@ -879,7 +879,7 @@ void PokeMod::Pokemod::setFishSkin(const QString& fname) throw(Exception) throw(SaveException("Pokemod", file.fileName())); } -void PokeMod::Pokemod::setSurfFishSkin(const QString& fname) throw(Exception) +void Pokemod::setSurfFishSkin(const QString& fname) throw(Exception) { QFile file(QString("%1/image/skin/surfFish.png").arg(getPath())); if (file.exists() && !file.remove()) @@ -888,126 +888,126 @@ void PokeMod::Pokemod::setSurfFishSkin(const QString& fname) throw(Exception) throw(SaveException("Pokemod", file.fileName())); } -void PokeMod::Pokemod::setSuperPCUname(const QString& u) +void Pokemod::setSuperPCUname(const QString& u) { superPCUname = u; } -void PokeMod::Pokemod::setSuperPCPasswd(const QString& p) +void Pokemod::setSuperPCPasswd(const QString& p) { superPCPasswd = p; } -void PokeMod::Pokemod::setTypeChart(const unsigned att, const unsigned def, const unsigned n, const unsigned d) throw(Exception) +void Pokemod::setTypeChart(const unsigned att, const unsigned def, const unsigned n, const unsigned d) throw(Exception) { typeChart(att, def).set(n, d); } -void PokeMod::Pokemod::setTypeChartNum(const unsigned att, const unsigned def, const unsigned n) throw(Exception) +void Pokemod::setTypeChartNum(const unsigned att, const unsigned def, const unsigned n) throw(Exception) { typeChart(att, def).setNum(n); } -void PokeMod::Pokemod::setTypeChartDenom(const unsigned att, const unsigned def, const unsigned d) throw(Exception) +void Pokemod::setTypeChartDenom(const unsigned att, const unsigned def, const unsigned d) throw(Exception) { typeChart(att, def).setDenom(d); } -void PokeMod::Pokemod::setRules(const Rules& r) +void Pokemod::setRules(const Rules& r) { rules = r; } -void PokeMod::Pokemod::setRules(const QString& fname) +void Pokemod::setRules(const QString& fname) { rules.load(fname); } -QString PokeMod::Pokemod::getTitle() const +QString Pokemod::getTitle() const { return title; } -QString PokeMod::Pokemod::getVersion() const +QString Pokemod::getVersion() const { return version; } -QString PokeMod::Pokemod::getDescription() const +QString Pokemod::getDescription() const { return description; } -unsigned PokeMod::Pokemod::getStartMap() const +unsigned Pokemod::getStartMap() const { return startMap; } -unsigned PokeMod::Pokemod::getStartWarp() const +unsigned Pokemod::getStartWarp() const { return startWarp; } -QString PokeMod::Pokemod::getSuperPCUname() const +QString Pokemod::getSuperPCUname() const { return superPCUname; } -QString PokeMod::Pokemod::getSuperPCPasswd() const +QString Pokemod::getSuperPCPasswd() const { return superPCPasswd; } -const FracMatrix& PokeMod::Pokemod::getTypeChart() const +const FracMatrix& Pokemod::getTypeChart() const { return typeChart; } -FracMatrix& PokeMod::Pokemod::getTypeChart() +FracMatrix& Pokemod::getTypeChart() { return typeChart; } -Frac PokeMod::Pokemod::getTypeChart(const unsigned att, const unsigned def) const +Frac Pokemod::getTypeChart(const unsigned att, const unsigned def) const { return typeChart(att, def); } -const PokeMod::Rules& PokeMod::Pokemod::getRules() const +const Rules& Pokemod::getRules() const { return rules; } -PokeMod::Rules& PokeMod::Pokemod::getRules() +Rules& Pokemod::getRules() { return rules; } -const PokeMod::Ability& PokeMod::Pokemod::getAbility(const unsigned i) const throw(IndexException) +const Ability& Pokemod::getAbility(const unsigned i) const throw(IndexException) { if (getAbilityCount() <= i) throw(IndexException("Pokemod")); return abilities.at(i); } -PokeMod::Ability& PokeMod::Pokemod::getAbility(const unsigned i) throw(IndexException) +Ability& Pokemod::getAbility(const unsigned i) throw(IndexException) { if (getAbilityCount() <= i) throw(IndexException("Pokemod")); return abilities[i]; } -const PokeMod::Ability& PokeMod::Pokemod::getAbilityByID(const unsigned i) const throw(IndexException) +const Ability& Pokemod::getAbilityByID(const unsigned i) const throw(IndexException) { return getAbility(getAbilityIndex(i)); } -PokeMod::Ability& PokeMod::Pokemod::getAbilityByID(const unsigned i) throw(IndexException) +Ability& Pokemod::getAbilityByID(const unsigned i) throw(IndexException) { return getAbility(getAbilityIndex(i)); } -unsigned PokeMod::Pokemod::getAbilityIndex(const unsigned _id) const +unsigned Pokemod::getAbilityIndex(const unsigned _id) const { for (unsigned i = 0; i < getAbilityCount(); ++i) { @@ -1017,61 +1017,61 @@ unsigned PokeMod::Pokemod::getAbilityIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getAbilityCount() const +unsigned Pokemod::getAbilityCount() const { return abilities.size(); } -PokeMod::Ability& PokeMod::Pokemod::newAbility() +Ability& Pokemod::newAbility() { abilities.append(Ability(*this, getNewAbilityId())); return abilities[getAbilityCount() - 1]; } -PokeMod::Ability& PokeMod::Pokemod::newAbility(const QString& fname) +Ability& Pokemod::newAbility(const QString& fname) { abilities.append(Ability(*this, fname, getNewAbilityId())); return abilities[getAbilityCount() - 1]; } -PokeMod::Ability& PokeMod::Pokemod::newAbility(const Ability& a) +Ability& Pokemod::newAbility(const Ability& a) { abilities.append(Ability(*this, a, getNewAbilityId())); return abilities[getAbilityCount() - 1]; } -void PokeMod::Pokemod::deleteAbility(const unsigned i) throw(IndexException) +void Pokemod::deleteAbility(const unsigned i) throw(IndexException) { if (getAbilityCount() <= i) throw(IndexException("Pokemod")); abilities.removeAt(i); } -const PokeMod::Author& PokeMod::Pokemod::getAuthor(const unsigned i) const throw(IndexException) +const Author& Pokemod::getAuthor(const unsigned i) const throw(IndexException) { if (getAuthorCount() <= i) throw(IndexException("Pokemod")); return authors.at(i); } -PokeMod::Author& PokeMod::Pokemod::getAuthor(const unsigned i) throw(IndexException) +Author& Pokemod::getAuthor(const unsigned i) throw(IndexException) { if (getAuthorCount() <= i) throw(IndexException("Pokemod")); return authors[i]; } -const PokeMod::Author& PokeMod::Pokemod::getAuthorByID(const unsigned i) const throw(IndexException) +const Author& Pokemod::getAuthorByID(const unsigned i) const throw(IndexException) { return getAuthor(getAuthorIndex(i)); } -PokeMod::Author& PokeMod::Pokemod::getAuthorByID(const unsigned i) throw(IndexException) +Author& Pokemod::getAuthorByID(const unsigned i) throw(IndexException) { return getAuthor(getAuthorIndex(i)); } -unsigned PokeMod::Pokemod::getAuthorIndex(const unsigned _id) const +unsigned Pokemod::getAuthorIndex(const unsigned _id) const { for (unsigned i = 0; i < getAuthorCount(); ++i) { @@ -1081,49 +1081,61 @@ unsigned PokeMod::Pokemod::getAuthorIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getAuthorCount() const +unsigned Pokemod::getAuthorCount() const { return authors.size(); } -PokeMod::Author& PokeMod::Pokemod::newAuthor() +Author& Pokemod::newAuthor() { authors.append(Author(*this, getNewAuthorId())); return authors[getAuthorCount() + 1]; } -void PokeMod::Pokemod::deleteAuthor(const unsigned i) throw(IndexException) +Author& Pokemod::newAuthor(const QString& fname) +{ + authors.append(Author(*this, fname, getNewAuthorId())); + return authors[getAuthorCount() + 1]; +} + +Author& Pokemod::newAuthor(const Author& a) +{ + authors.append(Author(*this, a, getNewAuthorId())); + return authors[getAuthorCount() + 1]; +} + +void Pokemod::deleteAuthor(const unsigned i) throw(IndexException) { if (getAuthorCount() <= i) throw(IndexException("Pokemod")); authors.removeAt(i); } -const PokeMod::Badge& PokeMod::Pokemod::getBadge(const unsigned i) const throw(IndexException) +const Badge& Pokemod::getBadge(const unsigned i) const throw(IndexException) { if (i < getBadgeCount()) throw(IndexException("Pokemod")); return badges.at(i); } -PokeMod::Badge& PokeMod::Pokemod::getBadge(const unsigned i) throw(IndexException) +Badge& Pokemod::getBadge(const unsigned i) throw(IndexException) { if (i < getBadgeCount()) throw(IndexException("Pokemod")); return badges[i]; } -const PokeMod::Badge& PokeMod::Pokemod::getBadgeByID(const unsigned i) const throw(IndexException) +const Badge& Pokemod::getBadgeByID(const unsigned i) const throw(IndexException) { return getBadge(getBadgeIndex(i)); } -PokeMod::Badge& PokeMod::Pokemod::getBadgeByID(const unsigned i) throw(IndexException) +Badge& Pokemod::getBadgeByID(const unsigned i) throw(IndexException) { return getBadge(getBadgeIndex(i)); } -unsigned PokeMod::Pokemod::getBadgeIndex(const unsigned _id) const +unsigned Pokemod::getBadgeIndex(const unsigned _id) const { for (unsigned i = 0; i < getBadgeCount(); ++i) { @@ -1133,61 +1145,61 @@ unsigned PokeMod::Pokemod::getBadgeIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getBadgeCount() const +unsigned Pokemod::getBadgeCount() const { return badges.size(); } -PokeMod::Badge& PokeMod::Pokemod::newBadge() +Badge& Pokemod::newBadge() { badges.append(Badge(*this, getNewBadgeId())); return badges[getBadgeCount() - 1]; } -PokeMod::Badge& PokeMod::Pokemod::newBadge(const QString& fname) +Badge& Pokemod::newBadge(const QString& fname) { badges.append(Badge(*this, fname, getNewBadgeId())); return badges[getBadgeCount() - 1]; } -PokeMod::Badge& PokeMod::Pokemod::newBadge(const Badge& b) +Badge& Pokemod::newBadge(const Badge& b) { badges.append(Badge(*this, b, getNewBadgeId())); return badges[getBadgeCount() - 1]; } -void PokeMod::Pokemod::deleteBadge(const unsigned i) throw(IndexException) +void Pokemod::deleteBadge(const unsigned i) throw(IndexException) { if (getBadgeCount() <= i) throw(IndexException("Pokemod")); badges.removeAt(i); } -const PokeMod::CoinList& PokeMod::Pokemod::getCoinList(const unsigned i) const throw(IndexException) +const CoinList& Pokemod::getCoinList(const unsigned i) const throw(IndexException) { if (getCoinListCount() <= i) throw(IndexException("Pokemod")); return coinLists.at(i); } -PokeMod::CoinList& PokeMod::Pokemod::getCoinList(const unsigned i) throw(IndexException) +CoinList& Pokemod::getCoinList(const unsigned i) throw(IndexException) { if (getCoinListCount() <= i) throw(IndexException("Pokemod")); return coinLists[i]; } -const PokeMod::CoinList& PokeMod::Pokemod::getCoinListByID(const unsigned i) const throw(IndexException) +const CoinList& Pokemod::getCoinListByID(const unsigned i) const throw(IndexException) { return getCoinList(getCoinListIndex(i)); } -PokeMod::CoinList& PokeMod::Pokemod::getCoinListByID(const unsigned i) throw(IndexException) +CoinList& Pokemod::getCoinListByID(const unsigned i) throw(IndexException) { return getCoinList(getCoinListIndex(i)); } -unsigned PokeMod::Pokemod::getCoinListIndex(const unsigned _id) const +unsigned Pokemod::getCoinListIndex(const unsigned _id) const { for (unsigned i = 0; i < getCoinListCount(); ++i) { @@ -1197,61 +1209,61 @@ unsigned PokeMod::Pokemod::getCoinListIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getCoinListCount() const +unsigned Pokemod::getCoinListCount() const { return coinLists.size(); } -PokeMod::CoinList& PokeMod::Pokemod::newCoinList() +CoinList& Pokemod::newCoinList() { coinLists.append(CoinList(*this, getNewCoinListId())); return coinLists[getCoinListCount() - 1]; } -PokeMod::CoinList& PokeMod::Pokemod::newCoinList(const QString& fname) +CoinList& Pokemod::newCoinList(const QString& fname) { coinLists.append(CoinList(*this, fname, getNewCoinListId())); return coinLists[getCoinListCount() - 1]; } -PokeMod::CoinList& PokeMod::Pokemod::newCoinList(const CoinList& c) +CoinList& Pokemod::newCoinList(const CoinList& c) { coinLists.append(CoinList(*this, c, getNewCoinListId())); return coinLists[getCoinListCount() - 1]; } -void PokeMod::Pokemod::deleteCoinList(const unsigned i) throw(IndexException) +void Pokemod::deleteCoinList(const unsigned i) throw(IndexException) { if (getCoinListCount() <= i) throw(IndexException("Pokemod")); coinLists.removeAt(i); } -const PokeMod::Dialog& PokeMod::Pokemod::getDialog(const unsigned i) const throw(IndexException) +const Dialog& Pokemod::getDialog(const unsigned i) const throw(IndexException) { if (getDialogCount() <= i) throw(IndexException("Pokemod")); return dialogs.at(i); } -PokeMod::Dialog& PokeMod::Pokemod::getDialog(const unsigned i) throw(IndexException) +Dialog& Pokemod::getDialog(const unsigned i) throw(IndexException) { if (getDialogCount() <= i) throw(IndexException("Pokemod")); return dialogs[i]; } -const PokeMod::Dialog& PokeMod::Pokemod::getDialogByID(const unsigned i) const throw(IndexException) +const Dialog& Pokemod::getDialogByID(const unsigned i) const throw(IndexException) { return getDialog(getDialogIndex(i)); } -PokeMod::Dialog& PokeMod::Pokemod::getDialogByID(const unsigned i) throw(IndexException) +Dialog& Pokemod::getDialogByID(const unsigned i) throw(IndexException) { return getDialog(getDialogIndex(i)); } -unsigned PokeMod::Pokemod::getDialogIndex(const unsigned _id) const +unsigned Pokemod::getDialogIndex(const unsigned _id) const { for (unsigned i = 0; i < getDialogCount(); ++i) { @@ -1261,61 +1273,61 @@ unsigned PokeMod::Pokemod::getDialogIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getDialogCount() const +unsigned Pokemod::getDialogCount() const { return dialogs.size(); } -PokeMod::Dialog& PokeMod::Pokemod::newDialog() +Dialog& Pokemod::newDialog() { dialogs.append(Dialog(*this, getNewDialogId())); return dialogs[getDialogCount() - 1]; } -PokeMod::Dialog& PokeMod::Pokemod::newDialog(const QString& fname) +Dialog& Pokemod::newDialog(const QString& fname) { dialogs.append(Dialog(*this, fname, getNewDialogId())); return dialogs[getDialogCount() - 1]; } -PokeMod::Dialog& PokeMod::Pokemod::newDialog(const Dialog& d) +Dialog& Pokemod::newDialog(const Dialog& d) { dialogs.append(Dialog(*this, d, getNewDialogId())); return dialogs[getDialogCount() - 1]; } -void PokeMod::Pokemod::deleteDialog(const unsigned i) throw(IndexException) +void Pokemod::deleteDialog(const unsigned i) throw(IndexException) { if (getDialogCount() <= i) throw(IndexException("Pokemod")); dialogs.removeAt(i); } -const PokeMod::EggGroup& PokeMod::Pokemod::getEggGroup(const unsigned i) const throw(IndexException) +const EggGroup& Pokemod::getEggGroup(const unsigned i) const throw(IndexException) { if (getEggGroupCount() <= i) throw(IndexException("Pokemod")); return eggGroups.at(i); } -PokeMod::EggGroup& PokeMod::Pokemod::getEggGroup(const unsigned i) throw(IndexException) +EggGroup& Pokemod::getEggGroup(const unsigned i) throw(IndexException) { if (getEggGroupCount() <= i) throw(IndexException("Pokemod")); return eggGroups[i]; } -const PokeMod::EggGroup& PokeMod::Pokemod::getEggGroupByID(const unsigned i) const throw(IndexException) +const EggGroup& Pokemod::getEggGroupByID(const unsigned i) const throw(IndexException) { return getEggGroup(getEggGroupIndex(i)); } -PokeMod::EggGroup& PokeMod::Pokemod::getEggGroupByID(const unsigned i) throw(IndexException) +EggGroup& Pokemod::getEggGroupByID(const unsigned i) throw(IndexException) { return getEggGroup(getEggGroupIndex(i)); } -unsigned PokeMod::Pokemod::getEggGroupIndex(const unsigned _id) const +unsigned Pokemod::getEggGroupIndex(const unsigned _id) const { for (unsigned i = 0; i < getEggGroupCount(); ++i) { @@ -1325,61 +1337,61 @@ unsigned PokeMod::Pokemod::getEggGroupIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getEggGroupCount() const +unsigned Pokemod::getEggGroupCount() const { return eggGroups.size(); } -PokeMod::EggGroup& PokeMod::Pokemod::newEggGroup() +EggGroup& Pokemod::newEggGroup() { eggGroups.append(EggGroup(*this, getNewEggGroupId())); return eggGroups[getEggGroupCount() - 1]; } -PokeMod::EggGroup& PokeMod::Pokemod::newEggGroup(const QString& fname) +EggGroup& Pokemod::newEggGroup(const QString& fname) { eggGroups.append(EggGroup(*this, fname, getNewEggGroupId())); return eggGroups[getEggGroupCount() - 1]; } -PokeMod::EggGroup& PokeMod::Pokemod::newEggGroup(const EggGroup& e) +EggGroup& Pokemod::newEggGroup(const EggGroup& e) { eggGroups.append(EggGroup(*this, e, getNewEggGroupId())); return eggGroups[getEggGroupCount() - 1]; } -void PokeMod::Pokemod::deleteEggGroup(const unsigned i) throw(IndexException) +void Pokemod::deleteEggGroup(const unsigned i) throw(IndexException) { if (getEggGroupCount() <= i) throw(IndexException("Pokemod")); eggGroups.removeAt(i); } -const PokeMod::Item& PokeMod::Pokemod::getItem(const unsigned i) const throw(IndexException) +const Item& Pokemod::getItem(const unsigned i) const throw(IndexException) { if (getItemCount() <= i) throw(IndexException("Pokemod")); return items.at(i); } -PokeMod::Item& PokeMod::Pokemod::getItem(const unsigned i) throw(IndexException) +Item& Pokemod::getItem(const unsigned i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException("Pokemod")); return items[i]; } -const PokeMod::Item& PokeMod::Pokemod::getItemByID(const unsigned i) const throw(IndexException) +const Item& Pokemod::getItemByID(const unsigned i) const throw(IndexException) { return getItem(getItemIndex(i)); } -PokeMod::Item& PokeMod::Pokemod::getItemByID(const unsigned i) throw(IndexException) +Item& Pokemod::getItemByID(const unsigned i) throw(IndexException) { return getItem(getItemIndex(i)); } -unsigned PokeMod::Pokemod::getItemIndex(const unsigned _id) const +unsigned Pokemod::getItemIndex(const unsigned _id) const { for (unsigned i = 0; i < getItemCount(); ++i) { @@ -1389,61 +1401,61 @@ unsigned PokeMod::Pokemod::getItemIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getItemCount() const +unsigned Pokemod::getItemCount() const { return items.size(); } -PokeMod::Item& PokeMod::Pokemod::newItem() +Item& Pokemod::newItem() { items.append(Item(*this, getNewItemId())); return items[getItemCount() - 1]; } -PokeMod::Item& PokeMod::Pokemod::newItem(const QString& fname) +Item& Pokemod::newItem(const QString& fname) { items.append(Item(*this, fname, getNewItemId())); return items[getItemCount() - 1]; } -PokeMod::Item& PokeMod::Pokemod::newItem(const Item& i) +Item& Pokemod::newItem(const Item& i) { items.append(Item(*this, i, getNewItemId())); return items[getItemCount() - 1]; } -void PokeMod::Pokemod::deleteItem(const unsigned i) throw(IndexException) +void Pokemod::deleteItem(const unsigned i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException("Pokemod")); items.removeAt(i); } -const PokeMod::ItemType& PokeMod::Pokemod::getItemType(const unsigned i) const throw(IndexException) +const ItemType& Pokemod::getItemType(const unsigned i) const throw(IndexException) { if (getItemTypeCount() <= i) throw(IndexException("Pokemod")); return itemTypes.at(i); } -PokeMod::ItemType& PokeMod::Pokemod::getItemType(const unsigned i) throw(IndexException) +ItemType& Pokemod::getItemType(const unsigned i) throw(IndexException) { if (getItemTypeCount() <= i) throw(IndexException("Pokemod")); return itemTypes[i]; } -const PokeMod::ItemType& PokeMod::Pokemod::getItemTypeByID(const unsigned i) const throw(IndexException) +const ItemType& Pokemod::getItemTypeByID(const unsigned i) const throw(IndexException) { return getItemType(getItemTypeIndex(i)); } -PokeMod::ItemType& PokeMod::Pokemod::getItemTypeByID(const unsigned i) throw(IndexException) +ItemType& Pokemod::getItemTypeByID(const unsigned i) throw(IndexException) { return getItemType(getItemTypeIndex(i)); } -unsigned PokeMod::Pokemod::getItemTypeIndex(const unsigned _id) const +unsigned Pokemod::getItemTypeIndex(const unsigned _id) const { for (unsigned i = 0; i < getItemTypeCount(); ++i) { @@ -1453,61 +1465,61 @@ unsigned PokeMod::Pokemod::getItemTypeIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getItemTypeCount() const +unsigned Pokemod::getItemTypeCount() const { return itemTypes.size(); } -PokeMod::ItemType& PokeMod::Pokemod::newItemType() +ItemType& Pokemod::newItemType() { itemTypes.append(ItemType(*this, getNewItemTypeId())); return itemTypes[getItemTypeCount() - 1]; } -PokeMod::ItemType& PokeMod::Pokemod::newItemType(const QString& fname) +ItemType& Pokemod::newItemType(const QString& fname) { itemTypes.append(ItemType(*this, fname, getNewItemTypeId())); return itemTypes[getItemTypeCount() - 1]; } -PokeMod::ItemType& PokeMod::Pokemod::newItemType(const ItemType& i) +ItemType& Pokemod::newItemType(const ItemType& i) { itemTypes.append(ItemType(*this, i, getNewItemTypeId())); return itemTypes[getItemTypeCount() - 1]; } -void PokeMod::Pokemod::deleteItemType(const unsigned i) throw(IndexException) +void Pokemod::deleteItemType(const unsigned i) throw(IndexException) { if (getItemTypeCount() <= i) throw(IndexException("Pokemod")); itemTypes.removeAt(i); } -const PokeMod::Map& PokeMod::Pokemod::getMap(const unsigned i) const throw(IndexException) +const Map& Pokemod::getMap(const unsigned i) const throw(IndexException) { if (getMapCount() <= i) throw(IndexException("Pokemod")); return maps.at(i); } -PokeMod::Map& PokeMod::Pokemod::getMap(const unsigned i) throw(IndexException) +Map& Pokemod::getMap(const unsigned i) throw(IndexException) { if (getMapCount() <= i) throw(IndexException("Pokemod")); return maps[i]; } -const PokeMod::Map& PokeMod::Pokemod::getMapByID(const unsigned i) const throw(IndexException) +const Map& Pokemod::getMapByID(const unsigned i) const throw(IndexException) { return getMap(getMapIndex(i)); } -PokeMod::Map& PokeMod::Pokemod::getMapByID(const unsigned i) throw(IndexException) +Map& Pokemod::getMapByID(const unsigned i) throw(IndexException) { return getMap(getMapIndex(i)); } -unsigned PokeMod::Pokemod::getMapIndex(const unsigned _id) const +unsigned Pokemod::getMapIndex(const unsigned _id) const { for (unsigned i = 0; i < getMapCount(); ++i) { @@ -1517,61 +1529,61 @@ unsigned PokeMod::Pokemod::getMapIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getMapCount() const +unsigned Pokemod::getMapCount() const { return maps.size(); } -PokeMod::Map& PokeMod::Pokemod::newMap() +Map& Pokemod::newMap() { maps.append(Map(*this, getNewMapId())); return maps[getMapCount() - 1]; } -PokeMod::Map& PokeMod::Pokemod::newMap(const QString& fname) +Map& Pokemod::newMap(const QString& fname) { maps.append(Map(*this, fname, getNewMapId())); return maps[getMapCount() - 1]; } -PokeMod::Map& PokeMod::Pokemod::newMap(const Map& m) +Map& Pokemod::newMap(const Map& m) { maps.append(Map(*this, m, getNewMapId())); return maps[getMapCount() - 1]; } -void PokeMod::Pokemod::deleteMap(const unsigned i) throw(IndexException) +void Pokemod::deleteMap(const unsigned i) throw(IndexException) { if (getMapCount() <= i) throw(IndexException("Pokemod")); maps.removeAt(i); } -const PokeMod::Move& PokeMod::Pokemod::getMove(const unsigned i) const throw(IndexException) +const Move& Pokemod::getMove(const unsigned i) const throw(IndexException) { if (getMoveCount() <= i) throw(IndexException("Pokemod")); return moves.at(i); } -PokeMod::Move& PokeMod::Pokemod::getMove(const unsigned i) throw(IndexException) +Move& Pokemod::getMove(const unsigned i) throw(IndexException) { if (getMoveCount() <= i) throw(IndexException("Pokemod")); return moves[i]; } -const PokeMod::Move& PokeMod::Pokemod::getMoveByID(const unsigned i) const throw(IndexException) +const Move& Pokemod::getMoveByID(const unsigned i) const throw(IndexException) { return getMove(getMoveIndex(i)); } -PokeMod::Move& PokeMod::Pokemod::getMoveByID(const unsigned i) throw(IndexException) +Move& Pokemod::getMoveByID(const unsigned i) throw(IndexException) { return getMove(getMoveIndex(i)); } -unsigned PokeMod::Pokemod::getMoveIndex(const unsigned _id) const +unsigned Pokemod::getMoveIndex(const unsigned _id) const { for (unsigned i = 0; i < getMoveCount(); ++i) { @@ -1581,61 +1593,61 @@ unsigned PokeMod::Pokemod::getMoveIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getMoveCount() const +unsigned Pokemod::getMoveCount() const { return moves.size(); } -PokeMod::Move& PokeMod::Pokemod::newMove() +Move& Pokemod::newMove() { moves.append(Move(*this, getNewMoveId())); return moves[getMoveCount() - 1]; } -PokeMod::Move& PokeMod::Pokemod::newMove(const QString& fname) +Move& Pokemod::newMove(const QString& fname) { moves.append(Move(*this, fname, getNewMoveId())); return moves[getMoveCount() - 1]; } -PokeMod::Move& PokeMod::Pokemod::newMove(const Move& m) +Move& Pokemod::newMove(const Move& m) { moves.append(Move(*this, m, getNewMoveId())); return moves[getMoveCount() - 1]; } -void PokeMod::Pokemod::deleteMove(const unsigned i) throw(IndexException) +void Pokemod::deleteMove(const unsigned i) throw(IndexException) { if (getMoveCount() <= i) throw(IndexException("Pokemod")); moves.removeAt(i); } -const PokeMod::Nature& PokeMod::Pokemod::getNature(const unsigned i) const throw(IndexException) +const Nature& Pokemod::getNature(const unsigned i) const throw(IndexException) { if (getNatureCount() <= i) throw(IndexException("Pokemod")); return natures.at(i); } -PokeMod::Nature& PokeMod::Pokemod::getNature(const unsigned i) throw(IndexException) +Nature& Pokemod::getNature(const unsigned i) throw(IndexException) { if (getNatureCount() <= i) throw(IndexException("Pokemod")); return natures[i]; } -const PokeMod::Nature& PokeMod::Pokemod::getNatureByID(const unsigned i) const throw(IndexException) +const Nature& Pokemod::getNatureByID(const unsigned i) const throw(IndexException) { return getNature(getNatureIndex(i)); } -PokeMod::Nature& PokeMod::Pokemod::getNatureByID(const unsigned i) throw(IndexException) +Nature& Pokemod::getNatureByID(const unsigned i) throw(IndexException) { return getNature(getNatureIndex(i)); } -unsigned PokeMod::Pokemod::getNatureIndex(const unsigned _id) const +unsigned Pokemod::getNatureIndex(const unsigned _id) const { for (unsigned i = 0; i < getNatureCount(); ++i) { @@ -1645,61 +1657,61 @@ unsigned PokeMod::Pokemod::getNatureIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getNatureCount() const +unsigned Pokemod::getNatureCount() const { return natures.size(); } -PokeMod::Nature& PokeMod::Pokemod::newNature() +Nature& Pokemod::newNature() { natures.append(Nature(*this, getNewNatureId())); return natures[getNatureCount() - 1]; } -PokeMod::Nature& PokeMod::Pokemod::newNature(const QString& fname) +Nature& Pokemod::newNature(const QString& fname) { natures.append(Nature(*this, fname, getNewNatureId())); return natures[getNatureCount() - 1]; } -PokeMod::Nature& PokeMod::Pokemod::newNature(const Nature& n) +Nature& Pokemod::newNature(const Nature& n) { natures.append(Nature(*this, n, getNewNatureId())); return natures[getNatureCount() - 1]; } -void PokeMod::Pokemod::deleteNature(const unsigned i) throw(IndexException) +void Pokemod::deleteNature(const unsigned i) throw(IndexException) { if (getNatureCount() <= i) throw(IndexException("Pokemod")); natures.removeAt(i); } -const PokeMod::Species& PokeMod::Pokemod::getSpecies(const unsigned i) const throw(IndexException) +const Species& Pokemod::getSpecies(const unsigned i) const throw(IndexException) { if (getSpeciesCount() <= i) throw(IndexException("Pokemod")); return species.at(i); } -PokeMod::Species& PokeMod::Pokemod::getSpecies(const unsigned i) throw(IndexException) +Species& Pokemod::getSpecies(const unsigned i) throw(IndexException) { if (getSpeciesCount() <= i) throw(IndexException("Pokemod")); return species[i]; } -const PokeMod::Species& PokeMod::Pokemod::getSpeciesByID(const unsigned i) const throw(IndexException) +const Species& Pokemod::getSpeciesByID(const unsigned i) const throw(IndexException) { return getSpecies(getSpeciesIndex(i)); } -PokeMod::Species& PokeMod::Pokemod::getSpeciesByID(const unsigned i) throw(IndexException) +Species& Pokemod::getSpeciesByID(const unsigned i) throw(IndexException) { return getSpecies(getSpeciesIndex(i)); } -unsigned PokeMod::Pokemod::getSpeciesIndex(const unsigned _id) const +unsigned Pokemod::getSpeciesIndex(const unsigned _id) const { for (unsigned i = 0; i < getSpeciesCount(); ++i) { @@ -1709,61 +1721,61 @@ unsigned PokeMod::Pokemod::getSpeciesIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getSpeciesCount() const +unsigned Pokemod::getSpeciesCount() const { return species.size(); } -PokeMod::Species& PokeMod::Pokemod::newSpecies() +Species& Pokemod::newSpecies() { species.append(Species(*this, getNewSpeciesId())); return species[getSpeciesCount() - 1]; } -PokeMod::Species& PokeMod::Pokemod::newSpecies(const QString& fname) +Species& Pokemod::newSpecies(const QString& fname) { species.append(Species(*this, fname, getNewSpeciesId())); return species[getSpeciesCount() - 1]; } -PokeMod::Species& PokeMod::Pokemod::newSpecies(const Species& s) +Species& Pokemod::newSpecies(const Species& s) { species.append(Species(*this, s, getNewSpeciesId())); return species[getSpeciesCount() - 1]; } -void PokeMod::Pokemod::deleteSpecies(const unsigned i) throw(IndexException) +void Pokemod::deleteSpecies(const unsigned i) throw(IndexException) { if (getSpeciesCount() <= i) throw(IndexException("Pokemod")); species.removeAt(i); } -const PokeMod::Store& PokeMod::Pokemod::getStore(const unsigned i) const throw(IndexException) +const Store& Pokemod::getStore(const unsigned i) const throw(IndexException) { if (getStoreCount() <= i) throw(IndexException("Pokemod")); return stores.at(i); } -PokeMod::Store& PokeMod::Pokemod::getStore(const unsigned i) throw(IndexException) +Store& Pokemod::getStore(const unsigned i) throw(IndexException) { if (getStoreCount() <= i) throw(IndexException("Pokemod")); return stores[i]; } -const PokeMod::Store& PokeMod::Pokemod::getStoreByID(const unsigned i) const throw(IndexException) +const Store& Pokemod::getStoreByID(const unsigned i) const throw(IndexException) { return getStore(getStoreIndex(i)); } -PokeMod::Store& PokeMod::Pokemod::getStoreByID(const unsigned i) throw(IndexException) +Store& Pokemod::getStoreByID(const unsigned i) throw(IndexException) { return getStore(getStoreIndex(i)); } -unsigned PokeMod::Pokemod::getStoreIndex(const unsigned _id) const +unsigned Pokemod::getStoreIndex(const unsigned _id) const { for (unsigned i = 0; i < getStoreCount(); ++i) { @@ -1773,61 +1785,61 @@ unsigned PokeMod::Pokemod::getStoreIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getStoreCount() const +unsigned Pokemod::getStoreCount() const { return stores.size(); } -PokeMod::Store& PokeMod::Pokemod::newStore() +Store& Pokemod::newStore() { stores.append(Store(*this, getNewStoreId())); return stores[getStoreCount() - 1]; } -PokeMod::Store& PokeMod::Pokemod::newStore(const QString& fname) +Store& Pokemod::newStore(const QString& fname) { stores.append(Store(*this, fname, getNewStoreId())); return stores[getStoreCount() - 1]; } -PokeMod::Store& PokeMod::Pokemod::newStore(const Store& s) +Store& Pokemod::newStore(const Store& s) { stores.append(Store(*this, s, getNewStoreId())); return stores[getStoreCount() - 1]; } -void PokeMod::Pokemod::deleteStore(const unsigned i) throw(IndexException) +void Pokemod::deleteStore(const unsigned i) throw(IndexException) { if (getStoreCount() <= i) throw(IndexException("Pokemod")); stores.removeAt(i); } -const PokeMod::Tile& PokeMod::Pokemod::getTile(const unsigned i) const throw(IndexException) +const Tile& Pokemod::getTile(const unsigned i) const throw(IndexException) { if (getTileCount() <= i) throw(IndexException("Pokemod")); return tiles.at(i); } -PokeMod::Tile& PokeMod::Pokemod::getTile(const unsigned i) throw(IndexException) +Tile& Pokemod::getTile(const unsigned i) throw(IndexException) { if (getTileCount() <= i) throw(IndexException("Pokemod")); return tiles[i]; } -const PokeMod::Tile& PokeMod::Pokemod::getTileByID(const unsigned i) const throw(IndexException) +const Tile& Pokemod::getTileByID(const unsigned i) const throw(IndexException) { return getTile(getTileIndex(i)); } -PokeMod::Tile& PokeMod::Pokemod::getTileByID(const unsigned i) throw(IndexException) +Tile& Pokemod::getTileByID(const unsigned i) throw(IndexException) { return getTile(getTileIndex(i)); } -unsigned PokeMod::Pokemod::getTileIndex(const unsigned _id) const +unsigned Pokemod::getTileIndex(const unsigned _id) const { for (unsigned i = 0; i < getTileCount(); ++i) { @@ -1837,61 +1849,61 @@ unsigned PokeMod::Pokemod::getTileIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getTileCount() const +unsigned Pokemod::getTileCount() const { return tiles.size(); } -PokeMod::Tile& PokeMod::Pokemod::newTile() +Tile& Pokemod::newTile() { tiles.append(Tile(*this, getNewTileId())); return tiles[getTileCount() - 1]; } -PokeMod::Tile& PokeMod::Pokemod::newTile(const QString& fname) +Tile& Pokemod::newTile(const QString& fname) { tiles.append(Tile(*this, fname, getNewTileId())); return tiles[getTileCount() - 1]; } -PokeMod::Tile& PokeMod::Pokemod::newTile(const Tile& t) +Tile& Pokemod::newTile(const Tile& t) { tiles.append(Tile(*this, t, getNewTileId())); return tiles[getTileCount() - 1]; } -void PokeMod::Pokemod::deleteTile(const unsigned i) throw(IndexException) +void Pokemod::deleteTile(const unsigned i) throw(IndexException) { if (getTileCount() <= i) throw(IndexException("Pokemod")); tiles.removeAt(i); } -const PokeMod::Time& PokeMod::Pokemod::getTime(const unsigned i) const throw(IndexException) +const Time& Pokemod::getTime(const unsigned i) const throw(IndexException) { if (getTimeCount() <= i) throw(IndexException("Pokemod")); return times.at(i); } -PokeMod::Time& PokeMod::Pokemod::getTime(const unsigned i) throw(IndexException) +Time& Pokemod::getTime(const unsigned i) throw(IndexException) { if (getTimeCount() <= i) throw(IndexException("Pokemod")); return times[i]; } -const PokeMod::Time& PokeMod::Pokemod::getTimeByID(const unsigned i) const throw(IndexException) +const Time& Pokemod::getTimeByID(const unsigned i) const throw(IndexException) { return getTime(getTimeIndex(i)); } -PokeMod::Time& PokeMod::Pokemod::getTimeByID(const unsigned i) throw(IndexException) +Time& Pokemod::getTimeByID(const unsigned i) throw(IndexException) { return getTime(getTimeIndex(i)); } -unsigned PokeMod::Pokemod::getTimeIndex(const unsigned _id) const +unsigned Pokemod::getTimeIndex(const unsigned _id) const { for (unsigned i = 0; i < getTimeCount(); ++i) { @@ -1901,61 +1913,61 @@ unsigned PokeMod::Pokemod::getTimeIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getTimeCount() const +unsigned Pokemod::getTimeCount() const { return times.size(); } -PokeMod::Time& PokeMod::Pokemod::newTime() +Time& Pokemod::newTime() { times.append(Time(*this, getNewTimeId())); return times[getTimeCount() - 1]; } -PokeMod::Time& PokeMod::Pokemod::newTime(const QString& fname) +Time& Pokemod::newTime(const QString& fname) { times.append(Time(*this, fname, getNewTimeId())); return times[getTimeCount() - 1]; } -PokeMod::Time& PokeMod::Pokemod::newTime(const Time& t) +Time& Pokemod::newTime(const Time& t) { times.append(Time(*this, t, getNewTimeId())); return times[getTimeCount() - 1]; } -void PokeMod::Pokemod::deleteTime(const unsigned i) throw(IndexException) +void Pokemod::deleteTime(const unsigned i) throw(IndexException) { if (getTimeCount() <= i) throw(IndexException("Pokemod")); times.removeAt(i); } -const PokeMod::Type& PokeMod::Pokemod::getType(const unsigned i) const throw(IndexException) +const Type& Pokemod::getType(const unsigned i) const throw(IndexException) { if (getTypeCount() <= i) throw(IndexException("Pokemod")); return types.at(i); } -PokeMod::Type& PokeMod::Pokemod::getType(const unsigned i) throw(IndexException) +Type& Pokemod::getType(const unsigned i) throw(IndexException) { if (getTypeCount() <= i) throw(IndexException("Pokemod")); return types[i]; } -const PokeMod::Type& PokeMod::Pokemod::getTypeByID(const unsigned i) const throw(IndexException) +const Type& Pokemod::getTypeByID(const unsigned i) const throw(IndexException) { return getType(getTypeIndex(i)); } -PokeMod::Type& PokeMod::Pokemod::getTypeByID(const unsigned i) throw(IndexException) +Type& Pokemod::getTypeByID(const unsigned i) throw(IndexException) { return getType(getTypeIndex(i)); } -unsigned PokeMod::Pokemod::getTypeIndex(const unsigned _id) const +unsigned Pokemod::getTypeIndex(const unsigned _id) const { for (unsigned i = 0; i < getTypeCount(); ++i) { @@ -1965,12 +1977,12 @@ unsigned PokeMod::Pokemod::getTypeIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Pokemod::getTypeCount() const +unsigned Pokemod::getTypeCount() const { return types.size(); } -PokeMod::Type& PokeMod::Pokemod::newType() +Type& Pokemod::newType() { unsigned i; types.append(Type(*this, i = getNewTypeId())); @@ -1979,7 +1991,7 @@ PokeMod::Type& PokeMod::Pokemod::newType() return types[getTypeCount() - 1]; } -PokeMod::Type& PokeMod::Pokemod::newType(const QString& fname) +Type& Pokemod::newType(const QString& fname) { unsigned i; types.append(Type(*this, fname, i = getNewTypeId())); @@ -1988,7 +2000,7 @@ PokeMod::Type& PokeMod::Pokemod::newType(const QString& fname) return types[getTypeCount() - 1]; } -PokeMod::Type& PokeMod::Pokemod::newType(const Type& t) +Type& Pokemod::newType(const Type& t) { unsigned i; types.append(Type(*this, t, i = getNewTypeId())); @@ -1997,7 +2009,7 @@ PokeMod::Type& PokeMod::Pokemod::newType(const Type& t) return types[getTypeCount() - 1]; } -void PokeMod::Pokemod::deleteType(const unsigned i) throw(IndexException) +void Pokemod::deleteType(const unsigned i) throw(IndexException) { if (getTypeCount() <= i) throw(IndexException("Pokemod")); diff --git a/pokemod/Pokemod.h b/pokemod/Pokemod.h index 4576d7e3..cd366c9b 100644 --- a/pokemod/Pokemod.h +++ b/pokemod/Pokemod.h @@ -48,287 +48,284 @@ #include "Time.h" #include "Type.h" -namespace PokeMod +class Pokemod : public Object { - class Pokemod : public Object - { - public: - enum Validation - { - V_Msg = 0, - V_Warn = 1, - V_Error = 2 - }; - - Pokemod(const QString& fpath); - - void load(const QString& fpath) throw(Exception); - void save() const throw(Exception); - - QString getPath() const; - - unsigned maxCompatability(const Pokemod& p) const; - - void validationMsg(const QString& msg, Validation val = V_Error) const; - void setValidationOutput(QIODevice& s); - - void setTitle(const QString& t); - void setVersion(const QString& v); - void setDescription(const QString& d); - void setStartMap(const unsigned s) throw(BoundsException); - void setStartWarp(const unsigned s) throw(BoundsException); - void setWalkSkin(const QString& fname) throw(Exception); - void setBikeSkin(const QString& fname) throw(Exception); - void setSurfSkin(const QString& fname) throw(Exception); - void setFlySkin(const QString& fname) throw(Exception); - void setFishSkin(const QString& fname) throw(Exception); - void setSurfFishSkin(const QString& fname) throw(Exception); - void setSuperPCUname(const QString& u); - void setSuperPCPasswd(const QString& p); - void setTypeChart(const unsigned att, const unsigned def, const unsigned n, const unsigned d) throw(Exception); - void setTypeChartNum(const unsigned att, const unsigned def, const unsigned n) throw(Exception); - void setTypeChartDenom(const unsigned att, const unsigned def, const unsigned d) throw(Exception); - void setRules(const Rules& r); - void setRules(const QString& fname); - - QString getTitle() const; - QString getVersion() const; - QString getDescription() const; - unsigned getStartMap() const; - unsigned getStartWarp() const; - QString getSuperPCUname() const; - QString getSuperPCPasswd() const; - const FracMatrix& getTypeChart() const; - FracMatrix& getTypeChart(); - Frac getTypeChart(const unsigned att, const unsigned def) const; - const Rules& getRules() const; - Rules& getRules(); - - const Ability& getAbility(const unsigned i) const throw(IndexException); - Ability& getAbility(const unsigned i) throw(IndexException); - const Ability& getAbilityByID(const unsigned i) const throw(IndexException); - Ability& getAbilityByID(const unsigned i) throw(IndexException); - unsigned getAbilityIndex(const unsigned i) const; - unsigned getAbilityCount() const; - Ability& newAbility(); - Ability& newAbility(const QString& fname); - Ability& newAbility(const Ability& a); - void deleteAbility(const unsigned i) throw(IndexException); - - const Author& getAuthor(const unsigned i) const throw(IndexException); - Author& getAuthor(const unsigned i) throw(IndexException); - const Author& getAuthorByID(const unsigned i) const throw(IndexException); - Author& getAuthorByID(const unsigned i) throw(IndexException); - unsigned getAuthorIndex(const unsigned i) const; - unsigned getAuthorCount() const; - Author& newAuthor(); - Author& newAuthor(const QString& fname); - Author& newAuthor(const Author& a); - void deleteAuthor(const unsigned i) throw(IndexException); - - const Badge& getBadge(const unsigned i) const throw(IndexException); - Badge& getBadge(const unsigned i) throw(IndexException); - const Badge& getBadgeByID(const unsigned i) const throw(IndexException); - Badge& getBadgeByID(const unsigned i) throw(IndexException); - unsigned getBadgeIndex(const unsigned i) const; - unsigned getBadgeCount() const; - Badge& newBadge(); - Badge& newBadge(const QString& fname); - Badge& newBadge(const Badge& b); - void deleteBadge(const unsigned i) throw(IndexException); - - const CoinList& getCoinList(const unsigned i) const throw(IndexException); - CoinList& getCoinList(const unsigned i) throw(IndexException); - const CoinList& getCoinListByID(const unsigned i) const throw(IndexException); - CoinList& getCoinListByID(const unsigned i) throw(IndexException); - unsigned getCoinListIndex(const unsigned i) const; - unsigned getCoinListCount() const; - CoinList& newCoinList(); - CoinList& newCoinList(const QString& fname); - CoinList& newCoinList(const CoinList& c); - void deleteCoinList(const unsigned i) throw(IndexException); - - const Dialog& getDialog(const unsigned i) const throw(IndexException); - Dialog& getDialog(const unsigned i) throw(IndexException); - const Dialog& getDialogByID(const unsigned i) const throw(IndexException); - Dialog& getDialogByID(const unsigned i) throw(IndexException); - unsigned getDialogIndex(const unsigned i) const; - unsigned getDialogCount() const; - Dialog& newDialog(); - Dialog& newDialog(const QString& fname); - Dialog& newDialog(const Dialog& d); - void deleteDialog(const unsigned i) throw(IndexException); - - const EggGroup& getEggGroup(const unsigned i) const throw(IndexException); - EggGroup& getEggGroup(const unsigned i) throw(IndexException); - const EggGroup& getEggGroupByID(const unsigned i) const throw(IndexException); - EggGroup& getEggGroupByID(const unsigned i) throw(IndexException); - unsigned getEggGroupIndex(const unsigned i) const; - unsigned getEggGroupCount() const; - EggGroup& newEggGroup(); - EggGroup& newEggGroup(const QString& fname); - EggGroup& newEggGroup(const EggGroup& e); - void deleteEggGroup(const unsigned i) throw(IndexException); - - const Item& getItem(const unsigned i) const throw(IndexException); - Item& getItem(const unsigned i) throw(IndexException); - const Item& getItemByID(const unsigned i) const throw(IndexException); - Item& getItemByID(const unsigned i) throw(IndexException); - unsigned getItemIndex(const unsigned i) const; - unsigned getItemCount() const; - Item& newItem(); - Item& newItem(const QString& fname); - Item& newItem(const Item& i); - void deleteItem(const unsigned i) throw(IndexException); - - const ItemType& getItemType(const unsigned i) const throw(IndexException); - ItemType& getItemType(const unsigned i) throw(IndexException); - const ItemType& getItemTypeByID(const unsigned i) const throw(IndexException); - ItemType& getItemTypeByID(const unsigned i) throw(IndexException); - unsigned getItemTypeIndex(const unsigned i) const; - unsigned getItemTypeCount() const; - ItemType& newItemType(); - ItemType& newItemType(const QString& fname); - ItemType& newItemType(const ItemType& i); - void deleteItemType(const unsigned i) throw(IndexException); - - const Map& getMap(const unsigned i) const throw(IndexException); - Map& getMap(const unsigned i) throw(IndexException); - const Map& getMapByID(const unsigned i) const throw(IndexException); - Map& getMapByID(const unsigned i) throw(IndexException); - unsigned getMapIndex(const unsigned i) const; - unsigned getMapCount() const; - Map& newMap(); - Map& newMap(const QString& fname); - Map& newMap(const Map& m); - void deleteMap(const unsigned i) throw(IndexException); - - const Move& getMove(const unsigned i) const throw(IndexException); - Move& getMove(const unsigned i) throw(IndexException); - const Move& getMoveByID(const unsigned i) const throw(IndexException); - Move& getMoveByID(const unsigned i) throw(IndexException); - unsigned getMoveIndex(const unsigned i) const; - unsigned getMoveCount() const; - Move& newMove(); - Move& newMove(const QString& fname); - Move& newMove(const Move& m); - void deleteMove(const unsigned i) throw(IndexException); - - const Nature& getNature(const unsigned i) const throw(IndexException); - Nature& getNature(const unsigned i) throw(IndexException); - const Nature& getNatureByID(const unsigned i) const throw(IndexException); - Nature& getNatureByID(const unsigned i) throw(IndexException); - unsigned getNatureIndex(const unsigned i) const; - unsigned getNatureCount() const; - Nature& newNature(); - Nature& newNature(const QString& fname); - Nature& newNature(const Nature& n); - void deleteNature(const unsigned i) throw(IndexException); - - const Species& getSpecies(const unsigned i) const throw(IndexException); - Species& getSpecies(const unsigned i) throw(IndexException); - const Species& getSpeciesByID(const unsigned i) const throw(IndexException); - Species& getSpeciesByID(const unsigned i) throw(IndexException); - unsigned getSpeciesIndex(const unsigned i) const; - unsigned getSpeciesCount() const; - Species& newSpecies(); - Species& newSpecies(const QString& fname); - Species& newSpecies(const Species& s); - void deleteSpecies(const unsigned i) throw(IndexException); - - const Store& getStore(const unsigned i) const throw(IndexException); - Store& getStore(const unsigned i) throw(IndexException); - const Store& getStoreByID(const unsigned i) const throw(IndexException); - Store& getStoreByID(const unsigned i) throw(IndexException); - unsigned getStoreIndex(const unsigned i) const; - unsigned getStoreCount() const; - Store& newStore(); - Store& newStore(const QString& fname); - Store& newStore(const Store& s); - void deleteStore(const unsigned i) throw(IndexException); - - const Tile& getTile(const unsigned i) const throw(IndexException); - Tile& getTile(const unsigned i) throw(IndexException); - const Tile& getTileByID(const unsigned i) const throw(IndexException); - Tile& getTileByID(const unsigned i) throw(IndexException); - unsigned getTileIndex(const unsigned i) const; - unsigned getTileCount() const; - Tile& newTile(); - Tile& newTile(const QString& fname); - Tile& newTile(const Tile& t); - void deleteTile(const unsigned i) throw(IndexException); - - const Time& getTime(const unsigned i) const throw(IndexException); - Time& getTime(const unsigned i) throw(IndexException); - const Time& getTimeByID(const unsigned i) const throw(IndexException); - Time& getTimeByID(const unsigned i) throw(IndexException); - unsigned getTimeIndex(const unsigned i) const; - unsigned getTimeCount() const; - Time& newTime(); - Time& newTime(const QString& fname); - Time& newTime(const Time& t); - void deleteTime(const unsigned i) throw(IndexException); - - const Type& getType(const unsigned i) const throw(IndexException); - Type& getType(const unsigned i) throw(IndexException); - const Type& getTypeByID(const unsigned i) const throw(IndexException); - Type& getTypeByID(const unsigned i) throw(IndexException); - unsigned getTypeIndex(const unsigned i) const; - unsigned getTypeCount() const; - Type& newType(); - Type& newType(const QString& fname); - Type& newType(const Type& t); - void deleteType(const unsigned i) throw(IndexException); - private: - QIODevice* valstream; - - bool validate() const; - unsigned getNewAbilityId() const; - unsigned getNewAuthorId() const; - unsigned getNewBadgeId() const; - unsigned getNewCoinListId() const; - unsigned getNewDialogId() const; - unsigned getNewEggGroupId() const; - unsigned getNewItemId() const; - unsigned getNewItemTypeId() const; - unsigned getNewMapId() const; - unsigned getNewMoveId() const; - unsigned getNewNatureId() const; - unsigned getNewSpeciesId() const; - unsigned getNewStoreId() const; - unsigned getNewTileId() const; - unsigned getNewTimeId() const; - unsigned getNewTypeId() const; - - QString title; - QString version; - QString description; - unsigned startMap; - unsigned startWarp; - QString superPCUname; - QString superPCPasswd; - FracMatrix typeChart; - Rules rules; - - QList<Ability> abilities; - QList<Author> authors; - QList<Badge> badges; - QList<CoinList> coinLists; - QList<Dialog> dialogs; - QList<EggGroup> eggGroups; - QList<Item> items; - QList<ItemType> itemTypes; - QList<Map> maps; - QList<Move> moves; - QList<Nature> natures; - QList<Species> species; - QList<Store> stores; - QList<Tile> tiles; - QList<Time> times; - QList<Type> types; - - QString path; - }; -} + public: + enum Validation + { + V_Msg = 0, + V_Warn = 1, + V_Error = 2 + }; + + Pokemod(const QString& fpath); + + void load(const QString& fpath) throw(Exception); + void save() const throw(Exception); + + QString getPath() const; + + unsigned maxCompatability(const Pokemod& p) const; + + void validationMsg(const QString& msg, Validation val = V_Error) const; + void setValidationOutput(QIODevice& s); + + void setTitle(const QString& t); + void setVersion(const QString& v); + void setDescription(const QString& d); + void setStartMap(const unsigned s) throw(BoundsException); + void setStartWarp(const unsigned s) throw(BoundsException); + void setWalkSkin(const QString& fname) throw(Exception); + void setBikeSkin(const QString& fname) throw(Exception); + void setSurfSkin(const QString& fname) throw(Exception); + void setFlySkin(const QString& fname) throw(Exception); + void setFishSkin(const QString& fname) throw(Exception); + void setSurfFishSkin(const QString& fname) throw(Exception); + void setSuperPCUname(const QString& u); + void setSuperPCPasswd(const QString& p); + void setTypeChart(const unsigned att, const unsigned def, const unsigned n, const unsigned d) throw(Exception); + void setTypeChartNum(const unsigned att, const unsigned def, const unsigned n) throw(Exception); + void setTypeChartDenom(const unsigned att, const unsigned def, const unsigned d) throw(Exception); + void setRules(const Rules& r); + void setRules(const QString& fname); + + QString getTitle() const; + QString getVersion() const; + QString getDescription() const; + unsigned getStartMap() const; + unsigned getStartWarp() const; + QString getSuperPCUname() const; + QString getSuperPCPasswd() const; + const FracMatrix& getTypeChart() const; + FracMatrix& getTypeChart(); + Frac getTypeChart(const unsigned att, const unsigned def) const; + const Rules& getRules() const; + Rules& getRules(); + + const Ability& getAbility(const unsigned i) const throw(IndexException); + Ability& getAbility(const unsigned i) throw(IndexException); + const Ability& getAbilityByID(const unsigned i) const throw(IndexException); + Ability& getAbilityByID(const unsigned i) throw(IndexException); + unsigned getAbilityIndex(const unsigned i) const; + unsigned getAbilityCount() const; + Ability& newAbility(); + Ability& newAbility(const QString& fname); + Ability& newAbility(const Ability& a); + void deleteAbility(const unsigned i) throw(IndexException); + + const Author& getAuthor(const unsigned i) const throw(IndexException); + Author& getAuthor(const unsigned i) throw(IndexException); + const Author& getAuthorByID(const unsigned i) const throw(IndexException); + Author& getAuthorByID(const unsigned i) throw(IndexException); + unsigned getAuthorIndex(const unsigned i) const; + unsigned getAuthorCount() const; + Author& newAuthor(); + Author& newAuthor(const QString& fname); + Author& newAuthor(const Author& a); + void deleteAuthor(const unsigned i) throw(IndexException); + + const Badge& getBadge(const unsigned i) const throw(IndexException); + Badge& getBadge(const unsigned i) throw(IndexException); + const Badge& getBadgeByID(const unsigned i) const throw(IndexException); + Badge& getBadgeByID(const unsigned i) throw(IndexException); + unsigned getBadgeIndex(const unsigned i) const; + unsigned getBadgeCount() const; + Badge& newBadge(); + Badge& newBadge(const QString& fname); + Badge& newBadge(const Badge& b); + void deleteBadge(const unsigned i) throw(IndexException); + + const CoinList& getCoinList(const unsigned i) const throw(IndexException); + CoinList& getCoinList(const unsigned i) throw(IndexException); + const CoinList& getCoinListByID(const unsigned i) const throw(IndexException); + CoinList& getCoinListByID(const unsigned i) throw(IndexException); + unsigned getCoinListIndex(const unsigned i) const; + unsigned getCoinListCount() const; + CoinList& newCoinList(); + CoinList& newCoinList(const QString& fname); + CoinList& newCoinList(const CoinList& c); + void deleteCoinList(const unsigned i) throw(IndexException); + + const Dialog& getDialog(const unsigned i) const throw(IndexException); + Dialog& getDialog(const unsigned i) throw(IndexException); + const Dialog& getDialogByID(const unsigned i) const throw(IndexException); + Dialog& getDialogByID(const unsigned i) throw(IndexException); + unsigned getDialogIndex(const unsigned i) const; + unsigned getDialogCount() const; + Dialog& newDialog(); + Dialog& newDialog(const QString& fname); + Dialog& newDialog(const Dialog& d); + void deleteDialog(const unsigned i) throw(IndexException); + + const EggGroup& getEggGroup(const unsigned i) const throw(IndexException); + EggGroup& getEggGroup(const unsigned i) throw(IndexException); + const EggGroup& getEggGroupByID(const unsigned i) const throw(IndexException); + EggGroup& getEggGroupByID(const unsigned i) throw(IndexException); + unsigned getEggGroupIndex(const unsigned i) const; + unsigned getEggGroupCount() const; + EggGroup& newEggGroup(); + EggGroup& newEggGroup(const QString& fname); + EggGroup& newEggGroup(const EggGroup& e); + void deleteEggGroup(const unsigned i) throw(IndexException); + + const Item& getItem(const unsigned i) const throw(IndexException); + Item& getItem(const unsigned i) throw(IndexException); + const Item& getItemByID(const unsigned i) const throw(IndexException); + Item& getItemByID(const unsigned i) throw(IndexException); + unsigned getItemIndex(const unsigned i) const; + unsigned getItemCount() const; + Item& newItem(); + Item& newItem(const QString& fname); + Item& newItem(const Item& i); + void deleteItem(const unsigned i) throw(IndexException); + + const ItemType& getItemType(const unsigned i) const throw(IndexException); + ItemType& getItemType(const unsigned i) throw(IndexException); + const ItemType& getItemTypeByID(const unsigned i) const throw(IndexException); + ItemType& getItemTypeByID(const unsigned i) throw(IndexException); + unsigned getItemTypeIndex(const unsigned i) const; + unsigned getItemTypeCount() const; + ItemType& newItemType(); + ItemType& newItemType(const QString& fname); + ItemType& newItemType(const ItemType& i); + void deleteItemType(const unsigned i) throw(IndexException); + + const Map& getMap(const unsigned i) const throw(IndexException); + Map& getMap(const unsigned i) throw(IndexException); + const Map& getMapByID(const unsigned i) const throw(IndexException); + Map& getMapByID(const unsigned i) throw(IndexException); + unsigned getMapIndex(const unsigned i) const; + unsigned getMapCount() const; + Map& newMap(); + Map& newMap(const QString& fname); + Map& newMap(const Map& m); + void deleteMap(const unsigned i) throw(IndexException); + + const Move& getMove(const unsigned i) const throw(IndexException); + Move& getMove(const unsigned i) throw(IndexException); + const Move& getMoveByID(const unsigned i) const throw(IndexException); + Move& getMoveByID(const unsigned i) throw(IndexException); + unsigned getMoveIndex(const unsigned i) const; + unsigned getMoveCount() const; + Move& newMove(); + Move& newMove(const QString& fname); + Move& newMove(const Move& m); + void deleteMove(const unsigned i) throw(IndexException); + + const Nature& getNature(const unsigned i) const throw(IndexException); + Nature& getNature(const unsigned i) throw(IndexException); + const Nature& getNatureByID(const unsigned i) const throw(IndexException); + Nature& getNatureByID(const unsigned i) throw(IndexException); + unsigned getNatureIndex(const unsigned i) const; + unsigned getNatureCount() const; + Nature& newNature(); + Nature& newNature(const QString& fname); + Nature& newNature(const Nature& n); + void deleteNature(const unsigned i) throw(IndexException); + + const Species& getSpecies(const unsigned i) const throw(IndexException); + Species& getSpecies(const unsigned i) throw(IndexException); + const Species& getSpeciesByID(const unsigned i) const throw(IndexException); + Species& getSpeciesByID(const unsigned i) throw(IndexException); + unsigned getSpeciesIndex(const unsigned i) const; + unsigned getSpeciesCount() const; + Species& newSpecies(); + Species& newSpecies(const QString& fname); + Species& newSpecies(const Species& s); + void deleteSpecies(const unsigned i) throw(IndexException); + + const Store& getStore(const unsigned i) const throw(IndexException); + Store& getStore(const unsigned i) throw(IndexException); + const Store& getStoreByID(const unsigned i) const throw(IndexException); + Store& getStoreByID(const unsigned i) throw(IndexException); + unsigned getStoreIndex(const unsigned i) const; + unsigned getStoreCount() const; + Store& newStore(); + Store& newStore(const QString& fname); + Store& newStore(const Store& s); + void deleteStore(const unsigned i) throw(IndexException); + + const Tile& getTile(const unsigned i) const throw(IndexException); + Tile& getTile(const unsigned i) throw(IndexException); + const Tile& getTileByID(const unsigned i) const throw(IndexException); + Tile& getTileByID(const unsigned i) throw(IndexException); + unsigned getTileIndex(const unsigned i) const; + unsigned getTileCount() const; + Tile& newTile(); + Tile& newTile(const QString& fname); + Tile& newTile(const Tile& t); + void deleteTile(const unsigned i) throw(IndexException); + + const Time& getTime(const unsigned i) const throw(IndexException); + Time& getTime(const unsigned i) throw(IndexException); + const Time& getTimeByID(const unsigned i) const throw(IndexException); + Time& getTimeByID(const unsigned i) throw(IndexException); + unsigned getTimeIndex(const unsigned i) const; + unsigned getTimeCount() const; + Time& newTime(); + Time& newTime(const QString& fname); + Time& newTime(const Time& t); + void deleteTime(const unsigned i) throw(IndexException); + + const Type& getType(const unsigned i) const throw(IndexException); + Type& getType(const unsigned i) throw(IndexException); + const Type& getTypeByID(const unsigned i) const throw(IndexException); + Type& getTypeByID(const unsigned i) throw(IndexException); + unsigned getTypeIndex(const unsigned i) const; + unsigned getTypeCount() const; + Type& newType(); + Type& newType(const QString& fname); + Type& newType(const Type& t); + void deleteType(const unsigned i) throw(IndexException); + private: + QIODevice* valstream; + + bool validate() const; + unsigned getNewAbilityId() const; + unsigned getNewAuthorId() const; + unsigned getNewBadgeId() const; + unsigned getNewCoinListId() const; + unsigned getNewDialogId() const; + unsigned getNewEggGroupId() const; + unsigned getNewItemId() const; + unsigned getNewItemTypeId() const; + unsigned getNewMapId() const; + unsigned getNewMoveId() const; + unsigned getNewNatureId() const; + unsigned getNewSpeciesId() const; + unsigned getNewStoreId() const; + unsigned getNewTileId() const; + unsigned getNewTimeId() const; + unsigned getNewTypeId() const; + + QString title; + QString version; + QString description; + unsigned startMap; + unsigned startWarp; + QString superPCUname; + QString superPCPasswd; + FracMatrix typeChart; + Rules rules; + + QList<Ability> abilities; + QList<Author> authors; + QList<Badge> badges; + QList<CoinList> coinLists; + QList<Dialog> dialogs; + QList<EggGroup> eggGroups; + QList<Item> items; + QList<ItemType> itemTypes; + QList<Map> maps; + QList<Move> moves; + QList<Nature> natures; + QList<Species> species; + QList<Store> stores; + QList<Tile> tiles; + QList<Time> times; + QList<Type> types; + + QString path; +}; #endif diff --git a/pokemod/Rules.cpp b/pokemod/Rules.cpp index 37c605d1..dfb4a09f 100644 --- a/pokemod/Rules.cpp +++ b/pokemod/Rules.cpp @@ -23,7 +23,7 @@ #include "Pokemod.h" #include "Rules.h" -PokeMod::Rules::Rules(const Pokemod& par) : +Rules::Rules(const Pokemod& par) : Object(par, 0), genderAllowed(false), breedingAllowed(false), @@ -53,13 +53,13 @@ PokeMod::Rules::Rules(const Pokemod& par) : { } -PokeMod::Rules::Rules(const Pokemod& par, const QString& fname) : +Rules::Rules(const Pokemod& par, const QString& fname) : Object(par, 0) { load(fname); } -bool PokeMod::Rules::validate() const +bool Rules::validate() const { bool valid = true; pokemod.validationMsg("---Rules", Pokemod::V_Msg); @@ -105,7 +105,7 @@ bool PokeMod::Rules::validate() const return valid; } -void PokeMod::Rules::load(const QString& fname) throw(Exception) +void Rules::load(const QString& fname) throw(Exception) { Ini ini(fname); unsigned i; @@ -139,7 +139,7 @@ void PokeMod::Rules::load(const QString& fname) throw(Exception) pokerusChance.set(i, j); } -void PokeMod::Rules::save() const throw(Exception) +void Rules::save() const throw(Exception) { Ini ini; ini.addField("genderAllowed", genderAllowed); @@ -171,138 +171,138 @@ void PokeMod::Rules::save() const throw(Exception) ini.save(QString("%1/rules.pini").arg(pokemod.getPath())); } -void PokeMod::Rules::setGenderAllowed(const bool g) +void Rules::setGenderAllowed(const bool g) { genderAllowed = g; if (!genderAllowed) breedingAllowed = false; } -void PokeMod::Rules::setBreedingAllowed(const bool b) throw(Exception) +void Rules::setBreedingAllowed(const bool b) throw(Exception) { if (!genderAllowed) throw(Exception("Rules", "cannot breed without genders")); breedingAllowed = b; } -void PokeMod::Rules::setHoldItems(const unsigned h) +void Rules::setHoldItems(const unsigned h) { holdItems = h; } -void PokeMod::Rules::setCriticalDomains(const bool c) +void Rules::setCriticalDomains(const bool c) { criticalDomains = c; } -void PokeMod::Rules::setAbilityAllowed(const bool a) +void Rules::setAbilityAllowed(const bool a) { abilityAllowed = a; } -void PokeMod::Rules::setNatureAllowed(const bool n) +void Rules::setNatureAllowed(const bool n) { natureAllowed = n; } -void PokeMod::Rules::setNumBoxes(const unsigned n) +void Rules::setNumBoxes(const unsigned n) { numBoxes = n; } -void PokeMod::Rules::setBoxSize(const unsigned b) +void Rules::setBoxSize(const unsigned b) { boxSize = b; } -void PokeMod::Rules::setMaxParty(const unsigned m) throw(BoundsException) +void Rules::setMaxParty(const unsigned m) throw(BoundsException) { if (!m) throw(BoundsException("Rules", "maxParty")); maxParty = m; } -void PokeMod::Rules::setMaxFight(const unsigned m) throw(BoundsException) +void Rules::setMaxFight(const unsigned m) throw(BoundsException) { if (maxParty < m) throw(BoundsException("Rules", "maxFight")); maxFight = m; } -void PokeMod::Rules::setMaxMoves(const unsigned m) throw(BoundsException) +void Rules::setMaxMoves(const unsigned m) throw(BoundsException) { if (!m) throw(BoundsException("Rules", "maxMoves")); maxMoves = m; } -void PokeMod::Rules::setMaxLevel(const unsigned m) throw(BoundsException) +void Rules::setMaxLevel(const unsigned m) throw(BoundsException) { if (!m) throw(BoundsException("Rules", "maxLevel")); maxLevel = m; } -void PokeMod::Rules::setMaxMoney(const unsigned m) +void Rules::setMaxMoney(const unsigned m) { maxMoney = m; } -void PokeMod::Rules::setHardCash(const bool h) +void Rules::setHardCash(const bool h) { hardCash = h; } -void PokeMod::Rules::setSpecialSplit(const bool s) +void Rules::setSpecialSplit(const bool s) { specialSplit = s; } -void PokeMod::Rules::setSpecialDVSplit(const bool s) +void Rules::setSpecialDVSplit(const bool s) { specialDVSplit = s; } -void PokeMod::Rules::setMaxDVValue(const unsigned char m) throw(BoundsException) +void Rules::setMaxDVValue(const unsigned char m) throw(BoundsException) { if ((m != 16) && (m != 32)) throw(BoundsException("Rules", "maxDVValue")); maxDVValue = m; } -void PokeMod::Rules::setHappiness(const bool h) +void Rules::setHappiness(const bool h) { happiness = h; } -void PokeMod::Rules::setHappyFaintLoss(const unsigned h) +void Rules::setHappyFaintLoss(const unsigned h) { happyFaintLoss = h; } -void PokeMod::Rules::setHappyLevelGain(const unsigned h) +void Rules::setHappyLevelGain(const unsigned h) { happyLevelGain = h; } -void PokeMod::Rules::setHappySteps(const unsigned h) +void Rules::setHappySteps(const unsigned h) { happySteps = h; } -void PokeMod::Rules::setEffortValuesAllowed(const bool e) +void Rules::setEffortValuesAllowed(const bool e) { effortValuesAllowed = e; } -void PokeMod::Rules::setMaxTotalEV(const unsigned m) throw(Exception) +void Rules::setMaxTotalEV(const unsigned m) throw(Exception) { if (!effortValuesAllowed) throw(Exception("Rules", "no effort values")); maxTotalEV = m; } -void PokeMod::Rules::setMaxEVPerStat(const unsigned m) throw(Exception) +void Rules::setMaxEVPerStat(const unsigned m) throw(Exception) { if (!effortValuesAllowed) throw(Exception("Rules", "no effort values")); @@ -311,147 +311,147 @@ void PokeMod::Rules::setMaxEVPerStat(const unsigned m) throw(Exception) maxEVPerStat = m; } -void PokeMod::Rules::setPokerusChance(const unsigned n, const unsigned d) throw(Exception) +void Rules::setPokerusChance(const unsigned n, const unsigned d) throw(Exception) { pokerusChance.set(n, d); } -void PokeMod::Rules::setPokerusChanceNum(const unsigned n) throw(Exception) +void Rules::setPokerusChanceNum(const unsigned n) throw(Exception) { pokerusChance.setNum(n); } -void PokeMod::Rules::setPokerusChanceDenom(const unsigned d) throw(Exception) +void Rules::setPokerusChanceDenom(const unsigned d) throw(Exception) { pokerusChance.setDenom(d); } -bool PokeMod::Rules::getGenderAllowed() const +bool Rules::getGenderAllowed() const { return genderAllowed; } -bool PokeMod::Rules::getBreedingAllowed() const +bool Rules::getBreedingAllowed() const { return breedingAllowed; } -unsigned PokeMod::Rules::getHoldItems() const +unsigned Rules::getHoldItems() const { return holdItems; } -bool PokeMod::Rules::getCriticalDomains() const +bool Rules::getCriticalDomains() const { return criticalDomains; } -bool PokeMod::Rules::getAbilityAllowed() const +bool Rules::getAbilityAllowed() const { return abilityAllowed; } -bool PokeMod::Rules::getNatureAllowed() const +bool Rules::getNatureAllowed() const { return natureAllowed; } -unsigned PokeMod::Rules::getNumBoxes() const +unsigned Rules::getNumBoxes() const { return numBoxes; } -unsigned PokeMod::Rules::getBoxSize() const +unsigned Rules::getBoxSize() const { return boxSize; } -unsigned PokeMod::Rules::getMaxParty() const +unsigned Rules::getMaxParty() const { return maxParty; } -unsigned PokeMod::Rules::getMaxFight() const +unsigned Rules::getMaxFight() const { return maxFight; } -unsigned PokeMod::Rules::getMaxMoves() const +unsigned Rules::getMaxMoves() const { return maxMoves; } -unsigned PokeMod::Rules::getMaxLevel() const +unsigned Rules::getMaxLevel() const { return maxLevel; } -unsigned PokeMod::Rules::getMaxMoney() const +unsigned Rules::getMaxMoney() const { return maxMoney; } -bool PokeMod::Rules::getHardCash() const +bool Rules::getHardCash() const { return hardCash; } -bool PokeMod::Rules::getSpecialSplit() const +bool Rules::getSpecialSplit() const { return specialSplit; } -bool PokeMod::Rules::getSpecialDVSplit() const +bool Rules::getSpecialDVSplit() const { return specialDVSplit; } -unsigned char PokeMod::Rules::getMaxDVValue() const +unsigned char Rules::getMaxDVValue() const { return maxDVValue; } -bool PokeMod::Rules::getHappiness() const +bool Rules::getHappiness() const { return happiness; } -unsigned PokeMod::Rules::getHappyFaintLoss() const +unsigned Rules::getHappyFaintLoss() const { return happyFaintLoss; } -unsigned PokeMod::Rules::getHappyLevelGain() const +unsigned Rules::getHappyLevelGain() const { return happyLevelGain; } -unsigned PokeMod::Rules::getHappySteps() const +unsigned Rules::getHappySteps() const { return happySteps; } -bool PokeMod::Rules::getEffortValuesAllowed() const +bool Rules::getEffortValuesAllowed() const { return effortValuesAllowed; } -unsigned PokeMod::Rules::getMaxTotalEV() const +unsigned Rules::getMaxTotalEV() const { return maxTotalEV; } -unsigned PokeMod::Rules::getMaxEVPerStat() const +unsigned Rules::getMaxEVPerStat() const { return maxEVPerStat; } -Frac PokeMod::Rules::getPokerusChance() const +Frac Rules::getPokerusChance() const { return pokerusChance; } -PokeMod::Rules& PokeMod::Rules::operator=(const Rules& rhs) +Rules& Rules::operator=(const Rules& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Rules.h b/pokemod/Rules.h index 229ca9ba..9eb34930 100644 --- a/pokemod/Rules.h +++ b/pokemod/Rules.h @@ -28,104 +28,101 @@ #include "../general/Frac.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class Rules : public Object { - class Pokemod; - - class Rules : public Object - { - public: - Rules(const Pokemod& pokemod); - Rules(const Pokemod& pokemod, const QString& fname); - Rules(const Pokemod& pokemod, const Rules& r); - - void load(const QString& fname) throw(Exception); - void save() const throw(Exception); - - void setGenderAllowed(const bool g); - void setBreedingAllowed(const bool b) throw(Exception); - void setHoldItems(const unsigned h); - void setCriticalDomains(const bool c); - void setAbilityAllowed(const bool a); - void setNatureAllowed(const bool n); - void setNumBoxes(const unsigned n); - void setBoxSize(const unsigned b); - void setMaxParty(const unsigned m) throw(BoundsException); - void setMaxFight(const unsigned m) throw(BoundsException); - void setMaxMoves(const unsigned m) throw(BoundsException); - void setMaxLevel(const unsigned m) throw(BoundsException); - void setMaxMoney(const unsigned m); - void setHardCash(const bool h); - void setSpecialSplit(const bool s); - void setSpecialDVSplit(const bool s); - void setMaxDVValue(const unsigned char m) throw(BoundsException); - void setHappiness(const bool h); - void setHappyFaintLoss(const unsigned h); - void setHappyLevelGain(const unsigned h); - void setHappySteps(const unsigned h); - void setEffortValuesAllowed(const bool e); - void setMaxTotalEV(const unsigned m) throw(Exception); - void setMaxEVPerStat(const unsigned m) throw(Exception); - void setPokerusChance(const unsigned n, const unsigned d) throw(Exception); - void setPokerusChanceNum(const unsigned n) throw(Exception); - void setPokerusChanceDenom(const unsigned d) throw(Exception); - - bool getGenderAllowed() const; - bool getBreedingAllowed() const; - unsigned getHoldItems() const; - bool getCriticalDomains() const; - bool getAbilityAllowed() const; - bool getNatureAllowed() const; - unsigned getNumBoxes() const; - unsigned getBoxSize() const; - unsigned getMaxParty() const; - unsigned getMaxFight() const; - unsigned getMaxMoves() const; - unsigned getMaxLevel() const; - unsigned getMaxMoney() const; - bool getHardCash() const; - bool getSpecialSplit() const; - bool getSpecialDVSplit() const; - unsigned char getMaxDVValue() const; - bool getHappiness() const; - unsigned getHappyFaintLoss() const; - unsigned getHappyLevelGain() const; - unsigned getHappySteps() const; - bool getEffortValuesAllowed() const; - unsigned getMaxTotalEV() const; - unsigned getMaxEVPerStat() const; - Frac getPokerusChance() const; - - Rules& operator=(const Rules& rhs); - private: - bool validate() const; - - bool genderAllowed; - bool breedingAllowed; - unsigned holdItems; - bool criticalDomains; - bool abilityAllowed; - bool natureAllowed; - unsigned numBoxes; - unsigned boxSize; - unsigned maxParty; - unsigned maxFight; - unsigned maxMoves; - unsigned maxLevel; - unsigned maxMoney; - bool hardCash; - bool specialSplit; - bool specialDVSplit; - unsigned char maxDVValue; - bool happiness; - unsigned happyFaintLoss; - unsigned happyLevelGain; - unsigned happySteps; - bool effortValuesAllowed; - unsigned maxTotalEV; - unsigned maxEVPerStat; - Frac pokerusChance; - }; -} + public: + Rules(const Pokemod& pokemod); + Rules(const Pokemod& pokemod, const QString& fname); + Rules(const Pokemod& pokemod, const Rules& r); + + void load(const QString& fname) throw(Exception); + void save() const throw(Exception); + + void setGenderAllowed(const bool g); + void setBreedingAllowed(const bool b) throw(Exception); + void setHoldItems(const unsigned h); + void setCriticalDomains(const bool c); + void setAbilityAllowed(const bool a); + void setNatureAllowed(const bool n); + void setNumBoxes(const unsigned n); + void setBoxSize(const unsigned b); + void setMaxParty(const unsigned m) throw(BoundsException); + void setMaxFight(const unsigned m) throw(BoundsException); + void setMaxMoves(const unsigned m) throw(BoundsException); + void setMaxLevel(const unsigned m) throw(BoundsException); + void setMaxMoney(const unsigned m); + void setHardCash(const bool h); + void setSpecialSplit(const bool s); + void setSpecialDVSplit(const bool s); + void setMaxDVValue(const unsigned char m) throw(BoundsException); + void setHappiness(const bool h); + void setHappyFaintLoss(const unsigned h); + void setHappyLevelGain(const unsigned h); + void setHappySteps(const unsigned h); + void setEffortValuesAllowed(const bool e); + void setMaxTotalEV(const unsigned m) throw(Exception); + void setMaxEVPerStat(const unsigned m) throw(Exception); + void setPokerusChance(const unsigned n, const unsigned d) throw(Exception); + void setPokerusChanceNum(const unsigned n) throw(Exception); + void setPokerusChanceDenom(const unsigned d) throw(Exception); + + bool getGenderAllowed() const; + bool getBreedingAllowed() const; + unsigned getHoldItems() const; + bool getCriticalDomains() const; + bool getAbilityAllowed() const; + bool getNatureAllowed() const; + unsigned getNumBoxes() const; + unsigned getBoxSize() const; + unsigned getMaxParty() const; + unsigned getMaxFight() const; + unsigned getMaxMoves() const; + unsigned getMaxLevel() const; + unsigned getMaxMoney() const; + bool getHardCash() const; + bool getSpecialSplit() const; + bool getSpecialDVSplit() const; + unsigned char getMaxDVValue() const; + bool getHappiness() const; + unsigned getHappyFaintLoss() const; + unsigned getHappyLevelGain() const; + unsigned getHappySteps() const; + bool getEffortValuesAllowed() const; + unsigned getMaxTotalEV() const; + unsigned getMaxEVPerStat() const; + Frac getPokerusChance() const; + + Rules& operator=(const Rules& rhs); + private: + bool validate() const; + + bool genderAllowed; + bool breedingAllowed; + unsigned holdItems; + bool criticalDomains; + bool abilityAllowed; + bool natureAllowed; + unsigned numBoxes; + unsigned boxSize; + unsigned maxParty; + unsigned maxFight; + unsigned maxMoves; + unsigned maxLevel; + unsigned maxMoney; + bool hardCash; + bool specialSplit; + bool specialDVSplit; + unsigned char maxDVValue; + bool happiness; + unsigned happyFaintLoss; + unsigned happyLevelGain; + unsigned happySteps; + bool effortValuesAllowed; + unsigned maxTotalEV; + unsigned maxEVPerStat; + Frac pokerusChance; +}; #endif diff --git a/pokemod/Species.cpp b/pokemod/Species.cpp index 59f47a46..f4b4b000 100644 --- a/pokemod/Species.cpp +++ b/pokemod/Species.cpp @@ -28,9 +28,9 @@ #include "Pokemod.h" #include "Species.h" -const QStringList PokeMod::Species::StyleStr = QStringList() << "Fluctuating" << "Fading" << "Slow" << "Normal" << "Fast" << "Erratic"; +const QStringList Species::StyleStr = QStringList() << "Fluctuating" << "Fading" << "Slow" << "Normal" << "Fast" << "Erratic"; -PokeMod::Species::Species(const Pokemod& par, const unsigned _id) : +Species::Species(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), growth(UINT_MAX), @@ -54,19 +54,19 @@ PokeMod::Species::Species(const Pokemod& par, const unsigned _id) : } } -PokeMod::Species::Species(const Pokemod& par, const Species& s, const unsigned _id) : +Species::Species(const Pokemod& par, const Species& s, const unsigned _id) : Object(par, _id) { *this = s; } -PokeMod::Species::Species(const Pokemod& par, const QString& fname, const unsigned _id) : +Species::Species(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::Species::validate() const +bool Species::validate() const { bool valid = true; pokemod.validationMsg(QString("---Species \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -298,7 +298,7 @@ bool PokeMod::Species::validate() const return valid; } -unsigned PokeMod::Species::getNewAbilityId() const +unsigned Species::getNewAbilityId() const { unsigned i = 0; for (; (i < getAbilityCount()) && (getAbilityIndex(i) != UINT_MAX); ++i) @@ -306,7 +306,7 @@ unsigned PokeMod::Species::getNewAbilityId() const return i; } -unsigned PokeMod::Species::getNewEvolutionId() const +unsigned Species::getNewEvolutionId() const { unsigned i = 0; for (; (i < getEvolutionCount()) && (getEvolutionIndex(i) != UINT_MAX); ++i) @@ -314,7 +314,7 @@ unsigned PokeMod::Species::getNewEvolutionId() const return i; } -unsigned PokeMod::Species::getNewItemId() const +unsigned Species::getNewItemId() const { unsigned i = 0; for (; (i < getItemCount()) && (getItemIndex(i) != UINT_MAX); ++i) @@ -322,7 +322,7 @@ unsigned PokeMod::Species::getNewItemId() const return i; } -unsigned PokeMod::Species::getNewMoveId() const +unsigned Species::getNewMoveId() const { unsigned i = 0; for (; (i < getMoveCount()) && (getMoveIndex(i) != UINT_MAX); ++i) @@ -330,7 +330,7 @@ unsigned PokeMod::Species::getNewMoveId() const return i; } -void PokeMod::Species::load(const QString& fname, const unsigned _id) throw(Exception) +void Species::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -410,7 +410,7 @@ void PokeMod::Species::load(const QString& fname, const unsigned _id) throw(Exce } } -void PokeMod::Species::save() const throw(Exception) +void Species::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -453,19 +453,19 @@ void PokeMod::Species::save() const throw(Exception) i.next().save(name); } -void PokeMod::Species::setName(const QString& n) +void Species::setName(const QString& n) { name = n; } -void PokeMod::Species::setBaseStat(const unsigned s, const unsigned b) throw(BoundsException) +void Species::setBaseStat(const unsigned s, const unsigned b) throw(BoundsException) { if ((ST_End_RBY <= s) || ((s == ST_SpecialDefense) && !pokemod.getRules().getSpecialSplit())) throw(BoundsException("Species", "stat")); baseStats[s] = b; } -void PokeMod::Species::setEffortValue(const unsigned s, const unsigned e) throw(Exception) +void Species::setEffortValue(const unsigned s, const unsigned e) throw(Exception) { if (!pokemod.getRules().getEffortValuesAllowed()) throw(Exception("Species", "effortValues not allowed")); @@ -476,81 +476,81 @@ void PokeMod::Species::setEffortValue(const unsigned s, const unsigned e) throw( effortValues[s] = e; } -void PokeMod::Species::setGrowth(const unsigned g) throw(BoundsException) +void Species::setGrowth(const unsigned g) throw(BoundsException) { if (End <= g) throw(BoundsException("Species", "growth")); growth = g; } -void PokeMod::Species::setExperienceValue(const unsigned e) +void Species::setExperienceValue(const unsigned e) { experienceValue = e; } -void PokeMod::Species::setCatchValue(const unsigned char c) +void Species::setCatchValue(const unsigned char c) { catchValue = c; } -void PokeMod::Species::setRunChance(const unsigned n, const unsigned d) throw(Exception) +void Species::setRunChance(const unsigned n, const unsigned d) throw(Exception) { runChance.set(n, d); } -void PokeMod::Species::setRunChanceNumerator(const unsigned n) throw(Exception) +void Species::setRunChanceNumerator(const unsigned n) throw(Exception) { runChance.setNum(n); } -void PokeMod::Species::setRunChanceDenominator(const unsigned d) throw(Exception) +void Species::setRunChanceDenominator(const unsigned d) throw(Exception) { runChance.setDenom(d); } -void PokeMod::Species::setItemChance(const unsigned n, const unsigned d) throw(Exception) +void Species::setItemChance(const unsigned n, const unsigned d) throw(Exception) { itemChance.set(n, d); } -void PokeMod::Species::setItemChanceNumerator(const unsigned n) throw(Exception) +void Species::setItemChanceNumerator(const unsigned n) throw(Exception) { itemChance.setNum(n); } -void PokeMod::Species::setItemChanceDenominator(const unsigned d) throw(Exception) +void Species::setItemChanceDenominator(const unsigned d) throw(Exception) { itemChance.setDenom(d); } -void PokeMod::Species::setPokedexNumber(const unsigned p) +void Species::setPokedexNumber(const unsigned p) { pokedexNumber = p; } -void PokeMod::Species::setWeight(const unsigned w) +void Species::setWeight(const unsigned w) { weight = w; } -void PokeMod::Species::setHeightFeet(const unsigned f) +void Species::setHeightFeet(const unsigned f) { heightFeet = f; } -void PokeMod::Species::setHeightInches(const unsigned char i) throw(BoundsException) +void Species::setHeightInches(const unsigned char i) throw(BoundsException) { if (12 <= i) throw(BoundsException("Species", "heightInches")); heightInches = i; } -void PokeMod::Species::setPokedexEntry(const QString& p) +void Species::setPokedexEntry(const QString& p) { pokedexEntry = p; } -void PokeMod::Species::setFrontMaleSprite(const QString& fname) throw(Exception) +void Species::setFrontMaleSprite(const QString& fname) throw(Exception) { QFile file(QString("%1/species/%2/front%3.png").arg(pokemod.getPath()).arg(name).arg(pokemod.getRules().getGenderAllowed() ? "-male" : "")); if (file.exists() && !file.remove()) @@ -559,7 +559,7 @@ void PokeMod::Species::setFrontMaleSprite(const QString& fname) throw(Exception) throw(SaveException("Species", file.fileName())); } -void PokeMod::Species::setBackMaleSprite(const QString& fname) throw(Exception) +void Species::setBackMaleSprite(const QString& fname) throw(Exception) { QFile file(QString("%1/species/%2/back%3.png").arg(pokemod.getPath()).arg(name).arg(pokemod.getRules().getGenderAllowed() ? "-male" : "")); if (file.exists() && !file.remove()) @@ -568,7 +568,7 @@ void PokeMod::Species::setBackMaleSprite(const QString& fname) throw(Exception) throw(SaveException("Species", file.fileName())); } -void PokeMod::Species::setFrontFemaleSprite(const QString& fname) throw(Exception) +void Species::setFrontFemaleSprite(const QString& fname) throw(Exception) { if (!pokemod.getRules().getGenderAllowed()) throw(Exception("Species", "gender is not allowed")); @@ -579,7 +579,7 @@ void PokeMod::Species::setFrontFemaleSprite(const QString& fname) throw(Exceptio throw(SaveException("Species", file.fileName())); } -void PokeMod::Species::setBackFemaleSprite(const QString& fname) throw(Exception) +void Species::setBackFemaleSprite(const QString& fname) throw(Exception) { if (!pokemod.getRules().getGenderAllowed()) throw(Exception("Species", "gender is not allowed")); @@ -590,7 +590,7 @@ void PokeMod::Species::setBackFemaleSprite(const QString& fname) throw(Exception throw(SaveException("Species", file.fileName())); } -void PokeMod::Species::setListSprite(const QString& fname) throw(Exception) +void Species::setListSprite(const QString& fname) throw(Exception) { QFile file(QString("%1/species/%2/list.png").arg(pokemod.getPath()).arg(name)); if (file.exists() && !file.remove()) @@ -599,39 +599,39 @@ void PokeMod::Species::setListSprite(const QString& fname) throw(Exception) throw(SaveException("Species", file.fileName())); } -void PokeMod::Species::setGenderFactor(const unsigned n, const unsigned d) throw(Exception) +void Species::setGenderFactor(const unsigned n, const unsigned d) throw(Exception) { genderFactor.set(n, d); } -void PokeMod::Species::setGenderFactorNum(const unsigned n) throw(Exception) +void Species::setGenderFactorNum(const unsigned n) throw(Exception) { genderFactor.setNum(n); } -void PokeMod::Species::setGenderFactorDenom(const unsigned d) throw(Exception) +void Species::setGenderFactorDenom(const unsigned d) throw(Exception) { genderFactor.setDenom(d); } -void PokeMod::Species::setEggSpecies(const unsigned e) throw(BoundsException) +void Species::setEggSpecies(const unsigned e) throw(BoundsException) { if (pokemod.getSpeciesIndex(e) == UINT_MAX) throw(BoundsException("Species", "eggSpecies")); eggSpecies = e; } -void PokeMod::Species::setEggSteps(const unsigned e) +void Species::setEggSteps(const unsigned e) { eggSteps = e; } -void PokeMod::Species::setNidoranGroup(const unsigned n) +void Species::setNidoranGroup(const unsigned n) { nidoranGroup = n; } -void PokeMod::Species::setType(const unsigned ty, const bool t) throw(Exception) +void Species::setType(const unsigned ty, const bool t) throw(Exception) { if (pokemod.getTypeIndex(ty) == UINT_MAX) throw(BoundsException("Species", "type")); @@ -650,7 +650,7 @@ void PokeMod::Species::setType(const unsigned ty, const bool t) throw(Exception) types.append(ty); } -void PokeMod::Species::setEggGroup(const unsigned eg, const bool e) throw(Exception) +void Species::setEggGroup(const unsigned eg, const bool e) throw(Exception) { if (pokemod.getEggGroupIndex(eg) == UINT_MAX) throw(BoundsException("Species", "eggGroup")); @@ -669,96 +669,96 @@ void PokeMod::Species::setEggGroup(const unsigned eg, const bool e) throw(Except eggGroups.append(eg); } -QString PokeMod::Species::getName() const +QString Species::getName() const { return name; } -unsigned PokeMod::Species::getBaseStat(const unsigned s) const throw(BoundsException) +unsigned Species::getBaseStat(const unsigned s) const throw(BoundsException) { if ((ST_End_RBY <= s) || ((s == ST_SpecialDefense) && !pokemod.getRules().getSpecialSplit())) throw(BoundsException("Species", "stat")); return baseStats[s]; } -unsigned PokeMod::Species::getEffortValue(const unsigned s) const throw(BoundsException) +unsigned Species::getEffortValue(const unsigned s) const throw(BoundsException) { if ((ST_End_RBY <= s) || ((s == ST_SpecialDefense) && !pokemod.getRules().getSpecialSplit())) throw(BoundsException("Species", "stat")); return effortValues[s]; } -unsigned PokeMod::Species::getGrowth() const +unsigned Species::getGrowth() const { return growth; } -unsigned PokeMod::Species::getExperienceValue() const +unsigned Species::getExperienceValue() const { return experienceValue; } -unsigned char PokeMod::Species::getCatchValue() const +unsigned char Species::getCatchValue() const { return catchValue; } -Frac PokeMod::Species::getRunChance() const +Frac Species::getRunChance() const { return runChance; } -Frac PokeMod::Species::getItemChance() const +Frac Species::getItemChance() const { return itemChance; } -unsigned PokeMod::Species::getPokedexNumber() const +unsigned Species::getPokedexNumber() const { return pokedexNumber; } -unsigned PokeMod::Species::getWeight() const +unsigned Species::getWeight() const { return weight; } -unsigned PokeMod::Species::getHeightFeet() const +unsigned Species::getHeightFeet() const { return heightFeet; } -unsigned PokeMod::Species::getHeightInches() const +unsigned Species::getHeightInches() const { return heightInches; } -QString PokeMod::Species::getPokedexEntry() const +QString Species::getPokedexEntry() const { return pokedexEntry; } -Frac PokeMod::Species::getGenderFactor() const +Frac Species::getGenderFactor() const { return genderFactor; } -unsigned PokeMod::Species::getEggSpecies() const +unsigned Species::getEggSpecies() const { return eggSpecies; } -unsigned PokeMod::Species::getEggSteps() const +unsigned Species::getEggSteps() const { return eggSteps; } -unsigned PokeMod::Species::getNidoranGroup() const +unsigned Species::getNidoranGroup() const { return nidoranGroup; } -bool PokeMod::Species::getType(const unsigned ty) const +bool Species::getType(const unsigned ty) const { for (QListIterator<unsigned> i(types); i.hasNext(); ) { @@ -768,7 +768,7 @@ bool PokeMod::Species::getType(const unsigned ty) const return false; } -bool PokeMod::Species::getEggGroup(const unsigned eg) const +bool Species::getEggGroup(const unsigned eg) const { for (QListIterator<unsigned> i(eggGroups); i.hasNext(); ) { @@ -778,31 +778,31 @@ bool PokeMod::Species::getEggGroup(const unsigned eg) const return false; } -const PokeMod::SpeciesAbility& PokeMod::Species::getAbility(const unsigned i) const throw(IndexException) +const SpeciesAbility& Species::getAbility(const unsigned i) const throw(IndexException) { if (getAbilityCount() <= i) throw(IndexException("Species")); return abilities.at(i); } -PokeMod::SpeciesAbility& PokeMod::Species::getAbility(const unsigned i) throw(IndexException) +SpeciesAbility& Species::getAbility(const unsigned i) throw(IndexException) { if (getAbilityCount() <= i) throw(IndexException("Species")); return abilities[i]; } -const PokeMod::SpeciesAbility& PokeMod::Species::getAbilityByID(const unsigned i) const throw(IndexException) +const SpeciesAbility& Species::getAbilityByID(const unsigned i) const throw(IndexException) { return getAbility(getAbilityIndex(i)); } -PokeMod::SpeciesAbility& PokeMod::Species::getAbilityByID(const unsigned i) throw(IndexException) +SpeciesAbility& Species::getAbilityByID(const unsigned i) throw(IndexException) { return getAbility(getAbilityIndex(i)); } -unsigned PokeMod::Species::getAbilityIndex(const unsigned _id) const +unsigned Species::getAbilityIndex(const unsigned _id) const { for (unsigned i = 0; i < getAbilityCount(); ++i) { @@ -812,61 +812,61 @@ unsigned PokeMod::Species::getAbilityIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Species::getAbilityCount() const +unsigned Species::getAbilityCount() const { return abilities.size(); } -PokeMod::SpeciesAbility& PokeMod::Species::newAbility() +SpeciesAbility& Species::newAbility() { abilities.append(SpeciesAbility(pokemod, getNewAbilityId())); return abilities[getAbilityCount() - 1]; } -PokeMod::SpeciesAbility& PokeMod::Species::newAbility(const QString& fname) +SpeciesAbility& Species::newAbility(const QString& fname) { abilities.append(SpeciesAbility(pokemod, fname, getNewAbilityId())); return abilities[getAbilityCount() - 1]; } -PokeMod::SpeciesAbility& PokeMod::Species::newAbility(const SpeciesAbility& a) +SpeciesAbility& Species::newAbility(const SpeciesAbility& a) { abilities.append(SpeciesAbility(pokemod, a, getNewAbilityId())); return abilities[getAbilityCount() - 1]; } -void PokeMod::Species::deleteAbility(const unsigned i) throw(IndexException) +void Species::deleteAbility(const unsigned i) throw(IndexException) { if (getAbilityCount() <= i) throw(IndexException("Species")); abilities.removeAt(i); } -const PokeMod::SpeciesEvolution& PokeMod::Species::getEvolution(const unsigned i) const throw(IndexException) +const SpeciesEvolution& Species::getEvolution(const unsigned i) const throw(IndexException) { if (getEvolutionCount() <= i) throw(IndexException("Species")); return evolutions.at(i); } -PokeMod::SpeciesEvolution& PokeMod::Species::getEvolution(const unsigned i) throw(IndexException) +SpeciesEvolution& Species::getEvolution(const unsigned i) throw(IndexException) { if (getEvolutionCount() <= i) throw(IndexException("Species")); return evolutions[i]; } -const PokeMod::SpeciesEvolution& PokeMod::Species::getEvolutionByID(const unsigned i) const throw(IndexException) +const SpeciesEvolution& Species::getEvolutionByID(const unsigned i) const throw(IndexException) { return getEvolution(getEvolutionIndex(i)); } -PokeMod::SpeciesEvolution& PokeMod::Species::getEvolutionByID(const unsigned i) throw(IndexException) +SpeciesEvolution& Species::getEvolutionByID(const unsigned i) throw(IndexException) { return getEvolution(getEvolutionIndex(i)); } -unsigned PokeMod::Species::getEvolutionIndex(const unsigned _id) const +unsigned Species::getEvolutionIndex(const unsigned _id) const { for (unsigned i = 0; i < getEvolutionCount(); ++i) { @@ -876,61 +876,61 @@ unsigned PokeMod::Species::getEvolutionIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Species::getEvolutionCount() const +unsigned Species::getEvolutionCount() const { return evolutions.size(); } -PokeMod::SpeciesEvolution& PokeMod::Species::newEvolution() +SpeciesEvolution& Species::newEvolution() { evolutions.append(SpeciesEvolution(pokemod, getNewEvolutionId())); return evolutions[getEvolutionCount() - 1]; } -PokeMod::SpeciesEvolution& PokeMod::Species::newEvolution(const QString& fname) +SpeciesEvolution& Species::newEvolution(const QString& fname) { evolutions.append(SpeciesEvolution(pokemod, fname, getNewEvolutionId())); return evolutions[getEvolutionCount() - 1]; } -PokeMod::SpeciesEvolution& PokeMod::Species::newEvolution(const SpeciesEvolution& e) +SpeciesEvolution& Species::newEvolution(const SpeciesEvolution& e) { evolutions.append(SpeciesEvolution(pokemod, e, getNewEvolutionId())); return evolutions[getEvolutionCount() - 1]; } -void PokeMod::Species::deleteEvolution(const unsigned i) throw(IndexException) +void Species::deleteEvolution(const unsigned i) throw(IndexException) { if (getEvolutionCount() <= i) throw(IndexException("Species")); evolutions.removeAt(i); } -const PokeMod::SpeciesItem& PokeMod::Species::getItem(const unsigned i) const throw(IndexException) +const SpeciesItem& Species::getItem(const unsigned i) const throw(IndexException) { if (getItemCount() <= i) throw(IndexException("Species")); return items.at(i); } -PokeMod::SpeciesItem& PokeMod::Species::getItem(const unsigned i) throw(IndexException) +SpeciesItem& Species::getItem(const unsigned i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException("Species")); return items[i]; } -const PokeMod::SpeciesItem& PokeMod::Species::getItemByID(const unsigned i) const throw(IndexException) +const SpeciesItem& Species::getItemByID(const unsigned i) const throw(IndexException) { return getItem(getItemIndex(i)); } -PokeMod::SpeciesItem& PokeMod::Species::getItemByID(const unsigned i) throw(IndexException) +SpeciesItem& Species::getItemByID(const unsigned i) throw(IndexException) { return getItem(getItemIndex(i)); } -unsigned PokeMod::Species::getItemIndex(const unsigned _id) const +unsigned Species::getItemIndex(const unsigned _id) const { for (unsigned i = 0; i < getItemCount(); ++i) { @@ -940,61 +940,61 @@ unsigned PokeMod::Species::getItemIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Species::getItemCount() const +unsigned Species::getItemCount() const { return items.size(); } -PokeMod::SpeciesItem& PokeMod::Species::newItem() +SpeciesItem& Species::newItem() { items.append(SpeciesItem(pokemod, getNewItemId())); return items[getItemCount() - 1]; } -PokeMod::SpeciesItem& PokeMod::Species::newItem(const QString& fname) +SpeciesItem& Species::newItem(const QString& fname) { items.append(SpeciesItem(pokemod, fname, getNewItemId())); return items[getItemCount() - 1]; } -PokeMod::SpeciesItem& PokeMod::Species::newItem(const SpeciesItem& i) +SpeciesItem& Species::newItem(const SpeciesItem& i) { items.append(SpeciesItem(pokemod, i, getNewItemId())); return items[getItemCount() - 1]; } -void PokeMod::Species::deleteItem(const unsigned i) throw(IndexException) +void Species::deleteItem(const unsigned i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException("Species")); items.removeAt(i); } -const PokeMod::SpeciesMove& PokeMod::Species::getMove(const unsigned i) const throw(IndexException) +const SpeciesMove& Species::getMove(const unsigned i) const throw(IndexException) { if (getMoveCount() <= i) throw(IndexException("Species")); return moves.at(i); } -PokeMod::SpeciesMove& PokeMod::Species::getMove(const unsigned i) throw(IndexException) +SpeciesMove& Species::getMove(const unsigned i) throw(IndexException) { if (getMoveCount() <= i) throw(IndexException("Species")); return moves[i]; } -const PokeMod::SpeciesMove& PokeMod::Species::getMoveByID(const unsigned i) const throw(IndexException) +const SpeciesMove& Species::getMoveByID(const unsigned i) const throw(IndexException) { return getMove(getMoveIndex(i)); } -PokeMod::SpeciesMove& PokeMod::Species::getMoveByID(const unsigned i) throw(IndexException) +SpeciesMove& Species::getMoveByID(const unsigned i) throw(IndexException) { return getMove(getMoveIndex(i)); } -unsigned PokeMod::Species::getMoveIndex(const unsigned _id) const +unsigned Species::getMoveIndex(const unsigned _id) const { for (unsigned i = 0; i < getMoveCount(); ++i) { @@ -1004,37 +1004,37 @@ unsigned PokeMod::Species::getMoveIndex(const unsigned _id) const return UINT_MAX; } -unsigned PokeMod::Species::getMoveCount() const +unsigned Species::getMoveCount() const { return moves.size(); } -PokeMod::SpeciesMove& PokeMod::Species::newMove() +SpeciesMove& Species::newMove() { moves.append(SpeciesMove(pokemod, getNewMoveId())); return moves[getMoveCount() - 1]; } -PokeMod::SpeciesMove& PokeMod::Species::newMove(const QString& fname) +SpeciesMove& Species::newMove(const QString& fname) { moves.append(SpeciesMove(pokemod, fname, getNewMoveId())); return moves[getMoveCount() - 1]; } -PokeMod::SpeciesMove& PokeMod::Species::newMove(const SpeciesMove& m) +SpeciesMove& Species::newMove(const SpeciesMove& m) { moves.append(SpeciesMove(pokemod, m, getNewMoveId())); return moves[getMoveCount() - 1]; } -void PokeMod::Species::deleteMove(const unsigned i) throw(IndexException) +void Species::deleteMove(const unsigned i) throw(IndexException) { if (getMoveCount() <= i) throw(IndexException("Species")); moves.removeAt(i); } -PokeMod::Species& PokeMod::Species::operator=(const Species& rhs) +Species& Species::operator=(const Species& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Species.h b/pokemod/Species.h index 418bd3a9..f8b2dd71 100644 --- a/pokemod/Species.h +++ b/pokemod/Species.h @@ -35,165 +35,162 @@ #include "SpeciesItem.h" #include "SpeciesMove.h" -namespace PokeMod +class Pokemod; + +class Species : public Object { - class Pokemod; - - class Species : public Object - { - public: - enum - { - Fluctuating = 0, - Fading = 1, - Slow = 2, - Normal = 3, - Fast = 5, - Erratic = 6, - End = 7 - }; - static const QStringList StyleStr; - - Species(const Pokemod& par, const unsigned _id); - Species(const Pokemod& par, const Species& s, const unsigned _id); - Species(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - void setBaseStat(const unsigned s, const unsigned b) throw(BoundsException); - void setEffortValue(const unsigned s, const unsigned e) throw(Exception); - void setGrowth(const unsigned g) throw(BoundsException); - void setExperienceValue(const unsigned e); - void setCatchValue(const unsigned char c); - void setRunChance(const unsigned n, const unsigned d) throw(Exception); - void setRunChanceNumerator(const unsigned n) throw(Exception); - void setRunChanceDenominator(const unsigned d) throw(Exception); - void setItemChance(const unsigned n, const unsigned d) throw(Exception); - void setItemChanceNumerator(const unsigned n) throw(Exception); - void setItemChanceDenominator(const unsigned d) throw(Exception); - void setPokedexNumber(const unsigned p); - void setWeight(const unsigned w); - void setHeightFeet(const unsigned f); - void setHeightInches(const unsigned char i) throw(BoundsException); - void setPokedexEntry(const QString& p); - void setFrontMaleSprite(const QString& fname) throw(Exception); - void setBackMaleSprite(const QString& fname) throw(Exception); - void setFrontFemaleSprite(const QString& fname) throw(Exception); - void setBackFemaleSprite(const QString& fname) throw(Exception); - void setListSprite(const QString& fname) throw(Exception); - void setGenderFactor(const unsigned n, const unsigned d) throw(Exception); - void setGenderFactorNum(const unsigned n) throw(Exception); - void setGenderFactorDenom(const unsigned d) throw(Exception); - void setEggSpecies(const unsigned e) throw(BoundsException); - void setEggSteps(const unsigned e); - void setNidoranGroup(const unsigned n); - void setType(const unsigned ty, const bool t) throw(Exception); - void setEggGroup(const unsigned eg, const bool e) throw(Exception); - - QString getName() const; - unsigned getBaseStat(const unsigned s) const throw(BoundsException); - unsigned getEffortValue(const unsigned s) const throw(BoundsException); - unsigned getGrowth() const; - unsigned getExperienceValue() const; - unsigned char getCatchValue() const; - Frac getRunChance() const; - Frac getItemChance() const; - unsigned getPokedexNumber() const; - unsigned getWeight() const; - unsigned getHeightFeet() const; - unsigned getHeightInches() const; - QString getPokedexEntry() const; - bool getFrontMaleSprite() const; - bool getBackMaleSprite() const; - bool getFrontFemaleSprite() const; - bool getBackFemaleSprite() const; - bool getListSprite() const; - Frac getGenderFactor() const; - unsigned getEggSpecies() const; - unsigned getEggSteps() const; - unsigned getNidoranGroup() const; - bool getType(const unsigned ty) const; - bool getEggGroup(const unsigned eg) const; - - const SpeciesAbility& getAbility(const unsigned i) const throw(IndexException); - SpeciesAbility& getAbility(const unsigned i) throw(IndexException); - const SpeciesAbility& getAbilityByID(const unsigned i) const throw(IndexException); - SpeciesAbility& getAbilityByID(const unsigned i) throw(IndexException); - unsigned getAbilityIndex(const unsigned _id) const; - unsigned getAbilityCount() const; - SpeciesAbility& newAbility(); - SpeciesAbility& newAbility(const QString& fname); - SpeciesAbility& newAbility(const SpeciesAbility& a); - void deleteAbility(const unsigned i) throw(IndexException); - - const SpeciesEvolution& getEvolution(const unsigned i) const throw(IndexException); - SpeciesEvolution& getEvolution(const unsigned i) throw(IndexException); - const SpeciesEvolution& getEvolutionByID(const unsigned i) const throw(IndexException); - SpeciesEvolution& getEvolutionByID(const unsigned i) throw(IndexException); - unsigned getEvolutionIndex(const unsigned _id) const; - unsigned getEvolutionCount() const; - SpeciesEvolution& newEvolution(); - SpeciesEvolution& newEvolution(const QString& fname); - SpeciesEvolution& newEvolution(const SpeciesEvolution& e); - void deleteEvolution(const unsigned i) throw(IndexException); - - const SpeciesItem& getItem(const unsigned i) const throw(IndexException); - SpeciesItem& getItem(const unsigned i) throw(IndexException); - const SpeciesItem& getItemByID(const unsigned i) const throw(IndexException); - SpeciesItem& getItemByID(const unsigned i) throw(IndexException); - unsigned getItemIndex(const unsigned _id) const; - unsigned getItemCount() const; - SpeciesItem& newItem(); - SpeciesItem& newItem(const QString& fname); - SpeciesItem& newItem(const SpeciesItem& i); - void deleteItem(const unsigned i) throw(IndexException); - - const SpeciesMove& getMove(const unsigned i) const throw(IndexException); - SpeciesMove& getMove(const unsigned i) throw(IndexException); - const SpeciesMove& getMoveByID(const unsigned i) const throw(IndexException); - SpeciesMove& getMoveByID(const unsigned i) throw(IndexException); - unsigned getMoveIndex(const unsigned _id) const; - unsigned getMoveCount() const; - SpeciesMove& newMove(); - SpeciesMove& newMove(const QString& fname); - SpeciesMove& newMove(const SpeciesMove& m); - void deleteMove(const unsigned i) throw(IndexException); - - Species& operator=(const Species& rhs); - private: - bool validate() const; - unsigned getNewAbilityId() const; - unsigned getNewEvolutionId() const; - unsigned getNewItemId() const; - unsigned getNewMoveId() const; - - QString name; - bool baseStats[ST_End_GSC]; - bool effortValues[ST_End_GSC]; - unsigned growth; - unsigned experienceValue; - unsigned char catchValue; - Frac runChance; - Frac itemChance; - unsigned pokedexNumber; - unsigned weight; - unsigned heightFeet; - unsigned heightInches; - QString pokedexEntry; - Frac genderFactor; - unsigned eggSpecies; - unsigned eggSteps; - unsigned nidoranGroup; - QList<unsigned> types; - QList<unsigned> eggGroups; - - QList<SpeciesAbility> abilities; - QList<SpeciesEvolution> evolutions; - QList<SpeciesItem> items; - QList<SpeciesMove> moves; - }; -} + public: + enum + { + Fluctuating = 0, + Fading = 1, + Slow = 2, + Normal = 3, + Fast = 5, + Erratic = 6, + End = 7 + }; + static const QStringList StyleStr; + + Species(const Pokemod& par, const unsigned _id); + Species(const Pokemod& par, const Species& s, const unsigned _id); + Species(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + void setBaseStat(const unsigned s, const unsigned b) throw(BoundsException); + void setEffortValue(const unsigned s, const unsigned e) throw(Exception); + void setGrowth(const unsigned g) throw(BoundsException); + void setExperienceValue(const unsigned e); + void setCatchValue(const unsigned char c); + void setRunChance(const unsigned n, const unsigned d) throw(Exception); + void setRunChanceNumerator(const unsigned n) throw(Exception); + void setRunChanceDenominator(const unsigned d) throw(Exception); + void setItemChance(const unsigned n, const unsigned d) throw(Exception); + void setItemChanceNumerator(const unsigned n) throw(Exception); + void setItemChanceDenominator(const unsigned d) throw(Exception); + void setPokedexNumber(const unsigned p); + void setWeight(const unsigned w); + void setHeightFeet(const unsigned f); + void setHeightInches(const unsigned char i) throw(BoundsException); + void setPokedexEntry(const QString& p); + void setFrontMaleSprite(const QString& fname) throw(Exception); + void setBackMaleSprite(const QString& fname) throw(Exception); + void setFrontFemaleSprite(const QString& fname) throw(Exception); + void setBackFemaleSprite(const QString& fname) throw(Exception); + void setListSprite(const QString& fname) throw(Exception); + void setGenderFactor(const unsigned n, const unsigned d) throw(Exception); + void setGenderFactorNum(const unsigned n) throw(Exception); + void setGenderFactorDenom(const unsigned d) throw(Exception); + void setEggSpecies(const unsigned e) throw(BoundsException); + void setEggSteps(const unsigned e); + void setNidoranGroup(const unsigned n); + void setType(const unsigned ty, const bool t) throw(Exception); + void setEggGroup(const unsigned eg, const bool e) throw(Exception); + + QString getName() const; + unsigned getBaseStat(const unsigned s) const throw(BoundsException); + unsigned getEffortValue(const unsigned s) const throw(BoundsException); + unsigned getGrowth() const; + unsigned getExperienceValue() const; + unsigned char getCatchValue() const; + Frac getRunChance() const; + Frac getItemChance() const; + unsigned getPokedexNumber() const; + unsigned getWeight() const; + unsigned getHeightFeet() const; + unsigned getHeightInches() const; + QString getPokedexEntry() const; + bool getFrontMaleSprite() const; + bool getBackMaleSprite() const; + bool getFrontFemaleSprite() const; + bool getBackFemaleSprite() const; + bool getListSprite() const; + Frac getGenderFactor() const; + unsigned getEggSpecies() const; + unsigned getEggSteps() const; + unsigned getNidoranGroup() const; + bool getType(const unsigned ty) const; + bool getEggGroup(const unsigned eg) const; + + const SpeciesAbility& getAbility(const unsigned i) const throw(IndexException); + SpeciesAbility& getAbility(const unsigned i) throw(IndexException); + const SpeciesAbility& getAbilityByID(const unsigned i) const throw(IndexException); + SpeciesAbility& getAbilityByID(const unsigned i) throw(IndexException); + unsigned getAbilityIndex(const unsigned _id) const; + unsigned getAbilityCount() const; + SpeciesAbility& newAbility(); + SpeciesAbility& newAbility(const QString& fname); + SpeciesAbility& newAbility(const SpeciesAbility& a); + void deleteAbility(const unsigned i) throw(IndexException); + + const SpeciesEvolution& getEvolution(const unsigned i) const throw(IndexException); + SpeciesEvolution& getEvolution(const unsigned i) throw(IndexException); + const SpeciesEvolution& getEvolutionByID(const unsigned i) const throw(IndexException); + SpeciesEvolution& getEvolutionByID(const unsigned i) throw(IndexException); + unsigned getEvolutionIndex(const unsigned _id) const; + unsigned getEvolutionCount() const; + SpeciesEvolution& newEvolution(); + SpeciesEvolution& newEvolution(const QString& fname); + SpeciesEvolution& newEvolution(const SpeciesEvolution& e); + void deleteEvolution(const unsigned i) throw(IndexException); + + const SpeciesItem& getItem(const unsigned i) const throw(IndexException); + SpeciesItem& getItem(const unsigned i) throw(IndexException); + const SpeciesItem& getItemByID(const unsigned i) const throw(IndexException); + SpeciesItem& getItemByID(const unsigned i) throw(IndexException); + unsigned getItemIndex(const unsigned _id) const; + unsigned getItemCount() const; + SpeciesItem& newItem(); + SpeciesItem& newItem(const QString& fname); + SpeciesItem& newItem(const SpeciesItem& i); + void deleteItem(const unsigned i) throw(IndexException); + + const SpeciesMove& getMove(const unsigned i) const throw(IndexException); + SpeciesMove& getMove(const unsigned i) throw(IndexException); + const SpeciesMove& getMoveByID(const unsigned i) const throw(IndexException); + SpeciesMove& getMoveByID(const unsigned i) throw(IndexException); + unsigned getMoveIndex(const unsigned _id) const; + unsigned getMoveCount() const; + SpeciesMove& newMove(); + SpeciesMove& newMove(const QString& fname); + SpeciesMove& newMove(const SpeciesMove& m); + void deleteMove(const unsigned i) throw(IndexException); + + Species& operator=(const Species& rhs); + private: + bool validate() const; + unsigned getNewAbilityId() const; + unsigned getNewEvolutionId() const; + unsigned getNewItemId() const; + unsigned getNewMoveId() const; + + QString name; + bool baseStats[ST_End_GSC]; + bool effortValues[ST_End_GSC]; + unsigned growth; + unsigned experienceValue; + unsigned char catchValue; + Frac runChance; + Frac itemChance; + unsigned pokedexNumber; + unsigned weight; + unsigned heightFeet; + unsigned heightInches; + QString pokedexEntry; + Frac genderFactor; + unsigned eggSpecies; + unsigned eggSteps; + unsigned nidoranGroup; + QList<unsigned> types; + QList<unsigned> eggGroups; + + QList<SpeciesAbility> abilities; + QList<SpeciesEvolution> evolutions; + QList<SpeciesItem> items; + QList<SpeciesMove> moves; +}; #endif diff --git a/pokemod/SpeciesAbility.cpp b/pokemod/SpeciesAbility.cpp index 6da854bc..41e51c28 100644 --- a/pokemod/SpeciesAbility.cpp +++ b/pokemod/SpeciesAbility.cpp @@ -23,26 +23,26 @@ #include "Pokemod.h" #include "SpeciesAbility.h" -PokeMod::SpeciesAbility::SpeciesAbility(const Pokemod& par, const unsigned _id) : +SpeciesAbility::SpeciesAbility(const Pokemod& par, const unsigned _id) : Object(par, _id), ability(UINT_MAX), weight(1) { } -PokeMod::SpeciesAbility::SpeciesAbility(const Pokemod& par, const SpeciesAbility& a, const unsigned _id) : +SpeciesAbility::SpeciesAbility(const Pokemod& par, const SpeciesAbility& a, const unsigned _id) : Object(par, _id) { *this = a; } -PokeMod::SpeciesAbility::SpeciesAbility(const Pokemod& par, const QString& fname, const unsigned _id) : +SpeciesAbility::SpeciesAbility(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::SpeciesAbility::validate() const +bool SpeciesAbility::validate() const { bool valid = true; pokemod.validationMsg(QString("------Ability with id %1---").arg(id), Pokemod::V_Msg); @@ -59,7 +59,7 @@ bool PokeMod::SpeciesAbility::validate() const return valid; } -void PokeMod::SpeciesAbility::load(const QString& fname, const unsigned _id) throw(Exception) +void SpeciesAbility::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -70,7 +70,7 @@ void PokeMod::SpeciesAbility::load(const QString& fname, const unsigned _id) thr ini.getValue("weight", weight, 1); } -void PokeMod::SpeciesAbility::save(const QString& species) const throw(Exception) +void SpeciesAbility::save(const QString& species) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -79,31 +79,31 @@ void PokeMod::SpeciesAbility::save(const QString& species) const throw(Exception ini.save(QString("%1/species/%2/ability/%3.pini").arg(pokemod.getPath()).arg(species).arg(id)); } -void PokeMod::SpeciesAbility::setAbility(const unsigned a) throw(BoundsException) +void SpeciesAbility::setAbility(const unsigned a) throw(BoundsException) { if (pokemod.getAbilityIndex(a) == UINT_MAX) throw(BoundsException("SpeciesAbility", "ability")); ability = a; } -void PokeMod::SpeciesAbility::setWeight(const unsigned w) throw(BoundsException) +void SpeciesAbility::setWeight(const unsigned w) throw(BoundsException) { if (!w) throw(BoundsException("SpeciesAbility", "weight")); weight = w; } -unsigned PokeMod::SpeciesAbility::getAbility() const +unsigned SpeciesAbility::getAbility() const { return ability; } -unsigned PokeMod::SpeciesAbility::getWeight() const +unsigned SpeciesAbility::getWeight() const { return weight; } -PokeMod::SpeciesAbility& PokeMod::SpeciesAbility::operator=(const SpeciesAbility& rhs) +SpeciesAbility& SpeciesAbility::operator=(const SpeciesAbility& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/SpeciesAbility.h b/pokemod/SpeciesAbility.h index d7065ed0..aeb9eb8b 100644 --- a/pokemod/SpeciesAbility.h +++ b/pokemod/SpeciesAbility.h @@ -27,33 +27,30 @@ #include "../general/Exception.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class SpeciesAbility : public Object { - class Pokemod; - - class SpeciesAbility : public Object - { - public: - SpeciesAbility(const Pokemod& par, const unsigned _id); - SpeciesAbility(const Pokemod& par, const SpeciesAbility& a, const unsigned _id); - SpeciesAbility(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save(const QString& species) const throw(Exception); - - void setAbility(const unsigned a) throw(BoundsException); - void setWeight(const unsigned w) throw(BoundsException); - - unsigned getAbility() const; - unsigned getWeight() const; - - SpeciesAbility& operator=(const SpeciesAbility& rhs); - private: - bool validate() const; - - unsigned ability; - unsigned weight; - }; -} + public: + SpeciesAbility(const Pokemod& par, const unsigned _id); + SpeciesAbility(const Pokemod& par, const SpeciesAbility& a, const unsigned _id); + SpeciesAbility(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save(const QString& species) const throw(Exception); + + void setAbility(const unsigned a) throw(BoundsException); + void setWeight(const unsigned w) throw(BoundsException); + + unsigned getAbility() const; + unsigned getWeight() const; + + SpeciesAbility& operator=(const SpeciesAbility& rhs); + private: + bool validate() const; + + unsigned ability; + unsigned weight; +}; #endif diff --git a/pokemod/SpeciesEvolution.cpp b/pokemod/SpeciesEvolution.cpp index 224bddb8..6ed220c9 100644 --- a/pokemod/SpeciesEvolution.cpp +++ b/pokemod/SpeciesEvolution.cpp @@ -26,10 +26,10 @@ #include "ItemEffect.h" #include "SpeciesEvolution.h" -const QStringList PokeMod::SpeciesEvolution::StyleStr = QStringList() << "Level" << "Happiness" << "Stat" << "Item" << "Trade" << "TradeItem" << "Personality" << "Spare Slot"; -const QStringList PokeMod::SpeciesEvolution::GiveHoldStr = QStringList() <<"Give" << "Hold"; +const QStringList SpeciesEvolution::StyleStr = QStringList() << "Level" << "Happiness" << "Stat" << "Item" << "Trade" << "TradeItem" << "Personality" << "Spare Slot"; +const QStringList SpeciesEvolution::GiveHoldStr = QStringList() <<"Give" << "Hold"; -PokeMod::SpeciesEvolution::SpeciesEvolution(const Pokemod& par, const unsigned _id) : +SpeciesEvolution::SpeciesEvolution(const Pokemod& par, const unsigned _id) : Object(par, _id), species(UINT_MAX), style(UINT_MAX), @@ -40,19 +40,19 @@ PokeMod::SpeciesEvolution::SpeciesEvolution(const Pokemod& par, const unsigned _ { } -PokeMod::SpeciesEvolution::SpeciesEvolution(const Pokemod& par, const SpeciesEvolution& e, const unsigned _id) : +SpeciesEvolution::SpeciesEvolution(const Pokemod& par, const SpeciesEvolution& e, const unsigned _id) : Object(par, _id) { *this = e; } -PokeMod::SpeciesEvolution::SpeciesEvolution(const Pokemod& par, const QString& fname, const unsigned _id) : +SpeciesEvolution::SpeciesEvolution(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::SpeciesEvolution::validate() const +bool SpeciesEvolution::validate() const { bool valid = true; pokemod.validationMsg(QString("------Evolution with id %1---").arg(id), Pokemod::V_Msg); @@ -77,9 +77,9 @@ bool PokeMod::SpeciesEvolution::validate() const ok = false; else { - for (unsigned i = 0; (i < pokemod.getItem(pokemod.getItemIndex(val1)).getEffectCount()) && !ok; ++i) + for (unsigned i = 0; (i < pokemod.getItemByID(val1).getEffectCount()) && !ok; ++i) { - if (pokemod.getItem(pokemod.getItemIndex(val1)).getEffect(i).getEffect() == ItemEffect::E_Evolution) + if (pokemod.getItemByID(val1).getEffect(i).getEffect() == ItemEffect::E_Evolution) ok = true; } } @@ -130,7 +130,7 @@ bool PokeMod::SpeciesEvolution::validate() const return valid; } -void PokeMod::SpeciesEvolution::load(const QString& fname, const unsigned _id) throw(Exception) +void SpeciesEvolution::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -145,7 +145,7 @@ void PokeMod::SpeciesEvolution::load(const QString& fname, const unsigned _id) t ini.getValue("level", level, 0); } -void PokeMod::SpeciesEvolution::save(const QString& species) const throw(Exception) +void SpeciesEvolution::save(const QString& species) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -158,21 +158,21 @@ void PokeMod::SpeciesEvolution::save(const QString& species) const throw(Excepti ini.save(QString("%1/species/%2/evolution/%3.pini").arg(pokemod.getPath()).arg(species).arg(id)); } -void PokeMod::SpeciesEvolution::setSpecies(const unsigned s) throw(BoundsException) +void SpeciesEvolution::setSpecies(const unsigned s) throw(BoundsException) { if (pokemod.getSpeciesIndex(s) == UINT_MAX) throw(BoundsException("SpeciesEvolution", "species")); species = s; } -void PokeMod::SpeciesEvolution::setStyle(const unsigned s) throw(BoundsException) +void SpeciesEvolution::setStyle(const unsigned s) throw(BoundsException) { if (S_End <= s) throw(BoundsException("SpeciesEvolution", "style")); style = s; } -void PokeMod::SpeciesEvolution::setVal1(const unsigned v1) throw(Exception) +void SpeciesEvolution::setVal1(const unsigned v1) throw(Exception) { bool ok = false; switch (style) @@ -188,9 +188,9 @@ void PokeMod::SpeciesEvolution::setVal1(const unsigned v1) throw(Exception) case S_TradeItem: if (pokemod.getItemIndex(val1) == UINT_MAX) throw(BoundsException("SpeciesEvolution", "val1")); - for (unsigned i = 0; (i < pokemod.getItem(pokemod.getItemIndex(val1)).getEffectCount()) && !ok; ++i) + for (unsigned i = 0; (i < pokemod.getItemByID(val1).getEffectCount()) && !ok; ++i) { - if (pokemod.getItem(pokemod.getItemIndex(val1)).getEffect(i).getEffect() == ItemEffect::E_Evolution) + if (pokemod.getItemByID(val1).getEffect(i).getEffect() == ItemEffect::E_Evolution) ok = true; } if (!ok) @@ -203,7 +203,7 @@ void PokeMod::SpeciesEvolution::setVal1(const unsigned v1) throw(Exception) val1 = v1; } -void PokeMod::SpeciesEvolution::setVal2(const unsigned v2) throw(Exception) +void SpeciesEvolution::setVal2(const unsigned v2) throw(Exception) { switch (style) { @@ -221,7 +221,7 @@ void PokeMod::SpeciesEvolution::setVal2(const unsigned v2) throw(Exception) val2 = v2; } -void PokeMod::SpeciesEvolution::setVal3(const unsigned v3) throw(Exception) +void SpeciesEvolution::setVal3(const unsigned v3) throw(Exception) { switch (style) { @@ -236,44 +236,44 @@ void PokeMod::SpeciesEvolution::setVal3(const unsigned v3) throw(Exception) val3 = v3; } -void PokeMod::SpeciesEvolution::setLevel(const unsigned l) throw(BoundsException) +void SpeciesEvolution::setLevel(const unsigned l) throw(BoundsException) { if (pokemod.getRules().getMaxLevel() < l) throw(BoundsException("SpeciesEvolution", "level")); level = l; } -unsigned PokeMod::SpeciesEvolution::getSpecies() const +unsigned SpeciesEvolution::getSpecies() const { return species; } -unsigned PokeMod::SpeciesEvolution::getStyle() const +unsigned SpeciesEvolution::getStyle() const { return style; } -unsigned PokeMod::SpeciesEvolution::getVal1() const +unsigned SpeciesEvolution::getVal1() const { return val1; } -unsigned PokeMod::SpeciesEvolution::getVal2() const +unsigned SpeciesEvolution::getVal2() const { return val2; } -unsigned PokeMod::SpeciesEvolution::getVal3() const +unsigned SpeciesEvolution::getVal3() const { return val3; } -unsigned PokeMod::SpeciesEvolution::getLevel() const +unsigned SpeciesEvolution::getLevel() const { return level; } -PokeMod::SpeciesEvolution& PokeMod::SpeciesEvolution::operator=(const SpeciesEvolution& rhs) +SpeciesEvolution& SpeciesEvolution::operator=(const SpeciesEvolution& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/SpeciesEvolution.h b/pokemod/SpeciesEvolution.h index acdc4c6c..8e77c429 100644 --- a/pokemod/SpeciesEvolution.h +++ b/pokemod/SpeciesEvolution.h @@ -28,67 +28,64 @@ #include "../general/Exception.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class SpeciesEvolution : public Object { - class Pokemod; - - class SpeciesEvolution : public Object - { - public: - enum Style - { - S_Level = 0, - S_Happiness = 1, - S_Stat = 2, - S_Item = 3, - S_Trade = 4, - S_TradeItem = 5, - S_Personality = 6, - S_SpareSlot = 7, - S_End = 8 - }; - static const QStringList StyleStr; - - enum GiveHold - { - G_Give = 0, - G_Hold = 1, - G_End = 2 - }; - static const QStringList GiveHoldStr; - - SpeciesEvolution(const Pokemod& par, const unsigned _id); - SpeciesEvolution(const Pokemod& par, const SpeciesEvolution& e, const unsigned _id); - SpeciesEvolution(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save(const QString& species) const throw(Exception); - - void setSpecies(const unsigned s) throw(BoundsException); - void setStyle(const unsigned s) throw(BoundsException); - void setVal1(const unsigned v1) throw(Exception); - void setVal2(const unsigned v2) throw(Exception); - void setVal3(const unsigned v3) throw(Exception); - void setLevel(const unsigned l) throw(BoundsException); - - unsigned getSpecies() const; - unsigned getStyle() const; - unsigned getVal1() const; - unsigned getVal2() const; - unsigned getVal3() const; - unsigned getLevel() const; - - SpeciesEvolution& operator=(const SpeciesEvolution& rhs); - private: - bool validate() const; - - unsigned species; - unsigned style; - unsigned val1; - unsigned val2; - unsigned val3; - unsigned level; - }; -} + public: + enum Style + { + S_Level = 0, + S_Happiness = 1, + S_Stat = 2, + S_Item = 3, + S_Trade = 4, + S_TradeItem = 5, + S_Personality = 6, + S_SpareSlot = 7, + S_End = 8 + }; + static const QStringList StyleStr; + + enum GiveHold + { + G_Give = 0, + G_Hold = 1, + G_End = 2 + }; + static const QStringList GiveHoldStr; + + SpeciesEvolution(const Pokemod& par, const unsigned _id); + SpeciesEvolution(const Pokemod& par, const SpeciesEvolution& e, const unsigned _id); + SpeciesEvolution(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save(const QString& species) const throw(Exception); + + void setSpecies(const unsigned s) throw(BoundsException); + void setStyle(const unsigned s) throw(BoundsException); + void setVal1(const unsigned v1) throw(Exception); + void setVal2(const unsigned v2) throw(Exception); + void setVal3(const unsigned v3) throw(Exception); + void setLevel(const unsigned l) throw(BoundsException); + + unsigned getSpecies() const; + unsigned getStyle() const; + unsigned getVal1() const; + unsigned getVal2() const; + unsigned getVal3() const; + unsigned getLevel() const; + + SpeciesEvolution& operator=(const SpeciesEvolution& rhs); + private: + bool validate() const; + + unsigned species; + unsigned style; + unsigned val1; + unsigned val2; + unsigned val3; + unsigned level; +}; #endif diff --git a/pokemod/SpeciesItem.cpp b/pokemod/SpeciesItem.cpp index be42911b..61b8abca 100644 --- a/pokemod/SpeciesItem.cpp +++ b/pokemod/SpeciesItem.cpp @@ -23,26 +23,26 @@ #include "Pokemod.h" #include "SpeciesItem.h" -PokeMod::SpeciesItem::SpeciesItem(const Pokemod& par, const unsigned _id) : +SpeciesItem::SpeciesItem(const Pokemod& par, const unsigned _id) : Object(par, _id), item(UINT_MAX), weight(1) { } -PokeMod::SpeciesItem::SpeciesItem(const Pokemod& par, const SpeciesItem& i, const unsigned _id) : +SpeciesItem::SpeciesItem(const Pokemod& par, const SpeciesItem& i, const unsigned _id) : Object(par, _id) { *this = i; } -PokeMod::SpeciesItem::SpeciesItem(const Pokemod& par, const QString& fname, const unsigned _id) : +SpeciesItem::SpeciesItem(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::SpeciesItem::validate() const +bool SpeciesItem::validate() const { bool valid = true; pokemod.validationMsg(QString("------Item with id %1---").arg(id), Pokemod::V_Msg); @@ -59,7 +59,7 @@ bool PokeMod::SpeciesItem::validate() const return valid; } -void PokeMod::SpeciesItem::load(const QString& fname, const unsigned _id) throw(Exception) +void SpeciesItem::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -70,7 +70,7 @@ void PokeMod::SpeciesItem::load(const QString& fname, const unsigned _id) throw( ini.getValue("weight", weight, 1); } -void PokeMod::SpeciesItem::save(const QString& species) const throw(Exception) +void SpeciesItem::save(const QString& species) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -79,31 +79,31 @@ void PokeMod::SpeciesItem::save(const QString& species) const throw(Exception) ini.save(QString("%1/species/%2/item/%3.pini").arg(pokemod.getPath()).arg(species).arg(id)); } -void PokeMod::SpeciesItem::setItem(const unsigned i) throw(BoundsException) +void SpeciesItem::setItem(const unsigned i) throw(BoundsException) { if (pokemod.getItemIndex(i) == UINT_MAX) throw(BoundsException("SpeciesItem", "item")); item = i; } -void PokeMod::SpeciesItem::setWeight(const unsigned w) throw(BoundsException) +void SpeciesItem::setWeight(const unsigned w) throw(BoundsException) { if (!w) throw(BoundsException("SpeciesItem", "weight")); weight = w; } -unsigned PokeMod::SpeciesItem::getItem() const +unsigned SpeciesItem::getItem() const { return item; } -unsigned PokeMod::SpeciesItem::getWeight() const +unsigned SpeciesItem::getWeight() const { return weight; } -PokeMod::SpeciesItem& PokeMod::SpeciesItem::operator=(const SpeciesItem& rhs) +SpeciesItem& SpeciesItem::operator=(const SpeciesItem& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/SpeciesItem.h b/pokemod/SpeciesItem.h index 5cbaa83c..da34aecf 100644 --- a/pokemod/SpeciesItem.h +++ b/pokemod/SpeciesItem.h @@ -27,33 +27,30 @@ #include "../general/Exception.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class SpeciesItem : public Object { - class Pokemod; - - class SpeciesItem : public Object - { - public: - SpeciesItem(const Pokemod& par, const unsigned _id); - SpeciesItem(const Pokemod& par, const SpeciesItem& i, const unsigned _id); - SpeciesItem(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save(const QString& species) const throw(Exception); - - void setItem(const unsigned i) throw(BoundsException); - void setWeight(const unsigned w) throw(BoundsException); - - unsigned getItem() const; - unsigned getWeight() const; - - SpeciesItem& operator=(const SpeciesItem& rhs); - private: - bool validate() const; - - unsigned item; - unsigned weight; - }; -} + public: + SpeciesItem(const Pokemod& par, const unsigned _id); + SpeciesItem(const Pokemod& par, const SpeciesItem& i, const unsigned _id); + SpeciesItem(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save(const QString& species) const throw(Exception); + + void setItem(const unsigned i) throw(BoundsException); + void setWeight(const unsigned w) throw(BoundsException); + + unsigned getItem() const; + unsigned getWeight() const; + + SpeciesItem& operator=(const SpeciesItem& rhs); + private: + bool validate() const; + + unsigned item; + unsigned weight; +}; #endif diff --git a/pokemod/SpeciesMove.cpp b/pokemod/SpeciesMove.cpp index da6d7dd9..aad8efad 100644 --- a/pokemod/SpeciesMove.cpp +++ b/pokemod/SpeciesMove.cpp @@ -23,7 +23,7 @@ #include "Pokemod.h" #include "SpeciesMove.h" -PokeMod::SpeciesMove::SpeciesMove(const Pokemod& par, const unsigned _id) : +SpeciesMove::SpeciesMove(const Pokemod& par, const unsigned _id) : Object(par, _id), move(UINT_MAX), level(0), @@ -31,19 +31,19 @@ PokeMod::SpeciesMove::SpeciesMove(const Pokemod& par, const unsigned _id) : { } -PokeMod::SpeciesMove::SpeciesMove(const Pokemod& par, const SpeciesMove& m, const unsigned _id) : +SpeciesMove::SpeciesMove(const Pokemod& par, const SpeciesMove& m, const unsigned _id) : Object(par, _id) { *this = m; } -PokeMod::SpeciesMove::SpeciesMove(const Pokemod& par, const QString& fname, const unsigned _id) : +SpeciesMove::SpeciesMove(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::SpeciesMove::validate() const +bool SpeciesMove::validate() const { bool valid = true; pokemod.validationMsg(QString("------Move with id %1---").arg(id), Pokemod::V_Msg); @@ -65,7 +65,7 @@ bool PokeMod::SpeciesMove::validate() const return valid; } -void PokeMod::SpeciesMove::load(const QString& fname, const unsigned _id) throw(Exception) +void SpeciesMove::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -77,7 +77,7 @@ void PokeMod::SpeciesMove::load(const QString& fname, const unsigned _id) throw( ini.getValue("wild", wild, 0); } -void PokeMod::SpeciesMove::save(const QString& species) const throw(Exception) +void SpeciesMove::save(const QString& species) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -87,43 +87,43 @@ void PokeMod::SpeciesMove::save(const QString& species) const throw(Exception) ini.save(QString("%1/species/%2/move/%3.pini").arg(pokemod.getPath()).arg(species).arg(id)); } -void PokeMod::SpeciesMove::setMove(const unsigned m) throw(BoundsException) +void SpeciesMove::setMove(const unsigned m) throw(BoundsException) { if (pokemod.getMoveIndex(m) == UINT_MAX) throw(BoundsException("SpeciesMove", "move")); move = m; } -void PokeMod::SpeciesMove::setLevel(const unsigned l) throw(BoundsException) +void SpeciesMove::setLevel(const unsigned l) throw(BoundsException) { if (pokemod.getRules().getMaxLevel() <= l) throw(BoundsException("SpeciesMove", "level")); level = l; } -void PokeMod::SpeciesMove::setWild(const unsigned w) throw(BoundsException) +void SpeciesMove::setWild(const unsigned w) throw(BoundsException) { if (pokemod.getRules().getMaxLevel() <= w) throw(BoundsException("SpeciesMove", "wild")); wild = w; } -unsigned PokeMod::SpeciesMove::getMove() const +unsigned SpeciesMove::getMove() const { return move; } -unsigned PokeMod::SpeciesMove::getLevel() const +unsigned SpeciesMove::getLevel() const { return level; } -unsigned PokeMod::SpeciesMove::getWild() const +unsigned SpeciesMove::getWild() const { return wild; } -PokeMod::SpeciesMove& PokeMod::SpeciesMove::operator=(const SpeciesMove& rhs) +SpeciesMove& SpeciesMove::operator=(const SpeciesMove& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/SpeciesMove.h b/pokemod/SpeciesMove.h index 2453a55a..ee859d61 100644 --- a/pokemod/SpeciesMove.h +++ b/pokemod/SpeciesMove.h @@ -27,36 +27,33 @@ #include "../general/Exception.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class SpeciesMove : public Object { - class Pokemod; - - class SpeciesMove : public Object - { - public: - SpeciesMove(const Pokemod& par, const unsigned _id); - SpeciesMove(const Pokemod& par, const SpeciesMove& m, const unsigned _id); - SpeciesMove(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save(const QString& species) const throw(Exception); - - void setMove(const unsigned m) throw(BoundsException); - void setLevel(const unsigned l) throw(BoundsException); - void setWild(const unsigned w) throw(BoundsException); - - unsigned getMove() const; - unsigned getLevel() const; - unsigned getWild() const; - - SpeciesMove& operator=(const SpeciesMove& rhs); - private: - bool validate() const; - - unsigned move; - unsigned level; - unsigned wild; - }; -} + public: + SpeciesMove(const Pokemod& par, const unsigned _id); + SpeciesMove(const Pokemod& par, const SpeciesMove& m, const unsigned _id); + SpeciesMove(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save(const QString& species) const throw(Exception); + + void setMove(const unsigned m) throw(BoundsException); + void setLevel(const unsigned l) throw(BoundsException); + void setWild(const unsigned w) throw(BoundsException); + + unsigned getMove() const; + unsigned getLevel() const; + unsigned getWild() const; + + SpeciesMove& operator=(const SpeciesMove& rhs); + private: + bool validate() const; + + unsigned move; + unsigned level; + unsigned wild; +}; #endif diff --git a/pokemod/Store.cpp b/pokemod/Store.cpp index 5ab49b73..1b5333d4 100644 --- a/pokemod/Store.cpp +++ b/pokemod/Store.cpp @@ -26,25 +26,25 @@ #include "Pokemod.h" #include "Store.h" -PokeMod::Store::Store(const Pokemod& par, const unsigned _id) : +Store::Store(const Pokemod& par, const unsigned _id) : Object(par, _id), name("") { } -PokeMod::Store::Store(const Pokemod& par, const Store& s, const unsigned _id) : +Store::Store(const Pokemod& par, const Store& s, const unsigned _id) : Object(par, _id) { *this = s; } -PokeMod::Store::Store(const Pokemod& par, const QString& fname, const unsigned _id) : +Store::Store(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::Store::validate() const +bool Store::validate() const { bool valid = true; pokemod.validationMsg(QString("---Store \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -79,7 +79,7 @@ bool PokeMod::Store::validate() const return valid; } -void PokeMod::Store::load(const QString& fname, const unsigned _id) throw(Exception) +void Store::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -99,7 +99,7 @@ void PokeMod::Store::load(const QString& fname, const unsigned _id) throw(Except } } -void PokeMod::Store::save() const throw(Exception) +void Store::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -110,12 +110,12 @@ void PokeMod::Store::save() const throw(Exception) ini.save(QString("%1/store/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeMod::Store::setName(const QString& n) +void Store::setName(const QString& n) { name = n; } -void PokeMod::Store::setItem(const unsigned itm, const bool it) throw(Exception) +void Store::setItem(const unsigned itm, const bool it) throw(Exception) { if (pokemod.getItemIndex(itm) == UINT_MAX) throw(BoundsException("Store", "item")); @@ -134,12 +134,12 @@ void PokeMod::Store::setItem(const unsigned itm, const bool it) throw(Exception) items.append(itm); } -QString PokeMod::Store::getName() const +QString Store::getName() const { return name; } -bool PokeMod::Store::getItem(const unsigned itm) const +bool Store::getItem(const unsigned itm) const { for (QListIterator<unsigned> i(items); i.hasNext(); ) { @@ -149,7 +149,7 @@ bool PokeMod::Store::getItem(const unsigned itm) const return false; } -PokeMod::Store& PokeMod::Store::operator=(const Store& rhs) +Store& Store::operator=(const Store& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Store.h b/pokemod/Store.h index 9b4f8aaf..f034267c 100644 --- a/pokemod/Store.h +++ b/pokemod/Store.h @@ -28,33 +28,30 @@ #include "../general/Exception.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class Store : public Object { - class Pokemod; - - class Store : public Object - { - public: - Store(const Pokemod& par, const unsigned _id); - Store(const Pokemod& par, const Store& s, const unsigned _id); - Store(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - void setItem(const unsigned itm, const bool it) throw(Exception); - - QString getName() const; - bool getItem(const unsigned itm) const; - - Store& operator=(const Store& rhs); - private: - bool validate() const; - - QString name; - QList<unsigned> items; - }; -} + public: + Store(const Pokemod& par, const unsigned _id); + Store(const Pokemod& par, const Store& s, const unsigned _id); + Store(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + void setItem(const unsigned itm, const bool it) throw(Exception); + + QString getName() const; + bool getItem(const unsigned itm) const; + + Store& operator=(const Store& rhs); + private: + bool validate() const; + + QString name; + QList<unsigned> items; +}; #endif diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp index d6d46440..b2c6487e 100644 --- a/pokemod/Tile.cpp +++ b/pokemod/Tile.cpp @@ -24,9 +24,9 @@ #include "Pokemod.h" #include "Tile.h" -const QStringList PokeMod::Tile::ForceStr = QStringList() << "None" << "Slip" << "Stop" << "Force" << "Push"; +const QStringList Tile::ForceStr = QStringList() << "None" << "Slip" << "Stop" << "Force" << "Push"; -PokeMod::Tile::Tile(const Pokemod& par, const unsigned _id) : +Tile::Tile(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), pic(""), @@ -40,20 +40,20 @@ PokeMod::Tile::Tile(const Pokemod& par, const unsigned _id) : from[i] = false; } -PokeMod::Tile::Tile(const Pokemod& par, const Tile& t, const unsigned _id) : +Tile::Tile(const Pokemod& par, const Tile& t, const unsigned _id) : Object(par, _id) { *this = t; } -PokeMod::Tile::Tile(const Pokemod& par, const QString& fname, const unsigned _id) : +Tile::Tile(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id), pic("") { load(fname, _id); } -bool PokeMod::Tile::validate() const +bool Tile::validate() const { bool valid = true; pokemod.validationMsg(QString("---Tile \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -103,7 +103,7 @@ bool PokeMod::Tile::validate() const return valid; } -void PokeMod::Tile::load(const QString& fname, const unsigned _id) throw(Exception) +void Tile::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -127,7 +127,7 @@ void PokeMod::Tile::load(const QString& fname, const unsigned _id) throw(Excepti ini.getValue("forceDirection", forceDirection); } -void PokeMod::Tile::save() const throw(Exception) +void Tile::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -146,41 +146,41 @@ void PokeMod::Tile::save() const throw(Exception) ini.save(QString("%1/tile/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeMod::Tile::setName(const QString& n) +void Tile::setName(const QString& n) { name = n; } -void PokeMod::Tile::setPic(const QString& p) throw(OpenException) +void Tile::setPic(const QString& p) throw(OpenException) { if (!QFile::exists(QString("%1/image/tile/%2.png").arg(pokemod.getPath()).arg(p))) throw(OpenException("Tile", QString("%1/image/tile/%2.png").arg(pokemod.getPath()).arg(p))); pic = p; } -void PokeMod::Tile::setFrom(const unsigned d, const bool f) throw(BoundsException) +void Tile::setFrom(const unsigned d, const bool f) throw(BoundsException) { if (D_End <= d) throw(BoundsException("Tile", "direction")); from[d] = f; } -void PokeMod::Tile::setWildChance(const unsigned n, const unsigned d) throw(Exception) +void Tile::setWildChance(const unsigned n, const unsigned d) throw(Exception) { wildChance.set(n, d); } -void PokeMod::Tile::setWildChanceNumerator(const unsigned n) throw(Exception) +void Tile::setWildChanceNumerator(const unsigned n) throw(Exception) { wildChance.setNum(n); } -void PokeMod::Tile::setWildChanceDenominator(const unsigned d) throw(Exception) +void Tile::setWildChanceDenominator(const unsigned d) throw(Exception) { wildChance.setDenom(d); } -void PokeMod::Tile::setHMType(const unsigned h) throw(BoundsException) +void Tile::setHMType(const unsigned h) throw(BoundsException) { if (HM_End <= h) throw(BoundsException("Tile", "hmType")); @@ -188,7 +188,7 @@ void PokeMod::Tile::setHMType(const unsigned h) throw(BoundsException) under = UINT_MAX; } -void PokeMod::Tile::setUnder(const unsigned u) throw(Exception) +void Tile::setUnder(const unsigned u) throw(Exception) { if ((hmType != HM_Whirlpool) || (hmType != HM_Cut) || (hmType != HM_RockSmash)) throw(UnusedException("Tile", "under")); @@ -197,14 +197,14 @@ void PokeMod::Tile::setUnder(const unsigned u) throw(Exception) under = u; } -void PokeMod::Tile::setForceType(const unsigned f) throw(BoundsException) +void Tile::setForceType(const unsigned f) throw(BoundsException) { if (End <= f) throw(BoundsException("Tile", "forceType")); forceType = f; } -void PokeMod::Tile::setForceDirection(const unsigned f) throw(Exception) +void Tile::setForceDirection(const unsigned f) throw(Exception) { if ((forceType == None) || (forceType == Stop)) throw(UnusedException("Tile", "forceDirection")); @@ -213,49 +213,49 @@ void PokeMod::Tile::setForceDirection(const unsigned f) throw(Exception) forceDirection = f; } -QString PokeMod::Tile::getName() const +QString Tile::getName() const { return name; } -QString PokeMod::Tile::getPic() const +QString Tile::getPic() const { return pic; } -bool PokeMod::Tile::getFrom(const unsigned d) const throw(BoundsException) +bool Tile::getFrom(const unsigned d) const throw(BoundsException) { if (D_End <= d) throw(BoundsException("Tile", "direction")); return from[d]; } -Frac PokeMod::Tile::getWildChance() const +Frac Tile::getWildChance() const { return wildChance; } -unsigned PokeMod::Tile::getHMType() const +unsigned Tile::getHMType() const { return hmType; } -unsigned PokeMod::Tile::getUnder() const +unsigned Tile::getUnder() const { return under; } -unsigned PokeMod::Tile::getForceType() const +unsigned Tile::getForceType() const { return forceType; } -unsigned PokeMod::Tile::getForceDirection() const +unsigned Tile::getForceDirection() const { return forceDirection; } -PokeMod::Tile& PokeMod::Tile::operator=(const Tile& rhs) +Tile& Tile::operator=(const Tile& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Tile.h b/pokemod/Tile.h index fe14ecdd..05e1b393 100644 --- a/pokemod/Tile.h +++ b/pokemod/Tile.h @@ -28,64 +28,61 @@ #include "../general/Exception.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class Tile : public Object { - class Pokemod; - - class Tile : public Object - { - public: - enum Force - { - None = 0, - Slip = 1, - Stop = 2, - Force = 3, - Push = 4, - End = 5 - }; - static const QStringList ForceStr; - - Tile(const Pokemod& par, const unsigned _id); - Tile(const Pokemod& par, const Tile& t, const unsigned _id); - Tile(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - void setPic(const QString& p) throw(OpenException); - void setFrom(const unsigned d, const bool f) throw(BoundsException); - void setWildChance(const unsigned n, const unsigned d) throw(Exception); - void setWildChanceNumerator(const unsigned n) throw(Exception); - void setWildChanceDenominator(const unsigned d) throw(Exception); - void setHMType(const unsigned h) throw(BoundsException); - void setUnder(const unsigned u) throw(Exception); - void setForceType(const unsigned f) throw(BoundsException); - void setForceDirection(const unsigned f) throw(Exception); - - QString getName() const; - QString getPic() const; - bool getFrom(const unsigned d) const throw(BoundsException); - Frac getWildChance() const; - unsigned getHMType() const; - unsigned getUnder() const; - unsigned getForceType() const; - unsigned getForceDirection() const; - - Tile& operator=(const Tile& rhs); - private: - bool validate() const; - - QString name; - QString pic; - bool from[D_End]; - Frac wildChance; - unsigned hmType; - unsigned under; - unsigned forceType; - unsigned forceDirection; - }; -} + public: + enum Force + { + None = 0, + Slip = 1, + Stop = 2, + Force = 3, + Push = 4, + End = 5 + }; + static const QStringList ForceStr; + + Tile(const Pokemod& par, const unsigned _id); + Tile(const Pokemod& par, const Tile& t, const unsigned _id); + Tile(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + void setPic(const QString& p) throw(OpenException); + void setFrom(const unsigned d, const bool f) throw(BoundsException); + void setWildChance(const unsigned n, const unsigned d) throw(Exception); + void setWildChanceNumerator(const unsigned n) throw(Exception); + void setWildChanceDenominator(const unsigned d) throw(Exception); + void setHMType(const unsigned h) throw(BoundsException); + void setUnder(const unsigned u) throw(Exception); + void setForceType(const unsigned f) throw(BoundsException); + void setForceDirection(const unsigned f) throw(Exception); + + QString getName() const; + QString getPic() const; + bool getFrom(const unsigned d) const throw(BoundsException); + Frac getWildChance() const; + unsigned getHMType() const; + unsigned getUnder() const; + unsigned getForceType() const; + unsigned getForceDirection() const; + + Tile& operator=(const Tile& rhs); + private: + bool validate() const; + + QString name; + QString pic; + bool from[D_End]; + Frac wildChance; + unsigned hmType; + unsigned under; + unsigned forceType; + unsigned forceDirection; +}; #endif diff --git a/pokemod/Time.cpp b/pokemod/Time.cpp index c33d0381..b8e3215d 100644 --- a/pokemod/Time.cpp +++ b/pokemod/Time.cpp @@ -23,7 +23,7 @@ #include "Pokemod.h" #include "Time.h" -PokeMod::Time::Time(const Pokemod& par, const unsigned _id) : +Time::Time(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), startHour(0), @@ -31,19 +31,19 @@ PokeMod::Time::Time(const Pokemod& par, const unsigned _id) : { } -PokeMod::Time::Time(const Pokemod& par, const Time& t, const unsigned _id) : +Time::Time(const Pokemod& par, const Time& t, const unsigned _id) : Object(par, _id) { *this = t; } -PokeMod::Time::Time(const Pokemod& par, const QString& fname, const unsigned _id) : +Time::Time(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::Time::validate() const +bool Time::validate() const { bool valid = true; pokemod.validationMsg(QString("---Time \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -65,7 +65,7 @@ bool PokeMod::Time::validate() const return valid; } -void PokeMod::Time::load(const QString& fname, const unsigned _id) throw(Exception) +void Time::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -77,7 +77,7 @@ void PokeMod::Time::load(const QString& fname, const unsigned _id) throw(Excepti ini.getValue("startMinute", startMinute, 0); } -void PokeMod::Time::save() const throw(Exception) +void Time::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -87,41 +87,41 @@ void PokeMod::Time::save() const throw(Exception) ini.save(QString("%1/time/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeMod::Time::setName(const QString& n) +void Time::setName(const QString& n) { name = n; } -void PokeMod::Time::setStartHour(const unsigned h) throw(BoundsException) +void Time::setStartHour(const unsigned h) throw(BoundsException) { if (24 <= h) throw(BoundsException("Time", "startHour")); startHour = h; } -void PokeMod::Time::setStartMinute(const unsigned m) throw(BoundsException) +void Time::setStartMinute(const unsigned m) throw(BoundsException) { if (60 <= m) throw(BoundsException("Time", "startMinute")); startMinute = m; } -QString PokeMod::Time::getName() const +QString Time::getName() const { return name; } -unsigned PokeMod::Time::getStartHour() const +unsigned Time::getStartHour() const { return startHour; } -unsigned PokeMod::Time::getStartMinute() const +unsigned Time::getStartMinute() const { return startMinute; } -PokeMod::Time& PokeMod::Time::operator=(const Time& rhs) +Time& Time::operator=(const Time& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Time.h b/pokemod/Time.h index 8a1b0198..a5d4bae0 100644 --- a/pokemod/Time.h +++ b/pokemod/Time.h @@ -27,36 +27,33 @@ #include "../general/Exception.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class Time : public Object { - class Pokemod; - - class Time : public Object - { - public: - Time(const Pokemod& par, const unsigned _id); - Time(const Pokemod& par, const Time& t, const unsigned _id); - Time(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - void setStartHour(const unsigned h) throw(BoundsException); - void setStartMinute(const unsigned m) throw(BoundsException); - - QString getName() const; - unsigned getStartHour() const; - unsigned getStartMinute() const; - - Time& operator=(const Time& rhs); - private: - bool validate() const; - - QString name; - unsigned startHour; - unsigned startMinute; - }; -} + public: + Time(const Pokemod& par, const unsigned _id); + Time(const Pokemod& par, const Time& t, const unsigned _id); + Time(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + void setStartHour(const unsigned h) throw(BoundsException); + void setStartMinute(const unsigned m) throw(BoundsException); + + QString getName() const; + unsigned getStartHour() const; + unsigned getStartMinute() const; + + Time& operator=(const Time& rhs); + private: + bool validate() const; + + QString name; + unsigned startHour; + unsigned startMinute; +}; #endif diff --git a/pokemod/Type.cpp b/pokemod/Type.cpp index 9c7137e0..c2c268cd 100644 --- a/pokemod/Type.cpp +++ b/pokemod/Type.cpp @@ -23,26 +23,26 @@ #include "Pokemod.h" #include "Type.h" -PokeMod::Type::Type(const Pokemod& par, const unsigned _id) : +Type::Type(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), stab(1, 1, true) { } -PokeMod::Type::Type(const Pokemod& par, const Type& t, const unsigned _id) : +Type::Type(const Pokemod& par, const Type& t, const unsigned _id) : Object(par, _id) { *this = t; } -PokeMod::Type::Type(const Pokemod& par, const QString& fname, const unsigned _id) : +Type::Type(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeMod::Type::validate() const +bool Type::validate() const { bool valid = true; pokemod.validationMsg(QString("---Type \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -54,7 +54,7 @@ bool PokeMod::Type::validate() const return valid; } -void PokeMod::Type::load(const QString& fname, const unsigned _id) throw(Exception) +void Type::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -69,7 +69,7 @@ void PokeMod::Type::load(const QString& fname, const unsigned _id) throw(Excepti stab.set(i, j, true); } -void PokeMod::Type::save() const throw(Exception) +void Type::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -79,37 +79,37 @@ void PokeMod::Type::save() const throw(Exception) ini.save(QString("%1/type/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeMod::Type::setName(const QString& n) +void Type::setName(const QString& n) { name = n; } -void PokeMod::Type::setStab(const unsigned n, const unsigned d) throw(Exception) +void Type::setStab(const unsigned n, const unsigned d) throw(Exception) { stab.set(n, d); } -void PokeMod::Type::setStabNum(const unsigned n) throw(Exception) +void Type::setStabNum(const unsigned n) throw(Exception) { stab.setNum(n); } -void PokeMod::Type::setStabDenom(const unsigned d) throw(Exception) +void Type::setStabDenom(const unsigned d) throw(Exception) { stab.setDenom(d); } -QString PokeMod::Type::getName() const +QString Type::getName() const { return name; } -Frac PokeMod::Type::getStab() const +Frac Type::getStab() const { return stab; } -PokeMod::Type& PokeMod::Type::operator=(const Type& rhs) +Type& Type::operator=(const Type& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Type.h b/pokemod/Type.h index 51370fd3..1bd4ccb9 100644 --- a/pokemod/Type.h +++ b/pokemod/Type.h @@ -28,35 +28,32 @@ #include "../general/Frac.h" #include "Object.h" -namespace PokeMod +class Pokemod; + +class Type : public Object { - class Pokemod; - - class Type : public Object - { - public: - Type(const Pokemod& par, const unsigned _id); - Type(const Pokemod& par, const Type& t, const unsigned _id); - Type(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); - - void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); - void save() const throw(Exception); - - void setName(const QString& n); - void setStab(const unsigned n, const unsigned d) throw(Exception); - void setStabNum(const unsigned n) throw(Exception); - void setStabDenom(const unsigned d) throw(Exception); - - QString getName() const; - Frac getStab() const; - - Type& operator=(const Type& rhs); - private: - bool validate() const; - - QString name; - Frac stab; - }; -} + public: + Type(const Pokemod& par, const unsigned _id); + Type(const Pokemod& par, const Type& t, const unsigned _id); + Type(const Pokemod& par, const QString& fname, const unsigned _id = UINT_MAX); + + void load(const QString& fname, const unsigned _id = UINT_MAX) throw(Exception); + void save() const throw(Exception); + + void setName(const QString& n); + void setStab(const unsigned n, const unsigned d) throw(Exception); + void setStabNum(const unsigned n) throw(Exception); + void setStabDenom(const unsigned d) throw(Exception); + + QString getName() const; + Frac getStab() const; + + Type& operator=(const Type& rhs); + private: + bool validate() const; + + QString name; + Frac stab; +}; #endif diff --git a/pokemodr/gui/moveeffect.ui b/pokemodr/gui/moveeffect.ui new file mode 100644 index 00000000..1acadaf1 --- /dev/null +++ b/pokemodr/gui/moveeffect.ui @@ -0,0 +1,219 @@ +<ui version="4.0" > + <class>formMoveEffect</class> + <widget class="QWidget" name="formMoveEffect" > + <property name="geometry" > + <rect> + <x>0</x> + <y>0</y> + <width>244</width> + <height>766</height> + </rect> + </property> + <property name="windowTitle" > + <string/> + </property> + <layout class="QVBoxLayout" > + <item> + <widget class="QGroupBox" name="boxButtons" > + <property name="title" > + <string/> + </property> + <layout class="QHBoxLayout" > + <item> + <widget class="KPushButton" name="buttonApply" > + <property name="text" > + <string>&Apply</string> + </property> + <property name="shortcut" > + <string>Ctrl+Return</string> + </property> + </widget> + </item> + <item> + <widget class="KPushButton" name="buttonDiscard" > + <property name="text" > + <string>&Discard</string> + </property> + <property name="shortcut" > + <string>Esc</string> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="boxChance" > + <property name="title" > + <string>Chance</string> + </property> + <layout class="QVBoxLayout" > + <item> + <widget class="KLineEdit" name="varChance" > + <property name="toolTip" > + <string>Chance the effect is applied</string> + </property> + <property name="readOnly" > + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="KIntNumInput" name="varChanceNum" > + <property name="label" > + <string>Numerator</string> + </property> + <property name="minimum" > + <number>0</number> + </property> + </widget> + </item> + <item> + <widget class="KIntNumInput" name="varChanceDenom" > + <property name="label" > + <string>Denominator</string> + </property> + <property name="minimum" > + <number>1</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="boxEffect" > + <property name="title" > + <string>Effect</string> + </property> + <layout class="QVBoxLayout" > + <item> + <widget class="KComboBox" name="varEffect" > + <property name="insertPolicy" > + <enum>QComboBox::NoInsert</enum> + </property> + <property name="sizeAdjustPolicy" > + <enum>QComboBox::AdjustToContents</enum> + </property> + </widget> + </item> + <item> + <widget class="QGroupBox" name="boxVal1" > + <property name="title" > + <string>Value 1</string> + </property> + <layout class="QHBoxLayout" > + <item> + <widget class="KComboBox" name="varVal1" > + <property name="insertPolicy" > + <enum>QComboBox::NoInsert</enum> + </property> + <property name="sizeAdjustPolicy" > + <enum>QComboBox::AdjustToContents</enum> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="boxVal2" > + <property name="title" > + <string>Value 2</string> + </property> + <layout class="QHBoxLayout" > + <item> + <widget class="KComboBox" name="varVal2" > + <property name="insertPolicy" > + <enum>QComboBox::NoInsert</enum> + </property> + <property name="sizeAdjustPolicy" > + <enum>QComboBox::AdjustToContents</enum> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="boxVal3" > + <property name="title" > + <string>Value 3</string> + </property> + <layout class="QHBoxLayout" > + <item> + <widget class="KIntNumInput" name="varVal3" > + <property name="minimum" > + <number>0</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + <item> + <widget class="QGroupBox" name="boxVal4" > + <property name="title" > + <string>Value 4</string> + </property> + <layout class="QVBoxLayout" > + <item> + <widget class="KLineEdit" name="varVal4" > + <property name="readOnly" > + <bool>true</bool> + </property> + </widget> + </item> + <item> + <widget class="KIntNumInput" name="varVal4Num" > + <property name="label" > + <string>Numerator</string> + </property> + <property name="minimum" > + <number>0</number> + </property> + </widget> + </item> + <item> + <widget class="KIntNumInput" name="varVal4Denom" > + <property name="label" > + <string>Denominator</string> + </property> + <property name="minimum" > + <number>1</number> + </property> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + </item> + </layout> + </widget> + <customwidgets> + <customwidget> + <class>KComboBox</class> + <extends>QComboBox</extends> + <header>kcombobox.h</header> + </customwidget> + <customwidget> + <class>KIntNumInput</class> + <extends>QWidget</extends> + <header>knuminput.h</header> + </customwidget> + <customwidget> + <class>KLineEdit</class> + <extends>QLineEdit</extends> + <header>klineedit.h</header> + </customwidget> + <customwidget> + <class>KPushButton</class> + <extends>QPushButton</extends> + <header>kpushbutton.h</header> + </customwidget> + </customwidgets> + <resources/> + <connections/> +</ui> |
