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/PokemonEvolution.cpp | 235 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 235 insertions(+) create mode 100644 pokemod/PokemonEvolution.cpp (limited to 'pokemod/PokemonEvolution.cpp') diff --git a/pokemod/PokemonEvolution.cpp b/pokemod/PokemonEvolution.cpp new file mode 100644 index 00000000..c355a89c --- /dev/null +++ b/pokemod/PokemonEvolution.cpp @@ -0,0 +1,235 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokemod/PokemonEvolution.cpp +// Purpose: Define an evolution that a Pokémon can go through +// 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 "PokemonEvolution.h" + +extern PokeGen::PokeMod::Pokemod curPokeMod; + +PokeGen::PokeMod::PokemonEvolution::PokemonEvolution(unsigned _id) +{ + LogCtor("PokemonEvolution", _id); + species = -1; + style = 0; + level = 0; + item = -1; + happiness = 0; + id = _id; +} + +PokeGen::PokeMod::PokemonEvolution::PokemonEvolution(Ini &ini, unsigned _id) +{ + LogCtorIni("PokemonEvolution", _id); + ImportIni(ini); + if(_id == UINT_MAX) + LogIdError("PokemonEvolution"); +} + +PokeGen::PokeMod::PokemonEvolution::~PokemonEvolution() +{ + LogDtor("PokemonEvolution", id); +} + +void PokeGen::PokeMod::PokemonEvolution::Validate() +{ + isValid = true; + LogValidateStart("PokemonEvolution", id); + if (!curPokeMod.GetPokemon(species)) + { + LogVarNotValid("PokemonEvolution", id, "species"); + isValid = false; + } + if (STY_END <= style) + { + LogVarNotValid("PokemonEvolution", id, "style"); + isValid = false; + } + if (curPokeMod.GetMaxLevel() <= level) + { + LogVarNotValid("PokemonEvolution", id, "level"); + isValid = false; + } + if (!curPokeMod.GetItem(item)) + { + LogVarNotValid("PokemonEvolution", id, "species"); + isValid = false; + } + LogValidateOver("PokemonEvolution", id, isValid); +} + +#ifdef PG_DEBUG_WINDOW +void PokeGen::PokeMod::PokemonEvolution::Validate(const wxListBox &output) +{ + isValid = true; + LogValidateStart("PokemonEvolution", id); + if (!curPokeMod.GetPokemon(species)) + { + LogVarNotValid("PokemonEvolution", id, "species"); + output.Append(ConsoleLogVarNotValid("PokemonEvolution", id, "move")); + isValid = false; + } + if (STY_END <= style) + { + LogVarNotValid("PokemonEvolution", id, "style"); + output.Append("Error (PokemonEvolution): Style out of range"); + isValid = false; + } + if (curPokeMod.GetMaxLevel() <= level) + { + LogVarNotValid("PokemonEvolution", id, "level"); + output.Append("Error (PokemonEvolution): Level out of range"); + isValid = false; + } + if (!curPokeMod.GetItem(item)) + { + LogVarNotValid("PokemonEvolution", id, "species"); + output.Append(ConsoleLogVarNotValid("PokemonEvolution", id, "species")); + isValid = false; + } + LogValidateOver("PokemonEvolution", id, isValid); +} +#endif + +void PokeGen::PokeMod::PokemonEvolution::ImportIni(Ini &ini, unsigned _id) +{ + LogImportStart("PokemonEvolution"); + if (_id == UINT_MAX) + { + ini.GetValue("id", id, UINT_MAX); + // Was there an id associated with the element? + if (id == UINT_MAX) + LogIdNotFound("PokemonEvolution"); + } + else + id = _id; + ini.GetValue("species", species, -1); + ini.GetValue("style", style, 0); + ini.GetValue("level", level, 0); + ini.GetValue("item", item, -1); + ini.GetValue("happiness", happiness, 0); + LogImportOver("PokemonEvolution", id); +} + +void PokeGen::PokeMod::PokemonEvolution::ExportIni(std::ofstream &fout) const +{ + LogExportStart("PokemonEvolution", id); + // Make elements + Ini exPokemonEvolution("PokemonEvolution"); + exPokemonEvolution.AddField("id", id); + exPokemonEvolution.AddField("species", species); + exPokemonEvolution.AddField("style", style); + exPokemonEvolution.AddField("level", level); + exPokemonEvolution.AddField("item", item); + exPokemonEvolution.AddField("happiness", happiness); + exPokemonEvolution.Export(fout); + LogExportOver("PokemonEvolution", id); +} + +void PokeGen::PokeMod::PokemonEvolution::SetSpecies(int s) +{ + LogSetVar("PokemonEvolution", id, "species", s); + species = s; +} + +void PokeGen::PokeMod::PokemonEvolution::SetSpecies(const String &s) +{ + LogSetVar("PokemonEvolution", id, "species", s); + if (Pokemon *temp = curPokeMod.GetPokemon(s)) + species = temp->GetId(); +} + +void PokeGen::PokeMod::PokemonEvolution::SetStyle(int s) +{ + LogSetVar("PokemonEvolution", id, "style", s); + style = s; +} + +void PokeGen::PokeMod::PokemonEvolution::SetLevel(unsigned l) +{ + LogSetVar("PokemonEvolution", id, "level", l); + level = l; +} + +void PokeGen::PokeMod::PokemonEvolution::SetItem(int i) +{ + LogSetVar("PokemonEvolution", id, "item", i); + item = i; +} + +void PokeGen::PokeMod::PokemonEvolution::SetItem(const String &i) +{ + LogSetVar("PokemonEvolution", id, "item", i); + if (Item *temp = curPokeMod.GetItem(i)) + item = temp->GetId(); +} + +void PokeGen::PokeMod::PokemonEvolution::SetHappiness(unsigned h) +{ + LogSetVar("PokemonEvolution", id, "happiness", h); + happiness = h; +} + +int PokeGen::PokeMod::PokemonEvolution::GetSpecies() +{ + LogFetchVar("PokemonEvolution", id, "species", species); + return species; +} + +PokeGen::PokeMod::String PokeGen::PokeMod::PokemonEvolution::GetSpeciesString() +{ + LogFetchVar("PokemonEvolution", id, "species string", species); + if (Pokemon *s = curPokeMod.GetPokemon(species)) + return s->GetName(); + return ""; +} + +int PokeGen::PokeMod::PokemonEvolution::GetStyle() +{ + LogFetchVar("PokemonEvolution", id, "style", style); + return style; +} + +unsigned PokeGen::PokeMod::PokemonEvolution::GetLevel() +{ + LogFetchVar("PokemonEvolution", id, "level", level); + return level; +} + +int PokeGen::PokeMod::PokemonEvolution::GetItem() +{ + LogFetchVar("PokemonEvolution", id, "item", item); + return item; +} + +PokeGen::PokeMod::String PokeGen::PokeMod::PokemonEvolution::GetItemString() +{ + LogFetchVar("PokemonEvolution", id, "item string", item); + if (Item *i = curPokeMod.GetItem(item)) + return i->GetName(); + return ""; +} + +unsigned PokeGen::PokeMod::PokemonEvolution::GetHappiness() +{ + LogFetchVar("PokemonEvolution", id, "happiness", happiness); + return happiness; +} -- cgit