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 | |
| 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
| -rw-r--r-- | Changelog | 9 | ||||
| -rw-r--r-- | pokegen.cbp | 30 | ||||
| -rw-r--r-- | pokegen.layout | 44 | ||||
| -rw-r--r-- | pokemod/PokemonItem.cpp | 165 | ||||
| -rw-r--r-- | pokemod/PokemonItem.h | 64 | ||||
| -rw-r--r-- | pokemod/Store.cpp | 207 | ||||
| -rw-r--r-- | pokemod/Store.h | 70 | ||||
| -rw-r--r-- | pokemod/Time.cpp | 164 | ||||
| -rw-r--r-- | pokemod/Time.h | 64 | ||||
| -rw-r--r-- | pokemod/Type.h | 4 |
10 files changed, 806 insertions, 15 deletions
@@ -1,4 +1,13 @@ -----------------
+Rev: 11
+Date: 21 May 2007
+User: MathStuf
+-----------------
+[ADD] /pokemod/Time.{h, cpp}
+[ADD] /pokemod/Store.{h, cpp}
+[ADD] /pokemod/PokemonItem.{h, cpp}
+
+-----------------
Rev: 10
Date: 20 May 2007
User: MathStuf
diff --git a/pokegen.cbp b/pokegen.cbp index 2a0f18a9..2d99b4a1 100644 --- a/pokegen.cbp +++ b/pokegen.cbp @@ -168,18 +168,48 @@ <Unit filename="pokemod\Point.h"> <Option target="pokemod-DLL" /> </Unit> + <Unit filename="pokemod\PokemonItem.cpp"> + <Option target="pokemodr" /> + <Option target="pokegen" /> + <Option target="pokemod-DLL" /> + </Unit> + <Unit filename="pokemod\PokemonItem.h"> + <Option target="pokemodr" /> + <Option target="pokegen" /> + <Option target="pokemod-DLL" /> + </Unit> <Unit filename="pokemod\Ref.cpp"> <Option target="pokemod-DLL" /> </Unit> <Unit filename="pokemod\Ref.h"> <Option target="pokemod-DLL" /> </Unit> + <Unit filename="pokemod\Store.cpp"> + <Option target="pokemodr" /> + <Option target="pokegen" /> + <Option target="pokemod-DLL" /> + </Unit> + <Unit filename="pokemod\Store.h"> + <Option target="pokemodr" /> + <Option target="pokegen" /> + <Option target="pokemod-DLL" /> + </Unit> <Unit filename="pokemod\String.cpp"> <Option target="pokemod-DLL" /> </Unit> <Unit filename="pokemod\String.h"> <Option target="pokemod-DLL" /> </Unit> + <Unit filename="pokemod\Time.cpp"> + <Option target="pokemodr" /> + <Option target="pokegen" /> + <Option target="pokemod-DLL" /> + </Unit> + <Unit filename="pokemod\Time.h"> + <Option target="pokemodr" /> + <Option target="pokegen" /> + <Option target="pokemod-DLL" /> + </Unit> <Unit filename="pokemod\Type.cpp"> <Option target="pokemodr" /> <Option target="pokegen" /> diff --git a/pokegen.layout b/pokegen.layout index feb1d88f..74587e8c 100644 --- a/pokegen.layout +++ b/pokegen.layout @@ -1,8 +1,8 @@ <?xml version="1.0" encoding="UTF-8" standalone="yes" ?> <CodeBlocks_layout_file> <ActiveTarget name="pokemodr" /> - <File name="Changelog" open="1" top="0" tabpos="1"> - <Cursor position="268" topLine="0" /> + <File name="Changelog" open="1" top="1" tabpos="1"> + <Cursor position="993" topLine="21" /> </File> <File name="STANDARDS" open="0" top="0" tabpos="0"> <Cursor position="2" topLine="0" /> @@ -26,10 +26,10 @@ <Cursor position="1408" topLine="0" /> </File> <File name="pokemod\Ability.cpp" open="0" top="0" tabpos="5"> - <Cursor position="4465" topLine="117" /> + <Cursor position="4232" topLine="166" /> </File> <File name="pokemod\Ability.h" open="0" top="0" tabpos="2"> - <Cursor position="2326" topLine="36" /> + <Cursor position="2198" topLine="36" /> </File> <File name="pokemod\AbilityEffect.cpp" open="0" top="0" tabpos="2"> <Cursor position="6719" topLine="198" /> @@ -53,7 +53,7 @@ <Cursor position="1310" topLine="16" /> </File> <File name="pokemod\Debug.h" open="0" top="0" tabpos="4"> - <Cursor position="12523" topLine="231" /> + <Cursor position="9129" topLine="195" /> </File> <File name="pokemod\Flag.cpp" open="0" top="0" tabpos="8"> <Cursor position="2832" topLine="54" /> @@ -67,11 +67,11 @@ <File name="pokemod\Frac.h" open="0" top="0" tabpos="11"> <Cursor position="1571" topLine="31" /> </File> - <File name="pokemod\Ini.cpp" open="1" top="1" tabpos="3"> - <Cursor position="1589" topLine="19" /> + <File name="pokemod\Ini.cpp" open="0" top="0" tabpos="3"> + <Cursor position="3247" topLine="85" /> </File> - <File name="pokemod\Ini.h" open="1" top="0" tabpos="12"> - <Cursor position="2601" topLine="41" /> + <File name="pokemod\Ini.h" open="0" top="0" tabpos="12"> + <Cursor position="2687" topLine="41" /> </File> <File name="pokemod\Matrix.h" open="0" top="0" tabpos="4"> <Cursor position="3839" topLine="117" /> @@ -100,29 +100,47 @@ <File name="pokemod\Point.h" open="0" top="0" tabpos="20"> <Cursor position="1594" topLine="32" /> </File> + <File name="pokemod\PokemonItem.cpp" open="0" top="0" tabpos="0"> + <Cursor position="4617" topLine="132" /> + </File> + <File name="pokemod\PokemonItem.h" open="0" top="0" tabpos="0"> + <Cursor position="1313" topLine="12" /> + </File> <File name="pokemod\Ref.cpp" open="0" top="0" tabpos="0"> <Cursor position="103" topLine="3" /> </File> <File name="pokemod\Ref.h" open="0" top="0" tabpos="0"> <Cursor position="103" topLine="3" /> </File> + <File name="pokemod\Store.cpp" open="0" top="0" tabpos="0"> + <Cursor position="5705" topLine="174" /> + </File> + <File name="pokemod\Store.h" open="0" top="0" tabpos="0"> + <Cursor position="1316" topLine="37" /> + </File> <File name="pokemod\String.cpp" open="0" top="0" tabpos="0"> <Cursor position="3983" topLine="100" /> </File> <File name="pokemod\String.h" open="0" top="0" tabpos="0"> <Cursor position="1715" topLine="26" /> </File> + <File name="pokemod\Time.cpp" open="0" top="0" tabpos="0"> + <Cursor position="3900" topLine="119" /> + </File> + <File name="pokemod\Time.h" open="0" top="0" tabpos="0"> + <Cursor position="1634" topLine="18" /> + </File> <File name="pokemod\Type.cpp" open="0" top="0" tabpos="0"> - <Cursor position="1897" topLine="32" /> + <Cursor position="1897" topLine="50" /> </File> <File name="pokemod\Type.h" open="0" top="0" tabpos="0"> - <Cursor position="1929" topLine="26" /> + <Cursor position="1431" topLine="26" /> </File> <File name="pokemod\pokemod_inc.h" open="0" top="0" tabpos="0"> - <Cursor position="103" topLine="0" /> + <Cursor position="1828" topLine="25" /> </File> <File name="pokemodr\PokeModr.cpp" open="0" top="0" tabpos="0"> - <Cursor position="103" topLine="0" /> + <Cursor position="1524" topLine="23" /> </File> <File name="pokemodr\PokeModrDebug.h" open="0" top="0" tabpos="0"> <Cursor position="202" topLine="0" /> 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;
+}
diff --git a/pokemod/PokemonItem.h b/pokemod/PokemonItem.h new file mode 100644 index 00000000..784f754b --- /dev/null +++ b/pokemod/PokemonItem.h @@ -0,0 +1,64 @@ +/////////////////////////////////////////////////////////////////////////////
+// Name: PokemonItem.h
+// 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.
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __POKEMOD_POKEMONITEM__
+#define __POKEMOD_POKEMONITEM__
+
+#include "Object.h"
+#include "String.h"
+#include "Pokemod.h"
+
+namespace PokeGen
+{
+ namespace PokeMod
+ {
+ class PokemonItem : public Object
+ {
+ public:
+ PokemonItem(unsigned _id);
+ PokemonItem(Ini &ini, unsigned _id = UINT_MAX);
+ ~PokemonItem();
+
+ void ImportIni(Ini &ini, unsigned _id = UINT_MAX);
+ void ExportIni(std::ofstream &fout) const;
+
+ void SetItem(int i);
+ void SetItem(const String &i);
+ void SetWeight(unsigned w);
+
+ int GetItem() const;
+ String GetItemString() const;
+ unsigned GetWeight() const;
+ private:
+ void Validate();
+# ifdef PG_DEBUG_WINDOW
+ void Validate(const wxListBox &output);
+# endif
+
+ int item;
+ unsigned weight;
+ };
+ }
+}
+
+#endif
diff --git a/pokemod/Store.cpp b/pokemod/Store.cpp new file mode 100644 index 00000000..acb40d0d --- /dev/null +++ b/pokemod/Store.cpp @@ -0,0 +1,207 @@ +/////////////////////////////////////////////////////////////////////////////
+// Name: Store.cpp
+// Purpose: Define a store that the player can shop at
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Tue Mar 20 18:31:50 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 "Store.h"
+
+extern PokeGen::PokeMod::PokeMod curPokeMod;
+
+PokeGen::PokeMod::Store::Store(unsigned _id)
+{
+ LogCtor("Store", _id);
+ name = "";
+ items.clear();
+ id = _id;
+}
+
+PokeGen::PokeMod::Store::Store(Ini &ini, unsigned _id)
+{
+ LogCtorIni("Store", _id);
+ ImportIni(ini);
+ if(_id == UINT_MAX)
+ LogIdError("Store");
+}
+
+PokeGen::PokeMod::Store::~Store()
+{
+ LogDtor("Store", id, name);
+}
+
+void PokeGen::PokeMod::Store::Validate()
+{
+ isValid = true;
+ LogValidateStart("Store", id, name);
+ if (name == "")
+ {
+ LogVarNotSet("Store", id, "name", name);
+ isValid = false;
+ }
+ for (unsigned i = 0; i < GetItemCount(); ++i)
+ {
+ if (!curPokeMod.GetItem(items[i]))
+ {
+ LogSubmoduleEmpty("Store", id, "item", name);
+ isValid = false;
+ }
+ }
+ LogValidateOver("Store", id, isValid, name);
+}
+
+#ifdef PG_DEBUG_WINDOW
+void PokeGen::PokeMod::Store::Validate(wxListBox &output)
+{
+ isValid = true;
+ LogValidateStart("Store", id, name);
+ if (name == "")
+ {
+ LogVarNotSet("Store", id, "name", name);
+ output.Append(ConsoleLogVarNotSet("Store", id, "name", name));
+ isValid = false;
+ }
+ for (unsigned i = 0; i < GetItemCount(); ++i)
+ {
+ if (!curPokeGen::PokeMod.GetItem(items[i]))
+ {
+ LogSubmoduleEmpty("Store", id, "item", name);
+ output.Append(ConsoleLogVarNotSet("Store", id, "item", name));
+ isValid = false;
+ }
+ }
+ LogValidateOver("Store", id, isValid, name);
+}
+#endif
+
+void PokeGen::PokeMod::Store::ImportIni(Ini &ini, unsigned _id)
+{
+ LogImportStart("Store");
+ if (_id == UINT_MAX)
+ {
+ ini.GetValue("id", id, UINT_MAX);
+ // Was there an id associated with the element?
+ if (id == UINT_MAX)
+ LogIdNotFound("Store");
+ }
+ else
+ id = _id;
+ items.clear();
+ unsigned i;
+ unsigned j;
+ ini.GetValue("name", name, "");
+ ini.GetValue("numItems", i, 0);
+ for (unsigned k = 0; k < i; ++k)
+ {
+ ini.GetValue(String("item-%u", k), j, UINT_MAX);
+ if (j != UINT_MAX)
+ items.push_back(j);
+ }
+ LogImportOver("Store", id, name);
+}
+
+void PokeGen::PokeMod::Store::ExportIni(std::ofstream &fout) const
+{
+ LogExportStart("Store", id, name);
+ // Make elements
+ Ini exStore("store");
+ exStore.AddField("id", id);
+ exStore.AddField("name", name);
+ exStore.AddField("numItems", items.size());
+ for (unsigned i = 0; i < items.size(); ++i)
+ exStore.AddField(String("items-%u", i), items[i]);
+ exStore.Export(fout);
+ LogExportOver("Store", id, name);
+}
+
+void PokeGen::PokeMod::Store::SetName(const String &n)
+{
+ LogSetVar("Store", id, "name", n, name);
+ name = n;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Store::GetName()
+{
+ LogFetchVar("Store", id, "name", name, name);
+ return name;
+}
+
+int PokeGen::PokeMod::Store::GetItem(unsigned i) const
+{
+ LogSubmoduleFetch("Store", id, "item", i, name);
+ if (GetItemCount() <= i)
+ {
+ LogSubmoduleFetchFail("Store", id, "item", i, name);
+ return -1;
+ }
+ return items[i];
+}
+
+bool PokeGen::PokeMod::Store::HasItem(unsigned _id) const
+{
+ LogSubmoduleFetch("Store", id, "item", _id, name);
+ return (GetItem(_id) != -1);
+}
+
+bool PokeGen::PokeMod::Store::HasItem(const String &n) const
+{
+ LogSubmoduleFetch("Store", id, "item", UINT_MAX, name);
+ for (unsigned i = 0; i < GetItemCount(); ++i)
+ {
+ if (curPokeMod.GetItem(items[i])->GetName() == n)
+ return true;
+ }
+ LogSubmoduleFetchFail("Store", id, "item", UINT_MAX, name);
+ return false;
+}
+
+unsigned PokeGen::PokeMod::Store::GetItemCount() const
+{
+ LogSubmoduleCount("Store", id, "item", name);
+ return items.size();
+}
+
+void PokeGen::PokeMod::Store::NewItem(unsigned i)
+{
+ LogSubmoduleNew("Store", id, "item", items.size());
+ items.push_back(i);
+}
+
+void PokeGen::PokeMod::Store::DeleteItem(unsigned i)
+{
+ LogSubmoduleRemoveStart("Store", id, "item", i, name);
+ if (GetItemCount() <= i)
+ LogSubmoduleRemoveFail("Store", id, "item", i, name);
+ else
+ DeleteItemByID(items[i]);
+}
+
+void PokeGen::PokeMod::Store::DeleteItemByID(unsigned _id)
+{
+ LogSubmoduleRemoveStart("Store", id, "item", _id, name);
+ for (std::vector<unsigned>::iterator i = items.begin(); i != items.end(); ++i)
+ {
+ if (*i == _id)
+ {
+ LogSubmoduleRemoved("Store", id, "item", _id, name);
+ items.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Store", id, "item", _id, name);
+}
diff --git a/pokemod/Store.h b/pokemod/Store.h new file mode 100644 index 00000000..7fee17db --- /dev/null +++ b/pokemod/Store.h @@ -0,0 +1,70 @@ +/////////////////////////////////////////////////////////////////////////////
+// Name: Store.h
+// Purpose: Define a store that the player can shop at
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Tue Mar 20 18:31:50 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.
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __POKEMOD_STORE__
+#define __POKEMOD_STORE__
+
+#include <vector>
+#include "Object.h"
+#include "String.h"
+#include "Pokemod.h"
+
+namespace PokeGen
+{
+ namespace PokeMod
+ {
+ class Store : public Object
+ {
+ public:
+ Store(unsigned _id);
+ Store(Ini &ini, unsigned _id = UINT_MAX);
+ ~Store();
+
+ void ImportIni(Ini &ini, unsigned _id = UINT_MAX);
+ void ExportIni(std::ofstream &fout) const;
+
+ void SetName(const String &n);
+
+ String GetName();
+
+ int GetItem(unsigned i) const;
+ bool HasItem(unsigned _id) const;
+ bool HasItem(const String &n) const;
+ unsigned GetItemCount() const;
+ void NewItem(unsigned i);
+ void DeleteItem(unsigned i);
+ void DeleteItemByID(unsigned i);
+ private:
+ void Validate();
+# ifdef PG_DEBUG_WINDOW
+ void Validate(const wxListBox &output);
+# endif
+
+ String name;
+
+ std::vector<unsigned> items;
+ };
+ }
+}
+
+#endif
diff --git a/pokemod/Time.cpp b/pokemod/Time.cpp new file mode 100644 index 00000000..d18d826f --- /dev/null +++ b/pokemod/Time.cpp @@ -0,0 +1,164 @@ +/////////////////////////////////////////////////////////////////////////////
+// Name: Time.cpp
+// Purpose: Define the start of a time of day in the PokéMod
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Wed Feb 28 21:00:46 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 "Time.h"
+
+PokeGen::PokeMod::Time::Time(unsigned _id)
+{
+ LogCtor("Time", id);
+ name = "";
+ startHour = 0;
+ startMinute = 0;
+ id = _id;
+}
+
+PokeGen::PokeMod::Time::Time(Ini &ini, unsigned _id)
+{
+ LogCtorIni("Time", _id);
+ ImportIni(ini, _id);
+ if(_id == UINT_MAX)
+ LogIdError("Time");
+}
+
+PokeGen::PokeMod::Time::~Time()
+{
+ LogDtor("Time", id, name);
+}
+
+void PokeGen::PokeMod::Time::Validate()
+{
+ isValid = true;
+ LogValidateStart("Time", id, name);
+ if (name == "")
+ {
+ LogVarNotSet("Time", id, "name", name);
+ isValid = false;
+ }
+ if (23 < startHour)
+ {
+ LogVarNotValid("Time", id, "startHour", name);
+ isValid = false;
+ }
+ if (59 < startMinute)
+ {
+ LogVarNotValid("Time", id, "startMinute", name);
+ isValid = false;
+ }
+ LogValidateOver("Time", id, isValid, name);
+}
+
+#ifdef PG_DEBUG_WINDOW
+void PokeGen::PokeMod::Time::Validate(const wxListBox &output)
+{
+ isValid = true;
+ LogValidateStart("Time", id, name);
+ if (name == "")
+ {
+ LogVarNotSet("Time", id, "name", name);
+ output.Append(ConsoleLogVarNotSet("Time", id, "name", name));
+ isValid = false;
+ }
+ if (23 < startHour)
+ {
+ LogVarNotValid("Time", id, "startHour", name);
+ output.Append(ConsoleLogVarNotValid("Time", id, "startHour", name));
+ isValid = false;
+ }
+ if (59 < startMinute)
+ {
+ LogVarNotValid("Time", id, "startMinute", name);
+ output.Append(ConsoleLogVarNotValid("Time", id, "startMinute", name));
+ isValid = false;
+ }
+ LogValidateOver("Time", id, isValid, name);
+}
+#endif
+
+void PokeGen::PokeMod::Time::ImportIni(Ini &ini, unsigned _id)
+{
+ LogImportStart("Time");
+ if (_id == UINT_MAX)
+ {
+ ini.GetValue("id", id, UINT_MAX);
+ // Was there an id associated with the element?
+ if (id == UINT_MAX)
+ LogIdNotFound("Time");
+ }
+ else
+ id = _id;
+ ini.GetValue("name", name, "");
+ ini.GetValue("startHour", startHour, 0);
+ ini.GetValue("startMinute", startMinute, 0);
+ LogImportOver("Time", id, name);
+}
+
+void PokeGen::PokeMod::Time::ExportIni(std::ofstream &fout) const
+{
+ LogExportStart("Time", id, name);
+ // Make elements
+ Ini exTime("time");
+ exTime.AddField("id", id);
+ exTime.AddField("name", name);
+ exTime.AddField("startHour", startHour);
+ exTime.AddField("startMinute", startMinute);
+ exTime.Export(fout);
+ LogExportOver("Time", id, name);
+}
+
+void PokeGen::PokeMod::Time::SetName(const String &n)
+{
+ LogSetVar("Time", id, "name", n, name);
+ name = n;
+}
+
+void PokeGen::PokeMod::Time::SetStartHour(unsigned h)
+{
+ LogSetVar("Time", id, "startHour", h, name);
+ if (h < 24)
+ startHour = h;
+}
+
+void PokeGen::PokeMod::Time::SetStartMinute(unsigned m)
+{
+ LogSetVar("Time", id, "startMinute", m, name);
+ if (m < 60)
+ startMinute = m;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Time::GetName() const
+{
+ LogFetchVar("Time", id, "name", name, name);
+ return name;
+}
+
+unsigned PokeGen::PokeMod::Time::GetStartHour() const
+{
+ LogFetchVar("Time", id, "startHour", startHour, name);
+ return startHour;
+}
+
+unsigned PokeGen::PokeMod::Time::GetStartMinute() const
+{
+ LogFetchVar("Time", id, "startMinute", startMinute, name);
+ return startMinute;
+}
diff --git a/pokemod/Time.h b/pokemod/Time.h new file mode 100644 index 00000000..3bbd2394 --- /dev/null +++ b/pokemod/Time.h @@ -0,0 +1,64 @@ +/////////////////////////////////////////////////////////////////////////////
+// Name: Time.h
+// Purpose: Define the start of a time of day in the PokéMod
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Wed Feb 28 21:00:46 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.
+/////////////////////////////////////////////////////////////////////////////
+
+#ifndef __POKEMOD_TIME__
+#define __POKEMOD_TIME__
+
+#include "Object.h"
+#include "String.h"
+
+namespace PokeGen
+{
+ namespace PokeMod
+ {
+ class Time : public Object
+ {
+ public:
+ Time(unsigned _id);
+ Time(Ini &ini, unsigned _id = UINT_MAX);
+ ~Time();
+
+ void ImportIni(Ini &ini, unsigned _id = UINT_MAX);
+ void ExportIni(std::ofstream &fout) const;
+
+ void SetName(const String &n);
+ void SetStartHour(unsigned h);
+ void SetStartMinute(unsigned m);
+
+ String GetName() const;
+ unsigned GetStartHour() const;
+ unsigned GetStartMinute() const;
+ private:
+ void Validate();
+# ifdef PG_DEBUG_WINDOW
+ void Validate(const wxListBox &output);
+# endif
+
+ String name;
+ unsigned startHour;
+ unsigned startMinute;
+ };
+ }
+}
+
+#endif
diff --git a/pokemod/Type.h b/pokemod/Type.h index c41d5884..06564cd8 100644 --- a/pokemod/Type.h +++ b/pokemod/Type.h @@ -35,10 +35,10 @@ namespace PokeGen {
public:
Type(unsigned _id);
- Type(Ini &xml, unsigned _id = UINT_MAX);
+ Type(Ini &ini, unsigned _id = UINT_MAX);
~Type();
- void ImportIni(Ini &xml, unsigned _id = UINT_MAX);
+ void ImportIni(Ini &ini, unsigned _id = UINT_MAX);
void ExportIni(std::ofstream &fout) const;
void SetName(const String &n);
|
