summaryrefslogtreecommitdiffstats
path: root/pokemod/PokemonAbility.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/PokemonAbility.cpp
parent0fec318eac634e5465c30eb73d47ec82aaed9db8 (diff)
downloadsigen-e858d98977a09b3c8faf4df87ada4abc1399e8e5.tar.gz
sigen-e858d98977a09b3c8faf4df87ada4abc1399e8e5.tar.xz
sigen-e858d98977a09b3c8faf4df87ada4abc1399e8e5.zip
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/PokemonAbility.cpp')
-rw-r--r--pokemod/PokemonAbility.cpp154
1 files changed, 154 insertions, 0 deletions
diff --git a/pokemod/PokemonAbility.cpp b/pokemod/PokemonAbility.cpp
new file mode 100644
index 00000000..33035db1
--- /dev/null
+++ b/pokemod/PokemonAbility.cpp
@@ -0,0 +1,154 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokemod/PokemonAbility.cpp
+// Purpose: Define an ability 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 "PokemonAbility.h"
+
+extern PokeGen::PokeMod::Pokemod curPokeMod;
+
+PokeGen::PokeMod::PokemonAbility::PokemonAbility(unsigned _id)
+{
+ LogCtor("PokemonAbility", _id);
+ ability = -1;
+ weight = 1;
+ id = _id;
+}
+
+PokeGen::PokeMod::PokemonAbility::PokemonAbility(Ini &ini, unsigned _id)
+{
+ LogCtorIni("PokemonAbility", _id);
+ ImportIni(ini, _id);
+ if(_id == UINT_MAX)
+ LogIdError("PokemonAbility");
+}
+
+PokeGen::PokeMod::PokemonAbility::~PokemonAbility()
+{
+ LogDtor("PokemonAbility", id, GetAbilityString());
+}
+
+void PokeGen::PokeMod::PokemonAbility::Validate()
+{
+ isValid = true;
+ LogValidateStart("PokemonAbility", id);
+ if (!curPokeMod.GetAbility(ability))
+ {
+ LogVarNotValid("PokemonAbility", id, "ability");
+ isValid = false;
+ }
+ if (!weight)
+ {
+ LogVarNotSet("PokemonAbility", id, "weight", GetAbilityString());
+ isValid = false;
+ }
+ LogValidateOver("PokemonAbility", id, isValid, GetAbilityString());
+}
+
+#ifdef PG_DEBUG_WINDOW
+void PokeGen::PokeMod::PokemonAbility::Validate(const wxListBox &output)
+{
+ isValid = true;
+ LogValidateStart("PokemonAbility", id);
+ if (!curPokeMod.GetAbility(ability))
+ {
+ LogVarNotValid("PokemonAbility", id, "ability");
+ output.Append(ConsoleLogVarNotValid("PokemonAbility", id, "ability"));
+ isValid = false;
+ }
+ if (!weight)
+ {
+ LogVarNotSet("PokemonAbility", id, "weight", GetAbilityString());
+ output.Append(ConsoleLogVarNotSet("PokemonAbility", id, weight, GetAbilityString());
+ isValid = false;
+ }
+ LogValidateOver("PokemonAbility", id, isValid, GetAbilityString());
+}
+#endif
+
+void PokeGen::PokeMod::PokemonAbility::ImportIni(Ini &ini, unsigned _id)
+{
+ LogImportStart("PokemonAbility");
+ if (_id == UINT_MAX)
+ {
+ ini.GetValue("id", id, UINT_MAX);
+ // Was there an id associated with the element?
+ if (id == UINT_MAX)
+ LogIdNotFound("PokemonAbility");
+ }
+ else
+ id = _id;
+ ini.GetValue("ability", ability, -1);
+ ini.GetValue("weight", weight, 1);
+ LogImportOver("PokemonAbility", id);
+}
+
+void PokeGen::PokeMod::PokemonAbility::ExportIni(std::ofstream &fout) const
+{
+ LogExportStart("PokemonAbility", id);
+ // Make elements
+ Ini exPokemonAbility("pokemonAbility");
+ exPokemonAbility.AddField("id", id);
+ exPokemonAbility.AddField("ability", ability);
+ exPokemonAbility.AddField("weight", weight);
+ exPokemonAbility.Export(fout);
+ LogExportOver("PokemonAbility", id);
+}
+
+void PokeGen::PokeMod::PokemonAbility::SetAbility(int a)
+{
+ LogSetVar("PokemonAbility", id, "ability", a);
+ ability = a;
+}
+
+void PokeGen::PokeMod::PokemonAbility::SetAbility(const String &a)
+{
+ LogSetVar("PokemonAbility", id, "ability", a);
+ if (Ability *temp = curPokeMod.GetAbility(a))
+ ability = a->GetId();
+}
+
+void PokeGen::PokeMod::PokemonAbility::SetWeight(unsigned w)
+{
+ LogSetVar("PokemonAbility", id, "weight", w, GetAbilityString());
+ if (w)
+ weight = w;
+}
+
+int PokeGen::PokeMod::PokemonAbility::GetAbility() const
+{
+ LogFetchVar("PokemonAbility", id, "ability", ability);
+ return ability;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::PokemonAbility::GetAbilityString() const
+{
+ LogFetchVar("PokemonAbility", id, "ability string", ability);
+ if (Ability *a = curPokeMod.GetAbility(ability))
+ return a->GetName();
+ return "";
+}
+
+unsigned PokeGen::PokeMod::PokemonAbility::GetWeight() const
+{
+ LogFetchVar("PokemonAbility", id, "weight", weight, GetAbilityString());
+ return weight;
+}