From 1a4b623c8ecb9d0c7d991312c12d78be4a68eff2 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Wed, 23 May 2007 02:24:14 +0000 Subject: Added more 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@13 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokemod/MapWildPokemon.cpp | 184 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 184 insertions(+) create mode 100644 pokemod/MapWildPokemon.cpp (limited to 'pokemod/MapWildPokemon.cpp') diff --git a/pokemod/MapWildPokemon.cpp b/pokemod/MapWildPokemon.cpp new file mode 100644 index 00000000..765142b6 --- /dev/null +++ b/pokemod/MapWildPokemon.cpp @@ -0,0 +1,184 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokemod/MapWildPokemon.cpp +// Purpose: Define a Pokémon that can be found in the wild +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Tue Mar 20 18:50:59 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 "MapWildPokemon.h" + +extern PokeGen::PokeMod::Pokemod curPokeMod; + +PokeGen::PokeMod::MapWildPokemon::MapWildPokemon(unsigned _id) +{ + LogCtor("MapWildPokemon", _id); + pokemon = -1; + level = 1; + weight = 1; + id = _id; +} + +PokeGen::PokeMod::MapWildPokemon::MapWildPokemon(Ini &ini, unsigned _id) +{ + LogCtorIni("MapWildPokemon", _id); + ImportIni(ini); + if (id == UINT_MAX) + LogIdError("MapWildPokemon"); +} + +PokeGen::PokeMod::MapWildPokemon::~MapWildPokemon() +{ + LogDtor("MapWildPokemon", id, GetPokemonString()); +} + +void PokeGen::PokeMod::MapWildPokemon::Validate() +{ + isValid = true; + LogValidateStart("MapWildPokemon", id, GetPokemonString()); + if (!curPokeMod.GetPokemon(pokemon)) + { + LogVarNotValid("MapWildPokemon", id, "pokemon"); + output.Append(ConsoleLogVarNotValid("MapWildPokemon", id, "pokemon")); + isValid = false; + } + if (curPokeMod.GetMaxLevel() <= level) + { + LogVarNotValid("MapWildPokemon", id, "level", GetPokemonString()); + output.Append(ConsoleLogVarNotValid("MapWildPokemon", id, "level", GetPokemonString())); + isValid = false; + } + if (!weight) + { + LogVarNotValid("MapWildPokemon", id, "weight", GetPokemonString()); + output.Append(ConsoleLogVarNotValid("MapWildPokemon", id, "weight", GetPokemonString())); + isValid = false; + } + LogValidateOver("MapWildPokemon", id, isValid, GetPokemonString()); +} + +#ifdef PG_DEBUG_WINDOW +void PokeGen::PokeMod::MapWildPokemon::Validate(const wxListBox &output) +{ + isValid = true; + LogValidateStart("MapWildPokemon", id, GetPokemonString()); + if (!curPokeMod.GetPokemon(pokemon)) + { + LogVarNotValid("MapWildPokemon", id, "pokemon"); + output.Append(ConsoleLogVarNotValid("MapWildPokemon", id, "pokemon")); + isValid = false; + } + if (curPokeMod.GetMaxLevel() <= level) + { + LogVarNotValid("MapWildPokemon", id, "level", GetPokemonString()); + output.Append(ConsoleLogVarNotValid("MapWildPokemon", id, "level", GetPokemonString())); + isValid = false; + } + if (!weight) + { + LogVarNotValid("MapWildPokemon", id, "weight", GetPokemonString()); + output.Append(ConsoleLogVarNotValid("MapWildPokemon", id, "weight", GetPokemonString())); + isValid = false; + } + LogValidateOver("MapWildPokemon", id, isValid, GetPokemonString()); +} +#endif + +void PokeGen::PokeMod::MapWildPokemon::ImportIni(Ini &ini, unsigned _id) +{ + LogImportStart("MapWildPokemon"); + if (_id == UINT_MAX) + { + ini.GetValue("id", id, UINT_MAX); + // Was there an id associated with the element? + if (id == UINT_MAX) + LogIdNotFound("MapWildPokemon"); + } + else + id = _id; + ini.GetValue("pokemon", pokemon, -1); + ini.GetValue("level", level, 1); + ini.GetValue("weight", weight, 1); + LogImportOver("MapWildPokemon", id, name); +} + +void PokeGen::PokeMod::MapWildPokemon::ExportIni(std::ofstream &fout, const String &map, const unsigned listId) const +{ + LogExportStart("MapWildPokemon", id, name); + // Make elements + Ini exMapWildPokemon(map + String(" %u mapWildPokemon", listId)); + exMapWildPokemon.AddField("id", id); + exMapWildPokemon.AddField("pokemon", pokemon); + exMapWildPokemon.AddField("level", level); + exMapWildPokemon.AddField("weight", weight); + exMapWildPokemon.Export(fout); + LogExportOver("MapWildPokemon", id, name); +} + +void PokeGen::PokeMod::MapWildPokemon::SetPokemon(int p) +{ + LogSetVar("MapWildPokemon", id, "pokemon", p); + if (curPokeMod.GetPokemon(p)) + pokemon = p; +} + +void PokeGen::PokeMod::MapWildPokemon::SetPokemon(const String &p) +{ + LogSetVar("MapWildPokemon", id, "pokemon string", p); + if (Pokemon *pok = curPokeMod.GetPokemon(p)) + pokemon = pok->GetId(); +} + +void PokeGen::PokeMod::MapWildPokemon::SetLevel(unsigned l) +{ + LogSetVar("MapWildPokemon", id, "level", l, GetPokemonString()); + level = l; +} + +void PokeGen::PokeMod::MapWildPokemon::SetWeight(unsigned w) +{ + LogSetVar("MapWildPokemon", id, "weight", w, GetPokemonString()); + if (w) + weight = w; +} + +int PokeGen::PokeMod::MapWildPokemon::GetPokemon() const +{ + LogFetchVar("MapWildPokemon", id, "pokemon", pokemon); + return pokemon; +} + +PokeGen::PokeMod::String PokeGen::PokeMod::MapWildPokemon::GetPokemonString() const +{ + LogFetchVar("MapWildPokemon", id, "pokemon string", pokemon); + if (Pokemon *p = curPokeMod.GetPokemon(pokemon)) + return p->GetName(); + return ""; +} + +unsigned PokeGen::PokeMod::MapWildPokemon::GetLevel() const +{ + LogFetchVar("MapWildPokemon", id, "level", level, GetPokemonString()); + return level; +} + +unsigned PokeGen::PokeMod::MapWildPokemon::GetWeight() const +{ + LogFetchVar("MapWildPokemon", id, "weight", weight, GetPokemonString()); + return weight; +} -- cgit