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/PokemonNature.cpp | 154 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 154 insertions(+) create mode 100644 pokemod/PokemonNature.cpp (limited to 'pokemod/PokemonNature.cpp') diff --git a/pokemod/PokemonNature.cpp b/pokemod/PokemonNature.cpp new file mode 100644 index 00000000..7bc972bc --- /dev/null +++ b/pokemod/PokemonNature.cpp @@ -0,0 +1,154 @@ +///////////////////////////////////////////////////////////////////////////// +// Name: pokemod/PokemonNature.cpp +// Purpose: Define an nature that a Pokémon can have +// Author: Ben Boeckel +// Modified by: Ben Boeckel +// Created: Tue Mar 20 18:39:17 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 "PokemonNature.h" + +extern PokeGen::PokeMod::Pokemod curPokeMod; + +PokeGen::PokeMod::PokemonNature::PokemonNature(unsigned _id) +{ + LogCtor("PokemonNature", _id); + nature = -1; + weight = 1; + id = _id; +} + +PokeGen::PokeMod::PokemonNature::PokemonNature(Ini &ini, unsigned _id) +{ + LogCtorIni("PokemonNature", _id); + ImportIni(ini, _id); + if(_id == UINT_MAX) + LogIdError("PokemonNature"); +} + +PokeGen::PokeMod::PokemonNature::~PokemonNature() +{ + LogDtor("PokemonNature", id, GetNatureString()); +} + +void PokeGen::PokeMod::PokemonNature::Validate() +{ + isValid = true; + LogValidateStart("PokemonNature", id); + if (!curPokeMod.GetNature(nature)) + { + LogVarNotValid("PokemonNature", id, "nature"); + isValid = false; + } + if (!weight) + { + LogVarNotSet("PokemonNature", id, "weight", GetNatureString()); + isValid = false; + } + LogValidateOver("PokemonNature", id, isValid, GetNatureString()); +} + +#ifdef PG_DEBUG_WINDOW +void PokeGen::PokeMod::PokemonNature::Validate(const wxListBox &output) +{ + isValid = true; + LogValidateStart("PokemonNature", id); + if (!curPokeMod.GetNature(nature)) + { + LogVarNotValid("PokemonNature", id, "nature"); + output.Append(ConsoleLogVarNotValid("PokemonNature", id, "nature")); + isValid = false; + } + if (!weight) + { + LogVarNotSet("PokemonNature", id, "weight", GetNatureString()); + output.Append(ConsoleLogVarNotSet("PokemonNature", id, weight, GetNatureString()); + isValid = false; + } + LogValidateOver("PokemonNature", id, isValid, GetNatureString()); +} +#endif + +void PokeGen::PokeMod::PokemonNature::ImportIni(Ini &ini, unsigned _id) +{ + LogImportStart("PokemonNature"); + if (_id == UINT_MAX) + { + ini.GetValue("id", id, UINT_MAX); + // Was there an id associated with the element? + if (id == UINT_MAX) + LogIdNotFound("PokemonNature"); + } + else + id = _id; + ini.GetValue("nature", nature, -1); + ini.GetValue("weight", weight, 1); + LogImportOver("PokemonNature", id); +} + +void PokeGen::PokeMod::PokemonNature::ExportIni(std::ofstream &fout) const +{ + LogExportStart("PokemonNature", id); + // Make elements + Ini exPokemonNature("PokemonNature"); + exPokemonNature.AddField("id", id); + exPokemonNature.AddField("nature", nature); + exPokemonNature.AddField("weight", weight); + exPokemonNature.Export(fout); + LogExportOver("PokemonNature", id); +} + +void PokeGen::PokeMod::PokemonNature::SetNature(int n) +{ + LogSetVar("PokemonNature", id, "nature", n); + nature = n; +} + +void PokeGen::PokeMod::PokemonNature::SetNature(const String &n) +{ + LogSetVar("PokemonNature", id, "nature", n); + if (Nature *temp = curPokeMod.GetNature(n)) + nature = temp->GetId(); +} + +void PokeGen::PokeMod::PokemonNature::SetWeight(unsigned w) +{ + LogSetVar("PokemonNature", id, "weight", w, GetNatureString()); + if (w) + weight = w; +} + +int PokeGen::PokeMod::PokemonNature::GetNature() const +{ + LogFetchVar("PokemonNature", id, "nature", nature); + return nature; +} + +PokeGen::PokeMod::String PokeGen::PokeMod::PokemonNature::GetNatureString() const +{ + LogFetchVar("PokemonNature", id, "nature string", nature); + if (Nature *n = curPokeMod.GetNature(nature)) + return n->GetName(); + return ""; +} + +unsigned PokeGen::PokeMod::PokemonNature::GetWeight() const +{ + LogFetchVar("PokemonNature", id, "weight", weight, GetNatureString()); + return weight; +} -- cgit