summaryrefslogtreecommitdiffstats
path: root/pokemod/MapEffect.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/MapEffect.cpp')
-rw-r--r--pokemod/MapEffect.cpp140
1 files changed, 72 insertions, 68 deletions
diff --git a/pokemod/MapEffect.cpp b/pokemod/MapEffect.cpp
index 1bb70d8a..2c146a96 100644
--- a/pokemod/MapEffect.cpp
+++ b/pokemod/MapEffect.cpp
@@ -15,27 +15,28 @@
* with this program. If not, see <http://www.gnu.org/licenses/>.
*/
-// Qt includes
-#include <QBuffer>
+// Header include
+#include "MapEffect.h"
// Pokemod includes
-#include "Pokemod.h"
#include "Dialog.h"
+#include "Map.h"
+#include "Pokemod.h"
-// Header include
-#include "MapEffect.h"
+// Qt includes
+#include <QBuffer>
const QStringList MapEffect::MapEffectStr = QStringList() << "Item" << "PC" << "Strength Block" << "Button" << "Slot Machine" << "Card Flip Game";
const QStringList MapEffect::PCTypeStr = QStringList() << "Item" << "Pokémon" << "PokéDex" << "Hall of Fame" << "All";
MapEffect::MapEffect(const MapEffect& effect) :
- Object("MapEffect", effect.pokemod(), effect.id())
+ Object("MapEffect", effect.parent(), effect.id())
{
*this = effect;
}
-MapEffect::MapEffect(const Pokemod* pokemod, const int id) :
- Object("MapEffect", pokemod, id),
+MapEffect::MapEffect(const Object* parent, const int id) :
+ Object("MapEffect", parent, id),
m_name(""),
m_coordinate(0, 0),
m_existFlag(0, 0),
@@ -50,73 +51,74 @@ MapEffect::MapEffect(const Pokemod* pokemod, const int id) :
{
}
-MapEffect::MapEffect(const MapEffect& effect, const Pokemod* pokemod, const int id) :
- Object("MapEffect", pokemod, id)
+MapEffect::MapEffect(const MapEffect& effect, const Object* parent, const int id) :
+ Object("MapEffect", parent, id)
{
*this = effect;
}
-MapEffect::MapEffect(const QDomElement& xml, const Pokemod* pokemod, const int id) :
- Object("MapEffect", pokemod, id)
+MapEffect::MapEffect(const QDomElement& xml, const Object* parent, const int id) :
+ Object("MapEffect", parent, id)
{
load(xml, id);
}
bool MapEffect::validate() const
{
- bool valid = true;
- pokemod()->validationMsg(QString("------Effect \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
- if (m_name == "")
- {
- pokemod()->validationMsg("Name is not defined");
- valid = false;
- }
- if (Flag::End <= m_existFlag.status())
- {
- pokemod()->validationMsg("Invalid existence flag status");
- valid = false;
- }
- if (m_effect < E_End)
- {
- bool ok = true;
- switch (m_effect)
- {
- case E_Item:
- if (pokemod()->itemIndex(m_value2) == INT_MAX)
- ok = false;
- break;
- case E_PC:
- if (PC_End <= m_value2)
- ok = false;
- break;
- case E_StrengthBlock:
- case E_Button:
- if (Flag::End <= m_value2)
- ok = false;
- break;
- }
- if (!ok)
- {
- pokemod()->validationMsg("Invalid val2");
- valid = false;
- }
- }
- else
- {
- pokemod()->validationMsg("Invalid effect");
- valid = false;
- }
- if (Pokemod::D_End_None <= m_direction)
- {
- pokemod()->validationMsg("Invalid driection");
- valid = false;
- }
- if (pokemod()->dialogIndex(m_dialog) == INT_MAX)
- {
- pokemod()->validationMsg("Invalid dialog");
- valid = false;
- }
- return valid;
+ // TODO: validate
+// bool valid = true;
+// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("------Effect \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg);
+// if (m_name == "")
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Name is not defined");
+// valid = false;
+// }
+// if (Flag::End <= m_existFlag.status())
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid existence flag status");
+// valid = false;
+// }
+// if (m_effect < E_End)
+// {
+// bool ok = true;
+// switch (m_effect)
+// {
+// case E_Item:
+// if (static_cast<const Pokemod*>(pokemod())->itemIndex(m_value2) == INT_MAX)
+// ok = false;
+// break;
+// case E_PC:
+// if (PC_End <= m_value2)
+// ok = false;
+// break;
+// case E_StrengthBlock:
+// case E_Button:
+// if (Flag::End <= m_value2)
+// ok = false;
+// break;
+// }
+// if (!ok)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid val2");
+// valid = false;
+// }
+// }
+// else
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid effect");
+// valid = false;
+// }
+// if (Pokemod::D_End_None <= m_direction)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid driection");
+// valid = false;
+// }
+// if (static_cast<const Pokemod*>(pokemod())->dialogIndex(m_dialog) == INT_MAX)
+// {
+// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid dialog");
+// valid = false;
+// }
+// return valid;
}
void MapEffect::load(const QDomElement& xml, int id)
@@ -157,8 +159,10 @@ void MapEffect::setName(const QString& name)
m_name = name;
}
-void MapEffect::setCoordinate(const Point& coordinate)
+void MapEffect::setCoordinate(const Point& coordinate) throw(BoundsException)
{
+ if ((static_cast<const Map*>(parent())->width() <= coordinate.x()) || (static_cast<const Map*>(parent())->height() <= coordinate.y()))
+ error<BoundsException>("coordinate");
m_coordinate = coordinate;
}
@@ -195,7 +199,7 @@ void MapEffect::setValue2(const int value2) throw(Exception)
switch (m_effect)
{
case E_Item:
- if (pokemod()->itemIndex(value2) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->itemIndex(value2) == INT_MAX)
error<BoundsException>("val2");
break;
case E_PC:
@@ -233,7 +237,7 @@ void MapEffect::setCanMove(const bool canMove)
void MapEffect::setDialog(const int dialog) throw(BoundsException)
{
- if (pokemod()->dialogIndex(dialog) == INT_MAX)
+ if (static_cast<const Pokemod*>(pokemod())->dialogIndex(dialog) == INT_MAX)
error<BoundsException>("dialog");
m_dialog = dialog;
}