diff options
author | Ben Boeckel <MathStuf@gmail.com> | 2009-04-09 16:03:28 -0400 |
---|---|---|
committer | Ben Boeckel <MathStuf@gmail.com> | 2009-04-09 16:03:28 -0400 |
commit | cb839e58e268c125fd3e6dd704370b4d0bde3cf8 (patch) | |
tree | 83bf15737450bf2c5a00ae392092d77c347321db /sigencore/plugins | |
parent | ce9e1a24c5ae67abbee16d02a43e42903ad644af (diff) | |
download | sigen-cb839e58e268c125fd3e6dd704370b4d0bde3cf8.tar.gz sigen-cb839e58e268c125fd3e6dd704370b4d0bde3cf8.tar.xz sigen-cb839e58e268c125fd3e6dd704370b4d0bde3cf8.zip |
Move the plugins out of sigencore
Diffstat (limited to 'sigencore/plugins')
19 files changed, 0 insertions, 1169 deletions
diff --git a/sigencore/plugins/CMakeLists.txt b/sigencore/plugins/CMakeLists.txt index 0ab6e649..a5faff9b 100644 --- a/sigencore/plugins/CMakeLists.txt +++ b/sigencore/plugins/CMakeLists.txt @@ -35,9 +35,6 @@ target_link_libraries(sigencoreplugins LINK_INTERFACE_LIBRARIES sigencore ) -add_subdirectory(arenas) -add_subdirectory(canvases) - install( TARGETS sigencoreplugins diff --git a/sigencore/plugins/arenas/CMakeLists.txt b/sigencore/plugins/arenas/CMakeLists.txt deleted file mode 100644 index de972424..00000000 --- a/sigencore/plugins/arenas/CMakeLists.txt +++ /dev/null @@ -1,40 +0,0 @@ -project(sigenarenas) - -set(sigenarenas_SRCS - SigenArenas.cpp - atb/ActionMap.cpp - atb/ATBArena.cpp - atb/ATBTimer.cpp - standard/TurnArena.cpp -) -set(sigenarenas_SERVICES - sigen_arenas.desktop -) - -kde4_add_plugin(arena_sigen - ${sigenarenas_SRCS} -) -target_link_libraries(arena_sigen - ${QT_QTCORE_LIBRARY} - ${KDE4_KDEUI_LIBRARY} - ${KDE4_KROSSCORE_LIBRARY} - sigencoreplugins -) - -install( - TARGETS - arena_sigen - DESTINATION - ${PLUGIN_INSTALL_DIR} - COMPONENT - plugins -) - -install( - FILES - ${sigenarenas_SERVICES} - DESTINATION - ${SERVICES_INSTALL_DIR} - COMPONENT - plugins -) diff --git a/sigencore/plugins/arenas/SigenArenas.cpp b/sigencore/plugins/arenas/SigenArenas.cpp deleted file mode 100644 index faf3f848..00000000 --- a/sigencore/plugins/arenas/SigenArenas.cpp +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -// Header include -#include "SigenArenas.h" - -// Arena includes -#include "standard/TurnArena.h" -#include "atb/ATBArena.h" - -// Sigencore includes -#include <sigencore/Arena.h> - -// KDE includes -#include <KIcon> - -SIGEN_ARENA_PLUGIN_VERSION(SigenArenas, "sigen_arenas", 000101) - -using namespace Sigscript; -using namespace Sigencore; -using namespace Sigencore::Plugins; - -SigenArenas::SigenArenas(QObject* parent, const QVariantList& args) : - ArenaPlugin(parent, args) -{ -} - -SigenArenas::~SigenArenas() -{ -} - -QStringList SigenArenas::classList() const -{ - return QStringList() << TurnArena::name() << ATBArena::name(); -} - -QString SigenArenas::description(const QString& name) const -{ - if (name == TurnArena::name()) - return TurnArena::description(); - if (name == ATBArena::name()) - return ATBArena::description(); - return "(Unknown arena)"; -} - -QIcon SigenArenas::icon(const QString& name) -{ - if (name == TurnArena::name()) - return TurnArena::icon(); - if (name == ATBArena::name()) - return ATBArena::icon(); - return KIcon(); -} - -Arena* SigenArenas::createArena(const QString& name, GameWrapper* game, Config* parent) -{ - if (name == TurnArena::name()) - return new TurnArena(game, parent); - if (name == ATBArena::name()) - return new ATBArena(game, parent); - return NULL; -} - -void SigenArenas::cleanupArena(Arena* arena) -{ - TurnArena* turnArena = qobject_cast<TurnArena*>(arena); - if (turnArena) - { - delete turnArena; - return; - } - ATBArena* atbArena = qobject_cast<ATBArena*>(arena); - if (atbArena) - { - delete atbArena; - return; - } -} diff --git a/sigencore/plugins/arenas/SigenArenas.h b/sigencore/plugins/arenas/SigenArenas.h deleted file mode 100644 index 14ce15c8..00000000 --- a/sigencore/plugins/arenas/SigenArenas.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef SIGENARENAS_SIGENARENAS -#define SIGENARENAS_SIGENARENAS - -// Sigencore plugin includes -#include <sigencore/plugins/ArenaPlugin.h> - -class SigenArenas : public Sigencore::Plugins::ArenaPlugin -{ - Q_OBJECT - - public: - SigenArenas(QObject* parent, const QVariantList& args); - ~SigenArenas(); - - QStringList classList() const; - QString description(const QString& name) const; - QIcon icon(const QString& name); - protected: - Sigencore::Arena* createArena(const QString& name, Sigscript::GameWrapper* game, Sigscript::Config* parent); - protected slots: - void cleanupArena(Sigencore::Arena* arena); -}; - -#endif diff --git a/sigencore/plugins/arenas/atb/ATBArena.cpp b/sigencore/plugins/arenas/atb/ATBArena.cpp deleted file mode 100644 index 21fd1914..00000000 --- a/sigencore/plugins/arenas/atb/ATBArena.cpp +++ /dev/null @@ -1,90 +0,0 @@ -/* - * 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -// Header includes -#include "ATBArena.h" - -// Sigbattle includes -#include "ATBTimer.h" - -// KDE includes -#include <KIcon> - -// Qt includes -#include <QtCore/QTimer> -#include <QtGui/QIcon> - -using namespace Sigscript; -using namespace Sigencore; - -ATBArena::ATBArena(GameWrapper* sigmod, Config* parent) : - Arena(sigmod, parent), - m_atbTimer(new ATBTimer(this, m_decisions)) -{ - connect(m_atbTimer, SIGNAL(actionReady(Sigencore::TeamMember*)), this, SLOT(processAction(Sigencore::TeamMember*))); - setupBattle(); -} - -ATBArena::~ATBArena() -{ -} - -QString ATBArena::name() -{ - return "Sigen ATB Arena"; -} - -QString ATBArena::description() -{ - return "An arena where creatures have an action bar which when filled, can act"; -} - -QIcon ATBArena::icon() -{ - // TODO - return KIcon(); -} - -void ATBArena::handleAction(TeamMember* teamMember, TeamMember::Action action) -{ - if ((action.first == TeamMember::Invalid) || (action.first == TeamMember::Timeout)) - return; - Arena::handleAction(teamMember, action); -} - -bool ATBArena::isTeamAllowed(Sigencore::Team* team) -{ - Q_UNUSED(team) - // TODO: Use rules format here? - return true; -} - -void ATBArena::setupBattle() -{ - Arena::setupBattle(); -} - -void ATBArena::processAction(TeamMember* teamMember) -{ - handleAction(teamMember, m_decisions[teamMember].second); - m_decisions.remove(teamMember); -} - -void ATBArena::cleanUp() -{ - Arena::cleanUp(); -} diff --git a/sigencore/plugins/arenas/atb/ATBArena.h b/sigencore/plugins/arenas/atb/ATBArena.h deleted file mode 100644 index 7e6e5b08..00000000 --- a/sigencore/plugins/arenas/atb/ATBArena.h +++ /dev/null @@ -1,59 +0,0 @@ -/* - * 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef SIGENARENAS_ATBARENA -#define SIGENARENAS_ATBARENA - -// ATB includes -#include "ActionMap.h" - -// Sigencore includes -#include <sigencore/Arena.h> - -// Forward declaraions -class QTimer; -class ATBTimer; - -class ATBArena : public Sigencore::Arena -{ - Q_OBJECT - - public: - ATBArena(Sigscript::GameWrapper* game, Sigscript::Config* parent); - ~ATBArena(); - - static QString name(); - static QString description(); - static QIcon icon(); - protected: - virtual void handleAction(Sigencore::TeamMember* teamMember, Sigencore::TeamMember::Action action); - - virtual bool isTeamAllowed(Sigencore::Team* team); - - virtual void setupBattle(); - - Kross::ActionCollection* m_priorityScripts; - protected slots: - void processAction(Sigencore::TeamMember* teamMember); - - virtual void cleanUp(); - private: - ActionMap m_decisions; - ATBTimer* m_atbTimer; -}; - -#endif diff --git a/sigencore/plugins/arenas/atb/ATBTimer.cpp b/sigencore/plugins/arenas/atb/ATBTimer.cpp deleted file mode 100644 index adb2a853..00000000 --- a/sigencore/plugins/arenas/atb/ATBTimer.cpp +++ /dev/null @@ -1,103 +0,0 @@ -/* - * 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -// Header include -#include "ATBTimer.h" - -// ATB includes -#include "ActionMap.h" -#include "ATBArena.h" - -// Sigscript includes -#include <sigscript/GameWrapper.h> -#include <sigscript/RulesWrapper.h> - -// Qt includes -#include <QtCore/QtConcurrentFilter> -#include <QtCore/QFuture> -#include <QtCore/QSignalMapper> -#include <QtCore/QTimerEvent> - -using namespace Sigencore; - -struct ATBTimer::TimerIncrementFunctor -{ - TimerIncrementFunctor(ATBTimer* timer) : - m_timer(timer) - { - } - - typedef bool result_type; - - bool operator()(TeamMember* teamMember) - { - double factor = .1; - m_timer->m_arena->valueOfType("meter-factor", &factor); - if (!m_timer->m_actions.contains(teamMember)) - { - m_timer->m_timers[teamMember] += teamMember->statValue(Sigmod::ST_Speed) * factor; - int threshold = 1000; - m_timer->m_arena->valueOfType("meter-threshold", &threshold); - if (threshold <= m_timer->m_timers[teamMember]) - { - QFutureWatcher<TeamMember::Action>* watcher = new QFutureWatcher<TeamMember::Action>(m_timer); - TeamMember::RequestedAction action = requestDecision(teamMember); - watcher->setFuture(action.second); - m_timer->connect(watcher, SIGNAL(finished()), m_timer->m_actionMapper, SLOT(map())); - m_timer->connect(watcher, SIGNAL(finished()), SLOT(deleteLater())); - m_timer->m_actionMapper->setMapping(watcher, teamMember); - m_timer->m_actions.set(teamMember, action); - } - } - return false; - } - - ATBTimer* m_timer; -}; - -ATBTimer::ATBTimer(ATBArena* arena, ActionMap& actions) : - QThread(arena), - m_arena(arena), - m_actionMapper(new QSignalMapper(this)), - m_actions(actions) -{ - connect(m_actionMapper, SIGNAL(mapped(QObject*)), this, SLOT(actionReceived(QObject*))); -} - -ATBTimer::~ATBTimer() -{ -} - -void ATBTimer::run() -{ - startTimer(50); - exec(); -} - -void ATBTimer::timerEvent(QTimerEvent* event) -{ - Q_UNUSED(event) - const QList<TeamMember*> active = m_arena->active(Arena::Fighters); - QtConcurrent::blockingFiltered(active, TimerIncrementFunctor(this)); -} - -void ATBTimer::actionReceived(QObject* object) -{ - TeamMember* teamMember = qobject_cast<TeamMember*>(object); - if (teamMember) - emit(actionReady(teamMember)); -} diff --git a/sigencore/plugins/arenas/atb/ATBTimer.h b/sigencore/plugins/arenas/atb/ATBTimer.h deleted file mode 100644 index 113d7669..00000000 --- a/sigencore/plugins/arenas/atb/ATBTimer.h +++ /dev/null @@ -1,58 +0,0 @@ -/* - * 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef SIGENARENAS_ATBTIMER -#define SIGENARENAS_ATBTIMER - -// Sigencore includes -#include <sigencore/TeamMember.h> - -// Qt includes -#include <QtCore/QFutureWatcher> -#include <QtCore/QMap> -#include <QtCore/QThread> - -// Forward declarations -class QSignalMapper; -class ActionMap; -class ATBArena; - -class ATBTimer : public QThread -{ - Q_OBJECT - - public: - ATBTimer(ATBArena* arena, ActionMap& actions); - ~ATBTimer(); - signals: - void actionReady(Sigencore::TeamMember* teamMember); - protected: - void run(); - - void timerEvent(QTimerEvent* event); - protected slots: - void actionReceived(QObject* object); - private: - struct TimerIncrementFunctor; - - ATBArena* m_arena; - QSignalMapper* m_actionMapper; - QMap<Sigencore::TeamMember*, int> m_timers; - ActionMap& m_actions; -}; - -#endif diff --git a/sigencore/plugins/arenas/atb/ActionMap.cpp b/sigencore/plugins/arenas/atb/ActionMap.cpp deleted file mode 100644 index c5ad49a2..00000000 --- a/sigencore/plugins/arenas/atb/ActionMap.cpp +++ /dev/null @@ -1,55 +0,0 @@ -/* - * 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -// Header include -#include "ActionMap.h" - -// Qt includes -#include <QtCore/QReadLocker> -#include <QtCore/QWriteLocker> - -using namespace Sigencore; - -bool ActionMap::contains(TeamMember* teamMember) const -{ - QReadLocker locker(&m_mutex); - return m_map.contains(teamMember); -} - -int ActionMap::remove(TeamMember* teamMember) -{ - QWriteLocker locker(&m_mutex); - return m_map.remove(teamMember); -} - -bool ActionMap::isEmpty() const -{ - QReadLocker locker(&m_mutex); - return m_map.isEmpty(); -} - -void ActionMap::set(TeamMember* teamMember, const TeamMember::RequestedAction& action) -{ - QWriteLocker locker(&m_mutex); - m_map[teamMember] = action; -} - -const TeamMember::RequestedAction ActionMap::operator[](TeamMember* teamMember) const -{ - QReadLocker locker(&m_mutex); - return m_map[teamMember]; -} diff --git a/sigencore/plugins/arenas/atb/ActionMap.h b/sigencore/plugins/arenas/atb/ActionMap.h deleted file mode 100644 index 7c65a97e..00000000 --- a/sigencore/plugins/arenas/atb/ActionMap.h +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef SIGENARENAS_ACTIONMAP -#define SIGENARENAS_ACTIONMAP - -// Sigencore includes -#include <sigencore/TeamMember.h> - -// Qt includes -#include <QtCore/QMap> -#include <QtCore/QReadWriteLock> - -class ActionMap -{ - public: - bool contains(Sigencore::TeamMember* teamMember) const; - int remove(Sigencore::TeamMember* teamMember); - - bool isEmpty() const; - - void set(Sigencore::TeamMember* teamMember, const Sigencore::TeamMember::RequestedAction& action); - - const Sigencore::TeamMember::RequestedAction operator[](Sigencore::TeamMember* teamMember) const; - private: - QMap<Sigencore::TeamMember*, Sigencore::TeamMember::RequestedAction> m_map; - mutable QReadWriteLock m_mutex; -}; - -#endif diff --git a/sigencore/plugins/arenas/sigen_arenas.desktop b/sigencore/plugins/arenas/sigen_arenas.desktop deleted file mode 100644 index e4f659c7..00000000 --- a/sigencore/plugins/arenas/sigen_arenas.desktop +++ /dev/null @@ -1,16 +0,0 @@ -[Desktop Entry] -Type=Service -X-KDE-ServiceTypes=Sigen/Arena -Icon=sigen-arenaplugin -Name=Sigen Arenas -X-Sigen-MinVersion=000101 -X-KDE-Library=arena_sigen -X-KDE-PluginInfo-Author=Ben Boeckel -X-KDE-PluginInfo-Email=MathStuf@gmail.com -X-KDE-PluginInfo-Name=sigen_arenas -X-KDE-PluginInfo-Version=0.1.1 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Category=arena -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPLv3 -X-KDE-PluginInfo-EnabledByDefault=true diff --git a/sigencore/plugins/arenas/standard/TurnArena.cpp b/sigencore/plugins/arenas/standard/TurnArena.cpp deleted file mode 100644 index 233e512f..00000000 --- a/sigencore/plugins/arenas/standard/TurnArena.cpp +++ /dev/null @@ -1,160 +0,0 @@ -/* - * 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -// Header include -#include "TurnArena.h" - -// Sigencore includes -#include <sigencore/Player.h> -#include <sigencore/RunScript.h> -#include <sigencore/Team.h> - -// Sigscript includes -#include <sigscript/GameWrapper.h> -#include <sigscript/MoveWrapper.h> - -// KDE includes -#include <KIcon> -#include <kross/core/actioncollection.h> - -// Qt includes -#include <QtAlgorithms> -#include <QtCore/QtConcurrentMap> -#include <QtCore/QFuture> -#include <QtGui/QIcon> - -using namespace Sigcore; -using namespace Sigscript; -using namespace Sigencore; - -bool sortActions(const TeamMember::RequestedAction& reqAction1, const TeamMember::RequestedAction& reqAction2) -{ - TeamMember::Action action1 = reqAction1.second.isCanceled() ? TeamMember::Action(TeamMember::Timeout, TeamMember::ActionData()) : reqAction1.second; - TeamMember::Action action2 = reqAction2.second.isCanceled() ? TeamMember::Action(TeamMember::Timeout, TeamMember::ActionData()) : reqAction2.second; - const int priority1 = actionPriority(reqAction1.first, action1); - const int priority2 = actionPriority(reqAction1.first, action2); - if (priority1 < priority2) - return true; - else if (priority1 == priority2) - { - const int speed1 = reqAction1.first->statValue(Sigmod::ST_Speed); - const int speed2 = reqAction2.first->statValue(Sigmod::ST_Speed); - if (speed1 < speed2) - return true; - else if (speed1 == speed2) - return Sigcore::Fraction::poll(1, 2); - } - return false; -} - -TurnArena::TurnArena(GameWrapper* sigmod, Config* parent) : - Arena(sigmod, parent), - m_priorityScripts(new Kross::ActionCollection("priority-scripts", m_actions)) -{ - setupBattle(); -} - -QString TurnArena::name() -{ - return "Sigen turn arena"; -} - -QString TurnArena::description() -{ - return "An arena where creatures act in order of their speed (unless move priority takes precedence)"; -} - -QIcon TurnArena::icon() -{ - // TODO - return KIcon(); -} - -bool TurnArena::isTeamAllowed(Sigencore::Team* team) -{ - Q_UNUSED(team) - // TODO: Use rules format here? - return true; -} - -void TurnArena::handleAction(TeamMember* teamMember, TeamMember::Action action) -{ - Arena::handleAction(teamMember, action); -} - -void TurnArena::setupBattle() -{ - connect(this, SIGNAL(battleStarted()), SLOT(processRound())); - Arena::setupBattle(); -} - -void TurnArena::distributeWinnings() -{ - Arena::distributeWinnings(); -} - -void TurnArena::checkForLosers() -{ - Arena::checkForLosers(); -} - -void TurnArena::registerScript(const Script& script) -{ - Arena::registerScript(script); -} - -void TurnArena::cleanUp() -{ - Arena::cleanUp(); -} - -void TurnArena::processRound() -{ - emit(roundAboutToStart()); - emit(roundStarted()); - QFuture<TeamMember::RequestedAction> reqActions = QtConcurrent::mapped(active(Fighters), &requestDecision); - reqActions.waitForFinished(); - QList<TeamMember::RequestedAction> actions = reqActions.results(); - qStableSort(actions.begin(), actions.end(), sortActions); - foreach (const TeamMember::RequestedAction& reqAction, actions) - { - TeamMember::Action action = reqAction.second; - if (action.first == TeamMember::Attack) - { - MoveWrapper* move = m_game->move(action.second.first.toInt()); - const Script script = move->priorityScript(); - ObjectMap objects; - objects["arena"] = this; - objects["move"] = move; - objects["owner"] = reqAction.first; - objects["player"] = reqAction.first->team()->player(); - objects["sigmod"] = m_game; - // TODO: Add other players - runScript(QString("priority-%1").arg(QUuid::createUuid().toString()), script, objects, m_priorityScripts)->trigger(); - } - } - qStableSort(actions.begin(), actions.end(), sortActions); - foreach (const TeamMember::RequestedAction& action, actions) - { - if (action.first->currentHp()) - handleAction(action.first, action.second); - } - emit(roundAboutToEnd()); - emit(roundEnded()); - // TODO: Check if there is anyone left to fight - processRound(); -} diff --git a/sigencore/plugins/arenas/standard/TurnArena.h b/sigencore/plugins/arenas/standard/TurnArena.h deleted file mode 100644 index 9dce6ea3..00000000 --- a/sigencore/plugins/arenas/standard/TurnArena.h +++ /dev/null @@ -1,60 +0,0 @@ -/* - * 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef SIGENARENAS_TURNARENA -#define SIGENARENAS_TURNARENA - -// Sigencore includes -#include <sigencore/Arena.h> - -class TurnArena : public Sigencore::Arena -{ - Q_OBJECT - - public: - TurnArena(Sigscript::GameWrapper* game, Sigscript::Config* parent); - - static QString name(); - static QString description(); - static QIcon icon(); - signals: - void roundAboutToStart(); - void roundStarted(); - void roundEnded(); - void roundAboutToEnd(); - protected: - virtual void handleAction(Sigencore::TeamMember* teamMember, Sigencore::TeamMember::Action action); - - virtual bool isTeamAllowed(Sigencore::Team* team); - - virtual void setupBattle(); - - virtual void distributeWinnings(); - virtual void checkForLosers(); - - Kross::ActionCollection* m_priorityScripts; - protected slots: - void processRound(); - - virtual void registerScript(const Sigcore::Script& script); - - virtual void cleanUp(); -}; - -bool sortActions(const Sigencore::TeamMember::RequestedAction& reqAction1, const Sigencore::TeamMember::RequestedAction& reqAction2); - -#endif diff --git a/sigencore/plugins/canvases/CMakeLists.txt b/sigencore/plugins/canvases/CMakeLists.txt deleted file mode 100644 index 931659d4..00000000 --- a/sigencore/plugins/canvases/CMakeLists.txt +++ /dev/null @@ -1,38 +0,0 @@ -project(sigencanvases) - -set(sigencanvases_SRCS - SigenCanvases.cpp - qgraphicsscene/QGSCanvas.cpp -) -set(sigencanvases_SERVICES - sigen_canvases.desktop -) - -kde4_add_plugin(canvas_sigen - ${sigencanvases_SRCS} -) -target_link_libraries(canvas_sigen - ${QT_QTCORE_LIBRARY} - ${QT_QTGUI_LIBRARY} - ${KDE4_KDEUI_LIBRARY} - ${KDE4_KROSSCORE_LIBRARY} - sigencoreplugins -) - -install( - TARGETS - canvas_sigen - DESTINATION - ${PLUGIN_INSTALL_DIR} - COMPONENT - plugins -) - -install( - FILES - ${sigencanvases_SERVICES} - DESTINATION - ${SERVICES_INSTALL_DIR} - COMPONENT - plugins -) diff --git a/sigencore/plugins/canvases/SigenCanvases.cpp b/sigencore/plugins/canvases/SigenCanvases.cpp deleted file mode 100644 index 3969a56e..00000000 --- a/sigencore/plugins/canvases/SigenCanvases.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/* - * Copyright 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -// Header include -#include "SigenCanvases.h" - -// Canvas includes -#include "qgraphicsscene/QGSCanvas.h" - -// Sigencore includes -#include <sigencore/Canvas.h> - -// KDE includes -#include <KIcon> - -SIGEN_CANVAS_PLUGIN_VERSION(SigenCanvases, "sigen_canvases", 000101) - -using namespace Sigscript; -using namespace Sigencore; -using namespace Sigencore::Plugins; - -SigenCanvases::SigenCanvases(QObject* parent, const QVariantList& args) : - CanvasPlugin(parent, args) -{ -} - -SigenCanvases::~SigenCanvases() -{ -} - -QStringList SigenCanvases::classList() const -{ - return QStringList() << QGSCanvas::name(); -} - -QString SigenCanvases::description(const QString& name) const -{ - if (name == QGSCanvas::name()) - return QGSCanvas::description(); - return "(Unknown canvas)"; -} - -QIcon SigenCanvases::icon(const QString& name) -{ - if (name == QGSCanvas::name()) - return QGSCanvas::icon(); - return KIcon(); -} - -Canvas* SigenCanvases::createCanvas(const QString& name, GameWrapper* game, Config* parent) -{ - if (name == QGSCanvas::name()) - return new QGSCanvas(game, parent); - return NULL; -} - -void SigenCanvases::cleanupCanvas(Canvas* canvas) -{ - QGSCanvas* qgsCanvas = qobject_cast<QGSCanvas*>(canvas); - if (qgsCanvas) - { - delete qgsCanvas; - return; - } -} diff --git a/sigencore/plugins/canvases/SigenCanvases.h b/sigencore/plugins/canvases/SigenCanvases.h deleted file mode 100644 index 6e0eaf22..00000000 --- a/sigencore/plugins/canvases/SigenCanvases.h +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef SIGENCANVASES_SIGENCANVASES -#define SIGENCANVASES_SIGENCANVASES - -// Sigencore plugin includes -#include <sigencore/plugins/CanvasPlugin.h> - -class SigenCanvases : public Sigencore::Plugins::CanvasPlugin -{ - Q_OBJECT - - public: - SigenCanvases(QObject* parent, const QVariantList& args); - ~SigenCanvases(); - - QStringList classList() const; - QString description(const QString& name) const; - QIcon icon(const QString& name); - protected: - Sigencore::Canvas* createCanvas(const QString& name, Sigscript::GameWrapper* game, Sigscript::Config* parent); - protected slots: - void cleanupCanvas(Sigencore::Canvas* canvas); -}; - -#endif diff --git a/sigencore/plugins/canvases/qgraphicsscene/QGSCanvas.cpp b/sigencore/plugins/canvases/qgraphicsscene/QGSCanvas.cpp deleted file mode 100644 index 09f823b1..00000000 --- a/sigencore/plugins/canvases/qgraphicsscene/QGSCanvas.cpp +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -// Header include -#include "QGSCanvas.h" - -// Sigencore includes -#include <sigencore/RunScript.h> - -// Sigscript includes -#include <sigscript/GameWrapper.h> -#include <sigscript/SpriteWrapper.h> - -// KDE includes -#include <KIcon> -#include <kross/core/action.h> -#include <kross/core/actioncollection.h> -#include <kross/core/manager.h> - -// Qt includes -#include <QtCore/QUuid> -#include <QtGui/QGraphicsItem> -#include <QtGui/QGraphicsScene> -#include <QtGui/QGraphicsView> - -using namespace Sigscript; -using namespace Sigencore; - -QGSCanvas::QGSCanvas(GameWrapper* game, Config* parent) : - Canvas(parent), - m_game(game), - m_scene(new QGraphicsScene), - m_collection(new Kross::ActionCollection(QString("canvas-%1").arg(QUuid::createUuid().toString()), Kross::Manager::self().actionCollection())) -{ -} - -QGSCanvas::~QGSCanvas() -{ - delete m_scene; - delete m_collection; -} - -QString QGSCanvas::name() -{ - return "QGraphicsScene canvas"; -} - -QString QGSCanvas::description() -{ - return "A canvas using QGraphicsScene"; -} - -QIcon QGSCanvas::icon() -{ - return KIcon(); -} - -void QGSCanvas::addSprite(const QString& name, const QString& sprite, const int x, const int y, const int zOrder) -{ - // TODO: NOOP or refresh? - if (m_items.contains(name)) - return; - SpriteWrapper* spr = m_game->sprite(sprite); - if (spr) - { - QGraphicsPixmapItem* item = new QGraphicsPixmapItem(spr->sprite()); - item->setPos(x, y); - item->setZValue(zOrder); - m_scene->addItem(item); - m_items[name] = item; - } -} - -void QGSCanvas::removeSprite(const QString& name) -{ - if (m_items.contains(name)) - { - delete m_items[name]; - m_items.remove(name); - } -} - -void QGSCanvas::transform(const QString& transform, const QString& object, const QVariantList& parameters) -{ -} - -int QGSCanvas::type() const -{ - return QGraphicsSceneCanvas; -} - -QWidget* QGSCanvas::viewport() -{ - // TODO: Only one view allowed? or as many as wanted? - QGraphicsView* view = new QGraphicsView; - view->setScene(m_scene); - return view; -} diff --git a/sigencore/plugins/canvases/qgraphicsscene/QGSCanvas.h b/sigencore/plugins/canvases/qgraphicsscene/QGSCanvas.h deleted file mode 100644 index d779a3b3..00000000 --- a/sigencore/plugins/canvases/qgraphicsscene/QGSCanvas.h +++ /dev/null @@ -1,62 +0,0 @@ -/* - * Copyright 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 - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License along - * with this program. If not, see <http://www.gnu.org/licenses/>. - */ - -#ifndef SIGENCANVASES_QGSCANVAS -#define SIGENCANVASES_QGSCANVAS - -// Sigencore includes -#include <sigencore/Canvas.h> - -// Forward declarations -namespace Kross -{ -class ActionCollection; -} -class QGraphicsItem; -class QGraphicsScene; -namespace Sigscript -{ -class GameWrapper; -} - -class QGSCanvas : public Sigencore::Canvas -{ - Q_OBJECT - - public: - QGSCanvas(Sigscript::GameWrapper* game, Sigscript::Config* parent); - ~QGSCanvas(); - - static QString name(); - static QString description(); - static QIcon icon(); - - Q_SCRIPTABLE void addSprite(const QString& name, const QString& sprite, const int x, const int y, const int zOrder); - Q_SCRIPTABLE void removeSprite(const QString& name); - Q_SCRIPTABLE void transform(const QString& transform, const QString& object, const QVariantList& parameters); - - int type() const; - - QWidget* viewport(); - private: - Sigscript::GameWrapper* m_game; - QGraphicsScene* m_scene; - QMap<QString, QGraphicsItem*> m_items; - Kross::ActionCollection* m_collection; -}; - -#endif diff --git a/sigencore/plugins/canvases/sigen_canvases.desktop b/sigencore/plugins/canvases/sigen_canvases.desktop deleted file mode 100644 index 7731030c..00000000 --- a/sigencore/plugins/canvases/sigen_canvases.desktop +++ /dev/null @@ -1,16 +0,0 @@ -[Desktop Entry] -Type=Service -X-KDE-ServiceTypes=Sigen/Canvas -Icon=sigen-canvasplugin -Name=Sigen Canvases -X-Sigen-MinVersion=0.1.1 -X-KDE-Library=canvas_sigen -X-KDE-PluginInfo-Author=Ben Boeckel -X-KDE-PluginInfo-Email=MathStuf@gmail.com -X-KDE-PluginInfo-Name=sigen_canvas -X-KDE-PluginInfo-Version=0.1.1 -X-KDE-PluginInfo-Website= -X-KDE-PluginInfo-Category=canvas -X-KDE-PluginInfo-Depends= -X-KDE-PluginInfo-License=GPLv3 -X-KDE-PluginInfo-EnabledByDefault=true |