///////////////////////////////////////////////////////////////////////////// // Name: pokemod/MapTrainerTeam.cpp // Purpose: Define a Pokémon on a trainer's team // Author: Ben Boeckel // Modified by: Ben Boeckel // Created: Tue Mar 20 19:20:21 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 "MapTrainerTeam.h" PokeGen::PokeMod::MapTrainerTeam::MapTrainerTeam(const Pokemod *par, const unsigned _id) : species(UINT_MAX), level(1), item(UINT_MAX) { LogCtor("MapTrainerTeam", _id); id = _id; pokemod = par; } PokeGen::PokeMod::MapTrainerTeam::MapTrainerTeam(const Pokemod *par, Ini &ini, const unsigned _id) { LogCtorIni("MapTrainerTeam", _id); pokemod = par; ImportIni(ini, _id); if (id == UINT_MAX) LogIdError("MapTrainerTeam"); } PokeGen::PokeMod::MapTrainerTeam::~MapTrainerTeam() { LogDtor("MapTrainerTeam", id, GetSpeciesString()); } void PokeGen::PokeMod::MapTrainerTeam::Validate() { LogValidateStart("MapTrainerTeam", id); if (!pokemod->GetPokemon(species)) { LogVarNotValid("MapTrainerTeam", id, "species"); isValid = false; } if (pokemod->GetMaxLevel() <= level) { LogOutOfRange("MapTrainerTeam", id, "level", level, GetSpeciesString()); isValid = false; } if (!pokemod->GetItem(item)) { LogVarNotValid("MapTrainerTeam", id, "item"); isValid = false; } LogValidateOver("MapTrainerTeam", id, isValid, GetSpeciesString()); } #ifdef PG_DEBUG_WINDOW void PokeGen::PokeMod::MapTrainerTeam::Validate(const wxListBox &output) { LogValidateStart("MapTrainerTeam", id); if (!pokemod->GetPokemon(species)) { LogVarNotValid("MapTrainerTeam", id, "species", species); output.Append(ConsoleLogVarNotValid("MapTrainerTeam", id, "species", species)); isValid = false; } if (pokemod->GetMaxLevel() <= level) { LogVarOutOfRange("MapTrainerTeam", id, "level", level, GetSpeciesString()); output.Append(ConsoleLogVarOutOfRange("MapTrainerTeam", id, "level", level, GetSpeciesString())); isValid = false; } if (!pokemod->GetItem(item)) { LogVarNotValid("MapTrainerTeam", id, "item", item); output.Append(ConsoleLogVarNotValid("MapTrainerTeam", id, "item", item)); isValid = false; } LogValidateOver("MapTrainerTeam", id, isValid, GetSpeciesString()); } #endif void PokeGen::PokeMod::MapTrainerTeam::ImportIni(Ini &ini, const unsigned _id) { LogImportStart("MapTrainerTeam"); if (_id == UINT_MAX) { ini.GetValue("id", id); if (id == UINT_MAX) LogIdNotFound("MapTrainerTeam"); } else id = _id; ini.GetValue("species", species); ini.GetValue("level", level, 1); ini.GetValue("item", item); LogImportOver("MapTrainerTeam", id); } void PokeGen::PokeMod::MapTrainerTeam::ExportIni(std::ofstream &fout, const String &map, const unsigned trainerId) const { LogExportStart("MapTrainerTeam", id); Ini exMapTrainerTeam(String("MapTrainerTeam %u ", trainerId) + map); exMapTrainerTeam.AddField("id", id); exMapTrainerTeam.AddField("species", species); exMapTrainerTeam.AddField("level", level); exMapTrainerTeam.AddField("item", item); exMapTrainerTeam.Export(fout); LogExportOver("MapTrainerTeam", id); } void PokeGen::PokeMod::MapTrainerTeam::SetSpecies(const unsigned s) { LogSetVar("MapTrainerTeam", id, "species", s); if (pokemod->GetPokemon(s)) species = s; } void PokeGen::PokeMod::MapTrainerTeam::SetSpecies(const String &s) { LogSetVar("MapTrainerTeam", id, "species string", s); if (const Pokemon *p = pokemod->GetPokemon(s)) species = p->GetId(); } void PokeGen::PokeMod::MapTrainerTeam::SetLevel(const unsigned l) { LogSetVar("MapTrainerTeam", id, "level", l, GetSpeciesString()); if (l <= pokemod->GetMaxLevel()) level = l; } void PokeGen::PokeMod::MapTrainerTeam::SetItem(const unsigned i) { LogSetVar("MapTrainerTeam", id, "item", i, GetSpeciesString()); if (pokemod->GetItem(i)) item = i; } void PokeGen::PokeMod::MapTrainerTeam::SetItem(const String &i) { LogSetVar("MapTrainerTeam", id, "item string", i, GetSpeciesString()); if (const Item *temp = pokemod->GetItem(i)) item = temp->GetId(); } unsigned PokeGen::PokeMod::MapTrainerTeam::GetSpecies() const { LogFetchVar("MapTrainerTeam", id, "speceis", species); return species; } PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainerTeam::GetSpeciesString() const { LogFetchVar("MapTrainerTeam", id, "species string", species); if (const Pokemon *p = pokemod->GetPokemon(species)) return p->GetName(); return ""; } unsigned PokeGen::PokeMod::MapTrainerTeam::GetLevel() const { LogFetchVar("MapTrainerTeam", id, "level", level, GetSpeciesString()); return level; } unsigned PokeGen::PokeMod::MapTrainerTeam::GetItem() const { LogFetchVar("MapTrainerTeam", id, "item", item, GetSpeciesString()); return item; } PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainerTeam::GetItemString() const { LogFetchVar("MapTrainerTeam", id, "item string", item, GetSpeciesString()); if (const Item *i = pokemod->GetItem(item)) i->GetName(); return ""; }