From f71140fae5218ee9839ffcd4ec83abfded5124f4 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 1 Jun 2007 02:54:29 +0000 Subject: Added Map and Tile, added Hat class, and fixed up some other minor things git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@17 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/Move.cpp | 108 +++++++++++++++++++++++++++---------------------------- 1 file changed, 53 insertions(+), 55 deletions(-) (limited to 'pokemod/Move.cpp') diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp index 19e18e62..05577f5a 100644 --- a/pokemod/Move.cpp +++ b/pokemod/Move.cpp @@ -31,21 +31,21 @@ PokeGen::PokeMod::Move::Move(const unsigned _id) name = ""; accuracy.Set(1, 1); power = 0; - type = -1; + type = UINT_MAX; special = false; powerPoints = 1; - target = -1; + target = UINT_MAX; numTargets = 0; - targetChoice = -1; + targetChoice = UINT_MAX; ignoreAccuracy = false; ignoreFlinch = false; sound = false; description = ""; - contestType = -1; + contestType = UINT_MAX; contestPoints = 0; jamPoints = 0; - contestEffect = -1; - contestTarget = -1; + contestEffect = UINT_MAX; + contestTarget = UINT_MAX; effects.clear(); id = _id; } @@ -71,6 +71,7 @@ void PokeGen::PokeMod::Move::Validate() LogVarNotSet("Move", id, "name"); isValid = ""; } + accuracy.Reduce(); if (!curPokeMod.GetType(type)) { LogVarNotValid("Move", id, "type", name); @@ -81,24 +82,24 @@ void PokeGen::PokeMod::Move::Validate() LogVarNotValid("Move", id, "powerPoints", name); isValid = false; } - if ((target <= TAR_NONE) || (TAR_END <= target)) + if (TAR_END <= target) { LogVarNotValid("Move", id, "target", name); isValid = false; } - if (!targets || (curPokeMod.GetMaxFight() << 1) < numTargets) + if (!target || (curPokeMod.GetMaxFight() << 1) < numTargets) { LogVarNotValid("Move", id, "numTargets", name); isValid = false; } - if ((targetChoice <= TAC_NONE) || (TAC_END <= targetChoice)) + if (TAC_END <= targetChoice) { LogVarNotValid("Move", id, "targetChoice", name); isValid = false; } if (curPokeMod.IsContestAllowed()) { - if ((contestType <= COTY_NONE) || (COTY_END <= contestType)) + if (COTY_END <= contestType) { LogVarNotValid("Move", id, "contestType", name); isValid = false; @@ -108,12 +109,12 @@ void PokeGen::PokeMod::Move::Validate() LogVarNotValid("Move", id, "contestPoints", name); isValid = false; } - if ((contestEffect <= CONE_NONE) || (CONE_END <= contestEffect)) + if (CONE_END <= contestEffect) { LogVarNotValid("Move", id, "contestEffect", name); isValid = false; } - if ((contestTarget <= CONT_NONE) || (CONT_END <= contestTarget)) + if (CONT_END <= contestTarget) { LogVarNotValid("Move", id, "contestTarget", name); isValid = false; @@ -144,7 +145,7 @@ void PokeGen::PokeMod::Move::Validate(const wxListBox &output) output.append(ConsoleLogVarNotValid("Move", id, "powerPoints", name)); isValid = false; } - if ((target <= TAR_NONE) || (TAR_END <= target)) + if (TAR_END <= target) { LogVarNotValid("Move", id, "target", name); output.append(ConsoleLogVarNotValid("Move", id, "target", name)); @@ -156,7 +157,7 @@ void PokeGen::PokeMod::Move::Validate(const wxListBox &output) output.append(ConsoleLogVarNotValid("Move", id, "numTargets", name)); isValid = false; } - if ((targetChoice <= TAC_NONE) || (TAC_END <= targetChoice)) + if (TAC_END <= targetChoice) { LogVarNotValid("Move", id, "targetChoice", name); output.append(ConsoleLogVarNotValid("Move", id, "targetChoice", name)); @@ -164,7 +165,7 @@ void PokeGen::PokeMod::Move::Validate(const wxListBox &output) } if (curPokeMod.IsContestAllowed()) { - if ((contestType <= COTY_NONE) || (COTY_END <= contestType)) + if (COTY_END <= contestType) { LogVarNotValid("Move", id, "contestType", name); output.append(ConsoleLogVarNotValid("Move", id, "contestType", name)); @@ -176,13 +177,13 @@ void PokeGen::PokeMod::Move::Validate(const wxListBox &output) output.append(ConsoleLogVarNotValid("Move", id, "contestPoints", name)); isValid = false; } - if ((contestEffect <= CONE_NONE) || (CONE_END <= contestEffect)) + if (CONE_END <= contestEffect) { LogVarNotValid("Move", id, "contestEffect", name); output.append(ConsoleLogVarNotValid("Move", id, "contestEffect", name)); isValid = false; } - if ((contestTarget <= CONT_NONE) || (CONT_END <= contestTarget)) + if (CONT_END <= contestTarget) { LogVarNotValid("Move", id, "contestTarget", name); output.append(ConsoleLogVarNotValid("Move", id, "contestTarget", name)); @@ -211,21 +212,21 @@ void PokeGen::PokeMod::Move::ImportIni(Ini &ini, const unsigned _id) ini.GetValue("accuracy-d", j, 1); accuracy.Set(i, j); ini.GetValue("power", power, 0); - ini.GetValue("type", type, -1); + ini.GetValue("type", type); ini.GetValue("special", special, false); ini.GetValue("powerPoints", powerPoints, 1); - ini.GetValue("target", target, -1); + ini.GetValue("target", target); ini.GetValue("numTargets", numTargets, 0); - ini.GetValue("targetChoice", targetChoice, -1); + ini.GetValue("targetChoice", targetChoice); 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("contestType", contestType); ini.GetValue("contestPoints", contestPoints, 0); ini.GetValue("jamPoints", jamPoints, 0); - ini.GetValue("contestEffect", contestEffect, -1); - ini.GetValue("contestTarget", contestTarget, -1); + ini.GetValue("contestEffect", contestEffect); + ini.GetValue("contestTarget", contestTarget); LogImportOver("Move", id, name); } @@ -253,6 +254,8 @@ void PokeGen::PokeMod::Move::ExportIni(std::ofstream &fout) const exMove.AddField("jamPoints", jamPoints); exMove.AddField("contestEffect", contestEffect); exMove.AddField("contestTarget", contestTarget); + for (std::vector::const_iterator i = effects.begin(); i != effects.end(); ++i) + i->ExportIni(fout, name); LogExportOver("Move", id, name); } @@ -313,17 +316,16 @@ void PokeGen::PokeMod::Move::SetPowerPoints(const unsigned p) powerPoints = p; } -void PokeGen::PokeMod::Move::SetTarget(const int t) +void PokeGen::PokeMod::Move::SetTarget(const unsigned t) { LogSetVar("Move", id, "target", t, name); - if ((TAR_NONE < t) && (t < TAR_END)) + if (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); + SetTarget(FindIn(TAR_END, t, TargetStr)); } void PokeGen::PokeMod::Move::SetNumTargets(const unsigned n) @@ -333,17 +335,16 @@ void PokeGen::PokeMod::Move::SetNumTargets(const unsigned n) numTargets = n; } -void PokeGen::PokeMod::Move::SetTargetChoice(const int t) +void PokeGen::PokeMod::Move::SetTargetChoice(const unsigned t) { LogSetVar("Move", id, "targetChoice", t, name); - if ((TAC_NONE < t) && (t < TAC_END)) + if (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); + SetTargetChoice(FindIn(TAC_END, t, TargetChoiceStr)); } void PokeGen::PokeMod::Move::SetIgnoreAccuracy(const bool i) @@ -370,17 +371,16 @@ void PokeGen::PokeMod::Move::SetDescription(const String &d) description = d; } -void PokeGen::PokeMod::Move::SetContestType(const int c) +void PokeGen::PokeMod::Move::SetContestType(const unsigned c) { LogSetVar("Move", id, "contestType", c, name); - if ((COTY_NONE < c) && (c < COTY_END)) + if (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); + SetContestType(FindIn(COTY_END, c, ContestTypeStr)); } void PokeGen::PokeMod::Move::SetContestPoints(const int c) @@ -396,30 +396,28 @@ void PokeGen::PokeMod::Move::SetJamPoints(const int j) jamPoints = j; } -void PokeGen::PokeMod::Move::SetContestEffect(const int c) +void PokeGen::PokeMod::Move::SetContestEffect(const unsigned c) { LogSetVar("Move", id, "contestEffect", c, name); - if ((CONE_NONE < c) && (c < CONE_END)) + if (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); + SetContestEffect(FindIn(CONE_END, c, ContestEffectStr)); } -void PokeGen::PokeMod::Move::SetContestTarget(const int c) +void PokeGen::PokeMod::Move::SetContestTarget(const unsigned c) { LogSetVar("Move", id, "contestTarget", c, name); - if ((CONT_NONE < c) && (c < CONT_END)) + if (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); + SetContestTarget(FindIn(CONT_END, c, ContestTargetStr)); } PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetName() const @@ -472,7 +470,7 @@ unsigned PokeGen::PokeMod::Move::GetPowerPoints() const return powerPoints; } -int PokeGen::PokeMod::Move::GetTarget() const +unsigned PokeGen::PokeMod::Move::GetTarget() const { LogFetchVar("Move", id, "target", target, name); return target; @@ -481,7 +479,7 @@ int PokeGen::PokeMod::Move::GetTarget() const PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetTargetString() const { LogFetchVar("Move", id, "target string", target, name); - if ((TAR_NONE < target) && (target < TAR_END)) + if (target < TAR_END) return TargetStr[target]; return ""; } @@ -492,7 +490,7 @@ unsigned PokeGen::PokeMod::Move::GetNumTargets() const return numTargets; } -int PokeGen::PokeMod::Move::GetTargetChoice() const +unsigned PokeGen::PokeMod::Move::GetTargetChoice() const { LogFetchVar("Move", id, "targetChoice", targetChoice, name); return targetChoice; @@ -501,7 +499,7 @@ int PokeGen::PokeMod::Move::GetTargetChoice() const PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetTargetChoiceString() const { LogFetchVar("Move", id, "targetChoice string", targetChoice, name); - if ((TARC_NONE < targetChoice) && (targetChoice < TARC_END)) + if (targetChoice < TARC_END) return TargetChoiceStr[targetChoice]; return ""; } @@ -530,7 +528,7 @@ PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetDescription() const return description; } -int PokeGen::PokeMod::Move::GetContestType() const +unsigned PokeGen::PokeMod::Move::GetContestType() const { LogFetchVar("Move", id, "contestType", contestType, name); return contestType; @@ -539,7 +537,7 @@ int PokeGen::PokeMod::Move::GetContestType() const PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetContestTypeString() const { LogFetchVar("Move", id, "contestType string", contestType, name); - if ((COTY_NONE < contestType) && (contestType < COTY_END)) + if (contestType < COTY_END) return ContestTypeStr[contestType]; return ""; } @@ -556,7 +554,7 @@ int PokeGen::PokeMod::Move::GetJamPoints() const return jamPoints; } -int PokeGen::PokeMod::Move::GetContestEffect() const +unsigned PokeGen::PokeMod::Move::GetContestEffect() const { LogFetchVar("Move", id, "contestEffect", contestEffect, name); return contestEffect; @@ -565,12 +563,12 @@ int PokeGen::PokeMod::Move::GetContestEffect() const PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetContestEffectString() const { LogFetchVar("Move", id, "contestEffect string", contestEffect, name); - if ((CONE_NONE < contestEffect) && (contestEffect < CONE_END)) + if (contestEffect < CONE_END) return ContestEffectStr[contestEffect]; return ""; } -int PokeGen::PokeMod::Move::GetContestTarget() const +unsigned PokeGen::PokeMod::Move::GetContestTarget() const { LogFetchVar("Move", id, "contestTarget", contestTarget, name); return contestTarget; @@ -579,12 +577,12 @@ int PokeGen::PokeMod::Move::GetContestTarget() const PokeGen::PokeMod::String PokeGen::PokeMod::Move::GetContestTargetString() const { LogFetchVar("Move", id, "contestTarget string", contestTarget, name); - if ((CONT_NONE < contestTarget) && (contestTarget < CONT_END)) + if (contestTarget < CONT_END) return ContestTargetStr[contestTarget]; return ""; } -PokeGen::PokeMod::MoveEffect *PokeGen::PokeMod::Move::GetMoveEffect(unsigned _id) +const PokeGen::PokeMod::MoveEffect *PokeGen::PokeMod::Move::GetMoveEffect(unsigned _id) const { LogSubmoduleFetch("Move", id, "effect", _id, name); for (unsigned i = 0; i < GetMoveEffectCount(); ++i) @@ -621,7 +619,7 @@ void PokeGen::PokeMod::Move::NewMoveEffect(Ini *const ini) void PokeGen::PokeMod::Move::DeleteMoveEffect(unsigned _id) { LogSubmoduleRemoveStart("Move", id, "effect", _id, name); - for (std::vector::iterator i = effects.begin(); i != effects.end(); ++i) + for (std::vector::const_iterator i = effects.begin(); i != effects.end(); ++i) { if (i->GetId() == _id) { -- cgit