diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2007-05-21 04:18:48 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2007-05-21 04:18:48 +0000 |
| commit | 0fec318eac634e5465c30eb73d47ec82aaed9db8 (patch) | |
| tree | 1851831cbcfce296aeabe7ad553ca936343d4a33 /pokemod/PokemonItem.cpp | |
| parent | 42375a0129fdd57355764c58ed27fa3a0a3c5465 (diff) | |
Added Time, Store, and PokemonItem
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@11 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/PokemonItem.cpp')
| -rw-r--r-- | pokemod/PokemonItem.cpp | 165 |
1 files changed, 165 insertions, 0 deletions
diff --git a/pokemod/PokemonItem.cpp b/pokemod/PokemonItem.cpp new file mode 100644 index 00000000..3ff1e273 --- /dev/null +++ b/pokemod/PokemonItem.cpp @@ -0,0 +1,165 @@ +/////////////////////////////////////////////////////////////////////////////
+// Name: PokemonItem.cpp
+// Purpose: Define an item that a Pokémon can be found with in the wild
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Tue Mar 20 18:40:28 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 "PokemonItem.h"
+
+extern PokeGen::PokeMod::Pokemod curPokeMod;
+
+PokeGen::PokeMod::PokemonItem::PokemonItem(unsigned _id)
+{
+ LogCtor("PokemonItem", _id);
+ item = -1;
+ weight = 1;
+ id = _id;
+}
+
+PokeGen::PokeMod::PokemonItem::PokemonItem(Ini &ini, unsigned _id)
+{
+ LogCtorIni("PokemonItem", _id);
+ ImportIni(ini, _id);
+ if(_id == UINT_MAX)
+ LogIdError("PokemonItem");
+}
+
+PokeGen::PokeMod::PokemonItem::~PokemonItem()
+{
+ LogDtor("PokemonItem", id, GetItemString());
+}
+
+void PokeGen::PokeMod::PokemonItem::Validate()
+{
+ isValid = true;
+ LogValidateStart("PokemonItem Validation: Starting", PM_DEBUG_INFO);
+ if (!curPokeMod.GetItem(item))
+ {
+ LogVarNotValid("PokemonItem", id, "item");
+ isValid = false;
+ }
+ if (!weight)
+ {
+ LogVarNotSet("PokemonItem", id, "weight", GetItemString());
+ isValid = false;
+ }
+ LogValidateOver("PokemonItem", id, isValid, GetItemString());
+}
+
+#ifdef PG_DEBUG_WINDOW
+void PokeGen::PokeMod::PokemonItem::Validate(wxListBox &output)
+{
+ isValid = true;
+ LogValidateStart("PokemonItem Validation: Starting", PM_DEBUG_INFO);
+ if (!curPokeMod.GetItem(item))
+ {
+ LogVarNotValid("PokemonItem", id, "item");
+ output.Append(ConsoleLogVarNotValid("PokemonItem", id, "item"));
+ isValid = false;
+ }
+ if (!weight)
+ {
+ LogVarNotSet("PokemonItem", id, weight, GetItemString());
+ output.Append(ConsoleLogVarNotSet("PokemonItem", id, weight, GetItemString());
+ isValid = false;
+ }
+ LogValidateOver("PokemonItem", id, isValid, GetItemString());
+}
+#endif
+
+void PokeGen::PokeMod::PokemonItem::ImportIni(Ini &ini, unsigned _id)
+{
+ LogImportStart("PokemonItem");
+ if (_id == UINT_MAX)
+ {
+ ini.GetValue("id", id, UINT_MAX);
+ // Was there an id associated with the element?
+ if (id == UINT_MAX)
+ LogIdNotFound("PokemonItem");
+ }
+ else
+ id = _id;
+ ini.GetValue("item", item, -1);
+ ini.GetValue("weight", weight, 1);
+ LogImportOver("PokemonItem", id);
+}
+
+void PokeGen::PokeMod::PokemonItem::ExportIni(std::ofstream &fout) const
+{
+ LogExportStart("PokemonItem", id);
+ // Make elements
+ Ini exPokemonItem("pokemonItem");
+ exPokemonItem.AddField("id", id);
+ exPokemonItem.AddField("item", item);
+ exPokemonItem.AddField("weight", weight);
+ exPokemonItem.Export(fout);
+ LogExportOver("PokemonItem", id);
+}
+
+void PokeGen::PokeMod::PokemonItem::SetItem(int i)
+{
+ if (curPokeMod.GetItem(i))
+ {
+ LogSetVar("PokemonItem", id, "item", curPokeMod.GetItem(i)->GetName());
+ item = i;
+ }
+ else
+ LogOutOfRange("PokemonItem", id, "item", i, "");
+}
+
+void PokeGen::PokeMod::PokemonItem::SetItem(const String &i)
+{
+ if (Item *itemId = curPokeMod.GetItem(i))
+ {
+ LogSetVar("PokemonItem", id, "item", itemId->GetName());
+ item = itemId->GetId();
+ }
+ else
+ LogOutOfRange("PokemonItem", id, "item", UINT_MAX, "");
+}
+
+void PokeGen::PokeMod::PokemonItem::SetWeight(unsigned w)
+{
+ if (w)
+ {
+ LogSetVar("PokemonItem", id, "weight", w);
+ weight = w;
+ }
+ else
+ LogOutOfRange("PokemonItem", id, "weight", w, "");
+}
+
+int PokeGen::PokeMod::PokemonItem::GetItem() const
+{
+ LogFetchVar("PokemonItem", id, "item", item, GetItemString());
+ return item;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::PokemonItem::GetItemString() const
+{
+ LogFetchVar("PokemonItem", id, "item", GetItemString());
+ return curPokeMod.GetItem(item)->GetName();
+}
+
+unsigned PokeGen::PokeMod::PokemonItem::GetWeight() const
+{
+ LogFetchVar("PokemonItem", id, "weight", weight, GetItemString());
+ return weight;
+}
|
