From a423cf3db8fa90cc09d2f92ff892e4fcdda4af16 Mon Sep 17 00:00:00 2001 From: Ben Boeckel Date: Mon, 30 Jun 2008 01:37:51 +0000 Subject: [FIX] Replaced Point with QPoint (less duplicate code) [FIX] Fraction and Point widgets are more compact [FIX] Fleshed out more of the TeamMember [FIX] Map tilemap editor now expands to fill all available area [FIX] Added priority values to abilities and moves [FIX] Added option for ATB-like battle rounds git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@217 6ecfd1a5-f3ed-3746-8530-beee90d26b22 --- pokebattle/Arena.cpp | 39 +++++++++++++++++++++++++++++++-------- 1 file changed, 31 insertions(+), 8 deletions(-) (limited to 'pokebattle/Arena.cpp') diff --git a/pokebattle/Arena.cpp b/pokebattle/Arena.cpp index a2ece8fa..68d3d6ed 100644 --- a/pokebattle/Arena.cpp +++ b/pokebattle/Arena.cpp @@ -26,36 +26,59 @@ // KDE includes #include -#include +#include -int Pokebattle::Arena::m_totalCount = 0; +QSet Pokebattle::Arena::m_arenaIds; Pokebattle::Arena::Arena(QList players) : - m_count(m_totalCount), + m_id(0), m_players(players), - m_actions(new Kross::ActionCollection(QString("arena-%1").arg(m_count), Kross::Manager::self().actionCollection())) + m_actions(NULL) { connect(this, SIGNAL(battleEnd()), SLOT(cleanUp())); connect(this, SIGNAL(battleEnd()), SLOT(unregisterAllScripts())); - ++m_totalCount; + for (; (m_id < m_arenaIds.size()) && m_arenaIds.contains(m_id); ++m_id) + ; + m_arenaIds.insert(m_id); + unregisterAllScripts(); +// foreach (Player* player, m_players) +// { +// QList leadMembers(player->active()); +// foreach (TeamMember* teamMember, leadMembers) +// { +// // TODO: load abilities +// // TODO: connect signals for retreating and fainting to removing abilities +// } +// } } Pokebattle::Arena::~Arena() { - --m_totalCount; + m_arenaIds.remove(m_id); delete m_actions; } +Kross::Action* Pokebattle::Arena::script(const QString& name) +{ + return m_actions->action(name); +} + void Pokebattle::Arena::registerScript(const QString& name, const Pokemod::Script& script) { Kross::Action* action = new Kross::Action(m_actions, name); action->setInterpreter(script.interpreter()); action->setCode(script.script().toUtf8()); action->addObject(this, "arena", Kross::ChildrenInterface::AutoConnectSignals); - action->trigger(); m_actions->addAction(action); } +void Pokebattle::Arena::triggerScript(const QString& name) +{ + Kross::Action* action = m_actions->action(name); + if (action) + action->trigger(); +} + void Pokebattle::Arena::unregisterScript(const QString& name) { m_actions->removeAction(name); @@ -64,7 +87,7 @@ void Pokebattle::Arena::unregisterScript(const QString& name) void Pokebattle::Arena::unregisterAllScripts() { delete m_actions; - m_actions = new Kross::ActionCollection(QString("arena-%1").arg(m_count), Kross::Manager::self().actionCollection()); + m_actions = new Kross::ActionCollection(QString("arena-%1").arg(m_id), Kross::Manager::self().actionCollection()); } void Pokebattle::Arena::cleanUp() -- cgit