/* * Copyright 2008 Ben Boeckel * * 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 . */ // Header include #include "Trainer.h" // Sigmod includes #include "Macros.h" #include "Sigmod.h" const QStringList Sigmod::Trainer::IntelligenceStr = QStringList() << "Ignorant" << "Remember" << "Cheating"; Sigmod::Trainer::Trainer(const Trainer& trainer) : Object(trainer.parent(), trainer.id()) { *this = trainer; } Sigmod::Trainer::Trainer(const Sigmod* parent, const int id) : Object(parent, id), m_name(""), m_moneyFactor(0), m_skin(-1), m_depth(0), m_teamIntel(Remember), m_moveIntel(Remember), m_itemIntel(Remember), m_abilityIntel(Remember), m_statIntel(Remember) { } Sigmod::Trainer::Trainer(const Trainer& trainer, const Sigmod* parent, const int id) : Object(parent, id) { *this = trainer; } Sigmod::Trainer::Trainer(const QDomElement& xml, const Sigmod* parent, const int id) : Object(parent, id) { LOAD_ID(); load(xml); } void Sigmod::Trainer::validate() { TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); TEST(moneyFactor); TEST(skin); TEST(depth); TEST_END(); } void Sigmod::Trainer::load(const QDomElement& xml) { LOAD_BEGIN(); LOAD(name); LOAD(moneyFactor); LOAD(skin); LOAD(depth); LOAD(teamIntel); LOAD(moveIntel); LOAD(itemIntel); LOAD(abilityIntel); LOAD(statIntel); } QDomElement Sigmod::Trainer::save() const { SAVE_CREATE(); SAVE(name); SAVE(moneyFactor); SAVE(skin); SAVE(depth); SAVE(teamIntel); SAVE(moveIntel); SAVE(itemIntel); SAVE(abilityIntel); SAVE(statIntel); return xml; } SETTER(Trainer, QString&, Name, name) SETTER(Trainer, int, MoneyFactor, moneyFactor) SETTER(Trainer, int, Skin, skin) SETTER(Trainer, int, Depth, depth) SETTER(Trainer, Intelligence, TeamIntel, teamIntel) SETTER(Trainer, Intelligence, MoveIntel, moveIntel) SETTER(Trainer, Intelligence, ItemIntel, itemIntel) SETTER(Trainer, Intelligence, AbilityIntel, abilityIntel) SETTER(Trainer, Intelligence, StatIntel, statIntel) GETTER(Trainer, QString, name) GETTER(Trainer, int, moneyFactor) GETTER(Trainer, int, skin) GETTER(Trainer, int, depth) GETTER(Trainer, Sigmod::Trainer::Intelligence, teamIntel) GETTER(Trainer, Sigmod::Trainer::Intelligence, moveIntel) GETTER(Trainer, Sigmod::Trainer::Intelligence, itemIntel) GETTER(Trainer, Sigmod::Trainer::Intelligence, abilityIntel) GETTER(Trainer, Sigmod::Trainer::Intelligence, statIntel) CHECK(Trainer, QString&, name) CHECK_BOUNDS(Trainer, int, moneyFactor, 0, INT_MAX) CHECK_INDEX(Trainer, int, skin, sigmod(), skin) CHECK_BOUNDS(Trainer, int, depth, 0, INT_MAX) CHECK(Trainer, Intelligence, teamIntel) CHECK(Trainer, Intelligence, moveIntel) CHECK(Trainer, Intelligence, itemIntel) CHECK(Trainer, Intelligence, abilityIntel) CHECK(Trainer, Intelligence, statIntel) Sigmod::Trainer& Sigmod::Trainer::operator=(const Trainer& rhs) { if (this == &rhs) return *this; COPY(name); COPY(moneyFactor); COPY(skin); COPY(depth); COPY(teamIntel); COPY(moveIntel); COPY(itemIntel); COPY(abilityIntel); COPY(statIntel); return *this; }