From fac9e51b6ec4e41d777c176e9bb1fadc0f9bc906 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 29 Dec 2008 10:57:12 -0500 Subject: Finished up converting classes to use CHECK macros --- sigmod/Trainer.cpp | 129 +++++++++++++---------------------------------------- 1 file changed, 32 insertions(+), 97 deletions(-) (limited to 'sigmod/Trainer.cpp') diff --git a/sigmod/Trainer.cpp b/sigmod/Trainer.cpp index 702c6f5e..d7a08618 100644 --- a/sigmod/Trainer.cpp +++ b/sigmod/Trainer.cpp @@ -62,8 +62,9 @@ void Sigmod::Trainer::validate() TEST_BEGIN(); if (m_name.isEmpty()) emit(error("Name is empty")); - TEST(setMoneyFactor, moneyFactor); - TEST(setSkin, skin); + TEST(moneyFactor); + TEST(skin); + TEST(depth); TEST_END(); } @@ -96,101 +97,35 @@ QDomElement Sigmod::Trainer::save() const 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; -} +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) { -- cgit