///////////////////////////////////////////////////////////////////////////// // 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 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 "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); } #ifdef PG_DEBUG_WINDOW void PokeGen::PokeMod::MoveEffect::Validate(const wxListBox &output) #else void PokeGen::PokeMod::MoveEffect::Validate() #endif { 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(std::ofstream &fout, const String &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 String &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 String &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; } PokeGen::PokeMod::String 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; } PokeGen::PokeMod::String PokeGen::PokeMod::MoveEffect::GetVal2String() const { LogFetchVar("MoveEffect", id, "val2 string", val2); // TODO (Ben#1#): Val2 string return ""; }