///////////////////////////////////////////////////////////////////////////// // Name: pokemod/SpeciesItem.cpp // Purpose: Define an item that a species can be found with in the wild // Author: Ben Boeckel // Modified by: Ben Boeckel // Created: Tue Mar 20 18:40:28 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 3 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, see . ///////////////////////////////////////////////////////////////////////////// #include "SpeciesItem.h" PokeGen::PokeMod::SpeciesItem::SpeciesItem(const Pokemod* par, const unsigned _id) : Object(_id, par), item(UINT_MAX), weight(1) { } PokeGen::PokeMod::SpeciesItem::SpeciesItem(const Pokemod* par, Ini& ini, const unsigned _id) : Object(_id, par) { ImportIni(ini, _id); } bool PokeGen::PokeMod::SpeciesItem::Validate() { pokemod->ValidationMsg(QString("------Item with id %1---").arg(id), Pokemod::V_Msg); if (pokemod->GetItemByID(item) == UINT_MAX) { pokemod->ValidationMsg("Invalid item"); isValid = false; } if (!weight) { pokemod->ValidationMsg("Invalid weight"); isValid = false; } return isValid; } void PokeGen::PokeMod::SpeciesItem::ImportIni(Ini& ini, const unsigned _id) { if (_id == UINT_MAX) ini.GetValue("id", id); else id = _id; ini.GetValue("item", item); ini.GetValue("weight", weight, 1); } void PokeGen::PokeMod::SpeciesItem::ExportIni(QFile& fout, const QString& species) const { Ini exSpeciesItem("speciesItem " + species); exSpeciesItem.AddField("id", id); exSpeciesItem.AddField("item", item); exSpeciesItem.AddField("weight", weight); exSpeciesItem.Export(fout); } bool PokeGen::PokeMod::SpeciesItem::SetItem(const unsigned i) { if (pokemod->GetItemByID(i) != UINT_MAX) item = i; return (item == i); } bool PokeGen::PokeMod::SpeciesItem::SetWeight(const unsigned w) { if (w) weight = w; return (weight == w); } unsigned PokeGen::PokeMod::SpeciesItem::GetItem() const { return item; } unsigned PokeGen::PokeMod::SpeciesItem::GetWeight() const { return weight; }