summaryrefslogtreecommitdiffstats
path: root/pokemod/MoveEffect.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/MoveEffect.cpp')
-rw-r--r--pokemod/MoveEffect.cpp341
1 files changed, 142 insertions, 199 deletions
diff --git a/pokemod/MoveEffect.cpp b/pokemod/MoveEffect.cpp
index 18a1f3d1..4ceedbb8 100644
--- a/pokemod/MoveEffect.cpp
+++ b/pokemod/MoveEffect.cpp
@@ -1,199 +1,142 @@
-/////////////////////////////////////////////////////////////////////////////
-// 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 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 "MoveEffect.h"
-
-PokeGen::PokeMod::MoveEffect::MoveEffect(const unsigned _id) :
- chance(1, 1),
- effect(UINT_MAX),
- val1(INT_MAX),
- val2(UINT_MAX)
-{
- LogCtor("MoveEffect", _id);
- id = _id;
-}
-
-PokeGen::PokeMod::MoveEffect::MoveEffect(Ini &ini, const unsigned _id)
-{
- LogCtorIni("MoveEffect", _id);
- ImportIni(ini, _id);
- if (id == UINT_MAX)
- LogIdError("MoveEffect");
-}
-
-PokeGen::PokeMod::MoveEffect::~MoveEffect()
-{
- LogDtor("MoveEffect", id);
-}
-
-void PokeGen::PokeMod::MoveEffect::Validate()
-{
- LogValidateStart("MoveEffect", id);
- // TODO (Validation#1#): MoveEffect Validation
-# warning "MoveEffect Validation"
- LogValidateOver("MoveEffect", id, isValid);
-}
-
-void PokeGen::PokeMod::MoveEffect::ImportIni(Ini &ini, const unsigned _id)
-{
- LogImportStart("MoveEffect");
- if (_id == UINT_MAX)
- {
- ini.GetValue("id", id);
- 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);
- ini.GetValue("val1", val1);
- ini.GetValue("val2", val2);
-}
-
-void PokeGen::PokeMod::MoveEffect::ExportIni(QFile &fout, const QString &move) const
-{
- LogExportStart("MoveEffect", id);
- 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);
-}
-
-void PokeGen::PokeMod::MoveEffect::SetChance(const Frac &c)
-{
- LogSetVar("MoveEffect", id, "chance", c.GetNum(), c.GetDenom());
- chance = c;
-}
-
-void PokeGen::PokeMod::MoveEffect::SetChance(const unsigned n, const unsigned d)
-{
- LogSetVar("MoveEffect", id, "chance", n, d);
- chance.Set(n, d);
-}
-
-void PokeGen::PokeMod::MoveEffect::SetChanceNum(const unsigned n)
-{
- LogSetVar("MoveEffect", id, "chance numerator", n);
- chance.SetNum(n);
-}
-
-void PokeGen::PokeMod::MoveEffect::SetChanceDenom(const unsigned d)
-{
- LogSetVar("MoveEffect", id, "chance denominator", d);
- chance.SetDenom(d);
-}
-
-void PokeGen::PokeMod::MoveEffect::SetEffect(const unsigned e)
-{
- LogSetVar("MoveEffect", id, "effect", e);
- if (e < ME_END)
- {
- effect = e;
- val1 = INT_MAX;
- val2 = UINT_MAX;
- }
-}
-
-void PokeGen::PokeMod::MoveEffect::SetEffect(const QString &e)
-{
- SetEffect(FindIn(ME_END, e, MoveEffectStr));
-}
-
-// TODO (Ben#1#): Effect code
-void PokeGen::PokeMod::MoveEffect::SetVal1(const int v1)
-{
- LogSetVar("MoveEffect", id, "val1", v1);
- val1 = v1;
-}
-
-void PokeGen::PokeMod::MoveEffect::SetVal2(const unsigned v2)
-{
- LogSetVar("MoveEffect", id, "val2", v2);
- val2 = v2;
-}
-
-void PokeGen::PokeMod::MoveEffect::SetVal2(const QString &v2)
-{
- LogSetVar("MoveEffect", id, "val2 string", v2);
- val2 = 0;
-}
-
-PokeGen::PokeMod::Frac PokeGen::PokeMod::MoveEffect::GetChance() const
-{
- LogFetchVar("MoveEffect", id, "chance", chance.GetNum(), chance.GetDenom());
- 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();
-}
-
-unsigned PokeGen::PokeMod::MoveEffect::GetEffect() const
-{
- LogFetchVar("MoveEffect", id, "effect", effect);
- return effect;
-}
-
-QString PokeGen::PokeMod::MoveEffect::GetEffectString() const
-{
- LogFetchVar("MoveEffect", id, "effect string", MoveEffectStr[effect]);
- if (effect < ME_END)
- return MoveEffectStr[effect];
- return "";
-}
-
-int PokeGen::PokeMod::MoveEffect::GetVal1() const
-{
- LogFetchVar("MoveEffect", id, "val1", val1);
- return val1;
-}
-
-unsigned PokeGen::PokeMod::MoveEffect::GetVal2() const
-{
- LogFetchVar("MoveEffect", id, "val2", val2);
- return val2;
-}
-
-QString PokeGen::PokeMod::MoveEffect::GetVal2String() const
-{
- LogFetchVar("MoveEffect", id, "val2 string", val2);
- // TODO (Ben#1#): Val2 string
- return "";
-}
+/////////////////////////////////////////////////////////////////////////////
+// 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 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 "MoveEffect.h"
+
+PokeGen::PokeMod::MoveEffect::MoveEffect(const Pokemod* par, const unsigned _id) :
+ Object(_id, par),
+ chance(1, 1),
+ effect(UINT_MAX),
+ val1(INT_MAX),
+ val2(UINT_MAX)
+{
+}
+
+PokeGen::PokeMod::MoveEffect::MoveEffect(const Pokemod* par, Ini& ini, const unsigned _id) :
+ Object(_id, par)
+{
+ ImportIni(ini, _id);
+}
+
+bool PokeGen::PokeMod::MoveEffect::Validate()
+{
+ pokemod->ValidationMsg(QString("------Effect with id %1---").arg(id), Pokemod::V_Msg);
+ // TODO (Ben#1#): Move Effect validation
+ return isValid;
+}
+
+void PokeGen::PokeMod::MoveEffect::ImportIni(Ini& ini, const unsigned _id)
+{
+ if (_id == UINT_MAX)
+ ini.GetValue("id", id);
+ 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);
+ ini.GetValue("val1", val1);
+ ini.GetValue("val2", val2);
+}
+
+void PokeGen::PokeMod::MoveEffect::ExportIni(QFile& fout, const QString& move) const
+{
+ 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);
+}
+
+bool PokeGen::PokeMod::MoveEffect::SetChance(const unsigned n, const unsigned d)
+{
+ return chance.Set(n, d);
+}
+
+bool PokeGen::PokeMod::MoveEffect::SetChanceNum(const unsigned n)
+{
+ return chance.SetNum(n);
+}
+
+bool PokeGen::PokeMod::MoveEffect::SetChanceDenom(const unsigned d)
+{
+ return chance.SetDenom(d);
+}
+
+bool PokeGen::PokeMod::MoveEffect::SetEffect(const unsigned e)
+{
+ if (e < E_End)
+ {
+ effect = e;
+ val1 = INT_MAX;
+ val2 = UINT_MAX;
+ }
+ return (effect == e);
+}
+
+// TODO (Ben#1#): Effect code
+bool PokeGen::PokeMod::MoveEffect::SetVal1(const int v1)
+{
+ val1 = v1;
+ return (val1 == v1);
+}
+
+bool PokeGen::PokeMod::MoveEffect::SetVal2(const unsigned v2)
+{
+ val2 = v2;
+ return (val2 == v2);
+}
+
+PokeGen::PokeMod::Frac PokeGen::PokeMod::MoveEffect::GetChance() const
+{
+ return chance;
+}
+
+unsigned PokeGen::PokeMod::MoveEffect::GetChanceNum() const
+{
+ return chance.GetNum();
+}
+
+unsigned PokeGen::PokeMod::MoveEffect::GetChanceDenom() const
+{
+ return chance.GetDenom();
+}
+
+unsigned PokeGen::PokeMod::MoveEffect::GetEffect() const
+{
+ return effect;
+}
+
+int PokeGen::PokeMod::MoveEffect::GetVal1() const
+{
+ return val1;
+}
+
+unsigned PokeGen::PokeMod::MoveEffect::GetVal2() const
+{
+ return val2;
+}