From 5b55d13ead7e352ee1feaae72009e8abf5bd071a Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Fri, 21 Sep 2007 15:36:22 +0000 Subject: [FIX] Neural Network methods complete [FIX] Wrapped Node up into the layer [FIX] Wrapped NatureEffect into Nature [FIX] Getting around to fixing up the design of the PokéMod stuff [FIX] Creating new subclasses now returns pointer to new subclass [FIX] Simplified interfaces [FIX] Minor style issues [FIX] Renamed CoinItem to CoinListObject [FIX] Renamed MapTrainerTeam to MapTrainerPokemon [FIX] Renamed MapWildPokemon to MapWildListPokemon [FIX] Moved global enums to relevant classes [FIX] Removed general logging features [DEL] pokemod/Debug.{h, cpp} [DEL] pokemod/Path.{h, cpp} [FIX] Using QFile rather than custom Path class for checking for files [FIX] Set* methods now return a bool to let the caller know if anything actually changed (if it can fail, otherwise it is void) [ADD] Compliation without errors is required for pokemod from now on before commits MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@24 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/StatusEffect.cpp | 336 ++++++++++++++++++++--------------------------- 1 file changed, 141 insertions(+), 195 deletions(-) (limited to 'pokemod/StatusEffect.cpp') diff --git a/pokemod/StatusEffect.cpp b/pokemod/StatusEffect.cpp index b73b28b0..53585882 100644 --- a/pokemod/StatusEffect.cpp +++ b/pokemod/StatusEffect.cpp @@ -1,195 +1,141 @@ -///////////////////////////////////////////////////////////////////////////// -// Name: pokemod/StatusEffect.cpp -// Purpose: Define an effect of a status -// Author: Ben Boeckel -// Modified by: Ben Boeckel -// Created: Sat June 2 2007 12:16:48 -// 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 -// MERCHANTStatus 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 . -///////////////////////////////////////////////////////////////////////////// - -#include "StatusEffect.h" - -PokeGen::PokeMod::StatusEffect::StatusEffect(const unsigned _id) : - effect(UINT_MAX), - val1(UINT_MAX), - val2(UINT_MAX) -{ - LogCtor("StatusEffect", _id); - id = _id; -} - -PokeGen::PokeMod::StatusEffect::StatusEffect(Ini &ini, const unsigned _id) -{ - LogCtorIni("StatusEffect", _id); - ImportIni(ini, _id); - if (id == UINT_MAX) - LogIdError("StatusEffect"); -} - -PokeGen::PokeMod::StatusEffect::~StatusEffect() -{ - LogDtor("StatusEffect", id); -} - -void PokeGen::PokeMod::StatusEffect::Validate() -{ - LogValidateStart("StatusEffect", id); - if (effect < SE_END) - { - switch (effect) - { - //case : - { - LogVarNotValid("StatusEffect", id, "val1"); - isValid = false; - } - break; - } - switch (effect) - { - //case : - { - LogVarNotValid("StatusEffect", id, "val1"); - isValid = false; - } - break; - } - } - else - { - LogVarNotValid("StatusEffect", id, "effect"); - isValid = false; - } - // TODO (Validation#1#): Validation - LogValidateOver("StatusEffect", id, isValid); -} - -void PokeGen::PokeMod::StatusEffect::ImportIni(Ini &ini, const unsigned _id) -{ - LogImportStart("StatusEffect"); - if (_id == UINT_MAX) - { - ini.GetValue("id", id); - if (id == UINT_MAX) - LogIdNotFound("StatusEffect"); - } - else - id = _id; - ini.GetValue("effect", effect); - ini.GetValue("val1", val1); - ini.GetValue("val2", val2); - LogImportOver("StatusEffect", id); -} - -void PokeGen::PokeMod::StatusEffect::ExportIni(QFile &fout, const QString &Status) const -{ - LogExportStart("StatusEffect", id); - Ini exStatusEffect("statusEffect " + status); - exStatusEffect.AddField("id", id); - exStatusEffect.AddField("effect", effect); - exStatusEffect.AddField("val1", val1); - exStatusEffect.AddField("val2", val2); - exStatusEffect.Export(fout); - LogExportOver("StatusEffect", id); -} - -void PokeGen::PokeMod::StatusEffect::SetEffect(const unsigned e) -{ - LogSetVar("StatusEffect", id, "effect", e); - if (e < SE_END) - { - effect = e; - val1 = UINT_MAX; - val2 = UINT_MAX; - } -} - -void PokeGen::PokeMod::StatusEffect::SetEffect(const QString &e) -{ - SetEffect(FindIn(SE_END, e, StatusEffectStr)); -} - -void PokeGen::PokeMod::StatusEffect::SetVal1(const unsigned v1) -{ - LogSetVar("StatusEffect", id, "val1", v1); - switch (effect) - { -// LogNoUse("StatusEffect", id, "val1", v1, "effect", StatusEffectStr[effect]); -// LogOutOfRange("StatusEffect", id, "val1", v1, "effect", StatusEffectStr[effect]); - default: - LogNotSet("StatusEffect", id, "val1", v1, "effect"); - } -} - -void PokeGen::PokeMod::StatusEffect::SetVal2(const unsigned v2) -{ - LogSetVar("StatusEffect", id, "val2", v2); - switch (effect) - { -// LogNoUse("StatusEffect", id, "val2", v2, "effect", StatusEffectStr[effect]); -// LogOutOfRange("StatusEffect", id, "val2", v2, "effect", StatusEffectStr[effect]); - default: - LogNotSet("StatusEffect", id, "val2", v2, "effect"); - } -} - -void PokeGen::PokeMod::StatusEffect::SetVal2(const QString &v2) -{ - switch (effect) - { -// LogNoUse("StatusEffect", id, "val2", v2, "effect", StatusEffectStr[effect]); -// SetVal2(FindIn(BM_END, v2, BattleMemberStr)); - default: - LogNotSet("StatusEffect", id, "val2", v2, "effect"); - } -} - -unsigned PokeGen::PokeMod::StatusEffect::GetEffect() const -{ - LogFetchVar("StatusEffect", id, "effect", effect); - return effect; -} - -QString PokeGen::PokeMod::StatusEffect::GetEffectString() const -{ - LogFetchVar("StatusEffect", id, "effect string", effect); - if (effect < SE_END) - return StatusEffectStr[effect]; - return ""; -} - -unsigned PokeGen::PokeMod::StatusEffect::GetVal1() const -{ - LogFetchVar("StatusEffect", id, "val1", val1); - return val1; -} - -unsigned PokeGen::PokeMod::StatusEffect::GetVal2() const -{ - LogFetchVar("StatusEffect", id, "val2", val2); - return val2; -} - -QString PokeGen::PokeMod::StatusEffect::GetVal2String() const -{ - LogFetchVar("StatusEffect", id, "val2 string", val2); - QString ret; - switch (effect) - { -// ret = BattleMemberStr[val2]; - } - return ret; -} +///////////////////////////////////////////////////////////////////////////// +// Name: pokemod/StatusEffect.cpp +// Purpose: Define an effect of a status +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Sat June 2 2007 12:16:48 +// 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 +// MERCHANTStatus 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 . +///////////////////////////////////////////////////////////////////////////// + +#include "StatusEffect.h" + +PokeGen::PokeMod::StatusEffect::StatusEffect(const Pokemod* par, const unsigned _id) : + Object(_id, par), + effect(UINT_MAX), + val1(UINT_MAX), + val2(UINT_MAX) +{ +} + +PokeGen::PokeMod::StatusEffect::StatusEffect(const Pokemod* par, Ini& ini, const unsigned _id) : + Object(_id, par) +{ + ImportIni(ini, _id); +} + +bool PokeGen::PokeMod::StatusEffect::Validate() +{ + pokemod->ValidationMsg(QString("------Effect with id %1---").arg(id), Pokemod::V_Msg); + if (effect < E_End) + { + bool ok = true; + switch (effect) + { + //case : + if (1) + ok = false; + break; + } + if (!ok) + { + pokemod->ValidationMsg("Invalid val1"); + isValid = false; + ok = true; + } + switch (effect) + { + //case : + if (1) + ok = false; + break; + } + if (!ok) + { + pokemod->ValidationMsg("Invalid val1"); + isValid = false; + } + } + else + { + pokemod->ValidationMsg("Invalid effect"); + isValid = false; + } + // TODO (Ben#1#): Status Effect Validation + return isValid; +} + +void PokeGen::PokeMod::StatusEffect::ImportIni(Ini& ini, const unsigned _id) +{ + if (_id == UINT_MAX) + ini.GetValue("id", id); + else + id = _id; + ini.GetValue("effect", effect); + ini.GetValue("val1", val1); + ini.GetValue("val2", val2); +} + +void PokeGen::PokeMod::StatusEffect::ExportIni(QFile& fout, const QString& status) const +{ + Ini exStatusEffect("statusEffect " + status); + exStatusEffect.AddField("id", id); + exStatusEffect.AddField("effect", effect); + exStatusEffect.AddField("val1", val1); + exStatusEffect.AddField("val2", val2); + exStatusEffect.Export(fout); +} + +bool PokeGen::PokeMod::StatusEffect::SetEffect(const unsigned e) +{ + if (e < E_End) + { + effect = e; + val1 = UINT_MAX; + val2 = UINT_MAX; + } + return (effect == e); +} + +bool PokeGen::PokeMod::StatusEffect::SetVal1(const unsigned v1) +{ + switch (effect) + { + } + return (val1 == v1); +} + +bool PokeGen::PokeMod::StatusEffect::SetVal2(const unsigned v2) +{ + switch (effect) + { + } + return (val2 == v2); +} + +unsigned PokeGen::PokeMod::StatusEffect::GetEffect() const +{ + return effect; +} + +unsigned PokeGen::PokeMod::StatusEffect::GetVal1() const +{ + return val1; +} + +unsigned PokeGen::PokeMod::StatusEffect::GetVal2() const +{ + return val2; +} -- cgit