diff options
Diffstat (limited to 'sigmod/Sigmod.cpp')
| -rw-r--r-- | sigmod/Sigmod.cpp | 117 |
1 files changed, 40 insertions, 77 deletions
diff --git a/sigmod/Sigmod.cpp b/sigmod/Sigmod.cpp index 576eec0b..a916e39c 100644 --- a/sigmod/Sigmod.cpp +++ b/sigmod/Sigmod.cpp @@ -285,7 +285,7 @@ void Sigmod::Sigmod::load(const QDomElement& xml) LOAD(singlePlayer); LOAD(startMap); LOAD(startWarp); - LOAD_Rules(); + m_rules->load(xml.firstChildElement("Rules")); LOAD_SUB(newAbility, Ability); LOAD_SUB(newAuthor, Author); LOAD_SUB(newBadge, Badge); @@ -348,53 +348,13 @@ QDomElement Sigmod::Sigmod::save() const return xml; } -void Sigmod::Sigmod::setTitle(const QString& title) -{ - CHECK(title); -} - -void Sigmod::Sigmod::setVersion(const QString& version) -{ - CHECK(version); -} - -void Sigmod::Sigmod::setDescription(const QString& description) -{ - CHECK(description); -} - -void Sigmod::Sigmod::setSinglePlayer(const bool singlePlayer) -{ - CHECK(singlePlayer); -} - -void Sigmod::Sigmod::setStartMap(const int startMap) -{ - if (!m_singlePlayer) - emit(error(unused("startMap"))); - if (!mapById(startMap)) - emit(error(bounds("startMap", startMap))); - else - CHECK(startMap); -} - -void Sigmod::Sigmod::setStartWarp(const int startWarp) -{ - if (!m_singlePlayer) - emit(error(unused("startWarp"))); - const Map* map = mapById(m_startMap); - if (!map) - emit(error(bounds("startMap", m_startMap))); - else if (!map->warpById(startWarp)) - emit(error(bounds("startWarp", startWarp))); - else - CHECK(startWarp); -} - -void Sigmod::Sigmod::setTypechart(const int attack, const int defense, const Sigcore::Fraction& multiplier) -{ - CHECK_ARRAY(typechart(attack, defense), multiplier); -} +SETTER(Sigmod, QString&, Title, title) +SETTER(Sigmod, QString&, Version, version) +SETTER(Sigmod, QString&, Description, description) +SETTER(Sigmod, bool, SinglePlayer, singlePlayer) +SETTER(Sigmod, int, StartMap, startMap) +SETTER(Sigmod, int, StartWarp, startWarp) +SETTER_MATRIX(Sigmod, Sigcore::Fraction&, Typechart, typechart, multiplier) void Sigmod::Sigmod::setRules(const Rules& rules) { @@ -406,35 +366,12 @@ void Sigmod::Sigmod::setRules(const QDomElement& xml) m_rules->load(xml); } -QString Sigmod::Sigmod::title() const -{ - return m_title; -} - -QString Sigmod::Sigmod::version() const -{ - return m_version; -} - -QString Sigmod::Sigmod::description() const -{ - return m_description; -} - -bool Sigmod::Sigmod::singlePlayer() const -{ - return m_singlePlayer; -} - -int Sigmod::Sigmod::startMap() const -{ - return m_startMap; -} - -int Sigmod::Sigmod::startWarp() const -{ - return m_startWarp; -} +GETTER(Sigmod, QString, title) +GETTER(Sigmod, QString, version) +GETTER(Sigmod, QString, description) +GETTER(Sigmod, bool, singlePlayer) +GETTER(Sigmod, int, startMap) +GETTER(Sigmod, int, startWarp) const Sigcore::Matrix<Sigcore::Fraction>* Sigmod::Sigmod::typechart() const { @@ -461,6 +398,32 @@ Sigmod::Rules* Sigmod::Sigmod::rules() return m_rules; } +CHECK(Sigmod, QString&, title) +CHECK(Sigmod, QString&, version) +CHECK(Sigmod, QString&, description) +CHECK(Sigmod, bool, singlePlayer) +CHECK_BEGIN(Sigmod, int, startMap) + if (!m_singlePlayer) + { + emit(error(unused("startMap"))); + return false; + } + if (!mapById(startMap)) + EBOUNDS_IDX(startMap); +CHECK_END() +CHECK_BEGIN(Sigmod, int, startWarp) + if (!m_singlePlayer) + { + emit(error(unused("startWarp"))); + return false; + } + const Map* map = mapById(m_startMap); + if (!map) + EBOUNDS_IDX(m_startMap); + IBOUNDS(startWarp, map, warp); +CHECK_END() +CHECK_BOUNDS(Sigmod, Sigcore::Fraction&, typechart, 0, INT_MAX) + const Sigmod::Ability* Sigmod::Sigmod::ability(const int index) const { if (index < abilityCount()) |
