diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2007-06-02 18:12:48 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2007-06-02 18:12:48 +0000 |
| commit | c9afda3ab74614fb36986f96b7972c082f275eca (patch) | |
| tree | 1b7c0b31950597d6ed562d94158dd3f8701496da /pokemod/Pokemon.cpp | |
| parent | f71140fae5218ee9839ffcd4ec83abfded5124f4 (diff) | |
| download | sigen-c9afda3ab74614fb36986f96b7972c082f275eca.tar.gz sigen-c9afda3ab74614fb36986f96b7972c082f275eca.tar.xz sigen-c9afda3ab74614fb36986f96b7972c082f275eca.zip | |
Finished off all PokeMod classes, added move validations, fixed up some GUI, various other fixes
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@18 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Pokemon.cpp')
| -rw-r--r-- | pokemod/Pokemon.cpp | 1414 |
1 files changed, 1414 insertions, 0 deletions
diff --git a/pokemod/Pokemon.cpp b/pokemod/Pokemon.cpp new file mode 100644 index 00000000..cacd72a5 --- /dev/null +++ b/pokemod/Pokemon.cpp @@ -0,0 +1,1414 @@ +/////////////////////////////////////////////////////////////////////////////
+// Name: pokemod/Pokemon.cpp
+// Purpose: Define a Pokemon
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Fri June 1 2007 12:10:40
+// Copyright: ©2007 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 2 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
+// MERCHANTPokemon 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, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+/////////////////////////////////////////////////////////////////////////////
+
+#include "Pokemon.h"
+
+extern PokeGen::PokeMod::Pokemod curPokeMod;
+
+PokeGen::PokeMod::Pokemon::Pokemon(const unsigned _id)
+{
+ LogCtor("Pokemon", id);
+ name = "";
+ for (unsigned i = 0; i < STH_END_GSC; ++i)
+ {
+ baseStats[i] = 0;
+ effortValues[i] = 0;
+ }
+ growth = UINT_MAX;
+ experienceValue = 0;
+ catchValue = 0;
+ runChance.Set(1, 1);
+ itemChance.Set(1, 1);
+ pokedexNumber = UINT_MAX;
+ weight = 0;
+ heightFeet = 0;
+ heightInches = 0;
+ pokedexEntry = "";
+ frontSprite = "";
+ backSprite = "";
+ listSprite = "";
+ genderFactor.Set(1, 1, true);
+ eggSpecies = UINT_MAX;
+ eggSteps = 0;
+ isDitto = false;
+ nidoranGroup = UINT_MAX;
+ id = _id;
+}
+
+PokeGen::PokeMod::Pokemon::Pokemon(Ini &ini, const unsigned _id)
+{
+ LogCtorIni("Pokemon", id);
+ ImportIni(ini, _id);
+ if (id == UINT_MAX)
+ LogIdError("Pokemon");
+}
+
+PokeGen::PokeMod::Pokemon::~Pokemon()
+{
+ LogDtor("Pokemon", id, name);
+}
+
+void PokeGen::PokeMod::Pokemon::Validate()
+{
+ LogValidateStart("Pokemon", id, name);
+ if (name == "")
+ {
+ LogVarNotSet("Pokemon", id, "name", name);
+ isValid = false;
+ }
+ for (unsigned i = 0; i < (curPokeMod.IsSpecialSplit() ? STH_END_GSC : STH_END_RBY); ++i)
+ {
+ if (!baseStats[i])
+ {
+ LogVarNotValid("Pokemon", id, String("baseStats[%u]", i), name);
+ isValid = false;
+ }
+ }
+ if (STY_END <= growth)
+ {
+ LogVarNotValid("Pokemon", id, "growth", name);
+ isValid = false;
+ }
+ if (curPokeMod.GetPokemonCount() <= pokedexNumber)
+ {
+ LogVarNotValid("Pokemon", id, "pokedexNumber", name);
+ isValid = false;
+ }
+ if (!weight)
+ LogVarNotSet("Pokemon", id, "weight", name);
+ if (12 <= heightInches)
+ {
+ LogVarNotValid("Pokemon", id, "heightInches", name);
+ isValid = false;
+ }
+ if (!frontSprite.DoesExist())
+ {
+ if (frontSprite == "")
+ LogVarNotSet("Pokemon", id, "frontSprite", name);
+ else
+ LogVarNotValid("Pokemon", id, "frontSprite", name);
+ isValid = false;
+ }
+ if (!backSprite.DoesExist())
+ {
+ if (backSprite == "")
+ LogVarNotSet("Pokemon", id, "backSprite", name);
+ else
+ LogVarNotValid("Pokemon", id, "backSprite", name);
+ isValid = false;
+ }
+ if (!listSprite.DoesExist())
+ {
+ if (listSprite == "")
+ LogVarNotSet("Pokemon", id, "listSprite", name);
+ else
+ LogVarNotValid("Pokemon", id, "listSprite", name);
+ isValid = false;
+ }
+ if (!curPokeMod.GetPokemon(eggSpecies))
+ LogVarNotValid("Pokemon", id, "eggSpecies", name);
+ else if (!eggSteps)
+ {
+ LogVarNotValid("Pokemon", id, "eggSteps", name);
+ isValid = false;
+ }
+ // Check if there are any abilities defined
+ if (GetPokemonAbilityCount())
+ {
+ // Validate each ability
+ for (std::vector<PokemonAbility>::iterator i = abilities.begin(); i != abilities.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "ability", i->GetId(), name);
+ // If an ability isn't valid, neither is the Pokémon
+ if (!i->IsValid())
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "ability", name);
+ isValid = false;
+ }
+ // Check if there are any evolutions defined
+ if (GetPokemonAbilityCount())
+ {
+ // Validate each evolution
+ for (std::vector<PokemonEvolution>::iterator i = evolutions.begin(); i != evolutions.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "evolution", i->GetId(), name);
+ // If an evolution isn't valid, neither is the Pokémon
+ if (!i->IsValid())
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "evolution", name);
+ isValid = false;
+ }
+ // Check if there are any item defined
+ if (GetPokemonItemCount())
+ {
+ // Validate each item
+ for (std::vector<PokemonItem>::iterator i = items.begin(); i != items.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "item", i->GetId(), name);
+ // If an item isn't valid, neither is the Pokémon
+ if (!i->IsValid())
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "item", name);
+ isValid = false;
+ }
+ // Check if there are any move defined
+ if (GetPokemonMoveCount())
+ {
+ // Validate each move
+ for (std::vector<PokemonMove>::iterator i = moves.begin(); i != moves.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "move", i->GetId(), name);
+ // If an move isn't valid, neither is the Pokémon
+ if (!i->IsValid())
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "move", name);
+ isValid = false;
+ }
+ // Check if there are any natures defined
+ if (GetPokemonAbilityCount())
+ {
+ // Validate each nature
+ for (std::vector<PokemonNature>::iterator i = natures.begin(); i != natures.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "nature", i->GetId(), name);
+ // If an nature isn't valid, neither is the Pokémon
+ if (!i->IsValid())
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "nature", name);
+ isValid = false;
+ }
+ LogValidateOver("Pokemon", id, isValid, name);
+}
+
+#ifdef PG_DEBUG_WINDOW
+void PokeGen::PokeMod::Pokemon::Validate(const wxListBox &output)
+{
+ LogValidateStart("Pokemon", id, name);
+ if (name == "")
+ {
+ LogVarNotSet("Pokemon", id, "Name", name);
+ output.Append(ConsoleLogVarNotSet("Pokemon", id, "Name", name));
+ isValid = false;
+ }
+ if (name == "")
+ {
+ LogVarNotSet("Pokemon", id, "name", name);
+ output.append(ConsoleLogVarNotSet("Pokemon", id, "name", name));
+ isValid = false;
+ }
+ for (unsigned i = 0; i < (curPokeMod.IsSpecialSplit() ? STH_END_GSC : STH_END_RBY); ++i)
+ {
+ if (!baseStats[i])
+ {
+ LogVarNotValid("Pokemon", id, String("baseStats[%u]", i), name);
+ output.append(ConsoleLogVarNotValid("Pokemon", id, String("baseStats[%u]", i), name));
+ isValid = false;
+ }
+ }
+ if (STY_END <= growth)
+ {
+ LogVarNotValid("Pokemon", id, "growth", name);
+ output.append(ConsoleLogVarNotValid("Pokemon", id, "growth", name));
+ isValid = false;
+ }
+ if (curPokeMod.GetPokemonCount() <= pokedexNumber)
+ {
+ LogVarNotValid("Pokemon", id, "pokedexNumber", name);
+ output.append(ConsoleLogVarNotValid("Pokemon", id, "pokedexNumber", name));
+ isValid = false;
+ }
+ if (!weight)
+ {
+ LogVarNotSet("Pokemon", id, "weight", name);
+ output.append(ConsoleLogVarNotSetW("Pokemon", id, "weight", name));
+ }
+ if (12 <= heightInches)
+ {
+ LogVarNotValid("Pokemon", id, "heightInches", name);
+ output.append(ConsoleLogVarNotValid("Pokemon", id, "heightInches", name));
+ isValid = false;
+ }
+ if (!frontSprite.DoesExist())
+ {
+ if (frontSprite == "")
+ {
+ LogVarNotSet("Pokemon", id, "frontSprite", name);
+ output.append(ConsoleLogVarNotSet("Pokemon", id, "frontSprite", name));
+ }
+ else
+ {
+ LogVarNotValid("Pokemon", id, "frontSprite", name);
+ output.append(ConsoleLogVarNotValid("Pokemon", id, "frontSprite", name));
+ }
+ isValid = false;
+ }
+ if (!backSprite.DoesExist())
+ {
+ if (backSprite == "")
+ {
+ LogVarNotSet("Pokemon", id, "backSprite", name);
+ output.append(ConsoleLogVarNotSet("Pokemon", id, "backSprite", name));
+ }
+ else
+ {
+ LogVarNotValid("Pokemon", id, "backSprite", name);
+ output.append(ConsoleLogVarNotValid("Pokemon", id, "backSprite", name));
+ }
+ isValid = false;
+ }
+ if (!listSprite.DoesExist())
+ {
+ if (listSprite == "")
+ {
+ LogVarNotSet("Pokemon", id, "listSprite", name);
+ output.append(ConsoleLogVarNotSet("Pokemon", id, "listSprite", name));
+ }
+ else
+ {
+ LogVarNotValid("Pokemon", id, "listSprite", name);
+ output.append(ConsoleLogVarNotValid("Pokemon", id, "listSprite", name));
+ }
+ isValid = false;
+ }
+ if (!curPokeMod.GetPokemon(eggSpecies))
+ {
+ LogVarNotValid("Pokemon", id, "eggSpecies", name);
+ output.append(ConsoleLogVarNotValidW("Pokemon", id, "eggSpecies", name));
+ }
+ else if (!eggSteps)
+ {
+ LogVarNotValid("Pokemon", id, "eggSteps", name);
+ output.append(ConsoleLogVarNotValid("Pokemon", id, "eggSteps", name));
+ isValid = false;
+ }
+ // Check if there are any abilities defined
+ if (GetPokemonAbilityCount())
+ {
+ // Validate each ability
+ for (std::vector<PokemonAbility>::iterator i = abilities.begin(); i != abilities.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "ability", i->GetId(), name);
+ // If an ability isn't valid, neither is the Pokémon
+ if (!i->IsValid())
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "ability", name);
+ output.append(ConsoleLogSubmoduleEmpty("Pokemon", id, "ability", name));
+ isValid = false;
+ }
+ // Check if there are any evolutions defined
+ if (GetPokemonAbilityCount())
+ {
+ // Validate each evolution
+ for (std::vector<PokemonEvolution>::iterator i = evolutions.begin(); i != evolutions.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "evolution", i->GetId(), name);
+ // If an evolution isn't valid, neither is the Pokémon
+ if (!i->IsValid())
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "evolution", name);
+ output.append(ConsoleLogSubmoduleEmpty("Pokemon", id, "evolution", name));
+ isValid = false;
+ }
+ // Check if there are any item defined
+ if (GetPokemonItemCount())
+ {
+ // Validate each item
+ for (std::vector<PokemonItem>::iterator i = items.begin(); i != items.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "item", i->GetId(), name);
+ // If an item isn't valid, neither is the Pokémon
+ if (!i->IsValid())
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "item", name);
+ output.append(ConsoleLogSubmoduleEmpty("Pokemon", id, "item", name));
+ isValid = false;
+ }
+ // Check if there are any move defined
+ if (GetPokemonMoveCount())
+ {
+ // Validate each move
+ for (std::vector<PokemonMove>::iterator i = moves.begin(); i != moves.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "move", i->GetId(), name);
+ // If an move isn't valid, neither is the Pokémon
+ if (!i->IsValid())
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "move", name);
+ output.append(ConsoleLogSubmoduleEmpty("Pokemon", id, "move", name));
+ isValid = false;
+ }
+ // Check if there are any natures defined
+ if (GetPokemonAbilityCount())
+ {
+ // Validate each nature
+ for (std::vector<PokemonNature>::iterator i = natures.begin(); i != natures.end(); ++i)
+ {
+ LogSubmoduleIterate("Pokemon", id, "nature", i->GetId(), name);
+ // If an nature isn't valid, neither is the Pokémon
+ if (!i->IsValid())
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogSubmoduleEmpty("Pokemon", id, "nature", name);
+ output.append(ConsoleLogSubmoduleEmpty("Pokemon", id, "nature", name));
+ isValid = false;
+ }
+ LogValidateOver("Pokemon", id, isValid, name);
+}
+#endif
+
+void PokeGen::PokeMod::Pokemon::ImportIni(Ini &ini, const unsigned _id)
+{
+ LogImportStart("Pokemon");
+ if (_id == UINT_MAX)
+ {
+ ini.GetValue("id", id);
+ // Was there an id associated with the element?
+ if (id == UINT_MAX)
+ LogIdNotFound("Pokemon");
+ }
+ else
+ id = _id;
+ unsigned i;
+ unsigned j;
+ ini.GetValue("name", name);
+ ini.GetValue("numTypes", i);
+ for (unsigned k = 0; k < i; ++k)
+ {
+ ini.GetValue(String("types-%d", i), j);
+ if (j != UINT_MAX)
+ types.push_back(j);
+ }
+ for (unsigned i = 0; i < STH_END_GSC; ++i)
+ ini.GetValue(String("baseStats-%d", i), baseStats[i], 0);
+ for (unsigned i = 0; i < STH_END_GSC; ++i)
+ ini.GetValue(String("effortValues-%d", i), effortValues[i], 0);
+ ini.GetValue("growth", growth);
+ ini.GetValue("experienceValue", experienceValue, 0);
+ ini.GetValue("catchValue", catchValue, 0);
+ ini.GetValue("runChance-n", i, 1);
+ ini.GetValue("runChance-d", j, 1);
+ runChance.Set(i, j);
+ ini.GetValue("itemChance-i", i, 1);
+ ini.GetValue("itemChance-j", j, 1);
+ itemChance.Set(i, j);
+ ini.GetValue("pokedexNumber", pokedexNumber);
+ ini.GetValue("weight", weight, 0);
+ ini.GetValue("heightFeet", heightFeet, 0);
+ ini.GetValue("heightInches", heightInches, 0);
+ ini.GetValue("pokedexEntry", pokedexEntry);
+ ini.GetValue("frontSprite", frontSprite);
+ ini.GetValue("backSprite", backSprite);
+ ini.GetValue("listSprite", listSprite);
+ ini.GetValue("genderFactor-n", i, 1);
+ ini.GetValue("genderFactor-d", j, 1);
+ genderFactor.Set(i, j, true);
+ ini.GetValue("numEggGroups", i);
+ for (unsigned k = 0; k < i; ++k)
+ {
+ ini.GetValue(String("eggGroups-%d", i), j);
+ if (j != UINT_MAX)
+ types.push_back(j);
+ }
+ ini.GetValue("eggSpecies", eggSpecies);
+ ini.GetValue("eggSteps", eggSteps, 0);
+ ini.GetValue("isDitto", isDitto, false);
+ ini.GetValue("nidoranGroup", nidoranGroup);
+ abilities.clear();
+ evolutions.clear();
+ items.clear();
+ moves.clear();
+ natures.clear();
+ LogImportOver("Pokemon", id, name);
+}
+
+void PokeGen::PokeMod::Pokemon::ExportIni(std::ofstream &fout) const
+{
+ LogExportStart("Pokemon", id, name);
+ // Make elements
+ Ini exPokemon("Pokemon");
+ exPokemon.AddField("id", id);
+ exPokemon.AddField("name", name);
+ exPokemon.AddField("numTypes", GetTypeCount());
+ for (unsigned i = 0; i < GetTypeCount(); ++i)
+ exPokemon.AddField(String("types-%d", i), types[i]);
+ for (unsigned i = 0; i < STH_END_GSC; ++i)
+ exPokemon.AddField(String("baseStats-%d", i), baseStats[i]);
+ for (unsigned i = 0; i < STH_END_GSC; ++i)
+ exPokemon.AddField(String("effortValues-%d", i), effortValues[i]);
+ exPokemon.AddField("growth", growth);
+ exPokemon.AddField("experienceValue", experienceValue);
+ exPokemon.AddField("catchValue", catchValue);
+ exPokemon.AddField("runChance-n", runChance.GetNum());
+ exPokemon.AddField("runChance-d", runChance.GetDenom());
+ exPokemon.AddField("itemChance-n", itemChance.GetNum());
+ exPokemon.AddField("itemChance-d", itemChance.GetDenom());
+ exPokemon.AddField("pokedexNumber", pokedexNumber);
+ exPokemon.AddField("weight", weight);
+ exPokemon.AddField("heightFeet", heightFeet);
+ exPokemon.AddField("heightInches", heightInches);
+ exPokemon.AddField("pokedexEntry", pokedexEntry);
+ exPokemon.AddField("frontSprite", frontSprite);
+ exPokemon.AddField("backSprite", backSprite);
+ exPokemon.AddField("listSprite", listSprite);
+ exPokemon.AddField("genderFactor-n", genderFactor.GetNum());
+ exPokemon.AddField("genderFactor-d", genderFactor.GetDenom());
+ exPokemon.AddField("numTypes", GetTypeCount());
+ for (unsigned i = 0; i < GetEggGroupCount(); ++i)
+ exPokemon.AddField(String("eggGroups-%d", i), eggGroups[i]);
+ exPokemon.AddField("eggSpecies", eggSpecies);
+ exPokemon.AddField("eggSteps", eggSteps);
+ exPokemon.AddField("isDitto", isDitto);
+ exPokemon.AddField("nidoranGroup", nidoranGroup);
+ exPokemon.Export(fout);
+ for (std::vector<PokemonAbility>::const_iterator i = abilities.begin(); i != abilities.end(); ++i)
+ i->ExportIni(fout, name);
+ for (std::vector<PokemonEvolution>::const_iterator i = evolutions.begin(); i != evolutions.end(); ++i)
+ i->ExportIni(fout, name);
+ for (std::vector<PokemonItem>::const_iterator i = items.begin(); i != items.end(); ++i)
+ i->ExportIni(fout, name);
+ for (std::vector<PokemonMove>::const_iterator i = moves.begin(); i != moves.end(); ++i)
+ i->ExportIni(fout, name);
+ for (std::vector<PokemonNature>::const_iterator i = natures.begin(); i != natures.end(); ++i)
+ i->ExportIni(fout, name);
+ LogExportOver("Pokemon", id, name);
+}
+
+void PokeGen::PokeMod::Pokemon::SetName(const String &n)
+{
+ LogSetVar("Pokemon", id, "name", n);
+ name = n;
+}
+
+void PokeGen::PokeMod::Pokemon::SetBaseStat(const unsigned s, const unsigned b)
+{
+ LogSetVar("Pokemon", id, String("baseStats[%u]", s), b, name);
+ if ((s < STH_END_RBY) || ((s == STH_SPECIAL_DEFENSE) && curPokeMod.IsSpecialSplit()))
+ baseStats[s] = b;
+}
+
+void PokeGen::PokeMod::Pokemon::SetEffortValue(const unsigned s, const unsigned e)
+{
+ LogSetVar("Pokemon", id, String("baseStats[%u]", s), e, name);
+ if ((s < STH_END_RBY) || ((s == STH_SPECIAL_DEFENSE) && curPokeMod.IsSpecialSplit()))
+ effortValues[s] = e;
+}
+
+void PokeGen::PokeMod::Pokemon::SetGrowth(const unsigned g)
+{
+ LogSetVar("Pokemon", id, "growth", g, name);
+ if (g < STY_END)
+ growth = g;
+}
+
+void PokeGen::PokeMod::Pokemon::SetGrowth(const String &g)
+{
+ SetGrowth(FindIn(STY_END, g, StyleStr));
+}
+
+void PokeGen::PokeMod::Pokemon::SetExperienceValue(const unsigned e)
+{
+ LogSetVar("Pokemon", id, "experienceValue", e, name);
+ experienceValue = e;
+}
+
+void PokeGen::PokeMod::Pokemon::SetCatchValue(const unsigned char c)
+{
+ LogSetVar("Pokemon", id, "catchValue", c, name);
+ catchValue = c;
+}
+
+void PokeGen::PokeMod::Pokemon::SetRunChance(const Frac &r)
+{
+ LogSetVar("Pokemon", id, "runChance", r.GetNum(), r.GetDenom(), name);
+ runChance = r;
+}
+
+void PokeGen::PokeMod::Pokemon::SetRunChance(const unsigned n, const unsigned d)
+{
+ LogSetVar("Pokemon", id, "runChance", n, d, name);
+ runChance.Set(n, d);
+}
+
+void PokeGen::PokeMod::Pokemon::SetRunChanceNumerator(const unsigned n)
+{
+ LogSetVar("Pokemon", id, "runChance numerator", n, name);
+ runChance.SetNum(n);
+}
+
+void PokeGen::PokeMod::Pokemon::SetRunChanceDenominator(const unsigned d)
+{
+ LogSetVar("Pokemon", id, "runChance denominator", d, name);
+ runChance.SetDenom(d);
+}
+
+void PokeGen::PokeMod::Pokemon::SetItemChance(const Frac &i)
+{
+ LogSetVar("Pokemon", id, "itemChance", i.GetNum(), i.GetDenom(), name);
+ itemChance = i;
+}
+
+void PokeGen::PokeMod::Pokemon::SetItemChance(const unsigned n, const unsigned d)
+{
+ LogSetVar("Pokemon", id, "itemChance", n, d, name);
+ itemChance.Set(n, d);
+}
+
+void PokeGen::PokeMod::Pokemon::SetItemChanceNumerator(const unsigned n)
+{
+ LogSetVar("Pokemon", id, "itemChance numerator", n, name);
+ itemChance.SetNum(n);
+}
+
+void PokeGen::PokeMod::Pokemon::SetItemChanceDenominator(const unsigned d)
+{
+ LogSetVar("Pokemon", id, "itemChance denominator", d, name);
+ itemChance.SetDenom(d);
+}
+
+void PokeGen::PokeMod::Pokemon::SetPokedexNumber(const unsigned p)
+{
+ LogSetVar("Pokemon", id, "pokedexNumber", p, name);
+ pokedexNumber = p;
+}
+
+void PokeGen::PokeMod::Pokemon::SetWeight(const unsigned w)
+{
+ LogSetVar("Pokemon", id, "weight", w, name);
+ weight = w;
+}
+
+void PokeGen::PokeMod::Pokemon::SetHeightFeet(const unsigned f)
+{
+ LogSetVar("Pokemon", id, "heightFeet", f, name);
+ heightFeet = f;
+}
+
+void PokeGen::PokeMod::Pokemon::SetHeightInches(const unsigned char i)
+{
+ LogSetVar("Pokemon", id, "heightInches", i, name);
+ if (i <= 11)
+ heightInches = i;
+}
+
+void PokeGen::PokeMod::Pokemon::SetPokedexEntry(const String &p)
+{
+ LogSetVar("Pokemon", id, "pokedexEntry", p, name);
+ pokedexEntry = p;
+}
+
+void PokeGen::PokeMod::Pokemon::SetFrontSprite(const Path &f)
+{
+ LogSetVar("Pokemon", id, "frontSprite", f, name);
+ frontSprite = f;
+}
+
+void PokeGen::PokeMod::Pokemon::SetBackSprite(const Path &b)
+{
+ LogSetVar("Pokemon", id, "backSprite", b, name);
+ backSprite = b;
+}
+
+void PokeGen::PokeMod::Pokemon::SetListSprite(const Path l)
+{
+ LogSetVar("Pokemon", id, "listSprite", l, name);
+ listSprite = l;
+}
+
+void PokeGen::PokeMod::Pokemon::SetGenderFactor(const Frac &g)
+{
+ LogSetVar("Pokemon", id, "genderFactor", g.GetNum(), g.GetDenom(), name);
+ genderFactor = g;
+}
+
+void PokeGen::PokeMod::Pokemon::SetGenderFactor(const unsigned n, const unsigned d)
+{
+ LogSetVar("Pokemon", id, "genderFactor", n, d, name);
+ genderFactor.Set(n, d);
+}
+
+void PokeGen::PokeMod::Pokemon::SetGenderFactorNumerator(const unsigned n)
+{
+ LogSetVar("Pokemon", id, "genderFactor numerator", n, name);
+ genderFactor.SetNum(n);
+}
+
+void PokeGen::PokeMod::Pokemon::SetGenderFactorDenominator(const unsigned d)
+{
+ LogSetVar("Pokemon", id, "genderFactor denominator", d, name);
+ genderFactor.SetDenom(d);
+}
+
+void PokeGen::PokeMod::Pokemon::SetEggSpecies(const unsigned e)
+{
+ LogSetVar("Pokemon", id, "eggSpecies", e, name);
+ if (curPokeMod.GetPokemon(e))
+ eggSpecies = e;
+}
+
+void PokeGen::PokeMod::Pokemon::SetEggSpecies(const String &e)
+{
+ LogSetVar("Pokemon", id, "eggSpecies", e, name);
+ if (const Pokemon *p = curPokeMod.GetPokemon(e))
+ eggSpecies = p->GetId();
+}
+
+void PokeGen::PokeMod::Pokemon::SetEggSteps(const unsigned e)
+{
+ LogSetVar("Pokemon", id, "eggSteps", e, name);
+ eggSteps = e;
+}
+
+void PokeGen::PokeMod::Pokemon::SetIsDitto(const bool i)
+{
+ LogSetVar("Pokemon", id, "isDitto", i, name);
+ isDitto = i;
+}
+
+void PokeGen::PokeMod::Pokemon::SetNidoranGroup(const unsigned n)
+{
+ LogSetVar("Pokemon", id, "nidoranGroup", n, name);
+ nidoranGroup = n;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemon::GetName() const
+{
+ LogFetchVar("Pokemon", id, "name", name);
+ return name;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetBaseStat(const unsigned s) const
+{
+ LogFetchVar("Pokemon", id, String("baseStats[%d]", s), s, name);
+ if ((s < STH_END_RBY) || ((s == STH_SPECIAL_DEFENSE) && curPokeMod.IsSpecialSplit()))
+ return baseStats[s];
+ return 0;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetEffortValue(const unsigned s) const
+{
+ LogFetchVar("Pokemon", id, String("effortValues[%d]", s), s, name);
+ if ((s < STH_END_RBY) || ((s == STH_SPECIAL_DEFENSE) && curPokeMod.IsSpecialSplit()))
+ return effortValues[s];
+ return 0;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetGrowth() const
+{
+ LogFetchVar("Pokemon", id, "growth", growth, name);
+ return growth;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemon::GetGrowthString() const
+{
+ LogFetchVar("Pokemon", id, "growth string", growth, name);
+ if (growth < STY_END)
+ return StyleStr[growth];
+ return "";
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetExperienceValue() const
+{
+ LogFetchVar("Pokemon", id, "experienceValue", experienceValue, name);
+ return experienceValue;
+}
+
+unsigned char PokeGen::PokeMod::Pokemon::GetCatchValue() const
+{
+ LogFetchVar("Pokemon", id, "catchValue", catchValue, name);
+ return catchValue;
+}
+
+PokeGen::PokeMod::Frac PokeGen::PokeMod::Pokemon::GetRunChance() const
+{
+ LogFetchVar("Pokemon", id, "runChance", runChance.GetNum(), runChance.GetDenom(), name);
+ return runChance;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetRunChanceNumerator() const
+{
+ LogFetchVar("Pokemon", id, "runChance numerator", runChance.GetNum(), name);
+ return runChance.GetNum();
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetRunChanceDenominator() const
+{
+ LogFetchVar("Pokemon", id, "runChance denominator", runChance.GetDenom(), name);
+ return runChance.GetDenom();
+}
+
+PokeGen::PokeMod::Frac PokeGen::PokeMod::Pokemon::GetItemChance() const
+{
+ LogFetchVar("Pokemon", id, "itemChance", itemChance.GetNum(), itemChance.GetDenom(), name);
+ return itemChance;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetItemChanceNumerator() const
+{
+ LogFetchVar("Pokemon", id, "itemChance numerator", itemChance.GetNum(), name);
+ return itemChance.GetNum();
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetItemChanceDenominator() const
+{
+ LogFetchVar("Pokemon", id, "itemChance denominator", itemChance.GetDenom(), name);
+ return itemChance.GetDenom();
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetPokedexNumber() const
+{
+ LogFetchVar("Pokemon", id, "pokedexNumber", pokedexNumber, name);
+ return pokedexNumber;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetWeight() const
+{
+ LogFetchVar("Pokemon", id, "weight", weight, name);
+ return weight;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetHeightFeet() const
+{
+ LogFetchVar("Pokemon", id, "heightFeet", heightFeet, name);
+ return heightFeet;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetHeightInches() const
+{
+ LogFetchVar("Pokemon", id, "heightInches", heightInches, name);
+ return heightInches;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemon::GetPokedexEntry() const
+{
+ LogFetchVar("Pokemon", id, "pokedexEntry", pokedexEntry, name);
+ return pokedexEntry;
+}
+
+PokeGen::PokeMod::Path PokeGen::PokeMod::Pokemon::GetFrontSprite() const
+{
+ LogFetchVar("Pokemon", id, "frontSprite", frontSprite, name);
+ return frontSprite;
+}
+
+PokeGen::PokeMod::Path PokeGen::PokeMod::Pokemon::GetBackSprite() const
+{
+ LogFetchVar("Pokemon", id, "backSprite", backSprite, name);
+ return backSprite;
+}
+
+PokeGen::PokeMod::Path PokeGen::PokeMod::Pokemon::GetListSprite() const
+{
+ LogFetchVar("Pokemon", id, "listSprite", listSprite, name);
+ return listSprite;
+}
+
+PokeGen::PokeMod::Frac PokeGen::PokeMod::Pokemon::GetGenderFactor() const
+{
+ LogFetchVar("Pokemon", id, "genderFactor", genderFactor.GetNum(), genderFactor.GetDenom(), name);
+ return genderFactor;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetGenderFactorNumerator() const
+{
+ LogFetchVar("Pokemon", id, "genderFactor numerator", genderFactor.GetNum(), name);
+ return genderFactor.GetNum();
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetGenderFactorDenominator() const
+{
+ LogFetchVar("Pokemon", id, "genderFactor denominator", genderFactor.GetDenom(), name);
+ return genderFactor.GetDenom();
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetEggSpecies() const
+{
+ LogFetchVar("Pokemon", id, "eggSpecies", eggSpecies, name);
+ return eggSpecies;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Pokemon::GetEggSpeciesString() const
+{
+ LogFetchVar("Pokemon", id, "eggSpecies string", eggSpecies, name);
+ if (const Pokemon *p = curPokeMod.GetPokemon(eggSpecies))
+ return p->GetName();
+ return "";
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetEggSteps() const
+{
+ LogFetchVar("Pokemon", id, "eggSteps", eggSteps, name);
+ return eggSteps;
+}
+
+bool PokeGen::PokeMod::Pokemon::GetIsDitto() const
+{
+ LogFetchVar("Pokemon", id, "isDitto", isDitto, name);
+ return isDitto;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetNidoranGroup() const
+{
+ LogFetchVar("Pokemon", id, "nidoranGroup", nidoranGroup, name);
+ return nidoranGroup;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetType(const unsigned i) const
+{
+ LogSubmoduleFetch("Pokemon", id, "type", i, name);
+ if (i < GetTypeCount() <= i)
+ return types[i];
+ LogSubmoduleFetchFail("Pokemon", id, "type", i, name);
+ return UINT_MAX;
+}
+
+bool PokeGen::PokeMod::Pokemon::HasType(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemon", id, "type", _id, name);
+ return (GetType(_id) != UINT_MAX);
+}
+
+bool PokeGen::PokeMod::Pokemon::HasType(const String &n) const
+{
+ LogSubmoduleFetch("Pokemon", id, "type", UINT_MAX, name);
+ for (unsigned i = 0; i < GetTypeCount(); ++i)
+ {
+ if (curPokeMod.GetType(types[i])->GetName() == n)
+ return true;
+ }
+ LogSubmoduleFetchFail("Pokemon", id, "type", UINT_MAX, name);
+ return false;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetTypeCount() const
+{
+ LogSubmoduleCount("Pokemon", id, "type", name);
+ return types.size();
+}
+
+void PokeGen::PokeMod::Pokemon::NewType(const unsigned i)
+{
+ LogSubmoduleNew("Pokemon", id, "type", i);
+ if (curPokeMod.GetType(i))
+ types.push_back(i);
+}
+
+void PokeGen::PokeMod::Pokemon::NewType(const String &n)
+{
+ LogSubmoduleNew("Pokemon", id, "type", n);
+ if (const Type *t = curPokeMod.GetType(n))
+ types.push_back(t->GetId());
+}
+
+void PokeGen::PokeMod::Pokemon::DeleteType(const unsigned i)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "type", i, name);
+ if (i < GetTypeCount())
+ DeleteTypeByID(types[i]);
+ else
+ LogSubmoduleRemoveFail("Pokemon", id, "type", i, name);
+}
+
+void PokeGen::PokeMod::Pokemon::DeleteType(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "type", n, name);
+ if (const Type *i = curPokeMod.GetType(n))
+ DeleteTypeByID(i->GetId());
+ else
+ LogSubmoduleRemoveFail("Pokemon", id, "type", n, name);
+}
+
+void PokeGen::PokeMod::Pokemon::DeleteTypeByID(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "type", _id, name);
+ for (std::vector<unsigned>::iterator i = types.begin(); i != types.end(); ++i)
+ {
+ if (*i == _id)
+ {
+ LogSubmoduleRemoved("Pokemon", id, "type", _id, name);
+ types.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemon", id, "type", _id, name);
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetEggGroup(const unsigned i) const
+{
+ LogSubmoduleFetch("Pokemon", id, "egg group", i, name);
+ if (i < GetEggGroupCount() <= i)
+ return eggGroups[i];
+ LogSubmoduleFetchFail("Pokemon", id, "egg group", i, name);
+ return UINT_MAX;
+}
+
+bool PokeGen::PokeMod::Pokemon::InEggGroup(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemon", id, "egg group", _id, name);
+ return (GetEggGroup(_id) != UINT_MAX);
+}
+
+bool PokeGen::PokeMod::Pokemon::InEggGroup(const String &n) const
+{
+ LogSubmoduleFetch("Pokemon", id, "egg group", UINT_MAX, name);
+ for (unsigned i = 0; i < GetEggGroupCount(); ++i)
+ {
+ if (curPokeMod.GetEggGroup(eggGroups[i])->GetName() == n)
+ return true;
+ }
+ LogSubmoduleFetchFail("Pokemon", id, "egg group", UINT_MAX, name);
+ return false;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetEggGroupCount() const
+{
+ LogSubmoduleCount("Pokemon", id, "egg group", name);
+ return eggGroups.size();
+}
+
+void PokeGen::PokeMod::Pokemon::NewEggGroup(const unsigned i)
+{
+ LogSubmoduleNew("Pokemon", id, "egg group", i);
+ if (curPokeMod.GetEggGroup(i))
+ eggGroups.push_back(i);
+}
+
+void PokeGen::PokeMod::Pokemon::NewEggGroup(const String &n)
+{
+ LogSubmoduleNew("Pokemon", id, "egg group", n);
+ if (const EggGroup *e = curPokeMod.GetEggGroup(n))
+ eggGroups.push_back(e->GetId());
+}
+
+void PokeGen::PokeMod::Pokemon::DeleteEggGroup(const unsigned i)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "egg group", i, name);
+ if (i < GetTypeCount())
+ DeleteEggGroupByID(eggGroups[i]);
+ else
+ LogSubmoduleRemoveFail("Pokemon", id, "egg group", i, name);
+}
+
+void PokeGen::PokeMod::Pokemon::DeleteEggGroup(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "egg group", n, name);
+ if (const EggGroup *i = curPokeMod.GetEggGroup(n))
+ DeleteEggGroupByID(i->GetId());
+ else
+ LogSubmoduleRemoveFail("Pokemon", id, "egg group", n, name);
+}
+
+void PokeGen::PokeMod::Pokemon::DeleteEggGroupByID(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "egg group", _id, name);
+ for (std::vector<unsigned>::iterator i = eggGroups.begin(); i != eggGroups.end(); ++i)
+ {
+ if (*i == _id)
+ {
+ LogSubmoduleRemoved("Pokemon", id, "egg group", _id, name);
+ eggGroups.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemon", id, "egg group", _id, name);
+}
+
+const PokeGen::PokeMod::PokemonAbility *PokeGen::PokeMod::Pokemon::GetPokemonAbility(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemon", id, "ability", _id, name);
+ for (unsigned i = 0; i < GetPokemonAbilityCount(); ++i)
+ {
+ if (abilities[i].GetId() == _id)
+ return &abilities[i];
+ }
+ LogSubmoduleFetchFail("Pokemon", id, "ability", _id, name);
+ return NULL;
+}
+
+const PokeGen::PokeMod::PokemonAbility *PokeGen::PokeMod::Pokemon::GetPokemonAbility(const String &n) const
+{
+ LogSubmoduleFetch("Pokemon", id, "ability", n, name);
+ for (unsigned i = 0; i < GetPokemonAbilityCount(); ++i)
+ {
+ if (abilities[i].GetAbilityString() == n)
+ return &abilities[i];
+ }
+ LogSubmoduleFetchFail("Pokemon", id, "ability", n, name);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetPokemonAbilityCount() const
+{
+ LogSubmoduleCount("Pokemon", id, "ability", name);
+ return abilities.size();
+}
+
+void PokeGen::PokeMod::Pokemon::NewPokemonAbility(Ini *const ini)
+{
+ unsigned i = 0;
+ // Find the first unused ID in the vector
+ for (; i < GetPokemonAbilityCount(); ++i)
+ {
+ if (!GetPokemonAbility(i))
+ break;
+ }
+ PokemonAbility newPokemonAbility(i);
+ if (ini)
+ newPokemonAbility.ImportIni(*ini);
+ LogSubmoduleNew("Pokemon", id, "ability", i, name);
+ abilities.push_back(newPokemonAbility);
+}
+
+void PokeGen::PokeMod::Pokemon::DeletePokemonAbility(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "ability", _id, name);
+ for (std::vector<PokemonAbility>::iterator i = abilities.begin(); i != abilities.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemon", id, "ability", _id, name);
+ abilities.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemon", id, "ability", _id, name);
+}
+
+void PokeGen::PokeMod::Pokemon::DeletePokemonAbility(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "ability", n, name);
+ for (std::vector<PokemonAbility>::iterator i = abilities.begin(); i != abilities.end(); ++i)
+ {
+ if (i->GetAbilityString() == n)
+ {
+ LogSubmoduleRemoved("Pokemon", id, "ability", n, name);
+ abilities.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemon", id, "ability", n, name);
+}
+
+const PokeGen::PokeMod::PokemonEvolution *PokeGen::PokeMod::Pokemon::GetPokemonEvolution(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemon", id, "evolution", _id, name);
+ for (unsigned i = 0; i < GetPokemonEvolutionCount(); ++i)
+ {
+ if (evolutions[i].GetId() == _id)
+ return &evolutions[i];
+ }
+ LogSubmoduleFetchFail("Pokemon", id, "evolution", _id, name);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetPokemonEvolutionCount() const
+{
+ LogSubmoduleCount("Pokemon", id, "evolution", name);
+ return evolutions.size();
+}
+
+void PokeGen::PokeMod::Pokemon::NewPokemonEvolution(Ini *const ini)
+{
+ unsigned i = 0;
+ // Find the first unused ID in the vector
+ for (; i < GetPokemonEvolutionCount(); ++i)
+ {
+ if (!GetPokemonEvolution(i))
+ break;
+ }
+ PokemonEvolution newPokemonEvolution(i);
+ if (ini)
+ newPokemonEvolution.ImportIni(*ini);
+ LogSubmoduleNew("Pokemon", id, "evolution", i, name);
+ evolutions.push_back(newPokemonEvolution);
+}
+
+void PokeGen::PokeMod::Pokemon::DeletePokemonEvolution(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "evolution", _id, name);
+ for (std::vector<PokemonEvolution>::iterator i = evolutions.begin(); i != evolutions.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemon", id, "evolution", _id, name);
+ evolutions.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemon", id, "evolution", _id, name);
+}
+
+const PokeGen::PokeMod::PokemonItem *PokeGen::PokeMod::Pokemon::GetPokemonItem(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemon", id, "item", _id, name);
+ for (unsigned i = 0; i < GetPokemonItemCount(); ++i)
+ {
+ if (items[i].GetId() == _id)
+ return &items[i];
+ }
+ LogSubmoduleFetchFail("Pokemon", id, "item", _id, name);
+ return NULL;
+}
+
+const PokeGen::PokeMod::PokemonItem *PokeGen::PokeMod::Pokemon::GetPokemonItem(const String &n) const
+{
+ LogSubmoduleFetch("Pokemon", id, "item", n, name);
+ for (unsigned i = 0; i < GetPokemonItemCount(); ++i)
+ {
+ if (items[i].GetItemString() == n)
+ return &items[i];
+ }
+ LogSubmoduleFetchFail("Pokemon", id, "item", n, name);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetPokemonItemCount() const
+{
+ LogSubmoduleCount("Pokemon", id, "item", name);
+ return items.size();
+}
+
+void PokeGen::PokeMod::Pokemon::NewPokemonItem(Ini *const ini)
+{
+ unsigned i = 0;
+ // Find the first unused ID in the vector
+ for (; i < GetPokemonItemCount(); ++i)
+ {
+ if (!GetPokemonItem(i))
+ break;
+ }
+ PokemonItem newPokemonItem(i);
+ if (ini)
+ newPokemonItem.ImportIni(*ini);
+ LogSubmoduleNew("Pokemon", id, "item", i, name);
+ items.push_back(newPokemonItem);
+}
+
+void PokeGen::PokeMod::Pokemon::DeletePokemonItem(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "item", _id, name);
+ for (std::vector<PokemonItem>::iterator i = items.begin(); i != items.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemon", id, "item", _id, name);
+ items.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemon", id, "item", _id, name);
+}
+
+void PokeGen::PokeMod::Pokemon::DeletePokemonItem(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "item", n, name);
+ for (std::vector<PokemonItem>::iterator i = items.begin(); i != items.end(); ++i)
+ {
+ if (i->GetItemString() == n)
+ {
+ LogSubmoduleRemoved("Pokemon", id, "item", n, name);
+ items.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemon", id, "item", n, name);
+}
+
+const PokeGen::PokeMod::PokemonMove *PokeGen::PokeMod::Pokemon::GetPokemonMove(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemon", id, "move", _id, name);
+ for (unsigned i = 0; i < GetPokemonMoveCount(); ++i)
+ {
+ if (moves[i].GetId() == _id)
+ return &moves[i];
+ }
+ LogSubmoduleFetchFail("Pokemon", id, "move", _id, name);
+ return NULL;
+}
+
+const PokeGen::PokeMod::PokemonMove *PokeGen::PokeMod::Pokemon::GetPokemonMove(const String &n) const
+{
+ LogSubmoduleFetch("Pokemon", id, "move", n, name);
+ for (unsigned i = 0; i < GetPokemonMoveCount(); ++i)
+ {
+ if (moves[i].GetMoveString() == n)
+ return &moves[i];
+ }
+ LogSubmoduleFetchFail("Pokemon", id, "move", n, name);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetPokemonMoveCount() const
+{
+ LogSubmoduleCount("Pokemon", id, "move", name);
+ return moves.size();
+}
+
+void PokeGen::PokeMod::Pokemon::NewPokemonMove(Ini *const ini)
+{
+ unsigned i = 0;
+ // Find the first unused ID in the vector
+ for (; i < GetPokemonMoveCount(); ++i)
+ {
+ if (!GetPokemonMove(i))
+ break;
+ }
+ PokemonMove newPokemonMove(i);
+ if (ini)
+ newPokemonMove.ImportIni(*ini);
+ LogSubmoduleNew("Pokemon", id, "move", i, name);
+ moves.push_back(newPokemonMove);
+}
+
+void PokeGen::PokeMod::Pokemon::DeletePokemonMove(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "move", _id, name);
+ for (std::vector<PokemonMove>::iterator i = moves.begin(); i != moves.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemon", id, "move", _id, name);
+ moves.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemon", id, "move", _id, name);
+}
+
+void PokeGen::PokeMod::Pokemon::DeletePokemonMove(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "move", n, name);
+ for (std::vector<PokemonMove>::iterator i = moves.begin(); i != moves.end(); ++i)
+ {
+ if (i->GetMoveString() == n)
+ {
+ LogSubmoduleRemoved("Pokemon", id, "move", n, name);
+ moves.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemon", id, "move", n, name);
+}
+
+const PokeGen::PokeMod::PokemonNature *PokeGen::PokeMod::Pokemon::GetPokemonNature(const unsigned _id) const
+{
+ LogSubmoduleFetch("Pokemon", id, "nature", _id, name);
+ for (unsigned i = 0; i < GetPokemonNatureCount(); ++i)
+ {
+ if (natures[i].GetId() == _id)
+ return &natures[i];
+ }
+ LogSubmoduleFetchFail("Pokemon", id, "nature", _id, name);
+ return NULL;
+}
+
+const PokeGen::PokeMod::PokemonNature *PokeGen::PokeMod::Pokemon::GetPokemonNature(const String &n) const
+{
+ LogSubmoduleFetch("Pokemon", id, "nature", n, name);
+ for (unsigned i = 0; i < GetPokemonNatureCount(); ++i)
+ {
+ if (natures[i].GetNatureString() == n)
+ return &natures[i];
+ }
+ LogSubmoduleFetchFail("Pokemon", id, "nature", n, name);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Pokemon::GetPokemonNatureCount() const
+{
+ LogSubmoduleCount("Pokemon", id, "nature", name);
+ return natures.size();
+}
+
+void PokeGen::PokeMod::Pokemon::NewPokemonNature(Ini *const ini)
+{
+ unsigned i = 0;
+ // Find the first unused ID in the vector
+ for (; i < GetPokemonNatureCount(); ++i)
+ {
+ if (!GetPokemonNature(i))
+ break;
+ }
+ PokemonNature newPokemonNature(i);
+ if (ini)
+ newPokemonNature.ImportIni(*ini);
+ LogSubmoduleNew("Pokemon", id, "nature", i, name);
+ natures.push_back(newPokemonNature);
+}
+
+void PokeGen::PokeMod::Pokemon::DeletePokemonNature(const unsigned _id)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "nature", _id, name);
+ for (std::vector<PokemonNature>::iterator i = natures.begin(); i != natures.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Pokemon", id, "nature", _id, name);
+ natures.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemon", id, "nature", _id, name);
+}
+
+void PokeGen::PokeMod::Pokemon::DeletePokemonNature(const String &n)
+{
+ LogSubmoduleRemoveStart("Pokemon", id, "nature", n, name);
+ for (std::vector<PokemonNature>::iterator i = natures.begin(); i != natures.end(); ++i)
+ {
+ if (i->GetNatureString() == n)
+ {
+ LogSubmoduleRemoved("Pokemon", id, "nature", n, name);
+ natures.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Pokemon", id, "nature", n, name);
+}
|
