From 3595239f08f2bc1df32ef22ed6de9bde10ca3384 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 4 Jun 2007 01:35:20 +0000 Subject: Style cleanup, minor Matrix fixes, duplication validations, Pokemod methods git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@19 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/Move.cpp | 136 +++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 102 insertions(+), 34 deletions(-) (limited to 'pokemod/Move.cpp') diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp index 6dee45f6..5aa55267 100644 --- a/pokemod/Move.cpp +++ b/pokemod/Move.cpp @@ -25,28 +25,25 @@ extern PokeGen::PokeMod::Pokemod curPokeMod; -PokeGen::PokeMod::Move::Move(const unsigned _id) +PokeGen::PokeMod::Move::Move(const unsigned _id) : + name(""), + accuracy(1, 1), + power(0), + type(UINT_MAX), + special(false), + powerPoints(0), + target(UINT_MAX), + ignoreAccuracy(false), + ignoreFlinch(false), + sound(false), + description(""), + contestType(UINT_MAX), + contestPoints(0), + jamPoints(0), + contestEffect(UINT_MAX), + contestTarget(UINT_MAX) { LogCtor("Move", _id); - name = ""; - accuracy.Set(1, 1); - power = 0; - type = UINT_MAX; - special = false; - powerPoints = 1; - target = UINT_MAX; - numTargets = 0; - targetChoice = UINT_MAX; - ignoreAccuracy = false; - ignoreFlinch = false; - sound = false; - description = ""; - contestType = UINT_MAX; - contestPoints = 0; - jamPoints = 0; - contestEffect = UINT_MAX; - contestTarget = UINT_MAX; - effects.clear(); id = _id; } @@ -120,6 +117,40 @@ void PokeGen::PokeMod::Move::Validate() isValid = false; } } + if (GetMoveEffectCount()) + { + std::map idChecker; + std::map effectChecker; + for (std::vector::iterator i = effects.begin(); i != effects.end(); ++i) + { + LogSubmoduleIterate("Move", id, "effect", i->GetId(), name); + if (!i->IsValid()) + isValid = false; + ++idChecker[i->GetId()]; + ++effectChecker[i->GetEffectString()]; + } + for (std::map::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateId("Move", id, "effect", i->first, name); + isValid = false; + } + } + for (std::map::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateSubmodule("Move", id, "effect", i->first, name); + isValid = false; + } + } + } + else + { + LogSubmoduleEmpty("Move", id, "effect", name); + isValid = false; + } LogValidateOver("Move", id, name); } @@ -127,40 +158,40 @@ void PokeGen::PokeMod::Move::Validate() void PokeGen::PokeMod::Move::Validate(const wxListBox &output) { LogValidateStart("Move", id, name); - if (name == "" + if (name == "") { LogVarNotSet("Move", id, "name"); - output.append(ConsoleLogVarNotSet("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)); + output.Append(ConsoleLogVarNotValid("Move", id, "type", name)); isValid = false; } if (!powerPoints) { LogVarNotValid("Move", id, "powerPoints", name); - output.append(ConsoleLogVarNotValid("Move", id, "powerPoints", name)); + output.Append(ConsoleLogVarNotValid("Move", id, "powerPoints", name)); isValid = false; } if (TAR_END <= target) { LogVarNotValid("Move", id, "target", name); - output.append(ConsoleLogVarNotValid("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)); + output.Append(ConsoleLogVarNotValid("Move", id, "numTargets", name)); isValid = false; } if (CHC_END <= targetChoice) { LogVarNotValid("Move", id, "targetChoice", name); - output.append(ConsoleLogVarNotValid("Move", id, "targetChoice", name)); + output.Append(ConsoleLogVarNotValid("Move", id, "targetChoice", name)); isValid = false; } if (curPokeMod.IsContestAllowed()) @@ -168,28 +199,65 @@ void PokeGen::PokeMod::Move::Validate(const wxListBox &output) if (COTY_END <= contestType) { LogVarNotValid("Move", id, "contestType", name); - output.append(ConsoleLogVarNotValid("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)); + output.Append(ConsoleLogVarNotValid("Move", id, "contestPoints", name)); isValid = false; } if (CONE_END <= contestEffect) { LogVarNotValid("Move", id, "contestEffect", name); - output.append(ConsoleLogVarNotValid("Move", id, "contestEffect", name)); + output.Append(ConsoleLogVarNotValid("Move", id, "contestEffect", name)); isValid = false; } if (CONT_END <= contestTarget) { LogVarNotValid("Move", id, "contestTarget", name); - output.append(ConsoleLogVarNotValid("Move", id, "contestTarget", name)); + output.Append(ConsoleLogVarNotValid("Move", id, "contestTarget", name)); isValid = false; } } + if (GetMoveEffectCount()) + { + std::map idChecker; + std::map effectChecker; + for (std::vector::iterator i = effects.begin(); i != effects.end(); ++i) + { + LogSubmoduleIterate("Move", id, "effect", i->GetId(), name); + if (!i->IsValid()) + isValid = false; + ++idChecker[i->GetId()]; + ++effectChecker[i->GetEffectString()]; + } + for (std::map::const_iterator i = idChecker.begin(); i != idChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateId("Move", id, "effect", i->first, name); + output.Append(ConsoleLogDuplicateId("Move", id, "effect", i->first, name)); + isValid = false; + } + } + for (std::map::const_iterator i = effectChecker.begin(); i != effectChecker.end(); ++i) + { + if (1 < i->second) + { + LogDuplicateSubmodule("Move", id, "effect", i->first, name); + output.Append(ConsoleLogDuplicateSubmodule("Move", id, "effect", i->first, name)); + isValid = false; + } + } + } + else + { + LogSubmoduleEmpty("Move", id, "effect", name); + output.Append(ConsoleLogSubmoduleEmpty("Move", id, "effect", name)); + isValid = false; + } LogValidateOver("Move", id, move); } #endif @@ -207,7 +275,7 @@ void PokeGen::PokeMod::Move::ImportIni(Ini &ini, const unsigned _id) id = _id; unsigned i; unsigned j; - ini.GetValue("name", name, ""); + ini.GetValue("name", name); ini.GetValue("accuracy-n", i, 1); ini.GetValue("accuracy-d", j, 1); accuracy.Set(i, j); @@ -392,7 +460,7 @@ void PokeGen::PokeMod::Move::SetContestPoints(const int c) void PokeGen::PokeMod::Move::SetJamPoints(const int j) { - LogSetVar("Move", id, "jamPoints",j, name); + LogSetVar("Move", id, "jamPoints", j, name); jamPoints = j; } @@ -603,7 +671,6 @@ unsigned PokeGen::PokeMod::Move::GetMoveEffectCount() const 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)) @@ -629,3 +696,4 @@ void PokeGen::PokeMod::Move::DeleteMoveEffect(unsigned _id) } LogSubmoduleRemoveFail("Move", id, "effect", _id, name); } + -- cgit