summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--sigmod/Ability.cpp79
-rw-r--r--sigmod/Ability.h7
-rw-r--r--sigmod/Author.cpp36
-rw-r--r--sigmod/Author.h4
-rw-r--r--sigmod/Badge.cpp114
-rw-r--r--sigmod/Badge.h8
-rw-r--r--sigmod/CoinList.cpp108
-rw-r--r--sigmod/CoinList.h5
-rw-r--r--sigmod/CoinListItem.cpp60
-rw-r--r--sigmod/CoinListItem.h4
-rw-r--r--sigmod/EggGroup.cpp12
-rw-r--r--sigmod/EggGroup.h2
-rw-r--r--sigmod/GlobalScript.cpp23
-rw-r--r--sigmod/GlobalScript.h3
-rw-r--r--sigmod/Item.cpp129
-rw-r--r--sigmod/Item.h9
-rw-r--r--sigmod/ItemType.cpp77
-rw-r--r--sigmod/ItemType.h6
-rw-r--r--sigmod/Macros.h245
-rw-r--r--sigmod/Map.cpp512
-rw-r--r--sigmod/Map.h6
-rw-r--r--sigmod/MapEffect.cpp77
-rw-r--r--sigmod/MapEffect.h6
-rw-r--r--sigmod/MapTile.cpp51
-rw-r--r--sigmod/MapTile.h4
-rw-r--r--sigmod/MapTrainer.cpp185
-rw-r--r--sigmod/MapTrainer.h7
-rw-r--r--sigmod/MapTrainerTeamMember.cpp149
-rw-r--r--sigmod/MapTrainerTeamMember.h15
-rw-r--r--sigmod/MapWarp.cpp105
-rw-r--r--sigmod/MapWarp.h7
-rw-r--r--sigmod/MapWildList.cpp95
-rw-r--r--sigmod/MapWildList.h2
-rw-r--r--sigmod/MapWildListEncounter.cpp51
-rw-r--r--sigmod/MapWildListEncounter.h4
-rw-r--r--sigmod/Move.cpp160
-rw-r--r--sigmod/Move.h12
-rw-r--r--sigmod/Nature.cpp68
-rw-r--r--sigmod/Nature.h4
-rw-r--r--sigmod/Object.cpp40
-rw-r--r--sigmod/Object.h2
-rw-r--r--sigmod/Rules.cpp408
-rw-r--r--sigmod/Rules.h25
-rw-r--r--sigmod/Sigmod.cpp1913
-rw-r--r--sigmod/Sigmod.h8
-rw-r--r--sigmod/Skin.cpp23
-rw-r--r--sigmod/Skin.h3
-rw-r--r--sigmod/Sound.cpp36
-rw-r--r--sigmod/Sound.h4
-rw-r--r--sigmod/Species.cpp785
-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
-rw-r--r--sigmod/Sprite.cpp23
-rw-r--r--sigmod/Sprite.h3
-rw-r--r--sigmod/Status.cpp36
-rw-r--r--sigmod/Status.h4
-rw-r--r--sigmod/Store.cpp41
-rw-r--r--sigmod/Store.h5
-rw-r--r--sigmod/Tile.cpp36
-rw-r--r--sigmod/Tile.h4
-rw-r--r--sigmod/Time.cpp46
-rw-r--r--sigmod/Time.h4
-rw-r--r--sigmod/Trainer.cpp129
-rw-r--r--sigmod/Trainer.h10
-rw-r--r--sigmod/Type.cpp26
-rw-r--r--sigmod/Type.h3
-rw-r--r--sigmod/Weather.cpp23
-rw-r--r--sigmod/Weather.h3
-rw-r--r--sigmod/test/TestBadge.cpp24
-rw-r--r--sigmodr/SpeciesUI.cpp5
-rw-r--r--sigmodr/gui/rules.ui4
-rw-r--r--sigmodr/gui/species.ui8
-rw-r--r--sigscript/AbilityWrapper.cpp3
-rw-r--r--sigscript/CoinListItemWrapper.cpp3
-rw-r--r--sigscript/Global.h11
-rw-r--r--sigscript/ItemTypeWrapper.cpp3
-rw-r--r--sigscript/ItemWrapper.cpp6
-rw-r--r--sigscript/MapEffectWrapper.cpp6
-rw-r--r--sigscript/MapTileWrapper.cpp6
-rw-r--r--sigscript/MapTrainerTeamMemberWrapper.cpp11
-rw-r--r--sigscript/MapWarpWrapper.cpp3
-rw-r--r--sigscript/MapWildListEncounterWrapper.cpp6
-rw-r--r--sigscript/MoveWrapper.cpp9
-rw-r--r--sigscript/RulesWrapper.cpp45
-rw-r--r--sigscript/SpeciesItemWrapper.cpp3
-rw-r--r--sigscript/SpeciesWrapper.cpp16
-rw-r--r--sigscript/StoreWrapper.cpp2
-rw-r--r--sigscript/TileWrapper.cpp3
-rw-r--r--sigscript/TrainerWrapper.cpp6
94 files changed, 1408 insertions, 5029 deletions
diff --git a/sigmod/Ability.cpp b/sigmod/Ability.cpp
index 5b4108c0..6a0bbf55 100644
--- a/sigmod/Ability.cpp
+++ b/sigmod/Ability.cpp
@@ -87,65 +87,26 @@ QDomElement Sigmod::Ability::save() const
return xml;
}
-void Sigmod::Ability::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::Ability::setPriority(const int priority)
-{
- CHECK(priority);
-}
-
-void Sigmod::Ability::setDescription(const QString& description)
-{
- CHECK(description);
-}
-
-void Sigmod::Ability::setBattleScript(const Sigcore::Script& battleScript)
-{
- CHECK(battleScript);
-}
-
-void Sigmod::Ability::setWorldScript(const Sigcore::Script& worldScript)
-{
- CHECK(worldScript);
-}
-
-void Sigmod::Ability::setPriorityScript(const Sigcore::Script& priorityScript)
-{
- CHECK(priorityScript);
-}
-
-QString Sigmod::Ability::name() const
-{
- return m_name;
-}
-
-int Sigmod::Ability::priority() const
-{
- return m_priority;
-}
-
-QString Sigmod::Ability::description() const
-{
- return m_description;
-}
-
-Sigcore::Script Sigmod::Ability::battleScript() const
-{
- return m_battleScript;
-}
-
-Sigcore::Script Sigmod::Ability::worldScript() const
-{
- return m_worldScript;
-}
-
-Sigcore::Script Sigmod::Ability::priorityScript() const
-{
- return m_priorityScript;
-}
+SETTER(Ability, QString&, Name, name)
+SETTER(Ability, int, Priority, priority)
+SETTER(Ability, QString&, Description, description)
+SETTER(Ability, Sigcore::Script&, BattleScript, battleScript)
+SETTER(Ability, Sigcore::Script&, WorldScript, worldScript)
+SETTER(Ability, Sigcore::Script&, PriorityScript, priorityScript)
+
+GETTER(Ability, QString, name)
+GETTER(Ability, int, priority)
+GETTER(Ability, QString, description)
+GETTER(Ability, Sigcore::Script, battleScript)
+GETTER(Ability, Sigcore::Script, worldScript)
+GETTER(Ability, Sigcore::Script, priorityScript)
+
+CHECK(Ability, QString&, name)
+CHECK(Ability, int, priority)
+CHECK(Ability, QString&, description)
+CHECK(Ability, Sigcore::Script&, battleScript)
+CHECK(Ability, Sigcore::Script&, worldScript)
+CHECK(Ability, Sigcore::Script&, priorityScript)
Sigmod::Ability& Sigmod::Ability::operator=(const Ability& rhs)
{
diff --git a/sigmod/Ability.h b/sigmod/Ability.h
index cf3c35a3..18780edb 100644
--- a/sigmod/Ability.h
+++ b/sigmod/Ability.h
@@ -204,6 +204,13 @@ class SIGMOD_EXPORT Ability : public Object
*/
Sigcore::Script priorityScript() const;
+ bool nameCheck(const QString& name) const;
+ bool priorityCheck(const int priority) const;
+ bool descriptionCheck(const QString& description) const;
+ bool battleScriptCheck(const Sigcore::Script& battleScript) const;
+ bool worldScriptCheck(const Sigcore::Script& worldScript) const;
+ bool priorityScriptCheck(const Sigcore::Script& priorityScript) const;
+
Ability& operator=(const Ability& rhs);
private:
QString m_name;
diff --git a/sigmod/Author.cpp b/sigmod/Author.cpp
index a8ee02fd..34fb3b9f 100644
--- a/sigmod/Author.cpp
+++ b/sigmod/Author.cpp
@@ -87,35 +87,17 @@ QDomElement Sigmod::Author::save() const
return xml;
}
-void Sigmod::Author::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::Author::setEmail(const QString& email)
-{
- CHECK(email);
-}
+SETTER(Author, QString&, Name, name)
+SETTER(Author, QString&, Email, email)
+SETTER(Author, QString&, Role, role)
-void Sigmod::Author::setRole(const QString& role)
-{
- CHECK(role);
-}
+GETTER(Author, QString, name)
+GETTER(Author, QString, email)
+GETTER(Author, QString, role)
-QString Sigmod::Author::name() const
-{
- return m_name;
-}
-
-QString Sigmod::Author::email() const
-{
- return m_email;
-}
-
-QString Sigmod::Author::role() const
-{
- return m_role;
-}
+CHECK(Author, QString&, name)
+CHECK(Author, QString&, email)
+CHECK(Author, QString&, role)
Sigmod::Author& Sigmod::Author::operator=(const Author& rhs)
{
diff --git a/sigmod/Author.h b/sigmod/Author.h
index b7f73ce9..e3e2d2a4 100644
--- a/sigmod/Author.h
+++ b/sigmod/Author.h
@@ -127,6 +127,10 @@ class SIGMOD_EXPORT Author : public Object
*/
QString role() const;
+ bool nameCheck(const QString& name) const;
+ bool emailCheck(const QString& email) const;
+ bool roleCheck(const QString& role) const;
+
Author& operator=(const Author& rhs);
private:
QString m_name;
diff --git a/sigmod/Badge.cpp b/sigmod/Badge.cpp
index a3936c87..60d1815c 100644
--- a/sigmod/Badge.cpp
+++ b/sigmod/Badge.cpp
@@ -67,12 +67,21 @@ void Sigmod::Badge::validate()
TEST_BEGIN();
if (m_name.isEmpty())
emit(error("Name is empty"));
- TEST(setFace, face);
- TEST(setBadge, badge);
+ TEST(face);
+ TEST(badge);
if (m_face == m_badge)
emit(error("Face and badge sprites are the same"));
- TEST(setObey, obey);
- TEST_ARRAY(setStat, stat, ST_SpecialDefense - ST_Attack + 1);
+ TEST(obey);
+ 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_END();
}
@@ -97,42 +106,23 @@ QDomElement Sigmod::Badge::save() const
return xml;
}
-void Sigmod::Badge::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::Badge::setFace(const int face)
-{
- if (!sigmod()->spriteById(face))
- emit(error(bounds("face", face)));
- else
- CHECK(face);
-}
+SETTER(Badge, QString&, Name, name)
+SETTER(Badge, int, Face, face)
+SETTER(Badge, int, Badge, badge)
+SETTER(Badge, int, Obey, obey)
+SETTER_ARRAY(Badge, Sigcore::Fraction&, Stat, stat, multiplier, Stat, stat, ST_Attack)
-void Sigmod::Badge::setBadge(const int badge)
-{
- if (!sigmod()->spriteById(badge))
- emit(error(bounds("badge", badge)));
- else
- CHECK(badge);
-}
+GETTER(Badge, QString, name)
+GETTER(Badge, int, face)
+GETTER(Badge, int, badge)
+GETTER(Badge, int, obey)
+GETTER_ARRAY(Badge, Sigcore::Fraction, stat, multiplier, Stat, stat, ST_Attack)
-void Sigmod::Badge::setObey(const int obey)
-{
- if (sigmod()->rules()->maxLevel() < obey)
- emit(error(bounds("obey", INT_MIN, sigmod()->rules()->maxLevel(), obey)));
- else
- CHECK(obey);
-}
-
-void Sigmod::Badge::setStat(const Stat stat, const Sigcore::Fraction& multiplier)
-{
- if (multiplier < 1)
- {
- emit(error(bounds("stat multiplier", 1, INT_MAX, multiplier)));
- return;
- }
+CHECK(Badge, QString&, name)
+CHECK_INDEX(Badge, int, face, sigmod(), sprite)
+CHECK_INDEX(Badge, int, badge, sigmod(), sprite)
+CHECK_BOUNDS(Badge, int, obey, INT_MIN, sigmod()->rules()->maxLevel())
+CHECK_BEGIN_ARRAY(Badge, Sigcore::Fraction&, stat, multiplier, Stat, stat)
switch (stat)
{
case ST_SpecialDefense:
@@ -140,51 +130,11 @@ void Sigmod::Badge::setStat(const Stat stat, const Sigcore::Fraction& multiplier
case ST_Attack ... ST_Special:
break;
default:
- emit(warning(bounds("stat", "Attack", sigmod()->rules()->specialSplit() ? "SpecialDefense" : "Special", stat)));
- return;
+ EBOUNDS(stat, "Attack", sigmod()->rules()->specialSplit() ? "SpecialDefense" : "Special");
+ return false;
}
- CHECK_ARRAY(stat[stat - ST_Attack], multiplier);
-}
-
-void Sigmod::Badge::setStat(const Sigcore::Fraction& multiplier)
-{
- if (multiplier < 1)
- emit(error(bounds("stat multiplier", 1, INT_MAX, multiplier)));
-}
-
-QString Sigmod::Badge::name() const
-{
- return m_name;
-}
-
-int Sigmod::Badge::face() const
-{
- return m_face;
-}
-
-int Sigmod::Badge::badge() const
-{
- return m_badge;
-}
-
-int Sigmod::Badge::obey() const
-{
- return m_obey;
-}
-
-Sigcore::Fraction Sigmod::Badge::stat(const Stat stat) const
-{
- switch (stat)
- {
- case ST_SpecialDefense:
- if (sigmod()->rules()->specialSplit())
- case ST_Attack ... ST_Special:
- return m_stat[stat - ST_Attack];
- default:
- emit(warning(bounds("stat", "Attack", sigmod()->rules()->specialSplit() ? "SpecialDefense" : "Special", stat)));
- return Sigcore::Fraction();
- }
-}
+ TBOUNDS(multiplier, 1, INT_MAX)
+CHECK_END()
Sigmod::Badge& Sigmod::Badge::operator=(const Badge& rhs)
{
diff --git a/sigmod/Badge.h b/sigmod/Badge.h
index d2727c58..eaee1667 100644
--- a/sigmod/Badge.h
+++ b/sigmod/Badge.h
@@ -159,10 +159,14 @@ class SIGMOD_EXPORT Badge : public Object
*/
Sigcore::Fraction stat(const Stat stat) const;
+ bool nameCheck(const QString& name) const;
+ bool faceCheck(const int face) const;
+ bool badgeCheck(const int badge) const;
+ bool obeyCheck(const int obey) const;
+ bool statCheck(const Stat stat, const Sigcore::Fraction& multiplier) const;
+
Badge& operator=(const Badge& rhs);
private:
- void setStat(const Sigcore::Fraction& multiplier);
-
QString m_name;
int m_face;
int m_badge;
diff --git a/sigmod/CoinList.cpp b/sigmod/CoinList.cpp
index d2b3e3a7..a8fd4f2f 100644
--- a/sigmod/CoinList.cpp
+++ b/sigmod/CoinList.cpp
@@ -102,107 +102,16 @@ QDomElement Sigmod::CoinList::save() const
return xml;
}
-void Sigmod::CoinList::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::CoinList::setScript(const Sigcore::Script& script)
-{
- CHECK(script);
-}
-
-QString Sigmod::CoinList::name() const
-{
- return m_name;
-}
-
-Sigcore::Script Sigmod::CoinList::script() const
-{
- return m_script;
-}
-
-const Sigmod::CoinListItem* Sigmod::CoinList::item(const int index) const
-{
- if (index < itemCount())
- return m_items.at(index);
- return NULL;
-}
-
-Sigmod::CoinListItem* Sigmod::CoinList::item(const int index)
-{
- if (index < itemCount())
- return m_items[index];
- return NULL;
-}
-
-const Sigmod::CoinListItem* Sigmod::CoinList::itemById(const int id) const
-{
- return item(itemIndex(id));
-}
+SETTER(CoinList, QString&, Name, name)
+SETTER(CoinList, Sigcore::Script&, Script, script)
-Sigmod::CoinListItem* Sigmod::CoinList::itemById(const int id)
-{
- return item(itemIndex(id));
-}
+GETTER(CoinList, QString, name)
+GETTER(CoinList, Sigcore::Script, script)
-int Sigmod::CoinList::itemIndex(const int id) const
-{
- for (int i = 0; i < itemCount(); ++i)
- {
- if (m_items[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
+CHECK(CoinList, QString&, name)
+CHECK(CoinList, Sigcore::Script&, script)
-int Sigmod::CoinList::itemCount() const
-{
- return m_items.size();
-}
-
-Sigmod::CoinListItem* Sigmod::CoinList::newItem()
-{
- return newItem(new CoinListItem(this, itemId()));
-}
-
-Sigmod::CoinListItem* Sigmod::CoinList::newItem(const QDomElement& xml)
-{
- return newItem(new CoinListItem(xml, this, itemId()));
-}
-
-Sigmod::CoinListItem* Sigmod::CoinList::newItem(const CoinListItem& item)
-{
- return newItem(new CoinListItem(item, this, itemId()));
-}
-
-Sigmod::CoinListItem* Sigmod::CoinList::newItem(CoinListItem* item)
-{
- m_items.append(item);
- return item;
-}
-
-void Sigmod::CoinList::deleteItem(const int index)
-{
- if (index < itemCount())
- {
- delete m_items[index];
- m_items.removeAt(index);
- }
-}
-
-void Sigmod::CoinList::deleteItemById(const int id)
-{
- deleteItem(itemIndex(id));
-}
-
-int Sigmod::CoinList::itemId() const
-{
- int i = 0;
- while ((i < itemCount()) && (itemIndex(i) != INT_MAX))
- ++i;
- return i;
-}
+SUBCLASS(CoinList, Item, item, items)
Sigmod::CoinList& Sigmod::CoinList::operator=(const CoinList& rhs)
{
@@ -217,6 +126,5 @@ Sigmod::CoinList& Sigmod::CoinList::operator=(const CoinList& rhs)
void Sigmod::CoinList::clear()
{
- qDeleteAll(m_items);
- m_items.clear();
+ SUBCLASS_CLEAR(items);
}
diff --git a/sigmod/CoinList.h b/sigmod/CoinList.h
index 7807271f..f84d339c 100644
--- a/sigmod/CoinList.h
+++ b/sigmod/CoinList.h
@@ -184,9 +184,12 @@ class SIGMOD_EXPORT CoinList : public Object
*/
void deleteItemById(const int id);
+ bool nameCheck(const QString& name) const;
+ bool scriptCheck(const Sigcore::Script& script) const;
+
CoinList& operator=(const CoinList& rhs);
private:
- int itemId() const;
+ int newItemId() const;
CoinListItem* newItem(CoinListItem* item);
void clear();
diff --git a/sigmod/CoinListItem.cpp b/sigmod/CoinListItem.cpp
index c015b6f9..64ef7fce 100644
--- a/sigmod/CoinListItem.cpp
+++ b/sigmod/CoinListItem.cpp
@@ -59,8 +59,8 @@ Sigmod::CoinListItem::CoinListItem(const QDomElement& xml, const CoinList* paren
void Sigmod::CoinListItem::validate()
{
TEST_BEGIN();
- TEST(setObject, object);
- TEST(setCost, cost);
+ TEST(object);
+ TEST(cost);
TEST_END();
}
@@ -81,41 +81,27 @@ QDomElement Sigmod::CoinListItem::save() const
return xml;
}
-void Sigmod::CoinListItem::setType(const Type type)
-{
- CHECK(type);
-}
-
-void Sigmod::CoinListItem::setObject(const int object)
-{
- if (((Item == m_type) && !sigmod()->itemById(object)) || ((Species == m_type) && !sigmod()->speciesById(object)))
- emit(error(bounds("object", object)));
- else
- CHECK(object);
-}
-
-void Sigmod::CoinListItem::setCost(const int cost)
-{
- if (cost <= 0)
- emit(error(bounds("cost", 1, INT_MAX, cost)));
- else
- CHECK(cost);
-}
-
-Sigmod::CoinListItem::Type Sigmod::CoinListItem::type() const
-{
- return m_type;
-}
-
-int Sigmod::CoinListItem::object() const
-{
- return m_object;
-}
-
-int Sigmod::CoinListItem::cost() const
-{
- return m_cost;
-}
+SETTER(CoinListItem, Type, Type, type)
+SETTER(CoinListItem, int, Object, object)
+SETTER(CoinListItem, int, Cost, cost)
+
+GETTER(CoinListItem, Sigmod::CoinListItem::Type, type)
+GETTER(CoinListItem, int, object)
+GETTER(CoinListItem, int, cost)
+
+CHECK(CoinListItem, Type, type)
+CHECK_BEGIN(CoinListItem, int, object)
+ switch (m_type)
+ {
+ case Item:
+ IBOUNDS(object, sigmod(), item)
+ break;
+ case Species:
+ IBOUNDS(object, sigmod(), species)
+ break;
+ }
+CHECK_END()
+CHECK_BOUNDS(CoinListItem, int, cost, 1, INT_MAX)
Sigmod::CoinListItem& Sigmod::CoinListItem::operator=(const CoinListItem& rhs)
{
diff --git a/sigmod/CoinListItem.h b/sigmod/CoinListItem.h
index 237d6317..c38a7b4b 100644
--- a/sigmod/CoinListItem.h
+++ b/sigmod/CoinListItem.h
@@ -141,6 +141,10 @@ class SIGMOD_EXPORT CoinListItem : public Object
*/
int cost() const;
+ bool typeCheck(const Type type) const;
+ bool objectCheck(const int object) const;
+ bool costCheck(const int cost) const;
+
CoinListItem& operator=(const CoinListItem& rhs);
private:
Type m_type;
diff --git a/sigmod/EggGroup.cpp b/sigmod/EggGroup.cpp
index 139c646a..b829ea81 100644
--- a/sigmod/EggGroup.cpp
+++ b/sigmod/EggGroup.cpp
@@ -72,15 +72,11 @@ QDomElement Sigmod::EggGroup::save() const
return xml;
}
-void Sigmod::EggGroup::setName(const QString& name)
-{
- CHECK(name);
-}
+SETTER(EggGroup, QString&, Name, name)
-QString Sigmod::EggGroup::name() const
-{
- return m_name;
-}
+GETTER(EggGroup, QString, name)
+
+CHECK(EggGroup, QString&, name)
Sigmod::EggGroup& Sigmod::EggGroup::operator=(const EggGroup& rhs)
{
diff --git a/sigmod/EggGroup.h b/sigmod/EggGroup.h
index 89e6a754..b259025a 100644
--- a/sigmod/EggGroup.h
+++ b/sigmod/EggGroup.h
@@ -101,6 +101,8 @@ class SIGMOD_EXPORT EggGroup : public Object
*/
QString name() const;
+ bool nameCheck(const QString& name) const;
+
EggGroup& operator=(const EggGroup& rhs);
private:
QString m_name;
diff --git a/sigmod/GlobalScript.cpp b/sigmod/GlobalScript.cpp
index fc5e7d62..a7d9efcf 100644
--- a/sigmod/GlobalScript.cpp
+++ b/sigmod/GlobalScript.cpp
@@ -75,25 +75,14 @@ QDomElement Sigmod::GlobalScript::save() const
return xml;
}
-void Sigmod::GlobalScript::setName(const QString& name)
-{
- CHECK(name);
-}
+SETTER(GlobalScript, QString&, Name, name)
+SETTER(GlobalScript, Sigcore::Script&, Script, script)
-void Sigmod::GlobalScript::setScript(const Sigcore::Script& script)
-{
- CHECK(script);
-}
+GETTER(GlobalScript, QString, name)
+GETTER(GlobalScript, Sigcore::Script, script)
-QString Sigmod::GlobalScript::name() const
-{
- return m_name;
-}
-
-Sigcore::Script Sigmod::GlobalScript::script() const
-{
- return m_script;
-}
+CHECK(GlobalScript, QString&, name)
+CHECK(GlobalScript, Sigcore::Script&, script)
Sigmod::GlobalScript& Sigmod::GlobalScript::operator=(const GlobalScript& rhs)
{
diff --git a/sigmod/GlobalScript.h b/sigmod/GlobalScript.h
index 0f1684b8..0c82a945 100644
--- a/sigmod/GlobalScript.h
+++ b/sigmod/GlobalScript.h
@@ -123,6 +123,9 @@ class SIGMOD_EXPORT GlobalScript : public Object
*/
Sigcore::Script script() const;
+ bool nameCheck(const QString& name) const;
+ bool scriptCheck(const Sigcore::Script& script) const;
+
GlobalScript& operator=(const GlobalScript& rhs);
private:
QString m_name;
diff --git a/sigmod/Item.cpp b/sigmod/Item.cpp
index e6f521dd..0ac9f360 100644
--- a/sigmod/Item.cpp
+++ b/sigmod/Item.cpp
@@ -68,11 +68,11 @@ void Sigmod::Item::validate()
TEST_BEGIN();
if (m_name.isEmpty())
emit(error("Name is empty"));
- TEST(setType, type);
- TEST(setPrice, price);
+ TEST(type);
+ TEST(price);
if (m_sellable)
- TEST(setSellPrice, sellPrice);
- TEST(setWeight, weight);
+ TEST(sellPrice);
+ TEST(weight);
TEST_END();
}
@@ -103,101 +103,36 @@ QDomElement Sigmod::Item::save() const
return xml;
}
-void Sigmod::Item::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::Item::setSellable(const bool sellable)
-{
- CHECK(sellable);
-}
-
-void Sigmod::Item::setType(const int type)
-{
- if (!sigmod()->itemTypeById(type))
- emit(error(bounds("type", type)));
- else
- CHECK(type);
-}
-
-void Sigmod::Item::setPrice(const int price)
-{
- if ((price <= 0) || (sigmod()->rules()->maxMoney() < price))
- emit(error(bounds("price", 1, sigmod()->rules()->maxMoney(), price)));
- else
- CHECK(price);
-}
-
-void Sigmod::Item::setSellPrice(const int sellPrice)
-{
- if ((sellPrice < 0) || (m_price < sellPrice))
- emit(error(bounds("sellPrice", 0, m_price, sellPrice)));
- else
- CHECK(sellPrice);
-}
-
-void Sigmod::Item::setWeight(const int weight)
-{
+SETTER(Item, QString&, Name, name)
+SETTER(Item, bool, Sellable, sellable)
+SETTER(Item, int, Type, type)
+SETTER(Item, int, Price, price)
+SETTER(Item, int, SellPrice, sellPrice)
+SETTER(Item, int, Weight, weight)
+SETTER(Item, QString&, Description, description)
+SETTER(Item, Sigcore::Script&, Script, script)
+
+GETTER(Item, QString, name)
+GETTER(Item, bool, sellable)
+GETTER(Item, int, type)
+GETTER(Item, int, price)
+GETTER(Item, int, sellPrice)
+GETTER(Item, int, weight)
+GETTER(Item, QString, description)
+GETTER(Item, Sigcore::Script, script)
+
+CHECK(Item, QString&, name)
+CHECK(Item, bool, sellable)
+CHECK_INDEX(Item, int, type, sigmod(), itemType)
+CHECK_BOUNDS(Item, int, price, 1, sigmod()->rules()->maxMoney())
+CHECK_BOUNDS(Item, int, sellPrice, 0, m_price)
+CHECK_BEGIN(Item, int, weight)
const ItemType* type = sigmod()->itemTypeById(m_type);
if (type)
- {
- if ((weight < 0) || (type->maxWeight() < weight))
- emit(error(bounds("weight", 0, type->maxWeight(), weight)));
- else
- CHECK(weight);
- }
-}
-
-void Sigmod::Item::setDescription(const QString& description)
-{
- CHECK(description);
-}
-
-void Sigmod::Item::setScript(const Sigcore::Script& script)
-{
- CHECK(script);
-}
-
-QString Sigmod::Item::name() const
-{
- return m_name;
-}
-
-bool Sigmod::Item::sellable() const
-{
- return m_sellable;
-}
-
-int Sigmod::Item::type() const
-{
- return m_type;
-}
-
-int Sigmod::Item::price() const
-{
- return m_price;
-}
-
-int Sigmod::Item::sellPrice() const
-{
- return m_sellPrice;
-}
-
-int Sigmod::Item::weight() const
-{
- return m_weight;
-}
-
-QString Sigmod::Item::description() const
-{
- return m_description;
-}
-
-Sigcore::Script Sigmod::Item::script() const
-{
- return m_script;
-}
+ TBOUNDS(weight, 0, type->maxWeight())
+CHECK_END()
+CHECK(Item, QString&, description)
+CHECK(Item, Sigcore::Script&, script)
Sigmod::Item& Sigmod::Item::operator=(const Item& rhs)
{
diff --git a/sigmod/Item.h b/sigmod/Item.h
index 59f04675..120b6166 100644
--- a/sigmod/Item.h
+++ b/sigmod/Item.h
@@ -200,6 +200,15 @@ class SIGMOD_EXPORT Item : public Object
*/
Sigcore::Script script() const;
+ bool nameCheck(const QString& name) const;
+ bool sellableCheck(const bool sellable) const;
+ bool typeCheck(const int type) const;
+ bool priceCheck(const int price) const;
+ bool sellPriceCheck(const int sellPrice) const;
+ bool weightCheck(const int weight) const;
+ bool descriptionCheck(const QString& description) const;
+ bool scriptCheck(const Sigcore::Script& script) const;
+
Item& operator=(const Item& rhs);
private:
QString m_name;
diff --git a/sigmod/ItemType.cpp b/sigmod/ItemType.cpp
index e3bc2b4d..1a0b43f7 100644
--- a/sigmod/ItemType.cpp
+++ b/sigmod/ItemType.cpp
@@ -63,9 +63,9 @@ void Sigmod::ItemType::validate()
TEST_BEGIN();
if (m_name.isEmpty())
emit(error("Name is empty"));
- TEST(setComputer, computer);
- TEST(setPlayer, player);
- TEST(setMaxWeight, maxWeight);
+ TEST(computer);
+ TEST(player);
+ TEST(maxWeight);
TEST_END();
}
@@ -90,64 +90,23 @@ QDomElement Sigmod::ItemType::save() const
return xml;
}
-void Sigmod::ItemType::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::ItemType::setComputer(const int computer)
-{
- if (computer < -1)
- emit(error(bounds("computer", -1, INT_MAX, computer)));
- else
- CHECK(computer);
-}
-
-void Sigmod::ItemType::setPlayer(const int player)
-{
- if (player < 0)
- emit(error(bounds("player", 0, INT_MAX, player)));
- else
- CHECK(player);
-}
+SETTER(ItemType, QString&, Name, name)
+SETTER(ItemType, int, Computer, computer)
+SETTER(ItemType, int, Player, player)
+SETTER(ItemType, int, MaxWeight, maxWeight)
+SETTER(ItemType, Count, Count, count)
-void Sigmod::ItemType::setMaxWeight(const int maxWeight)
-{
- if ((maxWeight < -1) || ((sigmod()->rules()->maxTotalWeight() != -1) && (sigmod()->rules()->maxTotalWeight() < maxWeight)))
- emit(error(bounds("maxWeight", -1, (sigmod()->rules()->maxTotalWeight() == -1) ? INT_MAX : sigmod()->rules()->maxTotalWeight(), maxWeight)));
- else
- CHECK(maxWeight);
-}
+GETTER(ItemType, QString, name)
+GETTER(ItemType, int, computer)
+GETTER(ItemType, int, player)
+GETTER(ItemType, int, maxWeight)
+GETTER(ItemType, Sigmod::ItemType::Count, count)
-void Sigmod::ItemType::setCount(const Count count)
-{
- CHECK(count);
-}
-
-QString Sigmod::ItemType::name() const
-{
- return m_name;
-}
-
-int Sigmod::ItemType::computer() const
-{
- return m_computer;
-}
-
-int Sigmod::ItemType::player() const
-{
- return m_player;
-}
-
-int Sigmod::ItemType::maxWeight() const
-{
- return m_maxWeight;
-}
-
-Sigmod::ItemType::Count Sigmod::ItemType::count() const
-{
- return m_count;
-}
+CHECK(ItemType, QString&, name)
+CHECK_BOUNDS(ItemType, int, computer, -1, INT_MAX)
+CHECK_BOUNDS(ItemType, int, player, 0, INT_MAX)
+CHECK_BOUNDS(ItemType, int, maxWeight, -1, (sigmod()->rules()->maxTotalWeight() == -1) ? INT_MAX : sigmod()->rules()->maxTotalWeight())
+CHECK(ItemType, Count, count)
Sigmod::ItemType& Sigmod::ItemType::operator=(const ItemType& rhs)
{
diff --git a/sigmod/ItemType.h b/sigmod/ItemType.h
index 10a71530..28ec6a97 100644
--- a/sigmod/ItemType.h
+++ b/sigmod/ItemType.h
@@ -166,6 +166,12 @@ class SIGMOD_EXPORT ItemType : public Object
*/
Count count() const;
+ bool nameCheck(const QString& name) const;
+ bool computerCheck(const int computer) const;
+ bool playerCheck(const int player) const;
+ bool maxWeightCheck(const int maxWeight) const;
+ bool countCheck(const Count count) const;
+
ItemType& operator=(const ItemType& rhs);
private:
QString m_name;
diff --git a/sigmod/Macros.h b/sigmod/Macros.h
index dd149746..6213bc97 100644
--- a/sigmod/Macros.h
+++ b/sigmod/Macros.h
@@ -35,7 +35,6 @@
#define LOAD_ARRAY(variable) loadArray(xml.firstChildElement(#variable), &m_##variable)
#define LOAD_LIST(variable) loadList(xml.firstChildElement(#variable), &m_##variable)
#define LOAD_MATRIX(variable) loadMatrix(xml.firstChildElement(#variable), &m_##variable)
-#define LOAD_Rules() m_rules->load(xml.firstChildElement("Rules"))
#define LOAD_SUB(setter, class) \
QDomElement xml_##class = xml.firstChildElement(#class); \
while (!xml_##class.isNull()) \
@@ -70,18 +69,16 @@
emit(valMessage(QString("--%1 (%2)").arg(className()).arg(id()))); \
disconnect(this, SIGNAL(warning(QString)), this, SIGNAL(valWarning(QString))); \
disconnect(this, SIGNAL(error(QString)), this, SIGNAL(valError(QString)))
-#define TEST(setter, variable) setter(m_##variable)
-#define TEST_ARRAY(setter, variable, size) \
- for (int i = 0; i < size; ++i) \
- setter(m_##variable[i])
-#define TEST_LIST(setter, variable) \
+#define TEST(variable) variable##Check(m_##variable)
+#define TEST_ARRAY_INDEX(variable, index) variable##Check(index, m_##variable[index])
+#define TEST_LIST(variable) \
foreach (int variable, m_##variable) \
- setter(variable, true)
-#define TEST_MATRIX(setter, variable) \
+ variable##Check(variable)
+#define TEST_MATRIX(variable) \
for (int i = 0; i < m_##variable.height(); ++i) \
{ \
for (int j = 0; j < m_##variable.width(); ++j) \
- setter(i, j, m_##variable(i, j)); \
+ variable##Check(i, j, m_##variable(i, j)); \
}
#define TEST_CHILD(object) \
connect(object, SIGNAL(valMessage(QString)), this, SIGNAL(valMessage(QString))); \
@@ -102,13 +99,235 @@
checking##Checker.insert(object->value())
#define TEST_SUB_END() }
-#define CHECK(variable) CHECK_ARRAY(variable, variable)
-#define CHECK_ARRAY(variable, value) \
- if (m_##variable != value) \
+#define TS(variable) \
+ if (variable##Check(variable) && (m_##variable != variable)) \
{ \
- m_##variable = value; \
+ m_##variable = variable; \
emit(changed()); \
}
+#define TS_ARRAY(variable, index, offset, value) \
+ if (variable##Check(index, value) && (m_##variable[index - offset] != value)) \
+ { \
+ m_##variable[index - offset] = value; \
+ emit(changed()); \
+ }
+#define TS_MATRIX(variable, row, column, value) \
+ if (variable##Check(value) && (m_##variable(row, column) != value)) \
+ { \
+ m_##variable(row, column) = value; \
+ emit(changed()); \
+ }
+#define TS_LIST_BEGIN(variable) \
+ if (variable##Check(variable) && state && !m_##variable.contains(variable)) \
+ {
+#define TS_LIST_INTERNAL(variable) \
+ m_##variable.append(variable); \
+ emit(changed())
+#define TS_LIST_INTERNAL_LIMIT(variable, limit, limitError) \
+ if (m_##variable.size() < limit) \
+ { \
+ m_##variable.append(variable); \
+ emit(changed()); \
+ } \
+ else \
+ ERROR(limitError)
+#define TS_LIST_END(variable) \
+ } \
+ else if (m_##variable.contains(variable)) \
+ { \
+ m_##variable.removeOne(variable); \
+ emit(changed()); \
+ }
+#define TS_LIST(variable) \
+ TS_LIST_BEGIN(variable) \
+ TS_LIST_INTERNAL(variable); \
+ TS_LIST_END(variable)
+#define TS_LIST_LIMIT(variable, limit, limitError) \
+ TS_LIST_BEGIN(variable) \
+ TS_LIST_INTERNAL_LIMIT(variable, limit, limitError); \
+ TS_LIST_END(variable)
+
+#define WARNING(msg) emit(warning(msg))
+#define ERROR(msg) emit(error(msg))
+#define EBOUNDS(variable, min, max) EBOUNDS_MOD(variable, (min), (max), variable)
+#define EBOUNDS_IDX(variable) emit(error(bounds(#variable, variable)))
+#define EBOUNDS_MOD(variable, min, max, value) emit(error(bounds(#variable, (min), (max), value)))
+#define TBOUNDS(variable, min, max) TBOUNDS_MOD(variable, min, max, variable)
+#define TBOUNDS_MOD(variable, min, max, value) \
+ { \
+ const __typeof(min) variable##_min = (min); \
+ const __typeof(max) variable##_max = (max); \
+ if ((value < variable##_min) || (variable##_max < value)) \
+ { \
+ EBOUNDS_MOD(variable, variable##_min, variable##_max, value); \
+ return false; \
+ } \
+ }
+#define IBOUNDS(variable, pointer, subclass) \
+ if (!pointer->subclass##ById(variable)) \
+ { \
+ EBOUNDS_IDX(variable); \
+ return false; \
+ }
+
+#define SETTER(class, type, capital, variable) \
+void Sigmod::class::set##capital(const type variable) \
+{ \
+ TS(variable); \
+}
+#define SETTER_ARRAY(class, type, capital, variable, valueName, indexType, indexName, offset) \
+void Sigmod::class::set##capital(const indexType indexName, const type valueName) \
+{ \
+ TS_ARRAY(variable, indexName, offset, valueName); \
+}
+#define SETTER_MATRIX(class, type, capital, variable, valueName) \
+void Sigmod::class::set##capital(const int row, const int column, const type valueName) \
+{ \
+ TS_MATRIX(variable, row, column, valueName); \
+}
+#define SETTER_LIST(class, capital, variable) \
+void Sigmod::class::set##capital(const int variable, const bool state) \
+{ \
+ TS_LIST(variable); \
+}
+#define SETTER_LIST_LIMIT(class, capital, variable, limit, limitError) \
+void Sigmod::class::set##capital(const int variable, const bool state) \
+{ \
+ TS_LIST_LIMIT(variable, limit, limitError); \
+}
+
+#define GETTER(class, type, variable) \
+type Sigmod::class::variable() const \
+{ \
+ return m_##variable; \
+}
+#define GETTER_ARRAY(class, type, variable, valueName, indexType, indexName, offset) \
+type Sigmod::class::variable(const indexType indexName) const \
+{ \
+ if (variable##Check(indexName, m_##variable[indexName])) \
+ return m_##variable[indexName - offset]; \
+ return type(); \
+}
+#define GETTER_LIST(class, variable) \
+bool Sigmod::class::variable(const int variable) const \
+{ \
+ return m_##variable.contains(variable); \
+} \
+ \
+QList<int> Sigmod::class::variable() const \
+{ \
+ return m_##variable; \
+}
+
+#define CHECK_BEGIN(class, type, variable) \
+bool Sigmod::class::variable##Check(const type variable) const \
+{
+#define CHECK_BEGIN_ARRAY(class, type, variable, valueName, indexType, indexName) \
+bool Sigmod::class::variable##Check(const indexType indexName, const type valueName) const \
+{
+#define CHECK_END() \
+ return true; \
+}
+#define CHECK(class, type, variable) \
+CHECK_BEGIN(class, type, variable) \
+ Q_UNUSED(variable) \
+CHECK_END()
+#define CHECK_INDEX(class, type, variable, pointer, subclass) \
+CHECK_BEGIN(class, type, variable) \
+ IBOUNDS(variable, pointer, subclass) \
+CHECK_END()
+#define CHECK_BOUNDS(class, type, variable, min, max) \
+CHECK_BEGIN(class, type, variable) \
+ TBOUNDS(variable, (min), (max)) \
+CHECK_END()
+
+#define SUBCLASS_RAW(class, subclass, capital, short, variable) \
+const Sigmod::subclass* Sigmod::class::short(const int index) const \
+{ \
+ if (index < short##Count()) \
+ return m_##variable.at(index); \
+ return NULL; \
+} \
+ \
+Sigmod::subclass* Sigmod::class::short(const int index) \
+{ \
+ if (index < short##Count()) \
+ return m_##variable[index]; \
+ return NULL; \
+} \
+ \
+const Sigmod::subclass* Sigmod::class::short##ById(const int id) const \
+{ \
+ return short(short##Index(id)); \
+} \
+ \
+Sigmod::subclass* Sigmod::class::short##ById(const int id) \
+{ \
+ return short(short##Index(id)); \
+} \
+ \
+int Sigmod::class::short##Index(const int id) const \
+{ \
+ for (int i = 0; i < short##Count(); ++i) \
+ { \
+ if (m_##variable[i]->id() == id) \
+ return i; \
+ } \
+ return INT_MAX; \
+} \
+ \
+int Sigmod::class::short##Count() const \
+{ \
+ return m_##variable.size(); \
+} \
+ \
+Sigmod::subclass* Sigmod::class::new##capital() \
+{ \
+ return new##capital(new subclass(this, new##capital##Id())); \
+} \
+ \
+Sigmod::subclass* Sigmod::class::new##capital(const QDomElement& xml) \
+{ \
+ return new##capital(new subclass(xml, this, new##capital##Id())); \
+} \
+ \
+Sigmod::subclass* Sigmod::class::new##capital(const subclass& short) \
+{ \
+ return new##capital(new subclass(short, this, new##capital##Id())); \
+} \
+ \
+Sigmod::subclass* Sigmod::class::new##capital(subclass* short) \
+{ \
+ m_##variable.append(short); \
+ return short; \
+} \
+ \
+void Sigmod::class::delete##capital(const int index) \
+{ \
+ if (index < short##Count()) \
+ { \
+ delete m_##variable[index]; \
+ m_##variable.removeAt(index); \
+ } \
+} \
+ \
+void Sigmod::class::delete##capital##ById(const int id) \
+{ \
+ delete##capital(short##Index(id)); \
+} \
+ \
+int Sigmod::class::new##capital##Id() const \
+{ \
+ int i = 0; \
+ while ((i < short##Count()) && (short##Index(i) != INT_MAX)) \
+ ++i; \
+ return i; \
+}
+#define SUBCLASS(class, capital, short, variable) SUBCLASS_RAW(class, class##capital, capital, short, variable)
+#define SSUBCLASS(class, capital, short, variable) SUBCLASS_RAW(class, capital, capital, short, variable)
+#define SUBCLASS_CLEAR(variable) \
+ qDeleteAll(m_##variable); \
+ m_##variable.clear()
#endif
diff --git a/sigmod/Map.cpp b/sigmod/Map.cpp
index 667b5524..af58d36f 100644
--- a/sigmod/Map.cpp
+++ b/sigmod/Map.cpp
@@ -71,12 +71,10 @@ void Sigmod::Map::validate()
TEST_BEGIN();
if (m_name.isEmpty())
emit(error("Name is empty"));
- TEST(setFlyWarp, flyWarp);
- TEST(setType, type);
- if (!m_width)
- emit(error("Map has no width"));
- if (!m_height)
- emit(error("Map has no height"));
+ TEST(flyWarp);
+ TEST(type);
+ TEST(width);
+ TEST(height);
QSet<int> idChecker;
QSet<QString> nameChecker;
if (!effectCount())
@@ -147,474 +145,35 @@ QDomElement Sigmod::Map::save() const
return xml;
}
-void Sigmod::Map::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::Map::setFlyWarp(const int flyWarp)
-{
- if ((flyWarp != -1) && !warpById(flyWarp))
- emit(error(bounds("flyWarp", flyWarp)));
- else
- CHECK(flyWarp);
-}
-
-void Sigmod::Map::setType(const Type type)
-{
- CHECK(type);
-}
-
-void Sigmod::Map::setWidth(const int width)
-{
- if (width <= 0)
- emit(error(bounds("width", 1, INT_MAX, width)));
- else
- CHECK(width);
-}
+SETTER(Map, QString&, Name, name)
+SETTER(Map, int, FlyWarp, flyWarp)
+SETTER(Map, Type, Type, type)
+SETTER(Map, int, Width, width)
+SETTER(Map, int, Height, height)
-void Sigmod::Map::setHeight(const int height)
-{
- if (height <= 0)
- emit(error(bounds("height", 1, INT_MAX, height)));
- else
- CHECK(height);
-}
-
-QString Sigmod::Map::name() const
-{
- return m_name;
-}
-
-int Sigmod::Map::flyWarp() const
-{
- return m_flyWarp;
-}
-
-Sigmod::Map::Type Sigmod::Map::type() const
-{
- return m_type;
-}
-
-int Sigmod::Map::width() const
-{
- return m_width;
-}
-
-int Sigmod::Map::height() const
-{
- return m_height;
-}
-
-const Sigmod::MapEffect* Sigmod::Map::effect(const int index) const
-{
- if (index < effectCount())
- return m_effects.at(index);
- return NULL;
-}
-
-Sigmod::MapEffect* Sigmod::Map::effect(const int index)
-{
- if (index < effectCount())
- return m_effects[index];
- return NULL;
-}
-
-const Sigmod::MapEffect* Sigmod::Map::effectById(const int index) const
-{
- return effect(effectIndex(index));
-}
-
-Sigmod::MapEffect* Sigmod::Map::effectById(const int index)
-{
- return effect(effectIndex(index));
-}
-
-int Sigmod::Map::effectIndex(const int id) const
-{
- for (int i = 0; i < effectCount(); ++i)
- {
- if (m_effects[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Map::effectCount() const
-{
- return m_effects.size();
-}
-
-Sigmod::MapEffect* Sigmod::Map::newEffect()
-{
- return newEffect(new MapEffect(this, newEffectId()));
-}
-
-Sigmod::MapEffect* Sigmod::Map::newEffect(const QDomElement& xml)
-{
- return newEffect(new MapEffect(xml, this, newEffectId()));
-}
-
-Sigmod::MapEffect* Sigmod::Map::newEffect(const MapEffect& effect)
-{
- return newEffect(new MapEffect(effect, this, newEffectId()));
-}
-
-Sigmod::MapEffect* Sigmod::Map::newEffect(MapEffect* effect)
-{
- m_effects.append(effect);
- return effect;
-}
-
-void Sigmod::Map::deleteEffect(const int index)
-{
- if (index < effectCount())
- {
- delete m_effects[index];
- m_effects.removeAt(index);
- }
-}
-
-void Sigmod::Map::deleteEffectById(const int id)
-{
- deleteEffect(effectIndex(id));
-}
-
-int Sigmod::Map::newEffectId() const
-{
- int i = 0;
- while ((i < effectCount()) && (effectIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::MapTile* Sigmod::Map::tile(const int index) const
-{
- if (index < tileCount())
- return m_tiles.at(index);
- return NULL;
-}
-
-Sigmod::MapTile* Sigmod::Map::tile(const int index)
-{
- if (index < tileCount())
- return m_tiles[index];
- return NULL;
-}
-
-const Sigmod::MapTile* Sigmod::Map::tileById(const int index) const
-{
- return tile(tileIndex(index));
-}
-
-Sigmod::MapTile* Sigmod::Map::tileById(const int index)
-{
- return tile(tileIndex(index));
-}
-
-int Sigmod::Map::tileIndex(const int id) const
-{
- for (int i = 0; i < tileCount(); ++i)
- {
- if (m_tiles[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Map::tileCount() const
-{
- return m_tiles.size();
-}
-
-Sigmod::MapTile* Sigmod::Map::newTile()
-{
- return newTile(new MapTile(this, newTileId()));
-}
-
-Sigmod::MapTile* Sigmod::Map::newTile(const QDomElement& xml)
-{
- return newTile(new MapTile(xml, this, newTileId()));
-}
-
-Sigmod::MapTile* Sigmod::Map::newTile(const MapTile& tile)
-{
- return newTile(new MapTile(tile, this, newTileId()));
-}
-
-Sigmod::MapTile* Sigmod::Map::newTile(MapTile* tile)
-{
- m_tiles.append(tile);
- return tile;
-}
-
-void Sigmod::Map::deleteTile(const int index)
-{
- if (index < tileCount())
- {
- delete m_tiles[index];
- m_tiles.removeAt(index);
- }
-}
-
-void Sigmod::Map::deleteTileById(const int id)
-{
- deleteTile(tileIndex(id));
-}
-
-int Sigmod::Map::newTileId() const
-{
- int i = 0;
- while ((i < tileCount()) && (tileIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::MapTrainer* Sigmod::Map::trainer(const int index) const
-{
- if (index < trainerCount())
- return m_trainers.at(index);
- return NULL;
-}
-
-Sigmod::MapTrainer* Sigmod::Map::trainer(const int index)
-{
- if (index < trainerCount())
- return m_trainers[index];
- return NULL;
-}
+GETTER(Map, QString, name)
+GETTER(Map, int, flyWarp)
+GETTER(Map, Sigmod::Map::Type, type)
+GETTER(Map, int, width)
+GETTER(Map, int, height)
-const Sigmod::MapTrainer* Sigmod::Map::trainerById(const int id) const
-{
- return trainer(trainerIndex(id));
-}
-
-Sigmod::MapTrainer* Sigmod::Map::trainerById(const int id)
-{
- return trainer(trainerIndex(id));
-}
-
-int Sigmod::Map::trainerIndex(const int id) const
-{
- for (int i = 0; i < trainerCount(); ++i)
- {
- if (m_trainers[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Map::trainerCount() const
-{
- return m_trainers.size();
-}
-
-Sigmod::MapTrainer* Sigmod::Map::newTrainer()
-{
- return newTrainer(new MapTrainer(this, newTrainerId()));
-}
-
-Sigmod::MapTrainer* Sigmod::Map::newTrainer(const QDomElement& xml)
-{
- return newTrainer(new MapTrainer(xml, this, newTrainerId()));
-}
-
-Sigmod::MapTrainer* Sigmod::Map::newTrainer(const MapTrainer& trainer)
-{
- return newTrainer(new MapTrainer(trainer, this, newTrainerId()));
-}
-
-Sigmod::MapTrainer* Sigmod::Map::newTrainer(MapTrainer* trainer)
-{
- m_trainers.append(trainer);
- return trainer;
-}
-
-void Sigmod::Map::deleteTrainer(const int index)
-{
- if (index < trainerCount())
- {
- delete m_trainers[index];
- m_trainers.removeAt(index);
- }
-}
-
-void Sigmod::Map::deleteTrainerById(const int id)
-{
- deleteTrainer(trainerIndex(id));
-}
-
-int Sigmod::Map::newTrainerId() const
-{
- int i = 0;
- while ((i < trainerCount()) && (trainerIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::MapWarp* Sigmod::Map::warp(const int index) const
-{
- if (index < warpCount())
- return m_warps.at(index);
- return NULL;
-}
-
-Sigmod::MapWarp* Sigmod::Map::warp(const int index)
-{
- if (index < warpCount())
- return m_warps[index];
- return NULL;
-}
-
-const Sigmod::MapWarp* Sigmod::Map::warpById(const int id) const
-{
- return warp(warpIndex(id));
-}
-
-Sigmod::MapWarp* Sigmod::Map::warpById(const int id)
-{
- return warp(warpIndex(id));
-}
-
-int Sigmod::Map::warpIndex(const int id) const
-{
- for (int i = 0; i < warpCount(); ++i)
- {
- if (m_warps[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Map::warpCount() const
-{
- return m_warps.size();
-}
-
-Sigmod::MapWarp* Sigmod::Map::newWarp()
-{
- return newWarp(new MapWarp(this, newWarpId()));
-}
-
-Sigmod::MapWarp* Sigmod::Map::newWarp(const QDomElement& xml)
-{
- return newWarp(new MapWarp(xml, this, newWarpId()));
-}
-
-Sigmod::MapWarp* Sigmod::Map::newWarp(const MapWarp& warp)
-{
- return newWarp(new MapWarp(warp, this, newWarpId()));
-}
-
-Sigmod::MapWarp* Sigmod::Map::newWarp(MapWarp* warp)
-{
- m_warps.append(warp);
- return warp;
-}
-
-void Sigmod::Map::deleteWarp(const int index)
-{
- if (index < warpCount())
- {
- delete m_warps[index];
- m_warps.removeAt(index);
- }
-}
-
-void Sigmod::Map::deleteWarpById(const int id)
-{
- deleteWarp(warpIndex(id));
-}
-
-int Sigmod::Map::newWarpId() const
-{
- int i = 0;
- while ((i < warpCount()) && (warpIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::MapWildList* Sigmod::Map::wildList(const int index) const
-{
- if (index < wildListCount())
- return m_wildLists.at(index);
- return NULL;
-}
-
-Sigmod::MapWildList* Sigmod::Map::wildList(const int index)
-{
- if (index < wildListCount())
- return m_wildLists[index];
- return NULL;
-}
-
-const Sigmod::MapWildList* Sigmod::Map::wildListById(const int id) const
-{
- return wildList(wildListIndex(id));
-}
-
-Sigmod::MapWildList* Sigmod::Map::wildListById(const int id)
-{
- return wildList(wildListIndex(id));
-}
-
-int Sigmod::Map::wildListIndex(const int id) const
-{
- for (int i = 0; i < wildListCount(); ++i)
- {
- if (m_wildLists[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Map::wildListCount() const
-{
- return m_wildLists.size();
-}
-
-Sigmod::MapWildList* Sigmod::Map::newWildList()
-{
- return newWildList(new MapWildList(this, newWildListId()));
-}
-
-Sigmod::MapWildList* Sigmod::Map::newWildList(const QDomElement& xml)
-{
- return newWildList(new MapWildList(xml, this, newWildListId()));
-}
-
-Sigmod::MapWildList* Sigmod::Map::newWildList(const MapWildList& wildList)
-{
- return newWildList(new MapWildList(wildList, this, newWildListId()));
-}
-
-Sigmod::MapWildList* Sigmod::Map::newWildList(MapWildList* wildList)
-{
- m_wildLists.append(wildList);
- return wildList;
-}
-
-void Sigmod::Map::deleteWildList(const int index)
-{
- if (index < wildListCount())
+CHECK(Map, QString&, name)
+CHECK_BEGIN(Map, int, flyWarp)
+ if ((flyWarp != -1) && !warpById(flyWarp))
{
- delete m_wildLists[index];
- m_wildLists.removeAt(index);
+ EBOUNDS_IDX(flyWarp);
+ return false;
}
-}
+CHECK_END()
+CHECK(Map, Type, type)
+CHECK_BOUNDS(Map, int, width, 1, INT_MAX)
+CHECK_BOUNDS(Map, int, height, 1, INT_MAX)
-void Sigmod::Map::deleteWildListById(const int id)
-{
- deleteWildList(wildListIndex(id));
-}
-
-int Sigmod::Map::newWildListId() const
-{
- int i = 0;
- while ((i < warpCount()) && (warpIndex(i) != INT_MAX))
- ++i;
- return i;
-}
+SUBCLASS(Map, Effect, effect, effects)
+SUBCLASS(Map, Tile, tile, tiles)
+SUBCLASS(Map, Trainer, trainer, trainers)
+SUBCLASS(Map, Warp, warp, warps)
+SUBCLASS(Map, WildList, wildList, wildLists)
Sigmod::Map& Sigmod::Map::operator=(const Map& rhs)
{
@@ -636,14 +195,9 @@ Sigmod::Map& Sigmod::Map::operator=(const Map& rhs)
void Sigmod::Map::clear()
{
- qDeleteAll(m_effects);
- m_effects.clear();
- qDeleteAll(m_tiles);
- m_tiles.clear();
- qDeleteAll(m_trainers);
- m_trainers.clear();
- qDeleteAll(m_warps);
- m_warps.clear();
- qDeleteAll(m_wildLists);
- m_wildLists.clear();
+ SUBCLASS_CLEAR(effects);
+ SUBCLASS_CLEAR(tiles);
+ SUBCLASS_CLEAR(trainers);
+ SUBCLASS_CLEAR(warps);
+ SUBCLASS_CLEAR(wildLists);
}
diff --git a/sigmod/Map.h b/sigmod/Map.h
index 8a62e2ba..1fc7108e 100644
--- a/sigmod/Map.h
+++ b/sigmod/Map.h
@@ -74,6 +74,12 @@ class SIGMOD_EXPORT Map : public Object
int width() const;
int height() const;
+ bool nameCheck(const QString& name) const;
+ bool flyWarpCheck(const int flyWarp) const;
+ bool typeCheck(const Type type) const;
+ bool widthCheck(const int width) const;
+ bool heightCheck(const int height) const;
+
const MapEffect* effect(const int index) const;
MapEffect* effect(const int index);
const MapEffect* effectById(const int id) const;
diff --git a/sigmod/MapEffect.cpp b/sigmod/MapEffect.cpp
index 7b992892..241a7ce3 100644
--- a/sigmod/MapEffect.cpp
+++ b/sigmod/MapEffect.cpp
@@ -57,8 +57,8 @@ void Sigmod::MapEffect::validate()
TEST_BEGIN();
if (m_name.isEmpty())
emit(error("Name is empty"));
- TEST(setCoordinate, coordinate);
- TEST(setSkin, skin);
+ TEST(coordinate);
+ TEST(skin);
TEST_END();
}
@@ -83,62 +83,27 @@ QDomElement Sigmod::MapEffect::save() const
return xml;
}
-void Sigmod::MapEffect::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::MapEffect::setCoordinate(const QPoint& coordinate)
-{
- const Map* map = qobject_cast<const Map*>(parent());
- if ((coordinate.x() < 0) || (coordinate.y() < 0) || (map->width() <= coordinate.x()) || (map->height() <= coordinate.y()))
- emit(error(bounds("coordinate", QPoint(0, 0), QPoint(map->width(), map->height()), coordinate)));
- else
- CHECK(coordinate);
-}
+SETTER(MapEffect, QString&, Name, name)
+SETTER(MapEffect, QPoint&, Coordinate, coordinate)
+SETTER(MapEffect, int, Skin, skin)
+SETTER(MapEffect, bool, IsGhost, isGhost)
+SETTER(MapEffect, Sigcore::Script&, Script, script)
-void Sigmod::MapEffect::setSkin(const int skin)
-{
- if (!sigmod()->skinById(skin))
- emit(error(bounds("skin", skin)));
- else
- CHECK(skin);
-}
+GETTER(MapEffect, QString, name)
+GETTER(MapEffect, QPoint, coordinate)
+GETTER(MapEffect, int, skin)
+GETTER(MapEffect, bool, isGhost)
+GETTER(MapEffect, Sigcore::Script, script)
-void Sigmod::MapEffect::setIsGhost(const bool isGhost)
-{
- CHECK(isGhost);
-}
-
-void Sigmod::MapEffect::setScript(const Sigcore::Script& script)
-{
- CHECK(script);
-}
-
-QString Sigmod::MapEffect::name() const
-{
- return m_name;
-}
-
-QPoint Sigmod::MapEffect::coordinate() const
-{
- return m_coordinate;
-}
-
-int Sigmod::MapEffect::skin() const
-{
- return m_skin;
-}
-
-bool Sigmod::MapEffect::isGhost() const
-{
- return m_isGhost;
-}
-
-Sigcore::Script Sigmod::MapEffect::script() const
-{
- return m_script;
-}
+CHECK(MapEffect, QString&, name)
+CHECK_BEGIN(MapEffect, QPoint&, coordinate)
+ const Map* map = qobject_cast<const Map*>(parent());
+ TBOUNDS_MOD(coordinate_x, 0, map->width() - 1, coordinate.x())
+ TBOUNDS_MOD(coordinate_y, 0, map->height() - 1, coordinate.y())
+CHECK_END()
+CHECK_INDEX(MapEffect, int, skin, sigmod(), skin)
+CHECK(MapEffect, bool, isGhost)
+CHECK(MapEffect, Sigcore::Script&, script)
Sigmod::MapEffect& Sigmod::MapEffect::operator=(const MapEffect& rhs)
{
diff --git a/sigmod/MapEffect.h b/sigmod/MapEffect.h
index f8f064bc..4ae0f376 100644
--- a/sigmod/MapEffect.h
+++ b/sigmod/MapEffect.h
@@ -59,6 +59,12 @@ class SIGMOD_EXPORT MapEffect : public Object
bool isGhost() const;
Sigcore::Script script() const;
+ bool nameCheck(const QString& name) const;
+ bool coordinateCheck(const QPoint& coordinate) const;
+ bool skinCheck(const int skin) const;
+ bool isGhostCheck(const bool isGhost) const;
+ bool scriptCheck(const Sigcore::Script& script) const;
+
MapEffect& operator=(const MapEffect& rhs);
private:
QString m_name;
diff --git a/sigmod/MapTile.cpp b/sigmod/MapTile.cpp
index c407c5e2..bc978319 100644
--- a/sigmod/MapTile.cpp
+++ b/sigmod/MapTile.cpp
@@ -58,8 +58,8 @@ Sigmod::MapTile::~MapTile()
void Sigmod::MapTile::validate()
{
TEST_BEGIN();
- TEST(setTile, tile);
- TEST(setPosition, position);
+ TEST(tile);
+ TEST(position);
TEST_END();
}
@@ -80,42 +80,21 @@ QDomElement Sigmod::MapTile::save() const
return xml;
}
-void Sigmod::MapTile::setTile(const int tile)
-{
- if (!sigmod()->tileById(tile))
- emit(error(bounds("tile", tile)));
- else
- CHECK(tile);
-}
+SETTER(MapTile, int, Tile, tile)
+SETTER(MapTile, QPoint&, Position, position)
+SETTER(MapTile, int, ZIndex, zIndex)
-void Sigmod::MapTile::setPosition(const QPoint& position)
-{
- const Map* map = qobject_cast<const Map*>(parent());
- if ((position.x() < 0) || (position.y() < 0) || (map->width() <= position.x()) || (map->height() <= position.y()))
- emit(error(bounds("position", QPoint(0, 0), QPoint(map->width(), map->height()), position)));
- else
- CHECK(position);
-}
+GETTER(MapTile, int, tile)
+GETTER(MapTile, QPoint, position)
+GETTER(MapTile, int, zIndex)
-void Sigmod::MapTile::setZIndex(const int zIndex)
-{
- CHECK(zIndex);
-}
-
-int Sigmod::MapTile::tile() const
-{
- return m_tile;
-}
-
-QPoint Sigmod::MapTile::position() const
-{
- return m_position;
-}
-
-int Sigmod::MapTile::zIndex() const
-{
- return m_zIndex;
-}
+CHECK_INDEX(MapTile, int, tile, sigmod(), tile)
+CHECK_BEGIN(MapTile, QPoint&, position)
+ const Map* map = qobject_cast<const Map*>(parent());
+ TBOUNDS_MOD(position_x, 0, map->width() - 1, position.x())
+ TBOUNDS_MOD(position_y, 0, map->height() - 1, position.y())
+CHECK_END()
+CHECK(MapTile, int, zIndex)
Sigmod::MapTile& Sigmod::MapTile::operator=(const MapTile& rhs)
{
diff --git a/sigmod/MapTile.h b/sigmod/MapTile.h
index d7d51e93..4cf5af6c 100644
--- a/sigmod/MapTile.h
+++ b/sigmod/MapTile.h
@@ -47,6 +47,10 @@ class SIGMOD_EXPORT MapTile : public Object
QPoint position() const;
int zIndex() const;
+ bool tileCheck(const int tile) const;
+ bool positionCheck(const QPoint& position) const;
+ bool zIndexCheck(const int zIndex) const;
+
MapTile& operator=(const MapTile& rhs);
private:
int m_tile;
diff --git a/sigmod/MapTrainer.cpp b/sigmod/MapTrainer.cpp
index b4b5fa33..516af27c 100644
--- a/sigmod/MapTrainer.cpp
+++ b/sigmod/MapTrainer.cpp
@@ -68,10 +68,10 @@ void Sigmod::MapTrainer::validate()
TEST_BEGIN();
if (m_name.isEmpty())
emit(error("Name is empty"));
- TEST(setTrainerClass, trainerClass);
- TEST(setCoordinate, coordinate);
- TEST(setNumberFight, numberFight);
- TEST(setLeadTeamMember, leadTeamMember);
+ TEST(trainerClass);
+ TEST(coordinate);
+ TEST(numberFight);
+ TEST(leadTeamMember);
if (!teamMemberCount())
emit(error("There are no team members"));
QSet<int> idChecker;
@@ -89,6 +89,7 @@ void Sigmod::MapTrainer::load(const QDomElement& xml)
LOAD(coordinate);
LOAD(numberFight);
LOAD(script);
+ LOAD(leadTeamMember);
LOAD_SUB(newTeamMember, MapTrainerTeamMember);
LOAD(leadTeamMember);
}
@@ -101,164 +102,43 @@ QDomElement Sigmod::MapTrainer::save() const
SAVE(coordinate);
SAVE(numberFight);
SAVE(script);
+ SAVE(leadTeamMember);
SAVE_SUB(MapTrainerTeamMember, teamMembers);
return xml;
}
-void Sigmod::MapTrainer::setName(const QString& name)
-{
- CHECK(name);
-}
+SETTER(MapTrainer, QString&, Name, name)
+SETTER(MapTrainer, int, TrainerClass, trainerClass)
+SETTER(MapTrainer, QPoint&, Coordinate, coordinate)
+SETTER(MapTrainer, int, NumberFight, numberFight)
+SETTER(MapTrainer, Sigcore::Script&, Script, script)
+SETTER(MapTrainer, int, LeadTeamMember, leadTeamMember)
-void Sigmod::MapTrainer::setTrainerClass(const int trainerClass)
-{
- if (!sigmod()->trainerById(trainerClass))
- emit(error(bounds("trainerClass", trainerClass)));
- else
- CHECK(trainerClass);
-}
+GETTER(MapTrainer, QString, name)
+GETTER(MapTrainer, int, trainerClass)
+GETTER(MapTrainer, QPoint, coordinate)
+GETTER(MapTrainer, int, numberFight)
+GETTER(MapTrainer, Sigcore::Script, script)
+GETTER(MapTrainer, int, leadTeamMember)
-void Sigmod::MapTrainer::setCoordinate(const QPoint& coordinate)
-{
+CHECK(MapTrainer, QString&, name)
+CHECK_INDEX(MapTrainer, int, trainerClass, sigmod(), trainer)
+CHECK_BEGIN(MapTrainer, QPoint&, coordinate)
const Map* map = qobject_cast<const Map*>(parent());
- if ((coordinate.x() < 0) || (coordinate.y() < 0) || (map->width() <= coordinate.x()) || (map->height() <= coordinate.y()))
- emit(error(bounds("coordinate", QPoint(0, 0), QPoint(map->width(), map->height()), coordinate)));
- else
- CHECK(coordinate);
-}
-
-void Sigmod::MapTrainer::setNumberFight(const int numberFight)
-{
- if ((numberFight <= 0) || (sigmod()->rules()->maxFight() < numberFight))
- emit(error(bounds("numberFight", 1, sigmod()->rules()->maxFight(), numberFight)));
- else
- CHECK(numberFight);
-}
-
-void Sigmod::MapTrainer::setScript(const Sigcore::Script& script)
-{
- CHECK(script);
-}
-
-void Sigmod::MapTrainer::setLeadTeamMember(const int leadTeamMember)
-{
+ TBOUNDS_MOD(coordinate_x, 0, map->width() - 1, coordinate.x())
+ TBOUNDS_MOD(coordinate_y, 0, map->height() - 1, coordinate.y())
+CHECK_END()
+CHECK_BOUNDS(MapTrainer, int, numberFight, 1, sigmod()->rules()->maxFight())
+CHECK(MapTrainer, Sigcore::Script&, script)
+CHECK_BEGIN(MapTrainer, int, leadTeamMember)
if (!teamMemberById(leadTeamMember))
- emit(error(bounds("leadTeamMember", leadTeamMember)));
- else
- CHECK(leadTeamMember);
-}
-
-QString Sigmod::MapTrainer::name() const
-{
- return m_name;
-}
-
-int Sigmod::MapTrainer::trainerClass() const
-{
- return m_trainerClass;
-}
-
-QPoint Sigmod::MapTrainer::coordinate() const
-{
- return m_coordinate;
-}
-
-int Sigmod::MapTrainer::numberFight() const
-{
- return m_numberFight;
-}
-
-Sigcore::Script Sigmod::MapTrainer::script() const
-{
- return m_script;
-}
-
-int Sigmod::MapTrainer::leadTeamMember() const
-{
- return m_leadTeamMember;
-}
-
-const Sigmod::MapTrainerTeamMember* Sigmod::MapTrainer::teamMember(const int index) const
-{
- if (index < teamMemberCount())
- return m_teamMembers.at(index);
- return NULL;
-}
-
-Sigmod::MapTrainerTeamMember* Sigmod::MapTrainer::teamMember(const int index)
-{
- if (index < teamMemberCount())
- return m_teamMembers[index];
- return NULL;
-}
-
-const Sigmod::MapTrainerTeamMember* Sigmod::MapTrainer::teamMemberById(const int id) const
-{
- return teamMember(teamMemberIndex(id));
-}
-
-Sigmod::MapTrainerTeamMember* Sigmod::MapTrainer::teamMemberById(const int id)
-{
- return teamMember(teamMemberIndex(id));
-}
-
-int Sigmod::MapTrainer::teamMemberIndex(const int id) const
-{
- for (int i = 0; i < teamMemberCount(); ++i)
{
- if (m_teamMembers[i]->id() == id)
- return i;
+ EBOUNDS_IDX(leadTeamMember);
+ return false;
}
- return INT_MAX;
-}
-
-int Sigmod::MapTrainer::teamMemberCount() const
-{
- return m_teamMembers.size();
-}
+CHECK_END()
-Sigmod::MapTrainerTeamMember* Sigmod::MapTrainer::newTeamMember()
-{
- return newTeamMember(new MapTrainerTeamMember(this, newTeamMemberId()));
-}
-
-Sigmod::MapTrainerTeamMember* Sigmod::MapTrainer::newTeamMember(const QDomElement& xml)
-{
- return newTeamMember(new MapTrainerTeamMember(xml, this, newTeamMemberId()));
-}
-
-Sigmod::MapTrainerTeamMember* Sigmod::MapTrainer::newTeamMember(const MapTrainerTeamMember& teamMember)
-{
- return newTeamMember(new MapTrainerTeamMember(teamMember, this, newTeamMemberId()));
-}
-
-Sigmod::MapTrainerTeamMember* Sigmod::MapTrainer::newTeamMember(MapTrainerTeamMember* teamMember)
-{
- m_teamMembers.append(teamMember);
- return teamMember;
-}
-
-void Sigmod::MapTrainer::deleteTeamMember(const int index)
-{
- if (index < teamMemberCount())
- {
- delete m_teamMembers[index];
- m_teamMembers.removeAt(index);
- }
-}
-
-void Sigmod::MapTrainer::deleteTeamMemberById(const int id)
-{
- deleteTeamMember(teamMemberIndex(id));
-}
-
-int Sigmod::MapTrainer::newTeamMemberId() const
-{
- int i = 0;
- while ((i < teamMemberCount()) && (teamMemberIndex(i) != INT_MAX))
- ++i;
- return i;
-}
+SUBCLASS(MapTrainer, TeamMember, teamMember, teamMembers)
Sigmod::MapTrainer& Sigmod::MapTrainer::operator=(const MapTrainer& rhs)
{
@@ -277,6 +157,5 @@ Sigmod::MapTrainer& Sigmod::MapTrainer::operator=(const MapTrainer& rhs)
void Sigmod::MapTrainer::clear()
{
- while (teamMemberCount())
- deleteTeamMember(0);
+ SUBCLASS_CLEAR(teamMembers);
}
diff --git a/sigmod/MapTrainer.h b/sigmod/MapTrainer.h
index f01afdbe..27ba9c88 100644
--- a/sigmod/MapTrainer.h
+++ b/sigmod/MapTrainer.h
@@ -64,6 +64,13 @@ class SIGMOD_EXPORT MapTrainer : public Object
Sigcore::Script script() const;
int leadTeamMember() const;
+ bool nameCheck(const QString& name) const;
+ bool trainerClassCheck(const int trainerClass) const;
+ bool coordinateCheck(const QPoint& coordinate) const;
+ bool numberFightCheck(const int numberFight) const;
+ bool scriptCheck(const Sigcore::Script& script) const;
+ bool leadTeamMemberCheck(const int leadTeamMember) const;
+
const MapTrainerTeamMember* teamMember(const int index) const;
MapTrainerTeamMember* teamMember(const int index);
const MapTrainerTeamMember* teamMemberById(const int id) const;
diff --git a/sigmod/MapTrainerTeamMember.cpp b/sigmod/MapTrainerTeamMember.cpp
index dfeb84f8..29238063 100644
--- a/sigmod/MapTrainerTeamMember.cpp
+++ b/sigmod/MapTrainerTeamMember.cpp
@@ -59,20 +59,20 @@ Sigmod::MapTrainerTeamMember::MapTrainerTeamMember(const QDomElement& xml, const
void Sigmod::MapTrainerTeamMember::validate()
{
TEST_BEGIN();
- TEST(setSpecies, species);
- TEST(setLevel, level);
+ TEST(species);
+ TEST(level);
if (sigmod()->rules()->maxAbilities() < m_ability.size())
emit(error("Too many abilities"));
- TEST_LIST(setAbility, ability);
+ TEST_LIST(ability);
if (sigmod()->rules()->maxHeldItems() < m_item.size())
emit(error("Too many held items"));
- TEST_LIST(setItem, item);
+ TEST_LIST(item);
if (sigmod()->rules()->maxMoves() < m_move.size())
emit(error("Too many moves"));
- TEST_LIST(setMove, move);
+ TEST_LIST(move);
if (sigmod()->rules()->maxNatures() < m_nature.size())
emit(error("Too many natures"));
- TEST_LIST(setNature, nature);
+ TEST_LIST(nature);
TEST_END();
}
@@ -99,48 +99,13 @@ QDomElement Sigmod::MapTrainerTeamMember::save() const
return xml;
}
-void Sigmod::MapTrainerTeamMember::setSpecies(const int species)
-{
- if (!sigmod()->speciesById(species))
- emit(error(bounds("species", species)));
- else
- CHECK(species);
-}
-
-void Sigmod::MapTrainerTeamMember::setLevel(const int level)
-{
- if ((level <= 0) || (sigmod()->rules()->maxLevel() < level))
- emit(error(bounds("level", 0, sigmod()->rules()->maxLevel(), level)));
- else
- CHECK(level);
-}
-
-void Sigmod::MapTrainerTeamMember::setAbility(const int ability, const bool state)
-{
- if (!sigmod()->abilityById(ability))
- emit(error(bounds("ability", ability)));
- else if (state && !m_ability.contains(ability))
- {
- if (m_ability.size() < sigmod()->rules()->maxAbilities())
- {
- m_ability.append(ability);
- emit(changed());
- }
- else
- emit(error("Cannot have any more abilities"));
- }
- else if (m_ability.contains(ability))
- {
- m_ability.removeAll(ability);
- emit(changed());
- }
-}
+SETTER(MapTrainerTeamMember, int, Species, species)
+SETTER(MapTrainerTeamMember, int, Level, level)
+SETTER_LIST_LIMIT(MapTrainerTeamMember, Ability, ability, sigmod()->rules()->maxAbilities(), "Cannot have anymore abilities")
void Sigmod::MapTrainerTeamMember::setItem(const int item, const bool state)
{
- if (!sigmod()->itemById(item))
- emit(error(bounds("item", item)));
- else if (state && !m_item.contains(item))
+ if (itemCheck(item) && state && !m_item.contains(item))
{
if (m_item.size() < sigmod()->rules()->maxHeldItems())
{
@@ -150,10 +115,10 @@ void Sigmod::MapTrainerTeamMember::setItem(const int item, const bool state)
emit(changed());
}
else
- emit(error("Cannot carry that much weight"));
+ ERROR("Cannot carry that much weight");
}
else
- emit(error("Cannot hold any more items"));
+ ERROR("Cannot hold any more items");
}
else if (m_item.contains(item))
{
@@ -164,9 +129,7 @@ void Sigmod::MapTrainerTeamMember::setItem(const int item, const bool state)
void Sigmod::MapTrainerTeamMember::setMove(const int move, const bool state)
{
- if (!sigmod()->moveById(move))
- emit(error(bounds("move", move)));
- else if (state && !m_move.contains(move))
+ if (moveCheck(move) && state && !m_move.contains(move))
{
const Species* species = sigmod()->speciesById(move);
for (int i = 0; i < species->moveCount(); ++i)
@@ -178,13 +141,12 @@ void Sigmod::MapTrainerTeamMember::setMove(const int move, const bool state)
{
m_move.append(move);
emit(changed());
- return;
}
else
- emit(error("Cannot know any more moves"));
+ ERROR("Cannot know any more moves");
}
}
- emit(error("Cannot learn the move"));
+ ERROR("Cannot learn the move");
}
else if (m_move.contains(move))
{
@@ -193,76 +155,21 @@ void Sigmod::MapTrainerTeamMember::setMove(const int move, const bool state)
}
}
-void Sigmod::MapTrainerTeamMember::setNature(const int nature, const bool state)
-{
- if (!sigmod()->natureById(nature))
- emit(error(bounds("nature", nature)));
- else if (state && !m_nature.contains(nature))
- {
- if (m_nature.size() < sigmod()->rules()->maxNatures())
- {
- m_nature.append(nature);
- emit(changed());
- }
- else
- emit(error("Cannot have any more natures"));
- }
- else if (m_nature.contains(nature))
- {
- m_nature.removeAll(nature);
- emit(changed());
- }
-}
-
-int Sigmod::MapTrainerTeamMember::species() const
-{
- return m_species;
-}
-
-int Sigmod::MapTrainerTeamMember::level() const
-{
- return m_level;
-}
-
-bool Sigmod::MapTrainerTeamMember::ability(const int ability) const
-{
- return m_ability.contains(ability);
-}
+SETTER_LIST_LIMIT(MapTrainerTeamMember, Nature, nature, sigmod()->rules()->maxNatures(), "Cannot have anymore natures")
-QList<int> Sigmod::MapTrainerTeamMember::abilities() const
-{
- return m_ability;
-}
+GETTER(MapTrainerTeamMember, int, species)
+GETTER(MapTrainerTeamMember, int, level)
+GETTER_LIST(MapTrainerTeamMember, ability)
+GETTER_LIST(MapTrainerTeamMember, item)
+GETTER_LIST(MapTrainerTeamMember, move)
+GETTER_LIST(MapTrainerTeamMember, nature)
-bool Sigmod::MapTrainerTeamMember::item(const int item) const
-{
- return m_item.contains(item);
-}
-
-QList<int> Sigmod::MapTrainerTeamMember::items() const
-{
- return m_item;
-}
-
-bool Sigmod::MapTrainerTeamMember::move(const int move) const
-{
- return m_move.contains(move);
-}
-
-QList<int> Sigmod::MapTrainerTeamMember::moves() const
-{
- return m_move;
-}
-
-bool Sigmod::MapTrainerTeamMember::nature(const int nature) const
-{
- return m_nature.contains(nature);
-}
-
-QList<int> Sigmod::MapTrainerTeamMember::natures() const
-{
- return m_nature;
-}
+CHECK_INDEX(MapTrainerTeamMember, int, species, sigmod(), species)
+CHECK_BOUNDS(MapTrainerTeamMember, int, level, 1, sigmod()->rules()->maxLevel())
+CHECK_INDEX(MapTrainerTeamMember, int, ability, sigmod(), ability)
+CHECK_INDEX(MapTrainerTeamMember, int, item, sigmod(), item)
+CHECK_INDEX(MapTrainerTeamMember, int, move, sigmod(), move)
+CHECK_INDEX(MapTrainerTeamMember, int, nature, sigmod(), nature)
Sigmod::MapTrainerTeamMember& Sigmod::MapTrainerTeamMember::operator=(const MapTrainerTeamMember& rhs)
{
diff --git a/sigmod/MapTrainerTeamMember.h b/sigmod/MapTrainerTeamMember.h
index 2b5de59c..9aa7acc8 100644
--- a/sigmod/MapTrainerTeamMember.h
+++ b/sigmod/MapTrainerTeamMember.h
@@ -54,13 +54,20 @@ class SIGMOD_EXPORT MapTrainerTeamMember : public Object
int species() const;
int level() const;
bool ability(const int ability) const;
- QList<int> abilities() const;
+ QList<int> ability() const;
bool item(const int item) const;
- QList<int> items() const;
+ QList<int> item() const;
bool move(const int move) const;
- QList<int> moves() const;
+ QList<int> move() const;
bool nature(const int nature) const;
- QList<int> natures() const;
+ QList<int> nature() const;
+
+ bool speciesCheck(const int species) const;
+ bool levelCheck(const int level) const;
+ bool abilityCheck(const int ability) const;
+ bool itemCheck(const int item) const;
+ bool moveCheck(const int move) const;
+ bool natureCheck(const int nature) const;
MapTrainerTeamMember& operator=(const MapTrainerTeamMember& p);
protected:
diff --git a/sigmod/MapWarp.cpp b/sigmod/MapWarp.cpp
index 137c5f98..157f2de9 100644
--- a/sigmod/MapWarp.cpp
+++ b/sigmod/MapWarp.cpp
@@ -60,9 +60,9 @@ void Sigmod::MapWarp::validate()
TEST_BEGIN();
if (m_name.isEmpty())
emit(error("Name is empty"));
- TEST(setArea, area);
- TEST(setToMap, toMap);
- TEST(setToWarp, toWarp);
+ TEST(area);
+ TEST(toMap);
+ TEST(toWarp);
TEST_END();
}
@@ -89,80 +89,37 @@ QDomElement Sigmod::MapWarp::save() const
return xml;
}
-void Sigmod::MapWarp::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::MapWarp::setArea(const QRect& area)
-{
- const Map* map = qobject_cast<const Map*>(parent());
- if ((map->width() <= area.x()) || (map->height() <= area.y()))
- emit(error(bounds("area", QPoint(0, 0), QPoint(map->width(), map->height()), area.topLeft())));
- else if ((area.width() <= 0) || (area.height() <= 0) || ((map->width() - area.x()) < area.width()) || ((map->height() - area.y()) < area.height()))
- emit(error(bounds("area size", QPoint(0, 0), QPoint(map->width() - area.x(), map->height() - area.y()), area.translated(-area.topLeft()).bottomRight())));
- else
- CHECK(area);
-}
-
-void Sigmod::MapWarp::setType(const Type type)
-{
- CHECK(type);
-}
+SETTER(MapWarp, QString&, Name, name)
+SETTER(MapWarp, QRect&, Area, area)
+SETTER(MapWarp, Type, Type, type)
+SETTER(MapWarp, int, ToMap, toMap)
+SETTER(MapWarp, int, ToWarp, toWarp)
+SETTER(MapWarp, Sigcore::Script&, Script, script)
-void Sigmod::MapWarp::setToMap(const int toMap)
-{
- if (!sigmod()->mapById(toMap))
- emit(error(bounds("toMap", toMap)));
- else
- CHECK(toMap);
-}
+GETTER(MapWarp, QString, name)
+GETTER(MapWarp, QRect, area)
+GETTER(MapWarp, Sigmod::MapWarp::Type, type)
+GETTER(MapWarp, int, toMap)
+GETTER(MapWarp, int, toWarp)
+GETTER(MapWarp, Sigcore::Script, script)
-void Sigmod::MapWarp::setToWarp(const int toWarp)
-{
- const Map* map = sigmod()->mapById(m_toMap);
+CHECK(MapWarp, QString&, name)
+CHECK_BEGIN(MapWarp, QRect&, area)
+ const Map* map = qobject_cast<const Map*>(parent());
+ TBOUNDS_MOD(area_x, 0, map->width() - 1, area.x());
+ TBOUNDS_MOD(area_y, 0, map->height() - 1, area.y());
+ TBOUNDS_MOD(area_width, 1, map->width() - area.x(), area.width());
+ TBOUNDS_MOD(area_height, 1, map->height() - area.y(), area.height());
+CHECK_END()
+CHECK(MapWarp, Type, type)
+CHECK_INDEX(MapWarp, int, toMap, sigmod(), map)
+CHECK_BEGIN(MapWarp, int, toWarp)
+ const Map* map = qobject_cast<const Map*>(parent());
if (!map)
- emit(error(bounds("toMap", m_toMap)));
- else if (!map->warpById(toWarp))
- emit(error(bounds("toWarp", toWarp)));
- else
- CHECK(toWarp);
-}
-
-void Sigmod::MapWarp::setScript(const Sigcore::Script& script)
-{
- CHECK(script);
-}
-
-QString Sigmod::MapWarp::name() const
-{
- return m_name;
-}
-
-QRect Sigmod::MapWarp::area() const
-{
- return m_area;
-}
-
-Sigmod::MapWarp::Type Sigmod::MapWarp::type() const
-{
- return m_type;
-}
-
-int Sigmod::MapWarp::toMap() const
-{
- return m_toMap;
-}
-
-int Sigmod::MapWarp::toWarp() const
-{
- return m_toWarp;
-}
-
-Sigcore::Script Sigmod::MapWarp::script() const
-{
- return m_script;
-}
+ EBOUNDS_IDX(m_toMap);
+ IBOUNDS(toWarp, map, warp);
+CHECK_END()
+CHECK(MapWarp, Sigcore::Script&, script)
Sigmod::MapWarp& Sigmod::MapWarp::operator=(const MapWarp& rhs)
{
diff --git a/sigmod/MapWarp.h b/sigmod/MapWarp.h
index dfdef6c3..8df320ad 100644
--- a/sigmod/MapWarp.h
+++ b/sigmod/MapWarp.h
@@ -71,6 +71,13 @@ class SIGMOD_EXPORT MapWarp : public Object
int toWarp() const;
Sigcore::Script script() const;
+ bool nameCheck(const QString& name) const;
+ bool areaCheck(const QRect& area) const;
+ bool typeCheck(const Type type) const;
+ bool toMapCheck(const int toMap) const;
+ bool toWarpCheck(const int toWarp) const;
+ bool scriptCheck(const Sigcore::Script& script) const;
+
MapWarp& operator=(const MapWarp& rhs);
private:
QString m_name;
diff --git a/sigmod/MapWildList.cpp b/sigmod/MapWildList.cpp
index 1a385632..27820147 100644
--- a/sigmod/MapWildList.cpp
+++ b/sigmod/MapWildList.cpp
@@ -85,97 +85,13 @@ QDomElement Sigmod::MapWildList::save() const
return xml;
}
-void Sigmod::MapWildList::setName(const QString& name)
-{
- CHECK(name);
-}
+SETTER(MapWildList, QString&, Name, name)
-QString Sigmod::MapWildList::name() const
-{
- return m_name;
-}
+GETTER(MapWildList, QString, name)
-const Sigmod::MapWildListEncounter* Sigmod::MapWildList::encounter(const int index) const
-{
- if (index < encounterCount())
- return m_encounters.at(index);
- return NULL;
-}
-
-Sigmod::MapWildListEncounter* Sigmod::MapWildList::encounter(const int index)
-{
- if (index < encounterCount())
- return m_encounters[index];
- return NULL;
-}
-
-const Sigmod::MapWildListEncounter* Sigmod::MapWildList::encounterById(const int id) const
-{
- return encounter(encounterIndex(id));
-}
-
-Sigmod::MapWildListEncounter* Sigmod::MapWildList::encounterById(const int id)
-{
- return encounter(encounterIndex(id));
-}
-
-int Sigmod::MapWildList::encounterIndex(const int id) const
-{
- for (int i = 0; i < encounterCount(); ++i)
- {
- if (m_encounters[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::MapWildList::encounterCount() const
-{
- return m_encounters.size();
-}
+CHECK(MapWildList, QString&, name)
-Sigmod::MapWildListEncounter* Sigmod::MapWildList::newEncounter()
-{
- return newEncounter(new MapWildListEncounter(this, newEncounterId()));
-}
-
-Sigmod::MapWildListEncounter* Sigmod::MapWildList::newEncounter(const QDomElement& xml)
-{
- return newEncounter(new MapWildListEncounter(xml, this, newEncounterId()));
-}
-
-Sigmod::MapWildListEncounter* Sigmod::MapWildList::newEncounter(const MapWildListEncounter& encounter)
-{
- return newEncounter(new MapWildListEncounter(encounter, this, newEncounterId()));
-}
-
-Sigmod::MapWildListEncounter* Sigmod::MapWildList::newEncounter(MapWildListEncounter* encounter)
-{
- m_encounters.append(encounter);
- return encounter;
-}
-
-void Sigmod::MapWildList::deleteEncounter(const int index)
-{
- if (index < encounterCount())
- {
- delete m_encounters[index];
- m_encounters.removeAt(index);
- }
-}
-
-void Sigmod::MapWildList::deleteEncounterById(const int id)
-{
- deleteEncounter(encounterIndex(id));
-}
-
-int Sigmod::MapWildList::newEncounterId() const
-{
- int i = 0;
- while ((i < encounterCount()) && (encounterIndex(i) != INT_MAX))
- ++i;
- return i;
-}
+SUBCLASS(MapWildList, Encounter, encounter, encounters)
Sigmod::MapWildList& Sigmod::MapWildList::operator=(const MapWildList& rhs)
{
@@ -189,6 +105,5 @@ Sigmod::MapWildList& Sigmod::MapWildList::operator=(const MapWildList& rhs)
void Sigmod::MapWildList::clear()
{
- qDeleteAll(m_encounters);
- m_encounters.clear();
+ SUBCLASS_CLEAR(encounters);
}
diff --git a/sigmod/MapWildList.h b/sigmod/MapWildList.h
index 01ad6e03..66a04cc5 100644
--- a/sigmod/MapWildList.h
+++ b/sigmod/MapWildList.h
@@ -50,6 +50,8 @@ class SIGMOD_EXPORT MapWildList : public Object
QString name() const;
+ bool nameCheck(const QString& name) const;
+
const MapWildListEncounter* encounter(const int index) const;
MapWildListEncounter* encounter(const int index);
const MapWildListEncounter* encounterById(const int id) const;
diff --git a/sigmod/MapWildListEncounter.cpp b/sigmod/MapWildListEncounter.cpp
index 39b5a79e..36a4cd35 100644
--- a/sigmod/MapWildListEncounter.cpp
+++ b/sigmod/MapWildListEncounter.cpp
@@ -55,9 +55,9 @@ Sigmod::MapWildListEncounter::MapWildListEncounter(const QDomElement& xml, const
void Sigmod::MapWildListEncounter::validate()
{
TEST_BEGIN();
- TEST(setSpecies, species);
- TEST(setLevel, level);
- TEST(setWeight, weight);
+ TEST(species);
+ TEST(level);
+ TEST(weight);
TEST_END();
}
@@ -78,44 +78,17 @@ QDomElement Sigmod::MapWildListEncounter::save() const
return xml;
}
-void Sigmod::MapWildListEncounter::setSpecies(const int species)
-{
- if (!sigmod()->speciesById(species))
- emit(error(bounds("species", species)));
- else
- CHECK(species);
-}
-
-void Sigmod::MapWildListEncounter::setLevel(const int level)
-{
- if ((level <= 0) || (sigmod()->rules()->maxLevel() <= level))
- emit(error(bounds("level", 1, sigmod()->rules()->maxLevel(), level)));
- else
- CHECK(level);
-}
+SETTER(MapWildListEncounter, int, Species, species)
+SETTER(MapWildListEncounter, int, Level, level)
+SETTER(MapWildListEncounter, int, Weight, weight)
-void Sigmod::MapWildListEncounter::setWeight(const int weight)
-{
- if (weight <= 0)
- emit(error(bounds("weight", 1, INT_MAX, weight)));
- else
- CHECK(weight);
-}
+GETTER(MapWildListEncounter, int, species)
+GETTER(MapWildListEncounter, int, level)
+GETTER(MapWildListEncounter, int, weight)
-int Sigmod::MapWildListEncounter::species() const
-{
- return m_species;
-}
-
-int Sigmod::MapWildListEncounter::level() const
-{
- return m_level;
-}
-
-int Sigmod::MapWildListEncounter::weight() const
-{
- return m_weight;
-}
+CHECK_INDEX(MapWildListEncounter, int, species, sigmod(), species)
+CHECK_BOUNDS(MapWildListEncounter, int, level, 1, sigmod()->rules()->maxLevel())
+CHECK_BOUNDS(MapWildListEncounter, int, weight, 1, INT_MAX)
Sigmod::MapWildListEncounter& Sigmod::MapWildListEncounter::operator=(const MapWildListEncounter& rhs)
{
diff --git a/sigmod/MapWildListEncounter.h b/sigmod/MapWildListEncounter.h
index 45932f80..34b9d02b 100644
--- a/sigmod/MapWildListEncounter.h
+++ b/sigmod/MapWildListEncounter.h
@@ -49,6 +49,10 @@ class SIGMOD_EXPORT MapWildListEncounter: public Object
int level() const;
int weight() const;
+ bool speciesCheck(const int species) const;
+ bool levelCheck(const int level) const;
+ bool weightCheck(const int weight) const;
+
MapWildListEncounter& operator=(const MapWildListEncounter& rhs);
private:
int m_species;
diff --git a/sigmod/Move.cpp b/sigmod/Move.cpp
index 76fdc7f3..a03ffbae 100644
--- a/sigmod/Move.cpp
+++ b/sigmod/Move.cpp
@@ -70,9 +70,10 @@ void Sigmod::Move::validate()
TEST_BEGIN();
if (m_name.isEmpty())
emit(error("Name is empty"));
- TEST(setAccuracy, accuracy);
- TEST(setType, type);
- TEST(setPowerPoints, powerPoints);
+ TEST(accuracy);
+ TEST(power);
+ TEST(type);
+ TEST(powerPoints);
TEST_END();
}
@@ -109,124 +110,41 @@ QDomElement Sigmod::Move::save() const
return xml;
}
-void Sigmod::Move::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::Move::setAccuracy(const Sigcore::Fraction& accuracy)
-{
- if ((accuracy < 0) || (1 < accuracy))
- emit(error(bounds("accuracy", 0, 1, accuracy)));
- else
- CHECK(accuracy);
-}
-
-void Sigmod::Move::setPower(const int power)
-{
- CHECK(power);
-}
-
-void Sigmod::Move::setType(const int type)
-{
- if (!sigmod()->typeById(type))
- emit(error(bounds("type", type)));
- else
- CHECK(type);
-}
-
-void Sigmod::Move::setSpecial(const bool special)
-{
- CHECK(special);
-}
-
-void Sigmod::Move::setPowerPoints(const int powerPoints)
-{
- if (powerPoints <= 0)
- emit(error(bounds("powerPoints", 1, INT_MAX, powerPoints)));
- else
- CHECK(powerPoints);
-}
-
-void Sigmod::Move::setPriority(const int priority)
-{
- CHECK(priority);
-}
-
-void Sigmod::Move::setDescription(const QString& description)
-{
- CHECK(description);
-}
-
-void Sigmod::Move::setBattleScript(const Sigcore::Script& battleScript)
-{
- CHECK(battleScript);
-}
-
-void Sigmod::Move::setWorldScript(const Sigcore::Script& worldScript)
-{
- CHECK(worldScript);
-}
-
-void Sigmod::Move::setPriorityScript(const Sigcore::Script& priorityScript)
-{
- CHECK(priorityScript);
-}
-
-QString Sigmod::Move::name() const
-{
- return m_name;
-}
-
-Sigcore::Fraction Sigmod::Move::accuracy() const
-{
- return m_accuracy;
-}
-
-int Sigmod::Move::power() const
-{
- return m_power;
-}
-
-int Sigmod::Move::type() const
-{
- return m_type;
-}
-
-bool Sigmod::Move::special() const
-{
- return m_special;
-}
-
-int Sigmod::Move::powerPoints() const
-{
- return m_powerPoints;
-}
-
-int Sigmod::Move::priority() const
-{
- return m_priority;
-}
-
-QString Sigmod::Move::description() const
-{
- return m_description;
-}
-
-Sigcore::Script Sigmod::Move::battleScript() const
-{
- return m_battleScript;
-}
-
-Sigcore::Script Sigmod::Move::worldScript() const
-{
- return m_worldScript;
-}
-
-Sigcore::Script Sigmod::Move::priorityScript() const
-{
- return m_priorityScript;
-}
+SETTER(Move, QString&, Name, name)
+SETTER(Move, Sigcore::Fraction&, Accuracy, accuracy)
+SETTER(Move, int, Power, power)
+SETTER(Move, int, Type, type)
+SETTER(Move, bool, Special, special)
+SETTER(Move, int, PowerPoints, powerPoints)
+SETTER(Move, int, Priority, priority)
+SETTER(Move, QString&, Description, description)
+SETTER(Move, Sigcore::Script&, BattleScript, battleScript)
+SETTER(Move, Sigcore::Script&, WorldScript, worldScript)
+SETTER(Move, Sigcore::Script&, PriorityScript, priorityScript)
+
+GETTER(Move, QString, name)
+GETTER(Move, Sigcore::Fraction, accuracy)
+GETTER(Move, int, power)
+GETTER(Move, int, type)
+GETTER(Move, bool, special)
+GETTER(Move, int, powerPoints)
+GETTER(Move, int, priority)
+GETTER(Move, QString, description)
+GETTER(Move, Sigcore::Script, battleScript)
+GETTER(Move, Sigcore::Script, worldScript)
+GETTER(Move, Sigcore::Script, priorityScript)
+
+CHECK(Move, QString&, name)
+CHECK_BOUNDS(Move, Sigcore::Fraction&, accuracy, 0, 1)
+CHECK_BOUNDS(Move, int, power, 0, INT_MAX)
+CHECK_INDEX(Move, int, type, sigmod(), type)
+CHECK(Move, bool, special)
+CHECK_BOUNDS(Move, int, powerPoints, 1, INT_MAX)
+CHECK(Move, int, priority)
+CHECK(Move, QString&, description)
+CHECK(Move, Sigcore::Script&, battleScript)
+CHECK(Move, Sigcore::Script&, worldScript)
+CHECK(Move, Sigcore::Script&, priorityScript)
Sigmod::Move& Sigmod::Move::operator=(const Move& rhs)
{
diff --git a/sigmod/Move.h b/sigmod/Move.h
index f4a6d2da..d9345b1d 100644
--- a/sigmod/Move.h
+++ b/sigmod/Move.h
@@ -70,6 +70,18 @@ class SIGMOD_EXPORT Move : public Object
Sigcore::Script worldScript() const;
Sigcore::Script priorityScript() const;
+ bool nameCheck(const QString& name) const;
+ bool accuracyCheck(const Sigcore::Fraction& accuracy) const;
+ bool powerCheck(const int power) const;
+ bool typeCheck(const int type) const;
+ bool specialCheck(const bool special) const;
+ bool powerPointsCheck(const int powerPoints) const;
+ bool priorityCheck(const int priority) const;
+ bool descriptionCheck(const QString& description) const;
+ bool battleScriptCheck(const Sigcore::Script& battleScript) const;
+ bool worldScriptCheck(const Sigcore::Script& worldScript) const;
+ bool priorityScriptCheck(const Sigcore::Script& priorityScript) const;
+
Move& operator=(const Move& rhs);
private:
QString m_name;
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)
{
diff --git a/sigmod/Nature.h b/sigmod/Nature.h
index 7c658832..80322912 100644
--- a/sigmod/Nature.h
+++ b/sigmod/Nature.h
@@ -52,6 +52,10 @@ class SIGMOD_EXPORT Nature : public Object
Sigcore::Fraction stat(const Stat stat) const;
int weight() const;
+ bool nameCheck(const QString& name) const;
+ bool statCheck(const Stat stat, const Sigcore::Fraction& multiplier) const;
+ bool weightCheck(const int weight) const;
+
Nature& operator=(const Nature& rhs);
private:
void setStat(const Sigcore::Fraction& multiplier);
diff --git a/sigmod/Object.cpp b/sigmod/Object.cpp
index 99e42f16..35e68b8d 100644
--- a/sigmod/Object.cpp
+++ b/sigmod/Object.cpp
@@ -44,15 +44,11 @@ const Sigmod::Sigmod* Sigmod::Object::sigmod() const
return qobject_cast<const Sigmod*>(this);
}
-int Sigmod::Object::id() const
-{
- return m_id;
-}
+GETTER(Object, int, id)
-void Sigmod::Object::setId(const int id)
-{
- CHECK(id);
-}
+SETTER(Object, int, Id, id)
+
+CHECK_BOUNDS(Object, int, id, 0, INT_MAX)
QDomDocument Sigmod::Object::xml(const Object* object)
{
@@ -73,40 +69,32 @@ QString Sigmod::Object::unused(const QString& variable)
QString Sigmod::Object::bounds(const QString& variable, const int min, const int max, const int value)
{
- QString msg = QString("Value for %1 out-of-bounds (%2 -- %3) (%4)");
- msg.arg(variable);
+ QString msg = QString("Value for %1 out-of-bounds (%2 -- %3) (%4)").arg(variable);
if (min == INT_MIN)
- msg.arg(QString::fromUtf8("-∞"));
+ msg = msg.arg(QString::fromUtf8("-∞"));
else
- msg.arg(min);
+ msg = msg.arg(min);
if (max == INT_MAX)
- msg.arg(QString::fromUtf8("∞"));
+ msg = msg.arg(QString::fromUtf8("∞"));
else
- msg.arg(max);
+ msg = msg.arg(max);
return msg.arg(value);
}
QString Sigmod::Object::bounds(const QString& variable, const int min, const int max, const Sigcore::Fraction& value)
{
- QString msg("Value for %1 out-of-bounds (%2 -- %3) (%4 / %5)");
- msg.arg(variable);
+ QString msg = QString("Value for %1 out-of-bounds (%2 -- %3) (%4 / %5)").arg(variable);
if (min == INT_MIN)
- msg.arg(QString::fromUtf8("-∞"));
+ msg = msg.arg(QString::fromUtf8("-∞"));
else
- msg.arg(min);
+ msg = msg.arg(min);
if (max == INT_MAX)
- msg.arg(QString::fromUtf8("∞"));
+ msg = msg.arg(QString::fromUtf8("∞"));
else
- msg.arg(max);
+ msg = msg.arg(max);
return msg.arg(value.numerator()).arg(value.denominator());
}
-QString Sigmod::Object::bounds(const QString& variable, const QPoint& min, const QPoint& max, const QPoint& value)
-{
- QString msg("Value for %1 out-of-bounds ((%2, %3) -- (%4, %5)) (%6 / %7)");
- return msg.arg(variable).arg(min.x()).arg(min.y()).arg(max.x()).arg(max.y()).arg(value.x()).arg(value.y());
-}
-
QString Sigmod::Object::bounds(const QString& variable, const QString& min, const QString& max, const int value)
{
return QString("Value for %1 out-of-bounds (%2 -- %3) (%4)").arg(variable).arg(min).arg(max).arg(value);
diff --git a/sigmod/Object.h b/sigmod/Object.h
index c6e857b7..08d0bfaf 100644
--- a/sigmod/Object.h
+++ b/sigmod/Object.h
@@ -152,12 +152,12 @@ class SIGMOD_EXPORT Object : public QObject
void changed() const;
protected:
void setId(const int id);
+ bool idCheck(const int id) const;
static QString unused(const QString& variable);
static QString bounds(const QString& variable, const int min, const int max, const int value);
static QString bounds(const QString& variable, const int min, const int max, const Sigcore::Fraction& value);
static QString bounds(const QString& variable, const QString& min, const QString& max, const int value);
- static QString bounds(const QString& variable, const QPoint& min, const QPoint& max, const QPoint& value);
static QString bounds(const QString& variable, const int value);
static QString bounds(const QString& variable, const QString& value);
static QString subclass(const QString& subclass, const int id);
diff --git a/sigmod/Rules.cpp b/sigmod/Rules.cpp
index 3de6fe1a..9f9394a4 100644
--- a/sigmod/Rules.cpp
+++ b/sigmod/Rules.cpp
@@ -74,23 +74,26 @@ Sigmod::Rules::Rules(const QDomElement& xml, const Sigmod* parent) :
void Sigmod::Rules::validate()
{
TEST_BEGIN();
- TEST(setBreedingAllowed, breedingAllowed);
- TEST(setNumBoxes, numBoxes);
- TEST(setBoxSize, boxSize);
- TEST(setMaxParty, maxParty);
- TEST(setMaxFight, maxFight);
- TEST(setMaxPlayers, maxPlayers);
- TEST(setMaxMoves, maxMoves);
- TEST(setMaxLevel, maxLevel);
- TEST(setMaxStages, maxStages);
+ TEST(breedingAllowed);
+ TEST(numBoxes);
+ TEST(boxSize);
+ TEST(maxParty);
+ TEST(maxFight);
+ TEST(maxPlayers);
+ TEST(maxHeldItems);
+ TEST(maxAbilities);
+ TEST(maxNatures);
+ TEST(maxMoves);
+ TEST(maxLevel);
+ TEST(maxStages);
if (!m_maxMoney)
emit(warning("Player cannot carry any money"));
else
- TEST(setMaxMoney, maxMoney);
- TEST(setMaxTotalWeight, maxTotalWeight);
+ TEST(maxMoney);
+ TEST(maxTotalWeight);
if (m_effortValuesAllowed)
{
- TEST(setMaxEVPerStat, maxEVPerStat);
+ TEST(maxEVPerStat);
}
TEST_END();
}
@@ -154,287 +157,110 @@ QDomElement Sigmod::Rules::save() const
return xml;
}
-void Sigmod::Rules::setGenderAllowed(const bool genderAllowed)
-{
- CHECK(genderAllowed);
-}
-
-void Sigmod::Rules::setBreedingAllowed(const bool breedingAllowed)
-{
+SETTER(Rules, bool, GenderAllowed, genderAllowed)
+SETTER(Rules, bool, BreedingAllowed, breedingAllowed)
+SETTER(Rules, bool, CriticalDomains, criticalDomains)
+SETTER(Rules, bool, UseTurns, useTurns)
+SETTER(Rules, bool, PausedATB, pausedATB)
+SETTER(Rules, int, NumBoxes, numBoxes)
+SETTER(Rules, int, BoxSize, boxSize)
+SETTER(Rules, int, MaxParty, maxParty)
+SETTER(Rules, int, MaxFight, maxFight)
+SETTER(Rules, int, MaxPlayers, maxPlayers)
+SETTER(Rules, int, MaxHeldItems, maxHeldItems)
+SETTER(Rules, int, MaxAbilities, maxAbilities)
+SETTER(Rules, int, MaxNatures, maxNatures)
+SETTER(Rules, int, MaxMoves, maxMoves)
+SETTER(Rules, int, MaxLevel, maxLevel)
+SETTER(Rules, int, MaxStages, maxStages)
+SETTER(Rules, int, MaxMoney, maxMoney)
+SETTER(Rules, int, MaxTotalWeight, maxTotalWeight)
+SETTER(Rules, bool, AllowSwitchStyle, allowSwitchStyle)
+SETTER(Rules, bool, SpecialSplit, specialSplit)
+SETTER(Rules, bool, SpecialDVSplit, specialDVSplit)
+SETTER(Rules, bool, EffortValuesAllowed, effortValuesAllowed)
+SETTER(Rules, int, MaxTotalEV, maxTotalEV)
+SETTER(Rules, int, MaxEVPerStat, maxEVPerStat)
+
+GETTER(Rules, bool, genderAllowed)
+GETTER(Rules, bool, breedingAllowed)
+GETTER(Rules, bool, criticalDomains)
+GETTER(Rules, bool, useTurns)
+GETTER(Rules, bool, pausedATB)
+GETTER(Rules, int, numBoxes)
+GETTER(Rules, int, boxSize)
+GETTER(Rules, int, maxParty)
+GETTER(Rules, int, maxFight)
+GETTER(Rules, int, maxPlayers)
+GETTER(Rules, int, maxHeldItems)
+GETTER(Rules, int, maxAbilities)
+GETTER(Rules, int, maxNatures)
+GETTER(Rules, int, maxMoves)
+GETTER(Rules, int, maxLevel)
+GETTER(Rules, int, maxStages)
+GETTER(Rules, int, maxMoney)
+GETTER(Rules, int, maxTotalWeight)
+GETTER(Rules, bool, allowSwitchStyle)
+GETTER(Rules, bool, specialSplit)
+GETTER(Rules, bool, specialDVSplit)
+GETTER(Rules, bool, effortValuesAllowed)
+GETTER(Rules, int, maxTotalEV)
+GETTER(Rules, int, maxEVPerStat)
+
+CHECK(Rules, bool, genderAllowed)
+CHECK_BEGIN(Rules, bool, breedingAllowed)
if (!m_genderAllowed && breedingAllowed)
- emit(error(bounds("breedingAllowed", breedingAllowed)));
- else
- CHECK(breedingAllowed);
-}
-
-void Sigmod::Rules::setCriticalDomains(const bool criticalDomains)
-{
- CHECK(criticalDomains);
-}
-
-void Sigmod::Rules::setUseTurns(const bool useTurns)
-{
- CHECK(useTurns);
-}
-
-void Sigmod::Rules::setPausedATB(const bool pausedATB)
-{
+ {
+ ERROR("Cannot breed when genders are not allowed");
+ return false;
+ }
+CHECK_END()
+CHECK(Rules, bool, criticalDomains)
+CHECK(Rules, bool, useTurns)
+CHECK_BEGIN(Rules, bool, pausedATB)
if (m_useTurns && pausedATB)
- emit(error(bounds("pausedATB", pausedATB)));
- else
- CHECK(pausedATB);
-}
-
-void Sigmod::Rules::setNumBoxes(const int numBoxes)
-{
- CHECK(numBoxes);
-}
-
-void Sigmod::Rules::setBoxSize(const int boxSize)
-{
- if (m_numBoxes && (boxSize <= 0))
- emit(error(bounds("boxSize", 1, INT_MAX, boxSize)));
- else
- CHECK(boxSize);
-}
-
-void Sigmod::Rules::setMaxParty(const int maxParty)
-{
- if (maxParty <= 0)
- emit(error(bounds("maxParty", 1, INT_MAX, maxParty)));
- else
- CHECK(maxParty);
-}
-
-void Sigmod::Rules::setMaxFight(const int maxFight)
-{
- if ((maxFight <= 0) || (m_maxParty < maxFight))
- emit(error(bounds("maxFight", 1, m_maxParty, maxFight)));
- else
- CHECK(maxFight);
-}
-
-void Sigmod::Rules::setMaxPlayers(const int maxPlayers)
-{
- if (maxPlayers < 2)
- emit(error(bounds("maxPlayers", 2, INT_MAX, maxPlayers)));
- else
- CHECK(maxPlayers);
-}
-
-void Sigmod::Rules::setMaxHeldItems(const int maxHeldItems)
-{
- CHECK(maxHeldItems);
-}
-
-void Sigmod::Rules::setMaxAbilities(const int maxAbilities)
-{
- CHECK(maxAbilities);
-}
-
-void Sigmod::Rules::setMaxNatures(const int maxNatures)
-{
- CHECK(maxNatures);
-}
-
-void Sigmod::Rules::setMaxMoves(const int maxMoves)
-{
- if (maxMoves <= 0)
- emit(error(bounds("maxMoves", 1, INT_MAX, maxMoves)));
- else
- CHECK(maxMoves);
-}
-
-void Sigmod::Rules::setMaxLevel(const int maxLevel)
-{
- if (maxLevel <= 0)
- emit(error(bounds("maxLevel", 1, INT_MAX, maxLevel)));
- else
- CHECK(maxLevel);
-}
-
-void Sigmod::Rules::setMaxStages(const int maxStages)
-{
- if (maxStages < 0)
- emit(error(bounds("maxStages", 0, INT_MAX, maxStages)));
- else
- CHECK(maxStages);
-}
-
-void Sigmod::Rules::setMaxMoney(const int maxMoney)
-{
- if (maxMoney < 0)
- emit(error(bounds("maxMoney", 0, INT_MAX, maxMoney)));
- else
- CHECK(maxMoney);
-}
-
-void Sigmod::Rules::setMaxTotalWeight(const int maxTotalWeight)
-{
- if (maxTotalWeight < -1)
- emit(error(bounds("maxTotalWeight", -1, INT_MAX, maxTotalWeight)));
- else
- CHECK(maxTotalWeight);
-}
-
-void Sigmod::Rules::setAllowSwitchStyle(const bool allowSwitchStyle)
-{
- CHECK(allowSwitchStyle);
-}
-
-void Sigmod::Rules::setSpecialSplit(const bool specialSplit)
-{
- CHECK(specialSplit);
-}
-
-void Sigmod::Rules::setSpecialDVSplit(const bool specialDVSplit)
-{
- if (!specialDVSplit && m_specialSplit)
- emit(error(bounds("specialDVSplit", specialDVSplit)));
- else
- CHECK(specialDVSplit);
-}
-
-void Sigmod::Rules::setEffortValuesAllowed(const bool effortValuesAllowed)
-{
- CHECK(effortValuesAllowed);
-}
-
-void Sigmod::Rules::setMaxTotalEV(const int maxTotalEV)
-{
- if (maxTotalEV <= 0)
- emit(error(bounds("maxTotalEV", maxTotalEV)));
- else
- CHECK(maxTotalEV);
-}
-
-void Sigmod::Rules::setMaxEVPerStat(const int maxEVPerStat)
-{
- if ((m_maxTotalEV && (maxEVPerStat <= 0)) || (m_maxTotalEV < maxEVPerStat))
- emit(error(bounds("maxEVPerStat", 1, m_maxTotalEV, maxEVPerStat)));
- else
- CHECK(maxEVPerStat);
-}
-
-bool Sigmod::Rules::genderAllowed() const
-{
- return m_genderAllowed;
-}
-
-bool Sigmod::Rules::breedingAllowed() const
-{
- return m_breedingAllowed;
-}
-
-bool Sigmod::Rules::criticalDomains() const
-{
- return m_criticalDomains;
-}
-
-bool Sigmod::Rules::useTurns() const
-{
- return m_useTurns;
-}
-
-bool Sigmod::Rules::pausedATB() const
-{
- return m_pausedATB;
-}
-
-int Sigmod::Rules::numBoxes() const
-{
- return m_numBoxes;
-}
-
-int Sigmod::Rules::boxSize() const
-{
- return m_boxSize;
-}
-
-int Sigmod::Rules::maxParty() const
-{
- return m_maxParty;
-}
-
-int Sigmod::Rules::maxFight() const
-{
- return m_maxFight;
-}
-
-int Sigmod::Rules::maxPlayers() const
-{
- return m_maxPlayers;
-}
-
-int Sigmod::Rules::maxHeldItems() const
-{
- return m_maxHeldItems;
-}
-
-int Sigmod::Rules::maxAbilities() const
-{
- return m_maxAbilities;
-}
-
-int Sigmod::Rules::maxNatures() const
-{
- return m_maxNatures;
-}
-
-int Sigmod::Rules::maxMoves() const
-{
- return m_maxMoves;
-}
-
-int Sigmod::Rules::maxLevel() const
-{
- return m_maxLevel;
-}
-
-int Sigmod::Rules::maxStages() const
-{
- return m_maxStages;
-}
-
-int Sigmod::Rules::maxMoney() const
-{
- return m_maxMoney;
-}
-
-int Sigmod::Rules::maxTotalWeight() const
-{
- return m_maxTotalWeight;
-}
-
-bool Sigmod::Rules::allowSwitchStyle() const
-{
- return m_allowSwitchStyle;
-}
-
-bool Sigmod::Rules::specialSplit() const
-{
- return m_specialSplit;
-}
-
-bool Sigmod::Rules::specialDVSplit() const
-{
- return m_specialDVSplit;
-}
-
-bool Sigmod::Rules::effortValuesAllowed() const
-{
- return m_effortValuesAllowed;
-}
-
-int Sigmod::Rules::maxTotalEV() const
-{
- return m_maxTotalEV;
-}
-
-int Sigmod::Rules::maxEVPerStat() const
-{
- return m_maxEVPerStat;
-}
+ {
+ ERROR("Cannot pause ATB when turns are used");
+ return false;
+ }
+CHECK_END()
+CHECK(Rules, int, numBoxes)
+CHECK_BEGIN(Rules, int, boxSize)
+ if (m_numBoxes)
+ {
+ TBOUNDS(boxSize, 1, INT_MAX);
+ return false;
+ }
+CHECK_END()
+CHECK_BOUNDS(Rules, int, maxParty, 1, INT_MAX)
+CHECK_BOUNDS(Rules, int, maxFight, 1, m_maxParty)
+CHECK_BOUNDS(Rules, int, maxPlayers, 2, INT_MAX)
+CHECK_BOUNDS(Rules, int, maxHeldItems, 0, INT_MAX)
+CHECK_BOUNDS(Rules, int, maxAbilities, 0, INT_MAX)
+CHECK_BOUNDS(Rules, int, maxNatures, 0, INT_MAX)
+CHECK_BOUNDS(Rules, int, maxMoves, 1, INT_MAX)
+CHECK_BOUNDS(Rules, int, maxLevel, 1, INT_MAX)
+CHECK_BOUNDS(Rules, int, maxStages, 0, INT_MAX)
+CHECK_BOUNDS(Rules, int, maxMoney, 0, INT_MAX)
+CHECK_BOUNDS(Rules, int, maxTotalWeight, -1, INT_MAX)
+CHECK(Rules, bool, allowSwitchStyle)
+CHECK(Rules, bool, specialSplit)
+CHECK_BEGIN(Rules, bool, specialDVSplit)
+ if (!m_specialSplit && specialDVSplit)
+ {
+ ERROR("Cannot split special DV when special is not split");
+ return false;
+ }
+CHECK_END()
+CHECK(Rules, bool, effortValuesAllowed)
+CHECK_BOUNDS(Rules, int, maxTotalEV, 0, INT_MAX)
+CHECK_BEGIN(Rules, int, maxEVPerStat)
+ if (m_maxTotalEV)
+ {
+ TBOUNDS(maxEVPerStat, 0, m_maxTotalEV);
+ return false;
+ }
+CHECK_END()
Sigmod::Rules& Sigmod::Rules::operator=(const Rules& rhs)
{
diff --git a/sigmod/Rules.h b/sigmod/Rules.h
index 7a9f621c..aaa574f0 100644
--- a/sigmod/Rules.h
+++ b/sigmod/Rules.h
@@ -93,6 +93,31 @@ class SIGMOD_EXPORT Rules : public Object
int maxTotalEV() const;
int maxEVPerStat() const;
+ bool genderAllowedCheck(const bool genderAllowed) const;
+ bool breedingAllowedCheck(const bool breedingAllowed) const;
+ bool criticalDomainsCheck(const bool criticalDomains) const;
+ bool useTurnsCheck(const bool useTurns) const;
+ bool pausedATBCheck(const bool pausedATB) const;
+ bool numBoxesCheck(const int numBoxes) const;
+ bool boxSizeCheck(const int boxSize) const;
+ bool maxPartyCheck(const int maxParty) const;
+ bool maxFightCheck(const int maxFight) const;
+ bool maxPlayersCheck(const int maxPlayers) const;
+ bool maxHeldItemsCheck(const int maxHeldItems) const;
+ bool maxAbilitiesCheck(const int maxAbilities) const;
+ bool maxNaturesCheck(const int maxNatures) const;
+ bool maxMovesCheck(const int maxMoves) const;
+ bool maxLevelCheck(const int maxLevel) const;
+ bool maxStagesCheck(const int maxStage) const;
+ bool maxMoneyCheck(const int maxMoney) const;
+ bool maxTotalWeightCheck(const int maxTotalWeight) const;
+ bool allowSwitchStyleCheck(const bool allowSwitchStyle) const;
+ bool specialSplitCheck(const bool specialSplit) const;
+ bool specialDVSplitCheck(const bool specialDVSplit) const;
+ bool effortValuesAllowedCheck(const bool effortValues) const;
+ bool maxTotalEVCheck(const int maxTotalEV) const;
+ bool maxEVPerStatCheck(const int maxEVPerStat) const;
+
Rules& operator=(const Rules& rhs);
private:
bool m_genderAllowed;
diff --git a/sigmod/Sigmod.cpp b/sigmod/Sigmod.cpp
index 576eec0b..c6eabb49 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,1645 +398,52 @@ Sigmod::Rules* Sigmod::Sigmod::rules()
return m_rules;
}
-const Sigmod::Ability* Sigmod::Sigmod::ability(const int index) const
-{
- if (index < abilityCount())
- return m_abilities.at(index);
- return NULL;
-}
-
-Sigmod::Ability* Sigmod::Sigmod::ability(const int index)
-{
- if (index < abilityCount())
- return m_abilities[index];
- return NULL;
-}
-
-const Sigmod::Ability* Sigmod::Sigmod::abilityById(const int id) const
-{
- return ability(abilityIndex(id));
-}
-
-Sigmod::Ability* Sigmod::Sigmod::abilityById(const int id)
-{
- return ability(abilityIndex(id));
-}
-
-int Sigmod::Sigmod::abilityIndex(const int id) const
-{
- for (int i = 0; i < abilityCount(); ++i)
- {
- if (m_abilities[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::abilityCount() const
-{
- return m_abilities.size();
-}
-
-Sigmod::Ability* Sigmod::Sigmod::newAbility()
-{
- return newAbility(new Ability(this, newAbilityId()));
-}
-
-Sigmod::Ability* Sigmod::Sigmod::newAbility(const QDomElement& xml)
-{
- return newAbility(new Ability(xml, this, newAbilityId()));
-}
-
-Sigmod::Ability* Sigmod::Sigmod::newAbility(const Ability& ability)
-{
- return newAbility(new Ability(ability, this, newAbilityId()));
-}
-
-Sigmod::Ability* Sigmod::Sigmod::newAbility(Ability* ability)
-{
- m_abilities.append(ability);
- return ability;
-}
-
-void Sigmod::Sigmod::deleteAbility(const int index)
-{
- if (index < abilityCount())
- {
- delete m_abilities[index];
- m_abilities.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteAbilityById(const int id)
-{
- deleteAbility(abilityIndex(id));
-}
-
-int Sigmod::Sigmod::newAbilityId() const
-{
- int i = 0;
- while ((i < abilityCount()) && (abilityIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Author* Sigmod::Sigmod::author(const int index) const
-{
- if (index < authorCount())
- return m_authors.at(index);
- return NULL;
-}
-
-Sigmod::Author* Sigmod::Sigmod::author(const int index)
-{
- if (index < authorCount())
- return m_authors[index];
- return NULL;
-}
-
-const Sigmod::Author* Sigmod::Sigmod::authorById(const int id) const
-{
- return author(authorIndex(id));
-}
-
-Sigmod::Author* Sigmod::Sigmod::authorById(const int id)
-{
- return author(authorIndex(id));
-}
-
-int Sigmod::Sigmod::authorIndex(const int id) const
-{
- for (int i = 0; i < authorCount(); ++i)
- {
- if (m_authors[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::authorCount() const
-{
- return m_authors.size();
-}
-
-Sigmod::Author* Sigmod::Sigmod::newAuthor()
-{
- return newAuthor(new Author(this, newAuthorId()));
-}
-
-Sigmod::Author* Sigmod::Sigmod::newAuthor(const QDomElement& xml)
-{
- return newAuthor(new Author(xml, this, newAuthorId()));
-}
-
-Sigmod::Author* Sigmod::Sigmod::newAuthor(const Author& author)
-{
- return newAuthor(new Author(author, this, newAuthorId()));
-}
-
-Sigmod::Author* Sigmod::Sigmod::newAuthor(Author* author)
-{
- m_authors.append(author);
- return author;
-}
-
-void Sigmod::Sigmod::deleteAuthor(const int index)
-{
- if (index < authorCount())
- {
- delete m_authors[index];
- m_authors.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteAuthorById(const int id)
-{
- deleteAuthor(authorIndex(id));
-}
-
-int Sigmod::Sigmod::newAuthorId() const
-{
- int i = 0;
- while ((i < authorCount()) && (authorIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Badge* Sigmod::Sigmod::badge(const int index) const
-{
- if (index < badgeCount())
- return m_badges.at(index);
- return NULL;
-}
-
-Sigmod::Badge* Sigmod::Sigmod::badge(const int index)
-{
- if (index < badgeCount())
- return m_badges[index];
- return NULL;
-}
-
-const Sigmod::Badge* Sigmod::Sigmod::badgeById(const int id) const
-{
- return badge(badgeIndex(id));
-}
-
-Sigmod::Badge* Sigmod::Sigmod::badgeById(const int id)
-{
- return badge(badgeIndex(id));
-}
-
-int Sigmod::Sigmod::badgeIndex(const int id) const
-{
- for (int i = 0; i < badgeCount(); ++i)
- {
- if (m_badges[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::badgeCount() const
-{
- return m_badges.size();
-}
-
-Sigmod::Badge* Sigmod::Sigmod::newBadge()
-{
- return newBadge(new Badge(this, newBadgeId()));
-}
-
-Sigmod::Badge* Sigmod::Sigmod::newBadge(const QDomElement& xml)
-{
- return newBadge(new Badge(xml, this, newBadgeId()));
-}
-
-Sigmod::Badge* Sigmod::Sigmod::newBadge(const Badge& badge)
-{
- return newBadge(new Badge(badge, this, newBadgeId()));
-}
-
-Sigmod::Badge* Sigmod::Sigmod::newBadge(Badge* badge)
-{
- m_badges.append(badge);
- return badge;
-}
-
-void Sigmod::Sigmod::deleteBadge(const int index)
-{
- if (index < badgeCount())
- {
- delete m_badges[index];
- m_badges.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteBadgeById(const int id)
-{
- deleteBadge(badgeIndex(id));
-}
-
-int Sigmod::Sigmod::newBadgeId() const
-{
- int i = 0;
- while ((i < badgeCount()) && (badgeIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::CoinList* Sigmod::Sigmod::coinList(const int index) const
-{
- if (index < coinListCount())
- return m_coinLists.at(index);
- return NULL;
-}
-
-Sigmod::CoinList* Sigmod::Sigmod::coinList(const int index)
-{
- if (index < coinListCount())
- return m_coinLists[index];
- return NULL;
-}
-
-const Sigmod::CoinList* Sigmod::Sigmod::coinListById(const int id) const
-{
- return coinList(coinListIndex(id));
-}
-
-Sigmod::CoinList* Sigmod::Sigmod::coinListById(const int id)
-{
- return coinList(coinListIndex(id));
-}
-
-int Sigmod::Sigmod::coinListIndex(const int id) const
-{
- for (int i = 0; i < coinListCount(); ++i)
- {
- if (m_coinLists[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::coinListCount() const
-{
- return m_coinLists.size();
-}
-
-Sigmod::CoinList* Sigmod::Sigmod::newCoinList()
-{
- return newCoinList(new CoinList(this, newCoinListId()));
-}
-
-Sigmod::CoinList* Sigmod::Sigmod::newCoinList(const QDomElement& xml)
-{
- return newCoinList(new CoinList(xml, this, newCoinListId()));
-}
-
-Sigmod::CoinList* Sigmod::Sigmod::newCoinList(const CoinList& coinList)
-{
- return newCoinList(new CoinList(coinList, this, newCoinListId()));
-}
-
-Sigmod::CoinList* Sigmod::Sigmod::newCoinList(CoinList* coinList)
-{
- m_coinLists.append(coinList);
- return coinList;
-}
-
-void Sigmod::Sigmod::deleteCoinList(const int index)
-{
- if (index < coinListCount())
- {
- delete m_coinLists[index];
- m_coinLists.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteCoinListById(const int id)
-{
- deleteCoinList(coinListIndex(id));
-}
-
-int Sigmod::Sigmod::newCoinListId() const
-{
- int i = 0;
- while ((i < coinListCount()) && (coinListIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::EggGroup* Sigmod::Sigmod::eggGroup(const int index) const
-{
- if (index < eggGroupCount())
- return m_eggGroups.at(index);
- return NULL;
-}
-
-Sigmod::EggGroup* Sigmod::Sigmod::eggGroup(const int index)
-{
- if (index < eggGroupCount())
- return m_eggGroups[index];
- return NULL;
-}
-
-const Sigmod::EggGroup* Sigmod::Sigmod::eggGroupById(const int id) const
-{
- return eggGroup(eggGroupIndex(id));
-}
-
-Sigmod::EggGroup* Sigmod::Sigmod::eggGroupById(const int id)
-{
- return eggGroup(eggGroupIndex(id));
-}
-
-int Sigmod::Sigmod::eggGroupIndex(const int id) const
-{
- for (int i = 0; i < eggGroupCount(); ++i)
- {
- if (m_eggGroups[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::eggGroupCount() const
-{
- return m_eggGroups.size();
-}
-
-Sigmod::EggGroup* Sigmod::Sigmod::newEggGroup()
-{
- return newEggGroup(new EggGroup(this, newEggGroupId()));
-}
-
-Sigmod::EggGroup* Sigmod::Sigmod::newEggGroup(const QDomElement& xml)
-{
- return newEggGroup(new EggGroup(xml, this, newEggGroupId()));
-}
-
-Sigmod::EggGroup* Sigmod::Sigmod::newEggGroup(const EggGroup& eggGroup)
-{
- return newEggGroup(new EggGroup(eggGroup, this, newEggGroupId()));
-}
-
-Sigmod::EggGroup* Sigmod::Sigmod::newEggGroup(EggGroup* eggGroup)
-{
- m_eggGroups.append(eggGroup);
- return eggGroup;
-}
-
-void Sigmod::Sigmod::deleteEggGroup(const int index)
-{
- if (index < eggGroupCount())
- {
- delete m_eggGroups[index];
- m_eggGroups.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteEggGroupById(const int id)
-{
- deleteEggGroup(eggGroupIndex(id));
-}
-
-int Sigmod::Sigmod::newEggGroupId() const
-{
- int i = 0;
- while ((i < eggGroupCount()) && (eggGroupIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::GlobalScript* Sigmod::Sigmod::globalScript(const int index) const
-{
- if (index < globalScriptCount())
- return m_globalScripts.at(index);
- return NULL;
-}
-
-Sigmod::GlobalScript* Sigmod::Sigmod::globalScript(const int index)
-{
- if (index < globalScriptCount())
- return m_globalScripts[index];
- return NULL;
-}
-
-const Sigmod::GlobalScript* Sigmod::Sigmod::globalScriptById(const int id) const
-{
- return globalScript(globalScriptIndex(id));
-}
-
-Sigmod::GlobalScript* Sigmod::Sigmod::globalScriptById(const int id)
-{
- return globalScript(globalScriptIndex(id));
-}
-
-int Sigmod::Sigmod::globalScriptIndex(const int id) const
-{
- for (int i = 0; i < globalScriptCount(); ++i)
- {
- if (m_globalScripts[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::globalScriptCount() const
-{
- return m_globalScripts.size();
-}
-
-Sigmod::GlobalScript* Sigmod::Sigmod::newGlobalScript()
-{
- return newGlobalScript(new GlobalScript(this, newGlobalScriptId()));
-}
-
-Sigmod::GlobalScript* Sigmod::Sigmod::newGlobalScript(const QDomElement& xml)
-{
- return newGlobalScript(new GlobalScript(xml, this, newGlobalScriptId()));
-}
-
-Sigmod::GlobalScript* Sigmod::Sigmod::newGlobalScript(const GlobalScript& globalScript)
-{
- return newGlobalScript(new GlobalScript(globalScript, this, newGlobalScriptId()));
-}
-
-Sigmod::GlobalScript* Sigmod::Sigmod::newGlobalScript(GlobalScript* globalScript)
-{
- m_globalScripts.append(globalScript);
- return globalScript;
-}
-
-void Sigmod::Sigmod::deleteGlobalScript(const int index)
-{
- if (index < globalScriptCount())
- {
- delete m_globalScripts[index];
- m_globalScripts.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteGlobalScriptById(const int id)
-{
- deleteGlobalScript(globalScriptIndex(id));
-}
-
-int Sigmod::Sigmod::newGlobalScriptId() const
-{
- int i = 0;
- while ((i < globalScriptCount()) && (globalScriptIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Item* Sigmod::Sigmod::item(const int index) const
-{
- if (index < itemCount())
- return m_items.at(index);
- return NULL;
-}
-
-Sigmod::Item* Sigmod::Sigmod::item(const int index)
-{
- if (index < itemCount())
- return m_items[index];
- return NULL;
-}
-
-const Sigmod::Item* Sigmod::Sigmod::itemById(const int id) const
-{
- return item(itemIndex(id));
-}
-
-Sigmod::Item* Sigmod::Sigmod::itemById(const int id)
-{
- return item(itemIndex(id));
-}
-
-int Sigmod::Sigmod::itemIndex(const int id) const
-{
- for (int i = 0; i < itemCount(); ++i)
- {
- if (m_items[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::itemCount() const
-{
- return m_items.size();
-}
-
-Sigmod::Item* Sigmod::Sigmod::newItem()
-{
- return newItem(new Item(this, newItemId()));
-}
-
-Sigmod::Item* Sigmod::Sigmod::newItem(const QDomElement& xml)
-{
- return newItem(new Item(xml, this, newItemId()));
-}
-
-Sigmod::Item* Sigmod::Sigmod::newItem(const Item& item)
-{
- return newItem(new Item(item, this, newItemId()));
-}
-
-Sigmod::Item* Sigmod::Sigmod::newItem(Item* item)
-{
- m_items.append(item);
- return item;
-}
-
-void Sigmod::Sigmod::deleteItem(const int index)
-{
- if (index < itemCount())
- {
- delete m_items[index];
- m_items.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteItemById(const int id)
-{
- deleteItem(itemIndex(id));
-}
-
-int Sigmod::Sigmod::newItemId() const
-{
- int i = 0;
- while ((i < itemCount()) && (itemIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::ItemType* Sigmod::Sigmod::itemType(const int index) const
-{
- if (index < itemTypeCount())
- return m_itemTypes.at(index);
- return NULL;
-}
-
-Sigmod::ItemType* Sigmod::Sigmod::itemType(const int index)
-{
- if (index < itemTypeCount())
- return m_itemTypes[index];
- return NULL;
-}
-
-const Sigmod::ItemType* Sigmod::Sigmod::itemTypeById(const int id) const
-{
- return itemType(itemTypeIndex(id));
-}
-
-Sigmod::ItemType* Sigmod::Sigmod::itemTypeById(const int id)
-{
- return itemType(itemTypeIndex(id));
-}
-
-int Sigmod::Sigmod::itemTypeIndex(const int id) const
-{
- for (int i = 0; i < itemTypeCount(); ++i)
- {
- if (m_itemTypes[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::itemTypeCount() const
-{
- return m_itemTypes.size();
-}
-
-Sigmod::ItemType* Sigmod::Sigmod::newItemType()
-{
- return newItemType(new ItemType(this, newItemTypeId()));
-}
-
-Sigmod::ItemType* Sigmod::Sigmod::newItemType(const QDomElement& xml)
-{
- return newItemType(new ItemType(xml, this, newItemTypeId()));
-}
-
-Sigmod::ItemType* Sigmod::Sigmod::newItemType(const ItemType& itemType)
-{
- return newItemType(new ItemType(itemType, this, newItemTypeId()));
-}
-
-Sigmod::ItemType* Sigmod::Sigmod::newItemType(ItemType* itemType)
-{
- m_itemTypes.append(itemType);
- return itemType;
-}
-
-void Sigmod::Sigmod::deleteItemType(const int index)
-{
- if (index < itemTypeCount())
- {
- delete m_itemTypes[index];
- m_itemTypes.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteItemTypeById(const int id)
-{
- deleteItemType(itemTypeIndex(id));
-}
-
-int Sigmod::Sigmod::newItemTypeId() const
-{
- int i = 0;
- while ((i < itemTypeCount()) && (itemTypeIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Map* Sigmod::Sigmod::map(const int index) const
-{
- if (index < mapCount())
- return m_maps.at(index);
- return NULL;
-}
-
-Sigmod::Map* Sigmod::Sigmod::map(const int index)
-{
- if (index < mapCount())
- return m_maps[index];
- return NULL;
-}
-
-const Sigmod::Map* Sigmod::Sigmod::mapById(const int id) const
-{
- return map(mapIndex(id));
-}
-
-Sigmod::Map* Sigmod::Sigmod::mapById(const int id)
-{
- return map(mapIndex(id));
-}
-
-int Sigmod::Sigmod::mapIndex(const int id) const
-{
- for (int i = 0; i < mapCount(); ++i)
- {
- if (m_maps[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::mapCount() const
-{
- return m_maps.size();
-}
-
-Sigmod::Map* Sigmod::Sigmod::newMap()
-{
- return newMap(new Map(this, newMapId()));
-}
-
-Sigmod::Map* Sigmod::Sigmod::newMap(const QDomElement& xml)
-{
- return newMap(new Map(xml, this, newMapId()));
-}
-
-Sigmod::Map* Sigmod::Sigmod::newMap(const Map& map)
-{
- return newMap(new Map(map, this, newMapId()));
-}
-
-Sigmod::Map* Sigmod::Sigmod::newMap(Map* map)
-{
- m_maps.append(map);
- return map;
-}
-
-void Sigmod::Sigmod::deleteMap(const int index)
-{
- if (index < mapCount())
- {
- delete m_maps[index];
- m_maps.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteMapById(const int id)
-{
- deleteMap(mapIndex(id));
-}
-
-int Sigmod::Sigmod::newMapId() const
-{
- int i = 0;
- while ((i < mapCount()) && (mapIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Move* Sigmod::Sigmod::move(const int index) const
-{
- if (index < moveCount())
- return m_moves.at(index);
- return NULL;
-}
-
-Sigmod::Move* Sigmod::Sigmod::move(const int index)
-{
- if (index < moveCount())
- return m_moves[index];
- return NULL;
-}
-
-const Sigmod::Move* Sigmod::Sigmod::moveById(const int id) const
-{
- return move(moveIndex(id));
-}
-
-Sigmod::Move* Sigmod::Sigmod::moveById(const int id)
-{
- return move(moveIndex(id));
-}
-
-int Sigmod::Sigmod::moveIndex(const int id) const
-{
- for (int i = 0; i < moveCount(); ++i)
- {
- if (m_moves[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::moveCount() const
-{
- return m_moves.size();
-}
-
-Sigmod::Move* Sigmod::Sigmod::newMove()
-{
- return newMove(new Move(this, newMoveId()));
-}
-
-Sigmod::Move* Sigmod::Sigmod::newMove(const QDomElement& xml)
-{
- return newMove(new Move(xml, this, newMoveId()));
-}
-
-Sigmod::Move* Sigmod::Sigmod::newMove(const Move& move)
-{
- return newMove(new Move(move, this, newMoveId()));
-}
-
-Sigmod::Move* Sigmod::Sigmod::newMove(Move* move)
-{
- m_moves.append(move);
- return move;
-}
-
-void Sigmod::Sigmod::deleteMove(const int index)
-{
- if (index < moveCount())
- {
- delete m_moves[index];
- m_moves.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteMoveById(const int id)
-{
- deleteMove(moveIndex(id));
-}
-
-int Sigmod::Sigmod::newMoveId() const
-{
- int i = 0;
- while ((i < moveCount()) && (moveIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Nature* Sigmod::Sigmod::nature(const int index) const
-{
- if (index < natureCount())
- return m_natures.at(index);
- return NULL;
-}
-
-Sigmod::Nature* Sigmod::Sigmod::nature(const int index)
-{
- if (index < natureCount())
- return m_natures[index];
- return NULL;
-}
-
-const Sigmod::Nature* Sigmod::Sigmod::natureById(const int id) const
-{
- return nature(natureIndex(id));
-}
-
-Sigmod::Nature* Sigmod::Sigmod::natureById(const int id)
-{
- return nature(natureIndex(id));
-}
-
-int Sigmod::Sigmod::natureIndex(const int id) const
-{
- for (int i = 0; i < natureCount(); ++i)
- {
- if (m_natures[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::natureCount() const
-{
- return m_natures.size();
-}
-
-Sigmod::Nature* Sigmod::Sigmod::newNature()
-{
- return newNature(new Nature(this, newNatureId()));
-}
-
-Sigmod::Nature* Sigmod::Sigmod::newNature(const QDomElement& xml)
-{
- return newNature(new Nature(xml, this, newNatureId()));
-}
-
-Sigmod::Nature* Sigmod::Sigmod::newNature(const Nature& nature)
-{
- return newNature(new Nature(nature, this, newNatureId()));
-}
-
-Sigmod::Nature* Sigmod::Sigmod::newNature(Nature* nature)
-{
- m_natures.append(nature);
- return nature;
-}
-
-void Sigmod::Sigmod::deleteNature(const int index)
-{
- if (index < natureCount())
- {
- delete m_natures[index];
- m_natures.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteNatureById(const int id)
-{
- deleteNature(natureIndex(id));
-}
-
-int Sigmod::Sigmod::newNatureId() const
-{
- int i = 0;
- while ((i < natureCount()) && (natureIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Skin* Sigmod::Sigmod::skin(const int index) const
-{
- if (index < skinCount())
- return m_skins.at(index);
- return NULL;
-}
-
-Sigmod::Skin* Sigmod::Sigmod::skin(const int index)
-{
- if (index < skinCount())
- return m_skins[index];
- return NULL;
-}
-
-const Sigmod::Skin* Sigmod::Sigmod::skinById(const int id) const
-{
- return skin(skinIndex(id));
-}
-
-Sigmod::Skin* Sigmod::Sigmod::skinById(const int id)
-{
- return skin(skinIndex(id));
-}
-
-int Sigmod::Sigmod::skinIndex(const int id) const
-{
- for (int i = 0; i < skinCount(); ++i)
- {
- if (m_skins[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::skinCount() const
-{
- return m_skins.size();
-}
-
-Sigmod::Skin* Sigmod::Sigmod::newSkin()
-{
- return newSkin(new Skin(this, newSkinId()));
-}
-
-Sigmod::Skin* Sigmod::Sigmod::newSkin(const QDomElement& xml)
-{
- return newSkin(new Skin(xml, this, newSkinId()));
-}
-
-Sigmod::Skin* Sigmod::Sigmod::newSkin(const Skin& skin)
-{
- return newSkin(new Skin(skin, this, newSkinId()));
-}
-
-Sigmod::Skin* Sigmod::Sigmod::newSkin(Skin* skin)
-{
- m_skins.append(skin);
- return skin;
-}
-
-void Sigmod::Sigmod::deleteSkin(const int index)
-{
- if (index < skinCount())
- {
- delete m_skins[index];
- m_skins.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteSkinById(const int id)
-{
- deleteSkin(skinIndex(id));
-}
-
-int Sigmod::Sigmod::newSkinId() const
-{
- int i = 0;
- while ((i < skinCount()) && (skinIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Sound* Sigmod::Sigmod::sound(const int index) const
-{
- if (index < soundCount())
- return m_sounds.at(index);
- return NULL;
-}
-
-Sigmod::Sound* Sigmod::Sigmod::sound(const int index)
-{
- if (index < soundCount())
- return m_sounds[index];
- return NULL;
-}
-
-const Sigmod::Sound* Sigmod::Sigmod::soundById(const int id) const
-{
- return sound(soundIndex(id));
-}
-
-Sigmod::Sound* Sigmod::Sigmod::soundById(const int id)
-{
- return sound(soundIndex(id));
-}
-
-int Sigmod::Sigmod::soundIndex(const int id) const
-{
- for (int i = 0; i < soundCount(); ++i)
- {
- if (m_sounds[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::soundCount() const
-{
- return m_sounds.size();
-}
-
-Sigmod::Sound* Sigmod::Sigmod::newSound()
-{
- return newSound(new Sound(this, newSoundId()));
-}
-
-Sigmod::Sound* Sigmod::Sigmod::newSound(const QDomElement& xml)
-{
- return newSound(new Sound(xml, this, newSoundId()));
-}
-
-Sigmod::Sound* Sigmod::Sigmod::newSound(const Sound& sound)
-{
- return newSound(new Sound(sound, this, newSoundId()));
-}
-
-Sigmod::Sound* Sigmod::Sigmod::newSound(Sound* sound)
-{
- m_sounds.append(sound);
- return sound;
-}
-
-void Sigmod::Sigmod::deleteSound(const int index)
-{
- if (index < soundCount())
- {
- delete m_sounds[index];
- m_sounds.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteSoundById(const int id)
-{
- deleteSound(soundIndex(id));
-}
-
-int Sigmod::Sigmod::newSoundId() const
-{
- int i = 0;
- while ((i < soundCount()) && (soundIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Species* Sigmod::Sigmod::species(const int index) const
-{
- if (index < speciesCount())
- return m_species.at(index);
- return NULL;
-}
-
-Sigmod::Species* Sigmod::Sigmod::species(const int index)
-{
- if (index < speciesCount())
- return m_species[index];
- return NULL;
-}
-
-const Sigmod::Species* Sigmod::Sigmod::speciesById(const int id) const
-{
- return species(speciesIndex(id));
-}
-
-Sigmod::Species* Sigmod::Sigmod::speciesById(const int id)
-{
- return species(speciesIndex(id));
-}
-
-int Sigmod::Sigmod::speciesIndex(const int id) const
-{
- for (int i = 0; i < speciesCount(); ++i)
- {
- if (m_species[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::speciesCount() const
-{
- return m_species.size();
-}
-
-Sigmod::Species* Sigmod::Sigmod::newSpecies()
-{
- return newSpecies(new Species(this, newSpeciesId()));
-}
-
-Sigmod::Species* Sigmod::Sigmod::newSpecies(const QDomElement& xml)
-{
- return newSpecies(new Species(xml, this, newSpeciesId()));
-}
-
-Sigmod::Species* Sigmod::Sigmod::newSpecies(const Species& species)
-{
- return newSpecies(new Species(species, this, newSpeciesId()));
-}
-
-Sigmod::Species* Sigmod::Sigmod::newSpecies(Species* species)
-{
- m_species.append(species);
- return species;
-}
-
-void Sigmod::Sigmod::deleteSpecies(const int index)
-{
- if (index < speciesCount())
- {
- delete m_species[index];
- m_species.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteSpeciesById(const int id)
-{
- deleteSpecies(speciesIndex(id));
-}
-
-int Sigmod::Sigmod::newSpeciesId() const
-{
- int i = 0;
- while ((i < speciesCount()) && (speciesIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Sprite* Sigmod::Sigmod::sprite(const int index) const
-{
- if (index < spriteCount())
- return m_sprites.at(index);
- return NULL;
-}
-
-Sigmod::Sprite* Sigmod::Sigmod::sprite(const int index)
-{
- if (index < spriteCount())
- return m_sprites[index];
- return NULL;
-}
-
-const Sigmod::Sprite* Sigmod::Sigmod::spriteById(const int id) const
-{
- return sprite(spriteIndex(id));
-}
-
-Sigmod::Sprite* Sigmod::Sigmod::spriteById(const int id)
-{
- return sprite(spriteIndex(id));
-}
-
-int Sigmod::Sigmod::spriteIndex(const int id) const
-{
- for (int i = 0; i < spriteCount(); ++i)
- {
- if (m_sprites[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::spriteCount() const
-{
- return m_sprites.size();
-}
-
-Sigmod::Sprite* Sigmod::Sigmod::newSprite()
-{
- return newSprite(new Sprite(this, newSpriteId()));
-}
-
-Sigmod::Sprite* Sigmod::Sigmod::newSprite(const QDomElement& xml)
-{
- return newSprite(new Sprite(xml, this, newSpriteId()));
-}
-
-Sigmod::Sprite* Sigmod::Sigmod::newSprite(const Sprite& sprite)
-{
- return newSprite(new Sprite(sprite, this, newSpriteId()));
-}
-
-Sigmod::Sprite* Sigmod::Sigmod::newSprite(Sprite* sprite)
-{
- m_sprites.append(sprite);
- return sprite;
-}
-
-void Sigmod::Sigmod::deleteSprite(const int index)
-{
- if (index < spriteCount())
- {
- delete m_sprites[index];
- m_sprites.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteSpriteById(const int id)
-{
- deleteSprite(spriteIndex(id));
-}
-
-int Sigmod::Sigmod::newSpriteId() const
-{
- int i = 0;
- while ((i < spriteCount()) && (spriteIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Status* Sigmod::Sigmod::status(const int index) const
-{
- if (index < statusCount())
- return m_status.at(index);
- return NULL;
-}
-
-Sigmod::Status* Sigmod::Sigmod::status(const int index)
-{
- if (index < statusCount())
- return m_status[index];
- return NULL;
-}
-
-const Sigmod::Status* Sigmod::Sigmod::statusById(const int id) const
-{
- return status(statusIndex(id));
-}
-
-Sigmod::Status* Sigmod::Sigmod::statusById(const int id)
-{
- return status(statusIndex(id));
-}
-
-int Sigmod::Sigmod::statusIndex(const int id) const
-{
- for (int i = 0; i < statusCount(); ++i)
- {
- if (m_status[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::statusCount() const
-{
- return m_status.size();
-}
-
-Sigmod::Status* Sigmod::Sigmod::newStatus()
-{
- return newStatus(new Status(this, newStatusId()));
-}
-
-Sigmod::Status* Sigmod::Sigmod::newStatus(const QDomElement& xml)
-{
- return newStatus(new Status(xml, this, newStatusId()));
-}
-
-Sigmod::Status* Sigmod::Sigmod::newStatus(const Status& status)
-{
- return newStatus(new Status(status, this, newStatusId()));
-}
-
-Sigmod::Status* Sigmod::Sigmod::newStatus(Status* status)
-{
- m_status.append(status);
- return status;
-}
-
-void Sigmod::Sigmod::deleteStatus(const int index)
-{
- if (index < statusCount())
- {
- delete m_status[index];
- m_status.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteStatusById(const int id)
-{
- deleteStatus(statusIndex(id));
-}
-
-int Sigmod::Sigmod::newStatusId() const
-{
- int i = 0;
- while ((i < statusCount()) && (statusIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Store* Sigmod::Sigmod::store(const int index) const
-{
- if (index < storeCount())
- return m_stores.at(index);
- return NULL;
-}
-
-Sigmod::Store* Sigmod::Sigmod::store(const int index)
-{
- if (index < storeCount())
- return m_stores[index];
- return NULL;
-}
-
-const Sigmod::Store* Sigmod::Sigmod::storeById(const int id) const
-{
- return store(storeIndex(id));
-}
-
-Sigmod::Store* Sigmod::Sigmod::storeById(const int id)
-{
- return store(storeIndex(id));
-}
-
-int Sigmod::Sigmod::storeIndex(const int id) const
-{
- for (int i = 0; i < storeCount(); ++i)
- {
- if (m_stores[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::storeCount() const
-{
- return m_stores.size();
-}
-
-Sigmod::Store* Sigmod::Sigmod::newStore()
-{
- return newStore(new Store(this, newStoreId()));
-}
-
-Sigmod::Store* Sigmod::Sigmod::newStore(const QDomElement& xml)
-{
- return newStore(new Store(xml, this, newStoreId()));
-}
-
-Sigmod::Store* Sigmod::Sigmod::newStore(const Store& store)
-{
- return newStore(new Store(store, this, newStoreId()));
-}
-
-Sigmod::Store* Sigmod::Sigmod::newStore(Store* store)
-{
- m_stores.append(store);
- return store;
-}
-
-void Sigmod::Sigmod::deleteStore(const int index)
-{
- if (index < storeCount())
- {
- delete m_stores[index];
- m_stores.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteStoreById(const int id)
-{
- deleteStore(storeIndex(id));
-}
-
-int Sigmod::Sigmod::newStoreId() const
-{
- int i = 0;
- while ((i < storeCount()) && (storeIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Tile* Sigmod::Sigmod::tile(const int index) const
-{
- if (index < tileCount())
- return m_tiles.at(index);
- return NULL;
-}
-
-Sigmod::Tile* Sigmod::Sigmod::tile(const int index)
-{
- if (index < tileCount())
- return m_tiles[index];
- return NULL;
-}
-
-const Sigmod::Tile* Sigmod::Sigmod::tileById(const int id) const
-{
- return tile(tileIndex(id));
-}
-
-Sigmod::Tile* Sigmod::Sigmod::tileById(const int id)
-{
- return tile(tileIndex(id));
-}
-
-int Sigmod::Sigmod::tileIndex(const int id) const
-{
- for (int i = 0; i < tileCount(); ++i)
- {
- if (m_tiles[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::tileCount() const
-{
- return m_tiles.size();
-}
-
-Sigmod::Tile* Sigmod::Sigmod::newTile()
-{
- return newTile(new Tile(this, newTileId()));
-}
-
-Sigmod::Tile* Sigmod::Sigmod::newTile(const QDomElement& xml)
-{
- return newTile(new Tile(xml, this, newTileId()));
-}
-
-Sigmod::Tile* Sigmod::Sigmod::newTile(const Tile& tile)
-{
- return newTile(new Tile(tile, this, newTileId()));
-}
-
-Sigmod::Tile* Sigmod::Sigmod::newTile(Tile* tile)
-{
- m_tiles.append(tile);
- return tile;
-}
-
-void Sigmod::Sigmod::deleteTile(const int index)
-{
- if (index < tileCount())
- {
- delete m_tiles[index];
- m_tiles.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteTileById(const int id)
-{
- deleteTile(tileIndex(id));
-}
-
-int Sigmod::Sigmod::newTileId() const
-{
- int i = 0;
- while ((i < tileCount()) && (tileIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Time* Sigmod::Sigmod::time(const int index) const
-{
- if (index < timeCount())
- return m_times.at(index);
- return NULL;
-}
-
-Sigmod::Time* Sigmod::Sigmod::time(const int index)
-{
- if (index < timeCount())
- return m_times[index];
- return NULL;
-}
-
-const Sigmod::Time* Sigmod::Sigmod::timeById(const int id) const
-{
- return time(timeIndex(id));
-}
-
-Sigmod::Time* Sigmod::Sigmod::timeById(const int id)
-{
- return time(timeIndex(id));
-}
-
-int Sigmod::Sigmod::timeIndex(const int id) const
-{
- for (int i = 0; i < timeCount(); ++i)
- {
- if (m_times[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::timeCount() const
-{
- return m_times.size();
-}
-
-Sigmod::Time* Sigmod::Sigmod::newTime()
-{
- return newTime(new Time(this, newTimeId()));
-}
-
-Sigmod::Time* Sigmod::Sigmod::newTime(const QDomElement& xml)
-{
- return newTime(new Time(xml, this, newTimeId()));
-}
-
-Sigmod::Time* Sigmod::Sigmod::newTime(const Time& time)
-{
- return newTime(new Time(time, this, newTimeId()));
-}
-
-Sigmod::Time* Sigmod::Sigmod::newTime(Time* time)
-{
- m_times.append(time);
- return time;
-}
-
-void Sigmod::Sigmod::deleteTime(const int index)
-{
- if (index < timeCount())
- {
- delete m_times[index];
- m_times.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteTimeById(const int id)
-{
- deleteTime(timeIndex(id));
-}
-
-int Sigmod::Sigmod::newTimeId() const
-{
- int i = 0;
- while ((i < timeCount()) && (timeIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::Trainer* Sigmod::Sigmod::trainer(const int index) const
-{
- if (index < trainerCount())
- return m_trainers.at(index);
- return NULL;
-}
-
-Sigmod::Trainer* Sigmod::Sigmod::trainer(const int index)
-{
- if (index < trainerCount())
- return m_trainers[index];
- return NULL;
-}
-
-const Sigmod::Trainer* Sigmod::Sigmod::trainerById(const int id) const
-{
- return trainer(trainerIndex(id));
-}
-
-Sigmod::Trainer* Sigmod::Sigmod::trainerById(const int id)
-{
- return trainer(trainerIndex(id));
-}
-
-int Sigmod::Sigmod::trainerIndex(const int id) const
-{
- for (int i = 0; i < trainerCount(); ++i)
+CHECK(Sigmod, QString&, title)
+CHECK(Sigmod, QString&, version)
+CHECK(Sigmod, QString&, description)
+CHECK(Sigmod, bool, singlePlayer)
+CHECK_BEGIN(Sigmod, int, startMap)
+ if (!m_singlePlayer)
{
- if (m_trainers[i]->id() == id)
- return i;
+ emit(error(unused("startMap")));
+ return false;
}
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::trainerCount() const
-{
- return m_trainers.size();
-}
-
-Sigmod::Trainer* Sigmod::Sigmod::newTrainer()
-{
- return newTrainer(new Trainer(this, newTrainerId()));
-}
-
-Sigmod::Trainer* Sigmod::Sigmod::newTrainer(const QDomElement& xml)
-{
- return newTrainer(new Trainer(xml, this, newTrainerId()));
-}
-
-Sigmod::Trainer* Sigmod::Sigmod::newTrainer(const Trainer& trainer)
-{
- return newTrainer(new Trainer(trainer, this, newTrainerId()));
-}
-
-Sigmod::Trainer* Sigmod::Sigmod::newTrainer(Trainer* trainer)
-{
- m_trainers.append(trainer);
- return trainer;
-}
-
-void Sigmod::Sigmod::deleteTrainer(const int index)
-{
- if (index < trainerCount())
+ if (!mapById(startMap))
+ EBOUNDS_IDX(startMap);
+CHECK_END()
+CHECK_BEGIN(Sigmod, int, startWarp)
+ if (!m_singlePlayer)
{
- delete m_trainers[index];
- m_trainers.removeAt(index);
+ emit(error(unused("startWarp")));
+ return false;
}
-}
-
-void Sigmod::Sigmod::deleteTrainerById(const int id)
-{
- deleteTrainer(trainerIndex(id));
-}
-
-int Sigmod::Sigmod::newTrainerId() const
-{
- int i = 0;
- while ((i < trainerCount()) && (trainerIndex(i) != INT_MAX))
- ++i;
- return i;
-}
+ 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)
+
+SSUBCLASS(Sigmod, Ability, ability, abilities)
+SSUBCLASS(Sigmod, Author, author, authors)
+SSUBCLASS(Sigmod, Badge, badge, badges)
+SSUBCLASS(Sigmod, CoinList, coinList, coinLists)
+SSUBCLASS(Sigmod, EggGroup, eggGroup, eggGroups)
+SSUBCLASS(Sigmod, GlobalScript, globalScript, globalScripts)
+SSUBCLASS(Sigmod, Item, item, items)
+SSUBCLASS(Sigmod, ItemType, itemType, itemTypes)
+SSUBCLASS(Sigmod, Map, map, maps)
+SSUBCLASS(Sigmod, Move, move, moves)
+SSUBCLASS(Sigmod, Nature, nature, natures)
+SSUBCLASS(Sigmod, Skin, skin, skins)
+SSUBCLASS(Sigmod, Sound, sound, sounds)
+SSUBCLASS(Sigmod, Species, species, species)
+SSUBCLASS(Sigmod, Sprite, sprite, sprites)
+SSUBCLASS(Sigmod, Status, status, status)
+SSUBCLASS(Sigmod, Store, store, stores)
+SSUBCLASS(Sigmod, Tile, tile, tiles)
+SSUBCLASS(Sigmod, Time, time, times)
+SSUBCLASS(Sigmod, Trainer, trainer, trainers)
const Sigmod::Type* Sigmod::Sigmod::type(const int index) const
{
@@ -2185,87 +529,7 @@ int Sigmod::Sigmod::newTypeId() const
return i;
}
-const Sigmod::Weather* Sigmod::Sigmod::weather(const int index) const
-{
- if (index < weatherCount())
- return m_weathers.at(index);
- return NULL;
-}
-
-Sigmod::Weather* Sigmod::Sigmod::weather(const int index)
-{
- if (index < weatherCount())
- return m_weathers[index];
- return NULL;
-}
-
-const Sigmod::Weather* Sigmod::Sigmod::weatherById(const int id) const
-{
- return weather(weatherIndex(id));
-}
-
-Sigmod::Weather* Sigmod::Sigmod::weatherById(const int id)
-{
- return weather(weatherIndex(id));
-}
-
-int Sigmod::Sigmod::weatherIndex(const int id) const
-{
- for (int i = 0; i < weatherCount(); ++i)
- {
- if (m_weathers[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Sigmod::weatherCount() const
-{
- return m_weathers.size();
-}
-
-Sigmod::Weather* Sigmod::Sigmod::newWeather()
-{
- return newWeather(new Weather(this, newWeatherId()));
-}
-
-Sigmod::Weather* Sigmod::Sigmod::newWeather(const QDomElement& xml)
-{
- return newWeather(new Weather(xml, this, newWeatherId()));
-}
-
-Sigmod::Weather* Sigmod::Sigmod::newWeather(const Weather& weather)
-{
- return newWeather(new Weather(weather, this, newWeatherId()));
-}
-
-Sigmod::Weather* Sigmod::Sigmod::newWeather(Weather* weather)
-{
- m_weathers.append(weather);
- return weather;
-}
-
-void Sigmod::Sigmod::deleteWeather(const int index)
-{
- if (index < weatherCount())
- {
- delete m_weathers[index];
- m_weathers.removeAt(index);
- }
-}
-
-void Sigmod::Sigmod::deleteWeatherById(const int id)
-{
- deleteWeather(weatherIndex(id));
-}
-
-int Sigmod::Sigmod::newWeatherId() const
-{
- int i = 0;
- while ((i < weatherCount()) && (weatherIndex(i) != INT_MAX))
- ++i;
- return i;
-}
+SSUBCLASS(Sigmod, Weather, weather, weathers)
Sigmod::Sigmod& Sigmod::Sigmod::operator=(const Sigmod& rhs)
{
@@ -2308,48 +572,23 @@ Sigmod::Sigmod& Sigmod::Sigmod::operator=(const Sigmod& rhs)
void Sigmod::Sigmod::clear()
{
- qDeleteAll(m_abilities);
- m_abilities.clear();
- qDeleteAll(m_authors);
- m_authors.clear();
- qDeleteAll(m_badges);
- m_badges.clear();
- qDeleteAll(m_coinLists);
- m_coinLists.clear();
- qDeleteAll(m_eggGroups);
- m_eggGroups.clear();
- qDeleteAll(m_globalScripts);
- m_globalScripts.clear();
- qDeleteAll(m_items);
- m_items.clear();
- qDeleteAll(m_itemTypes);
- m_itemTypes.clear();
- qDeleteAll(m_maps);
- m_maps.clear();
- qDeleteAll(m_moves);
- m_moves.clear();
- qDeleteAll(m_natures);
- m_natures.clear();
- qDeleteAll(m_skins);
- m_skins.clear();
- qDeleteAll(m_sounds);
- m_sounds.clear();
- qDeleteAll(m_species);
- m_species.clear();
- qDeleteAll(m_sprites);
- m_sprites.clear();
- qDeleteAll(m_status);
- m_status.clear();
- qDeleteAll(m_stores);
- m_stores.clear();
- qDeleteAll(m_tiles);
- m_tiles.clear();
- qDeleteAll(m_times);
- m_times.clear();
- qDeleteAll(m_trainers);
- m_trainers.clear();
- qDeleteAll(m_types);
- m_types.clear();
- qDeleteAll(m_weathers);
- m_weathers.clear();
+ SUBCLASS_CLEAR(abilities);
+ SUBCLASS_CLEAR(badges);
+ SUBCLASS_CLEAR(coinLists);
+ SUBCLASS_CLEAR(eggGroups);
+ SUBCLASS_CLEAR(globalScripts);
+ SUBCLASS_CLEAR(items);
+ SUBCLASS_CLEAR(maps);
+ SUBCLASS_CLEAR(moves);
+ SUBCLASS_CLEAR(natures);
+ SUBCLASS_CLEAR(skins);
+ SUBCLASS_CLEAR(sounds);
+ SUBCLASS_CLEAR(species);
+ SUBCLASS_CLEAR(sprites);
+ SUBCLASS_CLEAR(status);
+ SUBCLASS_CLEAR(stores);
+ SUBCLASS_CLEAR(tiles);
+ SUBCLASS_CLEAR(trainers);
+ SUBCLASS_CLEAR(types);
+ SUBCLASS_CLEAR(weathers);
}
diff --git a/sigmod/Sigmod.h b/sigmod/Sigmod.h
index 043c4df1..0ccad22d 100644
--- a/sigmod/Sigmod.h
+++ b/sigmod/Sigmod.h
@@ -134,6 +134,14 @@ class SIGMOD_EXPORT Sigmod : public Object
const Rules* rules() const;
Rules* rules();
+ bool titleCheck(const QString& title) const;
+ bool versionCheck(const QString& version) const;
+ bool descriptionCheck(const QString& description) const;
+ bool singlePlayerCheck(const bool singlePlayer) const;
+ bool startMapCheck(const int startMap) const;
+ bool startWarpCheck(const int startWarp) const;
+ bool typechartCheck(const Sigcore::Fraction& multiplier) const;
+
const Ability* ability(const int index) const;
Ability* ability(const int index);
const Ability* abilityById(const int id) const;
diff --git a/sigmod/Skin.cpp b/sigmod/Skin.cpp
index 2721a59a..7cd906fb 100644
--- a/sigmod/Skin.cpp
+++ b/sigmod/Skin.cpp
@@ -74,25 +74,14 @@ QDomElement Sigmod::Skin::save() const
return xml;
}
-void Sigmod::Skin::setName(const QString& name)
-{
- CHECK(name);
-}
+SETTER(Skin, QString&, Name, name)
+SETTER(Skin, Sigcore::Script&, Script, script)
-void Sigmod::Skin::setScript(const Sigcore::Script& script)
-{
- CHECK(script);
-}
+GETTER(Skin, QString, name)
+GETTER(Skin, Sigcore::Script, script)
-QString Sigmod::Skin::name() const
-{
- return m_name;
-}
-
-Sigcore::Script Sigmod::Skin::script() const
-{
- return m_script;
-}
+CHECK(Skin, QString&, name)
+CHECK(Skin, Sigcore::Script&, script)
Sigmod::Skin& Sigmod::Skin::operator=(const Skin& rhs)
{
diff --git a/sigmod/Skin.h b/sigmod/Skin.h
index e7d96a1a..a5369aab 100644
--- a/sigmod/Skin.h
+++ b/sigmod/Skin.h
@@ -50,6 +50,9 @@ class SIGMOD_EXPORT Skin : public Object
QString name() const;
Sigcore::Script script() const;
+ bool nameCheck(const QString& name) const;
+ bool scriptCheck(const Sigcore::Script& script) const;
+
Skin& operator=(const Skin& rhs);
private:
QString m_name;
diff --git a/sigmod/Sound.cpp b/sigmod/Sound.cpp
index ff1f0706..8e6060bf 100644
--- a/sigmod/Sound.cpp
+++ b/sigmod/Sound.cpp
@@ -78,35 +78,17 @@ QDomElement Sigmod::Sound::save() const
return xml;
}
-void Sigmod::Sound::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::Sound::setType(const Type type)
-{
- CHECK(type);
-}
+SETTER(Sound, QString&, Name, name)
+SETTER(Sound, Type, Type, type)
+SETTER(Sound, QByteArray&, Data, data)
-void Sigmod::Sound::setData(const QByteArray& data)
-{
- CHECK(data);
-}
+GETTER(Sound, QString, name)
+GETTER(Sound, Sigmod::Sound::Type, type)
+GETTER(Sound, QByteArray, data)
-QString Sigmod::Sound::name() const
-{
- return m_name;
-}
-
-Sigmod::Sound::Type Sigmod::Sound::type() const
-{
- return m_type;
-}
-
-QByteArray Sigmod::Sound::data() const
-{
- return m_data;
-}
+CHECK(Sound, QString&, name)
+CHECK(Sound, Type, type)
+CHECK(Sound, QByteArray&, data)
Sigmod::Sound& Sigmod::Sound::operator=(const Sound& rhs)
{
diff --git a/sigmod/Sound.h b/sigmod/Sound.h
index 6040a6fb..30b26532 100644
--- a/sigmod/Sound.h
+++ b/sigmod/Sound.h
@@ -61,6 +61,10 @@ class SIGMOD_EXPORT Sound : public Object
Type type() const;
QByteArray data() const;
+ bool nameCheck(const QString& name) const;
+ bool typeCheck(const Type type) const;
+ bool dataCheck(const QByteArray& data) const;
+
Sound& operator=(const Sound& rhs);
private:
QString m_name;
diff --git a/sigmod/Species.cpp b/sigmod/Species.cpp
index 3d0eb4fd..1940188a 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,594 +317,49 @@ 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;
- }
- 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;
-}
-
-const Sigmod::SpeciesAbility* Sigmod::Species::ability(const int index) const
-{
- if (index < abilityCount())
- return m_abilities.at(index);
- return NULL;
-}
-
-Sigmod::SpeciesAbility* Sigmod::Species::ability(const int index)
-{
- if (index < abilityCount())
- return m_abilities[index];
- return NULL;
-}
-
-const Sigmod::SpeciesAbility* Sigmod::Species::abilityById(const int id) const
-{
- return ability(abilityIndex(id));
-}
-
-Sigmod::SpeciesAbility* Sigmod::Species::abilityById(const int id)
-{
- return ability(abilityIndex(id));
-}
-
-int Sigmod::Species::abilityIndex(const int id) const
-{
- for (int i = 0; i < abilityCount(); ++i)
- {
- if (m_abilities[i]->id() == id)
- return i;
+ EBOUNDS(stat, "HP", sigmod()->rules()->specialSplit() ? "SpecialDefense" : "Special");
+ return false;
}
- return INT_MAX;
-}
-
-int Sigmod::Species::abilityCount() const
-{
- return m_abilities.size();
-}
-
-Sigmod::SpeciesAbility* Sigmod::Species::newAbility()
-{
- return newAbility(new SpeciesAbility(this, newAbilityId()));
-}
-
-Sigmod::SpeciesAbility* Sigmod::Species::newAbility(const QDomElement& xml)
-{
- return newAbility(new SpeciesAbility(xml, this, newAbilityId()));
-}
-
-Sigmod::SpeciesAbility* Sigmod::Species::newAbility(const SpeciesAbility& ability)
-{
- return newAbility(new SpeciesAbility(ability, this, newAbilityId()));
-}
-
-Sigmod::SpeciesAbility* Sigmod::Species::newAbility(SpeciesAbility* ability)
-{
- m_abilities.append(ability);
- return ability;
-}
-
-void Sigmod::Species::deleteAbility(const int index)
-{
- if (index < abilityCount())
- {
- delete m_abilities[index];
- m_abilities.removeAt(index);
- }
-}
-
-void Sigmod::Species::deleteAbilityById(const int id)
-{
- deleteAbility(abilityIndex(id));
-}
-
-int Sigmod::Species::newAbilityId() const
-{
- int i = 0;
- while ((i < abilityCount()) && (abilityIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::SpeciesItem* Sigmod::Species::item(const int index) const
-{
- if (index < itemCount())
- return m_items.at(index);
- return NULL;
-}
-
-Sigmod::SpeciesItem* Sigmod::Species::item(const int index)
-{
- if (index < itemCount())
- return m_items[index];
- return NULL;
-}
-
-const Sigmod::SpeciesItem* Sigmod::Species::itemById(const int id) const
-{
- return item(itemIndex(id));
-}
-
-Sigmod::SpeciesItem* Sigmod::Species::itemById(const int id)
-{
- return item(itemIndex(id));
-}
-
-int Sigmod::Species::itemIndex(const int id) const
-{
- for (int i = 0; i < itemCount(); ++i)
- {
- if (m_items[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Species::itemCount() const
-{
- return m_items.size();
-}
-
-Sigmod::SpeciesItem* Sigmod::Species::newItem()
-{
- return newItem(new SpeciesItem(this, newItemId()));
-}
-
-Sigmod::SpeciesItem* Sigmod::Species::newItem(const QDomElement& xml)
-{
- return newItem(new SpeciesItem(xml, this, newItemId()));
-}
-
-Sigmod::SpeciesItem* Sigmod::Species::newItem(const SpeciesItem& item)
-{
- return newItem(new SpeciesItem(item, this, newItemId()));
-}
-
-Sigmod::SpeciesItem* Sigmod::Species::newItem(SpeciesItem* item)
-{
- m_items.append(item);
- return item;
-}
-
-void Sigmod::Species::deleteItem(const int index)
-{
- if (index < itemCount())
- {
- delete m_items[index];
- m_items.removeAt(index);
- }
-}
-
-void Sigmod::Species::deleteItemById(const int id)
-{
- deleteItem(itemIndex(id));
-}
-
-int Sigmod::Species::newItemId() const
-{
- int i = 0;
- while ((i < itemCount()) && (itemIndex(i) != INT_MAX))
- ++i;
- return i;
-}
-
-const Sigmod::SpeciesMove* Sigmod::Species::move(const int index) const
-{
- if (index < moveCount())
- return m_moves.at(index);
- return NULL;
-}
-
-Sigmod::SpeciesMove* Sigmod::Species::move(const int index)
-{
- if (index < moveCount())
- return m_moves[index];
- return NULL;
-}
-
-const Sigmod::SpeciesMove* Sigmod::Species::moveById(const int id) const
-{
- return move(moveIndex(id));
-}
-
-Sigmod::SpeciesMove* Sigmod::Species::moveById(const int id)
-{
- return move(moveIndex(id));
-}
-
-int Sigmod::Species::moveIndex(const int id) const
-{
- for (int i = 0; i < moveCount(); ++i)
- {
- if (m_moves[i]->id() == id)
- return i;
- }
- return INT_MAX;
-}
-
-int Sigmod::Species::moveCount() const
-{
- return m_moves.size();
-}
-
-Sigmod::SpeciesMove* Sigmod::Species::newMove()
-{
- return newMove(new SpeciesMove(this, newMoveId()));
-}
-
-Sigmod::SpeciesMove* Sigmod::Species::newMove(const QDomElement& xml)
-{
- return newMove(new SpeciesMove(xml, this, newMoveId()));
-}
-
-Sigmod::SpeciesMove* Sigmod::Species::newMove(const SpeciesMove& move)
-{
- return newMove(new SpeciesMove(move, this, newMoveId()));
-}
-
-Sigmod::SpeciesMove* Sigmod::Species::newMove(SpeciesMove* move)
-{
- m_moves.append(move);
- return move;
-}
-
-void Sigmod::Species::deleteMove(const int index)
-{
- if (index < moveCount())
- {
- delete m_moves[index];
- m_moves.removeAt(index);
- }
-}
-
-void Sigmod::Species::deleteMoveById(const int id)
-{
- deleteMove(moveIndex(id));
-}
-
-int Sigmod::Species::newMoveId() const
-{
- int i = 0;
- while ((i < moveCount()) && (moveIndex(i) != INT_MAX))
- ++i;
- return i;
-}
+ 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)
+
+SUBCLASS(Species, Ability, ability, abilities)
+SUBCLASS(Species, Item, item, items)
+SUBCLASS(Species, Move, move, moves)
Sigmod::Species& Sigmod::Species::operator=(const Species& rhs)
{
@@ -891,10 +399,7 @@ Sigmod::Species& Sigmod::Species::operator=(const Species& rhs)
void Sigmod::Species::clear()
{
- qDeleteAll(m_abilities);
- m_abilities.clear();
- qDeleteAll(m_items);
- m_items.clear();
- qDeleteAll(m_moves);
- m_moves.clear();
+ SUBCLASS_CLEAR(abilities);
+ SUBCLASS_CLEAR(items);
+ SUBCLASS_CLEAR(moves);
}
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;
diff --git a/sigmod/Sprite.cpp b/sigmod/Sprite.cpp
index 562a9a30..b4a7983b 100644
--- a/sigmod/Sprite.cpp
+++ b/sigmod/Sprite.cpp
@@ -75,25 +75,14 @@ QDomElement Sigmod::Sprite::save() const
return xml;
}
-void Sigmod::Sprite::setName(const QString& name)
-{
- CHECK(name);
-}
+SETTER(Sprite, QString&, Name, name)
+SETTER(Sprite, QByteArray&, Sprite, sprite)
-void Sigmod::Sprite::setSprite(const QByteArray& sprite)
-{
- CHECK(sprite);
-}
+GETTER(Sprite, QString, name)
+GETTER(Sprite, QByteArray, sprite)
-QString Sigmod::Sprite::name() const
-{
- return m_name;
-}
-
-QByteArray Sigmod::Sprite::sprite() const
-{
- return m_sprite;
-}
+CHECK(Sprite, QString&, name)
+CHECK(Sprite, QByteArray&, sprite)
Sigmod::Sprite& Sigmod::Sprite::operator=(const Sprite& rhs)
{
diff --git a/sigmod/Sprite.h b/sigmod/Sprite.h
index 13b2fc19..ed3ba248 100644
--- a/sigmod/Sprite.h
+++ b/sigmod/Sprite.h
@@ -51,6 +51,9 @@ class SIGMOD_EXPORT Sprite : public Object
QString name() const;
QByteArray sprite() const;
+ bool nameCheck(const QString& name) const;
+ bool spriteCheck(const QByteArray& sprite) const;
+
Sprite& operator=(const Sprite& rhs);
private:
QString m_name;
diff --git a/sigmod/Status.cpp b/sigmod/Status.cpp
index cbe98ba0..fbb66c41 100644
--- a/sigmod/Status.cpp
+++ b/sigmod/Status.cpp
@@ -78,35 +78,17 @@ QDomElement Sigmod::Status::save() const
return xml;
}
-void Sigmod::Status::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::Status::setBattleScript(const Sigcore::Script& battleScript)
-{
- CHECK(battleScript);
-}
+SETTER(Status, QString&, Name, name)
+SETTER(Status, Sigcore::Script&, BattleScript, battleScript)
+SETTER(Status, Sigcore::Script&, WorldScript, worldScript)
-void Sigmod::Status::setWorldScript(const Sigcore::Script& worldScript)
-{
- CHECK(worldScript);
-}
+GETTER(Status, QString, name)
+GETTER(Status, Sigcore::Script, battleScript)
+GETTER(Status, Sigcore::Script, worldScript)
-QString Sigmod::Status::name() const
-{
- return m_name;
-}
-
-Sigcore::Script Sigmod::Status::battleScript() const
-{
- return m_battleScript;
-}
-
-Sigcore::Script Sigmod::Status::worldScript() const
-{
- return m_worldScript;
-}
+CHECK(Status, QString&, name)
+CHECK(Status, Sigcore::Script&, battleScript)
+CHECK(Status, Sigcore::Script&, worldScript)
Sigmod::Status& Sigmod::Status::operator=(const Status& rhs)
{
diff --git a/sigmod/Status.h b/sigmod/Status.h
index fcfaf8f4..7f22ee74 100644
--- a/sigmod/Status.h
+++ b/sigmod/Status.h
@@ -53,6 +53,10 @@ class SIGMOD_EXPORT Status : public Object
Sigcore::Script battleScript() const;
Sigcore::Script worldScript() const;
+ bool nameCheck(const QString& name) const;
+ bool battleScriptCheck(const Sigcore::Script& battleScript) const;
+ bool worldScriptCheck(const Sigcore::Script& worldScript) const;
+
Status& operator=(const Status& rhs);
private:
QString m_name;
diff --git a/sigmod/Store.cpp b/sigmod/Store.cpp
index f5778dd4..3bd260cf 100644
--- a/sigmod/Store.cpp
+++ b/sigmod/Store.cpp
@@ -53,7 +53,7 @@ void Sigmod::Store::validate()
if (m_name.isEmpty())
emit(error("Name is empty"));
if (m_item.size())
- TEST_LIST(setItem, item);
+ TEST_LIST(item);
else
emit(error("No items in the store"));
TEST_END();
@@ -72,41 +72,14 @@ QDomElement Sigmod::Store::save() const
return xml;
}
-void Sigmod::Store::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::Store::setItem(const int item, const bool state)
-{
- if (!sigmod()->itemById(item))
- emit(error(bounds("item", item)));
- else if (state && !m_item.contains(item))
- {
- m_item.append(item);
- emit(changed());
- }
- else if (m_item.contains(item))
- {
- m_item.removeAll(item);
- emit(changed());
- }
-}
-
-QString Sigmod::Store::name() const
-{
- return m_name;
-}
+SETTER(Store, QString&, Name, name)
+SETTER_LIST(Store, Item, item)
-bool Sigmod::Store::item(const int item) const
-{
- return m_item.contains(item);
-}
+GETTER(Store, QString, name)
+GETTER_LIST(Store, item)
-QList<int> Sigmod::Store::items() const
-{
- return m_item;
-}
+CHECK(Store, QString&, name)
+CHECK_INDEX(Store, int, item, sigmod(), item)
Sigmod::Store& Sigmod::Store::operator=(const Store& rhs)
{
diff --git a/sigmod/Store.h b/sigmod/Store.h
index 5b399fcb..1ea8640a 100644
--- a/sigmod/Store.h
+++ b/sigmod/Store.h
@@ -49,7 +49,10 @@ class SIGMOD_EXPORT Store : public Object
QString name() const;
bool item(const int item) const;
- QList<int> items() const;
+ QList<int> item() const;
+
+ bool nameCheck(const QString& name) const;
+ bool itemCheck(const int item) const;
Store& operator=(const Store& rhs);
private:
diff --git a/sigmod/Tile.cpp b/sigmod/Tile.cpp
index d4468056..3af65653 100644
--- a/sigmod/Tile.cpp
+++ b/sigmod/Tile.cpp
@@ -74,35 +74,17 @@ QDomElement Sigmod::Tile::save() const
return xml;
}
-void Sigmod::Tile::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::Tile::setWalkable(const bool walkable)
-{
- CHECK(walkable);
-}
+SETTER(Tile, QString&, Name, name)
+SETTER(Tile, bool, Walkable, walkable)
+SETTER(Tile, Sigcore::Script&, Script, script)
-void Sigmod::Tile::setScript(const Sigcore::Script& script)
-{
- CHECK(script);
-}
+GETTER(Tile, QString, name)
+GETTER(Tile, bool, walkable)
+GETTER(Tile, Sigcore::Script, script)
-QString Sigmod::Tile::name() const
-{
- return m_name;
-}
-
-bool Sigmod::Tile::walkable() const
-{
- return m_walkable;
-}
-
-Sigcore::Script Sigmod::Tile::script() const
-{
- return m_script;
-}
+CHECK(Tile, QString&, name)
+CHECK(Tile, bool, walkable)
+CHECK(Tile, Sigcore::Script&, script)
Sigmod::Tile& Sigmod::Tile::operator=(const Tile& rhs)
{
diff --git a/sigmod/Tile.h b/sigmod/Tile.h
index 7904948b..c2cde094 100644
--- a/sigmod/Tile.h
+++ b/sigmod/Tile.h
@@ -52,6 +52,10 @@ class SIGMOD_EXPORT Tile : public Object
bool walkable() const;
Sigcore::Script script() const;
+ bool nameCheck(const QString& name) const;
+ bool walkableCheck(const bool walkable) const;
+ bool scriptCheck(const Sigcore::Script& script) const;
+
Tile& operator=(const Tile& rhs);
private:
QString m_name;
diff --git a/sigmod/Time.cpp b/sigmod/Time.cpp
index b4172405..f0f34486 100644
--- a/sigmod/Time.cpp
+++ b/sigmod/Time.cpp
@@ -54,8 +54,8 @@ void Sigmod::Time::validate()
TEST_BEGIN();
if (m_name.isEmpty())
emit(error("Name is empty"));
- TEST(setHour, hour);
- TEST(setMinute, minute);
+ TEST(hour);
+ TEST(minute);
TEST_END();
}
@@ -76,41 +76,17 @@ QDomElement Sigmod::Time::save() const
return xml;
}
-void Sigmod::Time::setName(const QString& name)
-{
- CHECK(name);
-}
-
-void Sigmod::Time::setHour(const int hour)
-{
- if ((hour < 0) || (24 <= hour))
- emit(error(bounds("hour", 0, 23, hour)));
- else
- CHECK(hour);
-}
+SETTER(Time, QString&, Name, name)
+SETTER(Time, int, Hour, hour)
+SETTER(Time, int, Minute, minute)
-void Sigmod::Time::setMinute(const int minute)
-{
- if ((minute < 0) || (60 <= minute))
- emit(error(bounds("minute", 0, 59, minute)));
- else
- CHECK(minute);
-}
+GETTER(Time, QString, name)
+GETTER(Time, int, hour)
+GETTER(Time, int, minute)
-QString Sigmod::Time::name() const
-{
- return m_name;
-}
-
-int Sigmod::Time::hour() const
-{
- return m_hour;
-}
-
-int Sigmod::Time::minute() const
-{
- return m_minute;
-}
+CHECK(Time, QString&, name)
+CHECK_BOUNDS(Time, int, hour, 0, 23)
+CHECK_BOUNDS(Time, int, minute, 0, 59)
Sigmod::Time& Sigmod::Time::operator=(const Time& rhs)
{
diff --git a/sigmod/Time.h b/sigmod/Time.h
index db361397..6027f128 100644
--- a/sigmod/Time.h
+++ b/sigmod/Time.h
@@ -49,6 +49,10 @@ class SIGMOD_EXPORT Time : public Object
int hour() const;
int minute() const;
+ bool nameCheck(const QString& name) const;
+ bool hourCheck(const int hour) const;
+ bool minuteCheck(const int minutes) const;
+
Time& operator=(const Time& rhs);
private:
QString m_name;
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)
{
diff --git a/sigmod/Trainer.h b/sigmod/Trainer.h
index ab2c8a96..17c4d29a 100644
--- a/sigmod/Trainer.h
+++ b/sigmod/Trainer.h
@@ -74,6 +74,16 @@ class SIGMOD_EXPORT Trainer : public Object
Intelligence abilityIntel() const;
Intelligence statIntel() const;
+ bool nameCheck(const QString& name) const;
+ bool moneyFactorCheck(const int moneyFactor) const;
+ bool skinCheck(const int skin) const;
+ bool depthCheck(const int depth) const;
+ bool teamIntelCheck(const Intelligence teamIntel) const;
+ bool moveIntelCheck(const Intelligence moveIntel) const;
+ bool itemIntelCheck(const Intelligence itemIntel) const;
+ bool abilityIntelCheck(const Intelligence abilityIntel) const;
+ bool statIntelCheck(const Intelligence statIntel) const;
+
Trainer& operator=(const Trainer& rhs);
private:
QString m_name;
diff --git a/sigmod/Type.cpp b/sigmod/Type.cpp
index 6205b965..180d4585 100644
--- a/sigmod/Type.cpp
+++ b/sigmod/Type.cpp
@@ -71,28 +71,14 @@ QDomElement Sigmod::Type::save() const
return xml;
}
-void Sigmod::Type::setName(const QString& name)
-{
- CHECK(name);
-}
+SETTER(Type, QString&, Name, name)
+SETTER(Type, Sigcore::Fraction&, Stab, stab)
-void Sigmod::Type::setStab(const Sigcore::Fraction& stab)
-{
- if (stab < 1)
- emit(error(bounds("stab", 1, INT_MAX, stab)));
- else
- CHECK(stab);
-}
+GETTER(Type, QString, name)
+GETTER(Type, Sigcore::Fraction, stab)
-QString Sigmod::Type::name() const
-{
- return m_name;
-}
-
-Sigcore::Fraction Sigmod::Type::stab() const
-{
- return m_stab;
-}
+CHECK(Type, QString&, name)
+CHECK_BOUNDS(Type, Sigcore::Fraction&, stab, 0, 1)
Sigmod::Type& Sigmod::Type::operator=(const Type& rhs)
{
diff --git a/sigmod/Type.h b/sigmod/Type.h
index b0b1f13f..50cc4fbc 100644
--- a/sigmod/Type.h
+++ b/sigmod/Type.h
@@ -50,6 +50,9 @@ class SIGMOD_EXPORT Type : public Object
QString name() const;
Sigcore::Fraction stab() const;
+ bool nameCheck(const QString& name) const;
+ bool stabCheck(const Sigcore::Fraction& stab) const;
+
Type& operator=(const Type& rhs);
private:
QString m_name;
diff --git a/sigmod/Weather.cpp b/sigmod/Weather.cpp
index 532643a4..2458d836 100644
--- a/sigmod/Weather.cpp
+++ b/sigmod/Weather.cpp
@@ -78,25 +78,14 @@ QDomElement Sigmod::Weather::save() const
return xml;
}
-void Sigmod::Weather::setName(const QString& name)
-{
- CHECK(name);
-}
+SETTER(Weather, QString&, Name, name)
+SETTER(Weather, Sigcore::Script&, Script, script)
-void Sigmod::Weather::setScript(const Sigcore::Script& script)
-{
- CHECK(script);
-}
+GETTER(Weather, QString, name)
+GETTER(Weather, Sigcore::Script, script)
-QString Sigmod::Weather::name() const
-{
- return m_name;
-}
-
-Sigcore::Script Sigmod::Weather::script() const
-{
- return m_script;
-}
+CHECK(Weather, QString&, name)
+CHECK(Weather, Sigcore::Script&, script)
Sigmod::Weather& Sigmod::Weather::operator=(const Weather& rhs)
{
diff --git a/sigmod/Weather.h b/sigmod/Weather.h
index 897d772b..ff038740 100644
--- a/sigmod/Weather.h
+++ b/sigmod/Weather.h
@@ -51,6 +51,9 @@ class SIGMOD_EXPORT Weather : public Object
QString name() const;
Sigcore::Script script() const;
+ bool nameCheck(const QString& name) const;
+ bool scriptCheck(const Sigcore::Script& script) const;
+
Weather& operator=(const Weather& rhs);
private:
QString m_name;
diff --git a/sigmod/test/TestBadge.cpp b/sigmod/test/TestBadge.cpp
index 3139e7bd..ebdad7ff 100644
--- a/sigmod/test/TestBadge.cpp
+++ b/sigmod/test/TestBadge.cpp
@@ -245,8 +245,8 @@ void TestBadge::setStat()
QCOMPARE(m_changedCount, 0);
- QCOMPARE(m_warnings.size(), 1);
- QCOMPARE(m_errors.size(), 1);
+ QCOMPARE(m_warnings.size(), 0);
+ QCOMPARE(m_errors.size(), 2);
m_sigmod->rules()->setSpecialSplit(true);
@@ -257,8 +257,8 @@ void TestBadge::setStat()
QCOMPARE(m_changedCount, 1);
- QCOMPARE(m_warnings.size(), 1);
- QCOMPARE(m_errors.size(), 1);
+ QCOMPARE(m_warnings.size(), 0);
+ QCOMPARE(m_errors.size(), 2);
m_badge2->setStat(Sigmod::ST_Defense, Sigcore::Fraction(2, 1));
m_badge2->setStat(Sigmod::ST_Defense, Sigcore::Fraction(2, 1));
@@ -267,8 +267,8 @@ void TestBadge::setStat()
QCOMPARE(m_changedCount, 2);
- QCOMPARE(m_warnings.size(), 1);
- QCOMPARE(m_errors.size(), 1);
+ QCOMPARE(m_warnings.size(), 0);
+ QCOMPARE(m_errors.size(), 2);
m_badge2->setStat(Sigmod::ST_Speed, Sigcore::Fraction(2, 1));
m_badge2->setStat(Sigmod::ST_Speed, Sigcore::Fraction(2, 1));
@@ -277,8 +277,8 @@ void TestBadge::setStat()
QCOMPARE(m_changedCount, 3);
- QCOMPARE(m_warnings.size(), 1);
- QCOMPARE(m_errors.size(), 1);
+ QCOMPARE(m_warnings.size(), 0);
+ QCOMPARE(m_errors.size(), 2);
m_badge2->setStat(Sigmod::ST_SpecialAttack, Sigcore::Fraction(2, 1));
m_badge2->setStat(Sigmod::ST_SpecialAttack, Sigcore::Fraction(2, 1));
@@ -287,8 +287,8 @@ void TestBadge::setStat()
QCOMPARE(m_changedCount, 4);
- QCOMPARE(m_warnings.size(), 1);
- QCOMPARE(m_errors.size(), 1);
+ QCOMPARE(m_warnings.size(), 0);
+ QCOMPARE(m_errors.size(), 2);
m_badge2->setStat(Sigmod::ST_SpecialDefense, Sigcore::Fraction(2, 1));
m_badge2->setStat(Sigmod::ST_SpecialDefense, Sigcore::Fraction(2, 1));
@@ -297,8 +297,8 @@ void TestBadge::setStat()
QCOMPARE(m_changedCount, 5);
- QCOMPARE(m_warnings.size(), 1);
- QCOMPARE(m_errors.size(), 1);
+ QCOMPARE(m_warnings.size(), 0);
+ QCOMPARE(m_errors.size(), 2);
}
void TestBadge::assignment()
diff --git a/sigmodr/SpeciesUI.cpp b/sigmodr/SpeciesUI.cpp
index a77ae536..a020c2d8 100644
--- a/sigmodr/SpeciesUI.cpp
+++ b/sigmodr/SpeciesUI.cpp
@@ -48,6 +48,7 @@ void Sigmodr::SpeciesUI::initGui()
varGrowth->addItem(Sigmod::Species::StyleStr[Sigmod::Species::Normal], QVariant::fromValue(Sigmod::Species::Normal));
varGrowth->addItem(Sigmod::Species::StyleStr[Sigmod::Species::Fast], QVariant::fromValue(Sigmod::Species::Fast));
varGrowth->addItem(Sigmod::Species::StyleStr[Sigmod::Species::Erratic], QVariant::fromValue(Sigmod::Species::Erratic));
+ varEffortValue->setMaximum(sigmod()->rules()->maxEVPerStat() ? sigmod()->rules()->maxEVPerStat() : INT_MAX);
}
void Sigmodr::SpeciesUI::refreshGui()
@@ -192,7 +193,7 @@ void Sigmodr::SpeciesUI::setGui()
varFemaleBack->setCurrentIndex(varFemaleBack->findData(qobject_cast<Sigmod::Species*>(modified())->backFemaleSprite()));
}
varSkin->setCurrentIndex(varSkin->findData(qobject_cast<Sigmod::Species*>(modified())->skin()));
- boxGenderChance->setChecked((qobject_cast<Sigmod::Species*>(modified())->genderFactor().denominator() < qobject_cast<Sigmod::Species*>(modified())->genderFactor().numerator()) ? Qt::Checked : Qt::Unchecked);
+ boxGenderChance->setChecked((qobject_cast<Sigmod::Species*>(modified())->genderFactor() < 0) ? Qt::Checked : Qt::Unchecked);
varGenderChance->setValue(qobject_cast<Sigmod::Species*>(modified())->genderFactor());
varEggSpecies->setCurrentIndex(varEggSpecies->findData(qobject_cast<Sigmod::Species*>(modified())->eggSpecies()));
varEggSteps->setValue(qobject_cast<Sigmod::Species*>(modified())->eggSteps());
@@ -316,7 +317,7 @@ void Sigmodr::SpeciesUI::on_varSkin_currentIndexChanged(const int skin)
void Sigmodr::SpeciesUI::on_boxGenderChance_clicked(const bool genderChance)
{
- qobject_cast<Sigmod::Species*>(modified())->setGenderFactor(Sigcore::Fraction((genderChance ? 1 : 2), 1));
+ qobject_cast<Sigmod::Species*>(modified())->setGenderFactor(Sigcore::Fraction((genderChance ? 1 : -1), 1));
}
void Sigmodr::SpeciesUI::on_varGenderChance_valueChanged(const Sigcore::Fraction& genderChance)
diff --git a/sigmodr/gui/rules.ui b/sigmodr/gui/rules.ui
index 614d46a2..85c3af0f 100644
--- a/sigmodr/gui/rules.ui
+++ b/sigmodr/gui/rules.ui
@@ -182,7 +182,7 @@
<string>The maximum amount of effort values allowed</string>
</property>
<property name="minimum" >
- <number>1</number>
+ <number>0</number>
</property>
</widget>
</item>
@@ -201,7 +201,7 @@
<string>The maximum amount of effort values allowed for a single stat</string>
</property>
<property name="minimum" >
- <number>1</number>
+ <number>0</number>
</property>
</widget>
</item>
diff --git a/sigmodr/gui/species.ui b/sigmodr/gui/species.ui
index 0f60f13a..9d988e82 100644
--- a/sigmodr/gui/species.ui
+++ b/sigmodr/gui/species.ui
@@ -385,7 +385,7 @@
<string>The Encyclopedia number of the species</string>
</property>
<property name="minimum" >
- <number>0</number>
+ <number>-1</number>
</property>
</widget>
</item>
@@ -506,7 +506,11 @@
</property>
<layout class="QVBoxLayout" >
<item>
- <widget class="Sigmodr::FractionWidget" name="varGenderChance" />
+ <widget class="Sigmodr::FractionWidget" name="varGenderChance" >
+ <property name="behavior" >
+ <enum>Sigmodr::FractionWidget::Proper</enum>
+ </property>
+ </widget>
</item>
</layout>
</widget>
diff --git a/sigscript/AbilityWrapper.cpp b/sigscript/AbilityWrapper.cpp
index a08a8e4e..6627f5f7 100644
--- a/sigscript/AbilityWrapper.cpp
+++ b/sigscript/AbilityWrapper.cpp
@@ -42,8 +42,7 @@ QString Sigscript::AbilityWrapper::name() const
int Sigscript::AbilityWrapper::priority() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("priority"))
- return valueOfType<int>("priority");
+ ALLOW_OVERRIDE_SO(ability, int, priority);
return m_ability->priority();
}
diff --git a/sigscript/CoinListItemWrapper.cpp b/sigscript/CoinListItemWrapper.cpp
index 01bf3094..fd154efe 100644
--- a/sigscript/CoinListItemWrapper.cpp
+++ b/sigscript/CoinListItemWrapper.cpp
@@ -66,7 +66,6 @@ Sigscript::SpeciesWrapper* Sigscript::CoinListItemWrapper::speciesObject()
int Sigscript::CoinListItemWrapper::cost() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("cost"))
- return valueOfType<int>("cost");
+ ALLOW_OVERRIDE_SO(object, int, cost);
return m_object->cost();
}
diff --git a/sigscript/Global.h b/sigscript/Global.h
index c8ab9c93..9c60b170 100644
--- a/sigscript/Global.h
+++ b/sigscript/Global.h
@@ -34,4 +34,15 @@
# define SIGSCRIPT_EXPORT_DEPRECATED KDE_DEPRECATED SIGSCRIPT_EXPORT
#endif
+#ifdef MAKE_SIGSCRIPT_LIB
+
+#define ALLOW_OVERRIDE_SO(class, type, variable) \
+ if (sigmod()->singlePlayer()) \
+ ALLOW_OVERRIDE(class, type, variable)
+#define ALLOW_OVERRIDE(class, type, variable) \
+ if (hasValueOfType<type>(#variable) && m_##class->variable##Check(valueOfType<type>(#variable))) \
+ return valueOfType<type>(#variable)
+
+#endif
+
#endif
diff --git a/sigscript/ItemTypeWrapper.cpp b/sigscript/ItemTypeWrapper.cpp
index 8201a33b..42008c7a 100644
--- a/sigscript/ItemTypeWrapper.cpp
+++ b/sigscript/ItemTypeWrapper.cpp
@@ -61,8 +61,7 @@ int Sigscript::ItemTypeWrapper::player() const
int Sigscript::ItemTypeWrapper::maxWeight() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("maxWeight"))
- return valueOfType<int>("maxWeight");
+ ALLOW_OVERRIDE_SO(itemType, int, maxWeight);
return m_itemType->maxWeight();
}
diff --git a/sigscript/ItemWrapper.cpp b/sigscript/ItemWrapper.cpp
index 1e341144..22706474 100644
--- a/sigscript/ItemWrapper.cpp
+++ b/sigscript/ItemWrapper.cpp
@@ -52,15 +52,13 @@ Sigscript::ItemTypeWrapper* Sigscript::ItemWrapper::type()
int Sigscript::ItemWrapper::price() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("price"))
- return valueOfType<int>("price");
+ ALLOW_OVERRIDE_SO(item, int, price);
return m_item->price();
}
int Sigscript::ItemWrapper::sellPrice() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("sellPrice"))
- return valueOfType<int>("sellPrice");
+ ALLOW_OVERRIDE_SO(item, int, sellPrice);
return m_item->sellPrice();
}
diff --git a/sigscript/MapEffectWrapper.cpp b/sigscript/MapEffectWrapper.cpp
index 0302c89d..d51cdca0 100644
--- a/sigscript/MapEffectWrapper.cpp
+++ b/sigscript/MapEffectWrapper.cpp
@@ -43,8 +43,7 @@ QString Sigscript::MapEffectWrapper::name() const
QPoint Sigscript::MapEffectWrapper::coordinate() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<QPoint>("coordinate"))
- return valueOfType<QPoint>("coordinate");
+ ALLOW_OVERRIDE_SO(effect, QPoint, coordinate);
return m_effect->coordinate();
}
@@ -55,8 +54,7 @@ Sigscript::SkinWrapper* Sigscript::MapEffectWrapper::skin()
bool Sigscript::MapEffectWrapper::isGhost() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<bool>("ghost"))
- return valueOfType<bool>("ghost");
+ ALLOW_OVERRIDE_SO(effect, bool, isGhost);
return m_effect->isGhost();
}
diff --git a/sigscript/MapTileWrapper.cpp b/sigscript/MapTileWrapper.cpp
index 2ca2abbe..2faef412 100644
--- a/sigscript/MapTileWrapper.cpp
+++ b/sigscript/MapTileWrapper.cpp
@@ -43,14 +43,12 @@ Sigscript::TileWrapper* Sigscript::MapTileWrapper::tile()
QPoint Sigscript::MapTileWrapper::position() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<QPoint>("position"))
- return valueOfType<QPoint>("position");
+ ALLOW_OVERRIDE_SO(tile, QPoint, position);
return m_tile->position();
}
int Sigscript::MapTileWrapper::zIndex() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("zIndex"))
- return valueOfType<int>("zIndex");
+ ALLOW_OVERRIDE_SO(tile, int, zIndex);
return m_tile->zIndex();
}
diff --git a/sigscript/MapTrainerTeamMemberWrapper.cpp b/sigscript/MapTrainerTeamMemberWrapper.cpp
index 3159ad5e..6309c1d7 100644
--- a/sigscript/MapTrainerTeamMemberWrapper.cpp
+++ b/sigscript/MapTrainerTeamMemberWrapper.cpp
@@ -43,14 +43,13 @@ Sigscript::SpeciesWrapper* Sigscript::MapTrainerTeamMemberWrapper::species()
int Sigscript::MapTrainerTeamMemberWrapper::level() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("level"))
- return valueOfType<int>("level");
+ ALLOW_OVERRIDE_SO(teamMember, int, level);
return m_teamMember->level();
}
QList<Sigscript::AbilityWrapper*> Sigscript::MapTrainerTeamMemberWrapper::abilities()
{
- QList<int> abilityIds = m_teamMember->abilities();
+ QList<int> abilityIds = m_teamMember->ability();
QList<AbilityWrapper*> abilities;
foreach (int id, abilityIds)
abilities.append(sigmod()->ability(id));
@@ -59,7 +58,7 @@ QList<Sigscript::AbilityWrapper*> Sigscript::MapTrainerTeamMemberWrapper::abilit
QList<Sigscript::ItemWrapper*> Sigscript::MapTrainerTeamMemberWrapper::items()
{
- QList<int> itemIds = m_teamMember->items();
+ QList<int> itemIds = m_teamMember->item();
QList<ItemWrapper*> items;
foreach (int id, itemIds)
items.append(sigmod()->item(id));
@@ -68,7 +67,7 @@ QList<Sigscript::ItemWrapper*> Sigscript::MapTrainerTeamMemberWrapper::items()
QList<Sigscript::MoveWrapper*> Sigscript::MapTrainerTeamMemberWrapper::moves()
{
- QList<int> moveIds = m_teamMember->moves();
+ QList<int> moveIds = m_teamMember->move();
QList<MoveWrapper*> moves;
foreach (int id, moveIds)
moves.append(sigmod()->move(id));
@@ -77,7 +76,7 @@ QList<Sigscript::MoveWrapper*> Sigscript::MapTrainerTeamMemberWrapper::moves()
QList<Sigscript::NatureWrapper*> Sigscript::MapTrainerTeamMemberWrapper::natures()
{
- QList<int> natureIds = m_teamMember->natures();
+ QList<int> natureIds = m_teamMember->nature();
QList<NatureWrapper*> natures;
foreach (int id, natureIds)
natures.append(sigmod()->nature(id));
diff --git a/sigscript/MapWarpWrapper.cpp b/sigscript/MapWarpWrapper.cpp
index 4af106a9..70547608 100644
--- a/sigscript/MapWarpWrapper.cpp
+++ b/sigscript/MapWarpWrapper.cpp
@@ -56,8 +56,7 @@ QString Sigscript::MapWarpWrapper::name() const
QRect Sigscript::MapWarpWrapper::area() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<QRect>("area"))
- return valueOfType<QRect>("area");
+ ALLOW_OVERRIDE_SO(warp, QRect, area);
return m_warp->area();
}
diff --git a/sigscript/MapWildListEncounterWrapper.cpp b/sigscript/MapWildListEncounterWrapper.cpp
index 1d2b7904..b6d6daf4 100644
--- a/sigscript/MapWildListEncounterWrapper.cpp
+++ b/sigscript/MapWildListEncounterWrapper.cpp
@@ -43,14 +43,12 @@ Sigscript::SpeciesWrapper* Sigscript::MapWildListEncounterWrapper::species()
int Sigscript::MapWildListEncounterWrapper::level() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("level"))
- return valueOfType<int>("level");
+ ALLOW_OVERRIDE_SO(encounter, int, level);
return m_encounter->level();
}
int Sigscript::MapWildListEncounterWrapper::weight() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("weight"))
- return valueOfType<int>("weight");
+ ALLOW_OVERRIDE_SO(encounter, int, weight);
return m_encounter->weight();
}
diff --git a/sigscript/MoveWrapper.cpp b/sigscript/MoveWrapper.cpp
index 8242e88f..17c3b4f2 100644
--- a/sigscript/MoveWrapper.cpp
+++ b/sigscript/MoveWrapper.cpp
@@ -42,15 +42,13 @@ QString Sigscript::MoveWrapper::name() const
Sigcore::Fraction Sigscript::MoveWrapper::accuracy() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<Sigcore::Fraction>("accuracy"))
- return valueOfType<Sigcore::Fraction>("accuracy");
+ ALLOW_OVERRIDE_SO(move, Sigcore::Fraction, accuracy);
return m_move->accuracy();
}
int Sigscript::MoveWrapper::power() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("power"))
- return valueOfType<int>("power");
+ ALLOW_OVERRIDE_SO(move, int, power);
return m_move->power();
}
@@ -71,8 +69,7 @@ int Sigscript::MoveWrapper::powerPoints() const
int Sigscript::MoveWrapper::priority() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("priority"))
- return valueOfType<int>("priority");
+ ALLOW_OVERRIDE_SO(move, int, priority);
return m_move->priority();
}
diff --git a/sigscript/RulesWrapper.cpp b/sigscript/RulesWrapper.cpp
index 39efd685..a5f78592 100644
--- a/sigscript/RulesWrapper.cpp
+++ b/sigscript/RulesWrapper.cpp
@@ -57,50 +57,43 @@ bool Sigscript::RulesWrapper::useTurns() const
bool Sigscript::RulesWrapper::pausedATB() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<bool>("pausedATB"))
- return valueOfType<bool>("pausedATB");
+ ALLOW_OVERRIDE_SO(rules, bool, pausedATB);
return m_rules->pausedATB();
}
int Sigscript::RulesWrapper::numBoxes() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("numBoxes"))
- return valueOfType<int>("numBoxes");
+ ALLOW_OVERRIDE_SO(rules, int, numBoxes);
return m_rules->numBoxes();
}
int Sigscript::RulesWrapper::boxSize() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("boxSize"))
- return valueOfType<int>("boxSize");
+ ALLOW_OVERRIDE_SO(rules, int, boxSize);
return m_rules->boxSize();
}
int Sigscript::RulesWrapper::maxParty() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("maxParty"))
- return valueOfType<int>("maxParty");
+ ALLOW_OVERRIDE_SO(rules, int, maxParty);
return m_rules->maxParty();
}
int Sigscript::RulesWrapper::maxFight() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("maxFight"))
- return valueOfType<int>("maxFight");
+ ALLOW_OVERRIDE_SO(rules, int, maxFight);
return m_rules->maxFight();
}
int Sigscript::RulesWrapper::maxPlayers() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("maxFight"))
- return valueOfType<int>("maxFight");
+ ALLOW_OVERRIDE_SO(rules, int, maxFight);
return m_rules->maxPlayers();
}
int Sigscript::RulesWrapper::maxHeldItems() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("maxHeldItems"))
- return valueOfType<int>("maxHeldItems");
+ ALLOW_OVERRIDE_SO(rules, int, maxHeldItems);
return m_rules->maxHeldItems();
}
@@ -116,43 +109,37 @@ int Sigscript::RulesWrapper::maxNatures() const
int Sigscript::RulesWrapper::maxMoves() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("maxMoves"))
- return valueOfType<int>("maxMoves");
+ ALLOW_OVERRIDE_SO(rules, int, maxMoves);
return m_rules->maxMoves();
}
int Sigscript::RulesWrapper::maxLevel() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("maxLevel"))
- return valueOfType<int>("maxLevel");
+ ALLOW_OVERRIDE_SO(rules, int, maxLevel);
return m_rules->maxLevel();
}
int Sigscript::RulesWrapper::maxStages() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("maxStages"))
- return valueOfType<int>("maxStages");
+ ALLOW_OVERRIDE_SO(rules, int, maxStages);
return m_rules->maxStages();
}
int Sigscript::RulesWrapper::maxMoney() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("maxMoney"))
- return valueOfType<int>("maxMoney");
+ ALLOW_OVERRIDE_SO(rules, int, maxMoney);
return m_rules->maxMoney();
}
int Sigscript::RulesWrapper::maxTotalWeight() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("maxTotalWeight"))
- return valueOfType<int>("maxTotalWeight");
+ ALLOW_OVERRIDE_SO(rules, int, maxTotalWeight);
return m_rules->maxTotalWeight();
}
bool Sigscript::RulesWrapper::allowSwitchStyle() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<bool>("allowSwitchStyle"))
- return valueOfType<bool>("allowSwitchStyle");
+ ALLOW_OVERRIDE_SO(rules, bool, allowSwitchStyle);
return m_rules->allowSwitchStyle();
}
@@ -173,14 +160,12 @@ bool Sigscript::RulesWrapper::effortValuesAllowed() const
int Sigscript::RulesWrapper::maxTotalEV() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("maxTotalEV"))
- return valueOfType<int>("maxTotalEV");
+ ALLOW_OVERRIDE_SO(rules, int, maxTotalEV);
return m_rules->maxTotalEV();
}
int Sigscript::RulesWrapper::maxEVPerStat() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("maxEVPerStat"))
- return valueOfType<int>("maxEVPerStat");
+ ALLOW_OVERRIDE_SO(rules, int, maxEVPerStat);
return m_rules->maxEVPerStat();
}
diff --git a/sigscript/SpeciesItemWrapper.cpp b/sigscript/SpeciesItemWrapper.cpp
index a41f8dc5..a734c978 100644
--- a/sigscript/SpeciesItemWrapper.cpp
+++ b/sigscript/SpeciesItemWrapper.cpp
@@ -43,7 +43,6 @@ Sigscript::ItemWrapper* Sigscript::SpeciesItemWrapper::item()
int Sigscript::SpeciesItemWrapper::weight() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("weight"))
- return valueOfType<int>("weight");
+ ALLOW_OVERRIDE_SO(item, int, weight);
return m_item->weight();
}
diff --git a/sigscript/SpeciesWrapper.cpp b/sigscript/SpeciesWrapper.cpp
index 9afda9b0..08c59b68 100644
--- a/sigscript/SpeciesWrapper.cpp
+++ b/sigscript/SpeciesWrapper.cpp
@@ -108,22 +108,19 @@ int Sigscript::SpeciesWrapper::maxHoldWeight() const
Sigcore::Fraction Sigscript::SpeciesWrapper::runChance() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<Sigcore::Fraction>("runChance"))
- return valueOfType<Sigcore::Fraction>("runChance");
+ ALLOW_OVERRIDE_SO(species, Sigcore::Fraction, runChance);
return m_species->runChance();
}
Sigcore::Fraction Sigscript::SpeciesWrapper::fleeChance() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<Sigcore::Fraction>("fleeChance"))
- return valueOfType<Sigcore::Fraction>("fleeChance");
+ ALLOW_OVERRIDE_SO(species, Sigcore::Fraction, fleeChance);
return m_species->fleeChance();
}
Sigcore::Fraction Sigscript::SpeciesWrapper::itemChance() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<Sigcore::Fraction>("itemChance"))
- return valueOfType<Sigcore::Fraction>("itemChance");
+ ALLOW_OVERRIDE_SO(species, Sigcore::Fraction, itemChance);
return m_species->itemChance();
}
@@ -179,8 +176,7 @@ Sigcore::Fraction Sigscript::SpeciesWrapper::genderFactor() const
int Sigscript::SpeciesWrapper::eggSpecies() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("eggSpecies"))
- return valueOfType<int>("eggSpecies");
+ ALLOW_OVERRIDE_SO(species, int, eggSpecies);
return m_species->eggSpecies();
}
@@ -191,7 +187,7 @@ int Sigscript::SpeciesWrapper::eggSteps() const
QList<Sigscript::TypeWrapper*> Sigscript::SpeciesWrapper::types()
{
- QList<int> typeIds = m_species->types();
+ QList<int> typeIds = m_species->type();
QList<TypeWrapper*> types;
foreach (int id, typeIds)
types.append(sigmod()->type(id));
@@ -200,7 +196,7 @@ QList<Sigscript::TypeWrapper*> Sigscript::SpeciesWrapper::types()
QList<Sigscript::EggGroupWrapper*> Sigscript::SpeciesWrapper::eggGroups()
{
- QList<int> eggGroupIds = m_species->eggGroups();
+ QList<int> eggGroupIds = m_species->eggGroup();
QList<EggGroupWrapper*> eggGroups;
foreach (int id, eggGroupIds)
eggGroups.append(sigmod()->eggGroup(id));
diff --git a/sigscript/StoreWrapper.cpp b/sigscript/StoreWrapper.cpp
index e3344419..f3e4f708 100644
--- a/sigscript/StoreWrapper.cpp
+++ b/sigscript/StoreWrapper.cpp
@@ -42,7 +42,7 @@ QString Sigscript::StoreWrapper::name() const
QList<Sigscript::ItemWrapper*> Sigscript::StoreWrapper::items()
{
- QList<int> itemIds = m_store->items();
+ QList<int> itemIds = m_store->item();
QList<ItemWrapper*> items;
foreach (int id, itemIds)
items.append(sigmod()->item(id));
diff --git a/sigscript/TileWrapper.cpp b/sigscript/TileWrapper.cpp
index 2674caa8..5d7b5a55 100644
--- a/sigscript/TileWrapper.cpp
+++ b/sigscript/TileWrapper.cpp
@@ -42,8 +42,7 @@ QString Sigscript::TileWrapper::name() const
bool Sigscript::TileWrapper::walkable() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<bool>("walkable"))
- return valueOfType<bool>("walkable");
+ ALLOW_OVERRIDE_SO(tile, bool, walkable);
return m_tile->walkable();
}
diff --git a/sigscript/TrainerWrapper.cpp b/sigscript/TrainerWrapper.cpp
index 34751aa7..52a8f99b 100644
--- a/sigscript/TrainerWrapper.cpp
+++ b/sigscript/TrainerWrapper.cpp
@@ -55,8 +55,7 @@ QString Sigscript::TrainerWrapper::TrainerWrapper::name() const
int Sigscript::TrainerWrapper::TrainerWrapper::moneyFactor() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("moneyFactor"))
- return valueOfType<int>("moneyFactor");
+ ALLOW_OVERRIDE_SO(trainer, int, moneyFactor);
return m_trainer->moneyFactor();
}
@@ -67,8 +66,7 @@ Sigscript::SkinWrapper* Sigscript::TrainerWrapper::TrainerWrapper::skin()
int Sigscript::TrainerWrapper::TrainerWrapper::depth() const
{
- if (sigmod()->singlePlayer() && hasValueOfType<int>("depth"))
- return valueOfType<int>("depth");
+ ALLOW_OVERRIDE_SO(trainer, int, depth);
return m_trainer->depth();
}