summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-06-30 01:37:51 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-06-30 01:37:51 +0000
commita423cf3db8fa90cc09d2f92ff892e4fcdda4af16 (patch)
tree174b821adc5e089a313657499e0df740d7184fca
parent300e44b68e075d7fd78287e10262b0d502f4898d (diff)
downloadsigen-a423cf3db8fa90cc09d2f92ff892e4fcdda4af16.tar.gz
sigen-a423cf3db8fa90cc09d2f92ff892e4fcdda4af16.tar.xz
sigen-a423cf3db8fa90cc09d2f92ff892e4fcdda4af16.zip
[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
-rw-r--r--Changelog12
-rw-r--r--pokebattle/ATBArena.h42
-rw-r--r--pokebattle/Arena.cpp39
-rw-r--r--pokebattle/Arena.h40
-rw-r--r--pokebattle/CMakeLists.txt4
-rw-r--r--pokebattle/Containment.h58
-rw-r--r--pokebattle/TODO1
-rw-r--r--pokebattle/Team.h24
-rw-r--r--pokebattle/TeamMember.cpp286
-rw-r--r--pokebattle/TeamMember.h35
-rw-r--r--pokebattle/TurnArena.cpp26
-rw-r--r--pokebattle/TurnArena.h45
-rw-r--r--pokemod/Ability.cpp14
-rw-r--r--pokemod/Ability.h3
-rw-r--r--pokemod/CMakeLists.txt1
-rw-r--r--pokemod/Hat.h11
-rw-r--r--pokemod/Macros.h10
-rw-r--r--pokemod/Map.cpp2
-rw-r--r--pokemod/Map.h2
-rw-r--r--pokemod/MapEffect.cpp8
-rw-r--r--pokemod/MapEffect.h8
-rw-r--r--pokemod/MapTrainer.cpp8
-rw-r--r--pokemod/MapTrainer.h8
-rw-r--r--pokemod/MapWarp.cpp8
-rw-r--r--pokemod/MapWarp.h10
-rw-r--r--pokemod/Matrix.h16
-rw-r--r--pokemod/Move.cpp15
-rw-r--r--pokemod/Move.h1
-rw-r--r--pokemod/Nature.cpp10
-rw-r--r--pokemod/Nature.h2
-rw-r--r--pokemod/Point.h104
-rw-r--r--pokemod/Pokemod.h1
-rw-r--r--pokemod/Rules.cpp14
-rw-r--r--pokemod/Rules.h3
-rw-r--r--pokemodr/AbilityUI.cpp6
-rw-r--r--pokemodr/AbilityUI.h1
-rw-r--r--pokemodr/MapEffectUI.cpp2
-rw-r--r--pokemodr/MapEffectUI.h2
-rw-r--r--pokemodr/MapTrainerUI.cpp2
-rw-r--r--pokemodr/MapTrainerUI.h2
-rw-r--r--pokemodr/MapWarpUI.cpp2
-rw-r--r--pokemodr/MapWarpUI.h2
-rw-r--r--pokemodr/MoveUI.cpp6
-rw-r--r--pokemodr/MoveUI.h1
-rw-r--r--pokemodr/NatureUI.cpp3
-rw-r--r--pokemodr/PointWidget.cpp14
-rw-r--r--pokemodr/PointWidget.h16
-rw-r--r--pokemodr/RulesUI.cpp6
-rw-r--r--pokemodr/RulesUI.h1
-rw-r--r--pokemodr/gui/ability.ui21
-rw-r--r--pokemodr/gui/fraction.ui40
-rw-r--r--pokemodr/gui/map.ui64
-rw-r--r--pokemodr/gui/move.ui16
-rw-r--r--pokemodr/gui/point.ui2
-rw-r--r--pokemodr/gui/rules.ui13
55 files changed, 711 insertions, 382 deletions
diff --git a/Changelog b/Changelog
index 31ae8805..49b2e526 100644
--- a/Changelog
+++ b/Changelog
@@ -1,4 +1,16 @@
-----------------
+Rev: 217
+Date: 29 June 2008
+User: MathStuf
+-----------------
+[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
+
+-----------------
Rev: 216
Date: 28 June 2008
User: MathStuf
diff --git a/pokebattle/ATBArena.h b/pokebattle/ATBArena.h
new file mode 100644
index 00000000..4ec4a6fc
--- /dev/null
+++ b/pokebattle/ATBArena.h
@@ -0,0 +1,42 @@
+/*
+ * Copyright 2008 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 __POKEBATTLE_ATBARENA__
+#define __POKEBATTLE_ATBARENA__
+
+// Pokebattle includes
+#include "Arena.h"
+
+// Qt includes
+#include <QtCore/QQueue>
+
+namespace Pokebattle
+{
+class POKEBATTLE_EXPORT ATBArena : public Arena
+{
+ Q_OBJECT
+
+ public:
+ signals:
+ public slots:
+ protected slots:
+ private:
+ QQueue<Decision> m_decisions;
+};
+}
+
+#endif
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 <kross/core/action.h>
-#include <kross/core/childreninterface.h>
+#include <kross/core/manager.h>
-int Pokebattle::Arena::m_totalCount = 0;
+QSet<int> Pokebattle::Arena::m_arenaIds;
Pokebattle::Arena::Arena(QList<Player*> 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<TeamMember*> 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()
diff --git a/pokebattle/Arena.h b/pokebattle/Arena.h
index 17eeee2c..0bbec051 100644
--- a/pokebattle/Arena.h
+++ b/pokebattle/Arena.h
@@ -25,6 +25,8 @@
// Qt includes
#include <QtCore/QList>
#include <QtCore/QObject>
+#include <QtCore/QPair>
+#include <QtCore/QSet>
// KDE includes
#include <kross/core/actioncollection.h>
@@ -45,41 +47,39 @@ class POKEBATTLE_EXPORT Arena : public QObject
Q_OBJECT
public:
+ enum ActionType
+ {
+ Attack = 0,
+ Item = 1,
+ Run = 2,
+ Timeout = 3,
+ Undecided = 4,
+ End = 5
+ };
+
Arena(QList<Player*> players);
- Arena(const Arena& arena);
~Arena();
+
+ Kross::Action* script(const QString& name);
signals:
void battleStart();
-
- void roundStart();
-
- void turnStart(TeamMember* teamMember);
-
- void sentOut(TeamMember* teamMember);
- void actionChosen(TeamMember* teamMember);
- void actionExecuted(TeamMember* teamMember);
- void actionUsed(TeamMember* teamMember);
- void attackMissed(TeamMember* teamMember);
- void attackHit(TeamMember* teamMember);
- void faint(TeamMember* teamMember);
-
- void turnEnd(TeamMember* teamMember);
-
- void roundEnd();
-
void battleEnd();
public slots:
void registerScript(const QString& name, const Pokemod::Script& script);
+ void triggerScript(const QString& name);
void unregisterScript(const QString& name);
protected slots:
void unregisterAllScripts();
void cleanUp();
+ protected:
+ typedef QPair<ActionType, int> Action;
+ typedef QPair<TeamMember*, Action> Decision;
private:
- int m_count;
+ int m_id;
QList<Player*> m_players;
Kross::ActionCollection* m_actions;
- static int m_totalCount;
+ static QSet<int> m_arenaIds;
};
}
diff --git a/pokebattle/CMakeLists.txt b/pokebattle/CMakeLists.txt
index 1304c5cc..06085e8f 100644
--- a/pokebattle/CMakeLists.txt
+++ b/pokebattle/CMakeLists.txt
@@ -8,12 +8,15 @@ ADD_DEFINITIONS(-DMAKE_POKEBATTLE_LIB)
SET(pokebattle_MOC_HEADERS
Arena.h
+ ATBArena.h
Bot.h
+ Containment.h
GhostBot.h
Ghost.h
Player.h
Team.h
TeamMember.h
+ TurnArena.h
)
QT4_WRAP_CPP(pokebattle_MOC_SRCS ${pokebattle_MOC_HEADERS})
SET(pokebattle_HEADERS
@@ -27,6 +30,7 @@ SET(pokebattle_SRCS
Ghost.cpp
Team.cpp
TeamMember.cpp
+ TurnArena.cpp
)
ADD_LIBRARY(pokebattle
diff --git a/pokebattle/Containment.h b/pokebattle/Containment.h
new file mode 100644
index 00000000..ffa3c525
--- /dev/null
+++ b/pokebattle/Containment.h
@@ -0,0 +1,58 @@
+/*
+ * Copyright 2008 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 __POKEBATTLE_CONTAINMENT__
+#define __POKEBATTLE_CONTAINMENT__
+
+// Pokebattle includes
+#include "Global.h"
+
+// Qt includes
+#include <QtCore/QObject>
+
+// Forward declarations
+namespace Pokemod
+{
+class Pokemod;
+}
+
+namespace Pokebattle
+{
+class Player;
+class TeamMember;
+
+class POKEBATTLE_EXPORT Containment : public QObject
+{
+ Q_OBJECT
+
+ public:
+// const Player* player();
+
+ virtual bool isMutable() const = 0;
+
+ const Pokemod::Pokemod* pokemod() const;
+ signals:
+ void teamKnockedOut();
+ public slots:
+ protected slots:
+ protected:
+ private:
+// const Player* m_player;
+};
+}
+
+#endif
diff --git a/pokebattle/TODO b/pokebattle/TODO
new file mode 100644
index 00000000..b9357c4b
--- /dev/null
+++ b/pokebattle/TODO
@@ -0,0 +1 @@
+Put global scripts into requesting for things
diff --git a/pokebattle/Team.h b/pokebattle/Team.h
index cf4f04d4..b66471e1 100644
--- a/pokebattle/Team.h
+++ b/pokebattle/Team.h
@@ -19,39 +19,23 @@
#define __POKEBATTLE_TEAM__
// Pokebattle includes
-#include "Global.h"
-
-// Qt includes
-#include <QtCore/QObject>
-
-// Forward declarations
-namespace Pokemod
-{
-class Pokemod;
-}
+#include "Containment.h"
namespace Pokebattle
{
-class Player;
-class TeamMember;
-
-class POKEBATTLE_EXPORT Team : public QObject
+class POKEBATTLE_EXPORT Team : public Containment
{
Q_OBJECT
public:
- const Player* player();
-
- const Pokemod::Pokemod* pokemod() const;
+// const Player* player();
signals:
void teamKnockedOut();
public slots:
protected slots:
protected:
private:
- const Player* m_player;
-
- QList<TeamMember*> m_members;
+// const Player* m_player;
};
}
diff --git a/pokebattle/TeamMember.cpp b/pokebattle/TeamMember.cpp
index 8b2d59c9..aed42f05 100644
--- a/pokebattle/TeamMember.cpp
+++ b/pokebattle/TeamMember.cpp
@@ -19,7 +19,7 @@
#include "TeamMember.h"
// Pokebattle includes
-#include "Team.h"
+#include "Containment.h"
// Pokemod includes
#include "../pokemod/Hat.h"
@@ -31,64 +31,51 @@
#include "../pokemod/SpeciesItem.h"
#include "../pokemod/SpeciesMove.h"
-Pokebattle::TeamMember::TeamMember(const int speciesId, const int level, const Team* team, const bool suppressItems) :
- m_team(team)
+// Qt includes
+#include <QtCore/QUuid>
+
+// KDE includes
+#include <kross/core/action.h>
+#include <kross/core/actioncollection.h>
+#include <kross/core/manager.h>
+
+// C includes
+#include <cmath>
+
+Pokebattle::TeamMember::TeamMember(const int speciesId, const QString& name, const int level, Containment* containment, const bool suppressItems) :
+ m_containment(containment)
{
- const Pokemod::Species* species = pokemod()->speciesById(speciesId);
setSpecies(speciesId);
+ const Pokemod::Species* species = pokemod()->speciesById(m_species);
+ if (name.isEmpty())
+ setName(species->name());
+ else
+ setName(name);
setLevel(level);
if (!suppressItems)
- {
- const Pokemod::Fraction itemChance = species->itemChance();
- Pokemod::Hat<int> itemHat;
- for (int i = 0; i < species->itemCount(); ++i)
- {
- const Pokemod::SpeciesItem* item = species->item(i);
- itemHat.add(item->item(), item->weight());
- }
- for (int i = 0; i < pokemod()->rules()->maxHeldItems(); ++i)
- {
- if (itemChance.poll())
- m_items.append(itemHat.pick());
- }
- }
- // TODO: choose moves
- Pokemod::Hat<int> abilityHat;
- for (int i = 0; i < species->abilityCount(); ++i)
- {
- const Pokemod::SpeciesAbility* ability = species->ability(i);
- abilityHat.add(ability->ability(), ability->weight());
- }
- for (int i = 0; i < pokemod()->rules()->maxAbilities(); ++i)
- {
- const int ability = abilityHat.pick();
- m_abilities.append(ability);
- abilityHat.setCount(ability, 0);
- }
- if (pokemod()->rules()->specialDVSplit())
- {
- for (int i = 0; i < Pokemod::ST_End_GSC; ++i)
- m_dv[i] = qrand() & 31;
- }
- else
- {
- for (int i = Pokemod::ST_No_HP_Start; i < Pokemod::ST_End_RBY; ++i)
- m_dv[i] = qrand() & 15;
- m_dv[Pokemod::ST_HP] = (m_dv[Pokemod::ST_Attack] << 3) + (m_dv[Pokemod::ST_Defense] << 2) + (m_dv[Pokemod::ST_Speed] << 1) + m_dv[Pokemod::ST_Special];
- }
+ initItems();
+ initAbilities();
+ initMoves();
+ initStats();
if (species->genderFactor() <= 1)
- setGender(species->genderFactor().poll());
+ m_gender = species->genderFactor().poll();
else
- setGender(-1);
+ m_gender = -1;
for (int i = 0; i < Pokemod::ST_End_GSC; ++i)
- {
m_statExp[i] = 0;
- m_effortValues[i] = 0;
+ if (m_containment->isMutable())
+ {
+ const Pokemod::Script script = species->evolution();
+ Kross::Action* evolution = new Kross::Action(Kross::Manager::self().actionCollection()->collection("evolutions"), QString("evolution-%1").arg(QUuid::createUuid().toString()));
+ evolution->setInterpreter(script.interpreter());
+ evolution->setCode(script.script().toUtf8());
+ evolution->addObject(this, "owner", Kross::ChildrenInterface::AutoConnectSignals);
+ evolution->trigger();
}
}
-Pokebattle::TeamMember::TeamMember(const Pokemod::MapTrainerTeamMember& teamMember, const Team* team) :
- m_team(team)
+Pokebattle::TeamMember::TeamMember(const Pokemod::MapTrainerTeamMember& teamMember, Containment* containment) :
+ m_containment(containment)
{
// TODO: grab information from the class
// TODO: fill in anything else
@@ -109,15 +96,38 @@ int Pokebattle::TeamMember::level() const
return m_level;
}
-int Pokebattle::TeamMember::stat(const int stat) const
+int Pokebattle::TeamMember::statValue(const int stat, const int exp) const
{
- return calcStat(stat);
-}
-
-int Pokebattle::TeamMember::effortValue(const int stat) const
-{
- Q_ASSERT(stat < (pokemod()->rules()->specialSplit() ? Pokemod::ST_End_RBY : Pokemod::ST_End_GSC));
- return m_effortValues[stat];
+ Q_ASSERT(stat < (pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY));
+ int statValue;
+ if (exp < 0)
+ statValue = m_statExp[stat];
+ else
+ statValue = exp;
+ if (!pokemod()->rules()->effortValuesAllowed() && statValue)
+ statValue = sqrt(statValue - 1) + 1;
+ statValue >>= 2;
+ statValue += pokemod()->speciesById(m_species)->baseStat(stat) << 1;
+ if (pokemod()->rules()->specialDVSplit())
+ {
+ if (stat == Pokemod::ST_SpecialDefense)
+ statValue += m_dv[Pokemod::ST_Special] << 1;
+ else
+ statValue += m_dv[stat] << 1;
+ }
+ else
+ statValue += m_dv[stat];
+ statValue *= m_level;
+ statValue /= 100;
+ if (stat == Pokemod::ST_HP)
+ statValue += 10 + m_level;
+ else
+ {
+ statValue += 5;
+ foreach (int natureId, m_natures)
+ statValue *= pokemod()->natureById(natureId)->stat(stat);
+ }
+ return statValue;
}
int Pokebattle::TeamMember::calcExp(int level) const
@@ -136,6 +146,7 @@ int Pokebattle::TeamMember::calcExp(int level) const
return cube * ((14 + level) / 50.0);
else if (level <= 100)
return cube * ((32 + (level / 2)) / 50.0);
+ // TODO: better way for further growth?
else if (level <= 102)
return cube * (23 + level) / 75;
else
@@ -157,16 +168,25 @@ int Pokebattle::TeamMember::calcExp(int level) const
return cube * (1.274 - (level / 3) / 50.0 - p[level % 3]);
else if (level <= 100)
return cube * ((160 - level) / 100.0);
+ // TODO: better way for further growth?
else
return 3 * cube / 5;
+ default:
+ break;
}
+ Q_ASSERT(false);
+ return -1;
}
-int Pokebattle::TeamMember::calcStat(const int stat, int exp) const
+bool Pokebattle::TeamMember::canLearnMove(const int move)
{
- // TODO: calculate stat
- // TODO: extra factor for HP
- // TODO: factor in natures
+ const Pokemod::Species* species = pokemod()->speciesById(m_species);
+ for (int i = 0; i < species->moveCount(); ++i)
+ {
+ if (move == species->move(i)->move())
+ return true;
+ }
+ return false;
}
void Pokebattle::TeamMember::boostLevels(const int levels)
@@ -178,6 +198,11 @@ void Pokebattle::TeamMember::boostLevels(const int levels)
}
}
+void Pokebattle::TeamMember::evolveInto(const int newSpecies)
+{
+ setSpecies(newSpecies);
+}
+
void Pokebattle::TeamMember::setName(const QString& name)
{
if (m_name != name)
@@ -228,18 +253,32 @@ void Pokebattle::TeamMember::giveLevelExp(const int exp)
void Pokebattle::TeamMember::giveStatExp(const int stat, const int exp)
{
- // TODO: ensure that the stat is valid
- const int currentStat = calcStat(stat);
- // TODO: make sure the new exp doesn't overflow the total exp
- // TODO: emit a signal if the stat was changed
-}
-
-void Pokebattle::TeamMember::giveEffort(const int stat, const int exp)
-{
- // TODO: ensure that the stat is valid
- const int currentEffort = m_effortValues[stat];
- // TODO: Make sure both the stat and total EV is not overflowed
- // TODO: emit a signal if it updated the stat
+ Q_ASSERT(stat < (pokemod()->rules()->specialSplit() ? Pokemod::ST_End_GSC : Pokemod::ST_End_RBY));
+ const int oldStat = statValue(stat);
+ int expToGive = exp;
+ if (pokemod()->rules()->effortValuesAllowed())
+ {
+ int totalEV = 0;
+ for (int i = 0; i < Pokemod::ST_End_GSC; ++i)
+ totalEV += m_statExp[i];
+ while (expToGive && (totalEV < pokemod()->rules()->maxTotalEV()) && (m_statExp[stat] < pokemod()->rules()->maxEVPerStat()))
+ {
+ --expToGive;
+ ++totalEV;
+ ++m_statExp[stat];
+ }
+ }
+ else
+ {
+ while (expToGive && (m_statExp[stat] < INT_MAX))
+ {
+ --expToGive;
+ ++m_statExp[stat];
+ }
+ }
+ const int newStat = statValue(stat);
+ if (oldStat != newStat)
+ emit(statChanged(stat, newStat));
}
void Pokebattle::TeamMember::takeItem(const int itemIndex)
@@ -254,10 +293,12 @@ void Pokebattle::TeamMember::takeItem(const int itemIndex)
void Pokebattle::TeamMember::giveItem(const int item)
{
- // TODO: make sure that more items can be carried
- // TODO: make sure its a valid item
- m_items.append(item);
- emit(itemGiven(item));
+ Q_ASSERT(pokemod()->itemIndex(item) != INT_MAX);
+ if (m_items.size() < pokemod()->rules()->maxHeldItems())
+ {
+ m_items.append(item);
+ emit(itemGiven(item));
+ }
}
void Pokebattle::TeamMember::forgetMove(const int moveIndex)
@@ -272,11 +313,12 @@ void Pokebattle::TeamMember::forgetMove(const int moveIndex)
void Pokebattle::TeamMember::teachMove(const int move)
{
- // TODO: make sure that more moves can be learned
- // TODO: make sure its a valid move
- // TODO: make sure the move can be learned
- m_moves.append(move);
- emit(moveLearned(move));
+ Q_ASSERT(pokemod()->moveIndex(move) != INT_MAX);
+ if ((m_moves.size() < pokemod()->rules()->maxMoves()) && canLearnMove(move))
+ {
+ m_moves.append(move);
+ emit(moveLearned(move));
+ }
}
const Pokemod::Pokemod* Pokebattle::TeamMember::pokemod() const
@@ -289,12 +331,7 @@ void Pokebattle::TeamMember::setSpecies(const int species)
{
Q_ASSERT(pokemod()->speciesIndex(species) != INT_MAX);
m_species = species;
-}
-
-void Pokebattle::TeamMember::setGender(const int gender)
-{
- Q_ASSERT((-1 <= gender) && (gender <= 1));
- m_gender = gender;
+ emit(speciesChanged(m_species));
}
void Pokebattle::TeamMember::setLevel(const int level)
@@ -303,3 +340,78 @@ void Pokebattle::TeamMember::setLevel(const int level)
m_level = level;
m_levelExp = calcExp();
}
+
+void Pokebattle::TeamMember::levelGrown()
+{
+ const Pokemod::Species* species = pokemod()->speciesById(m_species);
+ for (int i = 0; i < species->moveCount(); ++i)
+ {
+ const Pokemod::SpeciesMove* move = species->move(i);
+ if (move->level() == m_level)
+ teachMove(move->move());
+ }
+}
+
+void Pokebattle::TeamMember::initItems()
+{
+ const Pokemod::Species* species = pokemod()->speciesById(m_species);
+ Pokemod::Hat<int> itemHat;
+ m_items.clear();
+ for (int i = 0; i < species->itemCount(); ++i)
+ {
+ const Pokemod::SpeciesItem* item = species->item(i);
+ itemHat.add(item->item(), item->weight());
+ }
+ for (int i = 0; i < pokemod()->rules()->maxHeldItems(); ++i)
+ {
+ if (species->itemChance().poll())
+ m_items.append(itemHat.pick());
+ }
+}
+
+void Pokebattle::TeamMember::initAbilities()
+{
+ m_abilities.clear();
+ while (m_abilities.size())
+ m_abilities.append(newAbility());
+}
+
+void Pokebattle::TeamMember::initMoves()
+{
+ const Pokemod::Species* species = pokemod()->speciesById(m_species);
+ m_moves.clear();
+ for (int i = 0; (i < species->moveCount()) && (m_moves.size() < pokemod()->rules()->maxMoves()); ++i)
+ {
+ if ((species->move(i)->level() < m_level) && (0 <= species->move(i)->level()))
+ m_moves.append(species->move(i)->move());
+ }
+ Q_ASSERT(m_moves.size());
+}
+
+void Pokebattle::TeamMember::initStats()
+{
+ if (pokemod()->rules()->specialDVSplit())
+ {
+ for (int i = 0; i < Pokemod::ST_End_GSC; ++i)
+ m_dv[i] = qrand() & 31;
+ }
+ else
+ {
+ for (int i = Pokemod::ST_No_HP_Start; i < Pokemod::ST_End_RBY; ++i)
+ m_dv[i] = qrand() & 15;
+ m_dv[Pokemod::ST_HP] = (m_dv[Pokemod::ST_Attack] << 3) + (m_dv[Pokemod::ST_Defense] << 2) + (m_dv[Pokemod::ST_Speed] << 1) + m_dv[Pokemod::ST_Special];
+ }
+}
+
+int Pokebattle::TeamMember::newAbility()
+{
+ const Pokemod::Species* species = pokemod()->speciesById(m_species);
+ Pokemod::Hat<int> abilityHat;
+ for (int i = 0; i < species->abilityCount(); ++i)
+ {
+ const Pokemod::SpeciesAbility* ability = species->ability(i);
+ if (!m_abilities.contains(ability->ability()))
+ abilityHat.add(ability->ability(), ability->weight());
+ }
+ return abilityHat.pick();
+}
diff --git a/pokebattle/TeamMember.h b/pokebattle/TeamMember.h
index db08cb59..85d10f26 100644
--- a/pokebattle/TeamMember.h
+++ b/pokebattle/TeamMember.h
@@ -38,25 +38,26 @@ class Pokemod;
namespace Pokebattle
{
-class Team;
+class Containment;
class POKEBATTLE_EXPORT TeamMember : public QObject
{
Q_OBJECT
public:
- TeamMember(const int speciesId, const int level, const Team* team, const bool suppressItems = false);
- TeamMember(const Pokemod::MapTrainerTeamMember& teamMember, const Team* team);
+ TeamMember(const int speciesId, const QString& name, const int level, Containment* containment, const bool suppressItems = false);
+ TeamMember(const Pokemod::MapTrainerTeamMember& teamMember, Containment* containment);
QString name() const;
int species() const;
int level() const;
- int stat(const int stat) const;
- int effortValue(const int stat) const;
-
+ int statValue(const int stat, const int exp = -1) const;
int calcExp(int level = -1) const;
- int calcStat(const int stat, int exp = -1) const;
+
+ bool canLearnMove(const int move);
signals:
+ void speciesChanged(const int species);
+
void nameChanged(const QString& oldName, const QString& newName);
void expGained(const int exp);
void statusCured(const int status);
@@ -74,24 +75,26 @@ class POKEBATTLE_EXPORT TeamMember : public QObject
public slots:
void boostLevels(const int levels);
+ void evolveInto(const int newSpecies);
+
void setName(const QString& name);
void cureStatus(const int status);
void giveStatus(const int status);
void giveLevelExp(const int exp);
void giveStatExp(const int stat, const int exp);
- void giveEffort(const int stat, const int effort);
void takeItem(const int itemIndex);
void giveItem(const int item);
void forgetMove(const int moveIndex);
void teachMove(const int move);
protected slots:
- const Pokemod::Pokemod* pokemod() const;
-
void setSpecies(const int species);
- void setGender(const int gender);
void setLevel(const int level);
+ private slots:
+ void levelGrown();
protected:
- const Team* m_team;
+ const Pokemod::Pokemod* pokemod() const;
+
+ Containment* m_containment;
QString m_name;
int m_species;
@@ -99,13 +102,19 @@ class POKEBATTLE_EXPORT TeamMember : public QObject
int m_levelExp;
int m_level;
int m_statExp[Pokemod::ST_End_GSC];
- int m_effortValues[Pokemod::ST_End_GSC];
int m_dv[Pokemod::ST_End_GSC];
QList<int> m_status;
QList<int> m_abilities;
QList<int> m_items;
QList<int> m_moves;
QList<int> m_natures;
+ private:
+ void initItems();
+ void initAbilities();
+ void initMoves();
+ void initStats();
+
+ int newAbility();
};
}
diff --git a/pokebattle/TurnArena.cpp b/pokebattle/TurnArena.cpp
new file mode 100644
index 00000000..2ec6eb55
--- /dev/null
+++ b/pokebattle/TurnArena.cpp
@@ -0,0 +1,26 @@
+/*
+ * Copyright 2008 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"
+
+Pokebattle::TurnArena::TurnArena(QList<Player*> players) :
+ Arena(players)
+{
+ emit(battleStart());
+}
+
diff --git a/pokebattle/TurnArena.h b/pokebattle/TurnArena.h
new file mode 100644
index 00000000..45fae44f
--- /dev/null
+++ b/pokebattle/TurnArena.h
@@ -0,0 +1,45 @@
+/*
+ * Copyright 2008 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 __POKEBATTLE_TURNARENA__
+#define __POKEBATTLE_TURNARENA__
+
+// Pokebattle includes
+#include "Arena.h"
+
+namespace Pokebattle
+{
+class POKEBATTLE_EXPORT TurnArena : public Arena
+{
+ Q_OBJECT
+
+ public:
+ TurnArena(QList<Player*> players);
+ signals:
+ void roundStart();
+ void roundEnd();
+ public slots:
+ protected slots:
+ private:
+ typedef QPair<ActionType, int> Action;
+ typedef QPair<TeamMember*, Action> Decision;
+
+ QList<Decision> m_decisions;
+};
+}
+
+#endif
diff --git a/pokemod/Ability.cpp b/pokemod/Ability.cpp
index 0d536765..385dd572 100644
--- a/pokemod/Ability.cpp
+++ b/pokemod/Ability.cpp
@@ -31,6 +31,7 @@ Pokemod::Ability::Ability(const Ability& ability) :
Pokemod::Ability::Ability(const Pokemod* parent, const int id) :
Object("Ability", parent, id),
m_name(""),
+ m_priority(0),
m_description(""),
m_script("", "")
{
@@ -65,6 +66,7 @@ void Pokemod::Ability::load(const QDomElement& xml)
{
LOAD_BEGIN();
LOAD(QString, name);
+ LOAD(int, priority);
LOAD(QString, description);
LOAD(Script, script);
}
@@ -73,6 +75,7 @@ QDomElement Pokemod::Ability::save() const
{
SAVE_CREATE();
SAVE(QString, name);
+ SAVE(int, priority);
SAVE(QString, description);
SAVE(Script, script);
return xml;
@@ -83,6 +86,11 @@ void Pokemod::Ability::setName(const QString& name)
CHECK(name);
}
+void Pokemod::Ability::setPriority(const int priority)
+{
+ CHECK(priority);
+}
+
void Pokemod::Ability::setDescription(const QString& description)
{
CHECK(description);
@@ -98,6 +106,11 @@ QString Pokemod::Ability::name() const
return m_name;
}
+int Pokemod::Ability::priority() const
+{
+ return m_priority;
+}
+
QString Pokemod::Ability::description() const
{
return m_description;
@@ -113,6 +126,7 @@ Pokemod::Ability& Pokemod::Ability::operator=(const Ability& rhs)
if (this == &rhs)
return *this;
COPY(name);
+ COPY(priority);
COPY(description);
COPY(script);
return *this;
diff --git a/pokemod/Ability.h b/pokemod/Ability.h
index 9a2aa898..f050f6b8 100644
--- a/pokemod/Ability.h
+++ b/pokemod/Ability.h
@@ -44,16 +44,19 @@ class POKEMOD_EXPORT Ability : public Object
QDomElement save() const;
void setName(const QString& name);
+ void setPriority(const int priority);
void setDescription(const QString& description);
void setScript(const Script& script);
QString name() const;
+ int priority() const;
QString description() const;
Script script() const;
Ability& operator=(const Ability& rhs);
private:
QString m_name;
+ int m_priority;
QString m_description;
Script m_script;
};
diff --git a/pokemod/CMakeLists.txt b/pokemod/CMakeLists.txt
index bf06f867..83b9dd64 100644
--- a/pokemod/CMakeLists.txt
+++ b/pokemod/CMakeLists.txt
@@ -49,7 +49,6 @@ SET(pokemod_HEADERS
Hat.h
Macros.h
Matrix.h
- Point.h
Script.h
)
SET(pokemod_DEVEL
diff --git a/pokemod/Hat.h b/pokemod/Hat.h
index 005972d1..7edd4bbb 100644
--- a/pokemod/Hat.h
+++ b/pokemod/Hat.h
@@ -34,8 +34,8 @@ template<class T> class Hat
T pick() const;
T take();
- void setCount(const T& key, const unsigned weight);
- void add(const T& key, const unsigned weight);
+ void setCount(const T& key, const int weight);
+ void add(const T& key, const int weight);
unsigned count() const;
unsigned count(const T& key) const;
double chance(const T& key) const;
@@ -43,7 +43,7 @@ template<class T> class Hat
unsigned operator[](const T& key) const;
private:
QMap<T, unsigned> m_objects;
- unsigned m_count;
+ int m_count;
};
template<class T> inline Hat<T>::Hat() :
@@ -72,7 +72,7 @@ template<class T> inline T Hat<T>::take()
return chosen;
}
-template<class T> inline void Hat<T>::setCount(const T& key, const unsigned weight)
+template<class T> inline void Hat<T>::setCount(const T& key, const int weight)
{
if (m_objects.contains(key))
m_count -= m_objects[key];
@@ -85,7 +85,7 @@ template<class T> inline void Hat<T>::setCount(const T& key, const unsigned weig
m_objects.remove(key);
}
-template<class T> inline void Hat<T>::add(const T& key, const unsigned weight)
+template<class T> inline void Hat<T>::add(const T& key, const int weight)
{
m_objects[key] += weight;
m_count += weight;
@@ -112,6 +112,7 @@ template<class T> inline unsigned Hat<T>::operator[](const T& key) const
{
return count(key);
}
+
}
#endif
diff --git a/pokemod/Macros.h b/pokemod/Macros.h
index f28d34e9..d10f609a 100644
--- a/pokemod/Macros.h
+++ b/pokemod/Macros.h
@@ -21,9 +21,7 @@
// Qt includes
#include <QtCore/QBuffer>
-/**
- * @todo The macros should probably be replaced by protected static members of \a Pokemod::Object
- */
+// TODO: The macros should probably be replaced by protected static members of Object
#define LOAD_NODE(variable) xml.firstChildElement(variable)
#define LOAD_DATA(node) node.firstChild().toText().data()
@@ -38,7 +36,7 @@
#define LOAD_int(node) LOAD_DATA(node).toInt()
#define LOAD_QString LOAD_DATA
#define LOAD_Fraction(node) Fraction(node.attribute("numerator", "1").toInt(), node.attribute("denominator", "1").toInt())
-#define LOAD_Point(node) Point(node.attribute("x", "0").toInt(), node.attribute("y", "0").toInt())
+#define LOAD_QPoint(node) QPoint(node.attribute("x", "0").toInt(), node.attribute("y", "0").toInt())
// FIXME: QPixmap::fromData static member would be nice
#define LOAD_QPixmap(node) QPixmap::fromImage(QImage::fromData(QByteArray::fromBase64(LOAD_DATA(node).toUtf8())))
#define LOAD_QByteArray(node) QByteArray::fromBase64(LOAD_DATA(node).toUtf8())
@@ -114,8 +112,8 @@
Fraction frac_##variable = value; \
xml_##variable.setAttribute("numerator", frac_##variable.numerator()); \
xml_##variable.setAttribute("denominator", frac_##variable.denominator())
-#define SAVE_Point(variable, value) \
- Point point_##variable = value; \
+#define SAVE_QPoint(variable, value) \
+ QPoint point_##variable = value; \
xml_##variable.setAttribute("x", point_##variable.x()); \
xml_##variable.setAttribute("y", point_##variable.y())
#define SAVE_QPixmap(variable, value) \
diff --git a/pokemod/Map.cpp b/pokemod/Map.cpp
index 93815983..7138db15 100644
--- a/pokemod/Map.cpp
+++ b/pokemod/Map.cpp
@@ -236,7 +236,7 @@ int Pokemod::Map::height() const
return m_tile.height();
}
-Pokemod::Point Pokemod::Map::size() const
+QPoint Pokemod::Map::size() const
{
return m_tile.size();
}
diff --git a/pokemod/Map.h b/pokemod/Map.h
index 2d6933c9..916e78d3 100644
--- a/pokemod/Map.h
+++ b/pokemod/Map.h
@@ -80,7 +80,7 @@ class POKEMOD_EXPORT Map : public Object
int tile(const int row, const int column) const;
int width() const;
int height() const;
- Point size() const;
+ QPoint size() const;
const MapEffect* effect(const int index) const;
MapEffect* effect(const int index);
diff --git a/pokemod/MapEffect.cpp b/pokemod/MapEffect.cpp
index 2f333f2c..1d677140 100644
--- a/pokemod/MapEffect.cpp
+++ b/pokemod/MapEffect.cpp
@@ -66,7 +66,7 @@ void Pokemod::MapEffect::load(const QDomElement& xml)
{
LOAD_BEGIN();
LOAD(QString, name);
- LOAD(Point, coordinate);
+ LOAD(QPoint, coordinate);
LOAD(QPixmap, skin);
LOAD(bool, isGhost);
LOAD(Script, script);
@@ -76,7 +76,7 @@ QDomElement Pokemod::MapEffect::save() const
{
SAVE_CREATE();
SAVE(QString, name);
- SAVE(Point, coordinate);
+ SAVE(QPoint, coordinate);
SAVE(QPixmap, skin);
SAVE(bool, isGhost);
SAVE(Script, script);
@@ -88,7 +88,7 @@ void Pokemod::MapEffect::setName(const QString& name)
CHECK(name);
}
-void Pokemod::MapEffect::setCoordinate(const Point& coordinate)
+void Pokemod::MapEffect::setCoordinate(const QPoint& coordinate)
{
if ((static_cast<const Map*>(parent())->width() <= coordinate.x()) || (static_cast<const Map*>(parent())->height() <= coordinate.y()))
{
@@ -124,7 +124,7 @@ QString Pokemod::MapEffect::name() const
return m_name;
}
-Pokemod::Point Pokemod::MapEffect::coordinate() const
+QPoint Pokemod::MapEffect::coordinate() const
{
return m_coordinate;
}
diff --git a/pokemod/MapEffect.h b/pokemod/MapEffect.h
index d86bf3d1..3a3fa2cc 100644
--- a/pokemod/MapEffect.h
+++ b/pokemod/MapEffect.h
@@ -20,10 +20,10 @@
// Pokemod includes
#include "Object.h"
-#include "Point.h"
#include "Script.h"
// Qt includes
+#include <QtCore/QPoint>
#include <QtGui/QPixmap>
namespace Pokemod
@@ -47,13 +47,13 @@ class POKEMOD_EXPORT MapEffect : public Object
QDomElement save() const;
void setName(const QString& name);
- void setCoordinate(const Point& coordinate);
+ void setCoordinate(const QPoint& coordinate);
void setSkin(const QPixmap& skin);
void setIsGhost(const bool isGhost);
void setScript(const Script& script);
QString name() const;
- Point coordinate() const;
+ QPoint coordinate() const;
QPixmap skin() const;
bool isGhost() const;
Script script() const;
@@ -61,7 +61,7 @@ class POKEMOD_EXPORT MapEffect : public Object
MapEffect& operator=(const MapEffect& rhs);
private:
QString m_name;
- Point m_coordinate;
+ QPoint m_coordinate;
QPixmap m_skin;
bool m_isGhost;
Script m_script;
diff --git a/pokemod/MapTrainer.cpp b/pokemod/MapTrainer.cpp
index 31507ec5..d16ab3c0 100644
--- a/pokemod/MapTrainer.cpp
+++ b/pokemod/MapTrainer.cpp
@@ -86,7 +86,7 @@ void Pokemod::MapTrainer::load(const QDomElement& xml)
LOAD_BEGIN();
LOAD(QString, name);
LOAD(int, trainerClass);
- LOAD(Point, coordinate);
+ LOAD(QPoint, coordinate);
LOAD(int, numberFight);
LOAD(Script, script);
LOAD_SUB(newTeamMember, MapTrainerTeamMember);
@@ -98,7 +98,7 @@ QDomElement Pokemod::MapTrainer::save() const
SAVE_CREATE();
SAVE(QString, name);
SAVE(int, trainerClass);
- SAVE(Point, coordinate);
+ SAVE(QPoint, coordinate);
SAVE(int, numberFight);
SAVE(Script, script);
SAVE_SUB(MapTrainerTeamMember, teamMembers);
@@ -120,7 +120,7 @@ void Pokemod::MapTrainer::setTrainerClass(const int trainerClass)
CHECK(trainerClass);
}
-void Pokemod::MapTrainer::setCoordinate(const Point& coordinate)
+void Pokemod::MapTrainer::setCoordinate(const QPoint& coordinate)
{
if ((static_cast<const Map*>(parent())->width() <= coordinate.x()) || (static_cast<const Map*>(parent())->height() <= coordinate.y()))
{
@@ -165,7 +165,7 @@ int Pokemod::MapTrainer::trainerClass() const
return m_trainerClass;
}
-Pokemod::Point Pokemod::MapTrainer::coordinate() const
+QPoint Pokemod::MapTrainer::coordinate() const
{
return m_coordinate;
}
diff --git a/pokemod/MapTrainer.h b/pokemod/MapTrainer.h
index 23fd7927..f77d0a97 100644
--- a/pokemod/MapTrainer.h
+++ b/pokemod/MapTrainer.h
@@ -20,11 +20,11 @@
// Pokemod includes
#include "Object.h"
-#include "Point.h"
#include "Script.h"
// Qt includes
#include <QtCore/QList>
+#include <QtCore/QPoint>
namespace Pokemod
{
@@ -50,14 +50,14 @@ class POKEMOD_EXPORT MapTrainer : public Object
void setName(const QString& name);
void setTrainerClass(const int trainerClass);
- void setCoordinate(const Point& coordinate);
+ void setCoordinate(const QPoint& coordinate);
void setNumberFight(const int numberFight);
void setScript(const Script& script);
void setLeadTeamMember(const int leadTeamMember);
QString name() const;
int trainerClass() const;
- Point coordinate() const;
+ QPoint coordinate() const;
int numberFight() const;
Script script() const;
int leadTeamMember() const;
@@ -83,7 +83,7 @@ class POKEMOD_EXPORT MapTrainer : public Object
QString m_name;
int m_trainerClass;
- Point m_coordinate;
+ QPoint m_coordinate;
int m_numberFight;
Script m_script;
int m_leadTeamMember;
diff --git a/pokemod/MapWarp.cpp b/pokemod/MapWarp.cpp
index 872fe894..b261228b 100644
--- a/pokemod/MapWarp.cpp
+++ b/pokemod/MapWarp.cpp
@@ -70,7 +70,7 @@ void Pokemod::MapWarp::load(const QDomElement& xml)
{
LOAD_BEGIN();
LOAD(QString, name);
- LOAD(Point, coordinate);
+ LOAD(QPoint, coordinate);
LOAD(int, type);
LOAD(int, toMap);
LOAD(int, toWarp);
@@ -81,7 +81,7 @@ QDomElement Pokemod::MapWarp::save() const
{
SAVE_CREATE();
SAVE(QString, name);
- SAVE(Point, coordinate);
+ SAVE(QPoint, coordinate);
SAVE(int, type);
SAVE(int, toMap);
SAVE(int, toWarp);
@@ -94,7 +94,7 @@ void Pokemod::MapWarp::setName(const QString& name)
CHECK(name);
}
-void Pokemod::MapWarp::setCoordinate(const Point& coordinate)
+void Pokemod::MapWarp::setCoordinate(const QPoint& coordinate)
{
if ((static_cast<const Map*>(parent())->width() <= coordinate.x()) || (static_cast<const Map*>(parent())->height() <= coordinate.y()))
{
@@ -149,7 +149,7 @@ QString Pokemod::MapWarp::name() const
return m_name;
}
-Pokemod::Point Pokemod::MapWarp::coordinate() const
+QPoint Pokemod::MapWarp::coordinate() const
{
return m_coordinate;
}
diff --git a/pokemod/MapWarp.h b/pokemod/MapWarp.h
index 02d11dd2..e3f7fa63 100644
--- a/pokemod/MapWarp.h
+++ b/pokemod/MapWarp.h
@@ -20,9 +20,11 @@
// Pokemod includes
#include "Object.h"
-#include "Point.h"
#include "Script.h"
+// Qt includes
+#include <QtCore/QPoint>
+
namespace Pokemod
{
// Forward declarations
@@ -54,14 +56,14 @@ class POKEMOD_EXPORT MapWarp : public Object
QDomElement save() const;
void setName(const QString& name);
- void setCoordinate(const Point& coordinate);
+ void setCoordinate(const QPoint& coordinate);
void setType(const int type);
void setToMap(const int toMap);
void setToWarp(const int toWarp);
void setScript(const Script& script);
QString name() const;
- Point coordinate() const;
+ QPoint coordinate() const;
int type() const;
int toMap() const;
int toWarp() const;
@@ -70,7 +72,7 @@ class POKEMOD_EXPORT MapWarp : public Object
MapWarp& operator=(const MapWarp& rhs);
private:
QString m_name;
- Point m_coordinate;
+ QPoint m_coordinate;
int m_type;
int m_toMap;
int m_toWarp;
diff --git a/pokemod/Matrix.h b/pokemod/Matrix.h
index 77cf3595..e1961d2c 100644
--- a/pokemod/Matrix.h
+++ b/pokemod/Matrix.h
@@ -20,9 +20,9 @@
// Pokemod includes
#include "Global.h"
-#include "Point.h"
// Qt includes
+#include <QtCore/QPoint>
#include <QtCore/QVector>
namespace Pokemod
@@ -52,7 +52,7 @@ template<class T> class POKEMOD_EXPORT Matrix
int height() const;
int width() const;
- Point size() const;
+ QPoint size() const;
T& operator()(const int row, const int column);
T operator()(const int row, const int column) const;
@@ -79,7 +79,7 @@ template<class T> inline Matrix<T>::Matrix(const Matrix<T>& rhs)
template<class T> inline void Matrix<T>::addRow(const T& value)
{
- if (size() == Point(0, 0))
+ if (size() == QPoint(0, 0))
m_matrix.append(QVector<T>(1, value));
else
m_matrix.append(QVector<T>(width(), value));
@@ -87,7 +87,7 @@ template<class T> inline void Matrix<T>::addRow(const T& value)
template<class T> inline void Matrix<T>::addColumn(const T& value)
{
- if (size() == Point(0, 0))
+ if (size() == QPoint(0, 0))
m_matrix.append(QVector<T>(1, value));
else
{
@@ -98,7 +98,7 @@ template<class T> inline void Matrix<T>::addColumn(const T& value)
template<class T> inline void Matrix<T>::insertRow(const int row, const T& value)
{
- if (size() == Point(0, 0))
+ if (size() == QPoint(0, 0))
m_matrix.append(QVector<T>(1, value));
else
{
@@ -109,7 +109,7 @@ template<class T> inline void Matrix<T>::insertRow(const int row, const T& value
template<class T> inline void Matrix<T>::insertColumn(const int column, const T& value)
{
- if (size() == Point(0, 0))
+ if (size() == QPoint(0, 0))
m_matrix.append(QVector<T>(1, value));
else
{
@@ -200,9 +200,9 @@ template<class T> inline int Matrix<T>::width() const
return 0;
}
-template<class T> inline Point Matrix<T>::size() const
+template<class T> inline QPoint Matrix<T>::size() const
{
- return Point(height(), width());
+ return QPoint(height(), width());
}
template<class T> inline T& Matrix<T>::operator()(const int row, const int column)
diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp
index 5393e427..1b0422d9 100644
--- a/pokemod/Move.cpp
+++ b/pokemod/Move.cpp
@@ -40,7 +40,7 @@ Pokemod::Move::Move(const Pokemod* parent, const int id) :
m_special(false),
m_overworld(false),
m_powerPoints(0),
- m_priority(1),
+ m_priority(0),
m_description(""),
m_script("", "")
{
@@ -84,6 +84,7 @@ void Pokemod::Move::load(const QDomElement& xml)
LOAD(bool, special);
LOAD(bool, overworld);
LOAD(int, powerPoints);
+ LOAD(int, priority);
LOAD(QString, description);
LOAD(Script, script);
}
@@ -98,6 +99,7 @@ QDomElement Pokemod::Move::save() const
SAVE(bool, special);
SAVE(bool, overworld);
SAVE(int, powerPoints);
+ SAVE(int, priority);
SAVE(QString, description);
SAVE(Script, script);
return xml;
@@ -153,6 +155,11 @@ void Pokemod::Move::setPowerPoints(const int powerPoints)
CHECK(powerPoints);
}
+void Pokemod::Move::setPriority(const int priority)
+{
+ CHECK(priority);
+}
+
void Pokemod::Move::setDescription(const QString& description)
{
CHECK(description);
@@ -198,6 +205,11 @@ int Pokemod::Move::powerPoints() const
return m_powerPoints;
}
+int Pokemod::Move::priority() const
+{
+ return m_priority;
+}
+
QString Pokemod::Move::description() const
{
return m_description;
@@ -219,6 +231,7 @@ Pokemod::Move& Pokemod::Move::operator=(const Move& rhs)
COPY(special);
COPY(overworld);
COPY(powerPoints);
+ COPY(priority);
COPY(description);
COPY(script);
return *this;
diff --git a/pokemod/Move.h b/pokemod/Move.h
index fc55ae26..32ee6a18 100644
--- a/pokemod/Move.h
+++ b/pokemod/Move.h
@@ -51,6 +51,7 @@ class POKEMOD_EXPORT Move : public Object
void setSpecial(const bool special);
void setOverworld(const bool overworld);
void setPowerPoints(const int powerPoints);
+ void setPriority(const int priority);
void setDescription(const QString& description);
void setScript(const Script& script);
diff --git a/pokemod/Nature.cpp b/pokemod/Nature.cpp
index 3ae75b96..52e597b6 100644
--- a/pokemod/Nature.cpp
+++ b/pokemod/Nature.cpp
@@ -34,7 +34,7 @@ Pokemod::Nature::Nature(const Pokemod* parent, const int id) :
m_name(""),
m_weight(1)
{
- for (int i = 0; i < ST_End_GSC; ++i)
+ for (int i = 0; i < (ST_End_GSC - ST_No_HP_Start); ++i)
m_stat[i].set(1, 1);
}
@@ -64,7 +64,7 @@ void Pokemod::Nature::load(const QDomElement& xml)
{
LOAD_BEGIN();
LOAD(QString, name);
- LOAD_ARRAY(Fraction, stat, ST_End_GSC);
+ LOAD_ARRAY(Fraction, stat, ST_End_GSC - ST_No_HP_Start);
LOAD(int, weight);
}
@@ -72,7 +72,7 @@ QDomElement Pokemod::Nature::save() const
{
SAVE_CREATE();
SAVE(QString, name);
- SAVE_ARRAY(Fraction, stat, ST_End_GSC);
+ SAVE_ARRAY(Fraction, stat, ST_End_GSC - ST_No_HP_Start);
SAVE(int, weight);
return xml;
}
@@ -84,7 +84,7 @@ void Pokemod::Nature::setName(const QString& name)
void Pokemod::Nature::setStat(const int stat, const Fraction& multiplier)
{
- if ((static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? ST_End_GSC : ST_End_RBY) <= stat)
+ if ((stat < ST_No_HP_Start) || ((static_cast<const Pokemod*>(pokemod())->rules()->specialSplit() ? ST_End_GSC : ST_End_RBY) <= stat))
{
emit(error(bounds("stat")));
return;
@@ -127,7 +127,7 @@ Pokemod::Nature& Pokemod::Nature::operator=(const Nature& rhs)
if (this == &rhs)
return *this;
COPY(name);
- COPY_ARRAY(stat, ST_End_GSC);
+ COPY_ARRAY(stat, ST_End_GSC - ST_No_HP_Start);
COPY(weight);
return *this;
}
diff --git a/pokemod/Nature.h b/pokemod/Nature.h
index c1c6dbbd..228ccf31 100644
--- a/pokemod/Nature.h
+++ b/pokemod/Nature.h
@@ -53,7 +53,7 @@ class POKEMOD_EXPORT Nature : public Object
Nature& operator=(const Nature& rhs);
private:
QString m_name;
- Fraction m_stat[ST_End_GSC];
+ Fraction m_stat[ST_End_GSC - ST_No_HP_Start];
int m_weight;
};
}
diff --git a/pokemod/Point.h b/pokemod/Point.h
deleted file mode 100644
index f5b0c890..00000000
--- a/pokemod/Point.h
+++ /dev/null
@@ -1,104 +0,0 @@
-/*
- * Copyright 2007-2008 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 __POKEMOD_POINT__
-#define __POKEMOD_POINT__
-
-// Pokemod includes
-#include "Global.h"
-
-namespace Pokemod
-{
-class POKEMOD_EXPORT Point
-{
- public:
- Point(const int x = 0, const int y = 0);
- Point(const Point& rhs);
-
- void set(const int x, const int y);
- void setX(const int x);
- void setY(const int y);
-
- int x() const;
- int y() const;
-
- Point& operator=(const Point& rhs);
- bool operator==(const Point& rhs) const;
- bool operator!=(const Point& rhs) const;
- private:
- int m_x;
- int m_y;
-};
-
-inline Point::Point(const int x, const int y) :
- m_x(x),
- m_y(y)
-{
-}
-
-inline Point::Point(const Point& rhs)
-{
- *this = rhs;
-}
-
-inline void Point::set(const int x, const int y)
-{
- m_x = x;
- m_y = y;
-}
-
-inline void Point::setX(const int x)
-{
- m_x = x;
-}
-
-inline void Point::setY(const int y)
-{
- m_y = y;
-}
-
-inline int Point::x() const
-{
- return m_x;
-}
-
-inline int Point::y() const
-{
- return m_y;
-}
-
-inline Point::Point& Point::operator=(const Point& rhs)
-{
- if (this == &rhs)
- return *this;
- m_x = rhs.m_x;
- m_y = rhs.m_y;
- return *this;
-}
-
-inline bool Point::operator==(const Point& rhs) const
-{
- return ((m_x == rhs.m_x) && (m_y == rhs.m_y));
-}
-
-inline bool Point::operator!=(const Point& rhs) const
-{
- return !(*this == rhs);
-}
-}
-
-#endif
diff --git a/pokemod/Pokemod.h b/pokemod/Pokemod.h
index 1cfebc69..76a858b3 100644
--- a/pokemod/Pokemod.h
+++ b/pokemod/Pokemod.h
@@ -22,7 +22,6 @@
#include "Fraction.h"
#include "Matrix.h"
#include "Object.h"
-#include "Point.h"
// Qt includes
#include <QtCore/QList>
diff --git a/pokemod/Rules.cpp b/pokemod/Rules.cpp
index ded6a566..5e3a0b47 100644
--- a/pokemod/Rules.cpp
+++ b/pokemod/Rules.cpp
@@ -35,6 +35,7 @@ Pokemod::Rules::Rules(const Pokemod* parent) :
m_genderAllowed(false),
m_breedingAllowed(false),
m_criticalDomains(false),
+ m_useTurns(true),
m_numBoxes(0),
m_boxSize(1),
m_maxParty(1),
@@ -103,6 +104,7 @@ void Pokemod::Rules::load(const QDomElement& xml)
LOAD(bool, genderAllowed);
LOAD(bool, breedingAllowed);
LOAD(bool, criticalDomains);
+ LOAD(bool, useTurns);
LOAD(int, numBoxes);
LOAD(int, boxSize);
LOAD(int, maxParty);
@@ -135,6 +137,7 @@ QDomElement Pokemod::Rules::save() const
SAVE(bool, genderAllowed);
SAVE(bool, breedingAllowed);
SAVE(bool, criticalDomains);
+ SAVE(bool, useTurns);
SAVE(int, numBoxes);
SAVE(int, boxSize);
SAVE(int, maxParty);
@@ -182,6 +185,11 @@ void Pokemod::Rules::setCriticalDomains(const bool criticalDomains)
CHECK(criticalDomains);
}
+void Pokemod::Rules::setUseTurns(const bool useTurns)
+{
+ CHECK(useTurns);
+}
+
void Pokemod::Rules::setNumBoxes(const int numBoxes)
{
CHECK(numBoxes);
@@ -367,6 +375,11 @@ bool Pokemod::Rules::criticalDomains() const
return m_criticalDomains;
}
+bool Pokemod::Rules::useTurns() const
+{
+ return m_useTurns;
+}
+
int Pokemod::Rules::numBoxes() const
{
return m_numBoxes;
@@ -494,6 +507,7 @@ Pokemod::Rules& Pokemod::Rules::operator=(const Rules& rhs)
COPY(genderAllowed);
COPY(breedingAllowed);
COPY(criticalDomains);
+ COPY(useTurns);
COPY(numBoxes);
COPY(boxSize);
COPY(maxParty);
diff --git a/pokemod/Rules.h b/pokemod/Rules.h
index b2e5099b..77436003 100644
--- a/pokemod/Rules.h
+++ b/pokemod/Rules.h
@@ -47,6 +47,7 @@ class POKEMOD_EXPORT Rules : public Object
void setGenderAllowed(const bool genderAllowed);
void setBreedingAllowed(const bool breedingAllowed);
void setCriticalDomains(const bool criticalDomains);
+ void setUseTurns(const bool useTurns);
void setNumBoxes(const int numBoxes);
void setBoxSize(const int boxSize);
void setMaxParty(const int maxParty);
@@ -75,6 +76,7 @@ class POKEMOD_EXPORT Rules : public Object
bool genderAllowed() const;
bool breedingAllowed() const;
bool criticalDomains() const;
+ bool useTurns() const;
int numBoxes() const;
int boxSize() const;
int maxParty() const;
@@ -105,6 +107,7 @@ class POKEMOD_EXPORT Rules : public Object
bool m_genderAllowed;
bool m_breedingAllowed;
bool m_criticalDomains;
+ bool m_useTurns;
int m_numBoxes;
int m_boxSize;
int m_maxParty;
diff --git a/pokemodr/AbilityUI.cpp b/pokemodr/AbilityUI.cpp
index 1768a83e..e4f6abc5 100644
--- a/pokemodr/AbilityUI.cpp
+++ b/pokemodr/AbilityUI.cpp
@@ -35,6 +35,7 @@ Pokemodr::AbilityUI::~AbilityUI()
void Pokemodr::AbilityUI::setGui()
{
varName->setText(static_cast<Pokemod::Ability*>(modified())->name());
+ varPriority->setValue(static_cast<Pokemod::Ability*>(modified())->priority());
varDescription->setText(static_cast<Pokemod::Ability*>(modified())->description());
varScript->setValue(static_cast<Pokemod::Ability*>(modified())->script());
}
@@ -59,6 +60,11 @@ void Pokemodr::AbilityUI::on_varName_textChanged(const QString& name)
varName->setCursorPosition(cursor);
}
+void Pokemodr::AbilityUI::on_varPriority_valueChanged(const int priority)
+{
+ static_cast<Pokemod::Ability*>(modified())->setPriority(priority);
+}
+
void Pokemodr::AbilityUI::on_varDescription_textChanged(const QString& description)
{
static_cast<Pokemod::Ability*>(modified())->setDescription(description);
diff --git a/pokemodr/AbilityUI.h b/pokemodr/AbilityUI.h
index e4275cc9..1fc4ff97 100644
--- a/pokemodr/AbilityUI.h
+++ b/pokemodr/AbilityUI.h
@@ -44,6 +44,7 @@ class AbilityUI : public ObjectUI, private Ui::formAbility
void discard();
protected slots:
void on_varName_textChanged(const QString& name);
+ void on_varPriority_valueChanged(const int priority);
void on_varDescription_textChanged(const QString& description);
void on_varScript_valueChanged(const Pokemod::Script& script);
private slots:
diff --git a/pokemodr/MapEffectUI.cpp b/pokemodr/MapEffectUI.cpp
index ad3585de..1db1ae64 100644
--- a/pokemodr/MapEffectUI.cpp
+++ b/pokemodr/MapEffectUI.cpp
@@ -72,7 +72,7 @@ void Pokemodr::MapEffectUI::on_varName_textChanged(const QString& name)
varName->setCursorPosition(cursor);
}
-void Pokemodr::MapEffectUI::on_varCoordinate_valueChanged(const Pokemod::Point& coordinate)
+void Pokemodr::MapEffectUI::on_varCoordinate_valueChanged(const QPoint& coordinate)
{
static_cast<Pokemod::MapEffect*>(modified())->setCoordinate(coordinate);
}
diff --git a/pokemodr/MapEffectUI.h b/pokemodr/MapEffectUI.h
index 79fbd1ce..d3ef1686 100644
--- a/pokemodr/MapEffectUI.h
+++ b/pokemodr/MapEffectUI.h
@@ -44,7 +44,7 @@ class MapEffectUI : public ObjectUI, private Ui::formMapEffect
void discard();
protected slots:
void on_varName_textChanged(const QString& name);
- void on_varCoordinate_valueChanged(const Pokemod::Point& coordinate);
+ void on_varCoordinate_valueChanged(const QPoint& coordinate);
void on_varSkin_pressed();
void on_varScript_valueChanged(const Pokemod::Script& script);
void on_varIsGhost_clicked(const bool isGhost);
diff --git a/pokemodr/MapTrainerUI.cpp b/pokemodr/MapTrainerUI.cpp
index 7111d155..b09b3315 100644
--- a/pokemodr/MapTrainerUI.cpp
+++ b/pokemodr/MapTrainerUI.cpp
@@ -95,7 +95,7 @@ void Pokemodr::MapTrainerUI::on_varTrainerClass_activated(const int trainerClass
static_cast<Pokemod::MapTrainer*>(modified())->setTrainerClass(varTrainerClass->itemData(trainerClass).toInt());
}
-void Pokemodr::MapTrainerUI::on_varCoordinate_valueChanged(const Pokemod::Point& coordinate)
+void Pokemodr::MapTrainerUI::on_varCoordinate_valueChanged(const QPoint& coordinate)
{
static_cast<Pokemod::MapTrainer*>(modified())->setCoordinate(coordinate);
}
diff --git a/pokemodr/MapTrainerUI.h b/pokemodr/MapTrainerUI.h
index ab1e052c..40593992 100644
--- a/pokemodr/MapTrainerUI.h
+++ b/pokemodr/MapTrainerUI.h
@@ -45,7 +45,7 @@ class MapTrainerUI : public ObjectUI, private Ui::formMapTrainer
protected slots:
void on_varName_textChanged(const QString& name);
void on_varTrainerClass_activated(const int trainerClass);
- void on_varCoordinate_valueChanged(const Pokemod::Point& coordinate);
+ void on_varCoordinate_valueChanged(const QPoint& coordinate);
void on_varNumberFight_valueChanged(const int numberFight);
void on_varScript_valueChanged(const Pokemod::Script& script);
void on_varLeadTeamMember_activated(const int leadTeamMember);
diff --git a/pokemodr/MapWarpUI.cpp b/pokemodr/MapWarpUI.cpp
index 33c4e070..4cd471c2 100644
--- a/pokemodr/MapWarpUI.cpp
+++ b/pokemodr/MapWarpUI.cpp
@@ -96,7 +96,7 @@ void Pokemodr::MapWarpUI::on_varName_textChanged(const QString& name)
varName->setCursorPosition(cursor);
}
-void Pokemodr::MapWarpUI::on_varCoordinate_valueChanged(const Pokemod::Point& coordinate)
+void Pokemodr::MapWarpUI::on_varCoordinate_valueChanged(const QPoint& coordinate)
{
static_cast<Pokemod::MapWarp*>(modified())->setCoordinate(coordinate);
}
diff --git a/pokemodr/MapWarpUI.h b/pokemodr/MapWarpUI.h
index 69159603..1d2186f1 100644
--- a/pokemodr/MapWarpUI.h
+++ b/pokemodr/MapWarpUI.h
@@ -44,7 +44,7 @@ class MapWarpUI : public ObjectUI, private Ui::formMapWarp
void discard();
protected slots:
void on_varName_textChanged(const QString& name);
- void on_varCoordinate_valueChanged(const Pokemod::Point& coordinate);
+ void on_varCoordinate_valueChanged(const QPoint& coordinate);
void on_varType_activated(const int type);
void on_varToMap_activated(const int toMap);
void on_varToWarp_activated(const int toWarp);
diff --git a/pokemodr/MoveUI.cpp b/pokemodr/MoveUI.cpp
index 97a9fd00..f4f9ce1a 100644
--- a/pokemodr/MoveUI.cpp
+++ b/pokemodr/MoveUI.cpp
@@ -47,6 +47,7 @@ void Pokemodr::MoveUI::refreshGui()
void Pokemodr::MoveUI::setGui()
{
varName->setText(static_cast<Pokemod::Move*>(modified())->name());
+ varPriority->setValue(static_cast<Pokemod::Move*>(modified())->priority());
varAccuracy->setValue(static_cast<Pokemod::Move*>(modified())->accuracy());
varPower->setValue(static_cast<Pokemod::Move*>(modified())->power());
varType->setCurrentIndex(varType->findData(static_cast<Pokemod::Move*>(modified())->type()));
@@ -77,6 +78,11 @@ void Pokemodr::MoveUI::on_varName_textChanged(const QString& name)
varName->setCursorPosition(cursor);
}
+void Pokemodr::MoveUI::on_varPriority_valueChanged(const int priority)
+{
+ static_cast<Pokemod::Move*>(modified())->setPriority(priority);
+}
+
void Pokemodr::MoveUI::on_varAccuracy_valueChanged(const Pokemod::Fraction& accuracy)
{
static_cast<Pokemod::Move*>(modified())->setAccuracy(accuracy);
diff --git a/pokemodr/MoveUI.h b/pokemodr/MoveUI.h
index 95fc7806..f22c2c35 100644
--- a/pokemodr/MoveUI.h
+++ b/pokemodr/MoveUI.h
@@ -44,6 +44,7 @@ class MoveUI : public ObjectUI, private Ui::formMove
void discard();
protected slots:
void on_varName_textChanged(const QString& name);
+ void on_varPriority_valueChanged(const int priority);
void on_varAccuracy_valueChanged(const Pokemod::Fraction& accuracy);
void on_varPower_valueChanged(const int power);
void on_varType_activated(const int type);
diff --git a/pokemodr/NatureUI.cpp b/pokemodr/NatureUI.cpp
index 67a0390c..6b15b33f 100644
--- a/pokemodr/NatureUI.cpp
+++ b/pokemodr/NatureUI.cpp
@@ -43,7 +43,8 @@ void Pokemodr::NatureUI::refreshGui()
{
varStat->clear();
const bool isSplit = pokemod()->rules()->specialSplit();
- varStat->addItems((isSplit ? Pokemod::StatGSCStr : Pokemod::StatRBYStr).mid(0, isSplit ? Pokemod::ST_End_RBY : Pokemod::ST_End_GSC));
+ for (int i = Pokemod::ST_No_HP_Start; i < isSplit ? Pokemod::ST_End_RBY : Pokemod::ST_End_GSC; ++i)
+ varStat->addItem((isSplit ? Pokemod::StatGSCStr : Pokemod::StatRBYStr)[i], i);
}
void Pokemodr::NatureUI::setGui()
diff --git a/pokemodr/PointWidget.cpp b/pokemodr/PointWidget.cpp
index 47209153..82168925 100644
--- a/pokemodr/PointWidget.cpp
+++ b/pokemodr/PointWidget.cpp
@@ -18,29 +18,29 @@
// Header include
#include "PointWidget.h"
-Pokemodr::PointWidget::PointWidget(QWidget* parent, const Pokemod::Point& value) :
+Pokemodr::PointWidget::PointWidget(QWidget* parent, const QPoint& value) :
QWidget(parent),
m_value(value)
{
setupUi(this);
}
-Pokemod::Point Pokemodr::PointWidget::value() const
+QPoint Pokemodr::PointWidget::value() const
{
return m_value;
}
-void Pokemodr::PointWidget::setValue(const Pokemod::Point& value)
+void Pokemodr::PointWidget::setValue(const QPoint& value)
{
if (m_value == value)
return;
m_value = value;
varX->setValue(m_value.x());
varY->setValue(m_value.y());
- emit(valueChanged(true));
+ emit(valueChanged(m_value));
}
-void Pokemodr::PointWidget::setMaximum(const Pokemod::Point& maximum)
+void Pokemodr::PointWidget::setMaximum(const QPoint& maximum)
{
varX->setMaximum(maximum.x());
varY->setMaximum(maximum.y());
@@ -49,11 +49,11 @@ void Pokemodr::PointWidget::setMaximum(const Pokemod::Point& maximum)
void Pokemodr::PointWidget::on_varX_valueChanged(const int x)
{
m_value.setX(x);
- emit(valueChanged(true));
+ emit(valueChanged(m_value));
}
void Pokemodr::PointWidget::on_varY_valueChanged(const int y)
{
m_value.setY(y);
- emit(valueChanged(true));
+ emit(valueChanged(m_value));
}
diff --git a/pokemodr/PointWidget.h b/pokemodr/PointWidget.h
index 4300dbb1..20cf9031 100644
--- a/pokemodr/PointWidget.h
+++ b/pokemodr/PointWidget.h
@@ -18,10 +18,8 @@
#ifndef __POKEMODR_POINTWIDGET__
#define __POKEMODR_POINTWIDGET__
-// Pokemod includes
-#include "../pokemod/Point.h"
-
// Qt includes
+#include <QtCore/QPoint>
#include <QtGui/QWidget>
// Form include
@@ -34,19 +32,19 @@ class PointWidget : public QWidget, private Ui::formPoint
Q_OBJECT
public:
- PointWidget(QWidget* parent, const Pokemod::Point& value = Pokemod::Point(0, 0));
+ PointWidget(QWidget* parent, const QPoint& value = QPoint(0, 0));
- Pokemod::Point value() const;
+ QPoint value() const;
signals:
- void valueChanged(const Pokemod::Point&);
+ void valueChanged(const QPoint&);
public slots:
- void setValue(const Pokemod::Point& value);
- void setMaximum(const Pokemod::Point& maximum);
+ void setValue(const QPoint& value);
+ void setMaximum(const QPoint& maximum);
protected slots:
void on_varX_valueChanged(const int x);
void on_varY_valueChanged(const int y);
private:
- Pokemod::Point m_value;
+ QPoint m_value;
};
}
diff --git a/pokemodr/RulesUI.cpp b/pokemodr/RulesUI.cpp
index ca733e9e..c6f65655 100644
--- a/pokemodr/RulesUI.cpp
+++ b/pokemodr/RulesUI.cpp
@@ -39,6 +39,7 @@ void Pokemodr::RulesUI::setGui()
varCriticalDomains->setChecked(static_cast<Pokemod::Rules*>(modified())->criticalDomains() ? Qt::Checked : Qt::Unchecked);
varHardCash->setChecked(static_cast<Pokemod::Rules*>(modified())->hardCash() ? Qt::Checked : Qt::Unchecked);
varSwitchStyle->setChecked(static_cast<Pokemod::Rules*>(modified())->allowSwitchStyle() ? Qt::Checked : Qt::Unchecked);
+ varUseTurns->setChecked(static_cast<Pokemod::Rules*>(modified())->useTurns() ? Qt::Checked : Qt::Unchecked);
boxSplitSpecial->setChecked(static_cast<Pokemod::Rules*>(modified())->specialSplit() ? Qt::Checked : Qt::Unchecked);
varSplitSpecialDV->setCheckState(static_cast<Pokemod::Rules*>(modified())->specialDVSplit() ? Qt::Checked : Qt::Unchecked);
boxHappiness->setChecked(static_cast<Pokemod::Rules*>(modified())->happiness() ? Qt::Checked : Qt::Unchecked);
@@ -105,6 +106,11 @@ void Pokemodr::RulesUI::on_varSwitchStyle_toggled(const bool switchStyle)
static_cast<Pokemod::Rules*>(modified())->setAllowSwitchStyle(switchStyle);
}
+void Pokemodr::RulesUI::on_varUseTurns_toggled(const bool useTurns)
+{
+ static_cast<Pokemod::Rules*>(modified())->setUseTurns(useTurns);
+}
+
void Pokemodr::RulesUI::on_boxSplitSpecial_toggled(const bool splitSpecial)
{
static_cast<Pokemod::Rules*>(modified())->setSpecialSplit(splitSpecial);
diff --git a/pokemodr/RulesUI.h b/pokemodr/RulesUI.h
index 9b4c5941..7097c7e1 100644
--- a/pokemodr/RulesUI.h
+++ b/pokemodr/RulesUI.h
@@ -48,6 +48,7 @@ class RulesUI : public ObjectUI, private Ui::formRules
void on_varCriticalDomains_toggled(const bool criticalDomains);
void on_varHardCash_toggled(const bool hardCash);
void on_varSwitchStyle_toggled(const bool switchStyle);
+ void on_varUseTurns_toggled(const bool useTurns);
void on_boxSplitSpecial_toggled(const bool specialSplit);
void on_varSplitSpecialDV_toggled(const bool specialSplitDV);
void on_boxHappiness_toggled(const bool happiness);
diff --git a/pokemodr/gui/ability.ui b/pokemodr/gui/ability.ui
index 90f23107..2e08101d 100644
--- a/pokemodr/gui/ability.ui
+++ b/pokemodr/gui/ability.ui
@@ -22,6 +22,22 @@
</widget>
</item>
<item>
+ <widget class="QGroupBox" name="boxPriority" >
+ <property name="title" >
+ <string>Priority</string>
+ </property>
+ <layout class="QHBoxLayout" >
+ <item>
+ <widget class="KIntNumInput" name="varPriority" >
+ <property name="toolTip" >
+ <string>The priority of the ability (lower goes first)</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<widget class="QGroupBox" name="boxDescription" >
<property name="title" >
<string>Description</string>
@@ -67,6 +83,11 @@
<header location="global" >KLineEdit</header>
</customwidget>
<customwidget>
+ <class>KIntNumInput</class>
+ <extends>QWidget</extends>
+ <header location="global" >KIntNumInput</header>
+ </customwidget>
+ <customwidget>
<class>Pokemodr::ScriptWidget</class>
<extends>QWidget</extends>
<header>ScriptWidget.h</header>
diff --git a/pokemodr/gui/fraction.ui b/pokemodr/gui/fraction.ui
index 51bd76f9..32b660c9 100644
--- a/pokemodr/gui/fraction.ui
+++ b/pokemodr/gui/fraction.ui
@@ -10,24 +10,28 @@
</widget>
</item>
<item>
- <widget class="KIntNumInput" name="varNumerator" >
- <property name="label" >
- <string>Numerator</string>
- </property>
- <property name="minimum" >
- <number>0</number>
- </property>
- </widget>
- </item>
- <item>
- <widget class="KIntNumInput" name="varDenominator" >
- <property name="label" >
- <string>Denominator</string>
- </property>
- <property name="minimum" >
- <number>1</number>
- </property>
- </widget>
+ <layout class="QHBoxLayout" >
+ <item>
+ <widget class="KIntNumInput" name="varNumerator" >
+ <property name="label" >
+ <string>Numerator</string>
+ </property>
+ <property name="minimum" >
+ <number>0</number>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="KIntNumInput" name="varDenominator" >
+ <property name="label" >
+ <string>Denominator</string>
+ </property>
+ <property name="minimum" >
+ <number>1</number>
+ </property>
+ </widget>
+ </item>
+ </layout>
</item>
</layout>
</widget>
diff --git a/pokemodr/gui/map.ui b/pokemodr/gui/map.ui
index 9f9883d5..d125e1ea 100644
--- a/pokemodr/gui/map.ui
+++ b/pokemodr/gui/map.ui
@@ -29,6 +29,9 @@
<property name="checkable" >
<bool>true</bool>
</property>
+ <property name="checked" >
+ <bool>false</bool>
+ </property>
<layout class="QHBoxLayout" >
<item>
<widget class="KComboBox" name="varFlyWarp" >
@@ -58,35 +61,37 @@
</item>
<item>
<widget class="QGroupBox" name="boxTilemap" >
+ <property name="sizePolicy" >
+ <sizepolicy vsizetype="Expanding" hsizetype="Preferred" >
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
<property name="title" >
<string>Tilemap</string>
</property>
<layout class="QGridLayout" >
- <item rowspan="6" row="0" column="0" >
+ <item rowspan="7" row="0" column="0" >
<widget class="QTableView" name="varTilemap" >
<property name="selectionMode" >
<enum>QAbstractItemView::SingleSelection</enum>
</property>
</widget>
</item>
- <item row="0" column="1" >
- <widget class="KPushButton" name="buttonAddRow" >
- <property name="text" >
- <string>Add Row</string>
- </property>
- </widget>
+ <item row="6" column="1" >
+ <widget class="KComboBox" name="varTile" />
</item>
- <item row="1" column="1" >
- <widget class="KPushButton" name="buttonInsertRow" >
+ <item row="5" column="1" >
+ <widget class="KPushButton" name="buttonDeleteColumn" >
<property name="text" >
- <string>Insert Row</string>
+ <string>Delete Column</string>
</property>
</widget>
</item>
- <item row="2" column="1" >
- <widget class="KPushButton" name="buttonDeleteRow" >
+ <item row="4" column="1" >
+ <widget class="KPushButton" name="buttonInsertColumn" >
<property name="text" >
- <string>Delete Row</string>
+ <string>Insert Column</string>
</property>
</widget>
</item>
@@ -97,39 +102,30 @@
</property>
</widget>
</item>
- <item row="4" column="1" >
- <widget class="KPushButton" name="buttonInsertColumn" >
+ <item row="2" column="1" >
+ <widget class="KPushButton" name="buttonDeleteRow" >
<property name="text" >
- <string>Insert Column</string>
+ <string>Delete Row</string>
</property>
</widget>
</item>
- <item row="5" column="1" >
- <widget class="KPushButton" name="buttonDeleteColumn" >
+ <item row="1" column="1" >
+ <widget class="KPushButton" name="buttonInsertRow" >
<property name="text" >
- <string>Delete Column</string>
+ <string>Insert Row</string>
</property>
</widget>
</item>
- <item row="6" column="0" colspan="2" >
- <widget class="KComboBox" name="varTile" />
+ <item row="0" column="1" >
+ <widget class="KPushButton" name="buttonAddRow" >
+ <property name="text" >
+ <string>Add Row</string>
+ </property>
+ </widget>
</item>
</layout>
</widget>
</item>
- <item>
- <spacer>
- <property name="orientation" >
- <enum>Qt::Vertical</enum>
- </property>
- <property name="sizeHint" >
- <size>
- <width>0</width>
- <height>1</height>
- </size>
- </property>
- </spacer>
- </item>
</layout>
</widget>
<customwidgets>
diff --git a/pokemodr/gui/move.ui b/pokemodr/gui/move.ui
index ca2f7ab7..a0495ad6 100644
--- a/pokemodr/gui/move.ui
+++ b/pokemodr/gui/move.ui
@@ -22,6 +22,22 @@
</widget>
</item>
<item>
+ <widget class="QGroupBox" name="boxPriority" >
+ <property name="title" >
+ <string>Priority</string>
+ </property>
+ <layout class="QHBoxLayout" >
+ <item>
+ <widget class="KIntNumInput" name="varPriority" >
+ <property name="toolTip" >
+ <string>The priority of the move (lower goes first)</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
+ <item>
<widget class="QGroupBox" name="boxAccuracy" >
<property name="title" >
<string>Accuracy</string>
diff --git a/pokemodr/gui/point.ui b/pokemodr/gui/point.ui
index 13b71c63..a52bf955 100644
--- a/pokemodr/gui/point.ui
+++ b/pokemodr/gui/point.ui
@@ -1,7 +1,7 @@
<ui version="4.0" >
<class>formPoint</class>
<widget class="QWidget" name="formPoint" >
- <layout class="QVBoxLayout" >
+ <layout class="QHBoxLayout" >
<item>
<widget class="KIntNumInput" name="varX" >
<property name="label" >
diff --git a/pokemodr/gui/rules.ui b/pokemodr/gui/rules.ui
index bfac7a4a..29f65b62 100644
--- a/pokemodr/gui/rules.ui
+++ b/pokemodr/gui/rules.ui
@@ -62,11 +62,24 @@
</item>
<item>
<widget class="QCheckBox" name="varSwitchStyle" >
+ <property name="toolTip" >
+ <string>If checked, the player will be able to switch after knocking an enemy out</string>
+ </property>
<property name="text" >
<string>Switch Style</string>
</property>
</widget>
</item>
+ <item>
+ <widget class="QCheckBox" name="varUseTurns" >
+ <property name="toolTip" >
+ <string>If checked, battle rounds will use strict ordering due to speed, otherwise the speed will fill a "ready" bar</string>
+ </property>
+ <property name="text" >
+ <string>Use Turns</string>
+ </property>
+ </widget>
+ </item>
</layout>
</widget>
</item>