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/MapTrainerTeam.cpp | 200 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 200 insertions(+) create mode 100644 pokemod/MapTrainerTeam.cpp (limited to 'pokemod/MapTrainerTeam.cpp') diff --git a/pokemod/MapTrainerTeam.cpp b/pokemod/MapTrainerTeam.cpp new file mode 100644 index 00000000..bc069497 --- /dev/null +++ b/pokemod/MapTrainerTeam.cpp @@ -0,0 +1,200 @@ +///////////////////////////////////////////////////////////////////////////// +// 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" + +extern PokeGen::PokeMod::Pokemod curPokeMod; + +PokeGen::PokeMod::MapTrainerTeam::MapTrainerTeam(unsigned _id) +{ + LogCtor("MapTrainerTeam", _id); + species = -1; + level = 1; + item = -1; + id = _id; +} + +PokeGen::PokeMod::MapTrainerTeam::MapTrainerTeam(Ini &ini, unsigned _id) +{ + LogCtorIni("MapTrainerTeam", _id); + ImportIni(ini); + if (id == UINT_MAX) + LogIdError("MapTrainerTeam"); +} + +PokeGen::PokeMod::MapTrainerTeam::~MapTrainerTeam() +{ + LogDtor("MapTrainerTeam", id, GetSpeciesString()); +} + +void PokeGen::PokeMod::MapTrainerTeam::Validate() +{ + isValid = true; + LogValidateStart("MapTrainerTeam", id); + if (!curPokeMod.GetPokemon(species)) + { + LogVarNotValid("MapTrainerTeam", id, "species", species); + output.Append(ConsoleLogVarNotValid("MapTrainerTeam", id, "species", species)); + isValid = false; + } + if (curPokeMod.GetMaxLevel() <= level) + { + LogVarOutOfRange("MapTrainerTeam", id, "level", level, GetSpeciesString()); + output.Append(ConsoleLogVarOutOfRange("MapTrainerTeam", id, "level", level, GetSpeciesString())); + isValid = false; + } + if ((item != -1) && !curPokeMod.GetItem(item)) + { + LogVarNotValid("MapTrainerTeam", id, "item", item); + output.Append(ConsoleLogVarNotValid("MapTrainerTeam", id, "item", item)); + isValid = false; + } + LogValidateOver("MapTrainerTeam", id, isValid, GetSpeciesString()); +} + +#ifdef PG_DEBUG_WINDOW +void PokeGen::PokeMod::MapTrainerTeam::Validate(const wxListBox &output) +{ + isValid = true; + LogValidateStart("MapTrainerTeam", id); + if (!curPokeMod.GetPokemon(species)) + { + LogVarNotValid("MapTrainerTeam", id, "species", species); + output.Append(ConsoleLogVarNotValid("MapTrainerTeam", id, "species", species)); + isValid = false; + } + if (curPokeMod.GetMaxLevel() <= level) + { + LogVarOutOfRange("MapTrainerTeam", id, "level", level, GetSpeciesString()); + output.Append(ConsoleLogVarOutOfRange("MapTrainerTeam", id, "level", level, GetSpeciesString())); + isValid = false; + } + if ((item != -1) && !curPokeMod.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, unsigned _id) +{ + LogImportStart("MapTrainerTeam"); + if (_id == UINT_MAX) + { + ini.GetValue("id", id, UINT_MAX); + // Was there an id associated with the element? + if (id == UINT_MAX) + LogIdNotFound("MapTrainerTeam"); + } + else + id = _id; + ini.GetValue("species", species, -1); + ini.GetValue("level", level, 1); + ini.GetValue("item", item, -1); + LogImportOver("MapTrainerTeam", id); +} + +void PokeGen::PokeMod::MapTrainerTeam::ExportIni(Ini &ini, const String &map, unsigned trainerId) const +{ + LogExportStart("MapTrainerTeam", id); + // Make elements + Ini exMapTrainerTeam(map + String(" %u MapTrainerTeam", trainerId)); + 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(int s) +{ + LogSetVar("MapTrainerTeam", id, "species", s); + if (curPokeMod.GetPokemon(s)) + species = s; +} + +void PokeGen::PokeMod::MapTrainerTeam::SetSpecies(const String &s) +{ + LogSetVar("MapTrainerTeam", id, "species string", s); + if (Pokemon *p = curPokeMod.GetPokemon(s)) + species = p->GetId(); +} + +void PokeGen::PokeMod::MapTrainerTeam::SetLevel(unsigned l) +{ + LogSetVar("MapTrainerTeam", id, "level", l, GetSpeciesString()); + if (l <= curPokeMod.GetMaxLevel()) + level = l; +} + +void PokeGen::PokeMod::MapTrainerTeam::SetItem(int i) +{ + LogSetVar("MapTrainerTeam", id, "item", i, GetSpeciesString()); + if (curPokeMod.GetItem(i)) + item = i; +} + +void PokeGen::PokeMod::MapTrainerTeam::SetItem(const String &i) +{ + LogSetVar("MapTrainerTeam", id, "item string", i, GetSpeciesString()); + if (Item *item = curPokeMod.GetItem(i)) + item = item->GetId(); +} + +int 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 (Pokemon *p = curPokeMod.GetPokemon(species)) + return p->GetName(); + return ""; +} + +unsigned PokeGen::PokeMod::MapTrainerTeam::GetLevel() const +{ + LogFetchVar("MapTrainerTeam", id, "level", level, GetSpeceisString()); + return level; +} + +int PokeGen::PokeMod::MapTrainerTeam::GetItem() const +{ + LogFetchVar("MapTrainerTeam", id, "item", item, GetSpeceisString()); + return item; +} + +PokeGen::PokeMod::String PokeGen::PokeMod::MapTrainerTeam::GetItemString() const +{ + LogFetchVar("MapTrainerTeam", id, "item string", item, GetSpeciesString()); + if (Item *i = curPokeMod.GetItem(item)) + i->GetName(); + return ""; +} -- cgit