From e858d98977a09b3c8faf4df87ada4abc1399e8e5 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Tue, 22 May 2007 03:51:45 +0000 Subject: Added a lot of minor PokéMod modules 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@12 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/PokemonMove.cpp | 179 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 179 insertions(+) create mode 100644 pokemod/PokemonMove.cpp (limited to 'pokemod/PokemonMove.cpp') diff --git a/pokemod/PokemonMove.cpp b/pokemod/PokemonMove.cpp new file mode 100644 index 00000000..6af754d7 --- /dev/null +++ b/pokemod/PokemonMove.cpp @@ -0,0 +1,179 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokemod/PokemonMove.cpp +// Purpose: Define a move that a Pokémon can learn +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Tue Mar 20 18:45:29 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 "PokemonMove.h" + +extern PokeGen::PokeMod::Pokemod curPokeMod; + +PokeGen::PokeMod::PokemonMove::PokemonMove(unsigned _id) +{ + LogCtor("PokemonMove", _id); + move = -1; + level = 0; + wild = 0; + id = _id; +} + +PokeGen::PokeMod::PokemonMove::PokemonMove(Ini &ini, unsigned _id) +{ + LogCtorIni("PokemonMove", _id); + ImportIni(ini); + if(_id == UINT_MAX) + LogIdError("PokemonMove"); +} + +PokeGen::PokeMod::PokemonMove::~PokemonMove() +{ + LogDtor("PokemonMove", id, GetMoveString()); +} + +void PokeGen::PokeMod::PokemonMove::Validate() +{ + isValid = true; + LogValidateStart("PokemonMove", id, GetMoveString()); + if (!curPokeMod.GetMove(move)) + { + LogVarNotValid("PokemonMove", id, "move"); + isValid = false; + } + if (curPokeMod.GetMaxLevel() <= level) + { + LogVarNotValid("PokemonMove", id, "level", GetMoveString()); + isValid = false; + } + if (curPokeMod.GetMaxLevel() <= wild) + { + LogVarNotValid("PokemonMove", id, "wild", GetMoveString()); + isValid = false; + } + LogValidateOver("PokemonMove", id, isValid, GetMoveString()); +} + +#ifdef PG_DEBUG_WINDOW +void PokeGen::PokeMod::PokemonMove::Validate(const wxListBox &output) +{ + isValid = true; + LogValidateStart("PokemonMove", id, GetMoveString()); + if (!curPokeMod.GetMove(move)) + { + LogVarNotValid("PokemonMove", id, "move"); + output.Append(ConsoleLogVarNotValid("PokemonMove", id, "move")); + isValid = false; + } + if (curPokeMod.GetMaxLevel() <= level) + { + LogVarNotValid("PokemonMove", id, "level", GetMoveString()); + output.Append(ConsoleLogVarNotValid("PokemonMove", id, "level", GetMoveString())); + isValid = false; + } + if (curPokeMod.GetMaxLevel() <= wild) + { + LogVarNotValid("PokemonMove", id, "wild", GetMoveString()); + output.Append(ConsoleLogVarNotValid("PokemonMove", id, "wild", GetMoveString())); + isValid = false; + } + LogValidateOver("PokemonMove", id, isValid, GetMoveString()); +} +#endif + +void PokeGen::PokeMod::PokemonMove::ImportIni(Ini &ini, unsigned _id) +{ + LogImportStart("PokemonMove"); + if (_id == UINT_MAX) + { + ini.GetValue("id", id, UINT_MAX); + // Was there an id associated with the element? + if (id == UINT_MAX) + LogIdNotFound("PokemonMove"); + } + else + id = _id; + ini.GetValue("move", move, -1); + ini.GetValue("level", level, 0); + ini.GetValue("wild", wild, 0); + LogImportOver("PokemonMove", id); +} + +void PokeGen::PokeMod::PokemonMove::ExportIni(std::ofstream &fout) const +{ + LogExportStart("PokemonMove", id); + // Make elements + Ini exPokemonMove("pokemonMove"); + exPokemonMove.AddField("id", id); + exPokemonMove.AddField("move", move); + exPokemonMove.AddField("level", level); + exPokemonMove.AddField("wild", wild); + exPokemonMove.Export(fout); + LogExportOver("PokemonMove", id); +} + +void PokeGen::PokeMod::PokemonMove::SetMove(int m) +{ + LogSetVar("PokemonMove", id, "move", m); + move = m; +} + +void PokeGen::PokeMod::PokemonMove::SetMove(const String &m) +{ + LogSetVar("PokemonMove", id, "move", m); + if (Move *temp = curPokeMod.GetMove(m)) + move = temp->GetId(); +} + +void PokeGen::PokeMod::PokemonMove::SetLevel(unsigned l) +{ + LogSetVar("PokemonMove", id, "level", l, GetMoveString()); + level = l; +} + +void PokeGen::PokeMod::PokemonMove::SetWild(unsigned w) +{ + LogSetVar("PokemonMove", id, "wild", w, GetMoveString()); + wild = w; +} + +int PokeGen::PokeMod::PokemonMove::GetMove() const +{ + LogFetchVar("PokemonMove", id, "move", move); + return move; +} + +PokeGen::PokeMod::String PokeGen::PokeMod::PokemonMove::GetMoveString() const +{ + LogFetchVar("PokemonMove", id, "move string", move); + if (Move *m = curPokeMod.GetMove(move)) + m->GetName(); + return ""; +} + +unsigned PokeGen::PokeMod::PokemonMove::GetLevel() const +{ + LogFetchVar("PokemonMove", id, "level", level, GetMoveString()); + return level; +} + +unsigned PokeGen::PokeMod::PokemonMove::GetWild() const +{ + LogFetchVar("PokemonMove", id, "wild", wild, GetMoveString()); + return wild; +} -- cgit