summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-09-07 00:43:01 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-09-07 00:43:01 +0000
commitfef5e045060aff28477751c4115d346a95425c0c (patch)
treebd17a801439274c13f3afbd50cbe7cf83b73ccc2
parent0b4b89cf8efdc15e5a8d4b6cb24a5c8a025227d9 (diff)
downloadsigen-fef5e045060aff28477751c4115d346a95425c0c.tar.gz
sigen-fef5e045060aff28477751c4115d346a95425c0c.tar.xz
sigen-fef5e045060aff28477751c4115d346a95425c0c.zip
[FIX] Fixed some things in the ATBTimer
[FIX] Fleshed out some methods git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@251 6ecfd1a5-f3ed-3746-8530-beee90d26b22
-rw-r--r--Changelog8
-rw-r--r--sigbattle/ATBTimer.cpp19
-rw-r--r--sigbattle/ATBTimer.h6
-rw-r--r--sigbattle/CMakeLists.txt4
-rw-r--r--sigbattle/Player.cpp22
-rw-r--r--sigbattle/Player.h2
-rw-r--r--sigbattle/TeamMember.cpp16
-rw-r--r--sigbattle/TeamMember.h7
-rw-r--r--sigmod/CMakeLists.txt4
-rw-r--r--sigmodr/Sigmodr.cpp1
-rw-r--r--sigmodr/sigmodr.tex52
-rw-r--r--sigscript/CMakeLists.txt4
12 files changed, 92 insertions, 53 deletions
diff --git a/Changelog b/Changelog
index 05110da2..25282951 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,12 @@
-----------------
+Rev: 251
+Date: 6 September 2008
+User: MathStuf
+-----------------
+[FIX] Fixed some things in the ATBTimer
+[FIX] Fleshed out some methods
+
+-----------------
Rev: 250
Date: 5 September 2008
User: MathStuf
diff --git a/sigbattle/ATBTimer.cpp b/sigbattle/ATBTimer.cpp
index 874c6fb8..ad00e2d3 100644
--- a/sigbattle/ATBTimer.cpp
+++ b/sigbattle/ATBTimer.cpp
@@ -22,6 +22,7 @@
#include "ATBArena.h"
// Qt includes
+#include <QtCore/QtAlgorithms>
#include <QtCore/QtConcurrentFilter>
#include <QtCore/QtConcurrentMap>
#include <QtCore/QFuture>
@@ -31,6 +32,11 @@
// STL includes
#include <functional>
+bool Sigbattle::compareTimers(TeamMember* const & member1, TeamMember* const & member2)
+{
+ return member1->timer() < member2->timer();
+}
+
Sigbattle::ATBTimer::ATBTimer(ATBArena* arena, ActionQueue& actions) :
QThread(arena),
m_arena(arena),
@@ -42,14 +48,11 @@ Sigbattle::ATBTimer::ATBTimer(ATBArena* arena, ActionQueue& actions) :
void Sigbattle::ATBTimer::update()
{
- const QList<TeamMember*> active = m_timeStates.keys();
+ const QList<TeamMember*> active = m_arena->active();
QtConcurrent::blockingMap(active, std::bind1st(std::mem_fun(&Sigbattle::ATBTimer::increaseMeter), this));
// TODO: adjust max time if needed
QList<TeamMember*> overflow = QtConcurrent::blockingFiltered(active, std::bind1st(std::mem_fun(&Sigbattle::ATBTimer::isOverflowed), this));
- QMultiMap<double, TeamMember*> sorter;
- foreach (TeamMember* teamMember, overflow)
- sorter.insert(m_timeStates[teamMember], teamMember);
- overflow = sorter.values();
+ qSort(overflow.begin(), overflow.end(), compareTimers);
foreach(TeamMember* teamMember, overflow)
m_actions.enqueue(requestDecision(teamMember));
}
@@ -60,13 +63,13 @@ void Sigbattle::ATBTimer::run()
exec();
}
-void Sigbattle::ATBTimer::increaseMeter(const TeamMember* teamMember)
+void Sigbattle::ATBTimer::increaseMeter(TeamMember* teamMember)
{
// TODO: tweak this(?)
- m_timeStates[const_cast<TeamMember*>(teamMember)] += teamMember->statValue(Sigmod::ST_Speed) / 10;
+ teamMember->advanceTimer(teamMember->statValue(Sigmod::ST_Speed) / 10);
}
bool Sigbattle::ATBTimer::isOverflowed(const TeamMember* teamMember) const
{
- return m_threshold < m_timeStates[const_cast<TeamMember*>(teamMember)];
+ return m_threshold < teamMember->timer();
}
diff --git a/sigbattle/ATBTimer.h b/sigbattle/ATBTimer.h
index ed0edd43..7917d011 100644
--- a/sigbattle/ATBTimer.h
+++ b/sigbattle/ATBTimer.h
@@ -22,7 +22,6 @@
#include "Global.h"
// Qt includes
-#include <QtCore/QMap>
#include <QtCore/QThread>
// Forward declarations
@@ -46,16 +45,17 @@ class SIGBATTLE_EXPORT ATBTimer : public QThread
protected:
void run();
private:
- void increaseMeter(const TeamMember* teamMember);
+ void increaseMeter(TeamMember* teamMember);
bool isOverflowed(const TeamMember* teamMember) const;
ATBArena* m_arena;
ActionQueue& m_actions;
- QMap<TeamMember*, double> m_timeStates;
double m_threshold;
QTimer* m_timer;
};
+bool compareTimers(TeamMember* const & member1, TeamMember* const & member2);
+
}
#endif
diff --git a/sigbattle/CMakeLists.txt b/sigbattle/CMakeLists.txt
index 5b16acd7..c2ec1145 100644
--- a/sigbattle/CMakeLists.txt
+++ b/sigbattle/CMakeLists.txt
@@ -45,8 +45,8 @@ ADD_LIBRARY(sigbattle
)
SET_TARGET_PROPERTIES(sigbattle
PROPERTIES
- VERSION ${POKEGEN_VERSION}
- SOVERSION ${POKEGEN_SOVERSION}
+ VERSION ${SIGEN_VERSION}
+ SOVERSION ${SIGEN_SOVERSION}
LINK_INTERFACE_LIBRARIES ""
)
TARGET_LINK_LIBRARIES(sigbattle
diff --git a/sigbattle/Player.cpp b/sigbattle/Player.cpp
index 20737775..48ca5b24 100644
--- a/sigbattle/Player.cpp
+++ b/sigbattle/Player.cpp
@@ -18,6 +18,10 @@
// Header include
#include "Player.h"
+// Sigmod includes
+#include "../sigscript/RulesWrapper.h"
+#include "../sigscript/SigmodWrapper.h"
+
Sigbattle::Player::Player(QObject* parent) :
Team(parent),
m_arena(NULL)
@@ -26,16 +30,26 @@ Sigbattle::Player::Player(QObject* parent) :
void Sigbattle::Player::enterArena(Arena* arena)
{
- // TODO: Get a list of the active members
- // TODO: Let them know that they are active
+ QList<TeamMember*> activeMembers = active();
+ foreach (TeamMember* member, activeMembers)
+ member->makeActive(arena);
}
QList<Sigbattle::TeamMember*> Sigbattle::Player::active()
{
- // TODO: return active members
+ // TODO: There are edge cases not considered here
+ QList<TeamMember*> activeMembers;
+ for (int i = 0; (i < sigmod()->rules()->maxFight()) && (i < m_members.size()); ++i)
+ {
+ if (m_members[i]->currentHp())
+ activeMembers.append(m_members[i]);
+ }
+ return activeMembers;
}
void Sigbattle::Player::exitArena()
{
- // TODO: Tell all active members that they can leave now
+ QList<TeamMember*> activeMembers = active();
+ foreach (TeamMember* member, activeMembers)
+ member->leaveArena();
}
diff --git a/sigbattle/Player.h b/sigbattle/Player.h
index 765c0263..50f2842b 100644
--- a/sigbattle/Player.h
+++ b/sigbattle/Player.h
@@ -46,8 +46,6 @@ class SIGBATTLE_EXPORT Player : public Team
void enterArena(Arena* arena);
QList<TeamMember*> active();
-
- const Sigmod::Sigmod* sigmod() const;
signals:
public slots:
void exitArena();
diff --git a/sigbattle/TeamMember.cpp b/sigbattle/TeamMember.cpp
index 1fa0843c..ef26edca 100644
--- a/sigbattle/TeamMember.cpp
+++ b/sigbattle/TeamMember.cpp
@@ -306,6 +306,11 @@ bool Sigbattle::TeamMember::canLearnMove(Sigscript::MoveWrapper* move) const
return false;
}
+long long Sigbattle::TeamMember::timer() const
+{
+ return m_timer;
+}
+
void Sigbattle::TeamMember::boostLevels(const int levels)
{
if ((m_level + levels) < sigmod()->rules()->maxLevel())
@@ -499,6 +504,7 @@ Sigbattle::TeamMember::Action Sigbattle::TeamMember::requestAction() const
void Sigbattle::TeamMember::makeActive(Arena* arena)
{
+ // TODO: not everything is done here...
QList<Sigscript::StatusWrapper*> statuses = m_status.uniqueKeys();
foreach (Sigscript::StatusWrapper* status, statuses)
{
@@ -525,6 +531,16 @@ void Sigbattle::TeamMember::makeActive(Arena* arena)
}
}
+void Sigbattle::TeamMember::leaveArena()
+{
+ // TODO: leave the arena
+}
+
+void Sigbattle::TeamMember::advanceTimer(const long long jump)
+{
+ m_timer += jump;
+}
+
void Sigbattle::TeamMember::writeBack()
{
// TODO: write back all (applicable) differences between config and local storage
diff --git a/sigbattle/TeamMember.h b/sigbattle/TeamMember.h
index 84e441d0..b6455cbb 100644
--- a/sigbattle/TeamMember.h
+++ b/sigbattle/TeamMember.h
@@ -106,6 +106,8 @@ class SIGBATTLE_EXPORT TeamMember : public Sigscript::Config
bool canLearnMove(Sigscript::MoveWrapper* move) const;
+ long long timer() const;
+
Sigscript::SigmodWrapper* sigmod() const;
signals:
void speciesChanged(Sigscript::SpeciesWrapper* species);
@@ -153,6 +155,9 @@ class SIGBATTLE_EXPORT TeamMember : public Sigscript::Config
Action requestAction() const;
void makeActive(Arena* arena);
+ void leaveArena();
+
+ void advanceTimer(const long long jump);
virtual void writeBack();
protected slots:
@@ -179,6 +184,8 @@ class SIGBATTLE_EXPORT TeamMember : public Sigscript::Config
QList<Sigscript::MoveWrapper*> m_moves;
QList<Sigscript::NatureWrapper*> m_natures;
+ long long m_timer;
+
QList<Kross::Action*> m_abilityBattleScripts;
QList<Kross::Action*> m_statusBattleScripts;
private:
diff --git a/sigmod/CMakeLists.txt b/sigmod/CMakeLists.txt
index b8eee63c..674508fd 100644
--- a/sigmod/CMakeLists.txt
+++ b/sigmod/CMakeLists.txt
@@ -101,8 +101,8 @@ ADD_LIBRARY(sigmod
)
SET_TARGET_PROPERTIES(sigmod
PROPERTIES
- VERSION ${POKEGEN_VERSION}
- SOVERSION ${POKEGEN_SOVERSION}
+ VERSION ${SIGEN_VERSION}
+ SOVERSION ${SIGEN_SOVERSION}
LINK_INTERFACE_LIBRARIES ""
)
TARGET_LINK_LIBRARIES(sigmod
diff --git a/sigmodr/Sigmodr.cpp b/sigmodr/Sigmodr.cpp
index a17a062e..4530b3d0 100644
--- a/sigmodr/Sigmodr.cpp
+++ b/sigmodr/Sigmodr.cpp
@@ -71,6 +71,5 @@ int main(int argc, char* argv[])
Sigmodr::SigmodrUI* mainWindow = new Sigmodr::SigmodrUI;
mainWindow->show();
app->exec();
- delete mainWindow;
return 0;
}
diff --git a/sigmodr/sigmodr.tex b/sigmodr/sigmodr.tex
index 0b1331f8..9d266ec0 100644
--- a/sigmodr/sigmodr.tex
+++ b/sigmodr/sigmodr.tex
@@ -145,15 +145,6 @@
#1%
}}{}
-\lstnewenvironment{smoke}[1][]{%
-\lstset{%
-% language=Smoke,%
- emph={},%
- emph={[2]true,false,nil,self,sender},%
- emph={[3]import,load,export},%
- #1%
-}}{}
-
\lstnewenvironment{c-sharp}[1][]{%
\lstset{%
language=CSharp,%
@@ -170,7 +161,10 @@
\tableofcontents
\newpage
-\chapter{Pok\'emod Classes}
+\chapter{What is Sigmodr?}
+
+
+\chapter{Sigmod Classes}
\label{pokemod-classes}
\section{Ability}
@@ -243,25 +237,25 @@ These examples are not guaranteed to work until an API has been made for the gam
This script will change the user's first type depending on the type of the last move used. Since types do not persist outside of the battle, the type only needs to be reset when the owner of the ability switches out or faints.
\begin{python}[caption={Type changer},label=script:type-changer]
-import pokemod # Data from the Pokemod
-import user # The owner of the ability
+import sigmod # Data from the Sigmod
+import owner # The owner of the ability
# Get the first type of the user
-originalType = user.type(0)
+originalType = owner.type(0)
# Set the type requested
-ghost = pokemod.type("Ghost")
+ghost = sigmod.type("Ghost")
def setType():
# Set the type
- user.setType(0, ghost)
+ owner.setType(0, ghost)
def retreat():
# Reset the type
- user.setType(0, originalType)
+ owner.setType(0, originalType)
-user.connect("sentOut()", setType)
-user.connect("switch()", retreat)
-user.connect("faint()", retreat)
+owner.connect("sentOut()", setType)
+owner.connect("switch()", retreat)
+owner.connect("faint()", retreat)
\end{python}
\subsubsection{Changing the weather}
@@ -269,13 +263,13 @@ user.connect("faint()", retreat)
This script will force the weather to be rainy all the time. Other weather effects can be in effect from the time it works until the beginning of the next turn where this ability will kick in and make it rain again.
\begin{python}[caption={Weather changer},label=script:weather-changer]
-import arena # The battle system
-import client # Used for messaging
-import pokemod # Data from the Pokemod
-import user # The owner of the ability
+import arena # The battle system
+import client # Used for messaging
+import sigmod # Data from the Sigmod
+import owne # The owner of the ability
# Get the handle for the "Rain" weather
-rain = pokemod.weather("Rain")
+rain = sigmod.weather("Rain")
# Local variable to keep track of when to force the weather
needChanging = False
@@ -306,20 +300,20 @@ def retreat():
# no longer in the battle, set the rain to stop
if arena.weather() == rain:
arena.setWeatherDuration() = 2
- client.message("The sky is clearing!")
+ client.message("The skies are clearing!")
# Connect signals from the arena
arena.connect("roundStart()", roundStart)
# Connect signals from the owner
-user.connect("sentOut()", sentOut)
-user.connect("switch()", retreat)
-user.connect("faint()", retreat)
+owner.connect("sentOut()", sentOut)
+owner.connect("switch()", retreat)
+owner.connect("faint()", retreat)
\end{python}
\section{Author}
\label{author}
-This is where the authors of the Pok\'eMod go. This class could be expanded to allow for something more detialed to allow the creation of credits, but it is simple for now.
+This is where the authors of the Sigmod go. This class could be expanded to allow for something more detialed to allow the creation of credits, but it is simple for now.
\subsection{Variables}
\label{author-variables}
diff --git a/sigscript/CMakeLists.txt b/sigscript/CMakeLists.txt
index 5d32b6fd..6f0bc07f 100644
--- a/sigscript/CMakeLists.txt
+++ b/sigscript/CMakeLists.txt
@@ -96,8 +96,8 @@ ADD_LIBRARY(sigscript
)
SET_TARGET_PROPERTIES(sigscript
PROPERTIES
- VERSION ${POKEGEN_VERSION}
- SOVERSION ${POKEGEN_SOVERSION}
+ VERSION ${SIGEN_VERSION}
+ SOVERSION ${SIGEN_SOVERSION}
LINK_INTERFACE_LIBRARIES ""
)
TARGET_LINK_LIBRARIES(sigscript