diff options
101 files changed, 4161 insertions, 4202 deletions
@@ -1,4 +1,14 @@ ----------------- +Rev: 33 +Date: 18 January 2008 +User: MathStuf +----------------- +[DEL] Removed PokeGen namespace +[ADD] general/AudioCache.h completed +[DEL] VERSION removed from subdir .pro files +[DEL] audio/ + +----------------- Rev: 32 Date: 18 January 2008 User: MathStuf diff --git a/audio/audio.pro b/audio/audio.pro deleted file mode 100644 index 99f68ee1..00000000 --- a/audio/audio.pro +++ /dev/null @@ -1,9 +0,0 @@ -OBJECTS_DIR = ../../obj/audio -DESTDIR = ../../lib -VERSION = 0.0.1 -TEMPLATE = lib - -CONFIG += qt warn_on dll - -HEADERS += *.h -SOURCES += *.cpp diff --git a/battle/Arena.cpp b/battle/Arena.cpp index da966377..0927a50c 100644 --- a/battle/Arena.cpp +++ b/battle/Arena.cpp @@ -22,7 +22,7 @@ #include "Arena.h" -long PokeGen::Arena::AlphaBeta(AIProfile ai, Arena arena, const unsigned depth, const long alpha, const long beta) +long Arena::AlphaBeta(AIProfile ai, Arena arena, const unsigned depth, const long alpha, const long beta) { long val; if (!depth) diff --git a/battle/Arena.h b/battle/Arena.h index f38804f9..0a3e7bd3 100644 --- a/battle/Arena.h +++ b/battle/Arena.h @@ -35,52 +35,46 @@ #include "pokemod/Pokemon.h" #include "pokemod/Type.h" -namespace PokeGen +class Arena { - namespace Battle - { - class Arena + public: + typedef struct { - public: - typedef struct - { - unsigned action; - union - { - Pokemon pokemon; - unsigned value; - }; - }Action; - - enum - { - A_Fight = 0, - A_Switch = 1, - A_Item = 2, - A_Run = 3, - A_End_Choices = 4, - A_Ability = 4, - A_HeldItem = 5, - A_End_All = 6 - }; - - Arena(Team& p, Team& e); - - bool Play(); - - unsigned CheckWeather() const; - private: - void AskForActions(); - void ParseActions(const Action action1, const Action action2); - - long PokeGen::AlphaBeta(AIProfile ai, Arena arena, const unsigned depth, const long alpha = LONG_MIN, const long beta = LONG_MAX); - - Team player; - Team opponent; - - unsigned weather; + unsigned action; + union + { + Pokemon pokemon; + unsigned value; + }; + }Action; + + enum + { + A_Fight = 0, + A_Switch = 1, + A_Item = 2, + A_Run = 3, + A_End_Choices = 4, + A_Ability = 4, + A_HeldItem = 5, + A_End_All = 6 }; - } -} + + Arena(Team& p, Team& e); + + bool Play(); + + unsigned CheckWeather() const; + private: + void AskForActions(); + void ParseActions(const Action action1, const Action action2); + + long PokeGen::AlphaBeta(AIProfile ai, Arena arena, const unsigned depth, const long alpha = LONG_MIN, const long beta = LONG_MAX); + + Team player; + Team opponent; + + unsigned weather; +}; #endif diff --git a/battle/Bot.h b/battle/Bot.h index 31ff1061..d20333da 100644 --- a/battle/Bot.h +++ b/battle/Bot.h @@ -32,19 +32,16 @@ #include "Team.h" #include "../pokemod/MapTrainer.h" -namespace PokeGen +class Bot : public Team { - class Bot : Team - { - public: - Bot(PokeMod::Pokemod* par, PokeMod::MapTrainer trainer); - - void InformOfAction(Arena::Action action); - Arena::Action RequestAction(Arena arena); - private: - GhostBot simulator; - AIProfile ai; - }; -} + public: + Bot(const PokeMod::Pokemod& par, PokeMod::MapTrainer trainer); + + void InformOfAction(Arena::Action action); + Arena::Action RequestAction(Arena arena); + private: + GhostBot simulator; + AIProfile ai; +}; #endif diff --git a/battle/Ghost.cpp b/battle/Ghost.cpp index 81b45c4c..b994da05 100644 --- a/battle/Ghost.cpp +++ b/battle/Ghost.cpp @@ -22,7 +22,7 @@ #include "Ghost.h" -Ghost(const PokeMod::Pokemod* par, const unsigned s, const unsigned l, const unsigned t) : +Ghost(const PokeMod::Pokemod& par, const unsigned s, const unsigned l, const unsigned t) : Pokemon(par, s, l), teamSize(t), unknownMoves(par->GetMaxMoves()) diff --git a/battle/Ghost.h b/battle/Ghost.h index d88cb3eb..84d0d09e 100644 --- a/battle/Ghost.h +++ b/battle/Ghost.h @@ -31,46 +31,40 @@ #include "Arena.h" #include "Team.h" -namespace PokeGen +class Ghost : public Pokemon { - namespace Battle - { - class Ghost : Pokemon + public: + Ghost(const PokeMod::Pokemod& par, const unsigned s, const unsigned l); + + void FeedAttack(const unsigned actualDamage, const unsigned stat, const unsigned otherLevel, const unsigned power, const bool isAttacker); + void FeedItem(const unsigned i); + void FeedMove(const unsigned m); + void FeedMoveChance(const unsigned m, const unsigned weight); + void FeedMoveCombo(const MoveCombo m); + void FeedAbility(const unsigned a); + + void UpdateHP(); + void SetHP(const Frac p); + private: + struct MoveCombo { public: - Ghost(const PokeMod::Pokemod* par, const unsigned s, const unsigned l); - - void FeedAttack(const unsigned actualDamage, const unsigned stat, const unsigned otherLevel, const unsigned power, const bool isAttacker); - void FeedItem(const unsigned i); - void FeedMove(const unsigned m); - void FeedMoveChance(const unsigned m, const unsigned weight); - void FeedMoveCombo(const MoveCombo m); - void FeedAbility(const unsigned a); - - void UpdateHP(); - void SetHP(const Frac p); - private: - struct MoveCombo + MoveCombo(const QSet<unsigned> p, const unsigned m, const unsigned c) : + prereqs(p), + move(m), + chance(c) { - public: - MoveCombo(const QSet<unsigned> p, const unsigned m, const unsigned c) : - prereqs(p), - move(m), - chance(c) - { - } - QSet<unsigned> prereqs; - unsigned move; - const unsigned chance; - }; - - unsigned minStats[PokeMod::ST_End_GSC]; - unsigned maxStats[PokeMod::ST_End_GSC]; - QMap<unsigned, unsigned> moveChances; - QList<MoveCombo> moveCombos; - unsigned unknownMoves; + } + QSet<unsigned> prereqs; + unsigned move; + const unsigned chance; }; - } -} + + unsigned minStats[PokeMod::ST_End_GSC]; + unsigned maxStats[PokeMod::ST_End_GSC]; + QMap<unsigned, unsigned> moveChances; + QList<MoveCombo> moveCombos; + unsigned unknownMoves; +}; #endif diff --git a/battle/GhostBot.h b/battle/GhostBot.h index 75f882c7..f5c986d8 100644 --- a/battle/GhostBot.h +++ b/battle/GhostBot.h @@ -31,20 +31,17 @@ #include "Ghost.h" #include "Team.h" -namespace PokeGen +class GhostBot : public Team { - class GhostBot : Team - { - public: - Ghost(const PokeMod::Pokemod* par, const QString aiFile, Bot host, const unsigned s, const unsigned l); - - void FeedAttack(const unsigned stat, const unsigned otherLevel, const unsigned power, const bool isAttacker); - void FeedItem(const unsigned i); - void FeedMove(const unsigned m); - void FeedAbility(const unsigned a); - private: - AIProfile ai; - }; -} + public: + Ghost(const PokeMod::Pokemod& par, const QString aiFile, Bot host, const unsigned s, const unsigned l); + + void FeedAttack(const unsigned stat, const unsigned otherLevel, const unsigned power, const bool isAttacker); + void FeedItem(const unsigned i); + void FeedMove(const unsigned m); + void FeedAbility(const unsigned a); + private: + AIProfile ai; +}; #endif diff --git a/battle/Pokemon.h b/battle/Pokemon.h index b4e7fa27..f527b72b 100644 --- a/battle/Pokemon.h +++ b/battle/Pokemon.h @@ -35,68 +35,62 @@ #include "../pokemod/Pokemod.h" #include "../pokemod/Species.h" -namespace PokeGen +class Pokemon { - namespace Battle - { - class Pokemon + public: + Pokemon(const PokeMod::Pokemod& par, Ini ini); + Pokemon(const PokeMod::Pokemod& par, const unsigned s, const unsigned l); + + unsigned GetStat(const unsigned s) const; + unsigned GetLevel() const; + + unsigned GetNumMoves() const; + bool SimulateMove(const unsigned m) const; + bool UseMove(const unsigned m); + bool UnlearnMove(const unsigned m); + + bool SetStatus(const unsigned s); + + bool UseItemOn(const unsigned i); + + unsigned GetNumHeldItems() const; + unsigned GetHeldItem(const unsigned h); + bool GiveItem(const unsigned i); + bool TakeItem(const unsigned i); + bool SimulateTakeItem(const unsigned i) const; + + bool CanFight() const; + + void OutOfBattle(); + protected: + typedef struct { - public: - Pokemon(const PokeMod::Pokemod& par, Ini ini); - Pokemon(const PokeMod::Pokemod& par, const unsigned s, const unsigned l); - - unsigned GetStat(const unsigned s) const; - unsigned GetLevel() const; - - unsigned GetNumMoves() const; - bool SimulateMove(const unsigned m) const; - bool UseMove(const unsigned m); - bool UnlearnMove(const unsigned m); - - bool SetStatus(const unsigned s); - - bool UseItemOn(const unsigned i); - - unsigned GetNumHeldItems() const; - unsigned GetHeldItem(const unsigned h); - bool GiveItem(const unsigned i); - bool TakeItem(const unsigned i); - bool SimulateTakeItem(const unsigned i) const; - - bool CanFight() const; - - void OutOfBattle(); - protected: - typedef struct - { - Frac statMultipliers[PokeMod::ST_End_Battle]; - bool isConfused; - bool isAttracted; - QList<bool> diabled; - unsigned substituteHP; - Frac toxicMultiplier; - }BattleSettings; - - void GrowLevel(); - - unsigned species; - QString name; - QSet<unsigned> moves; - QList<unsigned> heldItems; - QList<Frac> powerPoints; - unsigned dv[PokeMod::ST_End_GSC]; - unsigned statExp[PokeMod::ST_End_GSC]; - unsigned curHP; - unsigned experience; - unsigned nature; - unsigned ability; - unsigned status; - - BattleSettings battleSettings; - - const PokeMod::Pokemod pokemod; - }; - } -} + Frac statMultipliers[PokeMod::ST_End_Battle]; + bool isConfused; + bool isAttracted; + QList<bool> diabled; + unsigned substituteHP; + Frac toxicMultiplier; + }BattleSettings; + + void GrowLevel(); + + unsigned species; + QString name; + QSet<unsigned> moves; + QList<unsigned> heldItems; + QList<Frac> powerPoints; + unsigned dv[PokeMod::ST_End_GSC]; + unsigned statExp[PokeMod::ST_End_GSC]; + unsigned curHP; + unsigned experience; + unsigned nature; + unsigned ability; + unsigned status; + + BattleSettings battleSettings; + + const PokeMod::Pokemod& pokemod; +}; #endif diff --git a/battle/Team.cpp b/battle/Team.cpp index 2045d683..9bdc57f4 100644 --- a/battle/Team.cpp +++ b/battle/Team.cpp @@ -22,19 +22,19 @@ #include "Team.h" -PokeGen::Battle::Team::Team(PokeMod::Pokemod* par) : +Team::Team(const PokeMod::Pokemod& par) : active(0), parent(par) { } -void PokeGen::Battle::Team::AddItem(const unsigned i, const unsigned amt) +void Team::AddItem(const unsigned i, const unsigned amt) { if (amt) items[i] = amt; } -void PokeGen::Battle::Team::UseItem(const unsigned i) +void Team::UseItem(const unsigned i) { if (items.contains(i) && (items[i] != UINT_MAX)) { @@ -44,12 +44,12 @@ void PokeGen::Battle::Team::UseItem(const unsigned i) } } -void PokeGen::Battle::Team::AddPokemon(Pokemon& p) +void Team::AddPokemon(Pokemon& p) { pokemon.append(&p); } -void PokeGen::Battle::Team::SwapPokemon(const unsigned a, const unsigned b) +void Team::SwapPokemon(const unsigned a, const unsigned b) { if ((a < pokemon.size()) && (b < pokemon.size())) { @@ -59,13 +59,13 @@ void PokeGen::Battle::Team::SwapPokemon(const unsigned a, const unsigned b) } } -bool PokeGen::Battle::Team::SetActivePokemon(const unsigned a) +bool Team::SetActivePokemon(const unsigned a) { if ((a < pokemon.size()) && pokemon[a]->CanFight()) active = a; } -unsigned PokeGen::Battle::Team::CanFight() const +unsigned Team::CanFight() const { unsigned alive = 0; for (unsigned i = 0; (i < pokemon.size()) && !alive; ++i) diff --git a/battle/Team.h b/battle/Team.h index a2f8a938..b18b60fa 100644 --- a/battle/Team.h +++ b/battle/Team.h @@ -28,34 +28,28 @@ #include "Arena.h" #include "Pokemon.h" -namespace PokeGen +class Team { - namespace Battle - { - class Team - { - public: - Team(PokeMod::Pokemod* par); - - void AddItem(const unsigned i, const unsigned amt); - void UseItem(const unsigned i); - - void AddPokemon(Pokemon& p); - void SwapPokemon(const unsigned a, const unsigned b); - bool SetActivePokemon(const unsigned a); - - unsigned CanFight() const; - - virtual void InformOfAction(Arena::Action action); - virtual Arena::Action RequestAction(Arena arena); - protected: - QList<Pokemon*> pokemon; - QMap<unsigned, unsigned> items; - unsigned active; - - PokeMod::Pokemod* parent; - }; - } -} + public: + Team(const PokeMod::Pokemod& par); + + void AddItem(const unsigned i, const unsigned amt); + void UseItem(const unsigned i); + + void AddPokemon(Pokemon& p); + void SwapPokemon(const unsigned a, const unsigned b); + bool SetActivePokemon(const unsigned a); + + unsigned CanFight() const; + + virtual void InformOfAction(Arena::Action action); + virtual Arena::Action RequestAction(Arena arena); + protected: + QList<Pokemon*> pokemon; + QMap<unsigned, unsigned> items; + unsigned active; + + const PokeMod::Pokemod& parent; +}; #endif diff --git a/battle/battle.pro b/battle/battle.pro index 7b5a3e51..daa0d9b6 100644 --- a/battle/battle.pro +++ b/battle/battle.pro @@ -1,6 +1,5 @@ OBJECTS_DIR = ../../obj/battle DESTDIR = ../../lib -VERSION = 0.1.0 TEMPLATE = lib LIBS += -L../../lib -lgeneral -lpokemod diff --git a/general/AudioCache.h b/general/AudioCache.h new file mode 100644 index 00000000..4a691ac5 --- /dev/null +++ b/general/AudioCache.h @@ -0,0 +1,117 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: general/AudioCache.h +// Purpose: Cache for sound effects +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Fri Jan 18 15:29:22 2008 +// Copyright: ©2007-2008 Ben Boeckel and Nerdy Productions +// Licence: +// This program is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License along +// with this program. If not, see <http://www.gnu.org/licenses/>. +///////////////////////////////////////////////////////////////////////////// + +#ifndef __AUDIO_CACHE__ +#define __AUDIO_CACHE__ + +#include <QCache> +#include <QMutableVectorIterator> +#include <QVector> +#include <Phonon/MediaObject> +#include "Exception.h" + +class AudioCache +{ + public: + void playSFX(const QString& url, const bool force = false) static throw(OpenException) + { + if (force) + cache.remove(url); + if (!cache.contains(url)) + { + MediaObject sfx; + sfx.setCurrentSource(url); + if (sfx.state() == Phonon::ErrorState) + throw(OpenException("AudioCache", url)); + cache.insert(url, sfx); + } + MediaObject sfx = *(cache.object(url)); + sfx.play(); + curPlay.append(sfx); + curPlay[curPlay.size() - 1].play(); + } + + void playMusic(const QString& url) static + { + if (!started) + start(); + musicUrl = url; + if (music.state() == Phonon::PlayingState) + music.seek(music.totalTime - 1000); + else + { + music.setCurrentSource(url); + music.play(); + } + } + + void clear() static + { + cache.clear(); + } + void prune() static + { + for (QMutableVectorIterator<MediaObject> i(curPlay); i.hasNext(); i.next()) + { + if (i.value().state() == Phonon::StoppedState) + i.remove(); + } + } + + void remove(const QString& url) static + { + cache.remove(url); + } + + void start() static + { + if (!started) + connect(&music, SIGNAL(aboutToFinish()), SLOT(loopMusic())); + } + + float getVolume() static + { + return output.volume; + } + void setVolume(const float v) static + { + output.volume = v; + } + private: + void loopMusic() static + { + music.enqueue(musicUrl); + } + + static QCache<QString, MediaObject> cache; + static QVector<MediaObject*> curPlay; + static MediaObject music; + static QString musicUrl; + static AudiOutput output; + static bool started; +}; + +QCache<QString, MediaObject> AudioCache::sounds(4096); +AudioOutput AudioCache::output(Phonon::MusicCategory); +bool AudioCache::started = false; + +#endif diff --git a/general/Exception.h b/general/Exception.h index 53a7ab4b..5197e88d 100644 --- a/general/Exception.h +++ b/general/Exception.h @@ -23,106 +23,103 @@ #ifndef __EXCEPTIONS__ #define __EXCEPTIONS__ -namespace PokeGen +class Exception { - class Exception - { - public: - Exception(const QString& c, const QString e) : - cls(c), - error(e) - { - } - - QString getMsg() const - { - return QString("%1: %2").arg(cls).arg(error); - } - private: - QString cls; - QString error; - }; - - class UnusedException : public Exception - { - public: - UnusedException(const QString& c, const QString& var) : - Exception(c, QString("setting unused %1").arg(var)) - { - } - }; - - class BoundsException : public Exception - { - public: - BoundsException(const QString& c, const QString& var) : - Exception(c, QString("%1 out-of-bounds").arg(var)) - { - } - }; - - class IndexException : public BoundsException - { - public: - IndexException(const QString& c) : - BoundsException(c, "index") - { - } - }; - - class ReplaceException : public Exception - { - public: - ReplaceException(const QString& c, const QString& f) : - Exception(c, QString("unable to replace %1").arg(f)) - { - } - }; - - class SaveException : public Exception - { - public: - SaveException(const QString& c, const QString& f) : - Exception(c, QString("unable to save %1").arg(f)) - { - } - }; - - class OpenException : public Exception - { - public: - OpenException(const QString& c, const QString& f) : - Exception(c, QString("unable to open %1").arg(f)) - { - } - }; - - class DirException : public Exception - { - public: - DirException(const QString& c, const QString& p) : - Exception(c, QString("unable to create path %1").arg(p)) - { - } - }; - - class InvalidException : public Exception - { - public: - InvalidException(const QString& c, const QString& f) : - Exception(c, QString("%1 is invalid").arg(f)) - { - } - }; - - class RemoveException : public Exception - { - public: - RemoveException(const QString& c, const QString& f) : - Exception(c, QString("unable to remove %1").arg(f)) - { - } - }; -} + public: + Exception(const QString& c, const QString e) : + cls(c), + error(e) + { + } + + QString getMsg() const + { + return QString("%1: %2").arg(cls).arg(error); + } + private: + QString cls; + QString error; +}; + +class UnusedException : public Exception +{ + public: + UnusedException(const QString& c, const QString& var) : + Exception(c, QString("setting unused %1").arg(var)) + { + } +}; + +class BoundsException : public Exception +{ + public: + BoundsException(const QString& c, const QString& var) : + Exception(c, QString("%1 out-of-bounds").arg(var)) + { + } +}; + +class IndexException : public BoundsException +{ + public: + IndexException(const QString& c) : + BoundsException(c, "index") + { + } +}; + +class ReplaceException : public Exception +{ + public: + ReplaceException(const QString& c, const QString& f) : + Exception(c, QString("unable to replace %1").arg(f)) + { + } +}; + +class SaveException : public Exception +{ + public: + SaveException(const QString& c, const QString& f) : + Exception(c, QString("unable to save %1").arg(f)) + { + } +}; + +class OpenException : public Exception +{ + public: + OpenException(const QString& c, const QString& f) : + Exception(c, QString("unable to open %1").arg(f)) + { + } +}; + +class DirException : public Exception +{ + public: + DirException(const QString& c, const QString& p) : + Exception(c, QString("unable to create path %1").arg(p)) + { + } +}; + +class InvalidException : public Exception +{ + public: + InvalidException(const QString& c, const QString& f) : + Exception(c, QString("%1 is invalid").arg(f)) + { + } +}; + +class RemoveException : public Exception +{ + public: + RemoveException(const QString& c, const QString& f) : + Exception(c, QString("unable to remove %1").arg(f)) + { + } +}; #endif diff --git a/general/Flag.cpp b/general/Flag.cpp index 8dc6026e..ab86fa1b 100644 --- a/general/Flag.cpp +++ b/general/Flag.cpp @@ -22,4 +22,4 @@ #include "Flag.h" -const char* PokeGen::Flag::ValueStr[PokeGen::Flag::End] = {"Off", "On", "Ignore"}; +const char* Flag::ValueStr[Flag::End] = {"Off", "On", "Ignore"}; diff --git a/general/Flag.h b/general/Flag.h index 3862ad3b..0aae7fda 100644 --- a/general/Flag.h +++ b/general/Flag.h @@ -27,54 +27,51 @@ #include <QString> #include "Ref.h" -namespace PokeGen +class Flag { - class Flag - { - public: - enum - { - Off, - On, - Ignore, - End - }; - static const char* ValueStr[End]; - - Flag(const unsigned f = 0, const unsigned s = 0) : - flag(f) - { - setStatus(s); - } - - void set(const unsigned f, const unsigned s) - { - setFlag(f); - setStatus(s); - } - void setFlag(const unsigned f) - { - flag = f; - } - void setStatus(const unsigned s) - { - if (End <= s) - throw("Flag: status out-of-bounds"); - status = s; - } + public: + enum + { + Off, + On, + Ignore, + End + }; + static const char* ValueStr[End]; - unsigned getFlag() const - { - return flag; - } - unsigned getStatus() const - { - return status; - } - private: - unsigned flag; - unsigned status; - }; -} + Flag(const unsigned f = 0, const unsigned s = 0) : + flag(f) + { + setStatus(s); + } + + void set(const unsigned f, const unsigned s) + { + setFlag(f); + setStatus(s); + } + void setFlag(const unsigned f) + { + flag = f; + } + void setStatus(const unsigned s) + { + if (End <= s) + throw("Flag: status out-of-bounds"); + status = s; + } + + unsigned getFlag() const + { + return flag; + } + unsigned getStatus() const + { + return status; + } + private: + unsigned flag; + unsigned status; +}; #endif diff --git a/general/Frac.cpp b/general/Frac.cpp index 539205ef..76e7fd0b 100644 --- a/general/Frac.cpp +++ b/general/Frac.cpp @@ -22,7 +22,7 @@ #include "Frac.h" -void PokeGen::Frac::set(const unsigned n, const unsigned d) throw(Exception) +void Frac::set(const unsigned n, const unsigned d) throw(Exception) { if ((type == Improper) || ((n < d) && (type == Proper)) || ((d < n) && (type == Over1))) { @@ -33,23 +33,23 @@ void PokeGen::Frac::set(const unsigned n, const unsigned d) throw(Exception) throw(Exception("Frac", "values conflict with type")); } -void PokeGen::Frac::set(const unsigned n, const unsigned d, const unsigned t) throw(Exception) +void Frac::set(const unsigned n, const unsigned d, const unsigned t) throw(Exception) { setType(t); set(n, d); } -void PokeGen::Frac::setNum(const unsigned n) throw(Exception) +void Frac::setNum(const unsigned n) throw(Exception) { set(n, denom); } -void PokeGen::Frac::setDenom(const unsigned d) throw(Exception) +void Frac::setDenom(const unsigned d) throw(Exception) { set(num, d); } -void PokeGen::Frac::setType(const unsigned t) throw(BoundsException) +void Frac::setType(const unsigned t) throw(BoundsException) { if (t < End) { @@ -60,7 +60,7 @@ void PokeGen::Frac::setType(const unsigned t) throw(BoundsException) throw(BoundsException("Frac", "type")); } -void PokeGen::Frac::reduce() +void Frac::reduce() { int i = num; int j = denom; diff --git a/general/Frac.h b/general/Frac.h index 7be576c6..f5b178b1 100644 --- a/general/Frac.h +++ b/general/Frac.h @@ -27,58 +27,55 @@ #include <QString> #include "Exception.h" -namespace PokeGen +class Frac { - class Frac - { - public: - enum - { - Proper = 0, - Improper = 1, - Over1 = 2, - End = 3 - }; - - Frac(const unsigned t = Proper) - { - setType(t); - } - Frac(const unsigned n, const unsigned d, const unsigned t = Proper) - { - set(n, d, t); - } - - void set(const unsigned n, const unsigned d) throw(Exception); - void set(const unsigned n, const unsigned d, const unsigned t) throw(Exception); - void setNum(const unsigned n) throw(Exception); - void setDenom(const unsigned d) throw(Exception); - void setType(const unsigned t) throw(BoundsException); - - unsigned getNum() const - { - return num; - } - unsigned getDenom() const - { - return denom; - } - unsigned getType() const - { - return type; - } - - void reduce(); - - operator float() const - { - return (num / denom); - } - private: - unsigned num; - unsigned denom; - unsigned type; - }; -} + public: + enum + { + Proper = 0, + Improper = 1, + Over1 = 2, + End = 3 + }; + + Frac(const unsigned t = Proper) + { + setType(t); + } + Frac(const unsigned n, const unsigned d, const unsigned t = Proper) + { + set(n, d, t); + } + + void set(const unsigned n, const unsigned d) throw(Exception); + void set(const unsigned n, const unsigned d, const unsigned t) throw(Exception); + void setNum(const unsigned n) throw(Exception); + void setDenom(const unsigned d) throw(Exception); + void setType(const unsigned t) throw(BoundsException); + + unsigned getNum() const + { + return num; + } + unsigned getDenom() const + { + return denom; + } + unsigned getType() const + { + return type; + } + + void reduce(); + + operator float() const + { + return (num / denom); + } + private: + unsigned num; + unsigned denom; + unsigned type; +}; #endif diff --git a/general/FracMatrix.h b/general/FracMatrix.h index 3becd3dc..8d884910 100644 --- a/general/FracMatrix.h +++ b/general/FracMatrix.h @@ -26,64 +26,61 @@ #include "Frac.h" #include "Matrix.h" -namespace PokeGen +class FracMatrix : public Matrix<Frac> { - class FracMatrix : public Matrix<Frac> - { - public: - FracMatrix() : - Matrix<Frac>() + public: + FracMatrix() : + Matrix<Frac>() + { + } + FracMatrix(const unsigned w, const unsigned h, const Frac &d = Frac()) : + Matrix<Frac>(w, h, d) + { + } + FracMatrix(const QString& fname) + { + load(fname); + } + + void load(const QString& fname) + { + Ini ini(fname); + ini.getValue("width", Matrix<Frac>::width, 0); + ini.getValue("height", Matrix<Frac>::height, 0); + if (!(Matrix<Frac>::width && Matrix<Frac>::height)) + return; + Matrix<Frac>::matrix.resize(Matrix<Frac>::width); + Matrix<Frac>::matrix.fill(QVector<Frac>(Matrix<Frac>::height, Frac(1, 1))); + for (unsigned i = 0; i < Matrix<Frac>::width; ++i) { - } - FracMatrix(const unsigned w, const unsigned h, const Frac &d = Frac()) : - Matrix<Frac>(w, h, d) - { - } - FracMatrix(const QString& fname) - { - load(fname); - } - - void load(const QString& fname) - { - Ini ini(fname); - ini.getValue("width", Matrix<Frac>::width, 0); - ini.getValue("height", Matrix<Frac>::height, 0); - if (!(Matrix<Frac>::width && Matrix<Frac>::height)) - return; - Matrix<Frac>::matrix.resize(Matrix<Frac>::width); - Matrix<Frac>::matrix.fill(QVector<Frac>(Matrix<Frac>::height, Frac(1, 1))); - for (unsigned i = 0; i < Matrix<Frac>::width; ++i) + for (unsigned j = 0; j < Matrix<Frac>::height; ++j) { - for (unsigned j = 0; j < Matrix<Frac>::height; ++j) - { - unsigned k; - unsigned l; - bool m; - ini.getValue(QString("Element-%1-%2-n").arg(i).arg(j), k, 0); - ini.getValue(QString("Element-%1-%2-d").arg(i).arg(j), l, 0); - ini.getValue(QString("Element-%1-%2-t").arg(i).arg(j), m, 0); - Matrix<Frac>::matrix[i][j].set(k, l, m); - } + unsigned k; + unsigned l; + bool m; + ini.getValue(QString("Element-%1-%2-n").arg(i).arg(j), k, 0); + ini.getValue(QString("Element-%1-%2-d").arg(i).arg(j), l, 0); + ini.getValue(QString("Element-%1-%2-t").arg(i).arg(j), m, 0); + Matrix<Frac>::matrix[i][j].set(k, l, m); } } - void save(const QString& fname) const + } + void save(const QString& fname) const + { + Ini ini; + ini.addField("height", Matrix<Frac>::height); + ini.addField("width", Matrix<Frac>::width); + for (unsigned i = 0; i < Matrix<Frac>::width; ++i) { - Ini ini; - ini.addField("height", Matrix<Frac>::height); - ini.addField("width", Matrix<Frac>::width); - for (unsigned i = 0; i < Matrix<Frac>::width; ++i) + for (unsigned j = 0; j < Matrix<Frac>::height; ++j) { - for (unsigned j = 0; j < Matrix<Frac>::height; ++j) - { - ini.addField(QString("Element-%1-%2-t").arg(i).arg(j), Matrix<Frac>::matrix[i][j].getType()); - ini.addField(QString("Element-%1-%2-n").arg(i).arg(j), Matrix<Frac>::matrix[i][j].getNum()); - ini.addField(QString("Element-%1-%2-d").arg(i).arg(j), Matrix<Frac>::matrix[i][j].getDenom()); - } + ini.addField(QString("Element-%1-%2-t").arg(i).arg(j), Matrix<Frac>::matrix[i][j].getType()); + ini.addField(QString("Element-%1-%2-n").arg(i).arg(j), Matrix<Frac>::matrix[i][j].getNum()); + ini.addField(QString("Element-%1-%2-d").arg(i).arg(j), Matrix<Frac>::matrix[i][j].getDenom()); } - ini.save(fname); } - }; -} + ini.save(fname); + } +}; #endif diff --git a/general/Hat.h b/general/Hat.h index a6e892e0..54169e1d 100644 --- a/general/Hat.h +++ b/general/Hat.h @@ -27,59 +27,56 @@ #include <cstdlib> #include <ctime> -namespace PokeGen +template<class T> class Hat { - template<class T> class Hat - { - public: - Hat() : - totalWeight(1) + public: + Hat() : + totalWeight(1) + { + std::srand(std::time(NULL)) + } + + T pick() const + { + int choice = std::rand() % totalWeight; + for (typename QMap<T, unsigned>::Iterator i = objects.begin(); i != objects.end(); ++i) { - std::srand(std::time(NULL)) + choice -= i.value(); + if (choice < 0) + return i.key(); } - - T pick() const - { - int choice = std::rand() % totalWeight; - for (typename QMap<T, unsigned>::Iterator i = objects.begin(); i != objects.end(); ++i) - { - choice -= i.value(); - if (choice < 0) - return i.key(); - } - } - T remove() - { - T chosen = pick(); - if (!(--objects[chosen])) - objects.erase(chosen); - --totalWeight; - return chosen; - } - - void setCount(const T& key, const unsigned wt) - { - if (objects.find(key) != objects.end()) - totalWeight -= objects[key]; - objects[key] = wt; - totalWeight += wt; - } - - unsigned getCount(const T& key) const - { - if (objects.find(key) != objects.end()) - return objects[key]; - throw("Hat: key does not exist"); - } - - unsigned operator[](const T& key) const - { - return getCount(key); - } - private: - QMap<T, unsigned> objects; - unsigned totalCount; - }; -} + } + T remove() + { + T chosen = pick(); + if (!(--objects[chosen])) + objects.erase(chosen); + --totalWeight; + return chosen; + } + + void setCount(const T& key, const unsigned wt) + { + if (objects.find(key) != objects.end()) + totalWeight -= objects[key]; + objects[key] = wt; + totalWeight += wt; + } + + unsigned getCount(const T& key) const + { + if (objects.find(key) != objects.end()) + return objects[key]; + throw("Hat: key does not exist"); + } + + unsigned operator[](const T& key) const + { + return getCount(key); + } + private: + QMap<T, unsigned> objects; + unsigned totalCount; +}; #endif diff --git a/general/ImageCache.cpp b/general/ImageCache.cpp index c02342ae..e5585651 100644 --- a/general/ImageCache.cpp +++ b/general/ImageCache.cpp @@ -22,7 +22,7 @@ #include "ImageCache.h" -QPixmap PokeGen::ImageCache::open(const QString& fname, const bool force) throw(OpenException) +QPixmap ImageCache::open(const QString& fname, const bool force) throw(OpenException) { QPixmap pm; if (force) diff --git a/general/ImageCache.h b/general/ImageCache.h index 097d099c..1b06576f 100644 --- a/general/ImageCache.h +++ b/general/ImageCache.h @@ -28,13 +28,10 @@ #include <QString> #include "Exception.h" -namespace PokeGen +class ImageCache { - class ImageCache - { - public: - static QPixmap open(const QString& fname, const bool force = false) throw(OpenException); - }; -} + public: + static QPixmap open(const QString& fname, const bool force = false) throw(OpenException); +}; #endif diff --git a/general/Ini.cpp b/general/Ini.cpp index df2b74a0..b829b115 100644 --- a/general/Ini.cpp +++ b/general/Ini.cpp @@ -22,12 +22,12 @@ #include "Ini.h" -PokeGen::Ini::Ini(const QString& fname) +Ini::Ini(const QString& fname) { load(fname); } -void PokeGen::Ini::load(const QString& fname) throw(Exception) +void Ini::load(const QString& fname) throw(Exception) { QFile fin(fname); if (!fin.exists()) @@ -36,7 +36,7 @@ void PokeGen::Ini::load(const QString& fname) throw(Exception) fin.close(); } -void PokeGen::Ini::load(QFile& fin) throw(InvalidException) +void Ini::load(QFile& fin) throw(InvalidException) { QTextStream file(&fin); QString line = file.readLine(); @@ -58,7 +58,7 @@ void PokeGen::Ini::load(QFile& fin) throw(InvalidException) } } -void PokeGen::Ini::save(const QString& fname) const throw(Exception) +void Ini::save(const QString& fname) const throw(Exception) { QStringList path = fname.split(QDir::separator(), QString::SkipEmptyParts); path.removeLast(); @@ -71,7 +71,7 @@ void PokeGen::Ini::save(const QString& fname) const throw(Exception) fout.close(); } -void PokeGen::Ini::save(QFile& file) const +void Ini::save(QFile& file) const { QTextStream fout(&file); for (QMapIterator<QString, QString> i(fields); i.hasNext(); i.next()) @@ -79,42 +79,42 @@ void PokeGen::Ini::save(QFile& file) const fout << '\n'; } -void PokeGen::Ini::addField(const QString& n, const bool v) +void Ini::addField(const QString& n, const bool v) { fields[n] = v ? "true" : "false"; } -void PokeGen::Ini::addField(const QString& n, const unsigned char v) +void Ini::addField(const QString& n, const unsigned char v) { fields[n] = QString("%1").arg(v); } -void PokeGen::Ini::addField(const QString& n, const int v) +void Ini::addField(const QString& n, const int v) { fields[n] = QString("%1").arg(v); } -void PokeGen::Ini::addField(const QString& n, const unsigned v) +void Ini::addField(const QString& n, const unsigned v) { fields[n] = QString("%1").arg(v); } -void PokeGen::Ini::addField(const QString& n, const float v) +void Ini::addField(const QString& n, const float v) { fields[n] = QString("%1").arg(v); } -void PokeGen::Ini::addField(const QString& n, const double v) +void Ini::addField(const QString& n, const double v) { fields[n] = QString("%1").arg(v); } -void PokeGen::Ini::addField(const QString& n, const QString& v) +void Ini::addField(const QString& n, const QString& v) { fields[n] = v; } -void PokeGen::Ini::getValue(const QString& field, bool& val, const bool def) +void Ini::getValue(const QString& field, bool& val, const bool def) { if (!fields.contains(field)) { @@ -129,7 +129,7 @@ void PokeGen::Ini::getValue(const QString& field, bool& val, const bool def) val = def; } -void PokeGen::Ini::getValue(const QString& field, unsigned char& val, const unsigned char def) +void Ini::getValue(const QString& field, unsigned char& val, const unsigned char def) { if (!fields.contains(field)) { @@ -145,7 +145,7 @@ void PokeGen::Ini::getValue(const QString& field, unsigned char& val, const unsi val = def; } -void PokeGen::Ini::getValue(const QString& field, int& val, const int def) +void Ini::getValue(const QString& field, int& val, const int def) { if (!fields.contains(field)) { @@ -158,7 +158,7 @@ void PokeGen::Ini::getValue(const QString& field, int& val, const int def) val = def; } -void PokeGen::Ini::getValue(const QString& field, unsigned& val, const unsigned def) +void Ini::getValue(const QString& field, unsigned& val, const unsigned def) { if (!fields.contains(field)) { @@ -171,7 +171,7 @@ void PokeGen::Ini::getValue(const QString& field, unsigned& val, const unsigned val = def; } -void PokeGen::Ini::getValue(const QString& field, float& val, const float def) +void Ini::getValue(const QString& field, float& val, const float def) { if (!fields.contains(field)) { @@ -184,7 +184,7 @@ void PokeGen::Ini::getValue(const QString& field, float& val, const float def) val = def; } -void PokeGen::Ini::getValue(const QString& field, double& val, const double def) +void Ini::getValue(const QString& field, double& val, const double def) { if (!fields.contains(field)) { @@ -197,7 +197,7 @@ void PokeGen::Ini::getValue(const QString& field, double& val, const double def) val = def; } -void PokeGen::Ini::getValue(const QString& field, QString& val, const QString& def) +void Ini::getValue(const QString& field, QString& val, const QString& def) { if (!fields.contains(field)) { diff --git a/general/Ini.h b/general/Ini.h index 6cb441c7..c56060a3 100644 --- a/general/Ini.h +++ b/general/Ini.h @@ -31,45 +31,42 @@ #include <QTextStream> #include "Exception.h" -namespace PokeGen +class Ini { - class Ini - { - public: - Ini(); - Ini(const QString& fname); - - void load(const QString& fname) throw(Exception); - void save(const QString& fname) const throw(Exception); - - void addField(const QString& n, const bool v); - void addField(const QString& n, const unsigned char v); - void addField(const QString& n, const int v); - void addField(const QString& n, const unsigned v); - void addField(const QString& n, const float v); - void addField(const QString& n, const double v); - void addField(const QString& n, const QString& v); - - QString getName() const; - void getValue(const QString& field, bool& val, const bool def = true); - void getValue(const QString& field, unsigned char& val, const unsigned char def = UCHAR_MAX); - void getValue(const QString& field, int& val, const int def = INT_MAX); - void getValue(const QString& field, unsigned& val, const unsigned def = UINT_MAX); - void getValue(const QString& field, float& val, const float def = 0); - void getValue(const QString& field, double& val, const double def = 0); - void getValue(const QString& field, QString& val, const QString& def = ""); - protected: - enum LinePos - { - Field = 0, - Value = 1 - }; + public: + Ini(); + Ini(const QString& fname); - void load(QFile& fin) throw(InvalidException); - void save(QFile& fout) const; - - QMap<QString, QString> fields; - }; -} + void load(const QString& fname) throw(Exception); + void save(const QString& fname) const throw(Exception); + + void addField(const QString& n, const bool v); + void addField(const QString& n, const unsigned char v); + void addField(const QString& n, const int v); + void addField(const QString& n, const unsigned v); + void addField(const QString& n, const float v); + void addField(const QString& n, const double v); + void addField(const QString& n, const QString& v); + + QString getName() const; + void getValue(const QString& field, bool& val, const bool def = true); + void getValue(const QString& field, unsigned char& val, const unsigned char def = UCHAR_MAX); + void getValue(const QString& field, int& val, const int def = INT_MAX); + void getValue(const QString& field, unsigned& val, const unsigned def = UINT_MAX); + void getValue(const QString& field, float& val, const float def = 0); + void getValue(const QString& field, double& val, const double def = 0); + void getValue(const QString& field, QString& val, const QString& def = ""); + protected: + enum LinePos + { + Field = 0, + Value = 1 + }; + + void load(QFile& fin) throw(InvalidException); + void save(QFile& fout) const; + + QMap<QString, QString> fields; +}; #endif diff --git a/general/Matrix.h b/general/Matrix.h index f4fd638e..9e89bae1 100644 --- a/general/Matrix.h +++ b/general/Matrix.h @@ -29,205 +29,202 @@ #include <QVectorIterator> #include "Ini.h" -namespace PokeGen +template<class T> class Matrix { - template<class T> class Matrix - { - public: - Matrix() : - width(0), - height(0) - { - } - Matrix(const unsigned w, const unsigned h, const T& d = T()) : - width(w), - height(h), - matrix(h, QVector<T>(w, d)) - { - } - Matrix(const Matrix<T>& rhs) : - width(rhs.getWidth()), - height(rhs.getHeight()), - matrix(height, QVector<T>(width, T())) - { - for (unsigned i = 0; i < height; ++i) - { - for (unsigned j = 0; j < width; ++j) - matrix[i][j] = rhs(i, j); - } - } - - void load(const QString& fname) - { - Ini ini(fname); - ini.getValue("width", width, 0); - ini.getValue("height", height, 0); - if (!(width && height)) - return; - matrix.resize(width, QVector<T>(height, 0)); - for (unsigned i = 0; i < width; ++i) + public: + Matrix() : + width(0), + height(0) + { + } + Matrix(const unsigned w, const unsigned h, const T& d = T()) : + width(w), + height(h), + matrix(h, QVector<T>(w, d)) + { + } + Matrix(const Matrix<T>& rhs) : + width(rhs.getWidth()), + height(rhs.getHeight()), + matrix(height, QVector<T>(width, T())) + { + for (unsigned i = 0; i < height; ++i) + { + for (unsigned j = 0; j < width; ++j) + matrix[i][j] = rhs(i, j); + } + } + + void load(const QString& fname) + { + Ini ini(fname); + ini.getValue("width", width, 0); + ini.getValue("height", height, 0); + if (!(width && height)) + return; + matrix.resize(width, QVector<T>(height, 0)); + for (unsigned i = 0; i < width; ++i) + { + for (unsigned j = 0; j < height; ++j) { - for (unsigned j = 0; j < height; ++j) - { - int k; - ini.getValue(QString("Element-%1-%2").arg(i).arg(j), k, 0); - matrix[i][j] = k; - } + int k; + ini.getValue(QString("Element-%1-%2").arg(i).arg(j), k, 0); + matrix[i][j] = k; } } - void save(const QString& fname, const QString& val) const - { - Ini ini; - ini.addField("height", height); - ini.addField("width", width); - for (int i = 0; i < width; ++i) - { - for (unsigned j = 0; j < height; ++j) - ini.addField(QString("Element-%1-%2").arg(i).arg(j), matrix[i][j]); - } - ini.save(fname); - } - - void addRow(const T& d = T()) - { - matrix.append(QVector<T>(width, d)); - ++height; - } - void addCol(const T& d = T()) - { - for (QMutableVectorIterator< QVector<T> > i(matrix); i.hasNext(); ) - i.next().append(d); - ++width; - } - void insertRow(const unsigned pos, const T& d = T()) - { - if (height < pos) - throw("Matrix: dimension out-of-bounds"); - matrix.insert(pos, QVector<T>(width, d)); - ++height; - } - void insertCol(const unsigned pos, const T& d = T()) - { - if (width < pos) - throw("Matrix: dimension out-of-bounds"); - for (QMutableVectorIterator< QVector<T> > i(matrix); i.hasNext(); ) - i.next().insert(pos, d); - ++width; - } - void deleteRow(const unsigned pos) - { - if (height <= pos) - throw("Matrix: dimension out-of-bounds"); - matrix.remove(pos); - --height; - } - void deleteCol(const unsigned pos) - { - if (width <= pos) - throw("Matrix: dimension out-of-bounds"); - for (QMutableVectorIterator< QVector<T> > i(matrix); i.hasNext(); ) - i.next().remove(pos); - --width; - } - void clear() - { - matrix.clear(); - } - - void set(const unsigned row, const unsigned col, const T& s) - { - if ((height <= row) || (width <= col)) - throw("Matrix: dimension out-of-bounds"); - matrix(row, col) = s; - return true; - } - void resize(const unsigned h, const unsigned w, const T& d = T()) - { - clear(); - width = w; - height = h; - matrix = QVector< QVector<T> >(h, QVector<T>(w, d)); - } - - const T& at(const unsigned row, const unsigned col) const - { - if ((height <= row) || (width <= col)) - throw("Matrix: dimension out-of-bounds"); - return matrix.at(row).at(col); - } - const QVector<T> getRow(const unsigned row) const - { - if (height <= row) - throw("Matrix: dimension out-of-bounds"); - return matrix.at(row); - } - const QVector<T> getCol(const unsigned col) const - { - if (width <= col) - throw("Matrix: dimension out-of-bounds"); - QVector<T> c; - for (QVectorIterator< QVector<T> > i(matrix); i.hasNext(); ) - c.append(i.next().at(col)); - return c; - } - unsigned getHeight() const - { - return height; - } - unsigned getWidth() const - { - return width; - } - - T& operator()(const unsigned row, const unsigned col) - { - if ((height <= row) || (width <= col)) - throw("Matrix: dimension out-of-bounds"); - return (matrix[row])[col]; - } - const T& operator()(const unsigned row, const unsigned col) const - { - return at(row, col); - } - Matrix<T> operator=(const Matrix<T>& rhs) - { - if (this == &rhs) - return *this; - height = rhs.getHeight(); - width = rhs.getWidth(); - resize(height, width); - for (unsigned i = 0; i < height; ++i) - { - for (unsigned j = 0; j < width; ++j) - matrix[i][j] = rhs(i, j); - } + } + void save(const QString& fname, const QString& val) const + { + Ini ini; + ini.addField("height", height); + ini.addField("width", width); + for (int i = 0; i < width; ++i) + { + for (unsigned j = 0; j < height; ++j) + ini.addField(QString("Element-%1-%2").arg(i).arg(j), matrix[i][j]); + } + ini.save(fname); + } + + void addRow(const T& d = T()) + { + matrix.append(QVector<T>(width, d)); + ++height; + } + void addCol(const T& d = T()) + { + for (QMutableVectorIterator< QVector<T> > i(matrix); i.hasNext(); ) + i.next().append(d); + ++width; + } + void insertRow(const unsigned pos, const T& d = T()) + { + if (height < pos) + throw("Matrix: dimension out-of-bounds"); + matrix.insert(pos, QVector<T>(width, d)); + ++height; + } + void insertCol(const unsigned pos, const T& d = T()) + { + if (width < pos) + throw("Matrix: dimension out-of-bounds"); + for (QMutableVectorIterator< QVector<T> > i(matrix); i.hasNext(); ) + i.next().insert(pos, d); + ++width; + } + void deleteRow(const unsigned pos) + { + if (height <= pos) + throw("Matrix: dimension out-of-bounds"); + matrix.remove(pos); + --height; + } + void deleteCol(const unsigned pos) + { + if (width <= pos) + throw("Matrix: dimension out-of-bounds"); + for (QMutableVectorIterator< QVector<T> > i(matrix); i.hasNext(); ) + i.next().remove(pos); + --width; + } + void clear() + { + matrix.clear(); + } + + void set(const unsigned row, const unsigned col, const T& s) + { + if ((height <= row) || (width <= col)) + throw("Matrix: dimension out-of-bounds"); + matrix(row, col) = s; + return true; + } + void resize(const unsigned h, const unsigned w, const T& d = T()) + { + clear(); + width = w; + height = h; + matrix = QVector< QVector<T> >(h, QVector<T>(w, d)); + } + + const T& at(const unsigned row, const unsigned col) const + { + if ((height <= row) || (width <= col)) + throw("Matrix: dimension out-of-bounds"); + return matrix.at(row).at(col); + } + const QVector<T> getRow(const unsigned row) const + { + if (height <= row) + throw("Matrix: dimension out-of-bounds"); + return matrix.at(row); + } + const QVector<T> getCol(const unsigned col) const + { + if (width <= col) + throw("Matrix: dimension out-of-bounds"); + QVector<T> c; + for (QVectorIterator< QVector<T> > i(matrix); i.hasNext(); ) + c.append(i.next().at(col)); + return c; + } + unsigned getHeight() const + { + return height; + } + unsigned getWidth() const + { + return width; + } + + T& operator()(const unsigned row, const unsigned col) + { + if ((height <= row) || (width <= col)) + throw("Matrix: dimension out-of-bounds"); + return (matrix[row])[col]; + } + const T& operator()(const unsigned row, const unsigned col) const + { + return at(row, col); + } + Matrix<T> operator=(const Matrix<T>& rhs) + { + if (this == &rhs) return *this; - } - bool operator==(const Matrix<T>& rhs) + height = rhs.getHeight(); + width = rhs.getWidth(); + resize(height, width); + for (unsigned i = 0; i < height; ++i) + { + for (unsigned j = 0; j < width; ++j) + matrix[i][j] = rhs(i, j); + } + return *this; + } + bool operator==(const Matrix<T>& rhs) + { + if (this == &rhs) + return true; + if ((height != rhs.getHeight()) || (width == rhs.getWidth())) + return false; + for (unsigned i = 0; i < height; ++i) { - if (this == &rhs) - return true; - if ((height != rhs.getHeight()) || (width == rhs.getWidth())) - return false; - for (unsigned i = 0; i < height; ++i) + for (unsigned j = 0; j < width; ++j) { - for (unsigned j = 0; j < width; ++j) - { - if (matrix[i][j] != rhs(i, j)) - return false; - } + if (matrix[i][j] != rhs(i, j)) + return false; } - return true; - } - bool operator!=(const Matrix<T>& rhs) - { - return !(*this == rhs); } - protected: - unsigned width; - unsigned height; - QVector< QVector<T> > matrix; - }; -} + return true; + } + bool operator!=(const Matrix<T>& rhs) + { + return !(*this == rhs); + } + protected: + unsigned width; + unsigned height; + QVector< QVector<T> > matrix; +}; #endif diff --git a/general/Point.h b/general/Point.h index 9143b491..2f0d75c2 100644 --- a/general/Point.h +++ b/general/Point.h @@ -25,43 +25,40 @@ #include <QFile> -namespace PokeGen +class Point { - class Point - { - public: - Point(const unsigned _x = 0, const unsigned _y = 0) : - x(_x), - y(_y) - { - } - - void set(const unsigned _x, const unsigned _y) - { - x = _x; - y = _y; - } - void setX(const unsigned _x) - { - x = _x; - } - void setY(const unsigned _y) - { - y = _y; - } - - unsigned getX() const - { - return x; - } - unsigned getY() const - { - return y; - } - private: - unsigned x; - unsigned y; - }; -} + public: + Point(const unsigned _x = 0, const unsigned _y = 0) : + x(_x), + y(_y) + { + } + + void set(const unsigned _x, const unsigned _y) + { + x = _x; + y = _y; + } + void setX(const unsigned _x) + { + x = _x; + } + void setY(const unsigned _y) + { + y = _y; + } + + unsigned getX() const + { + return x; + } + unsigned getY() const + { + return y; + } + private: + unsigned x; + unsigned y; +}; #endif diff --git a/general/Ref.cpp b/general/Ref.cpp index e8ca482b..cad1b624 100644 --- a/general/Ref.cpp +++ b/general/Ref.cpp @@ -22,7 +22,7 @@ #include "Ref.h" -unsigned PokeGen::findIn(const unsigned end, const QString& str, const char* array[]) +unsigned findIn(const unsigned end, const QString& str, const char* array[]) { unsigned i = 0; for (; i < end; ++i) @@ -33,15 +33,15 @@ unsigned PokeGen::findIn(const unsigned end, const QString& str, const char* arr return i; } -const char* PokeGen::StatRBYStr[PokeGen::ST_End_Battle] = {"HP", "Attack", "Defense", "Speed", "Special", "Special", "Accuracy", "Evasion"}; -const char* PokeGen::StatGSCStr[PokeGen::ST_End_Battle] = {"HP", "Attack", "Defense", "Speed", "Special Attack", "Special Defense", "Accuracy", "Evasion"}; +const char* StatRBYStr[ST_End_Battle] = {"HP", "Attack", "Defense", "Speed", "Special", "Special", "Accuracy", "Evasion"}; +const char* StatGSCStr[ST_End_Battle] = {"HP", "Attack", "Defense", "Speed", "Special Attack", "Special Defense", "Accuracy", "Evasion"}; -const char* PokeGen::BattleMemberStr[PokeGen::BM_End] = {"Player", "Enemy"}; +const char* BattleMemberStr[BM_End] = {"Player", "Enemy"}; -const char* PokeGen::WeatherStr[PokeGen::W_End_All] = {"Ice", "Rain", "Sun", "Sand", "All"}; +const char* WeatherStr[W_End_All] = {"Ice", "Rain", "Sun", "Sand", "All"}; -const char* PokeGen::DirectionStr[PokeGen::D_End_None] = {"Up", "Down", "Left", "Right", "None"}; +const char* DirectionStr[D_End_None] = {"Up", "Down", "Left", "Right", "None"}; -const char* PokeGen::RelativeStr[PokeGen::REL_End] = {"Less", "Less or Equal", "Equal", "Greater or Equal", "Greater", "Not Equal"}; +const char* RelativeStr[REL_End] = {"Less", "Less or Equal", "Equal", "Greater or Equal", "Greater", "Not Equal"}; -const char* PokeGen::StatusStr[PokeGen::STS_End] = {"Freeze", "Paralyze", "Sleep", "Poison", "Toxic Poison", "Burn", "Any"}; +const char* StatusStr[STS_End] = {"Freeze", "Paralyze", "Sleep", "Poison", "Toxic Poison", "Burn", "Any"}; diff --git a/general/Ref.h b/general/Ref.h index 12508aed..89875f4f 100644 --- a/general/Ref.h +++ b/general/Ref.h @@ -25,84 +25,81 @@ #include <QString> -namespace PokeGen +unsigned findIn(const unsigned end, const QString& str, const char* array[]); + +enum EnumStat +{ + ST_HP = 0, + ST_Attack = 1, + ST_Defense = 2, + ST_Speed = 3, + ST_Special = 4, + ST_End_RBY = 5, + ST_SpecialAttack = 4, + ST_SpecialDefense = 5, + ST_End_GSC = 6, + ST_Accuracy = 6, + ST_Evasion = 7, + ST_End_Battle = 8, +}; +extern const char* StatRBYStr[ST_End_Battle]; +extern const char* StatGSCStr[ST_End_Battle]; + +enum EnumBattleMember +{ + BM_Player = 0, + BM_Enemy = 1, + BM_End = 2 +}; +extern const char* BattleMemberStr[BM_End]; + +enum EnumWeather +{ + W_Ice = 0, + W_Rain = 1, + W_Sun = 2, + W_Sand = 3, + W_End_Real = 4, + W_All = 4, + W_End_All = 5 +}; +extern const char* WeatherStr[W_End_All]; + +enum EnumDirection +{ + D_Up = 0, + D_Down = 1, + D_Left = 2, + D_Right = 3, + D_End = 4, + D_None = 4, + D_End_None = 5 +}; +extern const char* DirectionStr[D_End_None]; + +enum EnumRelative +{ + REL_Less = 0, + REL_LessOrEqual = 1, + REL_Equal = 2, + REL_GreaterOrEqual = 3, + REL_Greater = 4, + REL_NotEqual = 5, + REL_End = 6 +}; +extern const char* RelativeStr[REL_End]; + +enum EnumStatus { - unsigned findIn(const unsigned end, const QString& str, const char* array[]); - - enum EnumStat - { - ST_HP = 0, - ST_Attack = 1, - ST_Defense = 2, - ST_Speed = 3, - ST_Special = 4, - ST_End_RBY = 5, - ST_SpecialAttack = 4, - ST_SpecialDefense = 5, - ST_End_GSC = 6, - ST_Accuracy = 6, - ST_Evasion = 7, - ST_End_Battle = 8, - }; - extern const char* StatRBYStr[ST_End_Battle]; - extern const char* StatGSCStr[ST_End_Battle]; - - enum EnumBattleMember - { - BM_Player = 0, - BM_Enemy = 1, - BM_End = 2 - }; - extern const char* BattleMemberStr[BM_End]; - - enum EnumWeather - { - W_Ice = 0, - W_Rain = 1, - W_Sun = 2, - W_Sand = 3, - W_End_Real = 4, - W_All = 4, - W_End_All = 5 - }; - extern const char* WeatherStr[W_End_All]; - - enum EnumDirection - { - D_Up = 0, - D_Down = 1, - D_Left = 2, - D_Right = 3, - D_End = 4, - D_None = 4, - D_End_None = 5 - }; - extern const char* DirectionStr[D_End_None]; - - enum EnumRelative - { - REL_Less = 0, - REL_LessOrEqual = 1, - REL_Equal = 2, - REL_GreaterOrEqual = 3, - REL_Greater = 4, - REL_NotEqual = 5, - REL_End = 6 - }; - extern const char* RelativeStr[REL_End]; - - enum EnumStatus - { - STS_Freeze = 0, - STS_Paralyze = 1, - STS_Sleep = 2, - STS_Poison = 3, - STS_ToxicPoison = 4, - STS_Burn = 5, - STS_Any = 6, - STS_End = 7 - }; - extern const char* StatusStr[STS_End]; -} + STS_Freeze = 0, + STS_Paralyze = 1, + STS_Sleep = 2, + STS_Poison = 3, + STS_ToxicPoison = 4, + STS_Burn = 5, + STS_Any = 6, + STS_End = 7 +}; +extern const char* StatusStr[STS_End]; #endif diff --git a/general/general.pro b/general/general.pro index 3fe8b64a..e174ccec 100644 --- a/general/general.pro +++ b/general/general.pro @@ -1,6 +1,5 @@ OBJECTS_DIR = ../../obj/pokemod DESTDIR = ../../lib -VERSION = 1.0.0 TEMPLATE = lib CONFIG += qt warn_on dll diff --git a/menus/menus.pro b/menus/menus.pro new file mode 100644 index 00000000..cc232704 --- /dev/null +++ b/menus/menus.pro @@ -0,0 +1,9 @@ +OBJECTS_DIR = ../../obj/menus +DESTDIR = ../../lib +TEMPLATE = lib +LIBS += -L../../lib -lgeneral -lpokemod + +CONFIG += qt warn_on dll + +SOURCES += *.cpp +HEADERS += *.h diff --git a/overworld/overworld.pro b/overworld/overworld.pro index 9c0fd58f..d9fa2fe5 100644 --- a/overworld/overworld.pro +++ b/overworld/overworld.pro @@ -1,6 +1,5 @@ OBJECTS_DIR = ../../obj/overworld DESTDIR = ../../lib -VERSION = 0.1.0 TEMPLATE = lib LIBS += -L../../lib -lgeneral -lpokemod diff --git a/pokegen.pro b/pokegen.pro index a9b669cb..b8533e2b 100755 --- a/pokegen.pro +++ b/pokegen.pro @@ -1,12 +1,12 @@ -OBJECTS_DIR = ../obj -DESTDIR = ../bin VERSION = 0.0.1 TEMPLATE = subdirs CONFIG += ordered qt warn_on -SUBDIRS = audio \ - battle \ +SUBDIRS = battle \ general \ + menus \ + overworld \ + pokegen \ pokemod \ pokemodr diff --git a/pokegen/pokegen.pro b/pokegen/pokegen.pro index 6640bbe3..88406d08 100644 --- a/pokegen/pokegen.pro +++ b/pokegen/pokegen.pro @@ -1,8 +1,7 @@ OBJECTS_DIR = ../../obj/pokegen DESTDIR = ../../bin -VERSION = 0.1.0 TEMPLATE = app -LIBS += -L../../lib -lgeneral -lpokemod -loverworld -lbattle -laudio +LIBS += -L../../lib -lgeneral -lpokemod -loverworld -lbattle -laudio -lmenus CONFIG += qt gui warn_on dll diff --git a/pokemod/Ability.cpp b/pokemod/Ability.cpp index 1550f754..576161c0 100644 --- a/pokemod/Ability.cpp +++ b/pokemod/Ability.cpp @@ -23,25 +23,25 @@ #include "Ability.h" -PokeGen::PokeMod::Ability::Ability(const Pokemod& par, const unsigned _id) : +PokeMod::Ability::Ability(const Pokemod& par, const unsigned _id) : Object(par, _id), name("") { } -PokeGen::PokeMod::Ability::Ability(const Pokemod& par, const Ability& a, const unsigned _id) : +PokeMod::Ability::Ability(const Pokemod& par, const Ability& a, const unsigned _id) : Object(par, _id) { *this = a; } -PokeGen::PokeMod::Ability::Ability(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::Ability::Ability(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::Ability::validate() const +bool PokeMod::Ability::validate() const { bool valid = true; pokemod.validationMsg(QString("---Ability \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -76,7 +76,7 @@ bool PokeGen::PokeMod::Ability::validate() const return valid; } -unsigned PokeGen::PokeMod::Ability::getNewId() const +unsigned PokeMod::Ability::getNewId() const { unsigned i = 0; for (; (i < getEffectCount()) && (getEffectByID(i) != UINT_MAX); ++i) @@ -84,7 +84,7 @@ unsigned PokeGen::PokeMod::Ability::getNewId() const return i; } -void PokeGen::PokeMod::Ability::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::Ability::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -103,7 +103,7 @@ void PokeGen::PokeMod::Ability::load(const QString& fname, const unsigned _id) t } } -void PokeGen::PokeMod::Ability::save() const throw(Exception) +void PokeMod::Ability::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -113,31 +113,31 @@ void PokeGen::PokeMod::Ability::save() const throw(Exception) i.next().save(name); } -void PokeGen::PokeMod::Ability::setName(const QString& n) +void PokeMod::Ability::setName(const QString& n) { name = n; } -QString PokeGen::PokeMod::Ability::getName() const +QString PokeMod::Ability::getName() const { return name; } -const PokeGen::PokeMod::AbilityEffect& PokeGen::PokeMod::Ability::getEffect(const unsigned i) const throw(IndexException) +const PokeMod::AbilityEffect& PokeMod::Ability::getEffect(const unsigned i) const throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Ability")); return effects.at(i); } -PokeGen::PokeMod::AbilityEffect& PokeGen::PokeMod::Ability::getEffect(const unsigned i) throw(IndexException) +PokeMod::AbilityEffect& PokeMod::Ability::getEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Ability")); return effects[i]; } -unsigned PokeGen::PokeMod::Ability::getEffectByID(const unsigned _id) const +unsigned PokeMod::Ability::getEffectByID(const unsigned _id) const { for (unsigned i = 0; i < getEffectCount(); ++i) { @@ -147,37 +147,37 @@ unsigned PokeGen::PokeMod::Ability::getEffectByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Ability::getEffectCount() const +unsigned PokeMod::Ability::getEffectCount() const { return effects.size(); } -PokeGen::PokeMod::AbilityEffect& PokeGen::PokeMod::Ability::newEffect() +PokeMod::AbilityEffect& PokeMod::Ability::newEffect() { effects.append(AbilityEffect(pokemod, getNewId())); return effects[getEffectCount() - 1]; } -PokeGen::PokeMod::AbilityEffect& PokeGen::PokeMod::Ability::newEffect(const QString& fname) +PokeMod::AbilityEffect& PokeMod::Ability::newEffect(const QString& fname) { effects.append(AbilityEffect(pokemod, fname, getNewId())); return effects[getEffectCount() - 1]; } -PokeGen::PokeMod::AbilityEffect& PokeGen::PokeMod::Ability::newEffect(const AbilityEffect& e) +PokeMod::AbilityEffect& PokeMod::Ability::newEffect(const AbilityEffect& e) { effects.append(AbilityEffect(pokemod, e, getNewId())); return effects[getEffectCount() - 1]; } -void PokeGen::PokeMod::Ability::deleteEffect(const unsigned i) throw(IndexException) +void PokeMod::Ability::deleteEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Ability")); effects.removeAt(i); } -PokeGen::PokeMod::Ability& PokeGen::PokeMod::Ability::operator=(const Ability& rhs) +PokeMod::Ability& PokeMod::Ability::operator=(const Ability& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Ability.h b/pokemod/Ability.h index 8886276c..4e2ec210 100644 --- a/pokemod/Ability.h +++ b/pokemod/Ability.h @@ -36,43 +36,40 @@ #include "Object.h" #include "AbilityEffect.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class Ability : public Object { - 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); - unsigned getEffectByID(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); + unsigned getEffectByID(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 5df6545f..0f132cc4 100644 --- a/pokemod/AbilityEffect.cpp +++ b/pokemod/AbilityEffect.cpp @@ -22,17 +22,17 @@ #include "AbilityEffect.h" -const char* PokeGen::PokeMod::AbilityEffect::EffectStr[PokeGen::PokeMod::AbilityEffect::E_End] = {"Damage to HP", "Prevent Damage", "Auto Heal", "Deal Damage", "Wilds", "Stat", "Status", "Ability", "Accuracy/Power Trade", "Bullseye", "Item Effect", "Type", "Fast Hatch", "Weather"}; -const char* PokeGen::PokeMod::AbilityEffect::TriggerStr[PokeGen::PokeMod::AbilityEffect::T_End] = {"Anything", "Contact", "Weather", "Damage", "Type", "HP Boundary", "Stat Change", "Status"}; -const char* PokeGen::PokeMod::AbilityEffect::InteractStr[PokeGen::PokeMod::AbilityEffect::I_End] = {"Trade", "Shadow", "Block"}; -const char* PokeGen::PokeMod::AbilityEffect::PowerAccStr[PokeGen::PokeMod::AbilityEffect::PA_End] = {"Boost Power", "Boost Accuracy"}; -const char* PokeGen::PokeMod::AbilityEffect::ItemStr[PokeGen::PokeMod::AbilityEffect::IT_End] = {"Stat Modifier", "Type Booster", "Flinch", "Go First"}; -const char* PokeGen::PokeMod::AbilityEffect::CauseStr[PokeGen::PokeMod::AbilityEffect::C_End] = {"Prevent", "Inflict"}; -const char* PokeGen::PokeMod::AbilityEffect::BoostStr[PokeGen::PokeMod::AbilityEffect::B_End] = {"Boost", "Hinder"}; -const char* PokeGen::PokeMod::AbilityEffect::SideStr[PokeGen::PokeMod::AbilityEffect::S_End] = {"Above", "Below"}; +const char* PokeMod::AbilityEffect::EffectStr[PokeMod::AbilityEffect::E_End] = {"Damage to HP", "Prevent Damage", "Auto Heal", "Deal Damage", "Wilds", "Stat", "Status", "Ability", "Accuracy/Power Trade", "Bullseye", "Item Effect", "Type", "Fast Hatch", "Weather"}; +const char* PokeMod::AbilityEffect::TriggerStr[PokeMod::AbilityEffect::T_End] = {"Anything", "Contact", "Weather", "Damage", "Type", "HP Boundary", "Stat Change", "Status"}; +const char* PokeMod::AbilityEffect::InteractStr[PokeMod::AbilityEffect::I_End] = {"Trade", "Shadow", "Block"}; +const char* PokeMod::AbilityEffect::PowerAccStr[PokeMod::AbilityEffect::PA_End] = {"Boost Power", "Boost Accuracy"}; +const char* PokeMod::AbilityEffect::ItemStr[PokeMod::AbilityEffect::IT_End] = {"Stat Modifier", "Type Booster", "Flinch", "Go First"}; +const char* PokeMod::AbilityEffect::CauseStr[PokeMod::AbilityEffect::C_End] = {"Prevent", "Inflict"}; +const char* PokeMod::AbilityEffect::BoostStr[PokeMod::AbilityEffect::B_End] = {"Boost", "Hinder"}; +const char* PokeMod::AbilityEffect::SideStr[PokeMod::AbilityEffect::S_End] = {"Above", "Below"}; -PokeGen::PokeMod::AbilityEffect::AbilityEffect(const Pokemod& par, const unsigned _id) : +PokeMod::AbilityEffect::AbilityEffect(const Pokemod& par, const unsigned _id) : Object(par, _id), chance(1, 1), effect(UINT_MAX), @@ -45,19 +45,19 @@ PokeGen::PokeMod::AbilityEffect::AbilityEffect(const Pokemod& par, const unsigne { } -PokeGen::PokeMod::AbilityEffect::AbilityEffect(const Pokemod& par, const AbilityEffect& e, const unsigned _id) : +PokeMod::AbilityEffect::AbilityEffect(const Pokemod& par, const AbilityEffect& e, const unsigned _id) : Object(par, _id) { *this = e; } -PokeGen::PokeMod::AbilityEffect::AbilityEffect(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::AbilityEffect::AbilityEffect(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::AbilityEffect::validate() const +bool PokeMod::AbilityEffect::validate() const { bool valid = true; pokemod.validationMsg(QString("------Effect with id %1---").arg(id), Pokemod::V_Msg); @@ -197,7 +197,7 @@ bool PokeGen::PokeMod::AbilityEffect::validate() const return valid; } -void PokeGen::PokeMod::AbilityEffect::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::AbilityEffect::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -220,7 +220,7 @@ void PokeGen::PokeMod::AbilityEffect::load(const QString& fname, const unsigned tval2.set(i, j); } -void PokeGen::PokeMod::AbilityEffect::save(const QString& ability) const throw(Exception) +void PokeMod::AbilityEffect::save(const QString& ability) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -237,22 +237,22 @@ void PokeGen::PokeMod::AbilityEffect::save(const QString& ability) const throw(E ini.save(QString("%1/ability/%2/effect/%3.pini").arg(pokemod.getPath()).arg(ability).arg(id)); } -void PokeGen::PokeMod::AbilityEffect::setChance(const unsigned n, const unsigned d) throw(Exception) +void PokeMod::AbilityEffect::setChance(const unsigned n, const unsigned d) throw(Exception) { chance.set(n, d); } -void PokeGen::PokeMod::AbilityEffect::setChanceNum(const unsigned n) throw(Exception) +void PokeMod::AbilityEffect::setChanceNum(const unsigned n) throw(Exception) { chance.setNum(n); } -void PokeGen::PokeMod::AbilityEffect::setChanceDenom(const unsigned d) throw(Exception) +void PokeMod::AbilityEffect::setChanceDenom(const unsigned d) throw(Exception) { chance.setDenom(d); } -void PokeGen::PokeMod::AbilityEffect::setEffect(const unsigned e) throw(BoundsException) +void PokeMod::AbilityEffect::setEffect(const unsigned e) throw(BoundsException) { if (E_End <= e) throw(BoundsException("AbilityEffect", "effect")); @@ -262,7 +262,7 @@ void PokeGen::PokeMod::AbilityEffect::setEffect(const unsigned e) throw(BoundsEx val3 = INT_MAX; } -void PokeGen::PokeMod::AbilityEffect::setVal1(const unsigned v1) throw(Exception) +void PokeMod::AbilityEffect::setVal1(const unsigned v1) throw(Exception) { switch (effect) { @@ -301,7 +301,7 @@ void PokeGen::PokeMod::AbilityEffect::setVal1(const unsigned v1) throw(Exception val1 = v1; } -void PokeGen::PokeMod::AbilityEffect::setVal2(const unsigned v2) throw(Exception) +void PokeMod::AbilityEffect::setVal2(const unsigned v2) throw(Exception) { switch (effect) { @@ -329,7 +329,7 @@ void PokeGen::PokeMod::AbilityEffect::setVal2(const unsigned v2) throw(Exception val2 = v2; } -void PokeGen::PokeMod::AbilityEffect::setVal3(const int v3) throw(Exception) +void PokeMod::AbilityEffect::setVal3(const int v3) throw(Exception) { switch (effect) { @@ -355,7 +355,7 @@ void PokeGen::PokeMod::AbilityEffect::setVal3(const int v3) throw(Exception) val3 = v3; } -void PokeGen::PokeMod::AbilityEffect::setTrigger(const unsigned t) throw(BoundsException) +void PokeMod::AbilityEffect::setTrigger(const unsigned t) throw(BoundsException) { if (T_End <= t) throw(BoundsException("AbilityEffect", "trigger")); @@ -364,7 +364,7 @@ void PokeGen::PokeMod::AbilityEffect::setTrigger(const unsigned t) throw(BoundsE tval2.set(1, 1); } -void PokeGen::PokeMod::AbilityEffect::setTval1(const unsigned tv1) throw(Exception) +void PokeMod::AbilityEffect::setTval1(const unsigned tv1) throw(Exception) { switch (trigger) { @@ -395,88 +395,88 @@ void PokeGen::PokeMod::AbilityEffect::setTval1(const unsigned tv1) throw(Excepti tval1 = tv1; } -void PokeGen::PokeMod::AbilityEffect::setTval2(const unsigned n, const unsigned d) throw(Exception) +void PokeMod::AbilityEffect::setTval2(const unsigned n, const unsigned d) throw(Exception) { if (trigger != T_HPBoundary) throw(UnusedException("AbilityEffect", "tval2")); tval2.set(n, d); } -void PokeGen::PokeMod::AbilityEffect::setTval2Num(const unsigned n) throw(Exception) +void PokeMod::AbilityEffect::setTval2Num(const unsigned n) throw(Exception) { if (trigger != T_HPBoundary) throw(UnusedException("AbilityEffect", "tval2")); tval2.setNum(n); } -void PokeGen::PokeMod::AbilityEffect::setTval2Denom(const unsigned d) throw(Exception) +void PokeMod::AbilityEffect::setTval2Denom(const unsigned d) throw(Exception) { if (trigger != T_HPBoundary) throw(UnusedException("AbilityEffect", "tval2")); tval2.setDenom(d); } -PokeGen::Frac PokeGen::PokeMod::AbilityEffect::getChance() const +Frac PokeMod::AbilityEffect::getChance() const { return chance; } -unsigned PokeGen::PokeMod::AbilityEffect::getChanceNum() const +unsigned PokeMod::AbilityEffect::getChanceNum() const { return chance.getNum(); } -unsigned PokeGen::PokeMod::AbilityEffect::getChanceDenom() const +unsigned PokeMod::AbilityEffect::getChanceDenom() const { return chance.getDenom(); } -unsigned PokeGen::PokeMod::AbilityEffect::getEffect() const +unsigned PokeMod::AbilityEffect::getEffect() const { return effect; } -unsigned PokeGen::PokeMod::AbilityEffect::getVal1() const +unsigned PokeMod::AbilityEffect::getVal1() const { return val1; } -unsigned PokeGen::PokeMod::AbilityEffect::getVal2() const +unsigned PokeMod::AbilityEffect::getVal2() const { return val2; } -int PokeGen::PokeMod::AbilityEffect::getVal3() const +int PokeMod::AbilityEffect::getVal3() const { return val3; } -unsigned PokeGen::PokeMod::AbilityEffect::getTrigger() const +unsigned PokeMod::AbilityEffect::getTrigger() const { return trigger; } -unsigned PokeGen::PokeMod::AbilityEffect::getTval1() const +unsigned PokeMod::AbilityEffect::getTval1() const { return tval1; } -PokeGen::Frac PokeGen::PokeMod::AbilityEffect::getTval2() const +Frac PokeMod::AbilityEffect::getTval2() const { return tval2; } -unsigned PokeGen::PokeMod::AbilityEffect::getTval2Num() const +unsigned PokeMod::AbilityEffect::getTval2Num() const { return tval2.getNum(); } -unsigned PokeGen::PokeMod::AbilityEffect::getTval2Denom() const +unsigned PokeMod::AbilityEffect::getTval2Denom() const { return tval2.getDenom(); } -PokeGen::PokeMod::AbilityEffect& PokeGen::PokeMod::AbilityEffect::operator=(const AbilityEffect& rhs) +PokeMod::AbilityEffect& PokeMod::AbilityEffect::operator=(const AbilityEffect& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/AbilityEffect.h b/pokemod/AbilityEffect.h index 3f482044..515c5c7a 100644 --- a/pokemod/AbilityEffect.h +++ b/pokemod/AbilityEffect.h @@ -32,145 +32,142 @@ #include "Ability.h" #include "Type.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class AbilityEffect : public Object { - 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 char* EffectStr[E_End]; - - 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 char* TriggerStr[T_End]; - - enum Interact - { - I_Trade = 0, - I_Shadow = 1, - I_Block = 2, - I_End = 3 - }; - static const char* InteractStr[I_End]; - - enum PowerAccuracy - { - PA_Power = 0, - PA_Accuracy = 1, - PA_End = 2 - }; - static const char* PowerAccStr[PA_End]; - - enum Item - { - IT_Stat = 0, - IT_TypeBoost = 1, - IT_Flinch = 2, - IT_Quick = 3, - IT_End = 4 - }; - static const char* ItemStr[IT_End]; - - enum Cause - { - C_Prevent = 0, - C_Inflict = 1, - C_End = 2 - }; - static const char* CauseStr[C_End]; - - enum Boost - { - B_Boost = 0, - B_Hinder = 1, - B_End = 2 - }; - static const char* BoostStr[B_End]; - - enum Side - { - S_Above = 0, - S_Below = 1, - S_End = 2 - }; - static const char* SideStr[S_End]; - - 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 getChanceNum() const; - unsigned getChanceDenom() const; - unsigned getEffect() const; - unsigned getVal1() const; - unsigned getVal2() const; - int getVal3() const; - unsigned getTrigger() const; - unsigned getTval1() const; - Frac getTval2() const; - unsigned getTval2Num() const; - unsigned getTval2Denom() 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 char* EffectStr[E_End]; + + 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 char* TriggerStr[T_End]; + + enum Interact + { + I_Trade = 0, + I_Shadow = 1, + I_Block = 2, + I_End = 3 + }; + static const char* InteractStr[I_End]; + + enum PowerAccuracy + { + PA_Power = 0, + PA_Accuracy = 1, + PA_End = 2 + }; + static const char* PowerAccStr[PA_End]; + + enum Item + { + IT_Stat = 0, + IT_TypeBoost = 1, + IT_Flinch = 2, + IT_Quick = 3, + IT_End = 4 + }; + static const char* ItemStr[IT_End]; + + enum Cause + { + C_Prevent = 0, + C_Inflict = 1, + C_End = 2 + }; + static const char* CauseStr[C_End]; + + enum Boost + { + B_Boost = 0, + B_Hinder = 1, + B_End = 2 + }; + static const char* BoostStr[B_End]; + + enum Side + { + S_Above = 0, + S_Below = 1, + S_End = 2 + }; + static const char* SideStr[S_End]; + + 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 getChanceNum() const; + unsigned getChanceDenom() const; + unsigned getEffect() const; + unsigned getVal1() const; + unsigned getVal2() const; + int getVal3() const; + unsigned getTrigger() const; + unsigned getTval1() const; + Frac getTval2() const; + unsigned getTval2Num() const; + unsigned getTval2Denom() 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 95f3e97a..7dde9f38 100644 --- a/pokemod/Author.cpp +++ b/pokemod/Author.cpp @@ -22,7 +22,7 @@ #include "Author.h" -PokeGen::PokeMod::Author::Author(const Pokemod& par, const unsigned _id) : +PokeMod::Author::Author(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), email(""), @@ -30,19 +30,19 @@ PokeGen::PokeMod::Author::Author(const Pokemod& par, const unsigned _id) : { } -PokeGen::PokeMod::Author::Author(const Pokemod& par, const Author& a, const unsigned _id) : +PokeMod::Author::Author(const Pokemod& par, const Author& a, const unsigned _id) : Object(par, _id) { *this = a; } -PokeGen::PokeMod::Author::Author(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::Author::Author(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::Author::validate() const +bool PokeMod::Author::validate() const { bool valid = true; pokemod.validationMsg(QString("---Author \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -66,7 +66,7 @@ bool PokeGen::PokeMod::Author::validate() const return valid; } -void PokeGen::PokeMod::Author::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::Author::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -78,7 +78,7 @@ void PokeGen::PokeMod::Author::load(const QString& fname, const unsigned _id) th ini.getValue("role", role); } -void PokeGen::PokeMod::Author::save() const throw(Exception) +void PokeMod::Author::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -88,37 +88,37 @@ void PokeGen::PokeMod::Author::save() const throw(Exception) ini.save(QString("%1/author/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeGen::PokeMod::Author::setName(const QString& n) +void PokeMod::Author::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::Author::setEmail(const QString& e) +void PokeMod::Author::setEmail(const QString& e) { email = e; } -void PokeGen::PokeMod::Author::setRole(const QString& r) +void PokeMod::Author::setRole(const QString& r) { role = r; } -QString PokeGen::PokeMod::Author::getName() const +QString PokeMod::Author::getName() const { return name; } -QString PokeGen::PokeMod::Author::getEmail() const +QString PokeMod::Author::getEmail() const { return email; } -QString PokeGen::PokeMod::Author::getRole() const +QString PokeMod::Author::getRole() const { return role; } -PokeGen::PokeMod::Author& PokeGen::PokeMod::Author::operator=(const Author& rhs) +PokeMod::Author& PokeMod::Author::operator=(const Author& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Author.h b/pokemod/Author.h index 03a7011e..7ee92ce7 100644 --- a/pokemod/Author.h +++ b/pokemod/Author.h @@ -28,37 +28,34 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class Author : public Object { - 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 a07be4f3..d277cc31 100644 --- a/pokemod/Badge.cpp +++ b/pokemod/Badge.cpp @@ -23,9 +23,9 @@ #include "Badge.h" -const char* PokeGen::PokeMod::Badge::HMStr[PokeGen::PokeMod::Badge::End] = {"Cut", "Fly", "Surf", "Strength", "Flash", "Whirlpool", "Waterfall", "Dive", "Headbutt", "Rock Smash", "Defog", "Rock Climb"}; +const char* PokeMod::Badge::HMStr[PokeMod::Badge::End] = {"Cut", "Fly", "Surf", "Strength", "Flash", "Whirlpool", "Waterfall", "Dive", "Headbutt", "Rock Smash", "Defog", "Rock Climb"}; -PokeGen::PokeMod::Badge::Badge(const Pokemod& par, const unsigned _id) : +PokeMod::Badge::Badge(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), obey(0) @@ -36,19 +36,19 @@ PokeGen::PokeMod::Badge::Badge(const Pokemod& par, const unsigned _id) : hm[i] = false; } -PokeGen::PokeMod::Badge::Badge(const Pokemod& par, const Badge& b, const unsigned _id) : +PokeMod::Badge::Badge(const Pokemod& par, const Badge& b, const unsigned _id) : Object(par, _id) { *this = b; } -PokeGen::PokeMod::Badge::Badge(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::Badge::Badge(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::Badge::validate() const +bool PokeMod::Badge::validate() const { bool valid = true; pokemod.validationMsg(QString("---Badge \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -75,7 +75,7 @@ bool PokeGen::PokeMod::Badge::validate() const return valid; } -void PokeGen::PokeMod::Badge::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::Badge::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -96,7 +96,7 @@ void PokeGen::PokeMod::Badge::load(const QString& fname, const unsigned _id) thr ini.getValue(QString("hm-%1").arg(i), hm[i], false); } -void PokeGen::PokeMod::Badge::save() const throw(Exception) +void PokeMod::Badge::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -112,12 +112,12 @@ void PokeGen::PokeMod::Badge::save() const throw(Exception) ini.save(QString("%1/badge/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeGen::PokeMod::Badge::setName(const QString& n) +void PokeMod::Badge::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::Badge::setFace(const QString& f) throw(Exception) +void PokeMod::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()) @@ -126,7 +126,7 @@ void PokeGen::PokeMod::Badge::setFace(const QString& f) throw(Exception) throw(SaveException("Badge", file.fileName())); } -void PokeGen::PokeMod::Badge::setBadge(const QString& b) throw(Exception) +void PokeMod::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()) @@ -135,80 +135,80 @@ void PokeGen::PokeMod::Badge::setBadge(const QString& b) throw(Exception) throw(SaveException("Badge", file.fileName())); } -void PokeGen::PokeMod::Badge::setObey(const unsigned o) throw(BoundsException) +void PokeMod::Badge::setObey(const unsigned o) throw(BoundsException) { if (pokemod.getRules().getMaxLevel() < o) throw(BoundsException("Badge", "obey")); obey = o; } -void PokeGen::PokeMod::Badge::setStat(const unsigned s, const unsigned n, const unsigned d) throw(Exception) +void PokeMod::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 PokeGen::PokeMod::Badge::setStatNum(const unsigned s, const unsigned n) throw(Exception) +void PokeMod::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 PokeGen::PokeMod::Badge::setStatDenom(const unsigned s, const unsigned d) throw(Exception) +void PokeMod::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 PokeGen::PokeMod::Badge::setHm(const unsigned h, const bool hb) throw(BoundsException) +void PokeMod::Badge::setHm(const unsigned h, const bool hb) throw(BoundsException) { if (End <= h) throw(BoundsException("Badge", "hm")); hm[h] = hb; } -QString PokeGen::PokeMod::Badge::getName() const +QString PokeMod::Badge::getName() const { return name; } -unsigned PokeGen::PokeMod::Badge::getObey() const +unsigned PokeMod::Badge::getObey() const { return obey; } -PokeGen::Frac PokeGen::PokeMod::Badge::getStat(const unsigned s) const throw(BoundsException) +Frac PokeMod::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]; } -unsigned PokeGen::PokeMod::Badge::getStatNum(const unsigned s) const throw(BoundsException) +unsigned PokeMod::Badge::getStatNum(const unsigned s) const throw(BoundsException) { if ((pokemod.getRules().getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) throw(BoundsException("Badge", "stat")); return getStat(s).getNum(); } -unsigned PokeGen::PokeMod::Badge::getStatDenom(const unsigned s) const throw(BoundsException) +unsigned PokeMod::Badge::getStatDenom(const unsigned s) const throw(BoundsException) { if ((pokemod.getRules().getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) throw(BoundsException("Badge", "stat")); return getStat(s).getDenom(); } -bool PokeGen::PokeMod::Badge::getHm(const unsigned h) const throw(BoundsException) +bool PokeMod::Badge::getHm(const unsigned h) const throw(BoundsException) { if (End <= h) throw(BoundsException("Badge", "hm")); return hm[h]; } -PokeGen::PokeMod::Badge& PokeGen::PokeMod::Badge::operator=(const Badge& rhs) +PokeMod::Badge& PokeMod::Badge::operator=(const Badge& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Badge.h b/pokemod/Badge.h index 3cd00b01..7b7a76f7 100644 --- a/pokemod/Badge.h +++ b/pokemod/Badge.h @@ -31,64 +31,61 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class Badge : public Object { - class Badge : public Object - { - public: - enum HMMove - { - Cut = 0, - Fly = 1, - Surf = 2, - Strength = 3, - Flash = 4, - Whirlpool = 5, - Waterfall = 6, - Dive = 7, - Headbutt = 8, - RockSmash = 9, - Defog = 10, - RockClimb = 11, - End = 12 - }; - static const char* HMStr[End]; - - 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); - unsigned getStatNum(const unsigned s) const throw(BoundsException); - unsigned getStatDenom(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[End]; - }; - } + public: + enum HMMove + { + Cut = 0, + Fly = 1, + Surf = 2, + Strength = 3, + Flash = 4, + Whirlpool = 5, + Waterfall = 6, + Dive = 7, + Headbutt = 8, + RockSmash = 9, + Defog = 10, + RockClimb = 11, + End = 12 + }; + static const char* HMStr[End]; + + 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); + unsigned getStatNum(const unsigned s) const throw(BoundsException); + unsigned getStatDenom(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[End]; + }; } #endif diff --git a/pokemod/CoinList.cpp b/pokemod/CoinList.cpp index 8a8b2a0e..c4ca7f98 100644 --- a/pokemod/CoinList.cpp +++ b/pokemod/CoinList.cpp @@ -23,26 +23,26 @@ #include "CoinList.h" -PokeGen::PokeMod::CoinList::CoinList(const Pokemod& par, const unsigned _id) : +PokeMod::CoinList::CoinList(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), value(0) { } -PokeGen::PokeMod::CoinList::CoinList(const Pokemod& par, const CoinList& c, const unsigned _id) : +PokeMod::CoinList::CoinList(const Pokemod& par, const CoinList& c, const unsigned _id) : Object(par, _id) { *this = c; } -PokeGen::PokeMod::CoinList::CoinList(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::CoinList::CoinList(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::CoinList::validate() const +bool PokeMod::CoinList::validate() const { bool valid = true; pokemod.validationMsg(QString("---Coin List \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -113,7 +113,7 @@ bool PokeGen::PokeMod::CoinList::validate() const return valid; } -unsigned PokeGen::PokeMod::CoinList::getNewId() const +unsigned PokeMod::CoinList::getNewId() const { unsigned i = 0; for (; (i < getItemCount()) && (getItemByID(i) != UINT_MAX); ++i) @@ -121,7 +121,7 @@ unsigned PokeGen::PokeMod::CoinList::getNewId() const return i; } -void PokeGen::PokeMod::CoinList::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::CoinList::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -141,7 +141,7 @@ void PokeGen::PokeMod::CoinList::load(const QString& fname, const unsigned _id) } } -void PokeGen::PokeMod::CoinList::save() const throw(Exception) +void PokeMod::CoinList::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -152,12 +152,12 @@ void PokeGen::PokeMod::CoinList::save() const throw(Exception) i.next().save(name); } -void PokeGen::PokeMod::CoinList::setName(const QString& n) +void PokeMod::CoinList::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::CoinList::setValue(const unsigned v) throw(Exception) +void PokeMod::CoinList::setValue(const unsigned v) throw(Exception) { for (unsigned i = 0; (i < pokemod.getItemCount()); ++i) { @@ -173,31 +173,31 @@ void PokeGen::PokeMod::CoinList::setValue(const unsigned v) throw(Exception) throw(Exception("CoinList", "no compatable coin cases")); } -QString PokeGen::PokeMod::CoinList::getName() const +QString PokeMod::CoinList::getName() const { return name; } -unsigned PokeGen::PokeMod::CoinList::getValue() const +unsigned PokeMod::CoinList::getValue() const { return value; } -const PokeGen::PokeMod::CoinListObject& PokeGen::PokeMod::CoinList::getItem(const unsigned i) const throw(IndexException) +const PokeMod::CoinListObject& PokeMod::CoinList::getItem(const unsigned i) const throw(IndexException) { if (getItemCount() <= i) throw(IndexException("CoinList")); return items.at(i); } -PokeGen::PokeMod::CoinListObject& PokeGen::PokeMod::CoinList::getItem(const unsigned i) throw(IndexException) +PokeMod::CoinListObject& PokeMod::CoinList::getItem(const unsigned i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException("CoinList")); return items[i]; } -unsigned PokeGen::PokeMod::CoinList::getItemByID(const unsigned _id) const +unsigned PokeMod::CoinList::getItemByID(const unsigned _id) const { for (unsigned i = 0; i < getItemCount(); ++i) { @@ -207,37 +207,37 @@ unsigned PokeGen::PokeMod::CoinList::getItemByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::CoinList::getItemCount() const +unsigned PokeMod::CoinList::getItemCount() const { return items.size(); } -PokeGen::PokeMod::CoinListObject& PokeGen::PokeMod::CoinList::newItem() +PokeMod::CoinListObject& PokeMod::CoinList::newItem() { items.append(CoinListObject(pokemod, getNewId())); return items[getItemCount() - 1]; } -PokeGen::PokeMod::CoinListObject& PokeGen::PokeMod::CoinList::newItem(const QString& fname) +PokeMod::CoinListObject& PokeMod::CoinList::newItem(const QString& fname) { items.append(CoinListObject(pokemod, fname, getNewId())); return items[getItemCount() - 1]; } -PokeGen::PokeMod::CoinListObject& PokeGen::PokeMod::CoinList::newItem(const CoinListObject& o) +PokeMod::CoinListObject& PokeMod::CoinList::newItem(const CoinListObject& o) { items.append(CoinListObject(pokemod, o, getNewId())); return items[getItemCount() - 1]; } -void PokeGen::PokeMod::CoinList::deleteItem(const unsigned i) throw(IndexException) +void PokeMod::CoinList::deleteItem(const unsigned i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException("CoinList")); items.removeAt(i); } -PokeGen::PokeMod::CoinList& PokeGen::PokeMod::CoinList::operator=(const CoinList& rhs) +PokeMod::CoinList& PokeMod::CoinList::operator=(const CoinList& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/CoinList.h b/pokemod/CoinList.h index e9837bba..1254f5f6 100644 --- a/pokemod/CoinList.h +++ b/pokemod/CoinList.h @@ -38,46 +38,43 @@ #include "Item.h" #include "ItemEffect.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class CoinList : public Object { - 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); - unsigned getItemByID(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); + unsigned getItemByID(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 9e083638..74f09878 100644 --- a/pokemod/CoinListObject.cpp +++ b/pokemod/CoinListObject.cpp @@ -22,9 +22,9 @@ #include "CoinListObject.h" -const char* PokeGen::PokeMod::CoinListObject::TypeStr[PokeGen::PokeMod::CoinListObject::End] = {"Item", "Pokémon"}; +const char* PokeMod::CoinListObject::TypeStr[PokeMod::CoinListObject::End] = {"Item", "Pokémon"}; -PokeGen::PokeMod::CoinListObject::CoinListObject(const Pokemod& par, const unsigned _id) : +PokeMod::CoinListObject::CoinListObject(const Pokemod& par, const unsigned _id) : Object(par, _id), type(Item), object(UINT_MAX), @@ -33,19 +33,19 @@ PokeGen::PokeMod::CoinListObject::CoinListObject(const Pokemod& par, const unsig { } -PokeGen::PokeMod::CoinListObject::CoinListObject(const Pokemod& par, const CoinListObject& o, const unsigned _id) : +PokeMod::CoinListObject::CoinListObject(const Pokemod& par, const CoinListObject& o, const unsigned _id) : Object(par, _id) { *this = o; } -PokeGen::PokeMod::CoinListObject::CoinListObject(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::CoinListObject::CoinListObject(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::CoinListObject::validate() const +bool PokeMod::CoinListObject::validate() const { bool valid = true; pokemod.validationMsg(QString("------Object with id %1---").arg(id), Pokemod::V_Msg); @@ -78,7 +78,7 @@ bool PokeGen::PokeMod::CoinListObject::validate() const return valid; } -void PokeGen::PokeMod::CoinListObject::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::CoinListObject::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -91,7 +91,7 @@ void PokeGen::PokeMod::CoinListObject::load(const QString& fname, const unsigned ini.getValue("cost", cost, 0); } -void PokeGen::PokeMod::CoinListObject::save(const QString& coinList) const throw(Exception) +void PokeMod::CoinListObject::save(const QString& coinList) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -102,7 +102,7 @@ void PokeGen::PokeMod::CoinListObject::save(const QString& coinList) const throw ini.save(QString("%1/coinlist/%2/item/%3.pini").arg(pokemod.getPath()).arg(coinList).arg(id)); } -void PokeGen::PokeMod::CoinListObject::setType(const unsigned t) throw(BoundsException) +void PokeMod::CoinListObject::setType(const unsigned t) throw(BoundsException) { if (End <= t) throw(BoundsException("CoinListObject", "type")); @@ -110,46 +110,46 @@ void PokeGen::PokeMod::CoinListObject::setType(const unsigned t) throw(BoundsExc object = UINT_MAX; } -void PokeGen::PokeMod::CoinListObject::setObject(const unsigned o) throw(BoundsException) +void PokeMod::CoinListObject::setObject(const unsigned o) throw(BoundsException) { if (((type == Item) && (pokemod.getItemByID(object) == UINT_MAX)) || ((type == Pokemon) && (pokemod.getSpeciesByID(object) == UINT_MAX))) throw(BoundsException("CoinListObject", "object")); object = o; } -void PokeGen::PokeMod::CoinListObject::setAmount(const unsigned a) throw(BoundsException) +void PokeMod::CoinListObject::setAmount(const unsigned a) throw(BoundsException) { if (!a) throw(BoundsException("CoinListObject", "amount")); amount = a; } -void PokeGen::PokeMod::CoinListObject::setCost(const unsigned c) +void PokeMod::CoinListObject::setCost(const unsigned c) { cost = c; } -unsigned PokeGen::PokeMod::CoinListObject::getType() const +unsigned PokeMod::CoinListObject::getType() const { return type; } -unsigned PokeGen::PokeMod::CoinListObject::getObject() const +unsigned PokeMod::CoinListObject::getObject() const { return object; } -unsigned PokeGen::PokeMod::CoinListObject::getAmount() const +unsigned PokeMod::CoinListObject::getAmount() const { return amount; } -unsigned PokeGen::PokeMod::CoinListObject::getCost() const +unsigned PokeMod::CoinListObject::getCost() const { return cost; } -PokeGen::PokeMod::CoinListObject& PokeGen::PokeMod::CoinListObject::operator=(const CoinListObject& rhs) +PokeMod::CoinListObject& PokeMod::CoinListObject::operator=(const CoinListObject& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/CoinListObject.h b/pokemod/CoinListObject.h index c636c992..3fe8537a 100644 --- a/pokemod/CoinListObject.h +++ b/pokemod/CoinListObject.h @@ -28,48 +28,45 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class CoinListObject : public Object { - class CoinListObject : public Object - { - public: - enum - { - Item = 0, - Pokemon = 1, - End = 2 - }; - static const char* TypeStr[End]; - - 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 char* TypeStr[End]; + + 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 3f2a0dfb..d934d4ae 100644 --- a/pokemod/Dialog.cpp +++ b/pokemod/Dialog.cpp @@ -22,29 +22,29 @@ #include "Dialog.h" -const char* PokeGen::PokeMod::Dialog::CommandStr[PokeGen::PokeMod::Dialog::End] = {"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 char* PokeGen::PokeMod::Dialog::CommandAbbrStr[PokeGen::PokeMod::Dialog::End] = {"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 unsigned PokeGen::PokeMod::Dialog::CommandNumArgs[PokeGen::PokeMod::Dialog::Menu] = {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 char* PokeMod::Dialog::CommandStr[PokeMod::Dialog::End] = {"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 char* PokeMod::Dialog::CommandAbbrStr[PokeMod::Dialog::End] = {"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 unsigned PokeMod::Dialog::CommandNumArgs[PokeMod::Dialog::Menu] = {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}; -PokeGen::PokeMod::Dialog::Dialog(const Pokemod& par, const unsigned _id) : +PokeMod::Dialog::Dialog(const Pokemod& par, const unsigned _id) : Object(par, _id), dialog("") { } -PokeGen::PokeMod::Dialog::Dialog(const Pokemod& par, const Dialog& d, const unsigned _id) : +PokeMod::Dialog::Dialog(const Pokemod& par, const Dialog& d, const unsigned _id) : Object(par, _id) { *this = d; } -PokeGen::PokeMod::Dialog::Dialog(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::Dialog::Dialog(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::Dialog::validate() const +bool PokeMod::Dialog::validate() const { bool valid = true; pokemod.validationMsg(QString("---Dialog with id %1---").arg(id), Pokemod::V_Msg); @@ -652,7 +652,7 @@ bool PokeGen::PokeMod::Dialog::validate() const return valid; } -void PokeGen::PokeMod::Dialog::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::Dialog::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -662,7 +662,7 @@ void PokeGen::PokeMod::Dialog::load(const QString& fname, const unsigned _id) th ini.getValue("dialog", dialog); } -void PokeGen::PokeMod::Dialog::save() const throw(Exception) +void PokeMod::Dialog::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -670,24 +670,24 @@ void PokeGen::PokeMod::Dialog::save() const throw(Exception) ini.save(QString("%1/dialog/%2.pini").arg(pokemod.getPath()).arg(id)); } -void PokeGen::PokeMod::Dialog::setDialog(const QString& d) +void PokeMod::Dialog::setDialog(const QString& d) { dialog = d; } -QString PokeGen::PokeMod::Dialog::getDialog() const +QString PokeMod::Dialog::getDialog() const { return dialog; } -void PokeGen::PokeMod::Dialog::insertDialogCommand(const QString& cmd, const long pos) throw(BoundsException) +void PokeMod::Dialog::insertDialogCommand(const QString& cmd, const long pos) throw(BoundsException) { if (dialog.length() < pos) throw(BoundsException("Dialog" , "command")); dialog.insert(pos, cmd); } -PokeGen::PokeMod::Dialog& PokeGen::PokeMod::Dialog::operator=(const Dialog& rhs) +PokeMod::Dialog& PokeMod::Dialog::operator=(const Dialog& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Dialog.h b/pokemod/Dialog.h index a42bf51d..cb23a5fa 100644 --- a/pokemod/Dialog.h +++ b/pokemod/Dialog.h @@ -36,89 +36,86 @@ #include "Move.h" #include "Species.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class Dialog : public Object { - 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 char* CommandStr[End]; - static const char* CommandAbbrStr[End]; - static const unsigned CommandNumArgs[Menu]; - - 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 char* CommandStr[End]; + static const char* CommandAbbrStr[End]; + static const unsigned CommandNumArgs[Menu]; + + 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 671e63c1..59465985 100644 --- a/pokemod/EggGroup.cpp +++ b/pokemod/EggGroup.cpp @@ -22,25 +22,25 @@ #include "EggGroup.h" -PokeGen::PokeMod::EggGroup::EggGroup(const Pokemod& par, const unsigned _id) : +PokeMod::EggGroup::EggGroup(const Pokemod& par, const unsigned _id) : Object(par, _id), name("") { } -PokeGen::PokeMod::EggGroup::EggGroup(const Pokemod& par, const EggGroup& e, const unsigned _id) : +PokeMod::EggGroup::EggGroup(const Pokemod& par, const EggGroup& e, const unsigned _id) : Object(par, _id) { *this = e; } -PokeGen::PokeMod::EggGroup::EggGroup(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::EggGroup::EggGroup(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::EggGroup::validate() const +bool PokeMod::EggGroup::validate() const { bool valid = true; pokemod.validationMsg(QString("---Egg Group \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -52,7 +52,7 @@ bool PokeGen::PokeMod::EggGroup::validate() const return valid; } -void PokeGen::PokeMod::EggGroup::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::EggGroup::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -62,7 +62,7 @@ void PokeGen::PokeMod::EggGroup::load(const QString& fname, const unsigned _id) ini.getValue("name", name); } -void PokeGen::PokeMod::EggGroup::save() const throw(Exception) +void PokeMod::EggGroup::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -70,17 +70,17 @@ void PokeGen::PokeMod::EggGroup::save() const throw(Exception) ini.save(QString("%1/egggroup/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeGen::PokeMod::EggGroup::setName(const QString& n) +void PokeMod::EggGroup::setName(const QString& n) { name = n; } -QString PokeGen::PokeMod::EggGroup::getName() const +QString PokeMod::EggGroup::getName() const { return name; } -PokeGen::PokeMod::EggGroup& PokeGen::PokeMod::EggGroup::operator=(const EggGroup& rhs) +PokeMod::EggGroup& PokeMod::EggGroup::operator=(const EggGroup& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/EggGroup.h b/pokemod/EggGroup.h index ce706338..88fb64ea 100644 --- a/pokemod/EggGroup.h +++ b/pokemod/EggGroup.h @@ -27,31 +27,28 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class EggGroup : public Object { - 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 d4f31939..5ce51cf8 100644 --- a/pokemod/Item.cpp +++ b/pokemod/Item.cpp @@ -22,7 +22,7 @@ #include "Item.h" -PokeGen::PokeMod::Item::Item(const Pokemod& par, const unsigned _id) : +PokeMod::Item::Item(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), sellable(false), @@ -32,19 +32,19 @@ PokeGen::PokeMod::Item::Item(const Pokemod& par, const unsigned _id) : { } -PokeGen::PokeMod::Item::Item(const Pokemod& par, const Item& i, const unsigned _id) : +PokeMod::Item::Item(const Pokemod& par, const Item& i, const unsigned _id) : Object(par, _id) { *this = i; } -PokeGen::PokeMod::Item::Item(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::Item::Item(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::Item::validate() const +bool PokeMod::Item::validate() const { bool valid = true; pokemod.validationMsg(QString("---Item \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -84,7 +84,7 @@ bool PokeGen::PokeMod::Item::validate() const return valid; } -unsigned PokeGen::PokeMod::Item::getNewId() const +unsigned PokeMod::Item::getNewId() const { unsigned i = 0; for (; (i < getEffectCount()) && (getEffectByID(i) != UINT_MAX); ++i) @@ -92,7 +92,7 @@ unsigned PokeGen::PokeMod::Item::getNewId() const return i; } -void PokeGen::PokeMod::Item::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::Item::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -115,7 +115,7 @@ void PokeGen::PokeMod::Item::load(const QString& fname, const unsigned _id) thro } } -void PokeGen::PokeMod::Item::save() const throw(Exception) +void PokeMod::Item::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -129,73 +129,73 @@ void PokeGen::PokeMod::Item::save() const throw(Exception) i.next().save(name); } -void PokeGen::PokeMod::Item::setName(const QString& n) +void PokeMod::Item::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::Item::setSellable(const bool s) +void PokeMod::Item::setSellable(const bool s) { sellable = s; } -void PokeGen::PokeMod::Item::setType(const unsigned t) throw(BoundsException) +void PokeMod::Item::setType(const unsigned t) throw(BoundsException) { if (pokemod.getItemTypeByID(t) == UINT_MAX) throw(BoundsException("Item", "type")); type = t; } -void PokeGen::PokeMod::Item::setPrice(const unsigned p) +void PokeMod::Item::setPrice(const unsigned p) { price = p; } -void PokeGen::PokeMod::Item::setDescription(const QString& d) +void PokeMod::Item::setDescription(const QString& d) { description = d; } -QString PokeGen::PokeMod::Item::getName() const +QString PokeMod::Item::getName() const { return name; } -bool PokeGen::PokeMod::Item::getSellable() const +bool PokeMod::Item::getSellable() const { return sellable; } -unsigned PokeGen::PokeMod::Item::getType() const +unsigned PokeMod::Item::getType() const { return type; } -unsigned PokeGen::PokeMod::Item::getPrice() const +unsigned PokeMod::Item::getPrice() const { return price; } -QString PokeGen::PokeMod::Item::getDescription() const +QString PokeMod::Item::getDescription() const { return description; } -const PokeGen::PokeMod::ItemEffect& PokeGen::PokeMod::Item::getEffect(const unsigned i) const throw(IndexException) +const PokeMod::ItemEffect& PokeMod::Item::getEffect(const unsigned i) const throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Item")); return effects.at(i); } -PokeGen::PokeMod::ItemEffect& PokeGen::PokeMod::Item::getEffect(const unsigned i) throw(IndexException) +PokeMod::ItemEffect& PokeMod::Item::getEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Item")); return effects[i]; } -unsigned PokeGen::PokeMod::Item::getEffectByID(const unsigned _id) const +unsigned PokeMod::Item::getEffectByID(const unsigned _id) const { for (unsigned i = 0; i < getEffectCount(); ++i) { @@ -205,37 +205,37 @@ unsigned PokeGen::PokeMod::Item::getEffectByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Item::getEffectCount() const +unsigned PokeMod::Item::getEffectCount() const { return effects.size(); } -PokeGen::PokeMod::ItemEffect& PokeGen::PokeMod::Item::newEffect() +PokeMod::ItemEffect& PokeMod::Item::newEffect() { effects.append(ItemEffect(pokemod, getNewId())); return effects[getEffectCount() - 1]; } -PokeGen::PokeMod::ItemEffect& PokeGen::PokeMod::Item::newEffect(const QString& fname) +PokeMod::ItemEffect& PokeMod::Item::newEffect(const QString& fname) { effects.append(ItemEffect(pokemod, fname, getNewId())); return effects[getEffectCount() - 1]; } -PokeGen::PokeMod::ItemEffect& PokeGen::PokeMod::Item::newEffect(const ItemEffect& e) +PokeMod::ItemEffect& PokeMod::Item::newEffect(const ItemEffect& e) { effects.append(ItemEffect(pokemod, e, getNewId())); return effects[getEffectCount() - 1]; } -void PokeGen::PokeMod::Item::deleteEffect(const unsigned i) throw(IndexException) +void PokeMod::Item::deleteEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Item")); effects.removeAt(i); } -PokeGen::PokeMod::Item& PokeGen::PokeMod::Item::operator=(const Item& rhs) +PokeMod::Item& PokeMod::Item::operator=(const Item& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Item.h b/pokemod/Item.h index b190562a..a1547182 100644 --- a/pokemod/Item.h +++ b/pokemod/Item.h @@ -36,55 +36,52 @@ #include "Pokemod.h" #include "ItemEffect.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class Item : public Object { - 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); - unsigned getEffectByID(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); + unsigned getEffectByID(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 4581b5e5..2a115a07 100644 --- a/pokemod/ItemEffect.cpp +++ b/pokemod/ItemEffect.cpp @@ -22,16 +22,16 @@ #include "ItemEffect.h" -const char* PokeGen::PokeMod::ItemEffect::EffectStr[PokeGen::PokeMod::ItemEffect::E_End] = {"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 char* PokeGen::PokeMod::ItemEffect::RelativeStr[PokeGen::PokeMod::ItemEffect::R_End] = {"Absolute", "Relative"}; -const char* PokeGen::PokeMod::ItemEffect::EscapeStr[PokeGen::PokeMod::ItemEffect::ES_End] = {"Anywhere", "Dungeon"}; -const char* PokeGen::PokeMod::ItemEffect::RepelStr[PokeGen::PokeMod::ItemEffect::RP_End] = {"First", "Max", "All"}; -const char* PokeGen::PokeMod::ItemEffect::AmountStr[PokeGen::PokeMod::ItemEffect::A_End] = {"All", "One"}; -const char* PokeGen::PokeMod::ItemEffect::SpecialPhysicalStr[PokeGen::PokeMod::ItemEffect::SP_End] = {"Special", "Physical"}; -const char* PokeGen::PokeMod::ItemEffect::BallTypeStr[PokeGen::PokeMod::ItemEffect::B_End] = {"Regular", "Master", "Level", "Love", "Area", "Time", "Battle", "Friend", "Stat", "Type", "Weight"}; -const char* PokeGen::PokeMod::ItemEffect::BerryTypeStr[PokeGen::PokeMod::ItemEffect::B2_End] = {"HP Cure", "Status Cure"}; +const char* PokeMod::ItemEffect::EffectStr[PokeMod::ItemEffect::E_End] = {"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 char* PokeMod::ItemEffect::RelativeStr[PokeMod::ItemEffect::R_End] = {"Absolute", "Relative"}; +const char* PokeMod::ItemEffect::EscapeStr[PokeMod::ItemEffect::ES_End] = {"Anywhere", "Dungeon"}; +const char* PokeMod::ItemEffect::RepelStr[PokeMod::ItemEffect::RP_End] = {"First", "Max", "All"}; +const char* PokeMod::ItemEffect::AmountStr[PokeMod::ItemEffect::A_End] = {"All", "One"}; +const char* PokeMod::ItemEffect::SpecialPhysicalStr[PokeMod::ItemEffect::SP_End] = {"Special", "Physical"}; +const char* PokeMod::ItemEffect::BallTypeStr[PokeMod::ItemEffect::B_End] = {"Regular", "Master", "Level", "Love", "Area", "Time", "Battle", "Friend", "Stat", "Type", "Weight"}; +const char* PokeMod::ItemEffect::BerryTypeStr[PokeMod::ItemEffect::B2_End] = {"HP Cure", "Status Cure"}; -PokeGen::PokeMod::ItemEffect::ItemEffect(const Pokemod& par, const unsigned _id) : +PokeMod::ItemEffect::ItemEffect(const Pokemod& par, const unsigned _id) : Object(par, _id), overworld(false), battle(false), @@ -44,19 +44,19 @@ PokeGen::PokeMod::ItemEffect::ItemEffect(const Pokemod& par, const unsigned _id) { } -PokeGen::PokeMod::ItemEffect::ItemEffect(const Pokemod& par, const ItemEffect& e, const unsigned _id) : +PokeMod::ItemEffect::ItemEffect(const Pokemod& par, const ItemEffect& e, const unsigned _id) : Object(par, _id) { *this = e; } -PokeGen::PokeMod::ItemEffect::ItemEffect(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::ItemEffect::ItemEffect(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::ItemEffect::validate() const +bool PokeMod::ItemEffect::validate() const { bool valid = true; pokemod.validationMsg(QString("------Effect with id %1---").arg(id), Pokemod::V_Msg); @@ -295,7 +295,7 @@ bool PokeGen::PokeMod::ItemEffect::validate() const return valid; } -void PokeGen::PokeMod::ItemEffect::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::ItemEffect::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -316,7 +316,7 @@ void PokeGen::PokeMod::ItemEffect::load(const QString& fname, const unsigned _id val4.set(i, j); } -void PokeGen::PokeMod::ItemEffect::save(const QString& item) const throw(Exception) +void PokeMod::ItemEffect::save(const QString& item) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -332,7 +332,7 @@ void PokeGen::PokeMod::ItemEffect::save(const QString& item) const throw(Excepti ini.save(QString("%1/item/%2/effect/%3.pini").arg(pokemod.getPath()).arg(item).arg(id)); } -void PokeGen::PokeMod::ItemEffect::setOverworld(const bool o) throw(Exception) +void PokeMod::ItemEffect::setOverworld(const bool o) throw(Exception) { switch (effect) { @@ -373,17 +373,17 @@ void PokeGen::PokeMod::ItemEffect::setOverworld(const bool o) throw(Exception) overworld = o; } -void PokeGen::PokeMod::ItemEffect::setBattle(const bool b) +void PokeMod::ItemEffect::setBattle(const bool b) { battle = b; } -void PokeGen::PokeMod::ItemEffect::setHeld(const bool h) +void PokeMod::ItemEffect::setHeld(const bool h) { held = h; } -void PokeGen::PokeMod::ItemEffect::setEffect(const unsigned e) throw(Exception) +void PokeMod::ItemEffect::setEffect(const unsigned e) throw(Exception) { if (E_End <= e) throw(BoundsException("ItemEffect", "effect out-of-bounds")); @@ -430,7 +430,7 @@ void PokeGen::PokeMod::ItemEffect::setEffect(const unsigned e) throw(Exception) val4.set(1, 1, ((e == E_TypeBoost) || (e == E_PPBoost)) ? Frac::Over1 : Frac::Proper); } -void PokeGen::PokeMod::ItemEffect::setVal1(const int v1) throw(Exception) +void PokeMod::ItemEffect::setVal1(const int v1) throw(Exception) { switch (effect) { @@ -491,7 +491,7 @@ void PokeGen::PokeMod::ItemEffect::setVal1(const int v1) throw(Exception) val1 = v1; } -void PokeGen::PokeMod::ItemEffect::setVal2(const unsigned v2) throw(Exception) +void PokeMod::ItemEffect::setVal2(const unsigned v2) throw(Exception) { switch (effect) { @@ -563,7 +563,7 @@ void PokeGen::PokeMod::ItemEffect::setVal2(const unsigned v2) throw(Exception) val2 = v2; } -void PokeGen::PokeMod::ItemEffect::setVal3(const unsigned v3) throw(Exception) +void PokeMod::ItemEffect::setVal3(const unsigned v3) throw(Exception) { switch (effect) { @@ -625,7 +625,7 @@ void PokeGen::PokeMod::ItemEffect::setVal3(const unsigned v3) throw(Exception) val3 = v3; } -void PokeGen::PokeMod::ItemEffect::setVal4(const unsigned n, const unsigned d) throw(Exception) +void PokeMod::ItemEffect::setVal4(const unsigned n, const unsigned d) throw(Exception) { switch (effect) { @@ -658,7 +658,7 @@ void PokeGen::PokeMod::ItemEffect::setVal4(const unsigned n, const unsigned d) t val4.set(n, d); } -void PokeGen::PokeMod::ItemEffect::setVal4Num(const unsigned n) throw(Exception) +void PokeMod::ItemEffect::setVal4Num(const unsigned n) throw(Exception) { switch (effect) { @@ -691,7 +691,7 @@ void PokeGen::PokeMod::ItemEffect::setVal4Num(const unsigned n) throw(Exception) val4.setNum(n); } -void PokeGen::PokeMod::ItemEffect::setVal4Denom(const unsigned d) throw(Exception) +void PokeMod::ItemEffect::setVal4Denom(const unsigned d) throw(Exception) { switch (effect) { @@ -724,57 +724,57 @@ void PokeGen::PokeMod::ItemEffect::setVal4Denom(const unsigned d) throw(Exceptio val4.setDenom(d); } -bool PokeGen::PokeMod::ItemEffect::getOverworld() const +bool PokeMod::ItemEffect::getOverworld() const { return overworld; } -bool PokeGen::PokeMod::ItemEffect::getBattle() const +bool PokeMod::ItemEffect::getBattle() const { return battle; } -bool PokeGen::PokeMod::ItemEffect::getHeld() const +bool PokeMod::ItemEffect::getHeld() const { return held; } -unsigned PokeGen::PokeMod::ItemEffect::getEffect() const +unsigned PokeMod::ItemEffect::getEffect() const { return effect; } -int PokeGen::PokeMod::ItemEffect::getVal1() const +int PokeMod::ItemEffect::getVal1() const { return val1; } -unsigned PokeGen::PokeMod::ItemEffect::getVal2() const +unsigned PokeMod::ItemEffect::getVal2() const { return val2; } -unsigned PokeGen::PokeMod::ItemEffect::getVal3() const +unsigned PokeMod::ItemEffect::getVal3() const { return val3; } -PokeGen::Frac PokeGen::PokeMod::ItemEffect::getVal4() const +Frac PokeMod::ItemEffect::getVal4() const { return val4; } -unsigned PokeGen::PokeMod::ItemEffect::getVal4Num() const +unsigned PokeMod::ItemEffect::getVal4Num() const { return val4.getNum(); } -unsigned PokeGen::PokeMod::ItemEffect::getVal4Denom() const +unsigned PokeMod::ItemEffect::getVal4Denom() const { return val4.getDenom(); } -PokeGen::PokeMod::ItemEffect& PokeGen::PokeMod::ItemEffect::operator=(const ItemEffect& rhs) +PokeMod::ItemEffect& PokeMod::ItemEffect::operator=(const ItemEffect& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/ItemEffect.h b/pokemod/ItemEffect.h index 259bc701..b2cc32d4 100644 --- a/pokemod/ItemEffect.h +++ b/pokemod/ItemEffect.h @@ -30,158 +30,155 @@ #include "Pokemod.h" #include "MapWildList.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class ItemEffect : public Object { - 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 char* EffectStr[E_End]; - - enum Relative - { - R_Absolute = 0, - R_Relative = 1, - R_End = 2 - }; - static const char* RelativeStr[R_End]; - - enum Escape - { - ES_Anywhere = 0, - ES_Dungeon = 1, - ES_End = 2 - }; - static const char* EscapeStr[ES_End]; - - enum Repel - { - RP_First = 0, - RP_Max = 1, - RP_All = 2, - RP_End = 3 - }; - static const char* RepelStr[RP_End]; - - enum Amount - { - A_All = 0, - A_One = 1, - A_End = 2 - }; - static const char* AmountStr[A_End]; - - enum SpecialPhysical - { - SP_Special = 0, - SP_Physical = 1, - SP_End = 2 - }; - static const char* SpecialPhysicalStr[SP_End]; - - 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 char* BallTypeStr[B_End]; - - enum BerryType - { - B2_HPCure = 0, - B2_StatusCure = 1, - B2_End = 2 - }; - static const char* BerryTypeStr[B2_End]; - - 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 char* EffectStr[E_End]; + + enum Relative + { + R_Absolute = 0, + R_Relative = 1, + R_End = 2 + }; + static const char* RelativeStr[R_End]; + + enum Escape + { + ES_Anywhere = 0, + ES_Dungeon = 1, + ES_End = 2 + }; + static const char* EscapeStr[ES_End]; + + enum Repel + { + RP_First = 0, + RP_Max = 1, + RP_All = 2, + RP_End = 3 + }; + static const char* RepelStr[RP_End]; + + enum Amount + { + A_All = 0, + A_One = 1, + A_End = 2 + }; + static const char* AmountStr[A_End]; + + enum SpecialPhysical + { + SP_Special = 0, + SP_Physical = 1, + SP_End = 2 + }; + static const char* SpecialPhysicalStr[SP_End]; + + 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 char* BallTypeStr[B_End]; + + enum BerryType + { + B2_HPCure = 0, + B2_StatusCure = 1, + B2_End = 2 + }; + static const char* BerryTypeStr[B2_End]; + + 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 d57346b0..b554dcea 100644 --- a/pokemod/ItemType.cpp +++ b/pokemod/ItemType.cpp @@ -22,7 +22,7 @@ #include "ItemType.h" -PokeGen::PokeMod::ItemType::ItemType(const Pokemod& par, const unsigned _id) : +PokeMod::ItemType::ItemType(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), computer(0), @@ -30,19 +30,19 @@ PokeGen::PokeMod::ItemType::ItemType(const Pokemod& par, const unsigned _id) : { } -PokeGen::PokeMod::ItemType::ItemType(const Pokemod& par, const ItemType& i, const unsigned _id) : +PokeMod::ItemType::ItemType(const Pokemod& par, const ItemType& i, const unsigned _id) : Object(par, _id) { *this = i; } -PokeGen::PokeMod::ItemType::ItemType(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::ItemType::ItemType(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::ItemType::validate() const +bool PokeMod::ItemType::validate() const { bool valid = true; pokemod.validationMsg(QString("---Item Type \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -59,7 +59,7 @@ bool PokeGen::PokeMod::ItemType::validate() const return valid; } -void PokeGen::PokeMod::ItemType::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::ItemType::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -71,7 +71,7 @@ void PokeGen::PokeMod::ItemType::load(const QString& fname, const unsigned _id) ini.getValue("player", player, 1); } -void PokeGen::PokeMod::ItemType::save() const throw(Exception) +void PokeMod::ItemType::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -81,39 +81,39 @@ void PokeGen::PokeMod::ItemType::save() const throw(Exception) ini.save(QString("%1/itemtype/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeGen::PokeMod::ItemType::setName(const QString& n) +void PokeMod::ItemType::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::ItemType::setComputer(const unsigned c) +void PokeMod::ItemType::setComputer(const unsigned c) { computer = c; } -void PokeGen::PokeMod::ItemType::setPlayer(const unsigned p) throw(BoundsException) +void PokeMod::ItemType::setPlayer(const unsigned p) throw(BoundsException) { if (!p) throw(BoundsException("ItemType", "player")); player = p; } -QString PokeGen::PokeMod::ItemType::getName() const +QString PokeMod::ItemType::getName() const { return name; } -unsigned PokeGen::PokeMod::ItemType::getComputer() const +unsigned PokeMod::ItemType::getComputer() const { return computer; } -unsigned PokeGen::PokeMod::ItemType::getPlayer() const +unsigned PokeMod::ItemType::getPlayer() const { return player; } -PokeGen::PokeMod::ItemType& PokeGen::PokeMod::ItemType::operator=(const ItemType& rhs) +PokeMod::ItemType& PokeMod::ItemType::operator=(const ItemType& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/ItemType.h b/pokemod/ItemType.h index 09255401..7fa351ae 100644 --- a/pokemod/ItemType.h +++ b/pokemod/ItemType.h @@ -29,37 +29,34 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class ItemType : public Object { - 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 74101944..ea8ed60e 100644 --- a/pokemod/Map.cpp +++ b/pokemod/Map.cpp @@ -22,9 +22,9 @@ #include "Map.h" -const char* PokeGen::PokeMod::Map::TypeStr[PokeGen::PokeMod::Map::End] = {"Outdoor", "Dungeon", "Building"}; +const char* PokeMod::Map::TypeStr[PokeMod::Map::End] = {"Outdoor", "Dungeon", "Building"}; -PokeGen::PokeMod::Map::Map(const Pokemod& par, const unsigned _id) : +PokeMod::Map::Map(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), flyWarp(UINT_MAX), @@ -32,19 +32,19 @@ PokeGen::PokeMod::Map::Map(const Pokemod& par, const unsigned _id) : { } -PokeGen::PokeMod::Map::Map(const Pokemod& par, const Map& m, const unsigned _id) : +PokeMod::Map::Map(const Pokemod& par, const Map& m, const unsigned _id) : Object(par, _id) { *this = m; } -PokeGen::PokeMod::Map::Map(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::Map::Map(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::Map::validate() const +bool PokeMod::Map::validate() const { bool valid = true; pokemod.validationMsg(QString("---Map \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -222,7 +222,7 @@ bool PokeGen::PokeMod::Map::validate() const return valid; } -void PokeGen::PokeMod::Map::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::Map::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -274,7 +274,7 @@ void PokeGen::PokeMod::Map::load(const QString& fname, const unsigned _id) throw } } -void PokeGen::PokeMod::Map::save() const throw(Exception) +void PokeMod::Map::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -299,107 +299,107 @@ void PokeGen::PokeMod::Map::save() const throw(Exception) i.next().save(name); } -void PokeGen::PokeMod::Map::setName(const QString& n) +void PokeMod::Map::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::Map::setFlyWarp(const unsigned f) throw(BoundsException) +void PokeMod::Map::setFlyWarp(const unsigned f) throw(BoundsException) { if (getWarpByID(f) == UINT_MAX) throw(BoundsException("Map", "warp")); flyWarp = f; } -void PokeGen::PokeMod::Map::setType(const unsigned t) throw(BoundsException) +void PokeMod::Map::setType(const unsigned t) throw(BoundsException) { if (End <= t) throw(BoundsException("Map", "type")); type = t; } -QString PokeGen::PokeMod::Map::getName() const +QString PokeMod::Map::getName() const { return name; } -unsigned PokeGen::PokeMod::Map::getFlyWarp() const +unsigned PokeMod::Map::getFlyWarp() const { return flyWarp; } -unsigned PokeGen::PokeMod::Map::getType() const +unsigned PokeMod::Map::getType() const { return type; } -void PokeGen::PokeMod::Map::setTile(unsigned x, unsigned y, unsigned _id) throw(BoundsException) +void PokeMod::Map::setTile(unsigned x, unsigned y, unsigned _id) throw(BoundsException) { if (pokemod.getTileByID(_id) == UINT_MAX) throw(BoundsException("Map", "tile")); tiles(x, y) = _id; } -void PokeGen::PokeMod::Map::insertColumn(unsigned x) +void PokeMod::Map::insertColumn(unsigned x) { tiles.insertCol(x, 0); } -void PokeGen::PokeMod::Map::insertRow(unsigned y) +void PokeMod::Map::insertRow(unsigned y) { tiles.insertRow(y, 0); } -void PokeGen::PokeMod::Map::addColumn() +void PokeMod::Map::addColumn() { tiles.addCol(0); } -void PokeGen::PokeMod::Map::addRow() +void PokeMod::Map::addRow() { tiles.addRow(0); } -void PokeGen::PokeMod::Map::deleteColumn(unsigned x) +void PokeMod::Map::deleteColumn(unsigned x) { tiles.deleteCol(x); } -void PokeGen::PokeMod::Map::deleteRow(unsigned y) +void PokeMod::Map::deleteRow(unsigned y) { tiles.deleteRow(y); } -unsigned PokeGen::PokeMod::Map::getTile(unsigned x, unsigned y) const +unsigned PokeMod::Map::getTile(unsigned x, unsigned y) const { return tiles(x, y); } -unsigned PokeGen::PokeMod::Map::getWidth() const +unsigned PokeMod::Map::getWidth() const { return tiles.getWidth(); } -unsigned PokeGen::PokeMod::Map::getHeight() const +unsigned PokeMod::Map::getHeight() const { return tiles.getHeight(); } -const PokeGen::PokeMod::MapEffect& PokeGen::PokeMod::Map::getEffect(const unsigned i) const throw(IndexException) +const PokeMod::MapEffect& PokeMod::Map::getEffect(const unsigned i) const throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Map")); return effects.at(i); } -PokeGen::PokeMod::MapEffect& PokeGen::PokeMod::Map::getEffect(const unsigned i) throw(IndexException) +PokeMod::MapEffect& PokeMod::Map::getEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Map")); return effects[i]; } -unsigned PokeGen::PokeMod::Map::getEffectByID(const unsigned _id) const +unsigned PokeMod::Map::getEffectByID(const unsigned _id) const { for (unsigned i = 0; i < getEffectCount(); ++i) { @@ -409,51 +409,51 @@ unsigned PokeGen::PokeMod::Map::getEffectByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Map::getEffectCount() const +unsigned PokeMod::Map::getEffectCount() const { return effects.size(); } -PokeGen::PokeMod::MapEffect& PokeGen::PokeMod::Map::newEffect() +PokeMod::MapEffect& PokeMod::Map::newEffect() { effects.append(MapEffect(pokemod, getNewEffectId())); return effects[getEffectCount() - 1]; } -PokeGen::PokeMod::MapEffect& PokeGen::PokeMod::Map::newEffect(const QString& fname) +PokeMod::MapEffect& PokeMod::Map::newEffect(const QString& fname) { effects.append(MapEffect(pokemod, fname, getNewEffectId())); return effects[getEffectCount() - 1]; } -PokeGen::PokeMod::MapEffect& PokeGen::PokeMod::Map::newEffect(const MapEffect& e) +PokeMod::MapEffect& PokeMod::Map::newEffect(const MapEffect& e) { effects.append(MapEffect(pokemod, e, getNewEffectId())); return effects[getEffectCount() - 1]; } -void PokeGen::PokeMod::Map::deleteEffect(const unsigned i) throw(IndexException) +void PokeMod::Map::deleteEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Map")); effects.removeAt(i); } -const PokeGen::PokeMod::MapTrainer& PokeGen::PokeMod::Map::getTrainer(const unsigned i) const throw(IndexException) +const PokeMod::MapTrainer& PokeMod::Map::getTrainer(const unsigned i) const throw(IndexException) { if (getTrainerCount() <= i) throw(IndexException("Map")); return trainers.at(i); } -PokeGen::PokeMod::MapTrainer& PokeGen::PokeMod::Map::getTrainer(const unsigned i) throw(IndexException) +PokeMod::MapTrainer& PokeMod::Map::getTrainer(const unsigned i) throw(IndexException) { if (getTrainerCount() <= i) throw(IndexException("Map")); return trainers[i]; } -unsigned PokeGen::PokeMod::Map::getTrainerByID(const unsigned _id) const +unsigned PokeMod::Map::getTrainerByID(const unsigned _id) const { for (unsigned i = 0; i < getTrainerCount(); ++i) { @@ -463,51 +463,51 @@ unsigned PokeGen::PokeMod::Map::getTrainerByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Map::getTrainerCount() const +unsigned PokeMod::Map::getTrainerCount() const { return trainers.size(); } -PokeGen::PokeMod::MapTrainer& PokeGen::PokeMod::Map::newTrainer() +PokeMod::MapTrainer& PokeMod::Map::newTrainer() { trainers.append(MapTrainer(pokemod, getNewTrainerId())); return trainers[getTrainerCount() - 1]; } -PokeGen::PokeMod::MapTrainer& PokeGen::PokeMod::Map::newTrainer(const QString& fname) +PokeMod::MapTrainer& PokeMod::Map::newTrainer(const QString& fname) { trainers.append(MapTrainer(pokemod, fname, getNewTrainerId())); return trainers[getTrainerCount() - 1]; } -PokeGen::PokeMod::MapTrainer& PokeGen::PokeMod::Map::newTrainer(const MapTrainer& t) +PokeMod::MapTrainer& PokeMod::Map::newTrainer(const MapTrainer& t) { trainers.append(MapTrainer(pokemod, t, getNewTrainerId())); return trainers[getTrainerCount() - 1]; } -void PokeGen::PokeMod::Map::deleteTrainer(const unsigned i) throw(IndexException) +void PokeMod::Map::deleteTrainer(const unsigned i) throw(IndexException) { if (getTrainerCount() <= i) throw(IndexException("Map")); trainers.removeAt(i); } -const PokeGen::PokeMod::MapWarp& PokeGen::PokeMod::Map::getWarp(const unsigned i) const throw(IndexException) +const PokeMod::MapWarp& PokeMod::Map::getWarp(const unsigned i) const throw(IndexException) { if (getWarpCount() <= i) throw(IndexException("Map")); return warps.at(i); } -PokeGen::PokeMod::MapWarp& PokeGen::PokeMod::Map::getWarp(const unsigned i) throw(IndexException) +PokeMod::MapWarp& PokeMod::Map::getWarp(const unsigned i) throw(IndexException) { if (getWarpCount() <= i) throw(IndexException("Map")); return warps[i]; } -unsigned PokeGen::PokeMod::Map::getWarpByID(const unsigned _id) const +unsigned PokeMod::Map::getWarpByID(const unsigned _id) const { for (unsigned i = 0; i < getWarpCount(); ++i) { @@ -517,44 +517,44 @@ unsigned PokeGen::PokeMod::Map::getWarpByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Map::getWarpCount() const +unsigned PokeMod::Map::getWarpCount() const { return warps.size(); } -PokeGen::PokeMod::MapWarp& PokeGen::PokeMod::Map::newWarp() +PokeMod::MapWarp& PokeMod::Map::newWarp() { warps.append(MapWarp(pokemod, getNewWarpId())); return warps[getWarpCount() - 1]; } -PokeGen::PokeMod::MapWarp& PokeGen::PokeMod::Map::newWarp(const QString& fname) +PokeMod::MapWarp& PokeMod::Map::newWarp(const QString& fname) { warps.append(MapWarp(pokemod, fname, getNewWarpId())); return warps[getWarpCount() - 1]; } -PokeGen::PokeMod::MapWarp& PokeGen::PokeMod::Map::newWarp(const MapWarp& w) +PokeMod::MapWarp& PokeMod::Map::newWarp(const MapWarp& w) { warps.append(MapWarp(pokemod, w, getNewWarpId())); return warps[getWarpCount() - 1]; } -void PokeGen::PokeMod::Map::deleteWarp(const unsigned i) throw(IndexException) +void PokeMod::Map::deleteWarp(const unsigned i) throw(IndexException) { if (getWarpCount() <= i) throw(IndexException("Map")); warps.removeAt(i); } -const PokeGen::PokeMod::MapWildList& PokeGen::PokeMod::Map::getWildList(const unsigned i) const throw(IndexException) +const PokeMod::MapWildList& PokeMod::Map::getWildList(const unsigned i) const throw(IndexException) { if (getWildListCount() <= i) throw(IndexException("Map")); return wildLists[i]; } -unsigned PokeGen::PokeMod::Map::getWildListByID(const unsigned _id) const +unsigned PokeMod::Map::getWildListByID(const unsigned _id) const { for (unsigned i = 0; i < getWildListCount(); ++i) { @@ -564,37 +564,37 @@ unsigned PokeGen::PokeMod::Map::getWildListByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Map::getWildListCount() const +unsigned PokeMod::Map::getWildListCount() const { return wildLists.size(); } -PokeGen::PokeMod::MapWildList& PokeGen::PokeMod::Map::newWildList() +PokeMod::MapWildList& PokeMod::Map::newWildList() { wildLists.append(MapWildList(pokemod, getNewWildListId())); return wildLists[getWildListCount() - 1]; } -PokeGen::PokeMod::MapWildList& PokeGen::PokeMod::Map::newWildList(const QString& fname) +PokeMod::MapWildList& PokeMod::Map::newWildList(const QString& fname) { wildLists.append(MapWildList(pokemod, fname, getNewWildListId())); return wildLists[getWildListCount() - 1]; } -PokeGen::PokeMod::MapWildList& PokeGen::PokeMod::Map::newWildList(const MapWildList& w) +PokeMod::MapWildList& PokeMod::Map::newWildList(const MapWildList& w) { wildLists.append(MapWildList(pokemod, w, getNewWildListId())); return wildLists[getWildListCount() - 1]; } -void PokeGen::PokeMod::Map::deleteWildList(const unsigned i) throw(IndexException) +void PokeMod::Map::deleteWildList(const unsigned i) throw(IndexException) { if (getWildListCount() <= i) throw(IndexException("Map")); wildLists.removeAt(i); } -PokeGen::PokeMod::Map& PokeGen::PokeMod::Map::operator=(const Map& rhs) +PokeMod::Map& PokeMod::Map::operator=(const Map& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Map.h b/pokemod/Map.h index 44353bb2..d808c793 100644 --- a/pokemod/Map.h +++ b/pokemod/Map.h @@ -38,104 +38,101 @@ #include "MapWarp.h" #include "MapWildList.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class Map : public Object { - class Map : public Object - { - public: - enum - { - Outdoor = 0, - Dungeon = 1, - Building = 2, - End = 3 - }; - static const char* TypeStr[End]; - - 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); - unsigned getEffectByID(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); - unsigned getTrainerByID(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); - unsigned getWarpByID(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); - unsigned getWildListByID(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 char* TypeStr[End]; + + 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); + unsigned getEffectByID(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); + unsigned getTrainerByID(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); + unsigned getWarpByID(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); + unsigned getWildListByID(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 db65dd69..7c835e78 100644 --- a/pokemod/MapEffect.cpp +++ b/pokemod/MapEffect.cpp @@ -22,10 +22,10 @@ #include "MapEffect.h" -const char* PokeGen::PokeMod::MapEffect::MapEffectStr[PokeGen::PokeMod::MapEffect::E_End] = {"Item", "PC", "Strength Block", "Button", "Slot Machine", "Card Flip Game"}; -const char* PokeGen::PokeMod::MapEffect::PCTypeStr[PokeGen::PokeMod::MapEffect::PC_End] = {"Item", "Pokémon", "PokéDex", "Hall of Fame", "All"}; +const char* PokeMod::MapEffect::MapEffectStr[PokeMod::MapEffect::E_End] = {"Item", "PC", "Strength Block", "Button", "Slot Machine", "Card Flip Game"}; +const char* PokeMod::MapEffect::PCTypeStr[PokeMod::MapEffect::PC_End] = {"Item", "Pokémon", "PokéDex", "Hall of Fame", "All"}; -PokeGen::PokeMod::MapEffect::MapEffect(const Pokemod& par, const unsigned _id) : +PokeMod::MapEffect::MapEffect(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), coordinate(0, 0), @@ -41,19 +41,19 @@ PokeGen::PokeMod::MapEffect::MapEffect(const Pokemod& par, const unsigned _id) : { } -PokeGen::PokeMod::MapEffect::MapEffect(const Pokemod& par, const MapEffect& e, const unsigned _id) : +PokeMod::MapEffect::MapEffect(const Pokemod& par, const MapEffect& e, const unsigned _id) : Object(par, _id) { *this = e; } -PokeGen::PokeMod::MapEffect::MapEffect(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::MapEffect::MapEffect(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::MapEffect::validate() const +bool PokeMod::MapEffect::validate() const { bool valid = true; pokemod.validationMsg(QString("------Effect \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -115,7 +115,7 @@ bool PokeGen::PokeMod::MapEffect::validate() const return valid; } -void PokeGen::PokeMod::MapEffect::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::MapEffect::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -141,7 +141,7 @@ void PokeGen::PokeMod::MapEffect::load(const QString& fname, const unsigned _id) ini.getValue("dialog", dialog); } -void PokeGen::PokeMod::MapEffect::save(const QString& map) const throw(Exception) +void PokeMod::MapEffect::save(const QString& map) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -161,49 +161,49 @@ void PokeGen::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 PokeGen::PokeMod::MapEffect::setName(const QString& n) +void PokeMod::MapEffect::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::MapEffect::setCoordinate(const unsigned x, const unsigned y) +void PokeMod::MapEffect::setCoordinate(const unsigned x, const unsigned y) { coordinate.set(x, y); } -void PokeGen::PokeMod::MapEffect::setCoordinateX(const unsigned x) +void PokeMod::MapEffect::setCoordinateX(const unsigned x) { coordinate.setX(x); } -void PokeGen::PokeMod::MapEffect::setCoordinateY(const unsigned y) +void PokeMod::MapEffect::setCoordinateY(const unsigned y) { coordinate.setY(y); } -void PokeGen::PokeMod::MapEffect::setExistFlag(const unsigned f, const unsigned s) +void PokeMod::MapEffect::setExistFlag(const unsigned f, const unsigned s) { existFlag.set(f, s); } -void PokeGen::PokeMod::MapEffect::setExistFlagFlag(const unsigned f) +void PokeMod::MapEffect::setExistFlagFlag(const unsigned f) { existFlag.setFlag(f); } -void PokeGen::PokeMod::MapEffect::setExistFlagStatus(const unsigned s) +void PokeMod::MapEffect::setExistFlagStatus(const unsigned s) { existFlag.setStatus(s); } -void PokeGen::PokeMod::MapEffect::setSkin(const QString& s) throw(Exception) +void PokeMod::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 PokeGen::PokeMod::MapEffect::setEffect(const unsigned e) throw(BoundsException) +void PokeMod::MapEffect::setEffect(const unsigned e) throw(BoundsException) { if (E_End <= e) throw(BoundsException("MapEffect", "effect")); @@ -212,14 +212,14 @@ void PokeGen::PokeMod::MapEffect::setEffect(const unsigned e) throw(BoundsExcept val2 = UINT_MAX; } -void PokeGen::PokeMod::MapEffect::setVal1(const unsigned v1) throw(UnusedException) +void PokeMod::MapEffect::setVal1(const unsigned v1) throw(UnusedException) { if ((effect != E_StrengthBlock) && (effect != E_Button)) throw(UnusedException("MapEffect", "val1")); val1 = v1; } -void PokeGen::PokeMod::MapEffect::setVal2(const unsigned v2) throw(Exception) +void PokeMod::MapEffect::setVal2(const unsigned v2) throw(Exception) { switch (effect) { @@ -243,106 +243,106 @@ void PokeGen::PokeMod::MapEffect::setVal2(const unsigned v2) throw(Exception) val2 = v2; } -void PokeGen::PokeMod::MapEffect::setDirection(const unsigned d) throw(BoundsException) +void PokeMod::MapEffect::setDirection(const unsigned d) throw(BoundsException) { if (D_End_None <= d) throw(BoundsException("MapEffect", "direction")); direction = d; } -void PokeGen::PokeMod::MapEffect::setIsTransparent(const bool i) +void PokeMod::MapEffect::setIsTransparent(const bool i) { isTransparent = i; } -void PokeGen::PokeMod::MapEffect::setCanMove(const bool c) +void PokeMod::MapEffect::setCanMove(const bool c) { canMove = c; } -void PokeGen::PokeMod::MapEffect::setDialog(const unsigned d) throw(BoundsException) +void PokeMod::MapEffect::setDialog(const unsigned d) throw(BoundsException) { if (pokemod.getDialogByID(d) == UINT_MAX) throw(BoundsException("MapEffect", "dialog")); dialog = d; } -QString PokeGen::PokeMod::MapEffect::getName() const +QString PokeMod::MapEffect::getName() const { return name; } -PokeGen::Point PokeGen::PokeMod::MapEffect::getCoordinate() const +Point PokeMod::MapEffect::getCoordinate() const { return coordinate; } -unsigned PokeGen::PokeMod::MapEffect::getCoordinateX() const +unsigned PokeMod::MapEffect::getCoordinateX() const { return coordinate.getX(); } -unsigned PokeGen::PokeMod::MapEffect::getCoordinateY() const +unsigned PokeMod::MapEffect::getCoordinateY() const { return coordinate.getY(); } -PokeGen::Flag PokeGen::PokeMod::MapEffect::getExistFlag() const +Flag PokeMod::MapEffect::getExistFlag() const { return existFlag; } -unsigned PokeGen::PokeMod::MapEffect::getExistFlagFlag() const +unsigned PokeMod::MapEffect::getExistFlagFlag() const { return existFlag.getFlag(); } -unsigned PokeGen::PokeMod::MapEffect::getExistFlagStatus() const +unsigned PokeMod::MapEffect::getExistFlagStatus() const { return existFlag.getStatus(); } -QString PokeGen::PokeMod::MapEffect::getSkin() const +QString PokeMod::MapEffect::getSkin() const { return skin; } -unsigned PokeGen::PokeMod::MapEffect::getEffect() const +unsigned PokeMod::MapEffect::getEffect() const { return effect; } -unsigned PokeGen::PokeMod::MapEffect::getVal1() const +unsigned PokeMod::MapEffect::getVal1() const { return val1; } -unsigned PokeGen::PokeMod::MapEffect::getVal2() const +unsigned PokeMod::MapEffect::getVal2() const { return val2; } -unsigned PokeGen::PokeMod::MapEffect::getDirection() const +unsigned PokeMod::MapEffect::getDirection() const { return direction; } -bool PokeGen::PokeMod::MapEffect::getIsTransparent() const +bool PokeMod::MapEffect::getIsTransparent() const { return isTransparent; } -bool PokeGen::PokeMod::MapEffect::getCanMove() const +bool PokeMod::MapEffect::getCanMove() const { return canMove; } -unsigned PokeGen::PokeMod::MapEffect::getDialog() const +unsigned PokeMod::MapEffect::getDialog() const { return dialog; } -PokeGen::PokeMod::MapEffect& PokeGen::PokeMod::MapEffect::operator=(const MapEffect& rhs) +PokeMod::MapEffect& PokeMod::MapEffect::operator=(const MapEffect& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/MapEffect.h b/pokemod/MapEffect.h index 42ba7915..43b9465b 100644 --- a/pokemod/MapEffect.h +++ b/pokemod/MapEffect.h @@ -30,92 +30,89 @@ #include "../general/Point.h" #include "Dialog.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class MapEffect : public Object { - 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 char* MapEffectStr[E_End]; - - enum PC - { - PC_Item = 0, - PC_Pokemon = 1, - PC_Pokedex = 2, - PC_HallOfFame = 3, - PC_All = 4, - PC_End = 5, - }; - static const char* PCTypeStr[PC_End]; - - 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 setIsTransparent(const bool i); - void setCanMove(const bool c); - void setDialog(const unsigned d) throw(BoundsException); - - QString getName() const; - Point getCoordinate() const; - unsigned getCoordinateX() const; - unsigned getCoordinateY() const; - Flag getExistFlag() const; - unsigned getExistFlagFlag() const; - unsigned getExistFlagStatus() const; - QString getSkin() const; - unsigned getEffect() const; - unsigned getVal1() const; - unsigned getVal2() const; - unsigned getDirection() const; - bool getIsTransparent() 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 isTransparent; - 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 char* MapEffectStr[E_End]; + + enum PC + { + PC_Item = 0, + PC_Pokemon = 1, + PC_Pokedex = 2, + PC_HallOfFame = 3, + PC_All = 4, + PC_End = 5, + }; + static const char* PCTypeStr[PC_End]; + + 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 setIsTransparent(const bool i); + void setCanMove(const bool c); + void setDialog(const unsigned d) throw(BoundsException); + + QString getName() const; + Point getCoordinate() const; + unsigned getCoordinateX() const; + unsigned getCoordinateY() const; + Flag getExistFlag() const; + unsigned getExistFlagFlag() const; + unsigned getExistFlagStatus() const; + QString getSkin() const; + unsigned getEffect() const; + unsigned getVal1() const; + unsigned getVal2() const; + unsigned getDirection() const; + bool getIsTransparent() 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 isTransparent; + bool canMove; + unsigned dialog; + }; } #endif diff --git a/pokemod/MapTrainer.cpp b/pokemod/MapTrainer.cpp index c1effd1d..6ce711eb 100644 --- a/pokemod/MapTrainer.cpp +++ b/pokemod/MapTrainer.cpp @@ -22,7 +22,7 @@ #include "MapTrainer.h" -PokeGen::PokeMod::MapTrainer::MapTrainer(const Pokemod& par, const unsigned _id) : +PokeMod::MapTrainer::MapTrainer(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), coordinate(0, 0), @@ -39,19 +39,19 @@ PokeGen::PokeMod::MapTrainer::MapTrainer(const Pokemod& par, const unsigned _id) { } -PokeGen::PokeMod::MapTrainer::MapTrainer(const Pokemod& par, const MapTrainer& t, const unsigned _id) : +PokeMod::MapTrainer::MapTrainer(const Pokemod& par, const MapTrainer& t, const unsigned _id) : Object(par, _id) { *this = t; } -PokeGen::PokeMod::MapTrainer::MapTrainer(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::MapTrainer::MapTrainer(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::MapTrainer::validate() const +bool PokeMod::MapTrainer::validate() const { bool valid = true; pokemod.validationMsg(QString("------Trainer \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -126,7 +126,7 @@ bool PokeGen::PokeMod::MapTrainer::validate() const return valid; } -unsigned PokeGen::PokeMod::MapTrainer::getNewId() const +unsigned PokeMod::MapTrainer::getNewId() const { unsigned i = 0; for (; i < getPokemonCount(); ++i) @@ -137,7 +137,7 @@ unsigned PokeGen::PokeMod::MapTrainer::getNewId() const return UINT_MAX; } -void PokeGen::PokeMod::MapTrainer::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::MapTrainer::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -173,7 +173,7 @@ void PokeGen::PokeMod::MapTrainer::load(const QString& fname, const unsigned _id } } -void PokeGen::PokeMod::MapTrainer::save(const QString& map) const throw(Exception) +void PokeMod::MapTrainer::save(const QString& map) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -197,197 +197,197 @@ void PokeGen::PokeMod::MapTrainer::save(const QString& map) const throw(Exceptio i.next().save(map, name); } -void PokeGen::PokeMod::MapTrainer::setName(const QString& n) +void PokeMod::MapTrainer::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::MapTrainer::setCoordinate(const unsigned x, const unsigned y) +void PokeMod::MapTrainer::setCoordinate(const unsigned x, const unsigned y) { coordinate.set(x, y); } -void PokeGen::PokeMod::MapTrainer::setCoordinateX(const unsigned x) +void PokeMod::MapTrainer::setCoordinateX(const unsigned x) { coordinate.setX(x); } -void PokeGen::PokeMod::MapTrainer::setCoordinateY(const unsigned y) +void PokeMod::MapTrainer::setCoordinateY(const unsigned y) { coordinate.setY(y); } -void PokeGen::PokeMod::MapTrainer::setSkin(const QString& s) throw(OpenException) +void PokeMod::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 PokeGen::PokeMod::MapTrainer::setSight(const unsigned s) +void PokeMod::MapTrainer::setSight(const unsigned s) { sight = s; } -void PokeGen::PokeMod::MapTrainer::setDirection(const unsigned d) throw(BoundsException) +void PokeMod::MapTrainer::setDirection(const unsigned d) throw(BoundsException) { if (D_End_None <= d) throw(BoundsException("MapTrainer", "direction")); direction = d; } -void PokeGen::PokeMod::MapTrainer::setNumFight(const unsigned n) throw(BoundsException) +void PokeMod::MapTrainer::setNumFight(const unsigned n) throw(BoundsException) { if (!n || (pokemod.getRules().getMaxFight() < n)) throw(BoundsException("MapTrainer", "numFight")); numFight = n; } -void PokeGen::PokeMod::MapTrainer::setAI(const QString& a) throw(OpenException) +void PokeMod::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 PokeGen::PokeMod::MapTrainer::setAppearFlag(const unsigned f, const unsigned s) +void PokeMod::MapTrainer::setAppearFlag(const unsigned f, const unsigned s) { appearFlag.set(f, s); } -void PokeGen::PokeMod::MapTrainer::setAppearFlagFlag(const unsigned f) +void PokeMod::MapTrainer::setAppearFlagFlag(const unsigned f) { appearFlag.setFlag(f); } -void PokeGen::PokeMod::MapTrainer::setAppearFlagStatus(const unsigned s) +void PokeMod::MapTrainer::setAppearFlagStatus(const unsigned s) { appearFlag.setStatus(s); } -void PokeGen::PokeMod::MapTrainer::setOverworldDialog(const unsigned o) throw(BoundsException) +void PokeMod::MapTrainer::setOverworldDialog(const unsigned o) throw(BoundsException) { if (pokemod.getDialogByID(o) == UINT_MAX) throw(BoundsException("MapTrainer", "overworldDialog")); overworldDialog = o; } -void PokeGen::PokeMod::MapTrainer::setWinDialog(const unsigned w) throw(BoundsException) +void PokeMod::MapTrainer::setWinDialog(const unsigned w) throw(BoundsException) { if (pokemod.getDialogByID(w) == UINT_MAX) throw(BoundsException("MapTrainer", "winDialog")); winDialog = w; } -void PokeGen::PokeMod::MapTrainer::setLoseDialog(const unsigned l) throw(BoundsException) +void PokeMod::MapTrainer::setLoseDialog(const unsigned l) throw(BoundsException) { if (pokemod.getDialogByID(l) == UINT_MAX) throw(BoundsException("MapTrainer", "loseDialog")); loseDialog = l; } -void PokeGen::PokeMod::MapTrainer::setLeadPokemon(const unsigned l) throw(BoundsException) +void PokeMod::MapTrainer::setLeadPokemon(const unsigned l) throw(BoundsException) { if (getPokemonCount() <= l) throw(BoundsException("MapTrainer", "leadPokemon")); leadPokemon = l; } -QString PokeGen::PokeMod::MapTrainer::getName() const +QString PokeMod::MapTrainer::getName() const { return name; } -PokeGen::Point PokeGen::PokeMod::MapTrainer::getCoordinate() const +Point PokeMod::MapTrainer::getCoordinate() const { return coordinate; } -unsigned PokeGen::PokeMod::MapTrainer::getCoordinateX() const +unsigned PokeMod::MapTrainer::getCoordinateX() const { return coordinate.getX(); } -unsigned PokeGen::PokeMod::MapTrainer::getCoordinateY() const +unsigned PokeMod::MapTrainer::getCoordinateY() const { return coordinate.getY(); } -QString PokeGen::PokeMod::MapTrainer::getSkin() const +QString PokeMod::MapTrainer::getSkin() const { return skin; } -unsigned PokeGen::PokeMod::MapTrainer::getSight() const +unsigned PokeMod::MapTrainer::getSight() const { return sight; } -unsigned PokeGen::PokeMod::MapTrainer::getDirection() const +unsigned PokeMod::MapTrainer::getDirection() const { return direction; } -unsigned PokeGen::PokeMod::MapTrainer::getNumFight() const +unsigned PokeMod::MapTrainer::getNumFight() const { return numFight; } -QString PokeGen::PokeMod::MapTrainer::getAI() const +QString PokeMod::MapTrainer::getAI() const { return ai; } -PokeGen::Flag PokeGen::PokeMod::MapTrainer::getAppearFlag() const +Flag PokeMod::MapTrainer::getAppearFlag() const { return appearFlag; } -unsigned PokeGen::PokeMod::MapTrainer::getAppearFlagFlag() const +unsigned PokeMod::MapTrainer::getAppearFlagFlag() const { return appearFlag.getFlag(); } -unsigned PokeGen::PokeMod::MapTrainer::getAppearFlagStatus() const +unsigned PokeMod::MapTrainer::getAppearFlagStatus() const { return appearFlag.getStatus(); } -unsigned PokeGen::PokeMod::MapTrainer::getOverworldDialog() const +unsigned PokeMod::MapTrainer::getOverworldDialog() const { return overworldDialog; } -unsigned PokeGen::PokeMod::MapTrainer::getWinDialog() const +unsigned PokeMod::MapTrainer::getWinDialog() const { return winDialog; } -unsigned PokeGen::PokeMod::MapTrainer::getLoseDialog() const +unsigned PokeMod::MapTrainer::getLoseDialog() const { return loseDialog; } -unsigned PokeGen::PokeMod::MapTrainer::getLeadPokemon() const +unsigned PokeMod::MapTrainer::getLeadPokemon() const { return leadPokemon; } -const PokeGen::PokeMod::MapTrainerPokemon& PokeGen::PokeMod::MapTrainer::getPokemon(const unsigned i) const throw(IndexException) +const PokeMod::MapTrainerPokemon& PokeMod::MapTrainer::getPokemon(const unsigned i) const throw(IndexException) { if (getPokemonCount() <= i) throw(IndexException("MapTrainer")); return team.at(i); } -PokeGen::PokeMod::MapTrainerPokemon& PokeGen::PokeMod::MapTrainer::getPokemon(const unsigned i) throw(IndexException) +PokeMod::MapTrainerPokemon& PokeMod::MapTrainer::getPokemon(const unsigned i) throw(IndexException) { if (getPokemonCount() <= i) throw(IndexException("MapTrainer")); return team[i]; } -unsigned PokeGen::PokeMod::MapTrainer::getPokemonByID(const unsigned _id) const +unsigned PokeMod::MapTrainer::getPokemonByID(const unsigned _id) const { for (unsigned i = 0; i < getPokemonCount(); ++i) { @@ -397,37 +397,37 @@ unsigned PokeGen::PokeMod::MapTrainer::getPokemonByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::MapTrainer::getPokemonCount() const +unsigned PokeMod::MapTrainer::getPokemonCount() const { return team.size(); } -PokeGen::PokeMod::MapTrainerPokemon& PokeGen::PokeMod::MapTrainer::newPokemon() +PokeMod::MapTrainerPokemon& PokeMod::MapTrainer::newPokemon() { team.append(MapTrainerPokemon(pokemod, getNewId())); return team[getPokemonCount() - 1]; } -PokeGen::PokeMod::MapTrainerPokemon& PokeGen::PokeMod::MapTrainer::newPokemon(const QString& fname) +PokeMod::MapTrainerPokemon& PokeMod::MapTrainer::newPokemon(const QString& fname) { team.append(MapTrainerPokemon(pokemod, fname, getNewId())); return team[getPokemonCount() - 1]; } -PokeGen::PokeMod::MapTrainerPokemon& PokeGen::PokeMod::MapTrainer::newPokemon(const MapTrainerPokemon& p) +PokeMod::MapTrainerPokemon& PokeMod::MapTrainer::newPokemon(const MapTrainerPokemon& p) { team.append(MapTrainerPokemon(pokemod, p, getNewId())); return team[getPokemonCount() - 1]; } -void PokeGen::PokeMod::MapTrainer::deletePokemon(const unsigned i) throw(IndexException) +void PokeMod::MapTrainer::deletePokemon(const unsigned i) throw(IndexException) { if (getPokemonCount() <= i) throw(IndexException("MapTrainer")); team.removeAt(i); } -PokeGen::PokeMod::MapTrainer& PokeGen::PokeMod::MapTrainer::operator=(const MapTrainer& rhs) +PokeMod::MapTrainer& PokeMod::MapTrainer::operator=(const MapTrainer& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/MapTrainer.h b/pokemod/MapTrainer.h index a75bbb1a..e80fa782 100644 --- a/pokemod/MapTrainer.h +++ b/pokemod/MapTrainer.h @@ -38,86 +38,83 @@ #include "Dialog.h" #include "MapTrainerPokemon.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class MapTrainer : public Object { - 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 setLeadPokemon(const unsigned l) throw(BoundsException); - - QString getName() const; - Point getCoordinate() const; - unsigned getCoordinateX() const; - unsigned getCoordinateY() 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 getAppearFlagFlag() const; - unsigned getAppearFlagStatus() const; - unsigned getOverworldDialog() const; - unsigned getWinDialog() const; - unsigned getLoseDialog() const; - unsigned getLeadPokemon() const; - - const MapTrainerPokemon& getPokemon(const unsigned i) const throw(IndexException); - MapTrainerPokemon& getPokemon(const unsigned i) throw(IndexException); - unsigned getPokemonByID(const unsigned _id) const; - unsigned getPokemonCount() const; - MapTrainerPokemon& newPokemon(); - MapTrainerPokemon& newPokemon(const QString& fname); - MapTrainerPokemon& newPokemon(const MapTrainerPokemon& t); - void deletePokemon(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 leadPokemon; - - QList<MapTrainerPokemon> team; - }; - } + 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 setLeadPokemon(const unsigned l) throw(BoundsException); + + QString getName() const; + Point getCoordinate() const; + unsigned getCoordinateX() const; + unsigned getCoordinateY() 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 getAppearFlagFlag() const; + unsigned getAppearFlagStatus() const; + unsigned getOverworldDialog() const; + unsigned getWinDialog() const; + unsigned getLoseDialog() const; + unsigned getLeadPokemon() const; + + const MapTrainerPokemon& getPokemon(const unsigned i) const throw(IndexException); + MapTrainerPokemon& getPokemon(const unsigned i) throw(IndexException); + unsigned getPokemonByID(const unsigned _id) const; + unsigned getPokemonCount() const; + MapTrainerPokemon& newPokemon(); + MapTrainerPokemon& newPokemon(const QString& fname); + MapTrainerPokemon& newPokemon(const MapTrainerPokemon& t); + void deletePokemon(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 leadPokemon; + + QList<MapTrainerPokemon> team; + }; } #endif diff --git a/pokemod/MapTrainerPokemon.cpp b/pokemod/MapTrainerPokemon.cpp index 020e4a8a..531e4052 100644 --- a/pokemod/MapTrainerPokemon.cpp +++ b/pokemod/MapTrainerPokemon.cpp @@ -22,7 +22,7 @@ #include "MapTrainerPokemon.h" -PokeGen::PokeMod::MapTrainerPokemon::MapTrainerPokemon(const Pokemod& par, const unsigned _id) : +PokeMod::MapTrainerPokemon::MapTrainerPokemon(const Pokemod& par, const unsigned _id) : Object(par, _id), species(UINT_MAX), level(UINT_MAX), @@ -30,13 +30,13 @@ PokeGen::PokeMod::MapTrainerPokemon::MapTrainerPokemon(const Pokemod& par, const { } -PokeGen::PokeMod::MapTrainerPokemon::MapTrainerPokemon(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::MapTrainerPokemon::MapTrainerPokemon(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::MapTrainerPokemon::validate() const +bool PokeMod::MapTrainerPokemon::validate() const { bool valid = true; pokemod.validationMsg(QString("---------Pokémon with id %1---").arg(id), Pokemod::V_Msg); @@ -87,7 +87,7 @@ bool PokeGen::PokeMod::MapTrainerPokemon::validate() const return valid; } -void PokeGen::PokeMod::MapTrainerPokemon::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::MapTrainerPokemon::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -109,7 +109,7 @@ void PokeGen::PokeMod::MapTrainerPokemon::load(const QString& fname, const unsig } } -void PokeGen::PokeMod::MapTrainerPokemon::save(const QString& map, const QString& trainer) const throw(Exception) +void PokeMod::MapTrainerPokemon::save(const QString& map, const QString& trainer) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -122,50 +122,50 @@ void PokeGen::PokeMod::MapTrainerPokemon::save(const QString& map, const QString ini.save(QString("%1/map/%2/trainer/%3/team/%4.pini").arg(pokemod.getPath()).arg(map).arg(trainer).arg(id)); } -void PokeGen::PokeMod::MapTrainerPokemon::setSpecies(const unsigned s) throw(BoundsException) +void PokeMod::MapTrainerPokemon::setSpecies(const unsigned s) throw(BoundsException) { if (pokemod.getSpeciesByID(s) == UINT_MAX) throw(BoundsException("MapTrainerPokemon", "species")); species = s; } -void PokeGen::PokeMod::MapTrainerPokemon::setLevel(const unsigned l) throw(BoundsException) +void PokeMod::MapTrainerPokemon::setLevel(const unsigned l) throw(BoundsException) { if (pokemod.getRules().getMaxLevel() < l) throw(BoundsException("MapTrainerPokemon", "level")); level = l; } -void PokeGen::PokeMod::MapTrainerPokemon::setNature(const unsigned n) throw(BoundsException) +void PokeMod::MapTrainerPokemon::setNature(const unsigned n) throw(BoundsException) { if (!pokemod.getRules().getNatureAllowed() || (pokemod.getNatureByID(n) == UINT_MAX)) throw(BoundsException("MapTrainerPokemon", "nature")); nature = n; } -unsigned PokeGen::PokeMod::MapTrainerPokemon::getSpecies() const +unsigned PokeMod::MapTrainerPokemon::getSpecies() const { return species; } -unsigned PokeGen::PokeMod::MapTrainerPokemon::getLevel() const +unsigned PokeMod::MapTrainerPokemon::getLevel() const { return level; } -unsigned PokeGen::PokeMod::MapTrainerPokemon::getNature() const +unsigned PokeMod::MapTrainerPokemon::getNature() const { return nature; } -unsigned PokeGen::PokeMod::MapTrainerPokemon::getItem(const unsigned i) const throw(IndexException) +unsigned PokeMod::MapTrainerPokemon::getItem(const unsigned i) const throw(IndexException) { if (getItemCount() <= i) throw(IndexException("MapTrainerPokemon")); return items.at(i); } -unsigned PokeGen::PokeMod::MapTrainerPokemon::getItemByID(const unsigned _id) const +unsigned PokeMod::MapTrainerPokemon::getItemByID(const unsigned _id) const { for (unsigned i = 0; i < getItemCount(); ++i) { @@ -175,12 +175,12 @@ unsigned PokeGen::PokeMod::MapTrainerPokemon::getItemByID(const unsigned _id) co return UINT_MAX; } -unsigned PokeGen::PokeMod::MapTrainerPokemon::getItemCount() const +unsigned PokeMod::MapTrainerPokemon::getItemCount() const { return items.size(); } -void PokeGen::PokeMod::MapTrainerPokemon::newItem(const unsigned i) throw(Exception) +void PokeMod::MapTrainerPokemon::newItem(const unsigned i) throw(Exception) { if (pokemod.getRules().getHoldItems() <= getItemCount()) throw(Exception("MapTrainerPokemon", "too many items")); @@ -189,14 +189,14 @@ void PokeGen::PokeMod::MapTrainerPokemon::newItem(const unsigned i) throw(Except items.append(i); } -void PokeGen::PokeMod::MapTrainerPokemon::deleteItem(const unsigned i) throw(IndexException) +void PokeMod::MapTrainerPokemon::deleteItem(const unsigned i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException("MapTrainerPokemon")); items.erase(items.begin() + i); } -PokeGen::PokeMod::MapTrainerPokemon& PokeGen::PokeMod::MapTrainerPokemon::operator=(const MapTrainerPokemon& rhs) +PokeMod::MapTrainerPokemon& PokeMod::MapTrainerPokemon::operator=(const MapTrainerPokemon& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/MapTrainerPokemon.h b/pokemod/MapTrainerPokemon.h index fcd6df73..de7b4c69 100644 --- a/pokemod/MapTrainerPokemon.h +++ b/pokemod/MapTrainerPokemon.h @@ -32,44 +32,41 @@ #include "Item.h" #include "Species.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class MapTrainerPokemon : public Object { - class MapTrainerPokemon : public Object - { - public: - MapTrainerPokemon(const Pokemod& par, const unsigned _id); - MapTrainerPokemon(const Pokemod& par, const MapTrainerPokemon& p, const unsigned _id); - MapTrainerPokemon(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); - - unsigned getSpecies() const; - unsigned getLevel() const; - unsigned getNature() const; - - unsigned getItem(const unsigned i) const throw(IndexException); - unsigned getItemByID(const unsigned _id) const; - unsigned getItemCount() const; - void newItem(const unsigned i) throw(Exception); - void deleteItem(const unsigned i) throw(IndexException); - - MapTrainerPokemon& operator=(const MapTrainerPokemon& p); - private: - bool validate() const; - - unsigned species; - unsigned level; - unsigned nature; - QList<unsigned> items; - }; - } + public: + MapTrainerPokemon(const Pokemod& par, const unsigned _id); + MapTrainerPokemon(const Pokemod& par, const MapTrainerPokemon& p, const unsigned _id); + MapTrainerPokemon(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); + + unsigned getSpecies() const; + unsigned getLevel() const; + unsigned getNature() const; + + unsigned getItem(const unsigned i) const throw(IndexException); + unsigned getItemByID(const unsigned _id) const; + unsigned getItemCount() const; + void newItem(const unsigned i) throw(Exception); + void deleteItem(const unsigned i) throw(IndexException); + + MapTrainerPokemon& operator=(const MapTrainerPokemon& 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 dea20d92..33a85a2b 100644 --- a/pokemod/MapWarp.cpp +++ b/pokemod/MapWarp.cpp @@ -22,9 +22,9 @@ #include "MapWarp.h" -const char* PokeGen::PokeMod::MapWarp::TypeStr[PokeGen::PokeMod::MapWarp::End] = {"Door/Stair", "Warp Pad", "Hole", "Boundary"}; +const char* PokeMod::MapWarp::TypeStr[PokeMod::MapWarp::End] = {"Door/Stair", "Warp Pad", "Hole", "Boundary"}; -PokeGen::PokeMod::MapWarp::MapWarp(const Pokemod& par, const unsigned _id) : +PokeMod::MapWarp::MapWarp(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), coordinate(0, 0), @@ -42,19 +42,19 @@ PokeGen::PokeMod::MapWarp::MapWarp(const Pokemod& par, const unsigned _id) : from[i] = false; } -PokeGen::PokeMod::MapWarp::MapWarp(const Pokemod& par, const MapWarp& w, const unsigned _id) : +PokeMod::MapWarp::MapWarp(const Pokemod& par, const MapWarp& w, const unsigned _id) : Object(par, _id) { *this = w; } -PokeGen::PokeMod::MapWarp::MapWarp(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::MapWarp::MapWarp(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::MapWarp::validate() const +bool PokeMod::MapWarp::validate() const { bool valid = true; pokemod.validationMsg(QString("------Warp \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -99,7 +99,7 @@ bool PokeGen::PokeMod::MapWarp::validate() const return valid; } -void PokeGen::PokeMod::MapWarp::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::MapWarp::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -129,7 +129,7 @@ void PokeGen::PokeMod::MapWarp::load(const QString& fname, const unsigned _id) t ini.getValue("dialog", dialog); } -void PokeGen::PokeMod::MapWarp::save(const QString& map) const throw(Exception) +void PokeMod::MapWarp::save(const QString& map) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -152,63 +152,63 @@ void PokeGen::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 PokeGen::PokeMod::MapWarp::setName(const QString& n) +void PokeMod::MapWarp::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::MapWarp::setCoordinate(const unsigned x, const unsigned y) +void PokeMod::MapWarp::setCoordinate(const unsigned x, const unsigned y) { coordinate.set(x, y); } -void PokeGen::PokeMod::MapWarp::setCoordinateX(const unsigned x) +void PokeMod::MapWarp::setCoordinateX(const unsigned x) { coordinate.setX(x); } -void PokeGen::PokeMod::MapWarp::setCoordinateY(const unsigned y) +void PokeMod::MapWarp::setCoordinateY(const unsigned y) { coordinate.setY(y); } -void PokeGen::PokeMod::MapWarp::setFrom(const unsigned d, const bool f) throw(BoundsException) +void PokeMod::MapWarp::setFrom(const unsigned d, const bool f) throw(BoundsException) { if (D_End <= d) throw(BoundsException("MapWarp", "direction")); from[d] = f; } -void PokeGen::PokeMod::MapWarp::setDirectionOut(const unsigned d) throw(BoundsException) +void PokeMod::MapWarp::setDirectionOut(const unsigned d) throw(BoundsException) { if (D_End <= d) throw(BoundsException("MapWarp", "direction")); directionOut = d; } -void PokeGen::PokeMod::MapWarp::setWarpType(const unsigned w) throw(BoundsException) +void PokeMod::MapWarp::setWarpType(const unsigned w) throw(BoundsException) { if (End <= w) throw(BoundsException("MapWarp", "warpType")); warpType = w; } -void PokeGen::PokeMod::MapWarp::setIsBiking(const bool i) +void PokeMod::MapWarp::setIsBiking(const bool i) { isBiking = i; } -void PokeGen::PokeMod::MapWarp::setIsFlash(const bool i) +void PokeMod::MapWarp::setIsFlash(const bool i) { isFlash = i; } -void PokeGen::PokeMod::MapWarp::setIsFoggy(const bool i) +void PokeMod::MapWarp::setIsFoggy(const bool i) { isFoggy = i; } -void PokeGen::PokeMod::MapWarp::setToMap(const unsigned t) throw(BoundsException) +void PokeMod::MapWarp::setToMap(const unsigned t) throw(BoundsException) { if (pokemod.getMapByID(t) == UINT_MAX) throw(BoundsException("MapWarp", "toMap")); @@ -216,7 +216,7 @@ void PokeGen::PokeMod::MapWarp::setToMap(const unsigned t) throw(BoundsException toWarp = UINT_MAX; } -void PokeGen::PokeMod::MapWarp::setToWarp(const unsigned t) throw(BoundsException) +void PokeMod::MapWarp::setToWarp(const unsigned t) throw(BoundsException) { if (pokemod.getMapByID(toMap) == UINT_MAX) throw(BoundsException("MapWarp", "toMap")); @@ -224,111 +224,111 @@ void PokeGen::PokeMod::MapWarp::setToWarp(const unsigned t) throw(BoundsExceptio throw(BoundsException("MapWarp", "toWarp")); } -void PokeGen::PokeMod::MapWarp::setWorkingFlag(const unsigned f, const unsigned s) +void PokeMod::MapWarp::setWorkingFlag(const unsigned f, const unsigned s) { workingFlag.set(f, s); } -void PokeGen::PokeMod::MapWarp::setWorkingFlagFlag(const unsigned f) +void PokeMod::MapWarp::setWorkingFlagFlag(const unsigned f) { workingFlag.setFlag(f); } -void PokeGen::PokeMod::MapWarp::setWorkingFlagStatus(const unsigned s) +void PokeMod::MapWarp::setWorkingFlagStatus(const unsigned s) { workingFlag.setStatus(s); } -void PokeGen::PokeMod::MapWarp::setDialog(const unsigned d) throw(BoundsException) +void PokeMod::MapWarp::setDialog(const unsigned d) throw(BoundsException) { if (pokemod.getDialogByID(d) == UINT_MAX) throw(BoundsException("MapWarp", "dialog")); dialog = d; } -QString PokeGen::PokeMod::MapWarp::getName() const +QString PokeMod::MapWarp::getName() const { return name; } -PokeGen::Point PokeGen::PokeMod::MapWarp::getCoordinate() const +Point PokeMod::MapWarp::getCoordinate() const { return coordinate; } -unsigned PokeGen::PokeMod::MapWarp::getCoordinateX() const +unsigned PokeMod::MapWarp::getCoordinateX() const { return coordinate.getX(); } -unsigned PokeGen::PokeMod::MapWarp::getCoordinateY() const +unsigned PokeMod::MapWarp::getCoordinateY() const { return coordinate.getY(); } -bool PokeGen::PokeMod::MapWarp::getFrom(const unsigned d) const throw(BoundsException) +bool PokeMod::MapWarp::getFrom(const unsigned d) const throw(BoundsException) { if (D_End <= d) throw(BoundsException("MapWarp", "direction")); return from[d]; } -unsigned PokeGen::PokeMod::MapWarp::getDirectionOut() const +unsigned PokeMod::MapWarp::getDirectionOut() const { return directionOut; } -unsigned PokeGen::PokeMod::MapWarp::getWarpType() const +unsigned PokeMod::MapWarp::getWarpType() const { return warpType; } -bool PokeGen::PokeMod::MapWarp::getIsBiking() const +bool PokeMod::MapWarp::getIsBiking() const { return isBiking; } -bool PokeGen::PokeMod::MapWarp::getIsFlash() const +bool PokeMod::MapWarp::getIsFlash() const { return isFlash; } -bool PokeGen::PokeMod::MapWarp::getIsFoggy() const +bool PokeMod::MapWarp::getIsFoggy() const { return isFoggy; } -unsigned PokeGen::PokeMod::MapWarp::getToMap() const +unsigned PokeMod::MapWarp::getToMap() const { return toMap; } -unsigned PokeGen::PokeMod::MapWarp::getToWarp() const +unsigned PokeMod::MapWarp::getToWarp() const { return toWarp; } -PokeGen::Flag PokeGen::PokeMod::MapWarp::getWorkingFlag() const +Flag PokeMod::MapWarp::getWorkingFlag() const { return workingFlag; } -unsigned PokeGen::PokeMod::MapWarp::getWorkingFlagFlag() const +unsigned PokeMod::MapWarp::getWorkingFlagFlag() const { return workingFlag.getFlag(); } -unsigned PokeGen::PokeMod::MapWarp::getWorkingFlagStatus() const +unsigned PokeMod::MapWarp::getWorkingFlagStatus() const { return workingFlag.getStatus(); } -unsigned PokeGen::PokeMod::MapWarp::getDialog() const +unsigned PokeMod::MapWarp::getDialog() const { return dialog; } -PokeGen::PokeMod::MapWarp& PokeGen::PokeMod::MapWarp::operator=(const MapWarp& rhs) +PokeMod::MapWarp& PokeMod::MapWarp::operator=(const MapWarp& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/MapWarp.h b/pokemod/MapWarp.h index 97614d5b..1eff57f0 100644 --- a/pokemod/MapWarp.h +++ b/pokemod/MapWarp.h @@ -31,82 +31,79 @@ #include "Dialog.h" #include "Map.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class MapWarp : public Object { - class MapWarp : public Object - { - public: - enum - { - DoorStair = 0, - WarpPad = 1, - Hole = 2, - Boundary = 3, - End = 4 - }; - static const char* TypeStr[End]; - - 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; - unsigned getCoordinateX() const; - unsigned getCoordinateY() 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 getWorkingFlagFlag() const; - unsigned getWorkingFlagStatus() 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 char* TypeStr[End]; + + 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; + unsigned getCoordinateX() const; + unsigned getCoordinateY() 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 getWorkingFlagFlag() const; + unsigned getWorkingFlagStatus() 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 79a51633..44f7f42b 100644 --- a/pokemod/MapWildList.cpp +++ b/pokemod/MapWildList.cpp @@ -22,9 +22,9 @@ #include "MapWildList.h" -const char* PokeGen::PokeMod::MapWildList::ControlStr[PokeGen::PokeMod::MapWildList::End] = {"Grass", "Surfing", "Fishing", "Dive", "Headbutt", "Rock Smash"}; +const char* PokeMod::MapWildList::ControlStr[PokeMod::MapWildList::End] = {"Grass", "Surfing", "Fishing", "Dive", "Headbutt", "Rock Smash"}; -PokeGen::PokeMod::MapWildList::MapWildList(const Pokemod& par, const unsigned _id) : +PokeMod::MapWildList::MapWildList(const Pokemod& par, const unsigned _id) : Object(par, _id), control(UINT_MAX), value(INT_MAX), @@ -32,19 +32,19 @@ PokeGen::PokeMod::MapWildList::MapWildList(const Pokemod& par, const unsigned _i { } -PokeGen::PokeMod::MapWildList::MapWildList(const Pokemod& par, const MapWildList& w, const unsigned _id) : +PokeMod::MapWildList::MapWildList(const Pokemod& par, const MapWildList& w, const unsigned _id) : Object(par, _id) { *this = w; } -PokeGen::PokeMod::MapWildList::MapWildList(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::MapWildList::MapWildList(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::MapWildList::validate() const +bool PokeMod::MapWildList::validate() const { bool valid = true; pokemod.validationMsg(QString("------Wild List with id %1---").arg(id), Pokemod::V_Msg); @@ -108,7 +108,7 @@ bool PokeGen::PokeMod::MapWildList::validate() const return valid; } -unsigned PokeGen::PokeMod::MapWildList::getNewId() const +unsigned PokeMod::MapWildList::getNewId() const { unsigned i = 0; for (; (i < getPokemonCount()) && (getPokemonByID(i) != UINT_MAX); ++i) @@ -116,7 +116,7 @@ unsigned PokeGen::PokeMod::MapWildList::getNewId() const return i; } -void PokeGen::PokeMod::MapWildList::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::MapWildList::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -147,7 +147,7 @@ void PokeGen::PokeMod::MapWildList::load(const QString& fname, const unsigned _i } } -void PokeGen::PokeMod::MapWildList::save(const QString& map) const throw(Exception) +void PokeMod::MapWildList::save(const QString& map) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -162,19 +162,19 @@ void PokeGen::PokeMod::MapWildList::save(const QString& map) const throw(Excepti i.next().save(map, id); } -void PokeGen::PokeMod::MapWildList::setControl(const unsigned c) throw(BoundsException) +void PokeMod::MapWildList::setControl(const unsigned c) throw(BoundsException) { if (End <= c) throw(BoundsException("MapWildList", "control")); control = c; } -void PokeGen::PokeMod::MapWildList::setValue(const unsigned v) +void PokeMod::MapWildList::setValue(const unsigned v) { value = v; } -void PokeGen::PokeMod::MapWildList::setTime(const unsigned ts, const bool t) throw(Exception) +void PokeMod::MapWildList::setTime(const unsigned ts, const bool t) throw(Exception) { for (QMutableListIterator<unsigned> i(times); i.hasNext(); ) { @@ -191,22 +191,22 @@ void PokeGen::PokeMod::MapWildList::setTime(const unsigned ts, const bool t) thr times.append(ts); } -void PokeGen::PokeMod::MapWildList::setScope(const unsigned s) +void PokeMod::MapWildList::setScope(const unsigned s) { scope = s; } -unsigned PokeGen::PokeMod::MapWildList::getControl() const +unsigned PokeMod::MapWildList::getControl() const { return control; } -int PokeGen::PokeMod::MapWildList::getValue() const +int PokeMod::MapWildList::getValue() const { return value; } -bool PokeGen::PokeMod::MapWildList::getTime(const unsigned ts) const +bool PokeMod::MapWildList::getTime(const unsigned ts) const { for (QListIterator<unsigned> i(times); i.hasNext(); ) { @@ -216,26 +216,26 @@ bool PokeGen::PokeMod::MapWildList::getTime(const unsigned ts) const return false; } -int PokeGen::PokeMod::MapWildList::getScope() const +int PokeMod::MapWildList::getScope() const { return scope; } -const PokeGen::PokeMod::MapWildListPokemon& PokeGen::PokeMod::MapWildList::getPokemon(const unsigned i) const throw(IndexException) +const PokeMod::MapWildListPokemon& PokeMod::MapWildList::getPokemon(const unsigned i) const throw(IndexException) { if (getPokemonCount() <= i) throw(IndexException("MapWildList")); return pokemon.at(i); } -PokeGen::PokeMod::MapWildListPokemon& PokeGen::PokeMod::MapWildList::getPokemon(const unsigned i) throw(IndexException) +PokeMod::MapWildListPokemon& PokeMod::MapWildList::getPokemon(const unsigned i) throw(IndexException) { if (getPokemonCount() <= i) throw(IndexException("MapWildList")); return pokemon[i]; } -unsigned PokeGen::PokeMod::MapWildList::getPokemonByID(const unsigned _id) const +unsigned PokeMod::MapWildList::getPokemonByID(const unsigned _id) const { for (unsigned i = 0; i < getPokemonCount(); ++i) { @@ -245,37 +245,37 @@ unsigned PokeGen::PokeMod::MapWildList::getPokemonByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::MapWildList::getPokemonCount() const +unsigned PokeMod::MapWildList::getPokemonCount() const { return pokemon.size(); } -PokeGen::PokeMod::MapWildListPokemon& PokeGen::PokeMod::MapWildList::newPokemon() +PokeMod::MapWildListPokemon& PokeMod::MapWildList::newPokemon() { pokemon.append(MapWildListPokemon(pokemod, getNewId())); return pokemon[getPokemonCount() - 1]; } -PokeGen::PokeMod::MapWildListPokemon& PokeGen::PokeMod::MapWildList::newPokemon(const QString& fname) +PokeMod::MapWildListPokemon& PokeMod::MapWildList::newPokemon(const QString& fname) { pokemon.append(MapWildListPokemon(pokemod, fname, getNewId())); return pokemon[getPokemonCount() - 1]; } -PokeGen::PokeMod::MapWildListPokemon& PokeGen::PokeMod::MapWildList::newPokemon(const MapWildListPokemon& p) +PokeMod::MapWildListPokemon& PokeMod::MapWildList::newPokemon(const MapWildListPokemon& p) { pokemon.append(MapWildListPokemon(pokemod, p, getNewId())); return pokemon[getPokemonCount() - 1]; } -void PokeGen::PokeMod::MapWildList::deletePokemon(const unsigned i) throw(IndexException) +void PokeMod::MapWildList::deletePokemon(const unsigned i) throw(IndexException) { if (getPokemonCount() <= i) throw(IndexException("MapWildList")); pokemon.removeAt(i); } -PokeGen::PokeMod::MapWildList& PokeGen::PokeMod::MapWildList::operator=(const MapWildList& rhs) +PokeMod::MapWildList& PokeMod::MapWildList::operator=(const MapWildList& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/MapWildList.h b/pokemod/MapWildList.h index e0fdca18..d8c8f35a 100644 --- a/pokemod/MapWildList.h +++ b/pokemod/MapWildList.h @@ -39,64 +39,61 @@ #include "ItemEffect.h" #include "MapWildListPokemon.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class MapWildList : public Object { - class MapWildList : public Object - { - public: - enum - { - Grass = 0, - Surfing = 1, - Fishing = 2, - Dive = 3, - Headbutt = 4, - RockSmash = 5, - End = 6 - }; - static const char* ControlStr[End]; - - 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 MapWildListPokemon& getPokemon(const unsigned i) const throw(IndexException); - MapWildListPokemon& getPokemon(const unsigned i) throw(IndexException); - unsigned getPokemonByID(const unsigned _id) const; - unsigned getPokemonCount() const; - MapWildListPokemon& newPokemon(); - MapWildListPokemon& newPokemon(const QString& fname); - MapWildListPokemon& newPokemon(const MapWildListPokemon& w); - void deletePokemon(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<MapWildListPokemon> pokemon; - }; - } + public: + enum + { + Grass = 0, + Surfing = 1, + Fishing = 2, + Dive = 3, + Headbutt = 4, + RockSmash = 5, + End = 6 + }; + static const char* ControlStr[End]; + + 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 MapWildListPokemon& getPokemon(const unsigned i) const throw(IndexException); + MapWildListPokemon& getPokemon(const unsigned i) throw(IndexException); + unsigned getPokemonByID(const unsigned _id) const; + unsigned getPokemonCount() const; + MapWildListPokemon& newPokemon(); + MapWildListPokemon& newPokemon(const QString& fname); + MapWildListPokemon& newPokemon(const MapWildListPokemon& w); + void deletePokemon(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<MapWildListPokemon> pokemon; + }; } #endif diff --git a/pokemod/MapWildListPokemon.cpp b/pokemod/MapWildListPokemon.cpp index 23ac9625..046c18c3 100644 --- a/pokemod/MapWildListPokemon.cpp +++ b/pokemod/MapWildListPokemon.cpp @@ -22,7 +22,7 @@ #include "MapWildListPokemon.h" -PokeGen::PokeMod::MapWildListPokemon::MapWildListPokemon(const Pokemod& par, const unsigned _id) : +PokeMod::MapWildListPokemon::MapWildListPokemon(const Pokemod& par, const unsigned _id) : Object(par, _id), species(UINT_MAX), level(1), @@ -30,19 +30,19 @@ PokeGen::PokeMod::MapWildListPokemon::MapWildListPokemon(const Pokemod& par, con { } -PokeGen::PokeMod::MapWildListPokemon::MapWildListPokemon(const Pokemod& par, const MapWildListPokemon& p, const unsigned _id) : +PokeMod::MapWildListPokemon::MapWildListPokemon(const Pokemod& par, const MapWildListPokemon& p, const unsigned _id) : Object(par, _id) { *this = p; } -PokeGen::PokeMod::MapWildListPokemon::MapWildListPokemon(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::MapWildListPokemon::MapWildListPokemon(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::MapWildListPokemon::validate() const +bool PokeMod::MapWildListPokemon::validate() const { bool valid = true; pokemod.validationMsg(QString("---------Pokémon with id %1---").arg(id), Pokemod::V_Msg); @@ -64,7 +64,7 @@ bool PokeGen::PokeMod::MapWildListPokemon::validate() const return valid; } -void PokeGen::PokeMod::MapWildListPokemon::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::MapWildListPokemon::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -76,7 +76,7 @@ void PokeGen::PokeMod::MapWildListPokemon::load(const QString& fname, const unsi ini.getValue("weight", weight, 1); } -void PokeGen::PokeMod::MapWildListPokemon::save(const QString& map, const unsigned listId) const throw(Exception) +void PokeMod::MapWildListPokemon::save(const QString& map, const unsigned listId) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -86,43 +86,43 @@ void PokeGen::PokeMod::MapWildListPokemon::save(const QString& map, const unsign ini.save(QString("%1/map/%2/wildlist/%3/pokemon/%4.pini").arg(pokemod.getPath()).arg(map).arg(listId).arg(id)); } -void PokeGen::PokeMod::MapWildListPokemon::setSpecies(const unsigned s) throw(BoundsException) +void PokeMod::MapWildListPokemon::setSpecies(const unsigned s) throw(BoundsException) { if (pokemod.getSpeciesByID(s) == UINT_MAX) throw(BoundsException("MapWildListPokemon", "species")); species = s; } -void PokeGen::PokeMod::MapWildListPokemon::setLevel(const unsigned l) throw(BoundsException) +void PokeMod::MapWildListPokemon::setLevel(const unsigned l) throw(BoundsException) { if (!level || (pokemod.getRules().getMaxLevel() <= level)) throw(BoundsException("MapWildListPokemon", "level")); level = l; } -void PokeGen::PokeMod::MapWildListPokemon::setWeight(const unsigned w) throw(BoundsException) +void PokeMod::MapWildListPokemon::setWeight(const unsigned w) throw(BoundsException) { if (!w) throw(BoundsException("MapWildListPokemon", "weight")); weight = w; } -unsigned PokeGen::PokeMod::MapWildListPokemon::getSpecies() const +unsigned PokeMod::MapWildListPokemon::getSpecies() const { return species; } -unsigned PokeGen::PokeMod::MapWildListPokemon::getLevel() const +unsigned PokeMod::MapWildListPokemon::getLevel() const { return level; } -unsigned PokeGen::PokeMod::MapWildListPokemon::getWeight() const +unsigned PokeMod::MapWildListPokemon::getWeight() const { return weight; } -PokeGen::PokeMod::MapWildListPokemon& PokeGen::PokeMod::MapWildListPokemon::operator=(const MapWildListPokemon& rhs) +PokeMod::MapWildListPokemon& PokeMod::MapWildListPokemon::operator=(const MapWildListPokemon& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/MapWildListPokemon.h b/pokemod/MapWildListPokemon.h index e846994a..cb367b83 100644 --- a/pokemod/MapWildListPokemon.h +++ b/pokemod/MapWildListPokemon.h @@ -29,37 +29,34 @@ #include "Pokemod.h" #include "Species.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class MapWildListPokemon: public Object { - class MapWildListPokemon: public Object - { - public: - MapWildListPokemon(const Pokemod& par, const unsigned _id); - MapWildListPokemon(const Pokemod& par, const MapWildListPokemon& p, const unsigned _id); - MapWildListPokemon(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; - - MapWildListPokemon& operator=(const MapWildListPokemon& rhs); - private: - bool validate() const; - - unsigned species; - unsigned level; - unsigned weight; - }; - } + public: + MapWildListPokemon(const Pokemod& par, const unsigned _id); + MapWildListPokemon(const Pokemod& par, const MapWildListPokemon& p, const unsigned _id); + MapWildListPokemon(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; + + MapWildListPokemon& operator=(const MapWildListPokemon& rhs); + private: + bool validate() const; + + unsigned species; + unsigned level; + unsigned weight; + }; } #endif diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp index 4e67f4cf..b31ac792 100644 --- a/pokemod/Move.cpp +++ b/pokemod/Move.cpp @@ -22,10 +22,10 @@ #include "Move.h" -const char* PokeGen::PokeMod::Move::TargetStr[PokeGen::PokeMod::Move::T_End] = {"Player", "Enemy", "Both", "Random"}; -const char* PokeGen::PokeMod::Move::ChoiceStr[PokeGen::PokeMod::Move::C_End] = {"Player", "Enemy", "Random"}; +const char* PokeMod::Move::TargetStr[PokeMod::Move::T_End] = {"Player", "Enemy", "Both", "Random"}; +const char* PokeMod::Move::ChoiceStr[PokeMod::Move::C_End] = {"Player", "Enemy", "Random"}; -PokeGen::PokeMod::Move::Move(const Pokemod& par, const unsigned _id) : +PokeMod::Move::Move(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), accuracy(1, 1), @@ -44,19 +44,19 @@ PokeGen::PokeMod::Move::Move(const Pokemod& par, const unsigned _id) : { } -PokeGen::PokeMod::Move::Move(const Pokemod& par, const Move& m, const unsigned _id) : +PokeMod::Move::Move(const Pokemod& par, const Move& m, const unsigned _id) : Object(par, _id) { *this = m; } -PokeGen::PokeMod::Move::Move(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::Move::Move(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::Move::validate() const +bool PokeMod::Move::validate() const { bool valid = true; pokemod.validationMsg(QString("---Move \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -116,7 +116,7 @@ bool PokeGen::PokeMod::Move::validate() const return valid; } -unsigned PokeGen::PokeMod::Move::getNewId() const +unsigned PokeMod::Move::getNewId() const { unsigned i = 0; for (; (i < getEffectCount()) && (getEffectByID(i) != UINT_MAX); ++i) @@ -124,7 +124,7 @@ unsigned PokeGen::PokeMod::Move::getNewId() const return i; } -void PokeGen::PokeMod::Move::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::Move::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -161,7 +161,7 @@ void PokeGen::PokeMod::Move::load(const QString& fname, const unsigned _id) thro } } -void PokeGen::PokeMod::Move::save() const throw(Exception) +void PokeMod::Move::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -186,186 +186,186 @@ void PokeGen::PokeMod::Move::save() const throw(Exception) i.next().save(name); } -void PokeGen::PokeMod::Move::setName(const QString& n) +void PokeMod::Move::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::Move::setAccuracy(const unsigned n, const unsigned d) throw(Exception) +void PokeMod::Move::setAccuracy(const unsigned n, const unsigned d) throw(Exception) { accuracy.set(n, d); } -void PokeGen::PokeMod::Move::setAccuracyNum(const unsigned n) throw(Exception) +void PokeMod::Move::setAccuracyNum(const unsigned n) throw(Exception) { accuracy.setNum(n); } -void PokeGen::PokeMod::Move::setAccuracyDenom(const unsigned d) throw(Exception) +void PokeMod::Move::setAccuracyDenom(const unsigned d) throw(Exception) { accuracy.setDenom(d); } -void PokeGen::PokeMod::Move::setType(const unsigned t) throw(BoundsException) +void PokeMod::Move::setType(const unsigned t) throw(BoundsException) { if (pokemod.getTypeByID(t) == UINT_MAX) throw(BoundsException("Move", "type")); type = t; } -void PokeGen::PokeMod::Move::setSpecial(const bool s) +void PokeMod::Move::setSpecial(const bool s) { special = s; } -void PokeGen::PokeMod::Move::setPowerPoints(const unsigned p) throw(BoundsException) +void PokeMod::Move::setPowerPoints(const unsigned p) throw(BoundsException) { if (!p) throw(BoundsException("Move", "powerPoints")); powerPoints = p; } -void PokeGen::PokeMod::Move::setTarget(const unsigned t) throw(BoundsException) +void PokeMod::Move::setTarget(const unsigned t) throw(BoundsException) { if (T_End <= t) throw(BoundsException("Move", "target")); target = t; } -void PokeGen::PokeMod::Move::setNumTargets(const unsigned n) throw(BoundsException) +void PokeMod::Move::setNumTargets(const unsigned n) throw(BoundsException) { if (!n || ((pokemod.getRules().getMaxFight() << 1) < n)) throw(BoundsException("Move", "numTargets")); numTargets = n; } -void PokeGen::PokeMod::Move::setTargetChoice(const unsigned t) throw(BoundsException) +void PokeMod::Move::setTargetChoice(const unsigned t) throw(BoundsException) { if (C_End <= t) throw(BoundsException("Move", "targetChoice")); targetChoice = t; } -void PokeGen::PokeMod::Move::setIgnoreAccuracy(const bool i) +void PokeMod::Move::setIgnoreAccuracy(const bool i) { ignoreAccuracy = i; } -void PokeGen::PokeMod::Move::setCanFlinch(const bool c) +void PokeMod::Move::setCanFlinch(const bool c) { canFlinch = c; } -void PokeGen::PokeMod::Move::setCanRandom(const bool c) +void PokeMod::Move::setCanRandom(const bool c) { canRandom = c; } -void PokeGen::PokeMod::Move::setCanSnatch(const bool c) +void PokeMod::Move::setCanSnatch(const bool c) { canSnatch = c; } -void PokeGen::PokeMod::Move::setSound(const bool s) +void PokeMod::Move::setSound(const bool s) { sound = s; } -QString PokeGen::PokeMod::Move::getName() const +QString PokeMod::Move::getName() const { return name; } -PokeGen::Frac PokeGen::PokeMod::Move::getAccuracy() const +Frac PokeMod::Move::getAccuracy() const { return accuracy; } -unsigned PokeGen::PokeMod::Move::getAccuracyNum() const +unsigned PokeMod::Move::getAccuracyNum() const { return accuracy.getNum(); } -unsigned PokeGen::PokeMod::Move::getAccuracyDenom() const +unsigned PokeMod::Move::getAccuracyDenom() const { return accuracy.getDenom(); } -unsigned PokeGen::PokeMod::Move::getType() const +unsigned PokeMod::Move::getType() const { return type; } -bool PokeGen::PokeMod::Move::getSpecial() const +bool PokeMod::Move::getSpecial() const { return special; } -unsigned PokeGen::PokeMod::Move::getPowerPoints() const +unsigned PokeMod::Move::getPowerPoints() const { return powerPoints; } -unsigned PokeGen::PokeMod::Move::getTarget() const +unsigned PokeMod::Move::getTarget() const { return target; } -unsigned PokeGen::PokeMod::Move::getNumTargets() const +unsigned PokeMod::Move::getNumTargets() const { return numTargets; } -unsigned PokeGen::PokeMod::Move::getTargetChoice() const +unsigned PokeMod::Move::getTargetChoice() const { return targetChoice; } -bool PokeGen::PokeMod::Move::getIgnoreAccuracy() const +bool PokeMod::Move::getIgnoreAccuracy() const { return ignoreAccuracy; } -bool PokeGen::PokeMod::Move::getCanFlinch() const +bool PokeMod::Move::getCanFlinch() const { return canFlinch; } -bool PokeGen::PokeMod::Move::getCanRandom() const +bool PokeMod::Move::getCanRandom() const { return canRandom; } -bool PokeGen::PokeMod::Move::getCanSnatch() const +bool PokeMod::Move::getCanSnatch() const { return canSnatch; } -bool PokeGen::PokeMod::Move::getSound() const +bool PokeMod::Move::getSound() const { return sound; } -QString PokeGen::PokeMod::Move::getDescription() const +QString PokeMod::Move::getDescription() const { return description; } -const PokeGen::PokeMod::MoveEffect& PokeGen::PokeMod::Move::getEffect(const unsigned i) const throw(IndexException) +const PokeMod::MoveEffect& PokeMod::Move::getEffect(const unsigned i) const throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Move")); return effects.at(i); } -PokeGen::PokeMod::MoveEffect& PokeGen::PokeMod::Move::getEffect(const unsigned i) throw(IndexException) +PokeMod::MoveEffect& PokeMod::Move::getEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Move")); return effects[i]; } -unsigned PokeGen::PokeMod::Move::getEffectByID(const unsigned _id) const +unsigned PokeMod::Move::getEffectByID(const unsigned _id) const { for (unsigned i = 0; i < getEffectCount(); ++i) { @@ -375,37 +375,37 @@ unsigned PokeGen::PokeMod::Move::getEffectByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Move::getEffectCount() const +unsigned PokeMod::Move::getEffectCount() const { return effects.size(); } -PokeGen::PokeMod::MoveEffect& PokeGen::PokeMod::Move::newEffect() +PokeMod::MoveEffect& PokeMod::Move::newEffect() { effects.append(MoveEffect(pokemod, getNewId())); return effects[getEffectCount() - 1]; } -PokeGen::PokeMod::MoveEffect& PokeGen::PokeMod::Move::newEffect(const QString& fname) +PokeMod::MoveEffect& PokeMod::Move::newEffect(const QString& fname) { effects.append(MoveEffect(pokemod, fname, getNewId())); return effects[getEffectCount() - 1]; } -PokeGen::PokeMod::MoveEffect& PokeGen::PokeMod::Move::newEffect(const MoveEffect& e) +PokeMod::MoveEffect& PokeMod::Move::newEffect(const MoveEffect& e) { effects.append(MoveEffect(pokemod, e, getNewId())); return effects[getEffectCount() - 1]; } -void PokeGen::PokeMod::Move::deleteEffect(const unsigned i) throw(IndexException) +void PokeMod::Move::deleteEffect(const unsigned i) throw(IndexException) { if (getEffectCount() <= i) throw(IndexException("Move")); effects.removeAt(i); } -PokeGen::PokeMod::Move& PokeGen::PokeMod::Move::operator=(const Move& rhs) +PokeMod::Move& PokeMod::Move::operator=(const Move& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Move.h b/pokemod/Move.h index 72baa331..3d3ce88b 100644 --- a/pokemod/Move.h +++ b/pokemod/Move.h @@ -35,106 +35,103 @@ #include "Object.h" #include "MoveEffect.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class Move : public Object { - class Move : public Object - { - public: - enum Target - { - T_Player = 0, - T_Enemy = 1, - T_Both = 2, - T_Random = 3, - T_End = 4 - }; - static const char* TargetStr[T_End]; - - enum Choice - { - C_Player = 0, - C_Enemy = 1, - C_Random = 2, - C_End = 3 - }; - static const char* ChoiceStr[C_End]; - - 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 getAccuracyNum() const; - unsigned getAccuracyDenom() 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); - unsigned getEffectByID(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 char* TargetStr[T_End]; + + enum Choice + { + C_Player = 0, + C_Enemy = 1, + C_Random = 2, + C_End = 3 + }; + static const char* ChoiceStr[C_End]; + + 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 getAccuracyNum() const; + unsigned getAccuracyDenom() 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); + unsigned getEffectByID(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 edae397f..297e3344 100644 --- a/pokemod/MoveEffect.cpp +++ b/pokemod/MoveEffect.cpp @@ -22,9 +22,9 @@ #include "MoveEffect.h" -const char* PokeGen::PokeMod::MoveEffect::EffectStr[PokeGen::PokeMod::MoveEffect::E_End_Overworld] = {"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 char* PokeMod::MoveEffect::EffectStr[PokeMod::MoveEffect::E_End_Overworld] = {"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"}; -PokeGen::PokeMod::MoveEffect::MoveEffect(const Pokemod& par, const unsigned _id) : +PokeMod::MoveEffect::MoveEffect(const Pokemod& par, const unsigned _id) : Object(par, _id), chance(1, 1), effect(UINT_MAX), @@ -35,19 +35,19 @@ PokeGen::PokeMod::MoveEffect::MoveEffect(const Pokemod& par, const unsigned _id) { } -PokeGen::PokeMod::MoveEffect::MoveEffect(const Pokemod& par, const MoveEffect& e, const unsigned _id) : +PokeMod::MoveEffect::MoveEffect(const Pokemod& par, const MoveEffect& e, const unsigned _id) : Object(par, _id) { *this = e; } -PokeGen::PokeMod::MoveEffect::MoveEffect(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::MoveEffect::MoveEffect(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::MoveEffect::validate() const +bool PokeMod::MoveEffect::validate() const { bool valid = true; pokemod.validationMsg(QString("------Effect with id %1---").arg(id), Pokemod::V_Msg); @@ -55,7 +55,7 @@ bool PokeGen::PokeMod::MoveEffect::validate() const return valid; } -void PokeGen::PokeMod::MoveEffect::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::MoveEffect::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -78,7 +78,7 @@ void PokeGen::PokeMod::MoveEffect::load(const QString& fname, const unsigned _id val4.set(i, j, k); } -void PokeGen::PokeMod::MoveEffect::save(const QString& move) const throw(Exception) +void PokeMod::MoveEffect::save(const QString& move) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -94,22 +94,22 @@ void PokeGen::PokeMod::MoveEffect::save(const QString& move) const throw(Excepti ini.save(QString("%1/move/%2/effect/%3.pini").arg(pokemod.getPath()).arg(move).arg(id)); } -void PokeGen::PokeMod::MoveEffect::setChance(const unsigned n, const unsigned d) throw(Exception) +void PokeMod::MoveEffect::setChance(const unsigned n, const unsigned d) throw(Exception) { chance.set(n, d); } -void PokeGen::PokeMod::MoveEffect::setChanceNum(const unsigned n) throw(Exception) +void PokeMod::MoveEffect::setChanceNum(const unsigned n) throw(Exception) { chance.setNum(n); } -void PokeGen::PokeMod::MoveEffect::setChanceDenom(const unsigned d) throw(Exception) +void PokeMod::MoveEffect::setChanceDenom(const unsigned d) throw(Exception) { chance.setDenom(d); } -void PokeGen::PokeMod::MoveEffect::setEffect(const unsigned e) throw(BoundsException) +void PokeMod::MoveEffect::setEffect(const unsigned e) throw(BoundsException) { if (E_End <= e) throw(BoundsException("MoveEffect", "effect")); @@ -120,7 +120,7 @@ void PokeGen::PokeMod::MoveEffect::setEffect(const unsigned e) throw(BoundsExcep 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 PokeGen::PokeMod::MoveEffect::setVal1(const unsigned v1) throw(Exception) +void PokeMod::MoveEffect::setVal1(const unsigned v1) throw(Exception) { switch (effect) { @@ -153,7 +153,7 @@ void PokeGen::PokeMod::MoveEffect::setVal1(const unsigned v1) throw(Exception) val1 = v1; } -void PokeGen::PokeMod::MoveEffect::setVal2(const unsigned v2) throw(Exception) +void PokeMod::MoveEffect::setVal2(const unsigned v2) throw(Exception) { switch (effect) { @@ -168,7 +168,7 @@ void PokeGen::PokeMod::MoveEffect::setVal2(const unsigned v2) throw(Exception) val2 = v2; } -void PokeGen::PokeMod::MoveEffect::setVal3(const int v3) +void PokeMod::MoveEffect::setVal3(const int v3) { switch (effect) { @@ -179,72 +179,72 @@ void PokeGen::PokeMod::MoveEffect::setVal3(const int v3) val3 = v3; } -void PokeGen::PokeMod::MoveEffect::setVal4(const unsigned n, const unsigned d) throw(Exception) +void PokeMod::MoveEffect::setVal4(const unsigned n, const unsigned d) throw(Exception) { val4.set(n, d); } -void PokeGen::PokeMod::MoveEffect::setVal4Num(const unsigned n) throw(Exception) +void PokeMod::MoveEffect::setVal4Num(const unsigned n) throw(Exception) { val4.setNum(n); } -void PokeGen::PokeMod::MoveEffect::setVal4Denom(const unsigned d) throw(Exception) +void PokeMod::MoveEffect::setVal4Denom(const unsigned d) throw(Exception) { val4.setDenom(d); } -PokeGen::Frac PokeGen::PokeMod::MoveEffect::getChance() const +Frac PokeMod::MoveEffect::getChance() const { return chance; } -unsigned PokeGen::PokeMod::MoveEffect::getChanceNum() const +unsigned PokeMod::MoveEffect::getChanceNum() const { return chance.getNum(); } -unsigned PokeGen::PokeMod::MoveEffect::getChanceDenom() const +unsigned PokeMod::MoveEffect::getChanceDenom() const { return chance.getDenom(); } -unsigned PokeGen::PokeMod::MoveEffect::getEffect() const +unsigned PokeMod::MoveEffect::getEffect() const { return effect; } -unsigned PokeGen::PokeMod::MoveEffect::getVal1() const +unsigned PokeMod::MoveEffect::getVal1() const { return val1; } -unsigned PokeGen::PokeMod::MoveEffect::getVal2() const +unsigned PokeMod::MoveEffect::getVal2() const { return val2; } -int PokeGen::PokeMod::MoveEffect::getVal3() const +int PokeMod::MoveEffect::getVal3() const { return val3; } -PokeGen::Frac PokeGen::PokeMod::MoveEffect::getVal4() const +Frac PokeMod::MoveEffect::getVal4() const { return val4; } -unsigned PokeGen::PokeMod::MoveEffect::getVal4Num() const +unsigned PokeMod::MoveEffect::getVal4Num() const { return val4.getNum(); } -unsigned PokeGen::PokeMod::MoveEffect::getVal4Denom() const +unsigned PokeMod::MoveEffect::getVal4Denom() const { return val4.getDenom(); } -PokeGen::PokeMod::MoveEffect& PokeGen::PokeMod::MoveEffect::operator=(const MoveEffect& rhs) +PokeMod::MoveEffect& PokeMod::MoveEffect::operator=(const MoveEffect& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/MoveEffect.h b/pokemod/MoveEffect.h index bfea2b26..444853ff 100644 --- a/pokemod/MoveEffect.h +++ b/pokemod/MoveEffect.h @@ -30,131 +30,128 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class MoveEffect : public Object { - 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 char* EffectStr[E_End_Overworld]; - - enum Damage - { - D_Fixed = 0, - D_FixedRange = 1, - D_Relative = 2, - D_RelativeRange = 3, - D_Level = 4, - D_End = 5 - }; - static const char* DamageStr[D_End]; - - enum MoveType - { - MT_Physical = 0, - MT_Special = 1, - MT_End = 2 - }; - static const char* MoveTypeStr[MT_End]; - - enum Recoil - { - R_Hit = 0, - R_Miss = 1, - R_End = 2 - }; - static const char* RecoilStr[R_End]; - - 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 getChanceNum() const; - unsigned getChanceDenom() const; - unsigned getEffect() const; - unsigned getVal1() const; - unsigned getVal2() const; - int getVal3() const; - Frac getVal4() const; - unsigned getVal4Num() const; - unsigned getVal4Denom() 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 char* EffectStr[E_End_Overworld]; + + enum Damage + { + D_Fixed = 0, + D_FixedRange = 1, + D_Relative = 2, + D_RelativeRange = 3, + D_Level = 4, + D_End = 5 + }; + static const char* DamageStr[D_End]; + + enum MoveType + { + MT_Physical = 0, + MT_Special = 1, + MT_End = 2 + }; + static const char* MoveTypeStr[MT_End]; + + enum Recoil + { + R_Hit = 0, + R_Miss = 1, + R_End = 2 + }; + static const char* RecoilStr[R_End]; + + 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 getChanceNum() const; + unsigned getChanceDenom() const; + unsigned getEffect() const; + unsigned getVal1() const; + unsigned getVal2() const; + int getVal3() const; + Frac getVal4() const; + unsigned getVal4Num() const; + unsigned getVal4Denom() 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 6266452c..33255efb 100644 --- a/pokemod/Nature.cpp +++ b/pokemod/Nature.cpp @@ -22,7 +22,7 @@ #include "Nature.h" -PokeGen::PokeMod::Nature::Nature(const Pokemod& par, const unsigned _id) : +PokeMod::Nature::Nature(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), weight(1) @@ -31,19 +31,19 @@ PokeGen::PokeMod::Nature::Nature(const Pokemod& par, const unsigned _id) : stats[i].set(1, 1, Frac::Improper); } -PokeGen::PokeMod::Nature::Nature(const Pokemod& par, const Nature& n, const unsigned _id) : +PokeMod::Nature::Nature(const Pokemod& par, const Nature& n, const unsigned _id) : Object(par, _id) { *this = n; } -PokeGen::PokeMod::Nature::Nature(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::Nature::Nature(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::Nature::validate() const +bool PokeMod::Nature::validate() const { bool valid = true; pokemod.validationMsg(QString("---Nature \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -60,7 +60,7 @@ bool PokeGen::PokeMod::Nature::validate() const return valid; } -void PokeGen::PokeMod::Nature::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::Nature::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -79,7 +79,7 @@ void PokeGen::PokeMod::Nature::load(const QString& fname, const unsigned _id) th ini.getValue("weight", weight); } -void PokeGen::PokeMod::Nature::save() const throw(Exception) +void PokeMod::Nature::save() const throw(Exception) { Ini ini; ini.addField("name", name); @@ -92,71 +92,71 @@ void PokeGen::PokeMod::Nature::save() const throw(Exception) ini.save(QString("%1/nature/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeGen::PokeMod::Nature::setName(const QString& n) +void PokeMod::Nature::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::Nature::setStat(const unsigned s, const unsigned n, const unsigned d) throw(Exception) +void PokeMod::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 PokeGen::PokeMod::Nature::setStatNum(const unsigned s, const unsigned n) throw(Exception) +void PokeMod::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 PokeGen::PokeMod::Nature::setStatDenom(const unsigned s, const unsigned d) throw(Exception) +void PokeMod::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 PokeGen::PokeMod::Nature::setWeight(const unsigned w) throw(BoundsException) +void PokeMod::Nature::setWeight(const unsigned w) throw(BoundsException) { if (!w) throw(BoundsException("Nature", "weight")); weight = w; } -QString PokeGen::PokeMod::Nature::getName() const +QString PokeMod::Nature::getName() const { return name; } -PokeGen::Frac PokeGen::PokeMod::Nature::getStat(const unsigned s) const throw(BoundsException) +Frac PokeMod::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 PokeGen::PokeMod::Nature::getStatNum(const unsigned s) const throw(BoundsException) +unsigned PokeMod::Nature::getStatNum(const unsigned s) const throw(BoundsException) { if ((pokemod.getRules().getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) throw(BoundsException("Nature", "stat")); return getStat(s).getNum(); } -unsigned PokeGen::PokeMod::Nature::getStatDenom(const unsigned s) const throw(BoundsException) +unsigned PokeMod::Nature::getStatDenom(const unsigned s) const throw(BoundsException) { if ((pokemod.getRules().getSpecialSplit() ? ST_End_GSC : ST_End_RBY) <= s) throw(BoundsException("Nature", "stat")); return getStat(s).getDenom(); } -unsigned PokeGen::PokeMod::Nature::getWeight() const +unsigned PokeMod::Nature::getWeight() const { return weight; } -PokeGen::PokeMod::Nature& PokeGen::PokeMod::Nature::operator=(const Nature& rhs) +PokeMod::Nature& PokeMod::Nature::operator=(const Nature& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Nature.h b/pokemod/Nature.h index 98e1bf4d..8c040c75 100644 --- a/pokemod/Nature.h +++ b/pokemod/Nature.h @@ -30,41 +30,38 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class Nature : public Object { - 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 getStatNum(const unsigned s) const throw(BoundsException); - unsigned getStatDenom(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 getStatNum(const unsigned s) const throw(BoundsException); + unsigned getStatDenom(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 4f579419..9ac559ad 100644 --- a/pokemod/Object.h +++ b/pokemod/Object.h @@ -26,45 +26,42 @@ #include <QFile> #include "../general/Ini.h" -namespace PokeGen +namespace PokeMod { - 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 1917bd02..645ef33d 100644 --- a/pokemod/Pokemod.cpp +++ b/pokemod/Pokemod.cpp @@ -22,7 +22,7 @@ #include "Pokemod.h" -PokeGen::PokeMod::Pokemod::Pokemod(const QString& fname) : +PokeMod::Pokemod::Pokemod(const QString& fname) : Object(*this, 0), valstream(NULL), title(""), @@ -41,7 +41,7 @@ PokeGen::PokeMod::Pokemod::Pokemod(const QString& fname) : load(fname); } -bool PokeGen::PokeMod::Pokemod::validate() const +bool PokeMod::Pokemod::validate() const { bool valid = true; validationMsg(QString("Pokemod \"%1\"").arg(title), V_Msg); @@ -610,12 +610,12 @@ bool PokeGen::PokeMod::Pokemod::validate() const return valid; } -QString PokeGen::PokeMod::Pokemod::getPath() const +QString PokeMod::Pokemod::getPath() const { return path; } -void PokeGen::PokeMod::Pokemod::load(const QString& fname) throw(Exception) +void PokeMod::Pokemod::load(const QString& fname) throw(Exception) { Ini ini(fname); QStringList fpath = fname.split('\\', QString::SkipEmptyParts).join("/").split('\\', QString::SkipEmptyParts); @@ -762,7 +762,7 @@ void PokeGen::PokeMod::Pokemod::load(const QString& fname) throw(Exception) } } -void PokeGen::PokeMod::Pokemod::save() const throw(Exception) +void PokeMod::Pokemod::save() const throw(Exception) { Ini ini; ini.addField("title", title); @@ -820,39 +820,39 @@ void PokeGen::PokeMod::Pokemod::save() const throw(Exception) i.next().save(); } -unsigned PokeGen::PokeMod::Pokemod::maxCompatability(const Pokemod& p) const +unsigned PokeMod::Pokemod::maxCompatability(const Pokemod& p) const { // TODO (Ben #1#): MaxCompatability between two versions } -void PokeGen::PokeMod::Pokemod::setTitle(const QString& t) +void PokeMod::Pokemod::setTitle(const QString& t) { title = t; } -void PokeGen::PokeMod::Pokemod::setVersion(const QString& v) +void PokeMod::Pokemod::setVersion(const QString& v) { version = v; } -void PokeGen::PokeMod::Pokemod::setDescription(const QString& d) +void PokeMod::Pokemod::setDescription(const QString& d) { description = d; } -void PokeGen::PokeMod::Pokemod::setStartMap(const unsigned s) throw(BoundsException) +void PokeMod::Pokemod::setStartMap(const unsigned s) throw(BoundsException) { if (getMapByID(s) == UINT_MAX) throw(BoundsException("Pokemod", "startMap")); startMap = s; } -void PokeGen::PokeMod::Pokemod::setStartMoney(const unsigned s) +void PokeMod::Pokemod::setStartMoney(const unsigned s) { startMoney = s; } -void PokeGen::PokeMod::Pokemod::setStartCoordinate(const unsigned x, const unsigned y) throw(BoundsException) +void PokeMod::Pokemod::setStartCoordinate(const unsigned x, const unsigned y) throw(BoundsException) { if (getMapByID(startMap) == UINT_MAX) throw(BoundsException("Pokemod", "startMap")); @@ -863,7 +863,7 @@ void PokeGen::PokeMod::Pokemod::setStartCoordinate(const unsigned x, const unsig startCoordinate.set(x, y); } -void PokeGen::PokeMod::Pokemod::setStartCoordinateX(const unsigned x) throw(BoundsException) +void PokeMod::Pokemod::setStartCoordinateX(const unsigned x) throw(BoundsException) { if (getMapByID(startMap) == UINT_MAX) throw(BoundsException("Pokemod", "startMap")); @@ -872,7 +872,7 @@ void PokeGen::PokeMod::Pokemod::setStartCoordinateX(const unsigned x) throw(Boun startCoordinate.setX(x); } -void PokeGen::PokeMod::Pokemod::setStartCoordinateY(const unsigned y) throw(BoundsException) +void PokeMod::Pokemod::setStartCoordinateY(const unsigned y) throw(BoundsException) { if (getMapByID(startMap) == UINT_MAX) throw(BoundsException("Pokemod", "startMap")); @@ -881,21 +881,21 @@ void PokeGen::PokeMod::Pokemod::setStartCoordinateY(const unsigned y) throw(Boun startCoordinate.setY(y); } -void PokeGen::PokeMod::Pokemod::setStartDirection(const unsigned s) throw(BoundsException) +void PokeMod::Pokemod::setStartDirection(const unsigned s) throw(BoundsException) { if (D_End <= s) throw(BoundsException("Pokemod", "startDirection")); startDirection = s; } -void PokeGen::PokeMod::Pokemod::setStartDialog(const unsigned s) throw(BoundsException) +void PokeMod::Pokemod::setStartDialog(const unsigned s) throw(BoundsException) { if (getDialogByID(s) == UINT_MAX) throw(BoundsException("Pokemod", "startDialog")); startDialog = s; } -void PokeGen::PokeMod::Pokemod::setWalkSkin(const QString& fname) throw(Exception) +void PokeMod::Pokemod::setWalkSkin(const QString& fname) throw(Exception) { QFile file(QString("%1/image/skin/walk.png").arg(getPath())); if (file.exists() && !file.remove()) @@ -904,7 +904,7 @@ void PokeGen::PokeMod::Pokemod::setWalkSkin(const QString& fname) throw(Exceptio throw(SaveException("Pokemod", file.fileName())); } -void PokeGen::PokeMod::Pokemod::setBikeSkin(const QString& fname) throw(Exception) +void PokeMod::Pokemod::setBikeSkin(const QString& fname) throw(Exception) { QFile file(QString("%1/image/skin/bike.png").arg(getPath())); if (file.exists() && !file.remove()) @@ -913,7 +913,7 @@ void PokeGen::PokeMod::Pokemod::setBikeSkin(const QString& fname) throw(Exceptio throw(SaveException("Pokemod", file.fileName())); } -void PokeGen::PokeMod::Pokemod::setSurfSkin(const QString& fname) throw(Exception) +void PokeMod::Pokemod::setSurfSkin(const QString& fname) throw(Exception) { QFile file(QString("%1/image/skin/surf.png").arg(getPath())); if (file.exists() && !file.remove()) @@ -922,7 +922,7 @@ void PokeGen::PokeMod::Pokemod::setSurfSkin(const QString& fname) throw(Exceptio throw(SaveException("Pokemod", file.fileName())); } -void PokeGen::PokeMod::Pokemod::setFlySkin(const QString& fname) throw(Exception) +void PokeMod::Pokemod::setFlySkin(const QString& fname) throw(Exception) { QFile file(QString("%1/image/skin/fly.png").arg(getPath())); if (file.exists() && !file.remove()) @@ -931,7 +931,7 @@ void PokeGen::PokeMod::Pokemod::setFlySkin(const QString& fname) throw(Exception throw(SaveException("Pokemod", file.fileName())); } -void PokeGen::PokeMod::Pokemod::setFishSkin(const QString& fname) throw(Exception) +void PokeMod::Pokemod::setFishSkin(const QString& fname) throw(Exception) { QFile file(QString("%1/image/skin/fish.png").arg(getPath())); if (file.exists() && !file.remove()) @@ -940,7 +940,7 @@ void PokeGen::PokeMod::Pokemod::setFishSkin(const QString& fname) throw(Exceptio throw(SaveException("Pokemod", file.fileName())); } -void PokeGen::PokeMod::Pokemod::setSurfFishSkin(const QString& fname) throw(Exception) +void PokeMod::Pokemod::setSurfFishSkin(const QString& fname) throw(Exception) { QFile file(QString("%1/image/skin/surfFish.png").arg(getPath())); if (file.exists() && !file.remove()) @@ -949,151 +949,151 @@ void PokeGen::PokeMod::Pokemod::setSurfFishSkin(const QString& fname) throw(Exce throw(SaveException("Pokemod", file.fileName())); } -void PokeGen::PokeMod::Pokemod::setSuperPCUname(const QString& u) +void PokeMod::Pokemod::setSuperPCUname(const QString& u) { superPCUname = u; } -void PokeGen::PokeMod::Pokemod::setSuperPCPasswd(const QString& p) +void PokeMod::Pokemod::setSuperPCPasswd(const QString& p) { superPCPasswd = p; } -void PokeGen::PokeMod::Pokemod::setTypeChart(const unsigned att, const unsigned def, const unsigned n, const unsigned d) throw(Exception) +void PokeMod::Pokemod::setTypeChart(const unsigned att, const unsigned def, const unsigned n, const unsigned d) throw(Exception) { typeChart(att, def).set(n, d); } -void PokeGen::PokeMod::Pokemod::setTypeChartNum(const unsigned att, const unsigned def, const unsigned n) throw(Exception) +void PokeMod::Pokemod::setTypeChartNum(const unsigned att, const unsigned def, const unsigned n) throw(Exception) { typeChart(att, def).setNum(n); } -void PokeGen::PokeMod::Pokemod::setTypeChartDenom(const unsigned att, const unsigned def, const unsigned d) throw(Exception) +void PokeMod::Pokemod::setTypeChartDenom(const unsigned att, const unsigned def, const unsigned d) throw(Exception) { typeChart(att, def).setDenom(d); } -void PokeGen::PokeMod::Pokemod::setRules(const Rules& r) +void PokeMod::Pokemod::setRules(const Rules& r) { rules = r; } -void PokeGen::PokeMod::Pokemod::setRules(const QString& fname) +void PokeMod::Pokemod::setRules(const QString& fname) { rules.load(fname); } -QString PokeGen::PokeMod::Pokemod::getTitle() const +QString PokeMod::Pokemod::getTitle() const { return title; } -QString PokeGen::PokeMod::Pokemod::getVersion() const +QString PokeMod::Pokemod::getVersion() const { return version; } -QString PokeGen::PokeMod::Pokemod::getDescription() const +QString PokeMod::Pokemod::getDescription() const { return description; } -unsigned PokeGen::PokeMod::Pokemod::getStartMap() const +unsigned PokeMod::Pokemod::getStartMap() const { return startMap; } -unsigned PokeGen::PokeMod::Pokemod::getStartMoney() const +unsigned PokeMod::Pokemod::getStartMoney() const { return startMoney; } -PokeGen::Point PokeGen::PokeMod::Pokemod::getStartCoordinate() const +Point PokeMod::Pokemod::getStartCoordinate() const { return startCoordinate; } -unsigned PokeGen::PokeMod::Pokemod::getStartCoordinateX() const +unsigned PokeMod::Pokemod::getStartCoordinateX() const { return startCoordinate.getX(); } -unsigned PokeGen::PokeMod::Pokemod::getStartCoordinateY() const +unsigned PokeMod::Pokemod::getStartCoordinateY() const { return startCoordinate.getY(); } -unsigned PokeGen::PokeMod::Pokemod::getStartDirection() const +unsigned PokeMod::Pokemod::getStartDirection() const { return startDirection; } -unsigned PokeGen::PokeMod::Pokemod::getStartDialog() const +unsigned PokeMod::Pokemod::getStartDialog() const { return startDialog; } -QString PokeGen::PokeMod::Pokemod::getSuperPCUname() const +QString PokeMod::Pokemod::getSuperPCUname() const { return superPCUname; } -QString PokeGen::PokeMod::Pokemod::getSuperPCPasswd() const +QString PokeMod::Pokemod::getSuperPCPasswd() const { return superPCPasswd; } -const PokeGen::FracMatrix& PokeGen::PokeMod::Pokemod::getTypeChart() const +const FracMatrix& PokeMod::Pokemod::getTypeChart() const { return typeChart; } -PokeGen::FracMatrix& PokeGen::PokeMod::Pokemod::getTypeChart() +FracMatrix& PokeMod::Pokemod::getTypeChart() { return typeChart; } -PokeGen::Frac PokeGen::PokeMod::Pokemod::getTypeChart(const unsigned att, const unsigned def) const +Frac PokeMod::Pokemod::getTypeChart(const unsigned att, const unsigned def) const { return typeChart(att, def); } -unsigned PokeGen::PokeMod::Pokemod::getTypeChartNum(const unsigned att, const unsigned def) const +unsigned PokeMod::Pokemod::getTypeChartNum(const unsigned att, const unsigned def) const { return getTypeChart(att, def).getNum(); } -unsigned PokeGen::PokeMod::Pokemod::getTypeChartDenom(const unsigned att, const unsigned def) const +unsigned PokeMod::Pokemod::getTypeChartDenom(const unsigned att, const unsigned def) const { return getTypeChart(att, def).getDenom(); } -const PokeGen::PokeMod::Rules& PokeGen::PokeMod::Pokemod::getRules() const +const PokeMod::Rules& PokeMod::Pokemod::getRules() const { return rules; } -PokeGen::PokeMod::Rules& PokeGen::PokeMod::Pokemod::getRules() +PokeMod::Rules& PokeMod::Pokemod::getRules() { return rules; } -const PokeGen::PokeMod::Ability& PokeGen::PokeMod::Pokemod::getAbility(const unsigned i) const throw(IndexException) +const PokeMod::Ability& PokeMod::Pokemod::getAbility(const unsigned i) const throw(IndexException) { if (getAbilityCount() <= i) throw(IndexException("Pokemod")); return abilities.at(i); } -PokeGen::PokeMod::Ability& PokeGen::PokeMod::Pokemod::getAbility(const unsigned i) throw(IndexException) +PokeMod::Ability& PokeMod::Pokemod::getAbility(const unsigned i) throw(IndexException) { if (getAbilityCount() <= i) throw(IndexException("Pokemod")); return abilities[i]; } -unsigned PokeGen::PokeMod::Pokemod::getAbilityByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getAbilityByID(const unsigned _id) const { for (unsigned i = 0; i < getAbilityCount(); ++i) { @@ -1103,51 +1103,51 @@ unsigned PokeGen::PokeMod::Pokemod::getAbilityByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getAbilityCount() const +unsigned PokeMod::Pokemod::getAbilityCount() const { return abilities.size(); } -PokeGen::PokeMod::Ability& PokeGen::PokeMod::Pokemod::newAbility() +PokeMod::Ability& PokeMod::Pokemod::newAbility() { abilities.append(Ability(*this, getNewAbilityId())); return abilities[getAbilityCount() - 1]; } -PokeGen::PokeMod::Ability& PokeGen::PokeMod::Pokemod::newAbility(const QString& fname) +PokeMod::Ability& PokeMod::Pokemod::newAbility(const QString& fname) { abilities.append(Ability(*this, fname, getNewAbilityId())); return abilities[getAbilityCount() - 1]; } -PokeGen::PokeMod::Ability& PokeGen::PokeMod::Pokemod::newAbility(const Ability& a) +PokeMod::Ability& PokeMod::Pokemod::newAbility(const Ability& a) { abilities.append(Ability(*this, a, getNewAbilityId())); return abilities[getAbilityCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteAbility(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteAbility(const unsigned i) throw(IndexException) { if (getAbilityCount() <= i) throw(IndexException("Pokemod")); abilities.removeAt(i); } -const PokeGen::PokeMod::Author& PokeGen::PokeMod::Pokemod::getAuthor(const unsigned i) const throw(IndexException) +const PokeMod::Author& PokeMod::Pokemod::getAuthor(const unsigned i) const throw(IndexException) { if (getAuthorCount() <= i) throw(IndexException("Pokemod")); return authors.at(i); } -PokeGen::PokeMod::Author& PokeGen::PokeMod::Pokemod::getAuthor(const unsigned i) throw(IndexException) +PokeMod::Author& PokeMod::Pokemod::getAuthor(const unsigned i) throw(IndexException) { if (getAuthorCount() <= i) throw(IndexException("Pokemod")); return authors[i]; } -unsigned PokeGen::PokeMod::Pokemod::getAuthorByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getAuthorByID(const unsigned _id) const { for (unsigned i = 0; i < getAuthorCount(); ++i) { @@ -1157,39 +1157,39 @@ unsigned PokeGen::PokeMod::Pokemod::getAuthorByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getAuthorCount() const +unsigned PokeMod::Pokemod::getAuthorCount() const { return authors.size(); } -PokeGen::PokeMod::Author& PokeGen::PokeMod::Pokemod::newAuthor() +PokeMod::Author& PokeMod::Pokemod::newAuthor() { authors.append(Author(*this, getNewAuthorId())); return authors[getAuthorCount() + 1]; } -void PokeGen::PokeMod::Pokemod::deleteAuthor(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteAuthor(const unsigned i) throw(IndexException) { if (getAuthorCount() <= i) throw(IndexException("Pokemod")); authors.removeAt(i); } -const PokeGen::PokeMod::Badge& PokeGen::PokeMod::Pokemod::getBadge(const unsigned i) const throw(IndexException) +const PokeMod::Badge& PokeMod::Pokemod::getBadge(const unsigned i) const throw(IndexException) { if (i < getBadgeCount()) throw(IndexException("Pokemod")); return badges.at(i); } -PokeGen::PokeMod::Badge& PokeGen::PokeMod::Pokemod::getBadge(const unsigned i) throw(IndexException) +PokeMod::Badge& PokeMod::Pokemod::getBadge(const unsigned i) throw(IndexException) { if (i < getBadgeCount()) throw(IndexException("Pokemod")); return badges[i]; } -unsigned PokeGen::PokeMod::Pokemod::getBadgeByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getBadgeByID(const unsigned _id) const { for (unsigned i = 0; i < getBadgeCount(); ++i) { @@ -1199,51 +1199,51 @@ unsigned PokeGen::PokeMod::Pokemod::getBadgeByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getBadgeCount() const +unsigned PokeMod::Pokemod::getBadgeCount() const { return badges.size(); } -PokeGen::PokeMod::Badge& PokeGen::PokeMod::Pokemod::newBadge() +PokeMod::Badge& PokeMod::Pokemod::newBadge() { badges.append(Badge(*this, getNewBadgeId())); return badges[getBadgeCount() - 1]; } -PokeGen::PokeMod::Badge& PokeGen::PokeMod::Pokemod::newBadge(const QString& fname) +PokeMod::Badge& PokeMod::Pokemod::newBadge(const QString& fname) { badges.append(Badge(*this, fname, getNewBadgeId())); return badges[getBadgeCount() - 1]; } -PokeGen::PokeMod::Badge& PokeGen::PokeMod::Pokemod::newBadge(const Badge& b) +PokeMod::Badge& PokeMod::Pokemod::newBadge(const Badge& b) { badges.append(Badge(*this, b, getNewBadgeId())); return badges[getBadgeCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteBadge(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteBadge(const unsigned i) throw(IndexException) { if (getBadgeCount() <= i) throw(IndexException("Pokemod")); badges.removeAt(i); } -const PokeGen::PokeMod::CoinList& PokeGen::PokeMod::Pokemod::getCoinList(const unsigned i) const throw(IndexException) +const PokeMod::CoinList& PokeMod::Pokemod::getCoinList(const unsigned i) const throw(IndexException) { if (getCoinListCount() <= i) throw(IndexException("Pokemod")); return coinLists.at(i); } -PokeGen::PokeMod::CoinList& PokeGen::PokeMod::Pokemod::getCoinList(const unsigned i) throw(IndexException) +PokeMod::CoinList& PokeMod::Pokemod::getCoinList(const unsigned i) throw(IndexException) { if (getCoinListCount() <= i) throw(IndexException("Pokemod")); return coinLists[i]; } -unsigned PokeGen::PokeMod::Pokemod::getCoinListByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getCoinListByID(const unsigned _id) const { for (unsigned i = 0; i < getCoinListCount(); ++i) { @@ -1253,51 +1253,51 @@ unsigned PokeGen::PokeMod::Pokemod::getCoinListByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getCoinListCount() const +unsigned PokeMod::Pokemod::getCoinListCount() const { return coinLists.size(); } -PokeGen::PokeMod::CoinList& PokeGen::PokeMod::Pokemod::newCoinList() +PokeMod::CoinList& PokeMod::Pokemod::newCoinList() { coinLists.append(CoinList(*this, getNewCoinListId())); return coinLists[getCoinListCount() - 1]; } -PokeGen::PokeMod::CoinList& PokeGen::PokeMod::Pokemod::newCoinList(const QString& fname) +PokeMod::CoinList& PokeMod::Pokemod::newCoinList(const QString& fname) { coinLists.append(CoinList(*this, fname, getNewCoinListId())); return coinLists[getCoinListCount() - 1]; } -PokeGen::PokeMod::CoinList& PokeGen::PokeMod::Pokemod::newCoinList(const CoinList& c) +PokeMod::CoinList& PokeMod::Pokemod::newCoinList(const CoinList& c) { coinLists.append(CoinList(*this, c, getNewCoinListId())); return coinLists[getCoinListCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteCoinList(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteCoinList(const unsigned i) throw(IndexException) { if (getCoinListCount() <= i) throw(IndexException("Pokemod")); coinLists.removeAt(i); } -const PokeGen::PokeMod::Dialog& PokeGen::PokeMod::Pokemod::getDialog(const unsigned i) const throw(IndexException) +const PokeMod::Dialog& PokeMod::Pokemod::getDialog(const unsigned i) const throw(IndexException) { if (getDialogCount() <= i) throw(IndexException("Pokemod")); return dialogs.at(i); } -PokeGen::PokeMod::Dialog& PokeGen::PokeMod::Pokemod::getDialog(const unsigned i) throw(IndexException) +PokeMod::Dialog& PokeMod::Pokemod::getDialog(const unsigned i) throw(IndexException) { if (getDialogCount() <= i) throw(IndexException("Pokemod")); return dialogs[i]; } -unsigned PokeGen::PokeMod::Pokemod::getDialogByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getDialogByID(const unsigned _id) const { for (unsigned i = 0; i < getDialogCount(); ++i) { @@ -1307,51 +1307,51 @@ unsigned PokeGen::PokeMod::Pokemod::getDialogByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getDialogCount() const +unsigned PokeMod::Pokemod::getDialogCount() const { return dialogs.size(); } -PokeGen::PokeMod::Dialog& PokeGen::PokeMod::Pokemod::newDialog() +PokeMod::Dialog& PokeMod::Pokemod::newDialog() { dialogs.append(Dialog(*this, getNewDialogId())); return dialogs[getDialogCount() - 1]; } -PokeGen::PokeMod::Dialog& PokeGen::PokeMod::Pokemod::newDialog(const QString& fname) +PokeMod::Dialog& PokeMod::Pokemod::newDialog(const QString& fname) { dialogs.append(Dialog(*this, fname, getNewDialogId())); return dialogs[getDialogCount() - 1]; } -PokeGen::PokeMod::Dialog& PokeGen::PokeMod::Pokemod::newDialog(const Dialog& d) +PokeMod::Dialog& PokeMod::Pokemod::newDialog(const Dialog& d) { dialogs.append(Dialog(*this, d, getNewDialogId())); return dialogs[getDialogCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteDialog(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteDialog(const unsigned i) throw(IndexException) { if (getDialogCount() <= i) throw(IndexException("Pokemod")); dialogs.removeAt(i); } -const PokeGen::PokeMod::EggGroup& PokeGen::PokeMod::Pokemod::getEggGroup(const unsigned i) const throw(IndexException) +const PokeMod::EggGroup& PokeMod::Pokemod::getEggGroup(const unsigned i) const throw(IndexException) { if (getEggGroupCount() <= i) throw(IndexException("Pokemod")); return eggGroups.at(i); } -PokeGen::PokeMod::EggGroup& PokeGen::PokeMod::Pokemod::getEggGroup(const unsigned i) throw(IndexException) +PokeMod::EggGroup& PokeMod::Pokemod::getEggGroup(const unsigned i) throw(IndexException) { if (getEggGroupCount() <= i) throw(IndexException("Pokemod")); return eggGroups[i]; } -unsigned PokeGen::PokeMod::Pokemod::getEggGroupByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getEggGroupByID(const unsigned _id) const { for (unsigned i = 0; i < getEggGroupCount(); ++i) { @@ -1361,51 +1361,51 @@ unsigned PokeGen::PokeMod::Pokemod::getEggGroupByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getEggGroupCount() const +unsigned PokeMod::Pokemod::getEggGroupCount() const { return eggGroups.size(); } -PokeGen::PokeMod::EggGroup& PokeGen::PokeMod::Pokemod::newEggGroup() +PokeMod::EggGroup& PokeMod::Pokemod::newEggGroup() { eggGroups.append(EggGroup(*this, getNewEggGroupId())); return eggGroups[getEggGroupCount() - 1]; } -PokeGen::PokeMod::EggGroup& PokeGen::PokeMod::Pokemod::newEggGroup(const QString& fname) +PokeMod::EggGroup& PokeMod::Pokemod::newEggGroup(const QString& fname) { eggGroups.append(EggGroup(*this, fname, getNewEggGroupId())); return eggGroups[getEggGroupCount() - 1]; } -PokeGen::PokeMod::EggGroup& PokeGen::PokeMod::Pokemod::newEggGroup(const EggGroup& e) +PokeMod::EggGroup& PokeMod::Pokemod::newEggGroup(const EggGroup& e) { eggGroups.append(EggGroup(*this, e, getNewEggGroupId())); return eggGroups[getEggGroupCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteEggGroup(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteEggGroup(const unsigned i) throw(IndexException) { if (getEggGroupCount() <= i) throw(IndexException("Pokemod")); eggGroups.removeAt(i); } -const PokeGen::PokeMod::Item& PokeGen::PokeMod::Pokemod::getItem(const unsigned i) const throw(IndexException) +const PokeMod::Item& PokeMod::Pokemod::getItem(const unsigned i) const throw(IndexException) { if (getItemCount() <= i) throw(IndexException("Pokemod")); return items.at(i); } -PokeGen::PokeMod::Item& PokeGen::PokeMod::Pokemod::getItem(const unsigned i) throw(IndexException) +PokeMod::Item& PokeMod::Pokemod::getItem(const unsigned i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException("Pokemod")); return items[i]; } -unsigned PokeGen::PokeMod::Pokemod::getItemByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getItemByID(const unsigned _id) const { for (unsigned i = 0; i < getItemCount(); ++i) { @@ -1415,51 +1415,51 @@ unsigned PokeGen::PokeMod::Pokemod::getItemByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getItemCount() const +unsigned PokeMod::Pokemod::getItemCount() const { return items.size(); } -PokeGen::PokeMod::Item& PokeGen::PokeMod::Pokemod::newItem() +PokeMod::Item& PokeMod::Pokemod::newItem() { items.append(Item(*this, getNewItemId())); return items[getItemCount() - 1]; } -PokeGen::PokeMod::Item& PokeGen::PokeMod::Pokemod::newItem(const QString& fname) +PokeMod::Item& PokeMod::Pokemod::newItem(const QString& fname) { items.append(Item(*this, fname, getNewItemId())); return items[getItemCount() - 1]; } -PokeGen::PokeMod::Item& PokeGen::PokeMod::Pokemod::newItem(const Item& i) +PokeMod::Item& PokeMod::Pokemod::newItem(const Item& i) { items.append(Item(*this, i, getNewItemId())); return items[getItemCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteItem(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteItem(const unsigned i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException("Pokemod")); items.removeAt(i); } -const PokeGen::PokeMod::ItemType& PokeGen::PokeMod::Pokemod::getItemType(const unsigned i) const throw(IndexException) +const PokeMod::ItemType& PokeMod::Pokemod::getItemType(const unsigned i) const throw(IndexException) { if (getItemTypeCount() <= i) throw(IndexException("Pokemod")); return itemTypes.at(i); } -PokeGen::PokeMod::ItemType& PokeGen::PokeMod::Pokemod::getItemType(const unsigned i) throw(IndexException) +PokeMod::ItemType& PokeMod::Pokemod::getItemType(const unsigned i) throw(IndexException) { if (getItemTypeCount() <= i) throw(IndexException("Pokemod")); return itemTypes[i]; } -unsigned PokeGen::PokeMod::Pokemod::getItemTypeByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getItemTypeByID(const unsigned _id) const { for (unsigned i = 0; i < getItemTypeCount(); ++i) { @@ -1469,51 +1469,51 @@ unsigned PokeGen::PokeMod::Pokemod::getItemTypeByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getItemTypeCount() const +unsigned PokeMod::Pokemod::getItemTypeCount() const { return itemTypes.size(); } -PokeGen::PokeMod::ItemType& PokeGen::PokeMod::Pokemod::newItemType() +PokeMod::ItemType& PokeMod::Pokemod::newItemType() { itemTypes.append(ItemType(*this, getNewItemTypeId())); return itemTypes[getItemTypeCount() - 1]; } -PokeGen::PokeMod::ItemType& PokeGen::PokeMod::Pokemod::newItemType(const QString& fname) +PokeMod::ItemType& PokeMod::Pokemod::newItemType(const QString& fname) { itemTypes.append(ItemType(*this, fname, getNewItemTypeId())); return itemTypes[getItemTypeCount() - 1]; } -PokeGen::PokeMod::ItemType& PokeGen::PokeMod::Pokemod::newItemType(const ItemType& i) +PokeMod::ItemType& PokeMod::Pokemod::newItemType(const ItemType& i) { itemTypes.append(ItemType(*this, i, getNewItemTypeId())); return itemTypes[getItemTypeCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteItemType(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteItemType(const unsigned i) throw(IndexException) { if (getItemTypeCount() <= i) throw(IndexException("Pokemod")); itemTypes.removeAt(i); } -const PokeGen::PokeMod::Map& PokeGen::PokeMod::Pokemod::getMap(const unsigned i) const throw(IndexException) +const PokeMod::Map& PokeMod::Pokemod::getMap(const unsigned i) const throw(IndexException) { if (getMapCount() <= i) throw(IndexException("Pokemod")); return maps.at(i); } -PokeGen::PokeMod::Map& PokeGen::PokeMod::Pokemod::getMap(const unsigned i) throw(IndexException) +PokeMod::Map& PokeMod::Pokemod::getMap(const unsigned i) throw(IndexException) { if (getMapCount() <= i) throw(IndexException("Pokemod")); return maps[i]; } -unsigned PokeGen::PokeMod::Pokemod::getMapByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getMapByID(const unsigned _id) const { for (unsigned i = 0; i < getMapCount(); ++i) { @@ -1523,51 +1523,51 @@ unsigned PokeGen::PokeMod::Pokemod::getMapByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getMapCount() const +unsigned PokeMod::Pokemod::getMapCount() const { return maps.size(); } -PokeGen::PokeMod::Map& PokeGen::PokeMod::Pokemod::newMap() +PokeMod::Map& PokeMod::Pokemod::newMap() { maps.append(Map(*this, getNewMapId())); return maps[getMapCount() - 1]; } -PokeGen::PokeMod::Map& PokeGen::PokeMod::Pokemod::newMap(const QString& fname) +PokeMod::Map& PokeMod::Pokemod::newMap(const QString& fname) { maps.append(Map(*this, fname, getNewMapId())); return maps[getMapCount() - 1]; } -PokeGen::PokeMod::Map& PokeGen::PokeMod::Pokemod::newMap(const Map& m) +PokeMod::Map& PokeMod::Pokemod::newMap(const Map& m) { maps.append(Map(*this, m, getNewMapId())); return maps[getMapCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteMap(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteMap(const unsigned i) throw(IndexException) { if (getMapCount() <= i) throw(IndexException("Pokemod")); maps.removeAt(i); } -const PokeGen::PokeMod::Move& PokeGen::PokeMod::Pokemod::getMove(const unsigned i) const throw(IndexException) +const PokeMod::Move& PokeMod::Pokemod::getMove(const unsigned i) const throw(IndexException) { if (getMoveCount() <= i) throw(IndexException("Pokemod")); return moves.at(i); } -PokeGen::PokeMod::Move& PokeGen::PokeMod::Pokemod::getMove(const unsigned i) throw(IndexException) +PokeMod::Move& PokeMod::Pokemod::getMove(const unsigned i) throw(IndexException) { if (getMoveCount() <= i) throw(IndexException("Pokemod")); return moves[i]; } -unsigned PokeGen::PokeMod::Pokemod::getMoveByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getMoveByID(const unsigned _id) const { for (unsigned i = 0; i < getMoveCount(); ++i) { @@ -1577,51 +1577,51 @@ unsigned PokeGen::PokeMod::Pokemod::getMoveByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getMoveCount() const +unsigned PokeMod::Pokemod::getMoveCount() const { return moves.size(); } -PokeGen::PokeMod::Move& PokeGen::PokeMod::Pokemod::newMove() +PokeMod::Move& PokeMod::Pokemod::newMove() { moves.append(Move(*this, getNewMoveId())); return moves[getMoveCount() - 1]; } -PokeGen::PokeMod::Move& PokeGen::PokeMod::Pokemod::newMove(const QString& fname) +PokeMod::Move& PokeMod::Pokemod::newMove(const QString& fname) { moves.append(Move(*this, fname, getNewMoveId())); return moves[getMoveCount() - 1]; } -PokeGen::PokeMod::Move& PokeGen::PokeMod::Pokemod::newMove(const Move& m) +PokeMod::Move& PokeMod::Pokemod::newMove(const Move& m) { moves.append(Move(*this, m, getNewMoveId())); return moves[getMoveCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteMove(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteMove(const unsigned i) throw(IndexException) { if (getMoveCount() <= i) throw(IndexException("Pokemod")); moves.removeAt(i); } -const PokeGen::PokeMod::Nature& PokeGen::PokeMod::Pokemod::getNature(const unsigned i) const throw(IndexException) +const PokeMod::Nature& PokeMod::Pokemod::getNature(const unsigned i) const throw(IndexException) { if (getNatureCount() <= i) throw(IndexException("Pokemod")); return natures.at(i); } -PokeGen::PokeMod::Nature& PokeGen::PokeMod::Pokemod::getNature(const unsigned i) throw(IndexException) +PokeMod::Nature& PokeMod::Pokemod::getNature(const unsigned i) throw(IndexException) { if (getNatureCount() <= i) throw(IndexException("Pokemod")); return natures[i]; } -unsigned PokeGen::PokeMod::Pokemod::getNatureByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getNatureByID(const unsigned _id) const { for (unsigned i = 0; i < getNatureCount(); ++i) { @@ -1631,51 +1631,51 @@ unsigned PokeGen::PokeMod::Pokemod::getNatureByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getNatureCount() const +unsigned PokeMod::Pokemod::getNatureCount() const { return natures.size(); } -PokeGen::PokeMod::Nature& PokeGen::PokeMod::Pokemod::newNature() +PokeMod::Nature& PokeMod::Pokemod::newNature() { natures.append(Nature(*this, getNewNatureId())); return natures[getNatureCount() - 1]; } -PokeGen::PokeMod::Nature& PokeGen::PokeMod::Pokemod::newNature(const QString& fname) +PokeMod::Nature& PokeMod::Pokemod::newNature(const QString& fname) { natures.append(Nature(*this, fname, getNewNatureId())); return natures[getNatureCount() - 1]; } -PokeGen::PokeMod::Nature& PokeGen::PokeMod::Pokemod::newNature(const Nature& n) +PokeMod::Nature& PokeMod::Pokemod::newNature(const Nature& n) { natures.append(Nature(*this, n, getNewNatureId())); return natures[getNatureCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteNature(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteNature(const unsigned i) throw(IndexException) { if (getNatureCount() <= i) throw(IndexException("Pokemod")); natures.removeAt(i); } -const PokeGen::PokeMod::Species& PokeGen::PokeMod::Pokemod::getSpecies(const unsigned i) const throw(IndexException) +const PokeMod::Species& PokeMod::Pokemod::getSpecies(const unsigned i) const throw(IndexException) { if (getSpeciesCount() <= i) throw(IndexException("Pokemod")); return species.at(i); } -PokeGen::PokeMod::Species& PokeGen::PokeMod::Pokemod::getSpecies(const unsigned i) throw(IndexException) +PokeMod::Species& PokeMod::Pokemod::getSpecies(const unsigned i) throw(IndexException) { if (getSpeciesCount() <= i) throw(IndexException("Pokemod")); return species[i]; } -unsigned PokeGen::PokeMod::Pokemod::getSpeciesByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getSpeciesByID(const unsigned _id) const { for (unsigned i = 0; i < getSpeciesCount(); ++i) { @@ -1685,51 +1685,51 @@ unsigned PokeGen::PokeMod::Pokemod::getSpeciesByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getSpeciesCount() const +unsigned PokeMod::Pokemod::getSpeciesCount() const { return species.size(); } -PokeGen::PokeMod::Species& PokeGen::PokeMod::Pokemod::newSpecies() +PokeMod::Species& PokeMod::Pokemod::newSpecies() { species.append(Species(*this, getNewSpeciesId())); return species[getSpeciesCount() - 1]; } -PokeGen::PokeMod::Species& PokeGen::PokeMod::Pokemod::newSpecies(const QString& fname) +PokeMod::Species& PokeMod::Pokemod::newSpecies(const QString& fname) { species.append(Species(*this, fname, getNewSpeciesId())); return species[getSpeciesCount() - 1]; } -PokeGen::PokeMod::Species& PokeGen::PokeMod::Pokemod::newSpecies(const Species& s) +PokeMod::Species& PokeMod::Pokemod::newSpecies(const Species& s) { species.append(Species(*this, s, getNewSpeciesId())); return species[getSpeciesCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteSpecies(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteSpecies(const unsigned i) throw(IndexException) { if (getSpeciesCount() <= i) throw(IndexException("Pokemod")); species.removeAt(i); } -const PokeGen::PokeMod::Store& PokeGen::PokeMod::Pokemod::getStore(const unsigned i) const throw(IndexException) +const PokeMod::Store& PokeMod::Pokemod::getStore(const unsigned i) const throw(IndexException) { if (getStoreCount() <= i) throw(IndexException("Pokemod")); return stores.at(i); } -PokeGen::PokeMod::Store& PokeGen::PokeMod::Pokemod::getStore(const unsigned i) throw(IndexException) +PokeMod::Store& PokeMod::Pokemod::getStore(const unsigned i) throw(IndexException) { if (getStoreCount() <= i) throw(IndexException("Pokemod")); return stores[i]; } -unsigned PokeGen::PokeMod::Pokemod::getStoreByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getStoreByID(const unsigned _id) const { for (unsigned i = 0; i < getStoreCount(); ++i) { @@ -1739,51 +1739,51 @@ unsigned PokeGen::PokeMod::Pokemod::getStoreByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getStoreCount() const +unsigned PokeMod::Pokemod::getStoreCount() const { return stores.size(); } -PokeGen::PokeMod::Store& PokeGen::PokeMod::Pokemod::newStore() +PokeMod::Store& PokeMod::Pokemod::newStore() { stores.append(Store(*this, getNewStoreId())); return stores[getStoreCount() - 1]; } -PokeGen::PokeMod::Store& PokeGen::PokeMod::Pokemod::newStore(const QString& fname) +PokeMod::Store& PokeMod::Pokemod::newStore(const QString& fname) { stores.append(Store(*this, fname, getNewStoreId())); return stores[getStoreCount() - 1]; } -PokeGen::PokeMod::Store& PokeGen::PokeMod::Pokemod::newStore(const Store& s) +PokeMod::Store& PokeMod::Pokemod::newStore(const Store& s) { stores.append(Store(*this, s, getNewStoreId())); return stores[getStoreCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteStore(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteStore(const unsigned i) throw(IndexException) { if (getStoreCount() <= i) throw(IndexException("Pokemod")); stores.removeAt(i); } -const PokeGen::PokeMod::Tile& PokeGen::PokeMod::Pokemod::getTile(const unsigned i) const throw(IndexException) +const PokeMod::Tile& PokeMod::Pokemod::getTile(const unsigned i) const throw(IndexException) { if (getTileCount() <= i) throw(IndexException("Pokemod")); return tiles.at(i); } -PokeGen::PokeMod::Tile& PokeGen::PokeMod::Pokemod::getTile(const unsigned i) throw(IndexException) +PokeMod::Tile& PokeMod::Pokemod::getTile(const unsigned i) throw(IndexException) { if (getTileCount() <= i) throw(IndexException("Pokemod")); return tiles[i]; } -unsigned PokeGen::PokeMod::Pokemod::getTileByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getTileByID(const unsigned _id) const { for (unsigned i = 0; i < getTileCount(); ++i) { @@ -1793,51 +1793,51 @@ unsigned PokeGen::PokeMod::Pokemod::getTileByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getTileCount() const +unsigned PokeMod::Pokemod::getTileCount() const { return tiles.size(); } -PokeGen::PokeMod::Tile& PokeGen::PokeMod::Pokemod::newTile() +PokeMod::Tile& PokeMod::Pokemod::newTile() { tiles.append(Tile(*this, getNewTileId())); return tiles[getTileCount() - 1]; } -PokeGen::PokeMod::Tile& PokeGen::PokeMod::Pokemod::newTile(const QString& fname) +PokeMod::Tile& PokeMod::Pokemod::newTile(const QString& fname) { tiles.append(Tile(*this, fname, getNewTileId())); return tiles[getTileCount() - 1]; } -PokeGen::PokeMod::Tile& PokeGen::PokeMod::Pokemod::newTile(const Tile& t) +PokeMod::Tile& PokeMod::Pokemod::newTile(const Tile& t) { tiles.append(Tile(*this, t, getNewTileId())); return tiles[getTileCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteTile(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteTile(const unsigned i) throw(IndexException) { if (getTileCount() <= i) throw(IndexException("Pokemod")); tiles.removeAt(i); } -const PokeGen::PokeMod::Time& PokeGen::PokeMod::Pokemod::getTime(const unsigned i) const throw(IndexException) +const PokeMod::Time& PokeMod::Pokemod::getTime(const unsigned i) const throw(IndexException) { if (getTimeCount() <= i) throw(IndexException("Pokemod")); return times.at(i); } -PokeGen::PokeMod::Time& PokeGen::PokeMod::Pokemod::getTime(const unsigned i) throw(IndexException) +PokeMod::Time& PokeMod::Pokemod::getTime(const unsigned i) throw(IndexException) { if (getTimeCount() <= i) throw(IndexException("Pokemod")); return times[i]; } -unsigned PokeGen::PokeMod::Pokemod::getTimeByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getTimeByID(const unsigned _id) const { for (unsigned i = 0; i < getTimeCount(); ++i) { @@ -1847,51 +1847,51 @@ unsigned PokeGen::PokeMod::Pokemod::getTimeByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getTimeCount() const +unsigned PokeMod::Pokemod::getTimeCount() const { return times.size(); } -PokeGen::PokeMod::Time& PokeGen::PokeMod::Pokemod::newTime() +PokeMod::Time& PokeMod::Pokemod::newTime() { times.append(Time(*this, getNewTimeId())); return times[getTimeCount() - 1]; } -PokeGen::PokeMod::Time& PokeGen::PokeMod::Pokemod::newTime(const QString& fname) +PokeMod::Time& PokeMod::Pokemod::newTime(const QString& fname) { times.append(Time(*this, fname, getNewTimeId())); return times[getTimeCount() - 1]; } -PokeGen::PokeMod::Time& PokeGen::PokeMod::Pokemod::newTime(const Time& t) +PokeMod::Time& PokeMod::Pokemod::newTime(const Time& t) { times.append(Time(*this, t, getNewTimeId())); return times[getTimeCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteTime(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteTime(const unsigned i) throw(IndexException) { if (getTimeCount() <= i) throw(IndexException("Pokemod")); times.removeAt(i); } -const PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::getType(const unsigned i) const throw(IndexException) +const PokeMod::Type& PokeMod::Pokemod::getType(const unsigned i) const throw(IndexException) { if (getTypeCount() <= i) throw(IndexException("Pokemod")); return types.at(i); } -PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::getType(const unsigned i) throw(IndexException) +PokeMod::Type& PokeMod::Pokemod::getType(const unsigned i) throw(IndexException) { if (getTypeCount() <= i) throw(IndexException("Pokemod")); return types[i]; } -unsigned PokeGen::PokeMod::Pokemod::getTypeByID(const unsigned _id) const +unsigned PokeMod::Pokemod::getTypeByID(const unsigned _id) const { for (unsigned i = 0; i < getTypeCount(); ++i) { @@ -1901,12 +1901,12 @@ unsigned PokeGen::PokeMod::Pokemod::getTypeByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Pokemod::getTypeCount() const +unsigned PokeMod::Pokemod::getTypeCount() const { return types.size(); } -PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::newType() +PokeMod::Type& PokeMod::Pokemod::newType() { unsigned i; types.append(Type(*this, i = getNewTypeId())); @@ -1915,7 +1915,7 @@ PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::newType() return types[getTypeCount() - 1]; } -PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::newType(const QString& fname) +PokeMod::Type& PokeMod::Pokemod::newType(const QString& fname) { unsigned i; types.append(Type(*this, fname, i = getNewTypeId())); @@ -1924,7 +1924,7 @@ PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::newType(const QString& fname) return types[getTypeCount() - 1]; } -PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::newType(const Type& t) +PokeMod::Type& PokeMod::Pokemod::newType(const Type& t) { unsigned i; types.append(Type(*this, t, i = getNewTypeId())); @@ -1933,7 +1933,7 @@ PokeGen::PokeMod::Type& PokeGen::PokeMod::Pokemod::newType(const Type& t) return types[getTypeCount() - 1]; } -void PokeGen::PokeMod::Pokemod::deleteType(const unsigned i) throw(IndexException) +void PokeMod::Pokemod::deleteType(const unsigned i) throw(IndexException) { if (getTypeCount() <= i) throw(IndexException("Pokemod")); diff --git a/pokemod/Pokemod.h b/pokemod/Pokemod.h index 9ab84512..80c9f386 100644 --- a/pokemod/Pokemod.h +++ b/pokemod/Pokemod.h @@ -56,273 +56,270 @@ #include "Time.h" #include "Type.h" -namespace PokeGen +namespace PokeMod { - 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 setStartMoney(const unsigned s); - void setStartCoordinate(const unsigned x, const unsigned y) throw(BoundsException); - void setStartCoordinateX(const unsigned x) throw(BoundsException); - void setStartCoordinateY(const unsigned y) throw(BoundsException); - void setStartDirection(const unsigned s) throw(BoundsException); - void setStartDialog(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 getStartMoney() const; - Point getStartCoordinate() const; - unsigned getStartCoordinateX() const; - unsigned getStartCoordinateY() const; - unsigned getStartDirection() const; - unsigned getStartDialog() const; - QString getSuperPCUname() const; - QString getSuperPCPasswd() const; - const FracMatrix& getTypeChart() const; - FracMatrix& getTypeChart(); - Frac getTypeChart(const unsigned att, const unsigned def) const; - unsigned getTypeChartNum(const unsigned att, const unsigned def) const; - unsigned getTypeChartDenom(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); - unsigned getAbilityByID(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); - unsigned getAuthorByID(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); - unsigned getBadgeByID(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); - unsigned getCoinListByID(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); - unsigned getDialogByID(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); - unsigned getEggGroupByID(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); - unsigned getItemByID(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); - unsigned getItemTypeByID(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); - unsigned getMapByID(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); - unsigned getMoveByID(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); - unsigned getNatureByID(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); - unsigned getSpeciesByID(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); - unsigned getStoreByID(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); - unsigned getTileByID(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); - unsigned getTimeByID(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); - unsigned getTypeByID(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 startMoney; - Point startCoordinate; - unsigned startDirection; - unsigned startDialog; - 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 setStartMoney(const unsigned s); + void setStartCoordinate(const unsigned x, const unsigned y) throw(BoundsException); + void setStartCoordinateX(const unsigned x) throw(BoundsException); + void setStartCoordinateY(const unsigned y) throw(BoundsException); + void setStartDirection(const unsigned s) throw(BoundsException); + void setStartDialog(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 getStartMoney() const; + Point getStartCoordinate() const; + unsigned getStartCoordinateX() const; + unsigned getStartCoordinateY() const; + unsigned getStartDirection() const; + unsigned getStartDialog() const; + QString getSuperPCUname() const; + QString getSuperPCPasswd() const; + const FracMatrix& getTypeChart() const; + FracMatrix& getTypeChart(); + Frac getTypeChart(const unsigned att, const unsigned def) const; + unsigned getTypeChartNum(const unsigned att, const unsigned def) const; + unsigned getTypeChartDenom(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); + unsigned getAbilityByID(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); + unsigned getAuthorByID(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); + unsigned getBadgeByID(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); + unsigned getCoinListByID(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); + unsigned getDialogByID(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); + unsigned getEggGroupByID(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); + unsigned getItemByID(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); + unsigned getItemTypeByID(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); + unsigned getMapByID(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); + unsigned getMoveByID(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); + unsigned getNatureByID(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); + unsigned getSpeciesByID(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); + unsigned getStoreByID(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); + unsigned getTileByID(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); + unsigned getTimeByID(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); + unsigned getTypeByID(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 startMoney; + Point startCoordinate; + unsigned startDirection; + unsigned startDialog; + 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 fb2a32e3..fb88512a 100644 --- a/pokemod/Rules.cpp +++ b/pokemod/Rules.cpp @@ -22,7 +22,7 @@ #include "Rules.h" -PokeGen::PokeMod::Rules::Rules(const Pokemod& par) : +PokeMod::Rules::Rules(const Pokemod& par) : Object(par, 0), genderAllowed(false), breedingAllowed(false), @@ -52,13 +52,13 @@ PokeGen::PokeMod::Rules::Rules(const Pokemod& par) : { } -PokeGen::PokeMod::Rules::Rules(const Pokemod& par, const QString& fname) : +PokeMod::Rules::Rules(const Pokemod& par, const QString& fname) : Object(par, 0) { load(fname); } -bool PokeGen::PokeMod::Rules::validate() const +bool PokeMod::Rules::validate() const { bool valid = true; pokemod.validationMsg("---Rules", Pokemod::V_Msg); @@ -104,7 +104,7 @@ bool PokeGen::PokeMod::Rules::validate() const return valid; } -void PokeGen::PokeMod::Rules::load(const QString& fname) throw(Exception) +void PokeMod::Rules::load(const QString& fname) throw(Exception) { Ini ini(fname); unsigned i; @@ -138,7 +138,7 @@ void PokeGen::PokeMod::Rules::load(const QString& fname) throw(Exception) pokerusChance.set(i, j); } -void PokeGen::PokeMod::Rules::save() const throw(Exception) +void PokeMod::Rules::save() const throw(Exception) { Ini ini; ini.addField("genderAllowed", genderAllowed); @@ -170,138 +170,138 @@ void PokeGen::PokeMod::Rules::save() const throw(Exception) ini.save(QString("%1/rules.pini").arg(pokemod.getPath())); } -void PokeGen::PokeMod::Rules::setGenderAllowed(const bool g) +void PokeMod::Rules::setGenderAllowed(const bool g) { genderAllowed = g; if (!genderAllowed) breedingAllowed = false; } -void PokeGen::PokeMod::Rules::setBreedingAllowed(const bool b) throw(Exception) +void PokeMod::Rules::setBreedingAllowed(const bool b) throw(Exception) { if (!genderAllowed) throw(Exception("Rules", "cannot breed without genders")); breedingAllowed = b; } -void PokeGen::PokeMod::Rules::setHoldItems(const unsigned h) +void PokeMod::Rules::setHoldItems(const unsigned h) { holdItems = h; } -void PokeGen::PokeMod::Rules::setCriticalDomains(const bool c) +void PokeMod::Rules::setCriticalDomains(const bool c) { criticalDomains = c; } -void PokeGen::PokeMod::Rules::setAbilityAllowed(const bool a) +void PokeMod::Rules::setAbilityAllowed(const bool a) { abilityAllowed = a; } -void PokeGen::PokeMod::Rules::setNatureAllowed(const bool n) +void PokeMod::Rules::setNatureAllowed(const bool n) { natureAllowed = n; } -void PokeGen::PokeMod::Rules::setNumPokemonBoxes(const unsigned n) +void PokeMod::Rules::setNumPokemonBoxes(const unsigned n) { numPokemonBoxes = n; } -void PokeGen::PokeMod::Rules::setNumPokemonPerBox(const unsigned n) +void PokeMod::Rules::setNumPokemonPerBox(const unsigned n) { numPokemonPerBox = n; } -void PokeGen::PokeMod::Rules::setMaxParty(const unsigned m) throw(BoundsException) +void PokeMod::Rules::setMaxParty(const unsigned m) throw(BoundsException) { if (!m) throw(BoundsException("Rules", "maxParty")); maxParty = m; } -void PokeGen::PokeMod::Rules::setMaxFight(const unsigned m) throw(BoundsException) +void PokeMod::Rules::setMaxFight(const unsigned m) throw(BoundsException) { if (maxParty < m) throw(BoundsException("Rules", "maxFight")); maxFight = m; } -void PokeGen::PokeMod::Rules::setMaxMoves(const unsigned m) throw(BoundsException) +void PokeMod::Rules::setMaxMoves(const unsigned m) throw(BoundsException) { if (!m) throw(BoundsException("Rules", "maxMoves")); maxMoves = m; } -void PokeGen::PokeMod::Rules::setMaxLevel(const unsigned m) throw(BoundsException) +void PokeMod::Rules::setMaxLevel(const unsigned m) throw(BoundsException) { if (!m) throw(BoundsException("Rules", "maxLevel")); maxLevel = m; } -void PokeGen::PokeMod::Rules::setMaxMoney(const unsigned m) +void PokeMod::Rules::setMaxMoney(const unsigned m) { maxMoney = m; } -void PokeGen::PokeMod::Rules::setHardCash(const bool h) +void PokeMod::Rules::setHardCash(const bool h) { hardCash = h; } -void PokeGen::PokeMod::Rules::setSpecialSplit(const bool s) +void PokeMod::Rules::setSpecialSplit(const bool s) { specialSplit = s; } -void PokeGen::PokeMod::Rules::setSpecialDVSplit(const bool s) +void PokeMod::Rules::setSpecialDVSplit(const bool s) { specialDVSplit = s; } -void PokeGen::PokeMod::Rules::setMaxDVValue(const unsigned char m) throw(BoundsException) +void PokeMod::Rules::setMaxDVValue(const unsigned char m) throw(BoundsException) { if ((m != 16) && (m != 32)) throw(BoundsException("Rules", "maxDVValue")); maxDVValue = m; } -void PokeGen::PokeMod::Rules::setHappiness(const bool h) +void PokeMod::Rules::setHappiness(const bool h) { happiness = h; } -void PokeGen::PokeMod::Rules::setHappyFaintLoss(const unsigned h) +void PokeMod::Rules::setHappyFaintLoss(const unsigned h) { happyFaintLoss = h; } -void PokeGen::PokeMod::Rules::setHappyLevelGain(const unsigned h) +void PokeMod::Rules::setHappyLevelGain(const unsigned h) { happyLevelGain = h; } -void PokeGen::PokeMod::Rules::setHappySteps(const unsigned h) +void PokeMod::Rules::setHappySteps(const unsigned h) { happySteps = h; } -void PokeGen::PokeMod::Rules::setEffortValuesAllowed(const bool e) +void PokeMod::Rules::setEffortValuesAllowed(const bool e) { effortValuesAllowed = e; } -void PokeGen::PokeMod::Rules::setMaxTotalEV(const unsigned m) throw(Exception) +void PokeMod::Rules::setMaxTotalEV(const unsigned m) throw(Exception) { if (!effortValuesAllowed) throw(Exception("Rules", "no effort values")); maxTotalEV = m; } -void PokeGen::PokeMod::Rules::setMaxEVPerStat(const unsigned m) throw(Exception) +void PokeMod::Rules::setMaxEVPerStat(const unsigned m) throw(Exception) { if (!effortValuesAllowed) throw(Exception("Rules", "no effort values")); @@ -310,157 +310,157 @@ void PokeGen::PokeMod::Rules::setMaxEVPerStat(const unsigned m) throw(Exception) maxEVPerStat = m; } -void PokeGen::PokeMod::Rules::setPokerusChance(const unsigned n, const unsigned d) throw(Exception) +void PokeMod::Rules::setPokerusChance(const unsigned n, const unsigned d) throw(Exception) { pokerusChance.set(n, d); } -void PokeGen::PokeMod::Rules::setPokerusChanceNum(const unsigned n) throw(Exception) +void PokeMod::Rules::setPokerusChanceNum(const unsigned n) throw(Exception) { pokerusChance.setNum(n); } -void PokeGen::PokeMod::Rules::setPokerusChanceDenom(const unsigned d) throw(Exception) +void PokeMod::Rules::setPokerusChanceDenom(const unsigned d) throw(Exception) { pokerusChance.setDenom(d); } -bool PokeGen::PokeMod::Rules::getGenderAllowed() const +bool PokeMod::Rules::getGenderAllowed() const { return genderAllowed; } -bool PokeGen::PokeMod::Rules::getBreedingAllowed() const +bool PokeMod::Rules::getBreedingAllowed() const { return breedingAllowed; } -unsigned PokeGen::PokeMod::Rules::getHoldItems() const +unsigned PokeMod::Rules::getHoldItems() const { return holdItems; } -bool PokeGen::PokeMod::Rules::getCriticalDomains() const +bool PokeMod::Rules::getCriticalDomains() const { return criticalDomains; } -bool PokeGen::PokeMod::Rules::getAbilityAllowed() const +bool PokeMod::Rules::getAbilityAllowed() const { return abilityAllowed; } -bool PokeGen::PokeMod::Rules::getNatureAllowed() const +bool PokeMod::Rules::getNatureAllowed() const { return natureAllowed; } -unsigned PokeGen::PokeMod::Rules::getNumPokemonBoxes() const +unsigned PokeMod::Rules::getNumPokemonBoxes() const { return numPokemonBoxes; } -unsigned PokeGen::PokeMod::Rules::getNumPokemonPerBox() const +unsigned PokeMod::Rules::getNumPokemonPerBox() const { return numPokemonPerBox; } -unsigned PokeGen::PokeMod::Rules::getMaxParty() const +unsigned PokeMod::Rules::getMaxParty() const { return maxParty; } -unsigned PokeGen::PokeMod::Rules::getMaxFight() const +unsigned PokeMod::Rules::getMaxFight() const { return maxFight; } -unsigned PokeGen::PokeMod::Rules::getMaxMoves() const +unsigned PokeMod::Rules::getMaxMoves() const { return maxMoves; } -unsigned PokeGen::PokeMod::Rules::getMaxLevel() const +unsigned PokeMod::Rules::getMaxLevel() const { return maxLevel; } -unsigned PokeGen::PokeMod::Rules::getMaxMoney() const +unsigned PokeMod::Rules::getMaxMoney() const { return maxMoney; } -bool PokeGen::PokeMod::Rules::getHardCash() const +bool PokeMod::Rules::getHardCash() const { return hardCash; } -bool PokeGen::PokeMod::Rules::getSpecialSplit() const +bool PokeMod::Rules::getSpecialSplit() const { return specialSplit; } -bool PokeGen::PokeMod::Rules::getSpecialDVSplit() const +bool PokeMod::Rules::getSpecialDVSplit() const { return specialDVSplit; } -unsigned char PokeGen::PokeMod::Rules::getMaxDVValue() const +unsigned char PokeMod::Rules::getMaxDVValue() const { return maxDVValue; } -bool PokeGen::PokeMod::Rules::getHappiness() const +bool PokeMod::Rules::getHappiness() const { return happiness; } -unsigned PokeGen::PokeMod::Rules::getHappyFaintLoss() const +unsigned PokeMod::Rules::getHappyFaintLoss() const { return happyFaintLoss; } -unsigned PokeGen::PokeMod::Rules::getHappyLevelGain() const +unsigned PokeMod::Rules::getHappyLevelGain() const { return happyLevelGain; } -unsigned PokeGen::PokeMod::Rules::getHappySteps() const +unsigned PokeMod::Rules::getHappySteps() const { return happySteps; } -bool PokeGen::PokeMod::Rules::getEffortValuesAllowed() const +bool PokeMod::Rules::getEffortValuesAllowed() const { return effortValuesAllowed; } -unsigned PokeGen::PokeMod::Rules::getMaxTotalEV() const +unsigned PokeMod::Rules::getMaxTotalEV() const { return maxTotalEV; } -unsigned PokeGen::PokeMod::Rules::getMaxEVPerStat() const +unsigned PokeMod::Rules::getMaxEVPerStat() const { return maxEVPerStat; } -PokeGen::Frac PokeGen::PokeMod::Rules::getPokerusChance() const +Frac PokeMod::Rules::getPokerusChance() const { return pokerusChance; } -unsigned PokeGen::PokeMod::Rules::getPokerusChanceNum() const +unsigned PokeMod::Rules::getPokerusChanceNum() const { return pokerusChance.getNum(); } -unsigned PokeGen::PokeMod::Rules::getPokerusChanceDenom() const +unsigned PokeMod::Rules::getPokerusChanceDenom() const { return pokerusChance.getDenom(); } -PokeGen::PokeMod::Rules& PokeGen::PokeMod::Rules::operator=(const Rules& rhs) +PokeMod::Rules& PokeMod::Rules::operator=(const Rules& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Rules.h b/pokemod/Rules.h index 3ecf6e1e..f97361b8 100644 --- a/pokemod/Rules.h +++ b/pokemod/Rules.h @@ -28,109 +28,106 @@ #include "../general/Frac.h" #include "Object.h" -namespace PokeGen +namespace PokeMod { - 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 setNumPokemonBoxes(const unsigned n); - void setNumPokemonPerBox(const unsigned n); - 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 getNumPokemonBoxes() const; - unsigned getNumPokemonPerBox() 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; - unsigned getPokerusChanceNum() const; - unsigned getPokerusChanceDenom() const; - - Rules& operator=(const Rules& rhs); - private: - bool validate() const; - - bool genderAllowed; - bool breedingAllowed; - unsigned holdItems; - bool criticalDomains; - bool abilityAllowed; - bool natureAllowed; - unsigned numPokemonBoxes; - unsigned numPokemonPerBox; - 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 setNumPokemonBoxes(const unsigned n); + void setNumPokemonPerBox(const unsigned n); + 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 getNumPokemonBoxes() const; + unsigned getNumPokemonPerBox() 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; + unsigned getPokerusChanceNum() const; + unsigned getPokerusChanceDenom() const; + + Rules& operator=(const Rules& rhs); + private: + bool validate() const; + + bool genderAllowed; + bool breedingAllowed; + unsigned holdItems; + bool criticalDomains; + bool abilityAllowed; + bool natureAllowed; + unsigned numPokemonBoxes; + unsigned numPokemonPerBox; + 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; + }; } #include "Pokemod.h" diff --git a/pokemod/Species.cpp b/pokemod/Species.cpp index 60b5424a..8c53f4d0 100644 --- a/pokemod/Species.cpp +++ b/pokemod/Species.cpp @@ -22,9 +22,9 @@ #include "Species.h" -const char* PokeGen::PokeMod::Species::StyleStr[PokeGen::PokeMod::Species::End] = {"Fluctuating", "Fading", "Slow", "Normal", "Fast", "Erratic"}; +const char* PokeMod::Species::StyleStr[PokeMod::Species::End] = {"Fluctuating", "Fading", "Slow", "Normal", "Fast", "Erratic"}; -PokeGen::PokeMod::Species::Species(const Pokemod& par, const unsigned _id) : +PokeMod::Species::Species(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), growth(UINT_MAX), @@ -49,19 +49,19 @@ PokeGen::PokeMod::Species::Species(const Pokemod& par, const unsigned _id) : } } -PokeGen::PokeMod::Species::Species(const Pokemod& par, const Species& s, const unsigned _id) : +PokeMod::Species::Species(const Pokemod& par, const Species& s, const unsigned _id) : Object(par, _id) { *this = s; } -PokeGen::PokeMod::Species::Species(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::Species::Species(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::Species::validate() const +bool PokeMod::Species::validate() const { bool valid = true; pokemod.validationMsg(QString("---Species \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -293,7 +293,7 @@ bool PokeGen::PokeMod::Species::validate() const return valid; } -unsigned PokeGen::PokeMod::Species::getNewAbilityId() const +unsigned PokeMod::Species::getNewAbilityId() const { unsigned i = 0; for (; (i < getAbilityCount()) && (getAbilityByID(i) != UINT_MAX); ++i) @@ -301,7 +301,7 @@ unsigned PokeGen::PokeMod::Species::getNewAbilityId() const return i; } -unsigned PokeGen::PokeMod::Species::getNewEvolutionId() const +unsigned PokeMod::Species::getNewEvolutionId() const { unsigned i = 0; for (; (i < getEvolutionCount()) && (getEvolutionByID(i) != UINT_MAX); ++i) @@ -309,7 +309,7 @@ unsigned PokeGen::PokeMod::Species::getNewEvolutionId() const return i; } -unsigned PokeGen::PokeMod::Species::getNewItemId() const +unsigned PokeMod::Species::getNewItemId() const { unsigned i = 0; for (; (i < getItemCount()) && (getItemByID(i) != UINT_MAX); ++i) @@ -317,7 +317,7 @@ unsigned PokeGen::PokeMod::Species::getNewItemId() const return i; } -unsigned PokeGen::PokeMod::Species::getNewMoveId() const +unsigned PokeMod::Species::getNewMoveId() const { unsigned i = 0; for (; (i < getMoveCount()) && (getMoveByID(i) != UINT_MAX); ++i) @@ -325,7 +325,7 @@ unsigned PokeGen::PokeMod::Species::getNewMoveId() const return i; } -void PokeGen::PokeMod::Species::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::Species::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -406,7 +406,7 @@ void PokeGen::PokeMod::Species::load(const QString& fname, const unsigned _id) t } } -void PokeGen::PokeMod::Species::save() const throw(Exception) +void PokeMod::Species::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -450,19 +450,19 @@ void PokeGen::PokeMod::Species::save() const throw(Exception) i.next().save(name); } -void PokeGen::PokeMod::Species::setName(const QString& n) +void PokeMod::Species::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::Species::setBaseStat(const unsigned s, const unsigned b) throw(BoundsException) +void PokeMod::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 PokeGen::PokeMod::Species::setEffortValue(const unsigned s, const unsigned e) throw(Exception) +void PokeMod::Species::setEffortValue(const unsigned s, const unsigned e) throw(Exception) { if (!pokemod.getRules().getEffortValuesAllowed()) throw(Exception("Species", "effortValues not allowed")); @@ -473,81 +473,81 @@ void PokeGen::PokeMod::Species::setEffortValue(const unsigned s, const unsigned effortValues[s] = e; } -void PokeGen::PokeMod::Species::setGrowth(const unsigned g) throw(BoundsException) +void PokeMod::Species::setGrowth(const unsigned g) throw(BoundsException) { if (End <= g) throw(BoundsException("Species", "growth")); growth = g; } -void PokeGen::PokeMod::Species::setExperienceValue(const unsigned e) +void PokeMod::Species::setExperienceValue(const unsigned e) { experienceValue = e; } -void PokeGen::PokeMod::Species::setCatchValue(const unsigned char c) +void PokeMod::Species::setCatchValue(const unsigned char c) { catchValue = c; } -void PokeGen::PokeMod::Species::setRunChance(const unsigned n, const unsigned d) throw(Exception) +void PokeMod::Species::setRunChance(const unsigned n, const unsigned d) throw(Exception) { runChance.set(n, d); } -void PokeGen::PokeMod::Species::setRunChanceNumerator(const unsigned n) throw(Exception) +void PokeMod::Species::setRunChanceNumerator(const unsigned n) throw(Exception) { runChance.setNum(n); } -void PokeGen::PokeMod::Species::setRunChanceDenominator(const unsigned d) throw(Exception) +void PokeMod::Species::setRunChanceDenominator(const unsigned d) throw(Exception) { runChance.setDenom(d); } -void PokeGen::PokeMod::Species::setItemChance(const unsigned n, const unsigned d) throw(Exception) +void PokeMod::Species::setItemChance(const unsigned n, const unsigned d) throw(Exception) { itemChance.set(n, d); } -void PokeGen::PokeMod::Species::setItemChanceNumerator(const unsigned n) throw(Exception) +void PokeMod::Species::setItemChanceNumerator(const unsigned n) throw(Exception) { itemChance.setNum(n); } -void PokeGen::PokeMod::Species::setItemChanceDenominator(const unsigned d) throw(Exception) +void PokeMod::Species::setItemChanceDenominator(const unsigned d) throw(Exception) { itemChance.setDenom(d); } -void PokeGen::PokeMod::Species::setPokedexNumber(const unsigned p) +void PokeMod::Species::setPokedexNumber(const unsigned p) { pokedexNumber = p; } -void PokeGen::PokeMod::Species::setWeight(const unsigned w) +void PokeMod::Species::setWeight(const unsigned w) { weight = w; } -void PokeGen::PokeMod::Species::setHeightFeet(const unsigned f) +void PokeMod::Species::setHeightFeet(const unsigned f) { heightFeet = f; } -void PokeGen::PokeMod::Species::setHeightInches(const unsigned char i) throw(BoundsException) +void PokeMod::Species::setHeightInches(const unsigned char i) throw(BoundsException) { if (12 <= i) throw(BoundsException("Species", "heightInches")); heightInches = i; } -void PokeGen::PokeMod::Species::setPokedexEntry(const QString& p) +void PokeMod::Species::setPokedexEntry(const QString& p) { pokedexEntry = p; } -void PokeGen::PokeMod::Species::setFrontMaleSprite(const QString& fname) throw(Exception) +void PokeMod::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()) @@ -556,7 +556,7 @@ void PokeGen::PokeMod::Species::setFrontMaleSprite(const QString& fname) throw(E throw(SaveException("Species", file.fileName())); } -void PokeGen::PokeMod::Species::setBackMaleSprite(const QString& fname) throw(Exception) +void PokeMod::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()) @@ -565,7 +565,7 @@ void PokeGen::PokeMod::Species::setBackMaleSprite(const QString& fname) throw(Ex throw(SaveException("Species", file.fileName())); } -void PokeGen::PokeMod::Species::setFrontFemaleSprite(const QString& fname) throw(Exception) +void PokeMod::Species::setFrontFemaleSprite(const QString& fname) throw(Exception) { if (!pokemod.getRules().getGenderAllowed()) throw(Exception("Species", "gender is not allowed")); @@ -576,7 +576,7 @@ void PokeGen::PokeMod::Species::setFrontFemaleSprite(const QString& fname) throw throw(SaveException("Species", file.fileName())); } -void PokeGen::PokeMod::Species::setBackFemaleSprite(const QString& fname) throw(Exception) +void PokeMod::Species::setBackFemaleSprite(const QString& fname) throw(Exception) { if (!pokemod.getRules().getGenderAllowed()) throw(Exception("Species", "gender is not allowed")); @@ -587,7 +587,7 @@ void PokeGen::PokeMod::Species::setBackFemaleSprite(const QString& fname) throw( throw(SaveException("Species", file.fileName())); } -void PokeGen::PokeMod::Species::setListSprite(const QString& fname) throw(Exception) +void PokeMod::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()) @@ -596,44 +596,44 @@ void PokeGen::PokeMod::Species::setListSprite(const QString& fname) throw(Except throw(SaveException("Species", file.fileName())); } -void PokeGen::PokeMod::Species::setGenderFactor(const unsigned n, const unsigned d) throw(Exception) +void PokeMod::Species::setGenderFactor(const unsigned n, const unsigned d) throw(Exception) { genderFactor.set(n, d); } -void PokeGen::PokeMod::Species::setGenderFactorNum(const unsigned n) throw(Exception) +void PokeMod::Species::setGenderFactorNum(const unsigned n) throw(Exception) { genderFactor.setNum(n); } -void PokeGen::PokeMod::Species::setGenderFactorDenom(const unsigned d) throw(Exception) +void PokeMod::Species::setGenderFactorDenom(const unsigned d) throw(Exception) { genderFactor.setDenom(d); } -void PokeGen::PokeMod::Species::setEggSpecies(const unsigned e) throw(BoundsException) +void PokeMod::Species::setEggSpecies(const unsigned e) throw(BoundsException) { if (pokemod.getSpeciesByID(e) == UINT_MAX) throw(BoundsException("Species", "eggSpecies")); eggSpecies = e; } -void PokeGen::PokeMod::Species::setEggSteps(const unsigned e) +void PokeMod::Species::setEggSteps(const unsigned e) { eggSteps = e; } -void PokeGen::PokeMod::Species::setIsDitto(const bool i) +void PokeMod::Species::setIsDitto(const bool i) { isDitto = i; } -void PokeGen::PokeMod::Species::setNidoranGroup(const unsigned n) +void PokeMod::Species::setNidoranGroup(const unsigned n) { nidoranGroup = n; } -void PokeGen::PokeMod::Species::setType(const unsigned ty, const bool t) throw(Exception) +void PokeMod::Species::setType(const unsigned ty, const bool t) throw(Exception) { for (QMutableListIterator<unsigned> i(types); i.hasNext(); ) { @@ -650,7 +650,7 @@ void PokeGen::PokeMod::Species::setType(const unsigned ty, const bool t) throw(E types.append(ty); } -void PokeGen::PokeMod::Species::setEggGroup(const unsigned eg, const bool e) throw(Exception) +void PokeMod::Species::setEggGroup(const unsigned eg, const bool e) throw(Exception) { for (QMutableListIterator<unsigned> i(eggGroups); i.hasNext(); ) { @@ -667,131 +667,131 @@ void PokeGen::PokeMod::Species::setEggGroup(const unsigned eg, const bool e) thr eggGroups.append(eg); } -QString PokeGen::PokeMod::Species::getName() const +QString PokeMod::Species::getName() const { return name; } -unsigned PokeGen::PokeMod::Species::getBaseStat(const unsigned s) const throw(BoundsException) +unsigned PokeMod::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 PokeGen::PokeMod::Species::getEffortValue(const unsigned s) const throw(BoundsException) +unsigned PokeMod::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 PokeGen::PokeMod::Species::getGrowth() const +unsigned PokeMod::Species::getGrowth() const { return growth; } -unsigned PokeGen::PokeMod::Species::getExperienceValue() const +unsigned PokeMod::Species::getExperienceValue() const { return experienceValue; } -unsigned char PokeGen::PokeMod::Species::getCatchValue() const +unsigned char PokeMod::Species::getCatchValue() const { return catchValue; } -PokeGen::Frac PokeGen::PokeMod::Species::getRunChance() const +Frac PokeMod::Species::getRunChance() const { return runChance; } -unsigned PokeGen::PokeMod::Species::getRunChanceNumerator() const +unsigned PokeMod::Species::getRunChanceNumerator() const { return runChance.getNum(); } -unsigned PokeGen::PokeMod::Species::getRunChanceDenominator() const +unsigned PokeMod::Species::getRunChanceDenominator() const { return runChance.getDenom(); } -PokeGen::Frac PokeGen::PokeMod::Species::getItemChance() const +Frac PokeMod::Species::getItemChance() const { return itemChance; } -unsigned PokeGen::PokeMod::Species::getItemChanceNumerator() const +unsigned PokeMod::Species::getItemChanceNumerator() const { return itemChance.getNum(); } -unsigned PokeGen::PokeMod::Species::getItemChanceDenominator() const +unsigned PokeMod::Species::getItemChanceDenominator() const { return itemChance.getDenom(); } -unsigned PokeGen::PokeMod::Species::getPokedexNumber() const +unsigned PokeMod::Species::getPokedexNumber() const { return pokedexNumber; } -unsigned PokeGen::PokeMod::Species::getWeight() const +unsigned PokeMod::Species::getWeight() const { return weight; } -unsigned PokeGen::PokeMod::Species::getHeightFeet() const +unsigned PokeMod::Species::getHeightFeet() const { return heightFeet; } -unsigned PokeGen::PokeMod::Species::getHeightInches() const +unsigned PokeMod::Species::getHeightInches() const { return heightInches; } -QString PokeGen::PokeMod::Species::getPokedexEntry() const +QString PokeMod::Species::getPokedexEntry() const { return pokedexEntry; } -PokeGen::Frac PokeGen::PokeMod::Species::getGenderFactor() const +Frac PokeMod::Species::getGenderFactor() const { return genderFactor; } -unsigned PokeGen::PokeMod::Species::getGenderFactorNumerator() const +unsigned PokeMod::Species::getGenderFactorNumerator() const { return genderFactor.getNum(); } -unsigned PokeGen::PokeMod::Species::getGenderFactorDenominator() const +unsigned PokeMod::Species::getGenderFactorDenominator() const { return genderFactor.getDenom(); } -unsigned PokeGen::PokeMod::Species::getEggSpecies() const +unsigned PokeMod::Species::getEggSpecies() const { return eggSpecies; } -unsigned PokeGen::PokeMod::Species::getEggSteps() const +unsigned PokeMod::Species::getEggSteps() const { return eggSteps; } -bool PokeGen::PokeMod::Species::getIsDitto() const +bool PokeMod::Species::getIsDitto() const { return isDitto; } -unsigned PokeGen::PokeMod::Species::getNidoranGroup() const +unsigned PokeMod::Species::getNidoranGroup() const { return nidoranGroup; } -bool PokeGen::PokeMod::Species::getType(const unsigned ty) const +bool PokeMod::Species::getType(const unsigned ty) const { for (QListIterator<unsigned> i(types); i.hasNext(); ) { @@ -801,7 +801,7 @@ bool PokeGen::PokeMod::Species::getType(const unsigned ty) const return false; } -bool PokeGen::PokeMod::Species::getEggGroup(const unsigned eg) const +bool PokeMod::Species::getEggGroup(const unsigned eg) const { for (QListIterator<unsigned> i(eggGroups); i.hasNext(); ) { @@ -811,21 +811,21 @@ bool PokeGen::PokeMod::Species::getEggGroup(const unsigned eg) const return false; } -const PokeGen::PokeMod::SpeciesAbility& PokeGen::PokeMod::Species::getAbility(const unsigned i) const throw(IndexException) +const PokeMod::SpeciesAbility& PokeMod::Species::getAbility(const unsigned i) const throw(IndexException) { if (getAbilityCount() <= i) throw(IndexException("Species")); return abilities.at(i); } -PokeGen::PokeMod::SpeciesAbility& PokeGen::PokeMod::Species::getAbility(const unsigned i) throw(IndexException) +PokeMod::SpeciesAbility& PokeMod::Species::getAbility(const unsigned i) throw(IndexException) { if (getAbilityCount() <= i) throw(IndexException("Species")); return abilities[i]; } -unsigned PokeGen::PokeMod::Species::getAbilityByID(const unsigned _id) const +unsigned PokeMod::Species::getAbilityByID(const unsigned _id) const { for (unsigned i = 0; i < getAbilityCount(); ++i) { @@ -835,51 +835,51 @@ unsigned PokeGen::PokeMod::Species::getAbilityByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Species::getAbilityCount() const +unsigned PokeMod::Species::getAbilityCount() const { return abilities.size(); } -PokeGen::PokeMod::SpeciesAbility& PokeGen::PokeMod::Species::newAbility() +PokeMod::SpeciesAbility& PokeMod::Species::newAbility() { abilities.append(SpeciesAbility(pokemod, getNewAbilityId())); return abilities[getAbilityCount() - 1]; } -PokeGen::PokeMod::SpeciesAbility& PokeGen::PokeMod::Species::newAbility(const QString& fname) +PokeMod::SpeciesAbility& PokeMod::Species::newAbility(const QString& fname) { abilities.append(SpeciesAbility(pokemod, fname, getNewAbilityId())); return abilities[getAbilityCount() - 1]; } -PokeGen::PokeMod::SpeciesAbility& PokeGen::PokeMod::Species::newAbility(const SpeciesAbility& a) +PokeMod::SpeciesAbility& PokeMod::Species::newAbility(const SpeciesAbility& a) { abilities.append(SpeciesAbility(pokemod, a, getNewAbilityId())); return abilities[getAbilityCount() - 1]; } -void PokeGen::PokeMod::Species::deleteAbility(const unsigned i) throw(IndexException) +void PokeMod::Species::deleteAbility(const unsigned i) throw(IndexException) { if (getAbilityCount() <= i) throw(IndexException("Species")); abilities.removeAt(i); } -const PokeGen::PokeMod::SpeciesEvolution& PokeGen::PokeMod::Species::getEvolution(const unsigned i) const throw(IndexException) +const PokeMod::SpeciesEvolution& PokeMod::Species::getEvolution(const unsigned i) const throw(IndexException) { if (getEvolutionCount() <= i) throw(IndexException("Species")); return evolutions.at(i); } -PokeGen::PokeMod::SpeciesEvolution& PokeGen::PokeMod::Species::getEvolution(const unsigned i) throw(IndexException) +PokeMod::SpeciesEvolution& PokeMod::Species::getEvolution(const unsigned i) throw(IndexException) { if (getEvolutionCount() <= i) throw(IndexException("Species")); return evolutions[i]; } -unsigned PokeGen::PokeMod::Species::getEvolutionByID(const unsigned _id) const +unsigned PokeMod::Species::getEvolutionByID(const unsigned _id) const { for (unsigned i = 0; i < getEvolutionCount(); ++i) { @@ -889,51 +889,51 @@ unsigned PokeGen::PokeMod::Species::getEvolutionByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Species::getEvolutionCount() const +unsigned PokeMod::Species::getEvolutionCount() const { return evolutions.size(); } -PokeGen::PokeMod::SpeciesEvolution& PokeGen::PokeMod::Species::newEvolution() +PokeMod::SpeciesEvolution& PokeMod::Species::newEvolution() { evolutions.append(SpeciesEvolution(pokemod, getNewEvolutionId())); return evolutions[getEvolutionCount() - 1]; } -PokeGen::PokeMod::SpeciesEvolution& PokeGen::PokeMod::Species::newEvolution(const QString& fname) +PokeMod::SpeciesEvolution& PokeMod::Species::newEvolution(const QString& fname) { evolutions.append(SpeciesEvolution(pokemod, fname, getNewEvolutionId())); return evolutions[getEvolutionCount() - 1]; } -PokeGen::PokeMod::SpeciesEvolution& PokeGen::PokeMod::Species::newEvolution(const SpeciesEvolution& e) +PokeMod::SpeciesEvolution& PokeMod::Species::newEvolution(const SpeciesEvolution& e) { evolutions.append(SpeciesEvolution(pokemod, e, getNewEvolutionId())); return evolutions[getEvolutionCount() - 1]; } -void PokeGen::PokeMod::Species::deleteEvolution(const unsigned i) throw(IndexException) +void PokeMod::Species::deleteEvolution(const unsigned i) throw(IndexException) { if (getEvolutionCount() <= i) throw(IndexException("Species")); evolutions.removeAt(i); } -const PokeGen::PokeMod::SpeciesItem& PokeGen::PokeMod::Species::getItem(const unsigned i) const throw(IndexException) +const PokeMod::SpeciesItem& PokeMod::Species::getItem(const unsigned i) const throw(IndexException) { if (getItemCount() <= i) throw(IndexException("Species")); return items.at(i); } -PokeGen::PokeMod::SpeciesItem& PokeGen::PokeMod::Species::getItem(const unsigned i) throw(IndexException) +PokeMod::SpeciesItem& PokeMod::Species::getItem(const unsigned i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException("Species")); return items[i]; } -unsigned PokeGen::PokeMod::Species::getItemByID(const unsigned _id) const +unsigned PokeMod::Species::getItemByID(const unsigned _id) const { for (unsigned i = 0; i < getItemCount(); ++i) { @@ -943,51 +943,51 @@ unsigned PokeGen::PokeMod::Species::getItemByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Species::getItemCount() const +unsigned PokeMod::Species::getItemCount() const { return items.size(); } -PokeGen::PokeMod::SpeciesItem& PokeGen::PokeMod::Species::newItem() +PokeMod::SpeciesItem& PokeMod::Species::newItem() { items.append(SpeciesItem(pokemod, getNewItemId())); return items[getItemCount() - 1]; } -PokeGen::PokeMod::SpeciesItem& PokeGen::PokeMod::Species::newItem(const QString& fname) +PokeMod::SpeciesItem& PokeMod::Species::newItem(const QString& fname) { items.append(SpeciesItem(pokemod, fname, getNewItemId())); return items[getItemCount() - 1]; } -PokeGen::PokeMod::SpeciesItem& PokeGen::PokeMod::Species::newItem(const SpeciesItem& i) +PokeMod::SpeciesItem& PokeMod::Species::newItem(const SpeciesItem& i) { items.append(SpeciesItem(pokemod, i, getNewItemId())); return items[getItemCount() - 1]; } -void PokeGen::PokeMod::Species::deleteItem(const unsigned i) throw(IndexException) +void PokeMod::Species::deleteItem(const unsigned i) throw(IndexException) { if (getItemCount() <= i) throw(IndexException("Species")); items.removeAt(i); } -const PokeGen::PokeMod::SpeciesMove& PokeGen::PokeMod::Species::getMove(const unsigned i) const throw(IndexException) +const PokeMod::SpeciesMove& PokeMod::Species::getMove(const unsigned i) const throw(IndexException) { if (getMoveCount() <= i) throw(IndexException("Species")); return moves.at(i); } -PokeGen::PokeMod::SpeciesMove& PokeGen::PokeMod::Species::getMove(const unsigned i) throw(IndexException) +PokeMod::SpeciesMove& PokeMod::Species::getMove(const unsigned i) throw(IndexException) { if (getMoveCount() <= i) throw(IndexException("Species")); return moves[i]; } -unsigned PokeGen::PokeMod::Species::getMoveByID(const unsigned _id) const +unsigned PokeMod::Species::getMoveByID(const unsigned _id) const { for (unsigned i = 0; i < getMoveCount(); ++i) { @@ -997,37 +997,37 @@ unsigned PokeGen::PokeMod::Species::getMoveByID(const unsigned _id) const return UINT_MAX; } -unsigned PokeGen::PokeMod::Species::getMoveCount() const +unsigned PokeMod::Species::getMoveCount() const { return moves.size(); } -PokeGen::PokeMod::SpeciesMove& PokeGen::PokeMod::Species::newMove() +PokeMod::SpeciesMove& PokeMod::Species::newMove() { moves.append(SpeciesMove(pokemod, getNewMoveId())); return moves[getMoveCount() - 1]; } -PokeGen::PokeMod::SpeciesMove& PokeGen::PokeMod::Species::newMove(const QString& fname) +PokeMod::SpeciesMove& PokeMod::Species::newMove(const QString& fname) { moves.append(SpeciesMove(pokemod, fname, getNewMoveId())); return moves[getMoveCount() - 1]; } -PokeGen::PokeMod::SpeciesMove& PokeGen::PokeMod::Species::newMove(const SpeciesMove& m) +PokeMod::SpeciesMove& PokeMod::Species::newMove(const SpeciesMove& m) { moves.append(SpeciesMove(pokemod, m, getNewMoveId())); return moves[getMoveCount() - 1]; } -void PokeGen::PokeMod::Species::deleteMove(const unsigned i) throw(IndexException) +void PokeMod::Species::deleteMove(const unsigned i) throw(IndexException) { if (getMoveCount() <= i) throw(IndexException("Species")); moves.removeAt(i); } -PokeGen::PokeMod::Species& PokeGen::PokeMod::Species::operator=(const Species& rhs) +PokeMod::Species& PokeMod::Species::operator=(const Species& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Species.h b/pokemod/Species.h index 6a6cf378..05419760 100644 --- a/pokemod/Species.h +++ b/pokemod/Species.h @@ -40,167 +40,164 @@ #include "SpeciesItem.h" #include "SpeciesMove.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class Species : public Object { - class Species : public Object - { - public: - enum - { - Fluctuating = 0, - Fading = 1, - Slow = 2, - Normal = 3, - Fast = 5, - Erratic = 6, - End = 7 - }; - static const char* StyleStr[End]; - - 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 setIsDitto(const bool i); - 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; - unsigned getRunChanceNumerator() const; - unsigned getRunChanceDenominator() const; - Frac getItemChance() const; - unsigned getItemChanceNumerator() const; - unsigned getItemChanceDenominator() 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 getGenderFactorNumerator() const; - unsigned getGenderFactorDenominator() const; - unsigned getEggSpecies() const; - unsigned getEggSteps() const; - bool getIsDitto() 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); - unsigned getAbilityByID(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); - unsigned getEvolutionByID(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); - unsigned getItemByID(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); - unsigned getMoveByID(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; - bool isDitto; - 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 char* StyleStr[End]; + + 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 setIsDitto(const bool i); + 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; + unsigned getRunChanceNumerator() const; + unsigned getRunChanceDenominator() const; + Frac getItemChance() const; + unsigned getItemChanceNumerator() const; + unsigned getItemChanceDenominator() 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 getGenderFactorNumerator() const; + unsigned getGenderFactorDenominator() const; + unsigned getEggSpecies() const; + unsigned getEggSteps() const; + bool getIsDitto() 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); + unsigned getAbilityByID(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); + unsigned getEvolutionByID(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); + unsigned getItemByID(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); + unsigned getMoveByID(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; + bool isDitto; + 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 44e499e6..f6dfc1eb 100644 --- a/pokemod/SpeciesAbility.cpp +++ b/pokemod/SpeciesAbility.cpp @@ -22,26 +22,26 @@ #include "SpeciesAbility.h" -PokeGen::PokeMod::SpeciesAbility::SpeciesAbility(const Pokemod& par, const unsigned _id) : +PokeMod::SpeciesAbility::SpeciesAbility(const Pokemod& par, const unsigned _id) : Object(par, _id), ability(UINT_MAX), weight(1) { } -PokeGen::PokeMod::SpeciesAbility::SpeciesAbility(const Pokemod& par, const SpeciesAbility& a, const unsigned _id) : +PokeMod::SpeciesAbility::SpeciesAbility(const Pokemod& par, const SpeciesAbility& a, const unsigned _id) : Object(par, _id) { *this = a; } -PokeGen::PokeMod::SpeciesAbility::SpeciesAbility(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::SpeciesAbility::SpeciesAbility(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::SpeciesAbility::validate() const +bool PokeMod::SpeciesAbility::validate() const { bool valid = true; pokemod.validationMsg(QString("------Ability with id %1---").arg(id), Pokemod::V_Msg); @@ -58,7 +58,7 @@ bool PokeGen::PokeMod::SpeciesAbility::validate() const return valid; } -void PokeGen::PokeMod::SpeciesAbility::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::SpeciesAbility::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -69,7 +69,7 @@ void PokeGen::PokeMod::SpeciesAbility::load(const QString& fname, const unsigned ini.getValue("weight", weight, 1); } -void PokeGen::PokeMod::SpeciesAbility::save(const QString& species) const throw(Exception) +void PokeMod::SpeciesAbility::save(const QString& species) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -78,31 +78,31 @@ void PokeGen::PokeMod::SpeciesAbility::save(const QString& species) const throw( ini.save(QString("%1/species/%2/ability/%3.pini").arg(pokemod.getPath()).arg(species).arg(id)); } -void PokeGen::PokeMod::SpeciesAbility::setAbility(const unsigned a) throw(BoundsException) +void PokeMod::SpeciesAbility::setAbility(const unsigned a) throw(BoundsException) { if (pokemod.getAbilityByID(a) == UINT_MAX) throw(BoundsException("SpeciesAbility", "ability")); ability = a; } -void PokeGen::PokeMod::SpeciesAbility::setWeight(const unsigned w) throw(BoundsException) +void PokeMod::SpeciesAbility::setWeight(const unsigned w) throw(BoundsException) { if (!w) throw(BoundsException("SpeciesAbility", "weight")); weight = w; } -unsigned PokeGen::PokeMod::SpeciesAbility::getAbility() const +unsigned PokeMod::SpeciesAbility::getAbility() const { return ability; } -unsigned PokeGen::PokeMod::SpeciesAbility::getWeight() const +unsigned PokeMod::SpeciesAbility::getWeight() const { return weight; } -PokeGen::PokeMod::SpeciesAbility& PokeGen::PokeMod::SpeciesAbility::operator=(const SpeciesAbility& rhs) +PokeMod::SpeciesAbility& PokeMod::SpeciesAbility::operator=(const SpeciesAbility& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/SpeciesAbility.h b/pokemod/SpeciesAbility.h index 954af865..0c424f49 100644 --- a/pokemod/SpeciesAbility.h +++ b/pokemod/SpeciesAbility.h @@ -28,34 +28,31 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class SpeciesAbility : public Object { - 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 b431b96d..b41f82fc 100644 --- a/pokemod/SpeciesEvolution.cpp +++ b/pokemod/SpeciesEvolution.cpp @@ -22,10 +22,10 @@ #include "SpeciesEvolution.h" -const char* PokeGen::PokeMod::SpeciesEvolution::StyleStr[PokeGen::PokeMod::SpeciesEvolution::S_End] = {"Level", "Happiness", "Stat", "Item", "Trade", "TradeItem", "Personality", "Spare Slot"}; -const char* PokeGen::PokeMod::SpeciesEvolution::GiveHoldStr[PokeGen::PokeMod::SpeciesEvolution::G_End] = {"Give", "Hold"}; +const char* PokeMod::SpeciesEvolution::StyleStr[PokeMod::SpeciesEvolution::S_End] = {"Level", "Happiness", "Stat", "Item", "Trade", "TradeItem", "Personality", "Spare Slot"}; +const char* PokeMod::SpeciesEvolution::GiveHoldStr[PokeMod::SpeciesEvolution::G_End] = {"Give", "Hold"}; -PokeGen::PokeMod::SpeciesEvolution::SpeciesEvolution(const Pokemod& par, const unsigned _id) : +PokeMod::SpeciesEvolution::SpeciesEvolution(const Pokemod& par, const unsigned _id) : Object(par, _id), species(UINT_MAX), style(UINT_MAX), @@ -36,19 +36,19 @@ PokeGen::PokeMod::SpeciesEvolution::SpeciesEvolution(const Pokemod& par, const u { } -PokeGen::PokeMod::SpeciesEvolution::SpeciesEvolution(const Pokemod& par, const SpeciesEvolution& e, const unsigned _id) : +PokeMod::SpeciesEvolution::SpeciesEvolution(const Pokemod& par, const SpeciesEvolution& e, const unsigned _id) : Object(par, _id) { *this = e; } -PokeGen::PokeMod::SpeciesEvolution::SpeciesEvolution(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::SpeciesEvolution::SpeciesEvolution(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::SpeciesEvolution::validate() const +bool PokeMod::SpeciesEvolution::validate() const { bool valid = true; pokemod.validationMsg(QString("------Evolution with id %1---").arg(id), Pokemod::V_Msg); @@ -126,7 +126,7 @@ bool PokeGen::PokeMod::SpeciesEvolution::validate() const return valid; } -void PokeGen::PokeMod::SpeciesEvolution::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::SpeciesEvolution::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -141,7 +141,7 @@ void PokeGen::PokeMod::SpeciesEvolution::load(const QString& fname, const unsign ini.getValue("level", level, 0); } -void PokeGen::PokeMod::SpeciesEvolution::save(const QString& species) const throw(Exception) +void PokeMod::SpeciesEvolution::save(const QString& species) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -154,21 +154,21 @@ void PokeGen::PokeMod::SpeciesEvolution::save(const QString& species) const thro ini.save(QString("%1/species/%2/evolution/%3.pini").arg(pokemod.getPath()).arg(species).arg(id)); } -void PokeGen::PokeMod::SpeciesEvolution::setSpecies(const unsigned s) throw(BoundsException) +void PokeMod::SpeciesEvolution::setSpecies(const unsigned s) throw(BoundsException) { if (pokemod.getSpeciesByID(s) == UINT_MAX) throw(BoundsException("SpeciesEvolution", "species")); species = s; } -void PokeGen::PokeMod::SpeciesEvolution::setStyle(const unsigned s) throw(BoundsException) +void PokeMod::SpeciesEvolution::setStyle(const unsigned s) throw(BoundsException) { if (S_End <= s) throw(BoundsException("SpeciesEvolution", "style")); style = s; } -void PokeGen::PokeMod::SpeciesEvolution::setVal1(const unsigned v1) throw(Exception) +void PokeMod::SpeciesEvolution::setVal1(const unsigned v1) throw(Exception) { bool ok = false; switch (style) @@ -199,7 +199,7 @@ void PokeGen::PokeMod::SpeciesEvolution::setVal1(const unsigned v1) throw(Except val1 = v1; } -void PokeGen::PokeMod::SpeciesEvolution::setVal2(const unsigned v2) throw(Exception) +void PokeMod::SpeciesEvolution::setVal2(const unsigned v2) throw(Exception) { switch (style) { @@ -217,7 +217,7 @@ void PokeGen::PokeMod::SpeciesEvolution::setVal2(const unsigned v2) throw(Except val2 = v2; } -void PokeGen::PokeMod::SpeciesEvolution::setVal3(const unsigned v3) throw(Exception) +void PokeMod::SpeciesEvolution::setVal3(const unsigned v3) throw(Exception) { switch (style) { @@ -232,44 +232,44 @@ void PokeGen::PokeMod::SpeciesEvolution::setVal3(const unsigned v3) throw(Except val3 = v3; } -void PokeGen::PokeMod::SpeciesEvolution::setLevel(const unsigned l) throw(BoundsException) +void PokeMod::SpeciesEvolution::setLevel(const unsigned l) throw(BoundsException) { if (pokemod.getRules().getMaxLevel() < l) throw(BoundsException("SpeciesEvolution", "level")); level = l; } -unsigned PokeGen::PokeMod::SpeciesEvolution::getSpecies() const +unsigned PokeMod::SpeciesEvolution::getSpecies() const { return species; } -unsigned PokeGen::PokeMod::SpeciesEvolution::getStyle() const +unsigned PokeMod::SpeciesEvolution::getStyle() const { return style; } -unsigned PokeGen::PokeMod::SpeciesEvolution::getVal1() const +unsigned PokeMod::SpeciesEvolution::getVal1() const { return val1; } -unsigned PokeGen::PokeMod::SpeciesEvolution::getVal2() const +unsigned PokeMod::SpeciesEvolution::getVal2() const { return val2; } -unsigned PokeGen::PokeMod::SpeciesEvolution::getVal3() const +unsigned PokeMod::SpeciesEvolution::getVal3() const { return val3; } -unsigned PokeGen::PokeMod::SpeciesEvolution::getLevel() const +unsigned PokeMod::SpeciesEvolution::getLevel() const { return level; } -PokeGen::PokeMod::SpeciesEvolution& PokeGen::PokeMod::SpeciesEvolution::operator=(const SpeciesEvolution& rhs) +PokeMod::SpeciesEvolution& PokeMod::SpeciesEvolution::operator=(const SpeciesEvolution& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/SpeciesEvolution.h b/pokemod/SpeciesEvolution.h index 1b3bd42b..49218001 100644 --- a/pokemod/SpeciesEvolution.h +++ b/pokemod/SpeciesEvolution.h @@ -28,68 +28,65 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class SpeciesEvolution : public Object { - 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 char* StyleStr[S_End]; - - enum GiveHold - { - G_Give = 0, - G_Hold = 1, - G_End = 2 - }; - static const char* GiveHoldStr[G_End]; - - 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 char* StyleStr[S_End]; + + enum GiveHold + { + G_Give = 0, + G_Hold = 1, + G_End = 2 + }; + static const char* GiveHoldStr[G_End]; + + 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 da867e1e..4d132670 100644 --- a/pokemod/SpeciesItem.cpp +++ b/pokemod/SpeciesItem.cpp @@ -22,26 +22,26 @@ #include "SpeciesItem.h" -PokeGen::PokeMod::SpeciesItem::SpeciesItem(const Pokemod& par, const unsigned _id) : +PokeMod::SpeciesItem::SpeciesItem(const Pokemod& par, const unsigned _id) : Object(par, _id), item(UINT_MAX), weight(1) { } -PokeGen::PokeMod::SpeciesItem::SpeciesItem(const Pokemod& par, const SpeciesItem& i, const unsigned _id) : +PokeMod::SpeciesItem::SpeciesItem(const Pokemod& par, const SpeciesItem& i, const unsigned _id) : Object(par, _id) { *this = i; } -PokeGen::PokeMod::SpeciesItem::SpeciesItem(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::SpeciesItem::SpeciesItem(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::SpeciesItem::validate() const +bool PokeMod::SpeciesItem::validate() const { bool valid = true; pokemod.validationMsg(QString("------Item with id %1---").arg(id), Pokemod::V_Msg); @@ -58,7 +58,7 @@ bool PokeGen::PokeMod::SpeciesItem::validate() const return valid; } -void PokeGen::PokeMod::SpeciesItem::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::SpeciesItem::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -69,7 +69,7 @@ void PokeGen::PokeMod::SpeciesItem::load(const QString& fname, const unsigned _i ini.getValue("weight", weight, 1); } -void PokeGen::PokeMod::SpeciesItem::save(const QString& species) const throw(Exception) +void PokeMod::SpeciesItem::save(const QString& species) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -78,31 +78,31 @@ void PokeGen::PokeMod::SpeciesItem::save(const QString& species) const throw(Exc ini.save(QString("%1/species/%2/item/%3.pini").arg(pokemod.getPath()).arg(species).arg(id)); } -void PokeGen::PokeMod::SpeciesItem::setItem(const unsigned i) throw(BoundsException) +void PokeMod::SpeciesItem::setItem(const unsigned i) throw(BoundsException) { if (pokemod.getItemByID(i) == UINT_MAX) throw(BoundsException("SpeciesItem", "item")); item = i; } -void PokeGen::PokeMod::SpeciesItem::setWeight(const unsigned w) throw(BoundsException) +void PokeMod::SpeciesItem::setWeight(const unsigned w) throw(BoundsException) { if (!w) throw(BoundsException("SpeciesItem", "weight")); weight = w; } -unsigned PokeGen::PokeMod::SpeciesItem::getItem() const +unsigned PokeMod::SpeciesItem::getItem() const { return item; } -unsigned PokeGen::PokeMod::SpeciesItem::getWeight() const +unsigned PokeMod::SpeciesItem::getWeight() const { return weight; } -PokeGen::PokeMod::SpeciesItem& PokeGen::PokeMod::SpeciesItem::operator=(const SpeciesItem& rhs) +PokeMod::SpeciesItem& PokeMod::SpeciesItem::operator=(const SpeciesItem& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/SpeciesItem.h b/pokemod/SpeciesItem.h index 68477a41..9fa9fda8 100644 --- a/pokemod/SpeciesItem.h +++ b/pokemod/SpeciesItem.h @@ -28,34 +28,31 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class SpeciesItem : public Object { - 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 99ef8dc1..36606966 100644 --- a/pokemod/SpeciesMove.cpp +++ b/pokemod/SpeciesMove.cpp @@ -22,7 +22,7 @@ #include "SpeciesMove.h" -PokeGen::PokeMod::SpeciesMove::SpeciesMove(const Pokemod& par, const unsigned _id) : +PokeMod::SpeciesMove::SpeciesMove(const Pokemod& par, const unsigned _id) : Object(par, _id), move(UINT_MAX), level(0), @@ -30,19 +30,19 @@ PokeGen::PokeMod::SpeciesMove::SpeciesMove(const Pokemod& par, const unsigned _i { } -PokeGen::PokeMod::SpeciesMove::SpeciesMove(const Pokemod& par, const SpeciesMove& m, const unsigned _id) : +PokeMod::SpeciesMove::SpeciesMove(const Pokemod& par, const SpeciesMove& m, const unsigned _id) : Object(par, _id) { *this = m; } -PokeGen::PokeMod::SpeciesMove::SpeciesMove(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::SpeciesMove::SpeciesMove(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::SpeciesMove::validate() const +bool PokeMod::SpeciesMove::validate() const { bool valid = true; pokemod.validationMsg(QString("------Move with id %1---").arg(id), Pokemod::V_Msg); @@ -64,7 +64,7 @@ bool PokeGen::PokeMod::SpeciesMove::validate() const return valid; } -void PokeGen::PokeMod::SpeciesMove::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::SpeciesMove::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -76,7 +76,7 @@ void PokeGen::PokeMod::SpeciesMove::load(const QString& fname, const unsigned _i ini.getValue("wild", wild, 0); } -void PokeGen::PokeMod::SpeciesMove::save(const QString& species) const throw(Exception) +void PokeMod::SpeciesMove::save(const QString& species) const throw(Exception) { Ini ini; ini.addField("id", id); @@ -86,43 +86,43 @@ void PokeGen::PokeMod::SpeciesMove::save(const QString& species) const throw(Exc ini.save(QString("%1/species/%2/move/%3.pini").arg(pokemod.getPath()).arg(species).arg(id)); } -void PokeGen::PokeMod::SpeciesMove::setMove(const unsigned m) throw(BoundsException) +void PokeMod::SpeciesMove::setMove(const unsigned m) throw(BoundsException) { if (pokemod.getMoveByID(m) == UINT_MAX) throw(BoundsException("SpeciesMove", "move")); move = m; } -void PokeGen::PokeMod::SpeciesMove::setLevel(const unsigned l) throw(BoundsException) +void PokeMod::SpeciesMove::setLevel(const unsigned l) throw(BoundsException) { if (pokemod.getRules().getMaxLevel() <= l) throw(BoundsException("SpeciesMove", "level")); level = l; } -void PokeGen::PokeMod::SpeciesMove::setWild(const unsigned w) throw(BoundsException) +void PokeMod::SpeciesMove::setWild(const unsigned w) throw(BoundsException) { if (pokemod.getRules().getMaxLevel() <= w) throw(BoundsException("SpeciesMove", "wild")); wild = w; } -unsigned PokeGen::PokeMod::SpeciesMove::getMove() const +unsigned PokeMod::SpeciesMove::getMove() const { return move; } -unsigned PokeGen::PokeMod::SpeciesMove::getLevel() const +unsigned PokeMod::SpeciesMove::getLevel() const { return level; } -unsigned PokeGen::PokeMod::SpeciesMove::getWild() const +unsigned PokeMod::SpeciesMove::getWild() const { return wild; } -PokeGen::PokeMod::SpeciesMove& PokeGen::PokeMod::SpeciesMove::operator=(const SpeciesMove& rhs) +PokeMod::SpeciesMove& PokeMod::SpeciesMove::operator=(const SpeciesMove& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/SpeciesMove.h b/pokemod/SpeciesMove.h index 87c35329..3d5e60e3 100644 --- a/pokemod/SpeciesMove.h +++ b/pokemod/SpeciesMove.h @@ -28,37 +28,34 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class SpeciesMove : public Object { - 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 c4ec13fd..626b249d 100644 --- a/pokemod/Store.cpp +++ b/pokemod/Store.cpp @@ -22,25 +22,25 @@ #include "Store.h" -PokeGen::PokeMod::Store::Store(const Pokemod& par, const unsigned _id) : +PokeMod::Store::Store(const Pokemod& par, const unsigned _id) : Object(par, _id), name("") { } -PokeGen::PokeMod::Store::Store(const Pokemod& par, const Store& s, const unsigned _id) : +PokeMod::Store::Store(const Pokemod& par, const Store& s, const unsigned _id) : Object(par, _id) { *this = s; } -PokeGen::PokeMod::Store::Store(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::Store::Store(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::Store::validate() const +bool PokeMod::Store::validate() const { bool valid = true; pokemod.validationMsg(QString("---Store \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -75,7 +75,7 @@ bool PokeGen::PokeMod::Store::validate() const return valid; } -void PokeGen::PokeMod::Store::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::Store::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -95,7 +95,7 @@ void PokeGen::PokeMod::Store::load(const QString& fname, const unsigned _id) thr } } -void PokeGen::PokeMod::Store::save() const throw(Exception) +void PokeMod::Store::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -106,12 +106,12 @@ void PokeGen::PokeMod::Store::save() const throw(Exception) ini.save(QString("%1/store/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeGen::PokeMod::Store::setName(const QString& n) +void PokeMod::Store::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::Store::setItem(const unsigned itm, const bool it) throw(Exception) +void PokeMod::Store::setItem(const unsigned itm, const bool it) throw(Exception) { for (QMutableListIterator<unsigned> i(items); i.hasNext(); ) { @@ -128,12 +128,12 @@ void PokeGen::PokeMod::Store::setItem(const unsigned itm, const bool it) throw(E items.append(itm); } -QString PokeGen::PokeMod::Store::getName() const +QString PokeMod::Store::getName() const { return name; } -bool PokeGen::PokeMod::Store::getItem(const unsigned it) const +bool PokeMod::Store::getItem(const unsigned it) const { for (QListIterator<unsigned> i(items); i.hasNext(); ) { @@ -143,7 +143,7 @@ bool PokeGen::PokeMod::Store::getItem(const unsigned it) const return false; } -PokeGen::PokeMod::Store& PokeGen::PokeMod::Store::operator=(const Store& rhs) +PokeMod::Store& PokeMod::Store::operator=(const Store& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Store.h b/pokemod/Store.h index 56b81ef1..c81a6571 100644 --- a/pokemod/Store.h +++ b/pokemod/Store.h @@ -32,34 +32,31 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class Store : public Object { - 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 a4ab5b2d..6c4b98d2 100644 --- a/pokemod/Tile.cpp +++ b/pokemod/Tile.cpp @@ -22,11 +22,11 @@ #include "Tile.h" -const char* PokeGen::PokeMod::Tile::HMTypeStr[PokeGen::PokeMod::Tile::H_End] = +const char* PokeMod::Tile::HMTypeStr[PokeMod::Tile::H_End] = {"None", "Surf", "Dive", "Waterfall", "Whirlpool", "Cut", "Headbutt", "Rock Climb", "Rock Smash"}; -const char* PokeGen::PokeMod::Tile::ForceStr[PokeGen::PokeMod::Tile::F_End] = {"None", "Slip", "Stop", "Force", "Push"}; +const char* PokeMod::Tile::ForceStr[PokeMod::Tile::F_End] = {"None", "Slip", "Stop", "Force", "Push"}; -PokeGen::PokeMod::Tile::Tile(const Pokemod& par, const unsigned _id) : +PokeMod::Tile::Tile(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), pic(""), @@ -41,20 +41,20 @@ PokeGen::PokeMod::Tile::Tile(const Pokemod& par, const unsigned _id) : from[i] = false; } -PokeGen::PokeMod::Tile::Tile(const Pokemod& par, const Tile& t, const unsigned _id) : +PokeMod::Tile::Tile(const Pokemod& par, const Tile& t, const unsigned _id) : Object(par, _id) { *this = t; } -PokeGen::PokeMod::Tile::Tile(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::Tile::Tile(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id), pic("") { load(fname, _id); } -bool PokeGen::PokeMod::Tile::validate() const +bool PokeMod::Tile::validate() const { bool valid = true; pokemod.validationMsg(QString("---Tile \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -104,7 +104,7 @@ bool PokeGen::PokeMod::Tile::validate() const return valid; } -void PokeGen::PokeMod::Tile::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::Tile::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -129,7 +129,7 @@ void PokeGen::PokeMod::Tile::load(const QString& fname, const unsigned _id) thro ini.getValue("forceDirection", forceDirection); } -void PokeGen::PokeMod::Tile::save() const throw(Exception) +void PokeMod::Tile::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -149,46 +149,46 @@ void PokeGen::PokeMod::Tile::save() const throw(Exception) ini.save(QString("%1/tile/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeGen::PokeMod::Tile::setName(const QString& n) +void PokeMod::Tile::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::Tile::setPic(const QString& p) throw(OpenException) +void PokeMod::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 PokeGen::PokeMod::Tile::setFrom(const unsigned d, const bool f) throw(BoundsException) +void PokeMod::Tile::setFrom(const unsigned d, const bool f) throw(BoundsException) { if (D_End <= d) throw(BoundsException("Tile", "direction")); from[d] = f; } -void PokeGen::PokeMod::Tile::setIsWild(const bool i) +void PokeMod::Tile::setIsWild(const bool i) { isWild = i; } -void PokeGen::PokeMod::Tile::setWildChance(const unsigned n, const unsigned d) throw(Exception) +void PokeMod::Tile::setWildChance(const unsigned n, const unsigned d) throw(Exception) { wildChance.set(n, d); } -void PokeGen::PokeMod::Tile::setWildChanceNumerator(const unsigned n) throw(Exception) +void PokeMod::Tile::setWildChanceNumerator(const unsigned n) throw(Exception) { wildChance.setNum(n); } -void PokeGen::PokeMod::Tile::setWildChanceDenominator(const unsigned d) throw(Exception) +void PokeMod::Tile::setWildChanceDenominator(const unsigned d) throw(Exception) { wildChance.setDenom(d); } -void PokeGen::PokeMod::Tile::setHMType(const unsigned h) throw(BoundsException) +void PokeMod::Tile::setHMType(const unsigned h) throw(BoundsException) { if (H_End <= h) throw(BoundsException("Tile", "hmType")); @@ -196,7 +196,7 @@ void PokeGen::PokeMod::Tile::setHMType(const unsigned h) throw(BoundsException) under = UINT_MAX; } -void PokeGen::PokeMod::Tile::setUnder(const unsigned u) throw(Exception) +void PokeMod::Tile::setUnder(const unsigned u) throw(Exception) { if ((hmType != H_Whirlpool) || (hmType != H_Cut) || (hmType != H_RockSmash)) throw(UnusedException("Tile", "under")); @@ -205,78 +205,78 @@ void PokeGen::PokeMod::Tile::setUnder(const unsigned u) throw(Exception) under = u; } -void PokeGen::PokeMod::Tile::setForceType(const unsigned f) throw(BoundsException) +void PokeMod::Tile::setForceType(const unsigned f) throw(BoundsException) { if (F_End <= f) throw(BoundsException("Tile", "forceType")); forceType = f; } -void PokeGen::PokeMod::Tile::setForceDirection(const unsigned f) throw(BoundsException) +void PokeMod::Tile::setForceDirection(const unsigned f) throw(BoundsException) { if (D_End <= f) throw(BoundsException("Tile", "forceDirection")); forceDirection = f; } -QString PokeGen::PokeMod::Tile::getName() const +QString PokeMod::Tile::getName() const { return name; } -QString PokeGen::PokeMod::Tile::getPic() const +QString PokeMod::Tile::getPic() const { return pic; } -bool PokeGen::PokeMod::Tile::getFrom(const unsigned d) const throw(BoundsException) +bool PokeMod::Tile::getFrom(const unsigned d) const throw(BoundsException) { if (D_End <= d) throw(BoundsException("Tile", "direction")); return from[d]; } -bool PokeGen::PokeMod::Tile::getIsWild() const +bool PokeMod::Tile::getIsWild() const { return isWild; } -PokeGen::Frac PokeGen::PokeMod::Tile::getWildChance() const +Frac PokeMod::Tile::getWildChance() const { return wildChance; } -unsigned PokeGen::PokeMod::Tile::getWildChanceNumerator() const +unsigned PokeMod::Tile::getWildChanceNumerator() const { return wildChance.getNum(); } -unsigned PokeGen::PokeMod::Tile::getWildChanceDenominator() const +unsigned PokeMod::Tile::getWildChanceDenominator() const { return wildChance.getDenom(); } -unsigned PokeGen::PokeMod::Tile::getHMType() const +unsigned PokeMod::Tile::getHMType() const { return hmType; } -unsigned PokeGen::PokeMod::Tile::getUnder() const +unsigned PokeMod::Tile::getUnder() const { return under; } -unsigned PokeGen::PokeMod::Tile::getForceType() const +unsigned PokeMod::Tile::getForceType() const { return forceType; } -unsigned PokeGen::PokeMod::Tile::getForceDirection() const +unsigned PokeMod::Tile::getForceDirection() const { return forceDirection; } -PokeGen::PokeMod::Tile& PokeGen::PokeMod::Tile::operator=(const Tile& rhs) +PokeMod::Tile& PokeMod::Tile::operator=(const Tile& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Tile.h b/pokemod/Tile.h index e56c1589..5a5b4c7c 100644 --- a/pokemod/Tile.h +++ b/pokemod/Tile.h @@ -28,85 +28,82 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class Tile : public Object { - class Tile : public Object - { - public: - enum HMType - { - H_None = 0, - H_Surf = 1, - H_Dive = 2, - H_Waterfall = 3, - H_Whirlpool = 4, - H_Cut = 5, - H_Headbutt = 6, - H_RockClimb = 7, - H_RockSmash = 8, - H_End = 9 - }; - static const char* HMTypeStr[H_End]; - - enum Force - { - F_None = 0, - F_Slip = 1, - F_Stop = 2, - F_Force = 3, - F_Push = 4, - F_End = 5 - }; - static const char* ForceStr[F_End]; - - 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 setIsWild(const bool i); - 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(BoundsException); - - QString getName() const; - QString getPic() const; - bool getFrom(const unsigned d) const throw(BoundsException); - bool getIsWild() const; - Frac getWildChance() const; - unsigned getWildChanceNumerator() const; - unsigned getWildChanceDenominator() 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]; - bool isWild; - Frac wildChance; - unsigned hmType; - unsigned under; - unsigned forceType; - unsigned forceDirection; - }; - } + public: + enum HMType + { + H_None = 0, + H_Surf = 1, + H_Dive = 2, + H_Waterfall = 3, + H_Whirlpool = 4, + H_Cut = 5, + H_Headbutt = 6, + H_RockClimb = 7, + H_RockSmash = 8, + H_End = 9 + }; + static const char* HMTypeStr[H_End]; + + enum Force + { + F_None = 0, + F_Slip = 1, + F_Stop = 2, + F_Force = 3, + F_Push = 4, + F_End = 5 + }; + static const char* ForceStr[F_End]; + + 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 setIsWild(const bool i); + 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(BoundsException); + + QString getName() const; + QString getPic() const; + bool getFrom(const unsigned d) const throw(BoundsException); + bool getIsWild() const; + Frac getWildChance() const; + unsigned getWildChanceNumerator() const; + unsigned getWildChanceDenominator() 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]; + bool isWild; + Frac wildChance; + unsigned hmType; + unsigned under; + unsigned forceType; + unsigned forceDirection; + }; } #endif diff --git a/pokemod/Time.cpp b/pokemod/Time.cpp index 9f180524..f9f0e174 100644 --- a/pokemod/Time.cpp +++ b/pokemod/Time.cpp @@ -22,7 +22,7 @@ #include "Time.h" -PokeGen::PokeMod::Time::Time(const Pokemod& par, const unsigned _id) : +PokeMod::Time::Time(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), startHour(0), @@ -30,19 +30,19 @@ PokeGen::PokeMod::Time::Time(const Pokemod& par, const unsigned _id) : { } -PokeGen::PokeMod::Time::Time(const Pokemod& par, const Time& t, const unsigned _id) : +PokeMod::Time::Time(const Pokemod& par, const Time& t, const unsigned _id) : Object(par, _id) { *this = t; } -PokeGen::PokeMod::Time::Time(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::Time::Time(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::Time::validate() const +bool PokeMod::Time::validate() const { bool valid = true; pokemod.validationMsg(QString("---Time \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -64,7 +64,7 @@ bool PokeGen::PokeMod::Time::validate() const return valid; } -void PokeGen::PokeMod::Time::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::Time::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -76,7 +76,7 @@ void PokeGen::PokeMod::Time::load(const QString& fname, const unsigned _id) thro ini.getValue("startMinute", startMinute, 0); } -void PokeGen::PokeMod::Time::save() const throw(Exception) +void PokeMod::Time::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -86,41 +86,41 @@ void PokeGen::PokeMod::Time::save() const throw(Exception) ini.save(QString("%1/time/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeGen::PokeMod::Time::setName(const QString& n) +void PokeMod::Time::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::Time::setStartHour(const unsigned h) throw(BoundsException) +void PokeMod::Time::setStartHour(const unsigned h) throw(BoundsException) { if (24 <= h) throw(BoundsException("Time", "startHour")); startHour = h; } -void PokeGen::PokeMod::Time::setStartMinute(const unsigned m) throw(BoundsException) +void PokeMod::Time::setStartMinute(const unsigned m) throw(BoundsException) { if (60 <= m) throw(BoundsException("Time", "startMinute")); startMinute = m; } -QString PokeGen::PokeMod::Time::getName() const +QString PokeMod::Time::getName() const { return name; } -unsigned PokeGen::PokeMod::Time::getStartHour() const +unsigned PokeMod::Time::getStartHour() const { return startHour; } -unsigned PokeGen::PokeMod::Time::getStartMinute() const +unsigned PokeMod::Time::getStartMinute() const { return startMinute; } -PokeGen::PokeMod::Time& PokeGen::PokeMod::Time::operator=(const Time& rhs) +PokeMod::Time& PokeMod::Time::operator=(const Time& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Time.h b/pokemod/Time.h index 13591a34..9f7b296d 100644 --- a/pokemod/Time.h +++ b/pokemod/Time.h @@ -28,37 +28,34 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class Time : public Object { - 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 ee2d1f2d..f9ae30dc 100644 --- a/pokemod/Type.cpp +++ b/pokemod/Type.cpp @@ -22,26 +22,26 @@ #include "Type.h" -PokeGen::PokeMod::Type::Type(const Pokemod& par, const unsigned _id) : +PokeMod::Type::Type(const Pokemod& par, const unsigned _id) : Object(par, _id), name(""), stab(1, 1, true) { } -PokeGen::PokeMod::Type::Type(const Pokemod& par, const Type& t, const unsigned _id) : +PokeMod::Type::Type(const Pokemod& par, const Type& t, const unsigned _id) : Object(par, _id) { *this = t; } -PokeGen::PokeMod::Type::Type(const Pokemod& par, const QString& fname, const unsigned _id) : +PokeMod::Type::Type(const Pokemod& par, const QString& fname, const unsigned _id) : Object(par, _id) { load(fname, _id); } -bool PokeGen::PokeMod::Type::validate() const +bool PokeMod::Type::validate() const { bool valid = true; pokemod.validationMsg(QString("---Type \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); @@ -53,7 +53,7 @@ bool PokeGen::PokeMod::Type::validate() const return valid; } -void PokeGen::PokeMod::Type::load(const QString& fname, const unsigned _id) throw(Exception) +void PokeMod::Type::load(const QString& fname, const unsigned _id) throw(Exception) { Ini ini(fname); if (_id == UINT_MAX) @@ -68,7 +68,7 @@ void PokeGen::PokeMod::Type::load(const QString& fname, const unsigned _id) thro stab.set(i, j, true); } -void PokeGen::PokeMod::Type::save() const throw(Exception) +void PokeMod::Type::save() const throw(Exception) { Ini ini; ini.addField("id", id); @@ -78,47 +78,47 @@ void PokeGen::PokeMod::Type::save() const throw(Exception) ini.save(QString("%1/type/%2.pini").arg(pokemod.getPath()).arg(name)); } -void PokeGen::PokeMod::Type::setName(const QString& n) +void PokeMod::Type::setName(const QString& n) { name = n; } -void PokeGen::PokeMod::Type::setStab(const unsigned n, const unsigned d) throw(Exception) +void PokeMod::Type::setStab(const unsigned n, const unsigned d) throw(Exception) { stab.set(n, d); } -void PokeGen::PokeMod::Type::setStabNum(const unsigned n) throw(Exception) +void PokeMod::Type::setStabNum(const unsigned n) throw(Exception) { stab.setNum(n); } -void PokeGen::PokeMod::Type::setStabDenom(const unsigned d) throw(Exception) +void PokeMod::Type::setStabDenom(const unsigned d) throw(Exception) { stab.setDenom(d); } -QString PokeGen::PokeMod::Type::getName() const +QString PokeMod::Type::getName() const { return name; } -PokeGen::Frac PokeGen::PokeMod::Type::getStab() const +Frac PokeMod::Type::getStab() const { return stab; } -unsigned PokeGen::PokeMod::Type::getStabNum() const +unsigned PokeMod::Type::getStabNum() const { return stab.getNum(); } -unsigned PokeGen::PokeMod::Type::getStabDenom() const +unsigned PokeMod::Type::getStabDenom() const { return stab.getDenom(); } -PokeGen::PokeMod::Type& PokeGen::PokeMod::Type::operator=(const Type& rhs) +PokeMod::Type& PokeMod::Type::operator=(const Type& rhs) { if (this == &rhs) return *this; diff --git a/pokemod/Type.h b/pokemod/Type.h index cec9ad1a..fd9a46f5 100644 --- a/pokemod/Type.h +++ b/pokemod/Type.h @@ -29,38 +29,35 @@ #include "Object.h" #include "Pokemod.h" -namespace PokeGen +namespace PokeMod { - namespace PokeMod + class Type : public Object { - 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; - unsigned getStabNum() const; - unsigned getStabDenom() 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; + unsigned getStabNum() const; + unsigned getStabDenom() const; + + Type& operator=(const Type& rhs); + private: + bool validate() const; + + QString name; + Frac stab; + }; } #endif diff --git a/pokemod/pokemod.pro b/pokemod/pokemod.pro index a6b89891..44cd6041 100644 --- a/pokemod/pokemod.pro +++ b/pokemod/pokemod.pro @@ -1,6 +1,5 @@ OBJECTS_DIR = ../../obj/pokemod DESTDIR = ../../lib -VERSION = 0.1.0 TEMPLATE = lib LIBS += -L../../lib -lgeneral diff --git a/pokemod/pokemod_inc.h b/pokemod/pokemod_inc.h index cae71f36..3923f2e5 100644 --- a/pokemod/pokemod_inc.h +++ b/pokemod/pokemod_inc.h @@ -23,45 +23,42 @@ #ifndef __POKEMOD_H__ #define __POKEMOD_H__ -namespace PokeGen +namespace PokeMod { - namespace PokeMod - { - class Ability; - class AbilityEffect; - class Author; - class Badge; - class CoinList; - class CoinListObject; - class Dialog; - class EggGroup; - class Item; - class ItemEffect; - class ItemType; - class Map; - class MapEffect; - class MapTrainer; - class MapTrainerPokemon; - class MapWarp; - class MapWildList; - class MapWildListPokemon; - class Move; - class MoveEffect; - class Nature; - class Pokemod; - class Rules; - class Species; - class SpeciesAbility; - class SpeciesEvolution; - class SpeciesItem; - class SpeciesMove; - class Status; - class StatusEffect; - class Store; - class Tile; - class Time; - class Type; - } + class Ability; + class AbilityEffect; + class Author; + class Badge; + class CoinList; + class CoinListObject; + class Dialog; + class EggGroup; + class Item; + class ItemEffect; + class ItemType; + class Map; + class MapEffect; + class MapTrainer; + class MapTrainerPokemon; + class MapWarp; + class MapWildList; + class MapWildListPokemon; + class Move; + class MoveEffect; + class Nature; + class Pokemod; + class Rules; + class Species; + class SpeciesAbility; + class SpeciesEvolution; + class SpeciesItem; + class SpeciesMove; + class Status; + class StatusEffect; + class Store; + class Tile; + class Time; + class Type; } #include "Object.h" diff --git a/pokemodr/pokemodr.pro b/pokemodr/pokemodr.pro index 60e9aec6..e8fbd2fd 100644 --- a/pokemodr/pokemodr.pro +++ b/pokemodr/pokemodr.pro @@ -1,6 +1,5 @@ OBJECTS_DIR = ../../obj/pokemodr DESTDIR = ../../bin -VERSION = 0.1.0 TEMPLATE = app LIBS += -L../../lib -lgeneral -lpokemod -laudio |