summaryrefslogtreecommitdiffstats
path: root/pokemod/PokemonEvolution.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/PokemonEvolution.cpp')
-rw-r--r--pokemod/PokemonEvolution.cpp235
1 files changed, 235 insertions, 0 deletions
diff --git a/pokemod/PokemonEvolution.cpp b/pokemod/PokemonEvolution.cpp
new file mode 100644
index 00000000..c355a89c
--- /dev/null
+++ b/pokemod/PokemonEvolution.cpp
@@ -0,0 +1,235 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokemod/PokemonEvolution.cpp
+// Purpose: Define an evolution that a Pokémon can go through
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Tue Mar 20 18:45:29 2007
+// Copyright: ©2007 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 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
+// 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, write to the Free Software Foundation, Inc.,
+// 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+/////////////////////////////////////////////////////////////////////////////
+
+#include "PokemonEvolution.h"
+
+extern PokeGen::PokeMod::Pokemod curPokeMod;
+
+PokeGen::PokeMod::PokemonEvolution::PokemonEvolution(unsigned _id)
+{
+ LogCtor("PokemonEvolution", _id);
+ species = -1;
+ style = 0;
+ level = 0;
+ item = -1;
+ happiness = 0;
+ id = _id;
+}
+
+PokeGen::PokeMod::PokemonEvolution::PokemonEvolution(Ini &ini, unsigned _id)
+{
+ LogCtorIni("PokemonEvolution", _id);
+ ImportIni(ini);
+ if(_id == UINT_MAX)
+ LogIdError("PokemonEvolution");
+}
+
+PokeGen::PokeMod::PokemonEvolution::~PokemonEvolution()
+{
+ LogDtor("PokemonEvolution", id);
+}
+
+void PokeGen::PokeMod::PokemonEvolution::Validate()
+{
+ isValid = true;
+ LogValidateStart("PokemonEvolution", id);
+ if (!curPokeMod.GetPokemon(species))
+ {
+ LogVarNotValid("PokemonEvolution", id, "species");
+ isValid = false;
+ }
+ if (STY_END <= style)
+ {
+ LogVarNotValid("PokemonEvolution", id, "style");
+ isValid = false;
+ }
+ if (curPokeMod.GetMaxLevel() <= level)
+ {
+ LogVarNotValid("PokemonEvolution", id, "level");
+ isValid = false;
+ }
+ if (!curPokeMod.GetItem(item))
+ {
+ LogVarNotValid("PokemonEvolution", id, "species");
+ isValid = false;
+ }
+ LogValidateOver("PokemonEvolution", id, isValid);
+}
+
+#ifdef PG_DEBUG_WINDOW
+void PokeGen::PokeMod::PokemonEvolution::Validate(const wxListBox &output)
+{
+ isValid = true;
+ LogValidateStart("PokemonEvolution", id);
+ if (!curPokeMod.GetPokemon(species))
+ {
+ LogVarNotValid("PokemonEvolution", id, "species");
+ output.Append(ConsoleLogVarNotValid("PokemonEvolution", id, "move"));
+ isValid = false;
+ }
+ if (STY_END <= style)
+ {
+ LogVarNotValid("PokemonEvolution", id, "style");
+ output.Append("Error (PokemonEvolution): Style out of range");
+ isValid = false;
+ }
+ if (curPokeMod.GetMaxLevel() <= level)
+ {
+ LogVarNotValid("PokemonEvolution", id, "level");
+ output.Append("Error (PokemonEvolution): Level out of range");
+ isValid = false;
+ }
+ if (!curPokeMod.GetItem(item))
+ {
+ LogVarNotValid("PokemonEvolution", id, "species");
+ output.Append(ConsoleLogVarNotValid("PokemonEvolution", id, "species"));
+ isValid = false;
+ }
+ LogValidateOver("PokemonEvolution", id, isValid);
+}
+#endif
+
+void PokeGen::PokeMod::PokemonEvolution::ImportIni(Ini &ini, unsigned _id)
+{
+ LogImportStart("PokemonEvolution");
+ if (_id == UINT_MAX)
+ {
+ ini.GetValue("id", id, UINT_MAX);
+ // Was there an id associated with the element?
+ if (id == UINT_MAX)
+ LogIdNotFound("PokemonEvolution");
+ }
+ else
+ id = _id;
+ ini.GetValue("species", species, -1);
+ ini.GetValue("style", style, 0);
+ ini.GetValue("level", level, 0);
+ ini.GetValue("item", item, -1);
+ ini.GetValue("happiness", happiness, 0);
+ LogImportOver("PokemonEvolution", id);
+}
+
+void PokeGen::PokeMod::PokemonEvolution::ExportIni(std::ofstream &fout) const
+{
+ LogExportStart("PokemonEvolution", id);
+ // Make elements
+ Ini exPokemonEvolution("PokemonEvolution");
+ exPokemonEvolution.AddField("id", id);
+ exPokemonEvolution.AddField("species", species);
+ exPokemonEvolution.AddField("style", style);
+ exPokemonEvolution.AddField("level", level);
+ exPokemonEvolution.AddField("item", item);
+ exPokemonEvolution.AddField("happiness", happiness);
+ exPokemonEvolution.Export(fout);
+ LogExportOver("PokemonEvolution", id);
+}
+
+void PokeGen::PokeMod::PokemonEvolution::SetSpecies(int s)
+{
+ LogSetVar("PokemonEvolution", id, "species", s);
+ species = s;
+}
+
+void PokeGen::PokeMod::PokemonEvolution::SetSpecies(const String &s)
+{
+ LogSetVar("PokemonEvolution", id, "species", s);
+ if (Pokemon *temp = curPokeMod.GetPokemon(s))
+ species = temp->GetId();
+}
+
+void PokeGen::PokeMod::PokemonEvolution::SetStyle(int s)
+{
+ LogSetVar("PokemonEvolution", id, "style", s);
+ style = s;
+}
+
+void PokeGen::PokeMod::PokemonEvolution::SetLevel(unsigned l)
+{
+ LogSetVar("PokemonEvolution", id, "level", l);
+ level = l;
+}
+
+void PokeGen::PokeMod::PokemonEvolution::SetItem(int i)
+{
+ LogSetVar("PokemonEvolution", id, "item", i);
+ item = i;
+}
+
+void PokeGen::PokeMod::PokemonEvolution::SetItem(const String &i)
+{
+ LogSetVar("PokemonEvolution", id, "item", i);
+ if (Item *temp = curPokeMod.GetItem(i))
+ item = temp->GetId();
+}
+
+void PokeGen::PokeMod::PokemonEvolution::SetHappiness(unsigned h)
+{
+ LogSetVar("PokemonEvolution", id, "happiness", h);
+ happiness = h;
+}
+
+int PokeGen::PokeMod::PokemonEvolution::GetSpecies()
+{
+ LogFetchVar("PokemonEvolution", id, "species", species);
+ return species;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::PokemonEvolution::GetSpeciesString()
+{
+ LogFetchVar("PokemonEvolution", id, "species string", species);
+ if (Pokemon *s = curPokeMod.GetPokemon(species))
+ return s->GetName();
+ return "";
+}
+
+int PokeGen::PokeMod::PokemonEvolution::GetStyle()
+{
+ LogFetchVar("PokemonEvolution", id, "style", style);
+ return style;
+}
+
+unsigned PokeGen::PokeMod::PokemonEvolution::GetLevel()
+{
+ LogFetchVar("PokemonEvolution", id, "level", level);
+ return level;
+}
+
+int PokeGen::PokeMod::PokemonEvolution::GetItem()
+{
+ LogFetchVar("PokemonEvolution", id, "item", item);
+ return item;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::PokemonEvolution::GetItemString()
+{
+ LogFetchVar("PokemonEvolution", id, "item string", item);
+ if (Item *i = curPokeMod.GetItem(item))
+ return i->GetName();
+ return "";
+}
+
+unsigned PokeGen::PokeMod::PokemonEvolution::GetHappiness()
+{
+ LogFetchVar("PokemonEvolution", id, "happiness", happiness);
+ return happiness;
+}