summaryrefslogtreecommitdiffstats
path: root/pokemod/PokemonNature.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2007-05-22 03:51:45 +0000
committerBen Boeckel <MathStuf@gmail.com>2007-05-22 03:51:45 +0000
commite858d98977a09b3c8faf4df87ada4abc1399e8e5 (patch)
treefbe406e42296b784cf03ae65cb9cbccb97aa7fa8 /pokemod/PokemonNature.cpp
parent0fec318eac634e5465c30eb73d47ec82aaed9db8 (diff)
Added a lot of minor PokéMod modules
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@12 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/PokemonNature.cpp')
-rw-r--r--pokemod/PokemonNature.cpp154
1 files changed, 154 insertions, 0 deletions
diff --git a/pokemod/PokemonNature.cpp b/pokemod/PokemonNature.cpp
new file mode 100644
index 00000000..7bc972bc
--- /dev/null
+++ b/pokemod/PokemonNature.cpp
@@ -0,0 +1,154 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokemod/PokemonNature.cpp
+// Purpose: Define an nature that a Pokémon can have
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Tue Mar 20 18:39:17 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 "PokemonNature.h"
+
+extern PokeGen::PokeMod::Pokemod curPokeMod;
+
+PokeGen::PokeMod::PokemonNature::PokemonNature(unsigned _id)
+{
+ LogCtor("PokemonNature", _id);
+ nature = -1;
+ weight = 1;
+ id = _id;
+}
+
+PokeGen::PokeMod::PokemonNature::PokemonNature(Ini &ini, unsigned _id)
+{
+ LogCtorIni("PokemonNature", _id);
+ ImportIni(ini, _id);
+ if(_id == UINT_MAX)
+ LogIdError("PokemonNature");
+}
+
+PokeGen::PokeMod::PokemonNature::~PokemonNature()
+{
+ LogDtor("PokemonNature", id, GetNatureString());
+}
+
+void PokeGen::PokeMod::PokemonNature::Validate()
+{
+ isValid = true;
+ LogValidateStart("PokemonNature", id);
+ if (!curPokeMod.GetNature(nature))
+ {
+ LogVarNotValid("PokemonNature", id, "nature");
+ isValid = false;
+ }
+ if (!weight)
+ {
+ LogVarNotSet("PokemonNature", id, "weight", GetNatureString());
+ isValid = false;
+ }
+ LogValidateOver("PokemonNature", id, isValid, GetNatureString());
+}
+
+#ifdef PG_DEBUG_WINDOW
+void PokeGen::PokeMod::PokemonNature::Validate(const wxListBox &output)
+{
+ isValid = true;
+ LogValidateStart("PokemonNature", id);
+ if (!curPokeMod.GetNature(nature))
+ {
+ LogVarNotValid("PokemonNature", id, "nature");
+ output.Append(ConsoleLogVarNotValid("PokemonNature", id, "nature"));
+ isValid = false;
+ }
+ if (!weight)
+ {
+ LogVarNotSet("PokemonNature", id, "weight", GetNatureString());
+ output.Append(ConsoleLogVarNotSet("PokemonNature", id, weight, GetNatureString());
+ isValid = false;
+ }
+ LogValidateOver("PokemonNature", id, isValid, GetNatureString());
+}
+#endif
+
+void PokeGen::PokeMod::PokemonNature::ImportIni(Ini &ini, unsigned _id)
+{
+ LogImportStart("PokemonNature");
+ if (_id == UINT_MAX)
+ {
+ ini.GetValue("id", id, UINT_MAX);
+ // Was there an id associated with the element?
+ if (id == UINT_MAX)
+ LogIdNotFound("PokemonNature");
+ }
+ else
+ id = _id;
+ ini.GetValue("nature", nature, -1);
+ ini.GetValue("weight", weight, 1);
+ LogImportOver("PokemonNature", id);
+}
+
+void PokeGen::PokeMod::PokemonNature::ExportIni(std::ofstream &fout) const
+{
+ LogExportStart("PokemonNature", id);
+ // Make elements
+ Ini exPokemonNature("PokemonNature");
+ exPokemonNature.AddField("id", id);
+ exPokemonNature.AddField("nature", nature);
+ exPokemonNature.AddField("weight", weight);
+ exPokemonNature.Export(fout);
+ LogExportOver("PokemonNature", id);
+}
+
+void PokeGen::PokeMod::PokemonNature::SetNature(int n)
+{
+ LogSetVar("PokemonNature", id, "nature", n);
+ nature = n;
+}
+
+void PokeGen::PokeMod::PokemonNature::SetNature(const String &n)
+{
+ LogSetVar("PokemonNature", id, "nature", n);
+ if (Nature *temp = curPokeMod.GetNature(n))
+ nature = temp->GetId();
+}
+
+void PokeGen::PokeMod::PokemonNature::SetWeight(unsigned w)
+{
+ LogSetVar("PokemonNature", id, "weight", w, GetNatureString());
+ if (w)
+ weight = w;
+}
+
+int PokeGen::PokeMod::PokemonNature::GetNature() const
+{
+ LogFetchVar("PokemonNature", id, "nature", nature);
+ return nature;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::PokemonNature::GetNatureString() const
+{
+ LogFetchVar("PokemonNature", id, "nature string", nature);
+ if (Nature *n = curPokeMod.GetNature(nature))
+ return n->GetName();
+ return "";
+}
+
+unsigned PokeGen::PokeMod::PokemonNature::GetWeight() const
+{
+ LogFetchVar("PokemonNature", id, "weight", weight, GetNatureString());
+ return weight;
+}