summaryrefslogtreecommitdiffstats
path: root/pokemod/CoinListObject.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/CoinListObject.cpp')
-rw-r--r--pokemod/CoinListObject.cpp142
1 files changed, 142 insertions, 0 deletions
diff --git a/pokemod/CoinListObject.cpp b/pokemod/CoinListObject.cpp
new file mode 100644
index 00000000..1a59c40a
--- /dev/null
+++ b/pokemod/CoinListObject.cpp
@@ -0,0 +1,142 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokemod/CoinListObject.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 3 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, see <http://www.gnu.org/licenses/>.
+/////////////////////////////////////////////////////////////////////////////
+
+#include "CoinListObject.h"
+
+PokeGen::PokeMod::CoinListObject::CoinListObject(const Pokemod* par, const unsigned _id) :
+ Object(_id, par),
+ type(Item),
+ object(UINT_MAX),
+ amount(1),
+ cost(0)
+{
+}
+
+PokeGen::PokeMod::CoinListObject::CoinListObject(const Pokemod* par, Ini& ini, const unsigned _id) :
+ Object(_id, par)
+{
+ ImportIni(ini, _id);
+}
+
+bool PokeGen::PokeMod::CoinListObject::Validate()
+{
+ pokemod->ValidationMsg(QString("------Object with id %1---").arg(id), Pokemod::V_Msg);
+ if (type == Item)
+ {
+ if (pokemod->GetItemByID(object) == UINT_MAX)
+ {
+ pokemod->ValidationMsg("Invalid item");
+ isValid = false;
+ }
+ }
+ else if (type == Pokemon)
+ {
+ if (pokemod->GetPokemonByID(object) == UINT_MAX)
+ {
+ pokemod->ValidationMsg("Invalid Pokémon");
+ isValid = false;
+ }
+ }
+ else
+ {
+ pokemod->ValidationMsg("Invalid type");
+ isValid = false;
+ }
+ if (!amount || ((1 < amount) && (type == Pokemon)))
+ {
+ pokemod->ValidationMsg("Invalid amount");
+ isValid = false;
+ }
+ return isValid;
+}
+
+void PokeGen::PokeMod::CoinListObject::ImportIni(Ini& ini, const unsigned _id)
+{
+ if (_id == UINT_MAX)
+ ini.GetValue("id", id);
+ else
+ id = _id;
+ ini.GetValue("type", type, Item);
+ ini.GetValue("object", object);
+ ini.GetValue("amount", amount, 1);
+ ini.GetValue("cost", cost, 0);
+}
+
+void PokeGen::PokeMod::CoinListObject::ExportIni(QFile& fout, const QString& coinList) const
+{
+ Ini exCoinListObject("CoinListObject " + coinList);
+ exCoinListObject.AddField("id", id);
+ exCoinListObject.AddField("type", type);
+ exCoinListObject.AddField("object", object);
+ exCoinListObject.AddField("amount", amount);
+ exCoinListObject.AddField("cost", cost);
+ exCoinListObject.Export(fout);
+}
+
+bool PokeGen::PokeMod::CoinListObject::SetType(const unsigned t)
+{
+ if (t < End)
+ {
+ type = t;
+ object = UINT_MAX;
+ }
+ return (type == t);
+}
+
+bool PokeGen::PokeMod::CoinListObject::SetObject(const unsigned o)
+{
+ if (((type == Item) && (pokemod->GetItemByID(o) != UINT_MAX)) || ((type == Pokemon) && (pokemod->GetPokemonByID(o) != UINT_MAX)))
+ object = o;
+ return (object == o);
+}
+
+bool PokeGen::PokeMod::CoinListObject::SetAmount(const unsigned a)
+{
+ if (a)
+ amount = a;
+ return (amount == a);
+}
+
+void PokeGen::PokeMod::CoinListObject::SetCost(const unsigned c)
+{
+ cost = c;
+}
+
+unsigned PokeGen::PokeMod::CoinListObject::GetType() const
+{
+ return type;
+}
+
+unsigned PokeGen::PokeMod::CoinListObject::GetObject() const
+{
+ return object;
+}
+
+unsigned PokeGen::PokeMod::CoinListObject::GetAmount() const
+{
+ return amount;
+}
+
+unsigned PokeGen::PokeMod::CoinListObject::GetCost() const
+{
+ return cost;
+}