summaryrefslogtreecommitdiffstats
path: root/pokemod/MoveEffect.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2007-05-25 00:15:36 +0000
committerBen Boeckel <MathStuf@gmail.com>2007-05-25 00:15:36 +0000
commit75b7d5c767428f7061365a186cb17a22de4112cc (patch)
tree46db9c129f3fa848a6ea084a31e01f2c59e67b2a /pokemod/MoveEffect.cpp
parent1a4b623c8ecb9d0c7d991312c12d78be4a68eff2 (diff)
downloadsigen-75b7d5c767428f7061365a186cb17a22de4112cc.tar.gz
sigen-75b7d5c767428f7061365a186cb17a22de4112cc.tar.xz
sigen-75b7d5c767428f7061365a186cb17a22de4112cc.zip
More modules PokéMod added
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@14 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/MoveEffect.cpp')
-rw-r--r--pokemod/MoveEffect.cpp205
1 files changed, 205 insertions, 0 deletions
diff --git a/pokemod/MoveEffect.cpp b/pokemod/MoveEffect.cpp
new file mode 100644
index 00000000..8558c44a
--- /dev/null
+++ b/pokemod/MoveEffect.cpp
@@ -0,0 +1,205 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokemod/MoveEffect.cpp
+// Purpose: Define an effect of a move
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Tue Mar 20 18:29:40 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 "MoveEffect.h"
+
+extern PokeGen::PokeMod::Pokemod curPokeMod;
+
+PokeGen::PokeMod::MoveEffect::MoveEffect(unsigned _id)
+{
+ LogCtor("MoveEffect", _id);
+ chance.Set(1, 1);
+ effect = -1;
+ val1 = -1;
+ val2 = -1;
+ id = _id;
+}
+
+PokeGen::PokeMod::MoveEffect::MoveEffect(Ini &ini, unsigned _id)
+{
+ LogCtorIni("MoveEffect", _id);
+ ImportIni(ini, _id);
+ if (id == UINT_MAX)
+ LogIdError("MoveEffect");
+}
+
+PokeGen::PokeMod::MoveEffect::~MoveEffect()
+{
+ LogDtor("MoveEffect", id);
+}
+
+#ifdef PG_DEBUG_WINDOW
+void PokeGen::PokeMod::MoveEffect::Validate(const wxListBox &output)
+#else
+void PokeGen::PokeMod::MoveEffect::Validate()
+#endif
+{
+ isValid = true;
+ LogValidateStart("MoveEffect", id);
+ // TODO (Validation#1#): MoveEffect Validation
+ LogValidateOver("MoveEffect", id, isValid);
+}
+
+void PokeGen::PokeMod::MoveEffect::ImportIni(Ini &ini, unsigned _id)
+{
+ LogImportStart("MoveEffect");
+ if (_id == UINT_MAX)
+ {
+ ini.GetValue("id", id, UINT_MAX);
+ // Was there an id associated with the element?
+ if (id == UINT_MAX)
+ LogIdNotFound("MoveEffect");
+ }
+ else
+ id = _id;
+ unsigned i;
+ unsigned j;
+ ini.GetValue("chance-n", i, 1);
+ ini.GetValue("chance-d", j, 1);
+ chance.Set(i, j);
+ ini.GetValue("effect", effect, -1);
+ ini.GetValue("val1", val1, -1);
+ ini.GetValue("val2", val2, -1);
+}
+
+void PokeGen::PokeMod::MoveEffect::ExportIni(std::ofstream &fout, const String &move) const
+{
+ LogExportStart("MoveEffect", id, name);
+ // Make elements
+ Ini exMoveEffect(move + " moveEffect");
+ exMoveEffect.AddField("id", id);
+ exMoveEffect.AddField("chance-n", chance.GetNum());
+ exMoveEffect.AddField("chance-d", chance.GetDenom());
+ exMoveEffect.AddField("effect", effect);
+ exMoveEffect.AddField("val1", val1);
+ exMoveEffect.AddField("val2", val2);
+ exMoveEffect.Export(fout);
+ LogExportOver("MoveEffect", id, name);
+}
+
+void PokeGen::PokeMod::MoveEffect::SetChance(const Frac &c)
+{
+ LogSetVar("MoveEffect", id, "chance", c.GetNum(), c.GetDenom());
+ chance = c;
+}
+
+void PokeGen::PokeMod::MoveEffect::SetChance(unsigned n, unsigned d)
+{
+ LogSetVar("MoveEffect", id, "chance", n, d);
+ chance.Set(n, d);
+}
+
+void PokeGen::PokeMod::MoveEffect::SetChanceNum(unsigned n)
+{
+ LogSetVar("MoveEffect", id, "chance numerator", n, true);
+ chance.SetNum(n);
+}
+
+void PokeGen::PokeMod::MoveEffect::SetChanceDenom(unsigned d)
+{
+ LogSetVar("MoveEffect", id, "chance denominator", d, false);
+ chance.SetDenom(d);
+}
+
+void PokeGen::PokeMod::MoveEffect::SetEffect(int e)
+{
+ LogSetVar("MoveEffect", id, "effect", e);
+ effect = e;
+ val1 = -1;
+ val2 = -1;
+}
+
+void PokeGen::PokeMod::MoveEffect::SetEffect(const String &e)
+{
+ LogSetVar("MoveEffect", id, "effect string", e);
+ effect = FindIn(ME_END, e, MoveEffectStr);
+ val1 = -1;
+ val2 = -1;
+}
+
+// TODO (Ben#1#): Effect code
+void PokeGen::PokeMod::MoveEffect::SetVal1(int v1)
+{
+ PMLog("MoveEffect: Setting val1", PM_DEBUG_DEBUG);
+ val1 = v1;
+}
+
+void PokeGen::PokeMod::MoveEffect::SetVal2(int v2)
+{
+ PMLog("MoveEffect: Setting val2", PM_DEBUG_DEBUG);
+ val2 = v2;
+}
+
+void PokeGen::PokeMod::MoveEffect::SetVal2(const PMString &v2)
+{
+ PMLog("MoveEffect: Setting val2", PM_DEBUG_DEBUG);
+ val2 = v2;
+}
+
+PokeGen::PokeMod::Frac PokeGen::PokeMod::MoveEffect::GetChance() const
+{
+ LogFetchVar("MoveEffect", id, "chance", chance.GetNum());
+ return chance;
+}
+
+unsigned PokeGen::PokeMod::MoveEffect::GetChanceNum() const
+{
+ LogFetchVar("MoveEffect", id, "chance numerator", chance.GetNum());
+ return chance.GetNum();
+}
+
+unsigned PokeGen::PokeMod::MoveEffect::GetChanceDenom() const
+{
+ LogFetchVar("MoveEffect", id, "chance denominator", chance.GetDenom());
+ return chance.GetDenom();
+}
+
+int PokeGen::PokeMod::MoveEffect::GetEffect() const
+{
+ LogFetchVar("MoveEffect", id, "effect", effect);
+ return effect;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::MoveEffect::GetEffectString() const
+{
+ LogFetchVar("MoveEffect", id, "effect string", MoveEffectStr[effect]);
+ return MoveEffectStr[effect];
+}
+
+int PokeGen::PokeMod::MoveEffect::GetVal1() const
+{
+ LogFetchVar("MoveEffect", id, "val1", val1);
+ return val1;
+}
+
+int PokeGen::PokeMod::MoveEffect::GetVal2() const
+{
+ LogFetchVar("MoveEffect", id, "val2", val2);
+ return val2;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::MoveEffect::GetVal2String() const
+{
+ LogFetchVar("MoveEffect", id, "val2 string", val2);
+ return val2;
+}