summaryrefslogtreecommitdiffstats
path: root/sigmod/Nature.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'sigmod/Nature.cpp')
-rw-r--r--sigmod/Nature.cpp68
1 files changed, 25 insertions, 43 deletions
diff --git a/sigmod/Nature.cpp b/sigmod/Nature.cpp
index f69dcda8..802349a7 100644
--- a/sigmod/Nature.cpp
+++ b/sigmod/Nature.cpp
@@ -60,7 +60,17 @@ void Sigmod::Nature::validate()
TEST_BEGIN();
if (m_name.isEmpty())
emit(error("Name is empty"));
- TEST(setWeight, weight);
+ TEST_ARRAY_INDEX(stat, ST_Attack);
+ TEST_ARRAY_INDEX(stat, ST_Defense);
+ TEST_ARRAY_INDEX(stat, ST_Speed);
+ if (sigmod()->rules()->specialSplit())
+ {
+ TEST_ARRAY_INDEX(stat, ST_SpecialAttack);
+ TEST_ARRAY_INDEX(stat, ST_SpecialDefense);
+ }
+ else
+ TEST_ARRAY_INDEX(stat, ST_Special);
+ TEST(weight);
TEST_END();
}
@@ -81,57 +91,29 @@ QDomElement Sigmod::Nature::save() const
return xml;
}
-void Sigmod::Nature::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::Nature::setStat(const Stat stat, const Sigcore::Fraction& multiplier)
-{
- switch (stat)
- {
- case ST_SpecialDefense:
- if (sigmod()->rules()->specialSplit())
- case ST_Attack ... ST_Special:
- break;
- default:
- emit(warning(bounds("stat", "Attack", sigmod()->rules()->specialSplit() ? "SpecialDefense" : "Special", stat)));
- return;
- }
- CHECK_ARRAY(stat[stat - ST_Attack], multiplier);
-}
-
-void Sigmod::Nature::setWeight(const int weight)
-{
- if (weight <= 0)
- emit(error(bounds("weight", 1, INT_MAX, weight)));
- else
- CHECK(weight);
-}
+SETTER(Nature, QString&, Name, name)
+SETTER_ARRAY(Nature, Sigcore::Fraction&, Stat, stat, multiplier, Stat, stat, ST_Attack)
+SETTER(Nature, int, Weight, weight)
-QString Sigmod::Nature::name() const
-{
- return m_name;
-}
+GETTER(Nature, QString, name)
+GETTER_ARRAY(Nature, Sigcore::Fraction, stat, multiplier, Stat, stat, ST_Attack)
+GETTER(Nature, int, weight)
-Sigcore::Fraction Sigmod::Nature::stat(const Stat stat) const
-{
+CHECK(Nature, QString&, name)
+CHECK_BEGIN_ARRAY(Nature, Sigcore::Fraction&, stat, multiplier, Stat, stat)
switch (stat)
{
case ST_SpecialDefense:
if (sigmod()->rules()->specialSplit())
case ST_Attack ... ST_Special:
- return m_stat[stat - ST_Attack];
+ break;
default:
- emit(warning(bounds("stat", "Attack", sigmod()->rules()->specialSplit() ? "SpecialDefense" : "Special", stat)));
- return Sigcore::Fraction();
+ EBOUNDS(stat, "Attack", sigmod()->rules()->specialSplit() ? "SpecialDefense" : "Special");
+ return false;
}
-}
-
-int Sigmod::Nature::weight() const
-{
- return m_weight;
-}
+ TBOUNDS(multiplier, 1, INT_MAX)
+CHECK_END()
+CHECK_BOUNDS(Nature, int, weight, 1, INT_MAX)
Sigmod::Nature& Sigmod::Nature::operator=(const Nature& rhs)
{