diff options
| author | Ben Boeckel <MathStuf@gmail.com> | 2007-05-22 03:51:45 +0000 |
|---|---|---|
| committer | Ben Boeckel <MathStuf@gmail.com> | 2007-05-22 03:51:45 +0000 |
| commit | e858d98977a09b3c8faf4df87ada4abc1399e8e5 (patch) | |
| tree | fbe406e42296b784cf03ae65cb9cbccb97aa7fa8 /pokemod/CoinList.cpp | |
| parent | 0fec318eac634e5465c30eb73d47ec82aaed9db8 (diff) | |
| download | sigen-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/CoinList.cpp')
| -rw-r--r-- | pokemod/CoinList.cpp | 208 |
1 files changed, 208 insertions, 0 deletions
diff --git a/pokemod/CoinList.cpp b/pokemod/CoinList.cpp new file mode 100644 index 00000000..83748355 --- /dev/null +++ b/pokemod/CoinList.cpp @@ -0,0 +1,208 @@ +/////////////////////////////////////////////////////////////////////////////
+// Name: pokemod/CoinList.cpp
+// Purpose: A specialty store where Pokémon and items can be gotten for
+// coins won through gambling
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Wed Feb 28 21:16: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 "CoinList.h"
+
+extern PokeGen::PokeMod::Pokemod curPokeMod;
+
+PokeGen::PokeMod::CoinList::CoinList(unsigned _id)
+{
+ LogCtor("CoinList", _id);
+ name = "";
+ value = 0;
+ items.clear();
+ id = _id;
+}
+
+PokeGen::PokeMod::CoinList::CoinList(Ini &ini, unsigned _id)
+{
+ LogCtorIni("CoinList", _id);
+ ImportIni(ini);
+ if(_id == UINT_MAX)
+ LogIdError("CoinList");
+}
+
+PokeGen::PokeMod::CoinList::~CoinList()
+{
+ LogDtor("CoinList", id, name);
+}
+
+void PokeGen::PokeMod::CoinList::Validate()
+{
+ isValid = true;
+ LogValidateStart("CoinList", id, name);
+ if (name == "")
+ {
+ LogVarEmpty("CoinList", id, "name", name);
+ isValid = false;
+ }
+ if (GetCoinItemCount())
+ {
+ for (unsigned i = 0; i < GetCoinItemCount(); ++i)
+ {
+ LogSubmoduleIterate("CoinList", id, "item", i, name);
+ if (!items[i].IsValid())
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogSubmoduleEmpty("CoinList", id, "items", name);
+ isValid = false;
+ }
+ LogValidateOver("CoinList", id, isValid, name);
+}
+
+#ifdef PG_DEBUG_WINDOW
+void PokeGen::PokeMod::CoinList::Validate(const wxListBox &output)
+{
+ isValid = true;
+ LogValidateStart("CoinList", id, name);
+ if (name == "")
+ {
+ LogVarEmpty("CoinList", id, "name", name);
+ output.Append(ConsoleLogVarEmpty("CoinList", id, "name", name));
+ isValid = false;
+ }
+ if (GetCoinItemCount())
+ {
+ for (unsigned i = 0; i < GetCoinItemCount(); ++i)
+ {
+ LogSubmoduleIterate("CoinList", id, "item", i, name);
+ if (!items[i].IsValid())
+ isValid = false;
+ }
+ }
+ else
+ {
+ LogSubmoduleEmpty("CoinList", id, "items", name);
+ output.Append(ConsoleLogSubmoduleEmpty("CoinList", id, "items", name));
+ isValid = false;
+ }
+ LogValidateOver("CoinList", id, isValid, name);
+}
+#endif
+
+void PokeGen::PokeMod::CoinList::ImportIni(Ini &ini, unsigned _id)
+{
+ LogImportStart("CoinList");
+ if (_id == UINT_MAX)
+ {
+ ini.GetValue("id", id, UINT_MAX);
+ // Was there an id associated with the element?
+ if (id == UINT_MAX)
+ LogIdNotFound("CoinList");
+ }
+ else
+ id = _id;
+ ini.GetValue("name", name, "");
+ ini.GetValue("value", value, 0);
+ LogImportOver("CoinList", id, name);
+}
+
+void PokeGen::PokeMod::CoinList::ExportIni(std::ofstream &fout) const
+{
+ LogExportStart("CoinList", id, name);
+ // Make elements
+ Ini exCoinList("coinList");
+ exCoinList.AddField("id", id);
+ exCoinList.AddField("name", name);
+ exCoinList.AddField("value", value);
+ exCoinList.Export(fout);
+ for (std::vector<CoinItem>::iterator i = effects.begin(); i != effects.end(); ++i)
+ i->ExportIni(fout, name);
+ LogExportOver("CoinList", id, name);
+}
+
+void PokeGen::PokeMod::CoinList::SetName(const String &n)
+{
+ LogSetVar("CoinList", id, "name", n, name);
+ name = n;
+}
+
+void PokeGen::PokeMod::CoinList::SetValue(unsigned v)
+{
+ LogSetVar("CoinList", id, "value", value, name);
+ value = v;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::CoinList::GetName() const
+{
+ LogFetchVar("CoinList", id, "name", name, name);
+ return name;
+}
+
+unsigned PokeGen::PokeMod::CoinList::GetValue() const
+{
+ LogFetchVar("CoinList", id, "value", value, name);
+ return value;
+}
+
+PokeGen::PokeMod::CoinItem *PokeGen::PokeMod::CoinList::GetCoinItem(unsigned _id)
+{
+ LogSubmoduleFetch("CoinList", id, "item", _id, name);
+ for (unsigned i = 0; i < GetAbilityEffectCount(); ++i)
+ {
+ if (items[i].GetId() == _id)
+ return &items[i];
+ }
+ LogSubmoduleFetch("CoinList", id, "item", _id, name);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::CoinList::GetCoinItemCount() const
+{
+ LogSubmoduleCount("CoinList", id, "items", name);
+ return items.size();
+}
+
+void PokeGen::PokeMod::CoinList::NewCoinItem(Ini *const ini)
+{
+ unsigned i = 0;
+ // Find the first unused ID in the vector
+ for (; i < GetCoinItemCount(); ++i)
+ {
+ if (!GetCoinItem(i))
+ break;
+ }
+ CoinItem newCoinItem(i);
+ if (ini)
+ newCoinItem.ImportIni(*ini);
+ LogSubmoduleNew("CoinList", id, "item", i, name);
+ items.push_back(newCoinItem);
+}
+
+void PokeGen::PokeMod::CoinList::DeleteCoinItem(unsigned _id)
+{
+ LogSubmoduleRemoveStart("CoinList", id, "item", _id, name);
+ for (std::vector<AbilityEffect>::iterator i = items.begin(); i != items.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("CoinList", id, "item", _id, name);
+ effects.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("CoinList", id, "item", _id, name);
+}
|
