///////////////////////////////////////////////////////////////////////////// // Name: pokemod/EggGroup.cpp // Purpose: Define a breeding gourp // Author: Ben Boeckel // Modified by: Ben Boeckel // Created: Tue Mar 20 18:05:05 2007 // Copyright: ©2007-2008 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 "Pokemod.h" #include "EggGroup.h" EggGroup::EggGroup(const Pokemod* par, const int _id) : Object("EggGroup", par, _id), name("") { } EggGroup::EggGroup(const Pokemod* par, const EggGroup& e, const int _id) : Object("EggGroup", par, _id) { *this = e; } EggGroup::EggGroup(const Pokemod* par, const QString& fname, const int _id) : Object("EggGroup", par, _id) { load(fname, _id); } bool EggGroup::validate() const { bool valid = true; pokemod->validationMsg(QString("---Egg Group \"%1\" with id %2---").arg(name).arg(id), Pokemod::V_Msg); if (name == "") { pokemod->validationMsg("Name is not defined"); valid = false; } return valid; } void EggGroup::load(const QString& fname, const int _id) throw(Exception) { Ini ini(fname); if (_id == -1) ini.getValue("id", id); else id = _id; ini.getValue("name", name); } void EggGroup::save() const throw(Exception) { Ini ini; ini.addField("id", id); ini.addField("name", name); ini.save(QString("%1/egggroup/%2.pini").arg(pokemod->getPath()).arg(name)); } void EggGroup::setName(const QString& n) { name = n; } QString EggGroup::getName() const { return name; } EggGroup& EggGroup::operator=(const EggGroup& rhs) { if (this == &rhs) return *this; name = rhs.name; return *this; }