summaryrefslogtreecommitdiffstats
path: root/pokemod/CoinItem.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2007-05-23 02:24:14 +0000
committerBen Boeckel <MathStuf@gmail.com>2007-05-23 02:24:14 +0000
commit1a4b623c8ecb9d0c7d991312c12d78be4a68eff2 (patch)
tree97e260380c334f8f55ac6d82f174ce8604d7dd6c /pokemod/CoinItem.cpp
parente858d98977a09b3c8faf4df87ada4abc1399e8e5 (diff)
downloadsigen-1a4b623c8ecb9d0c7d991312c12d78be4a68eff2.tar.gz
sigen-1a4b623c8ecb9d0c7d991312c12d78be4a68eff2.tar.xz
sigen-1a4b623c8ecb9d0c7d991312c12d78be4a68eff2.zip
Added more PokéMod modules
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@13 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/CoinItem.cpp')
-rw-r--r--pokemod/CoinItem.cpp227
1 files changed, 227 insertions, 0 deletions
diff --git a/pokemod/CoinItem.cpp b/pokemod/CoinItem.cpp
new file mode 100644
index 00000000..d1b26125
--- /dev/null
+++ b/pokemod/CoinItem.cpp
@@ -0,0 +1,227 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokemod/CoinItem.cpp
+// Purpose: Define an object that can be bought with gambling winnings
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Wed Feb 28 21:21:23 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 "CoinItem.h"
+
+extern PokeGen::PokeMod::Pokemod curPokeMod;
+
+PokeGen::PokeMod::CoinItem::CoinItem(unsigned _id)
+{
+ LogCtor("CoinItem", _id);
+ type = 0;
+ object = -1;
+ amount = 1;
+ cost = 0;
+ id = _id;
+}
+
+PokeGen::PokeMod::CoinItem::CoinItem(Ini &ini, unsigned _id)
+{
+ LogCtorIni("CoinItem", _id);
+ ImportIni(ini);
+ if (id == UINT_MAX)
+ LogIdError("CoinItem");
+}
+
+PokeGen::PokeMod::CoinItem::~CoinItem()
+{
+ LogDtor("CoinItem", id);
+}
+
+void PokeGen::PokeMod::CoinItem::Validate()
+{
+ isValid = true;
+ LogValidateStart("CoinItem", id);
+ if (type == CIT_ITEM)
+ {
+ if (!curPokeMod.GetItem(object))
+ {
+ LogVarNotValid("CoinItem", id, "item", object);
+ isValid = false;
+ }
+ }
+ else if (type == CIT_POKEMON)
+ {
+ if (!curPokeMod.GetPokemon(object))
+ {
+ LogVarNotValid("CoinItem", id, "Pokémon", object);
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogVarNotValid("CoinItem", id, "type", type);
+ isValid = false;
+ }
+ if (!amount)
+ {
+ LogVarNotValid("CoinItem", id, "amount", amount, GetObjectString());
+ isValid = false;
+ }
+ LogValidateOver("CoinItem", id, isValid, GetObjectString());
+}
+
+#ifdef PG_DEBUG_WINDOW
+void PokeGen::PokeMod::CoinItem::Validate(const wxListBox &output)
+{
+ isValid = true;
+ LogValidateStart("CoinItem", id);
+ if (type == CIT_ITEM)
+ {
+ if (!curPokeMod.GetItem(object))
+ {
+ LogVarNotValid("CoinItem", id, "item", object);
+ output.Append(ConsoleLogVarNotValid("CoinItem", id, "item", object));
+ isValid = false;
+ }
+ }
+ else if (type == CIT_POKEMON)
+ {
+ if (!curPokeMod.GetPokemon(object))
+ {
+ LogVarNotValid("CoinItem", id, "Pokémon", object);
+ output.Append(ConsoleLogVarNotValid("CoinItem", id, "Pokémon", object));
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogVarNotValid("CoinItem", id, "type", type);
+ output.Append(ConsoleLogVarNotValid("CoinItem", id, "type", type));
+ isValid = false;
+ }
+ if (!amount)
+ {
+ LogVarNotValid("CoinItem", id, "amount", amount, GetObjectString());
+ output.Append(ConsoleLogVarNotValid("CoinItem", id, "amount", amount, GetObjectString()));
+ isValid = false;
+ }
+ LogValidateOver("CoinItem", id, isValid, GetObjectString());
+}
+#endif
+
+void PokeGen::PokeMod::CoinItem::ImportIni(Ini &ini, unsigned _id)
+{
+ LogImportStart("CoinItem");
+ if (_id == UINT_MAX)
+ {
+ ini.GetValue("id", id, UINT_MAX);
+ // Was there an id associated with the element?
+ if (id == UINT_MAX)
+ LogIdNotFound("CoinItem");
+ }
+ else
+ id = _id;
+ ini.GetValue("type", type, CIT_ITEM);
+ ini.GetValue("object", object, -1);
+ ini.GetValue("amount", amount, 1);
+ ini.GetValue("cost", cost, 0);
+ LogImportOver("CoinItem", id);
+}
+
+void PokeGen::PokeMod::CoinItem::ExportIni(std::ofstream &fout, const String &coinList) const
+{
+ LogExportStart("CoinItem", id, name);
+ // Make elements
+ Ini exCoinItem(coinList + " CoinItem");
+ exCoinItem.AddField("id", id);
+ exCoinItem.AddField("type",type);
+ exCoinItem.AddField("object", object);
+ exCoinItem.AddField("amount", amount);
+ exCoinItem.AddField("cost", cost);
+ exCoinItem.Export(fout);
+ LogExportOver("CoinItem", id, name);
+}
+
+void PokeGen::PokeMod::CoinItem::SetType(unsigned t)
+{
+ LogSetVar("CoinItem", id, "type", t);
+ if (t < CIT_END)
+ {
+ type = t;
+ object = -1;
+ }
+}
+
+void PokeGen::PokeMod::CoinItem::SetObject(int o)
+{
+ LogSetVar("CoinItem", id, "object", o);
+ if (((type == CIT_ITEM) && curPokeMod.GetItem(o)) || ((type == CIT_POKEMON) && curPokeMod.GetPokemon(o)))
+ object = o;
+}
+
+void PokeGen::PokeMod::CoinItem::SetObject(const String &o)
+{
+ LogSetVar("CoinItem", id, "object string", o);
+ if ((type == CIT_ITEM) && (Item *i = curPokeMod.GetItem(o)))
+ object = i->GetId();
+ else if ((type == CIT_POKEMON) && (Pokemon *p = curPokeMod.GetPokemon(o)))
+ object = p->GetId();
+}
+
+void PokeGen::PokeMod::CoinItem::SetAmount(unsigned a)
+{
+ LogSetVar("CoinItem", id, "amount", a);
+ if (a)
+ amount = a;
+}
+
+void PokeGen::PokeMod::CoinItem::SetCost(unsigned c)
+{
+ LogSetVar("CoinItem", id, "cost", c);
+ cost = c;
+}
+
+unsigned PokeGen::PokeMod::CoinItem::GetType() const
+{
+ LogFetchVar("CoinItem", id, "type", type);
+ return type;
+}
+
+int PokeGen::PokeMod::CoinItem::GetObject() const
+{
+ LogFetchVar("CoinItem", id, "object", object);
+ return object;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::CoinItem::GetObjectString() const
+{
+ LogFetchVar("CoinItem", id, "object string", object);
+ if ((type == CIT_ITEM) && (Item *i = curPokeMod.GetItem(object)))
+ return i->GetName();
+ else if ((type == CIT_POKEMON) && (Pokemon *p = curPokeMod.GetPokemon(object)))
+ return p->GetName();
+ return "";
+}
+
+unsigned PokeGen::PokeMod::CoinItem::GetAmount() const
+{
+ LogFetchVar("CoinItem", id, "amount", amount);
+ return amount;
+}
+
+unsigned PokeGen::PokeMod::CoinItem::GetCost() const
+{
+ LogFetchVar("CoinItem", id, "cost", cost);
+ return cost;
+}