/* * 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(setMoneyFactor, moneyFactor); TEST(setSkin, skin); 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; } void Sigmod::Trainer::setName(const QString& name) { CHECK(name); } void Sigmod::Trainer::setMoneyFactor(const int moneyFactor) { if (moneyFactor < 0) emit(error(bounds("moneyFactor", 0, INT_MAX, moneyFactor))); else CHECK(moneyFactor); } void Sigmod::Trainer::setSkin(const int skin) { if (!sigmod()->skinById(skin)) emit(error(bounds("skin", skin))); else CHECK(skin); } void Sigmod::Trainer::setDepth(const int depth) { CHECK(depth); } void Sigmod::Trainer::setTeamIntel(const Intelligence teamIntel) { CHECK(teamIntel); } void Sigmod::Trainer::setMoveIntel(const Intelligence moveIntel) { CHECK(moveIntel); } void Sigmod::Trainer::setItemIntel(const Intelligence itemIntel) { CHECK(itemIntel); } void Sigmod::Trainer::setAbilityIntel(const Intelligence abilityIntel) { CHECK(abilityIntel); } void Sigmod::Trainer::setStatIntel(const Intelligence statIntel) { CHECK(statIntel); } QString Sigmod::Trainer::name() const { return m_name; } int Sigmod::Trainer::moneyFactor() const { return m_moneyFactor; } int Sigmod::Trainer::skin() const { return m_skin; } int Sigmod::Trainer::depth() const { return m_depth; } Sigmod::Trainer::Intelligence Sigmod::Trainer::teamIntel() const { return m_teamIntel; } Sigmod::Trainer::Intelligence Sigmod::Trainer::moveIntel() const { return m_moveIntel; } Sigmod::Trainer::Intelligence Sigmod::Trainer::itemIntel() const { return m_itemIntel; } Sigmod::Trainer::Intelligence Sigmod::Trainer::abilityIntel() const { return m_abilityIntel; } Sigmod::Trainer::Intelligence Sigmod::Trainer::statIntel() const { return m_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; }