diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2009-03-05 19:36:36 -0500 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2009-03-05 19:46:37 -0500 |
commit | 05e36e61bd2bc631ef32c1e3dc869e789b141f41 (patch) | |
tree | 302c3f49f9962c084546032c4c124118f9b3df9c /sigencore | |
parent | 05413c5be74af567f97d8ca2b5c16c03e9f60941 (diff) | |
download | sigen-05e36e61bd2bc631ef32c1e3dc869e789b141f41.tar.gz sigen-05e36e61bd2bc631ef32c1e3dc869e789b141f41.tar.xz sigen-05e36e61bd2bc631ef32c1e3dc869e789b141f41.zip |
Initial cleanup of ATBArena
Diffstat (limited to 'sigencore')
-rw-r--r-- | sigencore/plugins/arenas/CMakeLists.txt | 1 | ||||
-rw-r--r-- | sigencore/plugins/arenas/atb/ATBArena.cpp | 35 | ||||
-rw-r--r-- | sigencore/plugins/arenas/atb/ATBArena.h | 44 |
3 files changed, 48 insertions, 32 deletions
diff --git a/sigencore/plugins/arenas/CMakeLists.txt b/sigencore/plugins/arenas/CMakeLists.txt index f7fc655c..6ac4ed39 100644 --- a/sigencore/plugins/arenas/CMakeLists.txt +++ b/sigencore/plugins/arenas/CMakeLists.txt @@ -3,6 +3,7 @@ project(sigenarenas) set(sigenarenas_SRCS SigenArenas.cpp atb/ActionQueue.cpp + atb/ATBArena.cpp atb/ATBTimer.cpp standard/TurnArena.cpp ) diff --git a/sigencore/plugins/arenas/atb/ATBArena.cpp b/sigencore/plugins/arenas/atb/ATBArena.cpp index eaea0134..8e40c06d 100644 --- a/sigencore/plugins/arenas/atb/ATBArena.cpp +++ b/sigencore/plugins/arenas/atb/ATBArena.cpp @@ -1,5 +1,5 @@ /* - * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -24,32 +24,39 @@ // Qt includes #include <QtCore/QTimer> -Sigbattle::ATBArena::ATBArena(Sigscript::SigmodWrapper* sigmod, QSet<Player*> players, const bool isWild, Sigscript::Config* parent) : - Arena(sigmod, players, isWild, parent) +using namespace Sigscript; +using namespace Sigencore; + +ATBArena::ATBArena(GameWrapper* sigmod, Config* parent) : + Arena(sigmod, parent), + m_atbTimer(NULL), + m_processTicker(NULL) { setupBattle(); } -void Sigbattle::ATBArena::handleAction(TeamMember* teamMember, TeamMember::Action action) +ATBArena::~ATBArena() { - if (action.first == TeamMember::Skip) - { - m_decisions.enqueue(requestDecision(teamMember)); +} + +void ATBArena::handleAction(TeamMember* teamMember, TeamMember::Action action) +{ + if ((action.first == TeamMember::Invalid) || (action.first == TeamMember::Timeout)) return; - } Arena::handleAction(teamMember, action); } -void Sigbattle::ATBArena::setupBattle() +void ATBArena::setupBattle() { m_atbTimer = new ATBTimer(this, m_decisions); m_processTicker = new QTimer(this); + m_processTicker->setInterval(100); connect(m_processTicker, SIGNAL(timeout()), this, SLOT(processActions())); - m_processTicker->start(100); + connect(this, SIGNAL(battleStarted()), m_processTicker, SLOT(start())); Arena::setupBattle(); } -void Sigbattle::ATBArena::processActions() +void ATBArena::processActions() { if (!m_decisions.isEmpty()) { @@ -61,11 +68,7 @@ void Sigbattle::ATBArena::processActions() } } -void Sigbattle::ATBArena::cleanUp() +void ATBArena::cleanUp() { - delete m_atbTimer; - m_atbTimer = NULL; - delete m_processTicker; - m_processTicker = NULL; Arena::cleanUp(); } diff --git a/sigencore/plugins/arenas/atb/ATBArena.h b/sigencore/plugins/arenas/atb/ATBArena.h index f5398d22..029ee0b1 100644 --- a/sigencore/plugins/arenas/atb/ATBArena.h +++ b/sigencore/plugins/arenas/atb/ATBArena.h @@ -1,5 +1,5 @@ /* - * Copyright 2008 Ben Boeckel <MathStuf@gmail.com> + * Copyright 2008-2009 Ben Boeckel <MathStuf@gmail.com> * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -15,40 +15,52 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -#ifndef SIGBATTLE_ATBARENA -#define SIGBATTLE_ATBARENA +#ifndef SIGENARENAS_ATBARENA +#define SIGENARENAS_ATBARENA -// Sigbattle includes +// ATB includes #include "ActionQueue.h" -#include "Arena.h" + +// Sigencore includes +#include <sigencore/Arena.h> // Forward declaraions class QTimer; - -namespace Sigbattle -{ class ATBTimer; -class SIGBATTLE_EXPORT ATBArena : public Arena +class ATBArena : public Sigencore::Arena { Q_OBJECT public: - ATBArena(Sigscript::SigmodWrapper* sigmod, QSet<Player*> players, const bool isWild, Sigscript::Config* parent); + ATBArena(Sigscript::GameWrapper* game, Sigscript::Config* parent); + ~ATBArena(); - void handleAction(TeamMember* teamMember, TeamMember::Action action); - public slots: - signals: + static QString name(); + static QString description(); + static QIcon icon(); + + Q_SCRIPTABLE virtual Sigencore::TeamMember::Action requestAction(Sigencore::TeamMember* teamMember) const; + Q_SCRIPTABLE virtual bool isTeamAllowed(Sigencore::Team* team); protected: - void setupBattle(); + virtual void handleAction(Sigencore::TeamMember* teamMember, Sigencore::TeamMember::Action action); + + virtual void setupBattle(); + + virtual void distributeWinnings(); + virtual void checkForLosers(); + + Kross::ActionCollection* m_priorityScripts; protected slots: void processActions(); - void cleanUp(); + + virtual void registerScript(const Sigcore::Script& script); + + virtual void cleanUp(); private: ActionQueue m_decisions; ATBTimer* m_atbTimer; QTimer* m_processTicker; }; -} #endif |