diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2008-05-27 00:47:02 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2008-05-27 00:47:02 +0000 |
| commit | 00fecef0aebaa379dfc176ddc5d6488fae0e8272 (patch) | |
| tree | 2b77cc9c4a31f012bcddbf1fe8efa3f3ca1f6139 /pokemod | |
| parent | c4a3724a2b981e8dbc20f5d319a80bf364f2c7b7 (diff) | |
[FIX] Status and Weather classes in pokemod instead of hardcoded
[FIX] Added a Sprite class to allow for animations and whatnot
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@178 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod')
| -rw-r--r-- | pokemod/Ability.cpp | 1 | ||||
| -rw-r--r-- | pokemod/CoinList.cpp | 1 | ||||
| -rw-r--r-- | pokemod/GlobalScript.cpp | 1 | ||||
| -rw-r--r-- | pokemod/Pokemod.cpp | 293 | ||||
| -rw-r--r-- | pokemod/Pokemod.h | 109 | ||||
| -rw-r--r-- | pokemod/Sprite.cpp | 105 | ||||
| -rw-r--r-- | pokemod/Sprite.h | 58 | ||||
| -rw-r--r-- | pokemod/Status.cpp | 102 | ||||
| -rw-r--r-- | pokemod/Status.h | 56 | ||||
| -rw-r--r-- | pokemod/Tile.cpp | 53 | ||||
| -rw-r--r-- | pokemod/Tile.h | 6 | ||||
| -rw-r--r-- | pokemod/Type.cpp | 50 | ||||
| -rw-r--r-- | pokemod/Type.h | 7 | ||||
| -rw-r--r-- | pokemod/Weather.cpp | 102 | ||||
| -rw-r--r-- | pokemod/Weather.h | 56 | ||||
| -rw-r--r-- | pokemod/pokemod.pro | 10 |
16 files changed, 829 insertions, 181 deletions
diff --git a/pokemod/Ability.cpp b/pokemod/Ability.cpp index dc07ce48..1afbf2f7 100644 --- a/pokemod/Ability.cpp +++ b/pokemod/Ability.cpp @@ -20,7 +20,6 @@ // Pokemod includes #include "Pokemod.h" -#include "Script.h" Ability::Ability(const Ability& ability) : Object("Ability", ability.parent(), ability.id()) diff --git a/pokemod/CoinList.cpp b/pokemod/CoinList.cpp index 8e76362c..d238807d 100644 --- a/pokemod/CoinList.cpp +++ b/pokemod/CoinList.cpp @@ -21,7 +21,6 @@ // Pokemod includes #include "CoinListObject.h" #include "Pokemod.h" -#include "Script.h" // Qt includes #include <QSet> diff --git a/pokemod/GlobalScript.cpp b/pokemod/GlobalScript.cpp index 770ea269..a49ac4ae 100644 --- a/pokemod/GlobalScript.cpp +++ b/pokemod/GlobalScript.cpp @@ -20,7 +20,6 @@ // Pokemod includes #include "Pokemod.h" -#include "Script.h" GlobalScript::GlobalScript(const GlobalScript& globalScript) : Object("GlobalScript", globalScript.parent(), globalScript.id()) diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp index 895366e1..6a76b081 100644 --- a/pokemod/Pokemod.cpp +++ b/pokemod/Pokemod.cpp @@ -33,11 +33,14 @@ #include "Rules.h" #include "Sound.h" #include "Species.h" +#include "Sprite.h" +#include "Status.h" #include "Store.h" #include "Tile.h" #include "Time.h" #include "Trainer.h" #include "Type.h" +#include "Weather.h" // Qt includes #include <QBuffer> @@ -45,12 +48,8 @@ const QStringList Pokemod::StatRBYStr = QStringList() << "HP" << "Attack" << "Defense" << "Speed" << "Special" << "Special" << "Accuracy" << "Evasion"; const QStringList Pokemod::StatGSCStr = QStringList() << "HP" << "Attack" << "Defense" << "Speed" << "Special Attack" << "Special Defense" << "Accuracy" << "Evasion"; -const QStringList Pokemod::BattleMemberStr = QStringList() << "Player" << "Enemy"; -const QStringList Pokemod::WeatherStr = QStringList() << "Ice" << "Rain" << "Sun" << "Sand" << "All"; const QStringList Pokemod::DirectionStr = QStringList() << "Up" << "Down" << "Left" << "Right" << "None"; const QStringList Pokemod::RelativeStr = QStringList() << "Less" << "Less or Equal" << "Greater or Equal" << "Greater" << "Equal" << "Not Equal"; -const QStringList Pokemod::StatusStr = QStringList() << "Freeze" << "Paralyze" << "Sleep" << "Poison" << "Toxic Poison" << "Burn" << "Any"; -const QStringList Pokemod::HMStr = QStringList() << "Cut" << "Fly" << "Surf" << "Strength" << "Flash" << "Whirlpool" << "Waterfall" << "Dive" << "Headbutt" << "Rock Smash" << "Defog" << "Rock Climb" << "Heal" << "Escape"; Pokemod::Pokemod() : Object("Pokemod", NULL, 0), @@ -302,6 +301,20 @@ void Pokemod::validate() } idChecker.clear(); nameChecker.clear(); + if (!statusCount()) + emit(error("There are no status effects")); + foreach (Status* status, m_status) + { + status->validate(); + if (idChecker.contains(status->id())) + emit(error(subclass("status effect", status->id()))); + idChecker.insert(status->id()); + if (nameChecker.contains(status->name())) + emit(error(subclass("status effect", status->name()))); + nameChecker.insert(status->name()); + } + idChecker.clear(); + nameChecker.clear(); if (!storeCount()) emit(warning("There are no stores")); foreach (Store* store, m_stores) @@ -373,6 +386,20 @@ void Pokemod::validate() emit(error(subclass("type", type->name()))); nameChecker.insert(type->name()); } + idChecker.clear(); + nameChecker.clear(); + if (!weatherCount()) + emit(error("There are no weathers")); + foreach (Weather* weather, m_weathers) + { + weather->validate(); + if (idChecker.contains(weather->id())) + emit(error(subclass("weather", weather->id()))); + idChecker.insert(weather->id()); + if (nameChecker.contains(weather->name())) + emit(error(subclass("weather", weather->name()))); + nameChecker.insert(weather->name()); + } } void Pokemod::load(const QDomElement& xml, const int) @@ -403,11 +430,14 @@ void Pokemod::load(const QDomElement& xml, const int) LOAD_SUB(newNature, Nature); LOAD_SUB(newSound, Sound); LOAD_SUB(newSpecies, Species); + LOAD_SUB(newSprite, Sprite); + LOAD_SUB(newStatus, Status); LOAD_SUB(newStore, Store); LOAD_SUB(newTile, Tile); LOAD_SUB(newTime, Time); LOAD_SUB(newTrainer, Trainer); LOAD_SUB(newType, Type); + LOAD_SUB(newWeather, Weather); LOAD_MATRIX(setTypeChart, Fraction, typeChart); } @@ -440,11 +470,14 @@ QDomElement Pokemod::save() const SAVE_SUB(Nature, natures); SAVE_SUB(Sound, sounds); SAVE_SUB(Species, species); + SAVE_SUB(Sprite, sprites); + SAVE_SUB(Status, status); SAVE_SUB(Store, stores); SAVE_SUB(Tile, tiles); SAVE_SUB(Time, times); SAVE_SUB(Trainer, trainers); SAVE_SUB(Type, types); + SAVE_SUB(Weather, weathers); return xml; } @@ -1707,6 +1740,168 @@ int Pokemod::newSpeciesId() const return i; } +const Sprite* Pokemod::sprite(const int index) const +{ + if (spriteCount() <= index) + return NULL; + return m_sprites.at(index); +} + +Sprite* Pokemod::sprite(const int index) +{ + if (spriteCount() <= index) + return NULL; + return m_sprites[index]; +} + +const Sprite* Pokemod::spriteById(const int id) const +{ + return sprite(spriteIndex(id)); +} + +Sprite* Pokemod::spriteById(const int id) +{ + return sprite(spriteIndex(id)); +} + +int Pokemod::spriteIndex(const int id) const +{ + for (int i = 0; i < spriteCount(); ++i) + { + if (m_sprites[i]->id() == id) + return i; + } + return INT_MAX; +} + +int Pokemod::spriteCount() const +{ + return m_sprites.size(); +} + +Sprite* Pokemod::newSprite() +{ + return newSprite(new Sprite(this, newSpriteId())); +} + +Sprite* Pokemod::newSprite(const QDomElement& xml) +{ + return newSprite(new Sprite(xml, this, newSpriteId())); +} + +Sprite* Pokemod::newSprite(const Sprite& sprite) +{ + return newSprite(new Sprite(sprite, this, newSpriteId())); +} + +Sprite* Pokemod::newSprite(Sprite* sprite) +{ + m_sprites.append(sprite); + return sprite; +} + +void Pokemod::deleteSprite(const int index) +{ + if (spriteCount() <= index) + return; + delete m_sprites[index]; + m_sprites.removeAt(index); +} + +void Pokemod::deleteSpriteById(const int id) +{ + deleteSprite(spriteIndex(id)); +} + +int Pokemod::newSpriteId() const +{ + int i = 0; + while ((i < spriteCount()) && (spriteIndex(i) != INT_MAX)) + ++i; + return i; +} + +const Status* Pokemod::status(const int index) const +{ + if (statusCount() <= index) + return NULL; + return m_status.at(index); +} + +Status* Pokemod::status(const int index) +{ + if (statusCount() <= index) + return NULL; + return m_status[index]; +} + +const Status* Pokemod::statusById(const int id) const +{ + return status(statusIndex(id)); +} + +Status* Pokemod::statusById(const int id) +{ + return status(statusIndex(id)); +} + +int Pokemod::statusIndex(const int id) const +{ + for (int i = 0; i < statusCount(); ++i) + { + if (m_status[i]->id() == id) + return i; + } + return INT_MAX; +} + +int Pokemod::statusCount() const +{ + return m_status.size(); +} + +Status* Pokemod::newStatus() +{ + return newStatus(new Status(this, newStatusId())); +} + +Status* Pokemod::newStatus(const QDomElement& xml) +{ + return newStatus(new Status(xml, this, newStatusId())); +} + +Status* Pokemod::newStatus(const Status& status) +{ + return newStatus(new Status(status, this, newStatusId())); +} + +Status* Pokemod::newStatus(Status* status) +{ + m_status.append(status); + return status; +} + +void Pokemod::deleteStatus(const int index) +{ + if (statusCount() <= index) + return; + delete m_status[index]; + m_status.removeAt(index); +} + +void Pokemod::deleteStatusById(const int id) +{ + deleteStatus(statusIndex(id)); +} + +int Pokemod::newStatusId() const +{ + int i = 0; + while ((i < statusCount()) && (statusIndex(i) != INT_MAX)) + ++i; + return i; +} + const Store* Pokemod::store(const int index) const { if (storeCount() <= index) @@ -2126,6 +2321,87 @@ int Pokemod::newTypeId() const return i; } +const Weather* Pokemod::weather(const int index) const +{ + if (weatherCount() <= index) + return NULL; + return m_weathers.at(index); +} + +Weather* Pokemod::weather(const int index) +{ + if (weatherCount() <= index) + return NULL; + return m_weathers[index]; +} + +const Weather* Pokemod::weatherById(const int id) const +{ + return weather(weatherIndex(id)); +} + +Weather* Pokemod::weatherById(const int id) +{ + return weather(weatherIndex(id)); +} + +int Pokemod::weatherIndex(const int id) const +{ + for (int i = 0; i < weatherCount(); ++i) + { + if (m_weathers[i]->id() == id) + return i; + } + return INT_MAX; +} + +int Pokemod::weatherCount() const +{ + return m_weathers.size(); +} + +Weather* Pokemod::newWeather() +{ + return newWeather(new Weather(this, newWeatherId())); +} + +Weather* Pokemod::newWeather(const QDomElement& xml) +{ + return newWeather(new Weather(xml, this, newWeatherId())); +} + +Weather* Pokemod::newWeather(const Weather& weather) +{ + return newWeather(new Weather(weather, this, newWeatherId())); +} + +Weather* Pokemod::newWeather(Weather* weather) +{ + m_weathers.append(weather); + return weather; +} + +void Pokemod::deleteWeather(const int index) +{ + if (weatherCount() <= index) + return; + delete m_weathers[index]; + m_weathers.removeAt(index); +} + +void Pokemod::deleteWeatherById(const int id) +{ + deleteWeather(weatherIndex(id)); +} + +int Pokemod::newWeatherId() const +{ + int i = 0; + while ((i < weatherCount()) && (weatherIndex(i) != INT_MAX)) + ++i; + return i; +} + Pokemod& Pokemod::operator=(const Pokemod& rhs) { if (this == &rhs) @@ -2151,11 +2427,14 @@ Pokemod& Pokemod::operator=(const Pokemod& rhs) COPY_SUB(Nature, natures); COPY_SUB(Sound, sounds); COPY_SUB(Species, species); + COPY_SUB(Sprite, sprites); + COPY_SUB(Status, status); COPY_SUB(Store, stores); COPY_SUB(Tile, tiles); COPY_SUB(Time, times); COPY_SUB(Trainer, trainers); COPY_SUB(Type, types); + COPY_SUB(Weather, weathers); return *this; } @@ -2188,6 +2467,10 @@ void Pokemod::clear() deleteSound(0); while (speciesCount()) deleteSpecies(0); + while (spriteCount()) + deleteSprite(0); + while (statusCount()) + deleteStatus(0); while (storeCount()) deleteStore(0); while (tileCount()) @@ -2198,4 +2481,6 @@ void Pokemod::clear() deleteTrainer(0); while (typeCount()) deleteType(0); + while (weatherCount()) + deleteWeather(0); } diff --git a/pokemod/Pokemod.h b/pokemod/Pokemod.h index 9f4c1d08..e2e2b11b 100644 --- a/pokemod/Pokemod.h +++ b/pokemod/Pokemod.h @@ -45,11 +45,14 @@ class Nature; class Rules; class Sound; class Species; +class Sprite; +class Status; class Store; class Tile; class Time; class Trainer; class Type; +class Weather; class Pokemod : public Object { @@ -74,27 +77,7 @@ class Pokemod : public Object }; static const QStringList StatRBYStr; static const QStringList StatGSCStr; - - enum BattleMember - { - BM_Player = 0, - BM_Enemy = 1, - BM_End = 2 - }; - static const QStringList BattleMemberStr; - - enum Weather - { - W_Ice = 0, - W_Rain = 1, - W_Sun = 2, - W_Sand = 3, - W_End_Real = 4, - W_All = 4, - W_End_All = 5 - }; - static const QStringList WeatherStr; - + enum Direction { D_Up = 0, @@ -106,7 +89,7 @@ class Pokemod : public Object D_End_None = 5 }; static const QStringList DirectionStr; - + enum Relative { REL_Less = 0, @@ -118,40 +101,6 @@ class Pokemod : public Object REL_End = 6 }; static const QStringList RelativeStr; - - enum Status - { - STS_Freeze = 0, - STS_Paralyze = 1, - STS_Sleep = 2, - STS_Poison = 3, - STS_ToxicPoison = 4, - STS_Burn = 5, - STS_Any = 6, - STS_End = 7 - }; - static const QStringList StatusStr; - - enum HMMove - { - HM_Cut = 0, - HM_Fly = 1, - HM_Surf = 2, - HM_Strength = 3, - HM_Whirlpool = 4, - HM_Waterfall = 5, - HM_Dive = 6, - HM_Headbutt = 7, - HM_RockSmash = 8, - HM_RockClimb = 9, - HM_End = 10, - HM_Defog = 10, - HM_Flash = 11, - HM_Heal = 12, - HM_Escape = 13, - HM_End_All = 14 - }; - static const QStringList HMStr; Pokemod(); Pokemod(const Pokemod& pokemod); @@ -351,6 +300,30 @@ class Pokemod : public Object void deleteSpecies(const int index); void deleteSpeciesById(const int id); + const Sprite* sprite(const int index) const; + Sprite* sprite(const int index); + const Sprite* spriteById(const int id) const; + Sprite* spriteById(const int id); + int spriteIndex(const int id) const; + int spriteCount() const; + Sprite* newSprite(); + Sprite* newSprite(const QDomElement& xml); + Sprite* newSprite(const Sprite& sprite); + void deleteSprite(const int index); + void deleteSpriteById(const int id); + + const Status* status(const int index) const; + Status* status(const int index); + const Status* statusById(const int id) const; + Status* statusById(const int id); + int statusIndex(const int id) const; + int statusCount() const; + Status* newStatus(); + Status* newStatus(const QDomElement& xml); + Status* newStatus(const Status& status); + void deleteStatus(const int index); + void deleteStatusById(const int id); + const Store* store(const int index) const; Store* store(const int index); const Store* storeById(const int id) const; @@ -411,6 +384,18 @@ class Pokemod : public Object void deleteType(const int index); void deleteTypeById(const int id); + const Weather* weather(const int index) const; + Weather* weather(const int index); + const Weather* weatherById(const int id) const; + Weather* weatherById(const int id); + int weatherIndex(const int id) const; + int weatherCount() const; + Weather* newWeather(); + Weather* newWeather(const QDomElement& xml); + Weather* newWeather(const Weather& weather); + void deleteWeather(const int index); + void deleteWeatherById(const int id); + Pokemod& operator=(const Pokemod& rhs); private: void validate(); @@ -454,6 +439,12 @@ class Pokemod : public Object int newSpeciesId() const; Species* newSpecies(Species* species); + int newSpriteId() const; + Sprite* newSprite(Sprite* sprite); + + int newStatusId() const; + Status* newStatus(Status* status); + int newStoreId() const; Store* newStore(Store* store); @@ -469,6 +460,9 @@ class Pokemod : public Object int newTypeId() const; Type* newType(Type* type); + int newWeatherId() const; + Weather* newWeather(Weather* weather); + void clear(); QString m_title; @@ -497,11 +491,14 @@ class Pokemod : public Object QList<Nature*> m_natures; QList<Sound*> m_sounds; QList<Species*> m_species; + QList<Sprite*> m_sprites; + QList<Status*> m_status; QList<Store*> m_stores; QList<Tile*> m_tiles; QList<Time*> m_times; QList<Trainer*> m_trainers; QList<Type*> m_types; + QList<Weather*> m_weathers; }; #endif diff --git a/pokemod/Sprite.cpp b/pokemod/Sprite.cpp new file mode 100644 index 00000000..df3c5bd5 --- /dev/null +++ b/pokemod/Sprite.cpp @@ -0,0 +1,105 @@ +/* + * Copyright 2007-2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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/>. + */ + +// Header include +#include "Sprite.h" + +// Pokemod includes +#include "Pokemod.h" + +// Qt includes +#include <QBuffer> + +Sprite::Sprite(const Sprite& sprite) : + Object("Sprite", sprite.parent(), sprite.id()) +{ + *this = sprite; +} + +Sprite::Sprite(const Pokemod* parent, const int id) : + Object("Sprite", parent, id), + m_name(""), + m_sprite() +{ +} + +Sprite::Sprite(const Sprite& sprite, const Pokemod* parent, const int id) : + Object("Sprite", parent, id) +{ + *this = sprite; +} + +Sprite::Sprite(const QDomElement& xml, const Pokemod* parent, const int id) : + Object("Sprite", parent, id) +{ + load(xml, id); +} + +Sprite::~Sprite() +{ +} + +void Sprite::validate() +{ + if (m_name.isEmpty()) + emit(error("Name is empty")); +} + +void Sprite::load(const QDomElement& xml, int id) +{ + LOAD_ID(); + LOAD(QString, name); + LOAD(QPixmap, sprite); +} + +QDomElement Sprite::save() const +{ + SAVE_CREATE(); + SAVE(QString, name); + SAVE(QPixmap, sprite); + return xml; +} + +void Sprite::setName(const QString& name) +{ + CHECK(name); +} + +void Sprite::setSprite(const QPixmap& sprite) +{ + m_sprite = sprite; + emit(changed()); +} + +QString Sprite::name() const +{ + return m_name; +} + +QPixmap Sprite::sprite() const +{ + return m_sprite; +} + +Sprite& Sprite::operator=(const Sprite& rhs) +{ + if (this == &rhs) + return *this; + COPY(name); + COPY(sprite); + return *this; +} diff --git a/pokemod/Sprite.h b/pokemod/Sprite.h new file mode 100644 index 00000000..b5d58100 --- /dev/null +++ b/pokemod/Sprite.h @@ -0,0 +1,58 @@ +/* + * Copyright 2007-2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 __POKEMOD_SPRITE__ +#define __POKEMOD_SPRITE__ + +// Pokemod includes +#include "Object.h" + +// Qt includes +#include <QPixmap> + +// Forward declarations +class Pokemod; + +class Sprite : public Object +{ + Q_OBJECT + + public: + Sprite(const Sprite& sprite); + Sprite(const Pokemod* parent, const int id); + Sprite(const Sprite& sprite, const Pokemod* parent, const int id); + Sprite(const QDomElement& xml, const Pokemod* parent, const int id = INT_MAX); + ~Sprite(); + + void validate(); + + void load(const QDomElement& xml, int id = INT_MAX); + QDomElement save() const; + + void setName(const QString& name); + void setSprite(const QPixmap& sprite); + + QString name() const; + QPixmap sprite() const; + + Sprite& operator=(const Sprite& rhs); + private: + QString m_name; + QPixmap m_sprite; +}; + +#endif diff --git a/pokemod/Status.cpp b/pokemod/Status.cpp new file mode 100644 index 00000000..8c9922d2 --- /dev/null +++ b/pokemod/Status.cpp @@ -0,0 +1,102 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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/>. + */ + +// Header include +#include "Status.h" + +// Pokemod includes +#include "Pokemod.h" +#include "Script.h" + +Status::Status(const Status& status) : + Object("Status", status.parent(), status.id()) +{ + *this = status; +} + +Status::Status(const Pokemod* parent, const int id) : + Object("Status", parent, id), + m_name(""), + m_script("", "") +{ +} + +Status::Status(const Status& status, const Pokemod* parent, const int id) : + Object("Status", parent, id) +{ + *this = status; +} + +Status::Status(const QDomElement& xml, const Pokemod* parent, const int id) : + Object("Status", parent, id) +{ + load(xml, id); +} + +Status::~Status() +{ +} + +void Status::validate() +{ + if (m_name.isEmpty()) + emit(error("Name is empty")); +} + +void Status::load(const QDomElement& xml, int id) +{ + LOAD_ID(); + LOAD(QString, name); + LOAD(Script, script); +} + +QDomElement Status::save() const +{ + SAVE_CREATE(); + SAVE(QString, name); + SAVE(Script, script); + return xml; +} + +void Status::setName(const QString& name) +{ + CHECK(name); +} + +void Status::setScript(const Script& script) +{ + CHECK(script); +} + +QString Status::name() const +{ + return m_name; +} + +Script Status::script() const +{ + return m_script; +} + +Status& Status::operator=(const Status& rhs) +{ + if (this == &rhs) + return *this; + COPY(name); + COPY(script); + return *this; +} diff --git a/pokemod/Status.h b/pokemod/Status.h new file mode 100644 index 00000000..3b8ab7f4 --- /dev/null +++ b/pokemod/Status.h @@ -0,0 +1,56 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 __POKEMOD_STATUS__ +#define __POKEMOD_STATUS__ + +// Pokemod includes +#include "Object.h" +#include "Script.h" + +// Forward declarations +class Pokemod; + +class Status : public Object +{ + Q_OBJECT + + public: + Status(const Status& status); + Status(const Pokemod* parent, const int id); + Status(const Status& status, const Pokemod* parent, const int id); + Status(const QDomElement& xml, const Pokemod* parent, const int id = INT_MAX); + ~Status(); + + void validate(); + + void load(const QDomElement& xml, int id = INT_MAX); + QDomElement save() const; + + void setName(const QString& name); + void setScript(const Script& script); + + QString name() const; + Script script() const; + + Status& operator=(const Status& rhs); + private: + QString m_name; + Script m_script; +}; + +#endif diff --git a/pokemod/Tile.cpp b/pokemod/Tile.cpp index 46363a27..91dd59d6 100644 --- a/pokemod/Tile.cpp +++ b/pokemod/Tile.cpp @@ -37,8 +37,6 @@ Tile::Tile(const Pokemod* parent, const int id) : m_name(""), m_sprite(64, 64), m_wildChance(1, 1), - m_hmType(INT_MAX), - m_under(INT_MAX), m_forceType(INT_MAX), m_forceDirection(INT_MAX) { @@ -64,8 +62,6 @@ void Tile::validate() emit(error("Name is empty")); TEST(setSprite, sprite); TEST(setWildChance, wildChance); - TEST(setHmType, hmType); - TEST(setUnder, under); TEST(setForceType, forceType); TEST(setForceDirection, forceDirection); } @@ -77,8 +73,6 @@ void Tile::load(const QDomElement& xml, int id) LOAD(QPixmap, sprite); LOAD_ARRAY(bool, from, Pokemod::D_End); LOAD(Fraction, wildChance); - LOAD(int, hmType); - LOAD(int, under); LOAD(int, forceType); LOAD(int, forceDirection); } @@ -90,8 +84,6 @@ QDomElement Tile::save() const SAVE(QPixmap, sprite); SAVE_ARRAY(bool, from, Pokemod::D_End); SAVE(Fraction, wildChance); - SAVE(int, hmType); - SAVE(int, under); SAVE(int, forceType); SAVE(int, forceDirection); return xml; @@ -133,39 +125,6 @@ void Tile::setWildChance(const Fraction& wildChance) CHECK(wildChance); } -void Tile::setHmType(const int hmType) -{ - if (Pokemod::HM_End <= hmType) - { - emit(error(bounds("hmType"))); - return; - } - if (((hmType == Pokemod::HM_Waterfall) || (hmType == Pokemod::HM_RockClimb)) && (!m_from[Pokemod::D_Up] || !m_from[Pokemod::D_Down])) - { - emit(error("Accessibility for HM type")); - return; - } - CHECK(hmType); -} - -void Tile::setUnder(const int under) -{ - if (m_hmType != INT_MAX) - { - if ((m_hmType != Pokemod::HM_Whirlpool) || (m_hmType != Pokemod::HM_Cut) || (m_hmType != Pokemod::HM_RockSmash)) - { - emit(warning(unused("under"))); - return; - } - if ((under == id()) || (static_cast<const Pokemod*>(pokemod())->tileIndex(under) == INT_MAX)) - { - emit(error(bounds("under"))); - return; - } - } - CHECK(under); -} - void Tile::setForceType(const int forceType) { if (End <= forceType) @@ -219,16 +178,6 @@ Fraction Tile::wildChance() const return m_wildChance; } -int Tile::hmType() const -{ - return m_hmType; -} - -int Tile::under() const -{ - return m_under; -} - int Tile::forceType() const { return m_forceType; @@ -246,8 +195,6 @@ Tile& Tile::operator=(const Tile& rhs) COPY(name); COPY_ARRAY(from, Pokemod::D_End); COPY(wildChance); - COPY(hmType); - COPY(under); COPY(forceType); COPY(forceDirection); return *this; diff --git a/pokemod/Tile.h b/pokemod/Tile.h index 12efe6f5..120e0fd3 100644 --- a/pokemod/Tile.h +++ b/pokemod/Tile.h @@ -55,8 +55,6 @@ class Tile : public Object void setSprite(const QPixmap& sprite); void setFrom(const int direction, const bool state); void setWildChance(const Fraction& wildChance); - void setHmType(const int hmType); - void setUnder(const int under); void setForceType(const int forceType); void setForceDirection(const int forceDirection); @@ -64,8 +62,6 @@ class Tile : public Object QPixmap sprite() const; bool from(const int direction) const; Fraction wildChance() const; - int hmType() const; - int under() const; int forceType() const; int forceDirection() const; @@ -75,8 +71,6 @@ class Tile : public Object QPixmap m_sprite; bool m_from[Pokemod::D_End]; Fraction m_wildChance; - int m_hmType; - int m_under; int m_forceType; int m_forceDirection; }; diff --git a/pokemod/Type.cpp b/pokemod/Type.cpp index 54c7350c..24ff76e8 100644 --- a/pokemod/Type.cpp +++ b/pokemod/Type.cpp @@ -32,10 +32,6 @@ Type::Type(const Pokemod* parent, const int id) : m_name(""), m_stab(1, 1) { - for (int i = 0; i < Pokemod::STS_End; ++i) - m_statusImmunity[i] = false; - for (int i = 0; i < Pokemod::W_End_All; ++i) - m_weatherImmunity[i] = false; } Type::Type(const Type& type, const Pokemod* parent, const int id) : @@ -61,8 +57,6 @@ void Type::load(const QDomElement& xml, int id) LOAD_ID(); LOAD(QString, name); LOAD(Fraction, stab); - LOAD_ARRAY(bool, statusImmunity, Pokemod::STS_End); - LOAD_ARRAY(bool, weatherImmunity, Pokemod::W_End_Real); } QDomElement Type::save() const @@ -70,8 +64,6 @@ QDomElement Type::save() const SAVE_CREATE(); SAVE(QString, name); SAVE(Fraction, stab); - SAVE_ARRAY(bool, statusImmunity, Pokemod::STS_End); - SAVE_ARRAY(bool, weatherImmunity, Pokemod::W_End_Real); return xml; } @@ -90,26 +82,6 @@ void Type::setStab(const Fraction& stab) CHECK(stab); } -void Type::setStatusImmunity(const int status, const bool immune) -{ - if (Pokemod::STS_End <= status) - { - emit(error(bounds("statusImmunity"))); - return; - } - CHECK_ARRAY(statusImmunity[status], immune); -} - -void Type::setWeatherImmunity(const int weather, const bool immune) -{ - if (Pokemod::W_End_Real <= weather) - { - emit(error(bounds("weatherImmunity"))); - return; - } - CHECK_ARRAY(weatherImmunity[weather], immune); -} - QString Type::name() const { return m_name; @@ -120,33 +92,11 @@ Fraction Type::stab() const return m_stab; } -bool Type::statusImmunity(const int status) const -{ - if (Pokemod::STS_End <= status) - { - emit(warning(bounds("statusImmunity"))); - return false; - } - return m_statusImmunity[status]; -} - -bool Type::weatherImmunity(const int weather) const -{ - if (Pokemod::W_End_Real <= weather) - { - emit(warning(bounds("weatherImmunity"))); - return false; - } - return m_weatherImmunity[weather]; -} - Type& Type::operator=(const Type& rhs) { if (this == &rhs) return *this; COPY(name); COPY(stab); - COPY_ARRAY(statusImmunity, Pokemod::STS_End); - COPY_ARRAY(weatherImmunity, Pokemod::W_End_Real); return *this; } diff --git a/pokemod/Type.h b/pokemod/Type.h index 06a7cdaf..6c9a0cdf 100644 --- a/pokemod/Type.h +++ b/pokemod/Type.h @@ -21,7 +21,6 @@ // Pokemod includes #include "Fraction.h" #include "Object.h" -#include "Pokemod.h" // Forward declarations class Pokemod; @@ -43,20 +42,14 @@ class Type : public Object void setName(const QString& name); void setStab(const Fraction& stab); - void setStatusImmunity(const int status, const bool immune); - void setWeatherImmunity(const int weather, const bool immune); QString name() const; Fraction stab() const; - bool statusImmunity(const int status) const; - bool weatherImmunity(const int weather) const; Type& operator=(const Type& rhs); private: QString m_name; Fraction m_stab; - bool m_statusImmunity[Pokemod::STS_End]; - bool m_weatherImmunity[Pokemod::W_End_All]; }; #endif diff --git a/pokemod/Weather.cpp b/pokemod/Weather.cpp new file mode 100644 index 00000000..59ff9135 --- /dev/null +++ b/pokemod/Weather.cpp @@ -0,0 +1,102 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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/>. + */ + +// Header include +#include "Weather.h" + +// Pokemod includes +#include "Pokemod.h" +#include "Script.h" + +Weather::Weather(const Weather& weather) : + Object("Weather", weather.parent(), weather.id()) +{ + *this = weather; +} + +Weather::Weather(const Pokemod* parent, const int id) : + Object("Weather", parent, id), + m_name(""), + m_script("", "") +{ +} + +Weather::Weather(const Weather& weather, const Pokemod* parent, const int id) : + Object("Weather", parent, id) +{ + *this = weather; +} + +Weather::Weather(const QDomElement& xml, const Pokemod* parent, const int id) : + Object("Weather", parent, id) +{ + load(xml, id); +} + +Weather::~Weather() +{ +} + +void Weather::validate() +{ + if (m_name.isEmpty()) + emit(error("Name is empty")); +} + +void Weather::load(const QDomElement& xml, int id) +{ + LOAD_ID(); + LOAD(QString, name); + LOAD(Script, script); +} + +QDomElement Weather::save() const +{ + SAVE_CREATE(); + SAVE(QString, name); + SAVE(Script, script); + return xml; +} + +void Weather::setName(const QString& name) +{ + CHECK(name); +} + +void Weather::setScript(const Script& script) +{ + CHECK(script); +} + +QString Weather::name() const +{ + return m_name; +} + +Script Weather::script() const +{ + return m_script; +} + +Weather& Weather::operator=(const Weather& rhs) +{ + if (this == &rhs) + return *this; + COPY(name); + COPY(script); + return *this; +} diff --git a/pokemod/Weather.h b/pokemod/Weather.h new file mode 100644 index 00000000..da727344 --- /dev/null +++ b/pokemod/Weather.h @@ -0,0 +1,56 @@ +/* + * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * + * 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 __POKEMOD_WEATHER__ +#define __POKEMOD_WEATHER__ + +// Pokemod includes +#include "Object.h" +#include "Script.h" + +// Forward declarations +class Pokemod; + +class Weather : public Object +{ + Q_OBJECT + + public: + Weather(const Weather& weather); + Weather(const Pokemod* parent, const int id); + Weather(const Weather& weather, const Pokemod* parent, const int id); + Weather(const QDomElement& xml, const Pokemod* parent, const int id = INT_MAX); + ~Weather(); + + void validate(); + + void load(const QDomElement& xml, int id = INT_MAX); + QDomElement save() const; + + void setName(const QString& name); + void setScript(const Script& script); + + QString name() const; + Script script() const; + + Weather& operator=(const Weather& rhs); + private: + QString m_name; + Script m_script; +}; + +#endif diff --git a/pokemod/pokemod.pro b/pokemod/pokemod.pro index 56e54ce7..cd95027f 100644 --- a/pokemod/pokemod.pro +++ b/pokemod/pokemod.pro @@ -40,11 +40,14 @@ SOURCES += Ability.cpp \ SpeciesAbility.cpp \ SpeciesItem.cpp \ SpeciesMove.cpp \ + Sprite.cpp \ + Status.cpp \ Store.cpp \ Tile.cpp \ Time.cpp \ Trainer.cpp \ - Type.cpp + Type.cpp \ + Weather.cpp HEADERS += Ability.h \ Author.h \ @@ -77,11 +80,14 @@ HEADERS += Ability.h \ SpeciesAbility.h \ SpeciesItem.h \ SpeciesMove.h \ + Sprite.h \ + Status.h \ Store.h \ Tile.h \ Time.h \ Trainer.h \ - Type.h + Type.h \ + Weather.h isEmpty(PREFIX) { PREFIX = $$(PREFIX) |
