summaryrefslogtreecommitdiffstats
path: root/pokemod/Move.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2007-05-29 01:02:16 +0000
committerBen Boeckel <MathStuf@gmail.com>2007-05-29 01:02:16 +0000
commit9e28e6ecd358a9801ad25914d3e8cca7b6d7f4f7 (patch)
tree8f200e87bc1fa3f1bbd2152dad0e62924c33ae12 /pokemod/Move.cpp
parentdc9682d704118840457aa3434711eba6e003eafc (diff)
downloadsigen-9e28e6ecd358a9801ad25914d3e8cca7b6d7f4f7.tar.gz
sigen-9e28e6ecd358a9801ad25914d3e8cca7b6d7f4f7.tar.xz
sigen-9e28e6ecd358a9801ad25914d3e8cca7b6d7f4f7.zip
Lots of minor fixes, added TODO file, Move methods
git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@16 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod/Move.cpp')
-rw-r--r--pokemod/Move.cpp633
1 files changed, 633 insertions, 0 deletions
diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp
new file mode 100644
index 00000000..19e18e62
--- /dev/null
+++ b/pokemod/Move.cpp
@@ -0,0 +1,633 @@
+/////////////////////////////////////////////////////////////////////////////
+// Name: pokemod/Move.cpp
+// Purpose: Define a move that Pokémon can learn
+// Author: Ben Boeckel
+// Modified by: Ben Boeckel
+// Created: Sat May 26 2007 22:51:21
+// Copyright: ©2007 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 "Move.h"
+
+extern PokeGen::PokeMod::Pokemod curPokeMod;
+
+PokeGen::PokeMod::Move::Move(const unsigned _id)
+{
+ LogCtor("Move", _id);
+ name = "";
+ accuracy.Set(1, 1);
+ power = 0;
+ type = -1;
+ special = false;
+ powerPoints = 1;
+ target = -1;
+ numTargets = 0;
+ targetChoice = -1;
+ ignoreAccuracy = false;
+ ignoreFlinch = false;
+ sound = false;
+ description = "";
+ contestType = -1;
+ contestPoints = 0;
+ jamPoints = 0;
+ contestEffect = -1;
+ contestTarget = -1;
+ effects.clear();
+ id = _id;
+}
+
+PokeGen::PokeMod::Move::Move(Ini &ini, const unsigned _id)
+{
+ LogCtorIni("Move", _id);
+ ImportIni(ini, _id);
+ if (_id == UINT_MAX)
+ LogIdError("Move");
+}
+
+PokeGen::PokeMod::Move::~Move()
+{
+ LogDtor("Move", id, name);
+}
+
+void PokeGen::PokeMod::Move::Validate()
+{
+ LogValidateStart("Move", id, name);
+ if (name == "")
+ {
+ LogVarNotSet("Move", id, "name");
+ isValid = "";
+ }
+ if (!curPokeMod.GetType(type))
+ {
+ LogVarNotValid("Move", id, "type", name);
+ isValid = false;
+ }
+ if (!powerPoints)
+ {
+ LogVarNotValid("Move", id, "powerPoints", name);
+ isValid = false;
+ }
+ if ((target <= TAR_NONE) || (TAR_END <= target))
+ {
+ LogVarNotValid("Move", id, "target", name);
+ isValid = false;
+ }
+ if (!targets || (curPokeMod.GetMaxFight() << 1) < numTargets)
+ {
+ LogVarNotValid("Move", id, "numTargets", name);
+ isValid = false;
+ }
+ if ((targetChoice <= TAC_NONE) || (TAC_END <= targetChoice))
+ {
+ LogVarNotValid("Move", id, "targetChoice", name);
+ isValid = false;
+ }
+ if (curPokeMod.IsContestAllowed())
+ {
+ if ((contestType <= COTY_NONE) || (COTY_END <= contestType))
+ {
+ LogVarNotValid("Move", id, "contestType", name);
+ isValid = false;
+ }
+ if (!contestPoints)
+ {
+ LogVarNotValid("Move", id, "contestPoints", name);
+ isValid = false;
+ }
+ if ((contestEffect <= CONE_NONE) || (CONE_END <= contestEffect))
+ {
+ LogVarNotValid("Move", id, "contestEffect", name);
+ isValid = false;
+ }
+ if ((contestTarget <= CONT_NONE) || (CONT_END <= contestTarget))
+ {
+ LogVarNotValid("Move", id, "contestTarget", name);
+ isValid = false;
+ }
+ }
+ LogValidateOver("Move", id, name);
+}
+
+#ifdef PG_DEBUG_WINDOW
+void PokeGen::PokeMod::Move::Validate(const wxListBox &output)
+{
+ LogValidateStart("Move", id, name);
+ if (name == ""
+ {
+ LogVarNotSet("Move", id, "name");
+ output.append(ConsoleLogVarNotSet("Move", id, "name"););
+ isValid = "";
+ }
+ if (!curPokeMod.GetType(type))
+ {
+ LogVarNotValid("Move", id, "type", name);
+ output.append(ConsoleLogVarNotValid("Move", id, "type", name));
+ isValid = false;
+ }
+ if (!powerPoints)
+ {
+ LogVarNotValid("Move", id, "powerPoints", name);
+ output.append(ConsoleLogVarNotValid("Move", id, "powerPoints", name));
+ isValid = false;
+ }
+ if ((target <= TAR_NONE) || (TAR_END <= target))
+ {
+ LogVarNotValid("Move", id, "target", name);
+ output.append(ConsoleLogVarNotValid("Move", id, "target", name));
+ isValid = false;
+ }
+ if (!targets || (curPokeMod.GetMaxFight() << 1) < numTargets)
+ {
+ LogVarNotValid("Move", id, "numTargets", name);
+ output.append(ConsoleLogVarNotValid("Move", id, "numTargets", name));
+ isValid = false;
+ }
+ if ((targetChoice <= TAC_NONE) || (TAC_END <= targetChoice))
+ {
+ LogVarNotValid("Move", id, "targetChoice", name);
+ output.append(ConsoleLogVarNotValid("Move", id, "targetChoice", name));
+ isValid = false;
+ }
+ if (curPokeMod.IsContestAllowed())
+ {
+ if ((contestType <= COTY_NONE) || (COTY_END <= contestType))
+ {
+ LogVarNotValid("Move", id, "contestType", name);
+ output.append(ConsoleLogVarNotValid("Move", id, "contestType", name));
+ isValid = false;
+ }
+ if (!contestPoints)
+ {
+ LogVarNotValid("Move", id, "contestPoints", name);
+ output.append(ConsoleLogVarNotValid("Move", id, "contestPoints", name));
+ isValid = false;
+ }
+ if ((contestEffect <= CONE_NONE) || (CONE_END <= contestEffect))
+ {
+ LogVarNotValid("Move", id, "contestEffect", name);
+ output.append(ConsoleLogVarNotValid("Move", id, "contestEffect", name));
+ isValid = false;
+ }
+ if ((contestTarget <= CONT_NONE) || (CONT_END <= contestTarget))
+ {
+ LogVarNotValid("Move", id, "contestTarget", name);
+ output.append(ConsoleLogVarNotValid("Move", id, "contestTarget", name));
+ isValid = false;
+ }
+ }
+ LogValidateOver("Move", id, move);
+}
+#endif
+
+void PokeGen::PokeMod::Move::ImportIni(Ini &ini, const unsigned _id)
+{
+ LogImportStart("Move");
+ if (_id == UINT_MAX)
+ {
+ ini.GetValue("id", id, UINT_MAX);
+ if (id == UINT_MAX)
+ LogIdNotFound("Move");
+ }
+ else
+ id = _id;
+ unsigned i;
+ unsigned j;
+ ini.GetValue("name", name, "");
+ ini.GetValue("accuracy-n", i, 1);
+ ini.GetValue("accuracy-d", j, 1);
+ accuracy.Set(i, j);
+ ini.GetValue("power", power, 0);
+ ini.GetValue("type", type, -1);
+ ini.GetValue("special", special, false);
+ ini.GetValue("powerPoints", powerPoints, 1);
+ ini.GetValue("target", target, -1);
+ ini.GetValue("numTargets", numTargets, 0);
+ ini.GetValue("targetChoice", targetChoice, -1);
+ ini.GetValue("ignoreAccuracy", ignoreAccuracy, false);
+ ini.GetValue("ignoreFlinch", ignoreFlinch, false);
+ ini.GetValue("sound", sound, false);
+ ini.GetValue("description", description, "");
+ ini.GetValue("contestType", contestType, -1);
+ ini.GetValue("contestPoints", contestPoints, 0);
+ ini.GetValue("jamPoints", jamPoints, 0);
+ ini.GetValue("contestEffect", contestEffect, -1);
+ ini.GetValue("contestTarget", contestTarget, -1);
+ LogImportOver("Move", id, name);
+}
+
+void PokeGen::PokeMod::Move::ExportIni(std::ofstream &fout) const
+{
+ LogExportStart("Move", id, name);
+ Ini exMove("Move");
+ exMove.AddField("id", id);
+ exMove.AddField("name", name);
+ exMove.AddField("accuracy-n", accuracy.GetNum());
+ exMove.AddField("accuracy-d", accuracy.GetDenom());
+ exMove.AddField("power", power);
+ exMove.AddField("type", type);
+ exMove.AddField("special", special);
+ exMove.AddField("powerPoints", powerPoints);
+ exMove.AddField("target", target);
+ exMove.AddField("numTargets", numTargets);
+ exMove.AddField("targetChoice", targetChoice);
+ exMove.AddField("ignoreAccuracy", ignoreAccuracy);
+ exMove.AddField("ignoreFlinch", ignoreFlinch);
+ exMove.AddField("sound", sound);
+ exMove.AddField("description", description);
+ exMove.AddField("contestType", contestPoints);
+ exMove.AddField("contestPoints", contestPoints);
+ exMove.AddField("jamPoints", jamPoints);
+ exMove.AddField("contestEffect", contestEffect);
+ exMove.AddField("contestTarget", contestTarget);
+ LogExportOver("Move", id, name);
+}
+
+void PokeGen::PokeMod::Move::SetName(const String &n)
+{
+ LogSetVar("Move", id, "name", n);
+ name = n;
+}
+
+void PokeGen::PokeMod::Move::SetAccuracy(const Frac &a)
+{
+ LogSetVar("Move", id, "accuracy", a.GetNum(), a.GetDenom(), name);
+ accuracy = a;
+}
+
+void PokeGen::PokeMod::Move::SetAccuracy(const unsigned n, const unsigned d)
+{
+ LogSetVar("Move", id, "accuracy", n, d, name);
+ accuracy.Set(n, d);
+}
+
+void PokeGen::PokeMod::Move::SetAccuracyNum(const unsigned n)
+{
+ LogSetVar("Move", id, "accuracy numerator", n, name);
+ accuracy.SetNum(n);
+}
+
+void PokeGen::PokeMod::Move::SetAccuracyDenom(const unsigned d)
+{
+ LogSetVar("Move", id, "accuracy denominator", d, name);
+ accuracy.SetDenom(d);
+}
+
+void PokeGen::PokeMod::Move::SetType(const unsigned t)
+{
+ LogSetVar("Move", id, "type", t, name);
+ if (curPokeMod.GetType(t))
+ type = t;
+}
+
+void PokeGen::PokeMod::Move::SetType(const String &t)
+{
+ LogSetVar("Move", id, "type string", t, name);
+ if (Type *temp = curPokeMod.GetType(t))
+ type = temp->GetId();
+}
+
+void PokeGen::PokeMod::Move::SetSpecial(const bool s)
+{
+ LogSetVar("Move", id, "special", s, name);
+ special = s;
+}
+
+void PokeGen::PokeMod::Move::SetPowerPoints(const unsigned p)
+{
+ LogSetVar("Move", id, "powerPoints", powerPoints, name);
+ if (p)
+ powerPoints = p;
+}
+
+void PokeGen::PokeMod::Move::SetTarget(const int t)
+{
+ LogSetVar("Move", id, "target", t, name);
+ if ((TAR_NONE < t) && (t < TAR_END))
+ target = t;
+}
+
+void PokeGen::PokeMod::Move::SetTarget(const String &t)
+{
+ LogSetVar("Move", id, "target string", t, name);
+ target = FindIn(TAR_END, t, TargetStr);
+}
+
+void PokeGen::PokeMod::Move::SetNumTargets(const unsigned n)
+{
+ LogSetVar("Name", id, "numTargets", n, name);
+ if (n && (n <= curPokeMod.GetMaxFight() << 1))
+ numTargets = n;
+}
+
+void PokeGen::PokeMod::Move::SetTargetChoice(const int t)
+{
+ LogSetVar("Move", id, "targetChoice", t, name);
+ if ((TAC_NONE < t) && (t < TAC_END))
+ targetChoice = t;
+}
+
+void PokeGen::PokeMod::Move::SetTargetChoice(const String &t)
+{
+ LogSetVar("Move", id, "targetChoice string", t, name);
+ targetChoice = FindIn(TAC_END, t, TargetChoiceStr);
+}
+
+void PokeGen::PokeMod::Move::SetIgnoreAccuracy(const bool i)
+{
+ LogSetVar("Move", id, "ignoeAccuracy", i, name);
+ ignoreAccuracy = i;
+}
+
+void PokeGen::PokeMod::Move::SetIgnoreFlinch(const bool i)
+{
+ LogSetVar("Move", id, "ignoreFlinch", i, name);
+ ignoreFlinch = i;
+}
+
+void PokeGen::PokeMod::Move::SetSound(const bool s)
+{
+ LogSetVar("Move", id, "sound", s, name);
+ sound = s;
+}
+
+void PokeGen::PokeMod::Move::SetDescription(const String &d)
+{
+ LogSetVar("Move", id, "description", d, name);
+ description = d;
+}
+
+void PokeGen::PokeMod::Move::SetContestType(const int c)
+{
+ LogSetVar("Move", id, "contestType", c, name);
+ if ((COTY_NONE < c) && (c < COTY_END))
+ contestType = c;
+}
+
+void PokeGen::PokeMod::Move::SetContestType(const String &c)
+{
+ LogSetVar("Move", id, "contestType string", c, name);
+ contestType = FindIn(COTY_END, c, ContestTypeStr);
+}
+
+void PokeGen::PokeMod::Move::SetContestPoints(const int c)
+{
+ LogSetVar("Move", id, "contestPoints", c, name);
+ if (c)
+ contestPoints = c;
+}
+
+void PokeGen::PokeMod::Move::SetJamPoints(const int j)
+{
+ LogSetVar("Move", id, "jamPoints",j, name);
+ jamPoints = j;
+}
+
+void PokeGen::PokeMod::Move::SetContestEffect(const int c)
+{
+ LogSetVar("Move", id, "contestEffect", c, name);
+ if ((CONE_NONE < c) && (c < CONE_END))
+ contestEffect = c;
+}
+
+void PokeGen::PokeMod::Move::SetContestEffect(const String &c)
+{
+ LogSetVar("Move", id, "contestEffect string", c, name);
+ contestEffect = FindIn(CONE_END, c, ContestEffectStr);
+}
+
+void PokeGen::PokeMod::Move::SetContestTarget(const int c)
+{
+ LogSetVar("Move", id, "contestTarget", c, name);
+ if ((CONT_NONE < c) && (c < CONT_END))
+ contestTarget = c;
+}
+
+void PokeGen::PokeMod::Move::SetContestTarget(const String &c)
+{
+ LogSetVar("Move", id, "contestTarget string", c, name);
+ contestTarget = FindIn(CONT_END, c, ContestTargetStr);
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetName() const
+{
+ LogFetchVar("Move", id, "name", name);
+ return name;
+}
+
+PokeGen::PokeMod::Frac PokeGen::PokeMod::Move::GetAccuracy() const
+{
+ LogFetchVar("Move", id, "accuracy", accuracy.GetNum(), accuracy.GetDenom(), name);
+ return accuracy;
+}
+
+unsigned PokeGen::PokeMod::Move::GetAccuracyNum() const
+{
+ LogFetchVar("Move", id, "accuracy numerator", accuracy.GetNum(), name);
+ return accuracy.GetNum();
+}
+
+unsigned PokeGen::PokeMod::Move::GetAccuracyDenom() const
+{
+ LogFetchVar("Move", id, "accuracy denominator", accuracy.GetDenom(), name);
+ return accuracy.GetDenom();
+}
+
+unsigned PokeGen::PokeMod::Move::GetType() const
+{
+ LogFetchVar("Move", id, "type", type, name);
+ return type;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetTypeString() const
+{
+ LogFetchVar("Move", id, "type string", type, name);
+ if (Type *t = curPokeMod.GetType(type))
+ return t->GetName();
+ return "";
+}
+
+bool PokeGen::PokeMod::Move::GetSpecial() const
+{
+ LogFetchVar("Move", id, "special", special, name);
+ return special;
+}
+
+unsigned PokeGen::PokeMod::Move::GetPowerPoints() const
+{
+ LogFetchVar("Move", id, "powerPoints", powerPoints, name);
+ return powerPoints;
+}
+
+int PokeGen::PokeMod::Move::GetTarget() const
+{
+ LogFetchVar("Move", id, "target", target, name);
+ return target;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetTargetString() const
+{
+ LogFetchVar("Move", id, "target string", target, name);
+ if ((TAR_NONE < target) && (target < TAR_END))
+ return TargetStr[target];
+ return "";
+}
+
+unsigned PokeGen::PokeMod::Move::GetNumTargets() const
+{
+ LogFetchVar("Move", id, "numTargets", numTargets, name);
+ return numTargets;
+}
+
+int PokeGen::PokeMod::Move::GetTargetChoice() const
+{
+ LogFetchVar("Move", id, "targetChoice", targetChoice, name);
+ return targetChoice;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetTargetChoiceString() const
+{
+ LogFetchVar("Move", id, "targetChoice string", targetChoice, name);
+ if ((TARC_NONE < targetChoice) && (targetChoice < TARC_END))
+ return TargetChoiceStr[targetChoice];
+ return "";
+}
+
+bool PokeGen::PokeMod::Move::GetIgnoreAccuracy() const
+{
+ LogFetchVar("Move", id, "ignoreAccuracy", ignoreAccuracy, name);
+ return ignoreAccuracy;
+}
+
+bool PokeGen::PokeMod::Move::GetIgnoreFlinch() const
+{
+ LogFetchVar("Move", id, "ignoreFlinch", ignoreFlinch, name);
+ return ignoreFlinch;
+}
+
+bool PokeGen::PokeMod::Move::GetSound() const
+{
+ LogFetchVar("Move", id, "sound", sound, name);
+ return sound;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetDescription() const
+{
+ LogFetchVar("Move", id, "description", description, name);
+ return description;
+}
+
+int PokeGen::PokeMod::Move::GetContestType() const
+{
+ LogFetchVar("Move", id, "contestType", contestType, name);
+ return contestType;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetContestTypeString() const
+{
+ LogFetchVar("Move", id, "contestType string", contestType, name);
+ if ((COTY_NONE < contestType) && (contestType < COTY_END))
+ return ContestTypeStr[contestType];
+ return "";
+}
+
+int PokeGen::PokeMod::Move::GetContestPoints() const
+{
+ LogFetchVar("Move", id, "contestPoints", contestPoints, name);
+ return contestPoints;
+}
+
+int PokeGen::PokeMod::Move::GetJamPoints() const
+{
+ LogFetchVar("Move", id, "jamPoints", jamPoints, name);
+ return jamPoints;
+}
+
+int PokeGen::PokeMod::Move::GetContestEffect() const
+{
+ LogFetchVar("Move", id, "contestEffect", contestEffect, name);
+ return contestEffect;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetContestEffectString() const
+{
+ LogFetchVar("Move", id, "contestEffect string", contestEffect, name);
+ if ((CONE_NONE < contestEffect) && (contestEffect < CONE_END))
+ return ContestEffectStr[contestEffect];
+ return "";
+}
+
+int PokeGen::PokeMod::Move::GetContestTarget() const
+{
+ LogFetchVar("Move", id, "contestTarget", contestTarget, name);
+ return contestTarget;
+}
+
+PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetContestTargetString() const
+{
+ LogFetchVar("Move", id, "contestTarget string", contestTarget, name);
+ if ((CONT_NONE < contestTarget) && (contestTarget < CONT_END))
+ return ContestTargetStr[contestTarget];
+ return "";
+}
+
+PokeGen::PokeMod::MoveEffect *PokeGen::PokeMod::Move::GetMoveEffect(unsigned _id)
+{
+ LogSubmoduleFetch("Move", id, "effect", _id, name);
+ for (unsigned i = 0; i < GetMoveEffectCount(); ++i)
+ {
+ if (effects[i].GetId() == _id)
+ return &effects[i];
+ }
+ LogSubmoduleFetchFail("Move", id, "effect", _id, name);
+ return NULL;
+}
+
+unsigned PokeGen::PokeMod::Move::GetMoveEffectCount() const
+{
+ LogSubmoduleCount("Move", id, "effects", name);
+ return effects.size();
+}
+
+void PokeGen::PokeMod::Move::NewMoveEffect(Ini *const ini)
+{
+ unsigned i = 0;
+ // Find the first unused ID in the vector
+ for (; i < GetMoveEffectCount(); ++i)
+ {
+ if (!GetMoveEffect(i))
+ break;
+ }
+ MoveEffect newMoveEffect(i);
+ if (ini)
+ newMoveEffect.ImportIni(*ini);
+ LogSubmoduleNew("Move", id, "effect", i, name);
+ effects.push_back(newMoveEffect);
+}
+
+void PokeGen::PokeMod::Move::DeleteMoveEffect(unsigned _id)
+{
+ LogSubmoduleRemoveStart("Move", id, "effect", _id, name);
+ for (std::vector<MoveEffect>::iterator i = effects.begin(); i != effects.end(); ++i)
+ {
+ if (i->GetId() == _id)
+ {
+ LogSubmoduleRemoved("Move", id, "effect", _id, name);
+ effects.erase(i);
+ }
+ }
+ LogSubmoduleRemoveFail("Move", id, "effect", _id, name);
+}