summaryrefslogtreecommitdiffstats
path: root/pokescripting/MapTrainerWrapper.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokescripting/MapTrainerWrapper.cpp')
-rw-r--r--pokescripting/MapTrainerWrapper.cpp14
1 files changed, 11 insertions, 3 deletions
diff --git a/pokescripting/MapTrainerWrapper.cpp b/pokescripting/MapTrainerWrapper.cpp
index d4d71914..a3ac6050 100644
--- a/pokescripting/MapTrainerWrapper.cpp
+++ b/pokescripting/MapTrainerWrapper.cpp
@@ -19,10 +19,18 @@
#include "MapTrainerWrapper.h"
// Pokescripting includes
+#include "MapWrapper.h"
#include "MapTrainerTeamMemberWrapper.h"
-#include "TrainerWrapper.h"
+#include "PokemodWrapper.h"
-Pokescripting::MapTrainerWrapper::MapTrainerWrapper(const Pokemod::MapTrainer* trainer, QObject* parent) :
+Pokescripting::MapTrainerWrapper* Pokescripting::MapTrainerWrapper::create(const Pokemod::MapTrainer* trainer, MapWrapper* parent)
+{
+ if (!m_instances.contains(Signiture(parent, trainer->id())))
+ m_instances[Signiture(parent, trainer->id())] = new MapTrainerWrapper(trainer, parent);
+ return qobject_cast<MapTrainerWrapper*>(m_instances[Signiture(parent, trainer->id())]);
+}
+
+Pokescripting::MapTrainerWrapper::MapTrainerWrapper(const Pokemod::MapTrainer* trainer, MapWrapper* parent) :
ObjectWrapper(trainer, parent),
m_trainer(trainer)
{
@@ -35,7 +43,7 @@ QString Pokescripting::MapTrainerWrapper::name() const
Pokescripting::TrainerWrapper* Pokescripting::MapTrainerWrapper::trainerClass()
{
- return TrainerWrapper::create(pokemod()->trainerById(m_trainer->trainerClass()), this);
+ return pokemod()->trainer(m_trainer->trainerClass());
}
int Pokescripting::MapTrainerWrapper::numberFight() const