summaryrefslogtreecommitdiffstats
path: root/pokemod
diff options
context:
space:
mode:
authorBen Boeckel <MathStuf@gmail.com>2008-05-19 03:27:00 +0000
committerBen Boeckel <MathStuf@gmail.com>2008-05-19 03:27:00 +0000
commite6bd0fad66fcce1a81d5b61ba6afd856d8f84d67 (patch)
tree5a33febc4ec0f5efe270bed38f4c7c451694ead4 /pokemod
parentc0634abfb225376249023faf524f5252f47f5090 (diff)
downloadsigen-e6bd0fad66fcce1a81d5b61ba6afd856d8f84d67.tar.gz
sigen-e6bd0fad66fcce1a81d5b61ba6afd856d8f84d67.tar.xz
sigen-e6bd0fad66fcce1a81d5b61ba6afd856d8f84d67.zip
[FIX] general is now merged into pokemod
[FIX] Added ItemEffect widget code git-svn-id: https://pokegen.svn.sourceforge.net/svnroot/pokegen/trunk@153 6ecfd1a5-f3ed-3746-8530-beee90d26b22
Diffstat (limited to 'pokemod')
-rw-r--r--pokemod/AbilityEffect.cpp1
-rw-r--r--pokemod/AbilityEffect.h4
-rw-r--r--pokemod/Badge.cpp1
-rw-r--r--pokemod/Badge.h4
-rw-r--r--pokemod/Dialog.cpp3
-rw-r--r--pokemod/Flag.cpp58
-rw-r--r--pokemod/Flag.h66
-rw-r--r--pokemod/Fraction.cpp35
-rw-r--r--pokemod/Fraction.h87
-rw-r--r--pokemod/Hat.h90
-rw-r--r--pokemod/Item.cpp1
-rw-r--r--pokemod/ItemEffect.cpp1
-rw-r--r--pokemod/ItemEffect.h4
-rw-r--r--pokemod/Map.h4
-rw-r--r--pokemod/MapEffect.h6
-rw-r--r--pokemod/MapTrainer.cpp1
-rw-r--r--pokemod/MapTrainer.h6
-rw-r--r--pokemod/MapTrainerTeamMember.cpp1
-rw-r--r--pokemod/MapWarp.h6
-rw-r--r--pokemod/MapWildListEncounter.cpp1
-rw-r--r--pokemod/Matrix.h210
-rw-r--r--pokemod/Move.cpp1
-rw-r--r--pokemod/Move.h4
-rw-r--r--pokemod/MoveEffect.h4
-rw-r--r--pokemod/Nature.cpp1
-rw-r--r--pokemod/Nature.h4
-rw-r--r--pokemod/Point.h78
-rw-r--r--pokemod/Pokemod.cpp1
-rw-r--r--pokemod/Pokemod.h8
-rw-r--r--pokemod/Rules.h4
-rw-r--r--pokemod/Species.cpp1
-rw-r--r--pokemod/Species.h4
-rw-r--r--pokemod/SpeciesEvolution.cpp1
-rw-r--r--pokemod/SpeciesMove.cpp1
-rw-r--r--pokemod/Tile.h4
-rw-r--r--pokemod/Type.h4
-rw-r--r--pokemod/pokemod.pro15
37 files changed, 667 insertions, 58 deletions
diff --git a/pokemod/AbilityEffect.cpp b/pokemod/AbilityEffect.cpp
index b7532e2d..df33be3b 100644
--- a/pokemod/AbilityEffect.cpp
+++ b/pokemod/AbilityEffect.cpp
@@ -22,6 +22,7 @@
#include "Ability.h"
#include "Type.h"
#include "Pokemod.h"
+#include "Rules.h"
const QStringList AbilityEffect::EffectStr = QStringList() << "Damage to HP" << "Prevent Damage" << "Auto Heal" << "Deal Damage" << "Wilds" << "Stat" << "Status" << "Ability" << "Accuracy/Power Trade" << "Bullseye" << "Item Effect" << "Type" << "Fast Hatch" << "Weather";
const QStringList AbilityEffect::TriggerStr = QStringList() << "Anything" << "Contact" << "Weather" << "Damage" << "Type" << "HP Boundary" << "Stat Change" << "Status";
diff --git a/pokemod/AbilityEffect.h b/pokemod/AbilityEffect.h
index 17b6d027..d855cdc8 100644
--- a/pokemod/AbilityEffect.h
+++ b/pokemod/AbilityEffect.h
@@ -19,11 +19,9 @@
#define __POKEMOD_ABILITYEFFECT__
// Pokemod includes
+#include "Fraction.h"
#include "Object.h"
-// General includes
-#include "../general/Fraction.h"
-
// Qt includes
#include <QStringList>
diff --git a/pokemod/Badge.cpp b/pokemod/Badge.cpp
index f4518f0d..75df4b73 100644
--- a/pokemod/Badge.cpp
+++ b/pokemod/Badge.cpp
@@ -17,6 +17,7 @@
// Header include
#include "Badge.h"
+#include "Rules.h"
// Qt includes
#include <QBuffer>
diff --git a/pokemod/Badge.h b/pokemod/Badge.h
index 70b5c528..988fea9a 100644
--- a/pokemod/Badge.h
+++ b/pokemod/Badge.h
@@ -19,12 +19,10 @@
#define __POKEMOD_BADGE__
// Pokemod includes
+#include "Fraction.h"
#include "Object.h"
#include "Pokemod.h"
-// General includes
-#include "../general/Fraction.h"
-
// Qt includes
#include <QPixmap>
diff --git a/pokemod/Dialog.cpp b/pokemod/Dialog.cpp
index 15607831..a755fbf2 100644
--- a/pokemod/Dialog.cpp
+++ b/pokemod/Dialog.cpp
@@ -26,8 +26,9 @@
#include "MapTrainer.h"
#include "MapWarp.h"
#include "Move.h"
-#include "Species.h"
#include "Pokemod.h"
+#include "Rules.h"
+#include "Species.h"
const QStringList Dialog::CommandStr = QStringList() << "Flip Flag" << "Set Flag" << "Unset Flag" << "Randomize Flag" << "Test Flag" << "Dialog" << "Yes/No" << "Item Shop" << "Give Item" << "Take Item" << "Check Item" << "Coin List" << "Teach Move" << "Delete Move" << "Give Pokemon" << "Take Pokemon" << "Show Pokemon" << "View Pokemon" << "Give Money" << "Take Money" << "Move Effect" << "Turn Effect" << "Check Direction" << "Check Roster" << "Check Levels" << "Check Species" << "Check Held Items" << "Check Money" << "Trade" << "Daycare" << "Battle" << "Badge" << "Warp" << "Name" << "Music" << "Sound Effect" << "Timer" << "Map Sign" << "Wild Scope" << "Safari" << "Heal Party" << "Refresh" << "Clear" << "Pause" << "New Line" << "Exit" << "Menu";
const QStringList Dialog::CommandAbbrStr = QStringList() << "FF" << "SF" << "UF" << "RF" << "TF" << "D" << "YN" << "ItS" << "GIt" << "TIt" << "CIt" << "CL" << "TMv" << "DMv" << "GPk" << "TPk" << "SPk" << "VPk" << "G$" << "T$" << "MvEf" << "TEf" << "CD" << "CR" << "CLv" << "CS" << "CHIt" << "C$" << "T" << "Dc" << "Bat" << "Bdg" << "W" << "N" << "Ms" << "SFX" << "Tmr" << "MS" << "WS" << "S" << "HP" << "R" << "C" << "P" << "NL" << "X" << "M";
diff --git a/pokemod/Flag.cpp b/pokemod/Flag.cpp
new file mode 100644
index 00000000..e08ba9f0
--- /dev/null
+++ b/pokemod/Flag.cpp
@@ -0,0 +1,58 @@
+/*
+ * 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/>.
+ */
+
+// Header include
+#include "Flag.h"
+
+const QStringList Flag::ValueStr = QStringList() << "Off" << "On" << "Ignore";
+
+Flag::Flag(const int flag, const int status) :
+ m_flag(flag)
+{
+ setStatus(status);
+}
+
+void Flag::set(const int flag, const int status)
+{
+ setFlag(flag);
+ setStatus(status);
+}
+
+void Flag::setFlag(const int flag)
+{
+ m_flag = flag;
+}
+
+void Flag::setStatus(const int status)
+{
+ if (End <= status)
+ {
+ m_status = Ignore;
+ return;
+ }
+ m_status = status;
+}
+
+int Flag::flag() const
+{
+ return m_flag;
+}
+
+int Flag::status() const
+{
+ return m_status;
+}
diff --git a/pokemod/Flag.h b/pokemod/Flag.h
new file mode 100644
index 00000000..55b3a73d
--- /dev/null
+++ b/pokemod/Flag.h
@@ -0,0 +1,66 @@
+/*
+ * 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 __FLAG__
+#define __FLAG__
+
+// Qt includes
+#include <QStringList>
+
+class Flag
+{
+ public:
+ enum
+ {
+ Off,
+ On,
+ Ignore,
+ End
+ };
+ static const QStringList ValueStr;
+
+ Flag(const int flag = 0, const int status = Off);
+
+ void set(const int flag, const int status);
+ void setFlag(const int flag);
+ void setStatus(const int status);
+
+ int flag() const;
+ int status() const;
+
+ inline Flag& operator=(const Flag& rhs)
+ {
+ if (this == &rhs)
+ return *this;
+ m_flag = rhs.m_flag;
+ m_status = rhs.m_status;
+ return *this;
+ }
+ inline bool operator==(const Flag& rhs) const
+ {
+ return ((m_flag == rhs.m_flag) && (m_status == rhs.m_status));
+ }
+ inline bool operator!=(const Flag& rhs) const
+ {
+ return !(*this == rhs);
+ }
+ private:
+ int m_flag;
+ int m_status;
+};
+
+#endif
diff --git a/pokemod/Fraction.cpp b/pokemod/Fraction.cpp
new file mode 100644
index 00000000..a4a41e7d
--- /dev/null
+++ b/pokemod/Fraction.cpp
@@ -0,0 +1,35 @@
+/*
+ * 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/>.
+ */
+
+// Header include
+#include "Fraction.h"
+
+void Fraction::set(const int numerator, const int denominator)
+{
+ m_numerator = numerator;
+ m_denominator = denominator;
+}
+
+void Fraction::reduce()
+{
+ int i = m_numerator;
+ int j = m_denominator;
+ while (i - j)
+ (i > j) ? (i -= j) : (j -= i);
+ m_numerator /= i;
+ m_denominator /= i;
+}
diff --git a/pokemod/Fraction.h b/pokemod/Fraction.h
new file mode 100644
index 00000000..2c1dc663
--- /dev/null
+++ b/pokemod/Fraction.h
@@ -0,0 +1,87 @@
+/*
+ * 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 __FRAC__
+#define __FRAC__
+
+// Qt includes
+#include <QMetaType>
+
+class Fraction
+{
+ public:
+ inline Fraction()
+ {
+ set(1, 1);
+ }
+ inline Fraction(const int numerator, const int denominator)
+ {
+ set(numerator, denominator);
+ }
+
+ void set(const int numerator, const int denominator);
+ inline void setNumerator(const int numerator)
+ {
+ set(numerator, m_denominator);
+ }
+ inline void setDenominator(const int denominator)
+ {
+ set(m_numerator, denominator);
+ }
+
+ inline int numerator() const
+ {
+ return m_numerator;
+ }
+ inline int denominator() const
+ {
+ return m_denominator;
+ }
+
+ void reduce();
+
+ inline operator double() const
+ {
+ return (double(m_numerator) / m_denominator);
+ }
+ inline Fraction operator*(const Fraction& rhs) const
+ {
+ return Fraction(m_numerator * rhs.m_numerator, m_denominator * rhs.m_denominator);
+ }
+ inline Fraction& operator=(const Fraction& rhs)
+ {
+ if (this == &rhs)
+ return *this;
+ m_numerator = rhs.m_numerator;
+ m_denominator = rhs.m_denominator;
+ return *this;
+ }
+ inline bool operator==(const Fraction& rhs) const
+ {
+ return ((m_numerator == rhs.m_numerator) && (m_denominator == rhs.m_denominator));
+ }
+ inline bool operator!=(const Fraction& rhs) const
+ {
+ return !(*this == rhs);
+ }
+ private:
+ int m_numerator;
+ int m_denominator;
+};
+Q_DECLARE_METATYPE(Fraction)
+
+#endif
diff --git a/pokemod/Hat.h b/pokemod/Hat.h
new file mode 100644
index 00000000..2b7fccea
--- /dev/null
+++ b/pokemod/Hat.h
@@ -0,0 +1,90 @@
+/*
+ * 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 __HAT__
+#define __HAT__
+
+// Qt includes
+#include <QtGlobal>
+#include <QDateTime>
+#include <QMap>
+
+template<class T> class Hat
+{
+ public:
+ Hat() :
+ m_count(0)
+ {
+ qsrand(QDateTime().toTime_t());
+ }
+
+ T pick() const
+ {
+ int choice = qrand() % m_count;
+ foreach (T key, m_objects.keys())
+ {
+ choice -= m_objects[key];
+ if (choice < 0)
+ break;
+ }
+ return key;
+ }
+ T take()
+ {
+ T chosen = pick();
+ if (!(--m_objects[chosen]))
+ m_objects.erase(chosen);
+ --m_count;
+ return chosen;
+ }
+ void setCount(const T& key, const unsigned weight)
+ {
+ if (m_objects.contains(key))
+ m_count -= m_objects[key];
+ m_objects[key] = weight;
+ m_count += weight;
+ }
+ void add(const T& key, const unsigned weight)
+ {
+ m_objects[key] += weight;
+ m_count += weight;
+ }
+ unsigned count() const
+ {
+ return m_count;
+ }
+ unsigned count(const T& key) const
+ {
+ if (m_objects.contains(key))
+ return m_objects[key];
+ return 0;
+ }
+ double chance(const T& key) const
+ {
+ return (double(count(key)) / m_count);
+ }
+
+ unsigned operator[](const T& key) const
+ {
+ return count(key);
+ }
+ private:
+ QMap<T, unsigned> m_objects;
+ unsigned m_count;
+};
+
+#endif
diff --git a/pokemod/Item.cpp b/pokemod/Item.cpp
index 777f5856..d76d74ec 100644
--- a/pokemod/Item.cpp
+++ b/pokemod/Item.cpp
@@ -21,6 +21,7 @@
// Pokemod includes
#include "ItemEffect.h"
#include "Pokemod.h"
+#include "Rules.h"
// Qt includes
#include <QSet>
diff --git a/pokemod/ItemEffect.cpp b/pokemod/ItemEffect.cpp
index cd9266a3..eed64e62 100644
--- a/pokemod/ItemEffect.cpp
+++ b/pokemod/ItemEffect.cpp
@@ -22,6 +22,7 @@
#include "Item.h"
#include "MapWildList.h"
#include "Pokemod.h"
+#include "Rules.h"
const QStringList ItemEffect::EffectStr = QStringList() << "HP Cure" << "Revive" << "Cure Status" << "Level Boost" << "Stat Boost" << "Flinch" << "Go First" << "Keep Alive" << "Modify Stat (Battle Only)" << "Shield (Battle Only)" << "Run (Battle Only)" << "PP Boost" << "Type Boost" << "PP Restore" << "Experience Share" << "Fishing Rod" << "Repel" << "Escape" << "TM" << "HM" << "Map" << "Ball" << "Itemfinder" << "Bike" << "Scope" << "Coin" << "Coin Case" << "Berry" << "Acorn";
const QStringList ItemEffect::RelativeStr = QStringList() << "Absolute" << "Relative";
diff --git a/pokemod/ItemEffect.h b/pokemod/ItemEffect.h
index 456ef3ad..5ce5af21 100644
--- a/pokemod/ItemEffect.h
+++ b/pokemod/ItemEffect.h
@@ -19,11 +19,9 @@
#define __POKEMOD_ITEMEFFECT__
// Pokemod include
+#include "Fraction.h"
#include "Object.h"
-// General includes
-#include "../general/Fraction.h"
-
// Qt includes
#include <QStringList>
diff --git a/pokemod/Map.h b/pokemod/Map.h
index 355257f4..09280a69 100644
--- a/pokemod/Map.h
+++ b/pokemod/Map.h
@@ -19,11 +19,9 @@
#define __POKEMOD_MAP__
// Pokemod includes
+#include "Matrix.h"
#include "Object.h"
-// General includes
-#include "../general/Matrix.h"
-
// Qt includes
#include <QList>
diff --git a/pokemod/MapEffect.h b/pokemod/MapEffect.h
index d9cc2383..1d84d09e 100644
--- a/pokemod/MapEffect.h
+++ b/pokemod/MapEffect.h
@@ -19,11 +19,9 @@
#define __POKEMOD_MAPEFFECT__
// Pokemod includes
+#include "Flag.h"
#include "Object.h"
-
-// General includes
-#include "../general/Flag.h"
-#include "../general/Point.h"
+#include "Point.h"
// Qt includes
#include <QPixmap>
diff --git a/pokemod/MapTrainer.cpp b/pokemod/MapTrainer.cpp
index ad0da7bc..8eb93ebd 100644
--- a/pokemod/MapTrainer.cpp
+++ b/pokemod/MapTrainer.cpp
@@ -23,6 +23,7 @@
#include "Map.h"
#include "MapTrainerTeamMember.h"
#include "Pokemod.h"
+#include "Rules.h"
// Qt includes
#include <QSet>
diff --git a/pokemod/MapTrainer.h b/pokemod/MapTrainer.h
index 4bfaf3bc..f7dea954 100644
--- a/pokemod/MapTrainer.h
+++ b/pokemod/MapTrainer.h
@@ -19,11 +19,9 @@
#define __POKEMOD_MAPTRAINER__
// Pokemod includes
+#include "Flag.h"
#include "Object.h"
-
-// General includes
-#include "../general/Flag.h"
-#include "../general/Point.h"
+#include "Point.h"
// Qt includes
#include <QList>
diff --git a/pokemod/MapTrainerTeamMember.cpp b/pokemod/MapTrainerTeamMember.cpp
index f95ae7e0..ce8cddae 100644
--- a/pokemod/MapTrainerTeamMember.cpp
+++ b/pokemod/MapTrainerTeamMember.cpp
@@ -22,6 +22,7 @@
#include "Item.h"
#include "MapTrainer.h"
#include "Pokemod.h"
+#include "Rules.h"
#include "Species.h"
// Qt includes
diff --git a/pokemod/MapWarp.h b/pokemod/MapWarp.h
index a25c60c1..6395e3ef 100644
--- a/pokemod/MapWarp.h
+++ b/pokemod/MapWarp.h
@@ -19,13 +19,11 @@
#define __POKEMOD_MAPWARP__
// Pokemod includes
+#include "Flag.h"
#include "Object.h"
+#include "Point.h"
#include "Pokemod.h"
-// General includes
-#include "../general/Flag.h"
-#include "../general/Point.h"
-
class MapWarp : public Object
{
Q_OBJECT
diff --git a/pokemod/MapWildListEncounter.cpp b/pokemod/MapWildListEncounter.cpp
index 5918df09..3ce241a8 100644
--- a/pokemod/MapWildListEncounter.cpp
+++ b/pokemod/MapWildListEncounter.cpp
@@ -21,6 +21,7 @@
// Pokemod includes
#include "MapWildList.h"
#include "Pokemod.h"
+#include "Rules.h"
#include "Species.h"
MapWildListEncounter::MapWildListEncounter(const MapWildListEncounter& encounter) :
diff --git a/pokemod/Matrix.h b/pokemod/Matrix.h
new file mode 100644
index 00000000..8d714f9d
--- /dev/null
+++ b/pokemod/Matrix.h
@@ -0,0 +1,210 @@
+/*
+ * 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 __MATRIX__
+#define __MATRIX__
+
+// General includes
+#include "Point.h"
+
+// Qt includes
+#include <QVector>
+
+template<class T> class Matrix
+{
+ public:
+ Matrix() :
+ m_width(0),
+ m_height(0)
+ {
+ }
+ Matrix(const int height, const int width, const T& value = T())
+ {
+ resize(height, width, value);
+ }
+ Matrix(const Matrix<T>& rhs)
+ {
+ *this = rhs;
+ }
+
+ void addRow(const T& value = T())
+ {
+ m_width += !m_width;
+ m_matrix.append(QVector<T>(m_width, value));
+ ++m_height;
+ }
+ void addColumn(const T& value = T())
+ {
+ if (!m_height)
+ {
+ m_matrix.append(QVector<T>(1));
+ ++m_height;
+ }
+ foreach (QVector<T> row, m_matrix)
+ row.append(value);
+ ++m_width;
+ }
+ void insertRow(const int row, const T& value = T())
+ {
+ if (m_height < row)
+ return;
+ m_width += !m_width;
+ m_matrix.insert(row, QVector<T>(m_width, value));
+ ++m_height;
+ }
+ void insertColumn(const int column, const T& value = T())
+ {
+ if (m_width < column)
+ return;
+ if (!m_height)
+ {
+ m_matrix.append(QVector<T>(1));
+ ++m_height;
+ }
+ foreach (QVector<T> row, m_matrix)
+ row.insert(column, value);
+ ++m_width;
+ }
+ void deleteRow(const int row)
+ {
+ if (m_height <= row)
+ return;
+ m_matrix.remove(row);
+ if (!(--m_height))
+ m_width = 0;
+ }
+ void deleteColumn(const int column)
+ {
+ if (m_width <= column)
+ return;
+ foreach (QVector<T> row, m_matrix)
+ row.remove(column);
+ if (!(--m_width))
+ m_height = 0;
+ }
+ void clear()
+ {
+ m_width = 0;
+ m_height = 0;
+ m_matrix.clear();
+ }
+
+ void set(const int row, const int column, const T& value)
+ {
+ if ((m_height <= row) || (m_width <= column))
+ return;
+ (m_matrix[row])[column] = value;
+ }
+ void resize(const int height, const int width, const T& value = T())
+ {
+ clear();
+ m_width = width;
+ m_height = height;
+ if (!m_width ^ !m_height)
+ {
+ if (m_width)
+ ++m_height;
+ if (m_height)
+ ++m_width;
+ }
+ m_matrix = QVector< QVector<T> >(m_height, QVector<T>(m_width, value));
+ }
+
+ T at(const int row, const int column) const
+ {
+ if ((m_height <= row) || (m_width <= column))
+ return T();
+ return m_matrix.at(row).at(column);
+ }
+ QVector<T> row(const int row) const
+ {
+ if (height <= row)
+ return QVector<T>();
+ return m_matrix.at(row);
+ }
+ QVector<T> column(const int column) const
+ {
+ if (m_width <= column)
+ return QVector<T>();
+ QVector<T> col;
+ foreach (QVector<T> row, m_matrix)
+ col.append(row.at(column));
+ return col;
+ }
+ int height() const
+ {
+ return m_height;
+ }
+ int width() const
+ {
+ return m_width;
+ }
+ Point size() const
+ {
+ return Point(m_width, m_height);
+ }
+
+ T& operator()(const int row, const int column)
+ {
+ // FIXME: compile error if used :(
+ if ((m_height <= row) || (m_width <= column))
+ return T();
+ return m_matrix[row][column];
+ }
+ T operator()(const int row, const int column) const
+ {
+ return at(row, column);
+ }
+ Matrix<T>& operator=(const Matrix<T>& rhs)
+ {
+ if (this == &rhs)
+ return *this;
+ resize(rhs.m_height, rhs.m_width);
+ for (int i = 0; i < m_height; ++i)
+ {
+ for (int j = 0; j < m_width; ++j)
+ m_matrix[i][j] = rhs.m_matrix[i][j];
+ }
+ return *this;
+ }
+ bool operator==(const Matrix<T>& rhs) const
+ {
+ if (this == &rhs)
+ return true;
+ if ((m_height != rhs.m_height) || (m_width == rhs.m_width))
+ return false;
+ for (int i = 0; i < m_height; ++i)
+ {
+ for (int j = 0; j < m_width; ++j)
+ {
+ if (m_matrix[i][j] != rhs.m_matrix[i][j])
+ return false;
+ }
+ }
+ return true;
+ }
+ bool operator!=(const Matrix<T>& rhs) const
+ {
+ return !(*this == rhs);
+ }
+ protected:
+ int m_width;
+ int m_height;
+ QVector< QVector<T> > m_matrix;
+};
+
+#endif
diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp
index 5567947d..b69dc373 100644
--- a/pokemod/Move.cpp
+++ b/pokemod/Move.cpp
@@ -21,6 +21,7 @@
// Pokemod includes
#include "MoveEffect.h"
#include "Pokemod.h"
+#include "Rules.h"
// Qt includes
#include <QSet>
diff --git a/pokemod/Move.h b/pokemod/Move.h
index ca70c7fb..c2080b7e 100644
--- a/pokemod/Move.h
+++ b/pokemod/Move.h
@@ -19,11 +19,9 @@
#define __POKEMOD_MOVE__
// Pokemod includes
+#include "Fraction.h"
#include "Object.h"
-// General includes
-#include "../general/Fraction.h"
-
// Qt includes
#include <QList>
diff --git a/pokemod/MoveEffect.h b/pokemod/MoveEffect.h
index bbc0f322..adadaeb5 100644
--- a/pokemod/MoveEffect.h
+++ b/pokemod/MoveEffect.h
@@ -19,11 +19,9 @@
#define __POKEMOD_MOVEEFFECT__
// Pokemod includes
+#include "Fraction.h"
#include "Object.h"
-// General includes
-#include "../general/Fraction.h"
-
// Qt includes
#include <QStringList>
diff --git a/pokemod/Nature.cpp b/pokemod/Nature.cpp
index db571d00..30f5a779 100644
--- a/pokemod/Nature.cpp
+++ b/pokemod/Nature.cpp
@@ -20,6 +20,7 @@
// Pokemod includes
#include "Pokemod.h"
+#include "Rules.h"
Nature::Nature(const Nature& nature) :
Object("Nature", nature.parent(), nature.id())
diff --git a/pokemod/Nature.h b/pokemod/Nature.h
index 82cb361f..1ef8bdee 100644
--- a/pokemod/Nature.h
+++ b/pokemod/Nature.h
@@ -19,12 +19,10 @@
#define __POKEMOD_NATURE__
// Pokemod includes
+#include "Fraction.h"
#include "Object.h"
#include "Pokemod.h"
-// General includes
-#include "../general/Fraction.h"
-
class Nature : public Object
{
Q_OBJECT
diff --git a/pokemod/Point.h b/pokemod/Point.h
new file mode 100644
index 00000000..0525f85b
--- /dev/null
+++ b/pokemod/Point.h
@@ -0,0 +1,78 @@
+/*
+ * 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 __POINT__
+#define __POINT__
+
+class Point
+{
+ public:
+ inline Point(const int x = 0, const int y = 0) :
+ m_x(x),
+ m_y(y)
+ {
+ }
+ inline Point(const Point& rhs)
+ {
+ *this = rhs;
+ }
+
+ inline void set(const int x, const int y)
+ {
+ m_x = x;
+ m_y = y;
+ }
+ inline void setX(const int x)
+ {
+ m_x = x;
+ }
+ inline void setY(const int y)
+ {
+ m_y = y;
+ }
+
+ inline int x() const
+ {
+ return m_x;
+ }
+ inline int y() const
+ {
+ return m_y;
+ }
+
+ Point& operator=(const Point& rhs)
+ {
+ if (this == &rhs)
+ return *this;
+ m_x = rhs.m_x;
+ m_y = rhs.m_y;
+ return *this;
+ }
+ inline bool operator==(const Point& rhs) const
+ {
+ return ((m_x == rhs.m_x) && (m_y == rhs.m_y));
+ }
+ inline bool operator!=(const Point& rhs) const
+ {
+ return !(*this == rhs);
+ }
+ private:
+ int m_x;
+ int m_y;
+};
+
+#endif
diff --git a/pokemod/Pokemod.cpp b/pokemod/Pokemod.cpp
index f19bb6c1..b33d8175 100644
--- a/pokemod/Pokemod.cpp
+++ b/pokemod/Pokemod.cpp
@@ -30,6 +30,7 @@
#include "Map.h"
#include "Move.h"
#include "Nature.h"
+#include "Rules.h"
#include "Sound.h"
#include "Species.h"
#include "Store.h"
diff --git a/pokemod/Pokemod.h b/pokemod/Pokemod.h
index 702314ea..7166f397 100644
--- a/pokemod/Pokemod.h
+++ b/pokemod/Pokemod.h
@@ -19,13 +19,12 @@
#define __POKEMOD_POKEMOD__
// Pokemod includes
+#include "Fraction.h"
+#include "Matrix.h"
#include "Object.h"
-#include "Rules.h"
+#include "Point.h"
// General includes
-#include "../general/Fraction.h"
-#include "../general/Matrix.h"
-#include "../general/Point.h"
// Qt includes
#include <QList>
@@ -43,6 +42,7 @@ class ItemType;
class Map;
class Move;
class Nature;
+class Rules;
class Sound;
class Species;
class Store;
diff --git a/pokemod/Rules.h b/pokemod/Rules.h
index 87562774..3b2b3e5a 100644
--- a/pokemod/Rules.h
+++ b/pokemod/Rules.h
@@ -19,11 +19,9 @@
#define __POKEMOD_RULES__
// Pokemod includes
+#include "Fraction.h"
#include "Object.h"
-// General includes
-#include "../general/Fraction.h"
-
// Forward declarations
class Pokemod;
diff --git a/pokemod/Species.cpp b/pokemod/Species.cpp
index 91ba0720..2867b401 100644
--- a/pokemod/Species.cpp
+++ b/pokemod/Species.cpp
@@ -20,6 +20,7 @@
// Pokemod includes
#include "Pokemod.h"
+#include "Rules.h"
#include "SpeciesAbility.h"
#include "SpeciesEvolution.h"
#include "SpeciesItem.h"
diff --git a/pokemod/Species.h b/pokemod/Species.h
index 704a6d29..c0d93460 100644
--- a/pokemod/Species.h
+++ b/pokemod/Species.h
@@ -19,12 +19,10 @@
#define __POKEMOD_SPECIES__
// Pokemod includes
+#include "Fraction.h"
#include "Object.h"
#include "Pokemod.h"
-// General includes
-#include "../general/Fraction.h"
-
// Qt includes
#include <QList>
diff --git a/pokemod/SpeciesEvolution.cpp b/pokemod/SpeciesEvolution.cpp
index b57f3715..060cc8de 100644
--- a/pokemod/SpeciesEvolution.cpp
+++ b/pokemod/SpeciesEvolution.cpp
@@ -22,6 +22,7 @@
#include "Item.h"
#include "ItemEffect.h"
#include "Pokemod.h"
+#include "Rules.h"
#include "Species.h"
const QStringList SpeciesEvolution::StyleStr = QStringList() << "Level" << "Happiness" << "Stat" << "Item" << "Trade" << "TradeItem" << "Personality" << "Spare Slot";
diff --git a/pokemod/SpeciesMove.cpp b/pokemod/SpeciesMove.cpp
index d5042414..c013c9de 100644
--- a/pokemod/SpeciesMove.cpp
+++ b/pokemod/SpeciesMove.cpp
@@ -20,6 +20,7 @@
// Pokemod includes
#include "Pokemod.h"
+#include "Rules.h"
#include "Species.h"
SpeciesMove::SpeciesMove(const SpeciesMove& move) :
diff --git a/pokemod/Tile.h b/pokemod/Tile.h
index c0ebc44d..12efe6f5 100644
--- a/pokemod/Tile.h
+++ b/pokemod/Tile.h
@@ -19,12 +19,10 @@
#define __POKEMOD_TILE__
// Pokemod includes
+#include "Fraction.h"
#include "Object.h"
#include "Pokemod.h"
-// General includes
-#include "../general/Fraction.h"
-
// Forward declarations
class Pokemod;
diff --git a/pokemod/Type.h b/pokemod/Type.h
index 8f492039..06a7cdaf 100644
--- a/pokemod/Type.h
+++ b/pokemod/Type.h
@@ -19,12 +19,10 @@
#define __POKEMOD_TYPE__
// Pokemod includes
+#include "Fraction.h"
#include "Object.h"
#include "Pokemod.h"
-// General includes
-#include "../general/Fraction.h"
-
// Forward declarations
class Pokemod;
diff --git a/pokemod/pokemod.pro b/pokemod/pokemod.pro
index 2a90538d..158233b9 100644
--- a/pokemod/pokemod.pro
+++ b/pokemod/pokemod.pro
@@ -3,8 +3,6 @@ TEMPLATE = lib
OBJECTS_DIR = .obj
MOC_DIR = .moc
DESTDIR = ../bin
-LIBS += -L../bin \
- -lgeneral
CONFIG += qt \
warn_on \
@@ -14,12 +12,6 @@ QT += xml
CONFIG += debug
}
-win32 {
- TARGETDEPS += $${DESTDIR}/general.dll
-} else {
- TARGETDEPS += $${DESTDIR}/libgeneral.so
-}
-
SOURCES += Ability.cpp \
AbilityEffect.cpp \
Author.cpp \
@@ -28,6 +20,8 @@ SOURCES += Ability.cpp \
CoinListObject.cpp \
Dialog.cpp \
EggGroup.cpp \
+ Flag.cpp \
+ Fraction.cpp \
Item.cpp \
ItemEffect.cpp \
ItemType.cpp \
@@ -64,6 +58,9 @@ HEADERS += AbilityEffect.h \
CoinListObject.h \
Dialog.h \
EggGroup.h \
+ Flag.h \
+ Fraction.h \
+ Hat.h \
ItemEffect.h \
Item.h \
ItemType.h \
@@ -74,10 +71,12 @@ HEADERS += AbilityEffect.h \
MapWarp.h \
MapWildListEncounter.h \
MapWildList.h \
+ Matrix.h \
MoveEffect.h \
Move.h \
Nature.h \
Object.h \
+ Point.h \
Pokemod.h \
Rules.h \
Sound.h \