summaryrefslogtreecommitdiffstats
path: root/pokemod/MapTrainerTeamMember.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-04-27 15:15:17 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-04-27 15:15:17 +0000
commit807071d35159de0660f9df31c48d5bf895ca3622 (patch)
treea1e9dbdc1e58b91cd2e4a5e472597b0204ccb41d /pokemod/MapTrainerTeamMember.cpp
parentf444f5a45e9325644a360f656176d47d7f540f52 (diff)
downloadsigen-807071d35159de0660f9df31c48d5bf895ca3622.tar.gz
sigen-807071d35159de0660f9df31c48d5bf895ca3622.tar.xz
sigen-807071d35159de0660f9df31c48d5bf895ca3622.zip
[FIX] Pokemod objects now know about parents
[FIX] Project includes are now relative [FIX] Headers included for better detection of invalid headers [FIX] Validation code commented out so it can be done better git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@111 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/MapTrainerTeamMember.cpp')
-rw-r--r--pokemod/MapTrainerTeamMember.cpp119
1 files changed, 60 insertions, 59 deletions
diff --git a/pokemod/MapTrainerTeamMember.cpp b/pokemod/MapTrainerTeamMember.cpp
index 1338f7b8..34971486 100644
--- a/pokemod/MapTrainerTeamMember.cpp
+++ b/pokemod/MapTrainerTeamMember.cpp
@@ -15,88 +15,89 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QMap>
-#include <QMutableListIterator>
-#include <QString>
+// Header include
+#include "MapTrainerTeamMember.h"
// Pokemod includes
-#include "Pokemod.h"
#include "Item.h"
#include "Species.h"
+#include "Pokemod.h"
-// Header include
-#include "MapTrainerTeamMember.h"
+// Qt includes
+#include <QMap>
+#include <QMutableListIterator>
+#include <QString>
MapTrainerTeamMember::MapTrainerTeamMember(const MapTrainerTeamMember& teamMember) :
- Object("MapTrainerTeamMember", teamMember.pokemod(), teamMember.id())
+ Object("MapTrainerTeamMember", teamMember.parent(), teamMember.id())
{
*this = teamMember;
}
-MapTrainerTeamMember::MapTrainerTeamMember(const Pokemod* pokemod, const int id) :
- Object("MapTrainerTeamMember", pokemod, id),
+MapTrainerTeamMember::MapTrainerTeamMember(const Object* parent, const int id) :
+ Object("MapTrainerTeamMember", parent, id),
m_species(INT_MAX),
m_level(INT_MAX),
m_nature(INT_MAX)
{
}
-MapTrainerTeamMember::MapTrainerTeamMember(const MapTrainerTeamMember& teamMember, const Pokemod* pokemod, const int id) :
- Object("MapTrainerTeamMember", pokemod, id)
+MapTrainerTeamMember::MapTrainerTeamMember(const MapTrainerTeamMember& teamMember, const Object* parent, const int id) :
+ Object("MapTrainerTeamMember", parent, id)
{
*this = teamMember;
}
-MapTrainerTeamMember::MapTrainerTeamMember(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("MapTrainerTeamMember", pokemod, id)
+MapTrainerTeamMember::MapTrainerTeamMember(const QDomElement& xml, const Object* parent, const int id) :
+ Object("MapTrainerTeamMember", parent, id)
{
load(xml, id);
}
bool MapTrainerTeamMember::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("---------Team Member with id %1---").arg(id()), Pokemod::V_Msg);
- if (pokemod()->speciesIndex(m_species) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid species");
- valid = false;
- }
- if (pokemod()->rules()->maxLevel() <= m_level)
- {
- pokemod()->validationMsg("Invalid level");
- valid = false;
- }
- if (m_items.size() <= pokemod()->rules()->holdItems())
- {
- QMap<int, bool> itemChecker;
- foreach (int item, m_items)
- {
- if (pokemod()->itemIndex(item) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid item");
- valid = false;
- }
- if (itemChecker[item])
- pokemod()->validationMsg(QString("Duplicate of item %1").arg(item));
- itemChecker[item] = true;
- }
- }
- else
- {
- pokemod()->validationMsg("Too many held items");
- valid = false;
- }
- if (pokemod()->rules()->natureAllowed())
- {
- if (pokemod()->natureIndex(m_nature) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid nature");
- valid = false;
- }
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---------Team Member with id %1---").arg(id()), Pokemod::V_Msg);
+// if (static_cast<const Pokemod*>(pokemod())->speciesIndex(m_species) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid species");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() <= m_level)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid level");
+// valid = false;
+// }
+// if (m_items.size() <= static_cast<const Pokemod*>(pokemod())->rules()->holdItems())
+// {
+// QMap<int, bool> itemChecker;
+// foreach (int item, m_items)
+// {
+// if (static_cast<const Pokemod*>(pokemod())->itemIndex(item) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid item");
+// valid = false;
+// }
+// if (itemChecker[item])
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate of item %1").arg(item));
+// itemChecker[item] = true;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Too many held items");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->rules()->natureAllowed())
+// {
+// if (static_cast<const Pokemod*>(pokemod())->natureIndex(m_nature) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid nature");
+// valid = false;
+// }
+// }
+// return valid;
}
void MapTrainerTeamMember::load(const QDomElement& xml, int id)
@@ -120,21 +121,21 @@ QDomElement MapTrainerTeamMember::save() const
void MapTrainerTeamMember::setSpecies(const int species) throw(BoundsException)
{
- if (pokemod()->speciesIndex(species) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->speciesIndex(species) == INT_MAX)
error<BoundsException>("species");
m_species = species;
}
void MapTrainerTeamMember::setLevel(const int level) throw(BoundsException)
{
- if (pokemod()->rules()->maxLevel() < level)
+ if (static_cast<const Pokemod*>(pokemod())->rules()->maxLevel() < level)
error<BoundsException>("level");
m_level = level;
}
void MapTrainerTeamMember::setItem(const int item, const bool state) throw(BoundsException)
{
- if (pokemod()->itemIndex(item) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->itemIndex(item) == INT_MAX)
error<BoundsException>("item");
if (state)
{
@@ -147,7 +148,7 @@ void MapTrainerTeamMember::setItem(const int item, const bool state) throw(Bound
void MapTrainerTeamMember::setNature(const int nature) throw(BoundsException)
{
- if (!pokemod()->rules()->natureAllowed() || (pokemod()->natureIndex(nature) == INT_MAX))
+ if (!static_cast<const Pokemod*>(pokemod())->rules()->natureAllowed() || (static_cast<const Pokemod*>(pokemod())->natureIndex(nature) == INT_MAX))
error<BoundsException>("nature");
m_nature = nature;
}