summaryrefslogtreecommitdiffstats
path: root/pokescripting/SpeciesWrapper.cpp
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-08-18 18:51:31 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-08-18 18:51:31 +0000
commitc1793a87ebea8c8e1bb2d5d1a409d105bfae3871 (patch)
treeb7ff53cf9747ad61a80b169e1adad96950f4b16c /pokescripting/SpeciesWrapper.cpp
parentfa4764c9e4d86fdfa976bb9fa9f6976e82c496d5 (diff)
downloadsigen-c1793a87ebea8c8e1bb2d5d1a409d105bfae3871.tar.gz
sigen-c1793a87ebea8c8e1bb2d5d1a409d105bfae3871.tar.xz
sigen-c1793a87ebea8c8e1bb2d5d1a409d105bfae3871.zip
[FIX] Script to make a tarball now defaults to HEAD for the revision
[FIX] Enumeration types used to help remove some checks [FIX] Macro code moved to static members of Object (not all though) [FIX] Scripting wrappers now share information by keeping track of already-created instances of the wrapper [FIX] Scripting methods are now Q_SCRIPTABLE and not slots git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@239 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokescripting/SpeciesWrapper.cpp')
-rw-r--r--pokescripting/SpeciesWrapper.cpp36
1 files changed, 19 insertions, 17 deletions
diff --git a/pokescripting/SpeciesWrapper.cpp b/pokescripting/SpeciesWrapper.cpp
index 9c2737e4..23f76082 100644
--- a/pokescripting/SpeciesWrapper.cpp
+++ b/pokescripting/SpeciesWrapper.cpp
@@ -19,17 +19,19 @@
#include "SpeciesWrapper.h"
// Pokescripting includes
-#include "AbilityWrapper.h"
-#include "EggGroupWrapper.h"
-#include "ItemWrapper.h"
-#include "SkinWrapper.h"
+#include "PokemodWrapper.h"
#include "SpeciesAbilityWrapper.h"
#include "SpeciesItemWrapper.h"
#include "SpeciesMoveWrapper.h"
-#include "SpriteWrapper.h"
-#include "TypeWrapper.h"
-Pokescripting::SpeciesWrapper::SpeciesWrapper(const Pokemod::Species* species, QObject* parent) :
+Pokescripting::SpeciesWrapper* Pokescripting::SpeciesWrapper::create(const Pokemod::Species* species, PokemodWrapper* parent)
+{
+ if (!m_instances.contains(Signiture(parent, species->id())))
+ m_instances[Signiture(parent, species->id())] = new SpeciesWrapper(species, parent);
+ return qobject_cast<SpeciesWrapper*>(m_instances[Signiture(parent, species->id())]);
+}
+
+Pokescripting::SpeciesWrapper::SpeciesWrapper(const Pokemod::Species* species, PokemodWrapper* parent) :
ObjectWrapper(species, parent),
m_species(species)
{
@@ -56,17 +58,17 @@ QString Pokescripting::SpeciesWrapper::name() const
return m_species->name();
}
-int Pokescripting::SpeciesWrapper::baseStat(const int stat) const
+int Pokescripting::SpeciesWrapper::baseStat(const Pokemod::Stat stat) const
{
return m_species->baseStat(stat);
}
-int Pokescripting::SpeciesWrapper::effortValue(const int stat) const
+int Pokescripting::SpeciesWrapper::effortValue(const Pokemod::Stat stat) const
{
return m_species->effortValue(stat);
}
-int Pokescripting::SpeciesWrapper::growth() const
+Pokemod::Species::Style Pokescripting::SpeciesWrapper::growth() const
{
return m_species->growth();
}
@@ -124,27 +126,27 @@ QString Pokescripting::SpeciesWrapper::pokedexEntry() const
Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::frontMaleSprite()
{
- return SpriteWrapper::create(pokemod()->spriteById(m_species->frontMaleSprite()), this);
+ return pokemod()->sprite(m_species->frontMaleSprite());
}
Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::backMaleSprite()
{
- return SpriteWrapper::create(pokemod()->spriteById(m_species->backMaleSprite()), this);
+ return pokemod()->sprite(m_species->backMaleSprite());
}
Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::frontFemaleSprite()
{
- return SpriteWrapper::create(pokemod()->spriteById(m_species->frontFemaleSprite()), this);
+ return pokemod()->sprite(m_species->frontFemaleSprite());
}
Pokescripting::SpriteWrapper* Pokescripting::SpeciesWrapper::backFemaleSprite()
{
- return SpriteWrapper::create(pokemod()->spriteById(m_species->backFemaleSprite()), this);
+ return pokemod()->sprite(m_species->backFemaleSprite());
}
Pokescripting::SkinWrapper* Pokescripting::SpeciesWrapper::skin()
{
- return SkinWrapper::create(pokemod()->skinById(m_species->skin()), this);
+ return pokemod()->skin(m_species->skin());
}
Pokemod::Fraction Pokescripting::SpeciesWrapper::genderFactor() const
@@ -169,7 +171,7 @@ QList<Pokescripting::TypeWrapper*> Pokescripting::SpeciesWrapper::types()
QList<int> typeIds = m_species->types();
QList<TypeWrapper*> types;
foreach (int id, typeIds)
- types.append(TypeWrapper::create(pokemod()->typeById(id), this));
+ types.append(pokemod()->type(id));
return types;
}
@@ -178,7 +180,7 @@ QList<Pokescripting::EggGroupWrapper*> Pokescripting::SpeciesWrapper::eggGroups(
QList<int> eggGroupIds = m_species->eggGroups();
QList<EggGroupWrapper*> eggGroups;
foreach (int id, eggGroupIds)
- eggGroups.append(EggGroupWrapper::create(pokemod()->eggGroupById(id), this));
+ eggGroups.append(pokemod()->eggGroup(id));
return eggGroups;
}