summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-12-29 10:56:06 -0500
committerBen Boeckel <MathStuf@gmail.com>2008-12-29 10:56:06 -0500
commit0f2a0fe8bcbeefa62d0fd4fae89f0de6610fe993 (patch)
treec00997c3ed1d1caad0ca20c7301965f7afde5335
parent61d2f8e4768c0767a64c85aa2b69cfb19d068d61 (diff)
downloadsigen-0f2a0fe8bcbeefa62d0fd4fae89f0de6610fe993.tar.gz
sigen-0f2a0fe8bcbeefa62d0fd4fae89f0de6610fe993.tar.xz
sigen-0f2a0fe8bcbeefa62d0fd4fae89f0de6610fe993.zip
Species* classes now use CHECK macros
-rw-r--r--sigmod/Species.cpp526
-rw-r--r--sigmod/Species.h33
-rw-r--r--sigmod/SpeciesAbility.cpp33
-rw-r--r--sigmod/SpeciesAbility.h3
-rw-r--r--sigmod/SpeciesItem.cpp33
-rw-r--r--sigmod/SpeciesItem.h3
-rw-r--r--sigmod/SpeciesMove.cpp51
-rw-r--r--sigmod/SpeciesMove.h4
8 files changed, 204 insertions, 482 deletions
diff --git a/sigmod/Species.cpp b/sigmod/Species.cpp
index 3d0eb4fd..00fe6062 100644
--- a/sigmod/Species.cpp
+++ b/sigmod/Species.cpp
@@ -97,21 +97,44 @@ void Sigmod::Species::validate()
TEST_BEGIN();
if (m_name.isEmpty())
emit(error("Name is empty"));
- TEST_ARRAY(setBaseStat, baseStat, ST_SpecialDefense - ST_HP + 1);
- TEST_ARRAY(setEffortValue, effortValue, ST_SpecialDefense - ST_HP + 1);
- TEST(setGrowth, growth);
- TEST(setRunChance, runChance);
- TEST(setFleeChance, fleeChance);
- TEST(setItemChance, itemChance);
- TEST(setWeight, weight);
- TEST(setFrontMaleSprite, frontMaleSprite);
- TEST(setBackMaleSprite, backMaleSprite);
- TEST(setFrontFemaleSprite, frontFemaleSprite);
- TEST(setBackFemaleSprite, backFemaleSprite);
- TEST(setSkin, skin);
- if ((m_encyclopediaNumber != INT_MAX) && m_encyclopediaEntry.isEmpty())
+ TEST_ARRAY_INDEX(baseStat, ST_HP);
+ TEST_ARRAY_INDEX(baseStat, ST_Attack);
+ TEST_ARRAY_INDEX(baseStat, ST_Defense);
+ TEST_ARRAY_INDEX(baseStat, ST_Speed);
+ if (sigmod()->rules()->specialSplit())
+ {
+ TEST_ARRAY_INDEX(baseStat, ST_SpecialAttack);
+ TEST_ARRAY_INDEX(baseStat, ST_SpecialDefense);
+ }
+ else
+ TEST_ARRAY_INDEX(baseStat, ST_Special);
+ TEST_ARRAY_INDEX(effortValue, ST_HP);
+ TEST_ARRAY_INDEX(effortValue, ST_Attack);
+ TEST_ARRAY_INDEX(effortValue, ST_Defense);
+ TEST_ARRAY_INDEX(effortValue, ST_Speed);
+ if (sigmod()->rules()->specialSplit())
+ {
+ TEST_ARRAY_INDEX(effortValue, ST_SpecialAttack);
+ TEST_ARRAY_INDEX(effortValue, ST_SpecialDefense);
+ }
+ else
+ TEST_ARRAY_INDEX(effortValue, ST_Special);
+ TEST(growth);
+ TEST(experienceValue);
+ TEST(maxHoldWeight);
+ TEST(runChance);
+ TEST(fleeChance);
+ TEST(itemChance);
+ TEST(encyclopediaNumber);
+ TEST(weight);
+ TEST(frontMaleSprite);
+ TEST(backMaleSprite);
+ TEST(frontFemaleSprite);
+ TEST(backFemaleSprite);
+ TEST(skin);
+ if ((m_encyclopediaNumber != -1) && m_encyclopediaEntry.isEmpty())
emit(error("Encyclopedia entry is empty"));
- TEST(setGenderFactor, genderFactor);
+ TEST(genderFactor);
if (sigmod()->rules()->breedingAllowed())
{
const Species* eggSpecies = sigmod()->speciesById(m_eggSpecies);
@@ -121,11 +144,11 @@ void Sigmod::Species::validate()
{
if (eggSpecies->growth() != m_growth)
emit(error("Growth mismatch with egg species"));
- TEST(setEggSteps, eggSteps);
+ TEST(eggSteps);
}
}
- TEST_LIST(setType, type);
- TEST_LIST(setEggGroup, eggGroup);
+ TEST_LIST(type);
+ TEST_LIST(eggGroup);
QSet<int> idChecker;
QSet<int> valueChecker;
if (abilityCount() < sigmod()->rules()->maxAbilities())
@@ -211,7 +234,7 @@ QDomElement Sigmod::Species::save() const
SAVE(genderFactor);
SAVE(eggSpecies);
SAVE(eggSteps);
- SAVE_LIST( type);
+ SAVE_LIST(type);
SAVE_LIST(eggGroup);
SAVE(evolution);
SAVE_SUB(SpeciesAbility, abilities);
@@ -220,18 +243,60 @@ QDomElement Sigmod::Species::save() const
return xml;
}
-void Sigmod::Species::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::Species::setBaseStat(const Stat stat, const int baseStat)
-{
- if (baseStat <= 0)
- {
- emit(error(bounds("baseStat", 1, INT_MAX, baseStat)));
- return;
- }
+SETTER(Species, QString&, Name, name)
+SETTER_ARRAY(Species, int, BaseStat, baseStat, baseStat, Stat, stat, ST_HP)
+SETTER_ARRAY(Species, int, EffortValue, effortValue, effortValue, Stat, stat, ST_HP)
+SETTER(Species, Style, Growth, growth)
+SETTER(Species, int, ExperienceValue, experienceValue)
+SETTER(Species, int, CatchValue, catchValue)
+SETTER(Species, int, MaxHoldWeight, maxHoldWeight)
+SETTER(Species, Sigcore::Fraction&, RunChance, runChance)
+SETTER(Species, Sigcore::Fraction&, FleeChance, fleeChance)
+SETTER(Species, Sigcore::Fraction&, ItemChance, itemChance)
+SETTER(Species, int, EncyclopediaNumber, encyclopediaNumber)
+SETTER(Species, int, Weight, weight)
+SETTER(Species, int, Height, height)
+SETTER(Species, int, FrontMaleSprite, frontMaleSprite)
+SETTER(Species, int, BackMaleSprite, backMaleSprite)
+SETTER(Species, int, FrontFemaleSprite, frontFemaleSprite)
+SETTER(Species, int, BackFemaleSprite, backFemaleSprite)
+SETTER(Species, int, Skin, skin)
+SETTER(Species, QString&, EncyclopediaEntry, encyclopediaEntry)
+SETTER(Species, Sigcore::Fraction&, GenderFactor, genderFactor)
+SETTER(Species, int, EggSpecies, eggSpecies)
+SETTER(Species, int, EggSteps, eggSteps)
+SETTER_LIST(Species, Type, type)
+SETTER_LIST(Species, EggGroup, eggGroup)
+SETTER(Species, Sigcore::Script&, Evolution, evolution)
+
+GETTER(Species, QString, name)
+GETTER_ARRAY(Species, int, baseStat, baseStat, Stat, stat, ST_HP)
+GETTER_ARRAY(Species, int, effortValue, effortValue, Stat, stat, ST_HP)
+GETTER(Species, Sigmod::Species::Style, growth)
+GETTER(Species, int, experienceValue)
+GETTER(Species, int, catchValue)
+GETTER(Species, int, maxHoldWeight)
+GETTER(Species, Sigcore::Fraction, runChance)
+GETTER(Species, Sigcore::Fraction, fleeChance)
+GETTER(Species, Sigcore::Fraction, itemChance)
+GETTER(Species, int, encyclopediaNumber)
+GETTER(Species, int, weight)
+GETTER(Species, int, height)
+GETTER(Species, int, frontMaleSprite)
+GETTER(Species, int, backMaleSprite)
+GETTER(Species, int, frontFemaleSprite)
+GETTER(Species, int, backFemaleSprite)
+GETTER(Species, int, skin)
+GETTER(Species, QString, encyclopediaEntry)
+GETTER(Species, Sigcore::Fraction, genderFactor)
+GETTER(Species, int, eggSpecies)
+GETTER(Species, int, eggSteps)
+GETTER_LIST(Species, type)
+GETTER_LIST(Species, eggGroup)
+GETTER(Species, Sigcore::Script, evolution)
+
+CHECK(Species, QString&, name)
+CHECK_BEGIN_ARRAY(Species, int, baseStat, baseStat, Stat, stat)
switch (stat)
{
case ST_SpecialDefense:
@@ -239,24 +304,12 @@ void Sigmod::Species::setBaseStat(const Stat stat, const int baseStat)
case ST_HP ... ST_Special:
break;
default:
- emit(warning(bounds("stat", "HP", sigmod()->rules()->specialSplit() ? "SpecialDefense" : "Special", stat)));
- return;
+ EBOUNDS(stat, "HP", sigmod()->rules()->specialSplit() ? "SpecialDefense" : "Special");
+ return false;
}
- CHECK_ARRAY(baseStat[stat], baseStat);
-}
-
-void Sigmod::Species::setBaseStat(const int baseStat)
-{
- if (baseStat <= 0)
- emit(error(bounds("baseStat", 1, INT_MAX, baseStat)));
-}
-
-void Sigmod::Species::setEffortValue(const Stat stat, const int effortValue)
-{
- if (!sigmod()->rules()->effortValuesAllowed())
- emit(error("Effort Values not allowed"));
- else if ((effortValue < 0) || (sigmod()->rules()->maxEVPerStat() < effortValue))
- emit(error(bounds("effortValue", 0, sigmod()->rules()->maxEVPerStat(), effortValue)));
+ TBOUNDS(baseStat, 1, INT_MAX)
+CHECK_END()
+CHECK_BEGIN_ARRAY(Species, int, effortValue, effortValue, Stat, stat)
switch (stat)
{
case ST_SpecialDefense:
@@ -264,348 +317,45 @@ void Sigmod::Species::setEffortValue(const Stat stat, const int effortValue)
case ST_HP ... ST_Special:
break;
default:
- emit(warning(bounds("stat", "HP", sigmod()->rules()->specialSplit() ? "SpecialDefense" : "Special", stat)));
- return;
+ EBOUNDS(stat, "HP", sigmod()->rules()->specialSplit() ? "SpecialDefense" : "Special");
+ return false;
}
- CHECK_ARRAY(effortValue[stat], effortValue);
-}
-
-void Sigmod::Species::setEffortValue(const int effortValue)
-{
- if (sigmod()->rules()->effortValuesAllowed() && sigmod()->rules()->maxEVPerStat() < effortValue)
- emit(error(bounds("effortValue", 0, sigmod()->rules()->maxEVPerStat(), effortValue)));
-}
-
-void Sigmod::Species::setGrowth(const Style growth)
-{
- CHECK(growth);
-}
-
-void Sigmod::Species::setExperienceValue(const int experienceValue)
-{
- CHECK(experienceValue);
-}
-
-void Sigmod::Species::setCatchValue(const int catchValue)
-{
- if ((catchValue <= 0) || (255 < catchValue))
- emit(error(bounds("catchValue", 1, 255, catchValue)));
- else
- CHECK(catchValue);
-}
-
-void Sigmod::Species::setMaxHoldWeight(const int maxHoldWeight)
-{
- CHECK(maxHoldWeight);
-}
-
-void Sigmod::Species::setRunChance(const Sigcore::Fraction& runChance)
-{
- if ((runChance < 0) || (1 < runChance))
- emit(error(bounds("runChance", 0, 1, runChance)));
- else
- CHECK(runChance);
-}
-
-void Sigmod::Species::setFleeChance(const Sigcore::Fraction& fleeChance)
-{
- if ((fleeChance < 0) || (1 < fleeChance))
- emit(error(bounds("fleeChance", 0, 1, fleeChance)));
- else
- CHECK(fleeChance);
-}
-
-void Sigmod::Species::setItemChance(const Sigcore::Fraction& itemChance)
-{
- if ((itemChance < 0) || (1 < itemChance))
- emit(error(bounds("itemChance", 0, 1, itemChance)));
- else
- CHECK(itemChance);
-}
-
-void Sigmod::Species::setEncyclopediaNumber(const int encyclopediaNumber)
-{
- CHECK(encyclopediaNumber);
-}
-
-void Sigmod::Species::setWeight(const int weight)
-{
- CHECK(weight);
-}
-
-void Sigmod::Species::setHeight(const int height)
-{
- CHECK(height);
-}
-
-void Sigmod::Species::setEncyclopediaEntry(const QString& encyclopediaEntry)
-{
- CHECK(encyclopediaEntry);
-}
-
-void Sigmod::Species::setFrontMaleSprite(const int frontMaleSprite)
-{
- if (m_genderFactor.numerator() == m_genderFactor.denominator())
- emit(error("Cannot be male"));
- else if (!sigmod()->spriteById(frontMaleSprite))
- emit(error(bounds("frontMaleSprite", frontMaleSprite)));
- else
- CHECK(frontMaleSprite);
-}
-
-void Sigmod::Species::setBackMaleSprite(const int backMaleSprite)
-{
- if (m_genderFactor.numerator() == m_genderFactor.denominator())
- emit(error("Cannot be male"));
- else if (!sigmod()->spriteById(backMaleSprite))
- emit(error(bounds("backMaleSprite", backMaleSprite)));
- else
- CHECK(backMaleSprite);
-}
-
-void Sigmod::Species::setFrontFemaleSprite(const int frontFemaleSprite)
-{
- if (!sigmod()->rules()->genderAllowed())
- emit(error("Gender is not allowed"));
- else if (!m_genderFactor.numerator())
- emit(error("Cannot be female"));
- else if (1 < m_genderFactor)
- emit(error("Genderless uses male sprites"));
- else if (!sigmod()->spriteById(frontFemaleSprite))
- emit(error(bounds("frontFemaleSprite", frontFemaleSprite)));
- else
- CHECK(frontFemaleSprite);
-}
-
-void Sigmod::Species::setBackFemaleSprite(const int backFemaleSprite)
-{
- if (!sigmod()->rules()->genderAllowed())
- emit(error("Gender is not allowed"));
- else if (!m_genderFactor.numerator())
- emit(error("Cannot be female"));
- else if (1 < m_genderFactor)
- emit(error("Genderless uses male sprites"));
- else if (!sigmod()->spriteById(backFemaleSprite))
- emit(error(bounds("backFemaleSprite", backFemaleSprite)));
- else
- CHECK(backFemaleSprite);
-}
-
-void Sigmod::Species::setSkin(const int skin)
-{
- if (!sigmod()->skinById(skin))
- emit(error(bounds("skin", skin)));
- else
- CHECK(skin);
-}
-
-void Sigmod::Species::setGenderFactor(const Sigcore::Fraction& genderFactor)
-{
- CHECK(genderFactor);
-}
-
-void Sigmod::Species::setEggSpecies(const int eggSpecies)
-{
- if (!sigmod()->speciesById(eggSpecies))
- emit(error(bounds("eggSpecies", eggSpecies)));
- else
- CHECK(eggSpecies);
-}
-
-void Sigmod::Species::setEggSteps(const int eggSteps)
-{
- CHECK(eggSteps);
-}
-
-void Sigmod::Species::setType(const int type, const bool state)
-{
- if (!sigmod()->typeById(type))
- emit(error(bounds("type", type)));
- else if (state && !m_type.contains(type))
- {
- m_type.append(type);
- emit(changed());
- }
- else if (m_type.contains(type))
- {
- m_type.removeAll(type);
- emit(changed());
- }
-}
-
-void Sigmod::Species::setEggGroup(const int eggGroup, const bool state)
-{
- if (!sigmod()->eggGroupById(eggGroup))
- emit(error(bounds("egg group", eggGroup)));
- else if (state && !m_eggGroup.contains(eggGroup))
- {
- m_eggGroup.append(eggGroup);
- emit(changed());
- }
- else if (m_eggGroup.contains(eggGroup))
- {
- m_eggGroup.removeAll(eggGroup);
- emit(changed());
- }
-}
-
-void Sigmod::Species::setEvolution(const Sigcore::Script& evolution)
-{
- CHECK(evolution);
-}
-
-QString Sigmod::Species::name() const
-{
- return m_name;
-}
-
-int Sigmod::Species::baseStat(const Stat stat) const
-{
- switch (stat)
- {
- case ST_SpecialDefense:
- if (sigmod()->rules()->specialSplit())
- case ST_HP ... ST_Special:
- return m_effortValue[stat];
- default:
- emit(warning(bounds("base stat", "Attack", sigmod()->rules()->specialSplit() ? "SpecialDefense" : "Special", stat)));
- return -1;
- }
-}
-
-int Sigmod::Species::effortValue(const Stat stat) const
-{
- switch (stat)
- {
- case ST_SpecialDefense:
- if (sigmod()->rules()->specialSplit())
- case ST_HP ... ST_Special:
- return m_effortValue[stat];
- default:
- emit(warning(bounds("effort value", "Attack", sigmod()->rules()->specialSplit() ? "SpecialDefense" : "Special", stat)));
- return -1;
- }
-}
-
-Sigmod::Species::Style Sigmod::Species::growth() const
-{
- return m_growth;
-}
-
-int Sigmod::Species::experienceValue() const
-{
- return m_experienceValue;
-}
-
-int Sigmod::Species::catchValue() const
-{
- return m_catchValue;
-}
-
-int Sigmod::Species::maxHoldWeight() const
-{
- return m_maxHoldWeight;
-}
-
-Sigcore::Fraction Sigmod::Species::runChance() const
-{
- return m_runChance;
-}
-
-Sigcore::Fraction Sigmod::Species::fleeChance() const
-{
- return m_fleeChance;
-}
-
-Sigcore::Fraction Sigmod::Species::itemChance() const
-{
- return m_itemChance;
-}
-
-int Sigmod::Species::encyclopediaNumber() const
-{
- return m_encyclopediaNumber;
-}
-
-int Sigmod::Species::weight() const
-{
- return m_weight;
-}
-
-int Sigmod::Species::height() const
-{
- return m_height;
-}
-
-QString Sigmod::Species::encyclopediaEntry() const
-{
- return m_encyclopediaEntry;
-}
-
-int Sigmod::Species::frontMaleSprite() const
-{
- return m_frontMaleSprite;
-}
-
-int Sigmod::Species::backMaleSprite() const
-{
- return m_backMaleSprite;
-}
-
-int Sigmod::Species::frontFemaleSprite() const
-{
- return m_frontFemaleSprite;
-}
-
-int Sigmod::Species::backFemaleSprite() const
-{
- return m_backFemaleSprite;
-}
-
-int Sigmod::Species::skin() const
-{
- return m_skin;
-}
-
-Sigcore::Fraction Sigmod::Species::genderFactor() const
-{
- return m_genderFactor;
-}
-
-int Sigmod::Species::eggSpecies() const
-{
- return m_eggSpecies;
-}
-
-int Sigmod::Species::eggSteps() const
-{
- return m_eggSteps;
-}
-
-bool Sigmod::Species::type(const int type) const
-{
- return m_type.contains(type);
-}
-
-QList<int> Sigmod::Species::types() const
-{
- return m_type;
-}
-
-bool Sigmod::Species::eggGroup(const int eggGroup) const
-{
- return m_eggGroup.contains(eggGroup);
-}
-
-QList<int> Sigmod::Species::eggGroups() const
-{
- return m_eggGroup;
-}
-
-Sigcore::Script Sigmod::Species::evolution() const
-{
- return m_evolution;
-}
+ TBOUNDS(effortValue, 0, sigmod()->rules()->maxEVPerStat() ? sigmod()->rules()->maxEVPerStat() : INT_MAX)
+CHECK_END()
+CHECK(Species, Style, growth)
+CHECK_BOUNDS(Species, int, experienceValue, 0, INT_MAX)
+CHECK_BOUNDS(Species, int, catchValue, 1, 255)
+CHECK_BOUNDS(Species, int, maxHoldWeight, 0, INT_MAX)
+CHECK_BOUNDS(Species, Sigcore::Fraction&, runChance, 0, 1)
+CHECK_BOUNDS(Species, Sigcore::Fraction&, fleeChance, 0, 1)
+CHECK_BOUNDS(Species, Sigcore::Fraction&, itemChance, 0, 1)
+CHECK_BOUNDS(Species, int, encyclopediaNumber, -1, INT_MAX)
+CHECK_BOUNDS(Species, int, weight, 0, INT_MAX)
+CHECK_BOUNDS(Species, int, height, 0, INT_MAX)
+CHECK_BEGIN(Species, int, frontMaleSprite)
+ if (m_genderFactor < 1)
+ IBOUNDS(frontMaleSprite, sigmod(), sprite);
+CHECK_END()
+CHECK_BEGIN(Species, int, backMaleSprite)
+ if (m_genderFactor < 1)
+ IBOUNDS(backMaleSprite, sigmod(), sprite);
+CHECK_END()
+CHECK_BEGIN(Species, int, frontFemaleSprite)
+ if (0 < m_genderFactor)
+ IBOUNDS(frontFemaleSprite, sigmod(), sprite);
+CHECK_END()
+CHECK_BEGIN(Species, int, backFemaleSprite)
+ if (0 < m_genderFactor)
+ IBOUNDS(backFemaleSprite, sigmod(), sprite);
+CHECK_END()
+CHECK_INDEX(Species, int, skin, sigmod(), skin)
+CHECK(Species, QString&, encyclopediaEntry)
+CHECK_BOUNDS(Species, Sigcore::Fraction&, genderFactor, -1, 1)
+CHECK_INDEX(Species, int, eggSpecies, sigmod(), species)
+CHECK_BOUNDS(Species, int, eggSteps, 1, INT_MAX)
+CHECK_INDEX(Species, int, type, sigmod(), type)
+CHECK_INDEX(Species, int, eggGroup, sigmod(), eggGroup)
+CHECK(Species, Sigcore::Script&, evolution)
const Sigmod::SpeciesAbility* Sigmod::Species::ability(const int index) const
{
diff --git a/sigmod/Species.h b/sigmod/Species.h
index 9d00eb4f..7adc375b 100644
--- a/sigmod/Species.h
+++ b/sigmod/Species.h
@@ -113,11 +113,37 @@ class SIGMOD_EXPORT Species : public Object
int eggSpecies() const;
int eggSteps() const;
bool type(const int type) const;
- QList<int> types() const;
+ QList<int> type() const;
bool eggGroup(const int eggGroup) const;
- QList<int> eggGroups() const;
+ QList<int> eggGroup() const;
Sigcore::Script evolution() const;
+ bool nameCheck(const QString& name) const;
+ bool baseStatCheck(const Stat stat, const int base) const;
+ bool effortValueCheck(const Stat stat, const int effortValue) const;
+ bool growthCheck(const Style growth) const;
+ bool experienceValueCheck(const int experienceValue) const;
+ bool catchValueCheck(const int catchValue) const;
+ bool maxHoldWeightCheck(const int maxHoldWeight) const;
+ bool runChanceCheck(const Sigcore::Fraction& runChance) const;
+ bool fleeChanceCheck(const Sigcore::Fraction& fleeChance) const;
+ bool itemChanceCheck(const Sigcore::Fraction& itemChance) const;
+ bool encyclopediaNumberCheck(const int encyclopediaNumber) const;
+ bool weightCheck(const int weight) const;
+ bool heightCheck(const int height) const;
+ bool encyclopediaEntryCheck(const QString& encyclopediaEntry) const;
+ bool frontMaleSpriteCheck(const int frontMaleSprite) const;
+ bool backMaleSpriteCheck(const int backMaleSprite) const;
+ bool frontFemaleSpriteCheck(const int frontFemaleSprite) const;
+ bool backFemaleSpriteCheck(const int backFemaleSprite) const;
+ bool genderFactorCheck(const Sigcore::Fraction& genderFactor) const;
+ bool skinCheck(const int skin) const;
+ bool eggSpeciesCheck(const int eggSpecies) const;
+ bool eggStepsCheck(const int eggSteps) const;
+ bool typeCheck(const int type) const;
+ bool eggGroupCheck(const int eggGroup) const;
+ bool evolutionCheck(const Sigcore::Script& evolution) const;
+
const SpeciesAbility* ability(const int index) const;
SpeciesAbility* ability(const int index);
const SpeciesAbility* abilityById(const int id) const;
@@ -156,9 +182,6 @@ class SIGMOD_EXPORT Species : public Object
Species& operator=(const Species& rhs);
private:
- void setBaseStat(const int baseStat);
- void setEffortValue(const int effortValue);
-
int newAbilityId() const;
SpeciesAbility* newAbility(SpeciesAbility* ability);
diff --git a/sigmod/SpeciesAbility.cpp b/sigmod/SpeciesAbility.cpp
index eea7a057..3941a43a 100644
--- a/sigmod/SpeciesAbility.cpp
+++ b/sigmod/SpeciesAbility.cpp
@@ -52,8 +52,8 @@ Sigmod::SpeciesAbility::SpeciesAbility(const QDomElement& xml, const Species* pa
void Sigmod::SpeciesAbility::validate()
{
TEST_BEGIN();
- TEST(setAbility, ability);
- TEST(setWeight, weight);
+ TEST(ability);
+ TEST(weight);
TEST_END();
}
@@ -72,31 +72,14 @@ QDomElement Sigmod::SpeciesAbility::save() const
return xml;
}
-void Sigmod::SpeciesAbility::setAbility(const int ability)
-{
- if (!sigmod()->abilityById(ability))
- emit(error(bounds("ability", ability)));
- else
- CHECK(ability);
-}
+SETTER(SpeciesAbility, int, Ability, ability)
+SETTER(SpeciesAbility, int, Weight, weight)
-void Sigmod::SpeciesAbility::setWeight(const int weight)
-{
- if (weight <= 0)
- emit(error(bounds("weight", 1, INT_MAX, weight)));
- else
- CHECK(weight);
-}
+GETTER(SpeciesAbility, int, ability)
+GETTER(SpeciesAbility, int, weight)
-int Sigmod::SpeciesAbility::ability() const
-{
- return m_ability;
-}
-
-int Sigmod::SpeciesAbility::weight() const
-{
- return m_weight;
-}
+CHECK_INDEX(SpeciesAbility, int, ability, sigmod(), ability)
+CHECK_BOUNDS(SpeciesAbility, int, weight, 1, INT_MAX)
Sigmod::SpeciesAbility& Sigmod::SpeciesAbility::operator=(const SpeciesAbility& rhs)
{
diff --git a/sigmod/SpeciesAbility.h b/sigmod/SpeciesAbility.h
index 895016d0..92233c9c 100644
--- a/sigmod/SpeciesAbility.h
+++ b/sigmod/SpeciesAbility.h
@@ -47,6 +47,9 @@ class SIGMOD_EXPORT SpeciesAbility : public Object
int ability() const;
int weight() const;
+ bool abilityCheck(const int ability) const;
+ bool weightCheck(const int weight) const;
+
SpeciesAbility& operator=(const SpeciesAbility& rhs);
private:
int m_ability;
diff --git a/sigmod/SpeciesItem.cpp b/sigmod/SpeciesItem.cpp
index 55e0a657..fcd12a8a 100644
--- a/sigmod/SpeciesItem.cpp
+++ b/sigmod/SpeciesItem.cpp
@@ -52,8 +52,8 @@ Sigmod::SpeciesItem::SpeciesItem(const QDomElement& xml, const Species* parent,
void Sigmod::SpeciesItem::validate()
{
TEST_BEGIN();
- TEST(setItem, item);
- TEST(setWeight, weight);
+ TEST(item);
+ TEST(weight);
TEST_END();
}
@@ -72,31 +72,14 @@ QDomElement Sigmod::SpeciesItem::save() const
return xml;
}
-void Sigmod::SpeciesItem::setItem(const int item)
-{
- if (!sigmod()->itemById(item))
- emit(error(bounds("item", item)));
- else
- CHECK(item);
-}
+SETTER(SpeciesItem, int, Item, item)
+SETTER(SpeciesItem, int, Weight, weight)
-void Sigmod::SpeciesItem::setWeight(const int weight)
-{
- if (weight <= 0)
- emit(error(bounds("weight", 1, INT_MAX, weight)));
- else
- CHECK(weight);
-}
+GETTER(SpeciesItem, int, item)
+GETTER(SpeciesItem, int, weight)
-int Sigmod::SpeciesItem::item() const
-{
- return m_item;
-}
-
-int Sigmod::SpeciesItem::weight() const
-{
- return m_weight;
-}
+CHECK_INDEX(SpeciesItem, int, item, sigmod(), item)
+CHECK_BOUNDS(SpeciesItem, int, weight, 1, INT_MAX)
Sigmod::SpeciesItem& Sigmod::SpeciesItem::operator=(const SpeciesItem& rhs)
{
diff --git a/sigmod/SpeciesItem.h b/sigmod/SpeciesItem.h
index a7e1faf0..b3ce640c 100644
--- a/sigmod/SpeciesItem.h
+++ b/sigmod/SpeciesItem.h
@@ -47,6 +47,9 @@ class SIGMOD_EXPORT SpeciesItem : public Object
int item() const;
int weight() const;
+ bool itemCheck(const int item) const;
+ bool weightCheck(const int weight) const;
+
SpeciesItem& operator=(const SpeciesItem& rhs);
private:
int m_item;
diff --git a/sigmod/SpeciesMove.cpp b/sigmod/SpeciesMove.cpp
index e15d28bf..76438ef4 100644
--- a/sigmod/SpeciesMove.cpp
+++ b/sigmod/SpeciesMove.cpp
@@ -54,9 +54,9 @@ Sigmod::SpeciesMove::SpeciesMove(const QDomElement& xml, const Species* parent,
void Sigmod::SpeciesMove::validate()
{
TEST_BEGIN();
- TEST(setMove, move);
- TEST(setLevel, level);
- TEST(setWild, wild);
+ TEST(move);
+ TEST(level);
+ TEST(wild);
TEST_END();
}
@@ -77,44 +77,17 @@ QDomElement Sigmod::SpeciesMove::save() const
return xml;
}
-void Sigmod::SpeciesMove::setMove(const int move)
-{
- if (!sigmod()->moveById(move))
- emit(error(bounds("move", move)));
- else
- CHECK(move);
-}
-
-void Sigmod::SpeciesMove::setLevel(const int level)
-{
- if ((level <= 0) || (sigmod()->rules()->maxLevel() <= level))
- emit(error(bounds("level", 1, sigmod()->rules()->maxLevel() - 1, level)));
- else
- CHECK(level);
-}
+SETTER(SpeciesMove, int, Move, move)
+SETTER(SpeciesMove, int, Level, level)
+SETTER(SpeciesMove, int, Wild, wild)
-void Sigmod::SpeciesMove::setWild(const int wild)
-{
- if ((wild <= 0) || (sigmod()->rules()->maxLevel() <= wild))
- emit(error(bounds("wild", 1, sigmod()->rules()->maxLevel() - 1, wild)));
- else
- CHECK(wild);
-}
+GETTER(SpeciesMove, int, move)
+GETTER(SpeciesMove, int, level)
+GETTER(SpeciesMove, int, wild)
-int Sigmod::SpeciesMove::move() const
-{
- return m_move;
-}
-
-int Sigmod::SpeciesMove::level() const
-{
- return m_level;
-}
-
-int Sigmod::SpeciesMove::wild() const
-{
- return m_wild;
-}
+CHECK_INDEX(SpeciesMove, int, move, sigmod(), move)
+CHECK_BOUNDS(SpeciesMove, int, level, 1, sigmod()->rules()->maxLevel())
+CHECK_BOUNDS(SpeciesMove, int, wild, 1, sigmod()->rules()->maxLevel())
Sigmod::SpeciesMove& Sigmod::SpeciesMove::operator=(const SpeciesMove& rhs)
{
diff --git a/sigmod/SpeciesMove.h b/sigmod/SpeciesMove.h
index 930bbdbc..76f627df 100644
--- a/sigmod/SpeciesMove.h
+++ b/sigmod/SpeciesMove.h
@@ -49,6 +49,10 @@ class SIGMOD_EXPORT SpeciesMove : public Object
int level() const;
int wild() const;
+ bool moveCheck(const int move) const;
+ bool levelCheck(const int level) const;
+ bool wildCheck(const int wild) const;
+
SpeciesMove& operator=(const SpeciesMove& rhs);
private:
int m_move;