summaryrefslogtreecommitdiffstats
path: root/pokemod/Ability.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2007-06-04 01:35:20 +0000
committerBen Boeckel <MathStuf@gmail.com>2007-06-04 01:35:20 +0000
commit3595239f08f2bc1df32ef22ed6de9bde10ca3384 (patch)
treed9962c84e3a1f19e2da422f9bb49f65c21ada9f6 /pokemod/Ability.cpp
parentc9afda3ab74614fb36986f96b7972c082f275eca (diff)
downloadsigen-3595239f08f2bc1df32ef22ed6de9bde10ca3384.tar.gz
sigen-3595239f08f2bc1df32ef22ed6de9bde10ca3384.tar.xz
sigen-3595239f08f2bc1df32ef22ed6de9bde10ca3384.zip
Style cleanup, minor Matrix fixes, duplication validations, Pokemod methods
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@19 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Ability.cpp')
-rw-r--r--pokemod/Ability.cpp61
1 files changed, 46 insertions, 15 deletions
diff --git a/pokemod/Ability.cpp b/pokemod/Ability.cpp
index 102348c8..01396882 100644
--- a/pokemod/Ability.cpp
+++ b/pokemod/Ability.cpp
@@ -25,7 +25,7 @@
#include "Ability.h"
PokeGen::PokeMod::Ability::Ability(const unsigned _id) :
- name("")
+ name("")
{
LogCtor("Ability", id);
id = _id;
@@ -47,22 +47,38 @@ PokeGen::PokeMod::Ability::~Ability()
void PokeGen::PokeMod::Ability::Validate()
{
LogValidateStart("Ability", id, name);
- // Make sure the name is set to something
if (name == "")
{
- LogVarNotSet("Ability", id, "Name", name);
+ LogVarNotSet("Ability", id, "name");
isValid = false;
}
- // Check if there are any effects defined
if (GetAbilityEffectCount())
{
- // Validate each effect
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> effectChecker;
for (std::vector<AbilityEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
{
LogSubmoduleIterate("Ability", id, "effect", i->GetId(), name);
- // If an effect isn't valid, neither is the ability
if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
+ ++effectChecker[i->GetEffectString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Ability", id, "effect", i->first, name);
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Ability", id, "effect", i->first, name);
+ isValid = false;
+ }
}
}
else
@@ -77,23 +93,41 @@ void PokeGen::PokeMod::Ability::Validate()
void PokeGen::PokeMod::Ability::Validate(const wxListBox &output)
{
LogValidateStart("Ability", id, name);
- // Make sure the name is set to something
if (name == "")
{
- LogVarNotSet("Ability", id, "Name", name);
- output.Append(ConsoleLogVarNotSet("Ability", id, "Name", name));
+ LogVarNotSet("Ability", id, "name");
+ output.Append(ConsoleLogVarNotSet("Ability", id, "name"));
isValid = false;
}
- // Check if there are any effects defined
if (GetAbilityEffectCount())
{
- // Validate each effect
+ std::map<unsigned, unsigned> idChecker;
+ std::map<String, unsigned> effectChecker;
for (std::vector<AbilityEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
{
LogSubmoduleIterate("Ability", id, "effect", i->GetId(), name);
- // If an effect isn't valid, neither is the ability
if (!i->IsValid())
isValid = false;
+ ++idChecker[i->GetId()];
+ ++effectChecker[i->GetEffectString()];
+ }
+ for (std::map<unsigned, unsigned>::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateId("Ability", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateId("Ability", id, "effect", i->first, name));
+ isValid = false;
+ }
+ }
+ for (std::map<String, unsigned>::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i)
+ {
+ if (1 < i->second)
+ {
+ LogDuplicateSubmodule("Ability", id, "effect", i->first, name);
+ output.Append(ConsoleLogDuplicateSubmodule("Ability", id, "effect", i->first, name));
+ isValid = false;
+ }
}
}
else
@@ -112,7 +146,6 @@ void PokeGen::PokeMod::Ability::ImportIni(Ini &ini, const unsigned _id)
if (_id == UINT_MAX)
{
ini.GetValue("id", id);
- // Was there an id associated with the element?
if (id == UINT_MAX)
LogIdNotFound("Ability");
}
@@ -126,7 +159,6 @@ void PokeGen::PokeMod::Ability::ImportIni(Ini &ini, const unsigned _id)
void PokeGen::PokeMod::Ability::ExportIni(std::ofstream &fout) const
{
LogExportStart("Ability", id, name);
- // Make elements
Ini exAbility("ability");
exAbility.AddField("id", id);
exAbility.AddField("name", name);
@@ -169,7 +201,6 @@ unsigned PokeGen::PokeMod::Ability::GetAbilityEffectCount() const
void PokeGen::PokeMod::Ability::NewAbilityEffect(Ini *const ini)
{
unsigned i = 0;
- // Find the first unused ID in the vector
for (; i < GetAbilityEffectCount(); ++i)
{
if (!GetAbilityEffect(i))