diff options
Diffstat (limited to 'pokemod/Move.cpp')
| -rw-r--r-- | pokemod/Move.cpp | 135 |
1 files changed, 68 insertions, 67 deletions
diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp index d1d17641..10c8affe 100644 --- a/pokemod/Move.cpp +++ b/pokemod/Move.cpp @@ -15,27 +15,27 @@ * with this program. If not, see <http://www.gnu.org/licenses/>. */ -// Qt includes -#include <QMap> +// Header include +#include "Move.h" // Pokemod includes -#include "Pokemod.h" #include "MoveEffect.h" +#include "Pokemod.h" -// Header include -#include "Move.h" +// Qt includes +#include <QMap> const QStringList Move::TargetStr = QStringList() << "Player" << "Enemy" << "All" << "Random"; const QStringList Move::ChoiceStr = QStringList() << "Player" << "Enemy" << "Random"; Move::Move(const Move& move) : - Object("Move", move.pokemod(), move.id()) + Object("Move", move.parent(), move.id()) { *this = move; } -Move::Move(const Pokemod* pokemod, const int id) : - Object("Move", pokemod, id), +Move::Move(const Object* parent, const int id) : + Object("Move", parent, id), m_name(""), m_accuracy(1, 1), m_power(0), @@ -54,14 +54,14 @@ Move::Move(const Pokemod* pokemod, const int id) : { } -Move::Move(const Move& move, const Pokemod* pokemod, const int id) : - Object("Move", pokemod, id) +Move::Move(const Move& move, const Object* parent, const int id) : + Object("Move", parent, id) { *this = move; } -Move::Move(const QDomElement& xml, const Pokemod* pokemod, const int id) : - Object("Move", pokemod, id) +Move::Move(const QDomElement& xml, const Object* parent, const int id) : + Object("Move", parent, id) { load(xml, id); } @@ -73,56 +73,57 @@ Move::~Move() bool Move::validate() const { - bool valid = true; - pokemod()->validationMsg(QString("---Move \"%1\" with id %2---").arg(m_name).arg(id()), Pokemod::V_Msg); - if (m_name == "") - { - pokemod()->validationMsg("Name is not defined"); - valid = ""; - } - if (pokemod()->typeIndex(m_type) == INT_MAX) - { - pokemod()->validationMsg("Invalid type"); - valid = false; - } - if (!m_powerPoints) - { - pokemod()->validationMsg("Invalid number of power points"); - valid = false; - } - if (T_End <= m_target) - { - pokemod()->validationMsg("Invalid target"); - valid = false; - } - if (!m_target || (pokemod()->rules()->maxFight() * ((m_target == T_All) ? pokemod()->rules()->maxPlayers() : 1)) < m_numTargets) - { - pokemod()->validationMsg("Invalid number of targets"); - valid = false; - } - if (C_End <= m_targetChoice) - { - pokemod()->validationMsg("Invalid target choice"); - valid = false; - } - if (effectCount()) - { - QMap<int, bool> idChecker; - foreach (MoveEffect* effect, m_effects) - { - if (!effect->isValid()) - valid = false; - if (idChecker[effect->id()]) - pokemod()->validationMsg(QString("Duplicate effect with id %1").arg(effect->id())); - idChecker[effect->id()] = true; - } - } - else - { - pokemod()->validationMsg("There are no effects"); - valid = false; - } - return valid; + // TODO: validate +// bool valid = true; +// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("---Move \"%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 = ""; +// } +// if (static_cast<const Pokemod*>(pokemod())->typeIndex(m_type) == INT_MAX) +// { +// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid type"); +// valid = false; +// } +// if (!m_powerPoints) +// { +// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid number of power points"); +// valid = false; +// } +// if (T_End <= m_target) +// { +// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid target"); +// valid = false; +// } +// if (!m_target || (static_cast<const Pokemod*>(pokemod())->rules()->maxFight() * ((m_target == T_All) ? static_cast<const Pokemod*>(pokemod())->rules()->maxPlayers() : 1)) < m_numTargets) +// { +// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid number of targets"); +// valid = false; +// } +// if (C_End <= m_targetChoice) +// { +// static_cast<const Pokemod*>(pokemod())->validationMsg("Invalid target choice"); +// valid = false; +// } +// if (effectCount()) +// { +// QMap<int, bool> idChecker; +// foreach (MoveEffect* effect, m_effects) +// { +// if (!effect->isValid()) +// valid = false; +// if (idChecker[effect->id()]) +// static_cast<const Pokemod*>(pokemod())->validationMsg(QString("Duplicate effect with id %1").arg(effect->id())); +// idChecker[effect->id()] = true; +// } +// } +// else +// { +// static_cast<const Pokemod*>(pokemod())->validationMsg("There are no effects"); +// valid = false; +// } +// return valid; } void Move::load(const QDomElement& xml, int id) @@ -186,7 +187,7 @@ void Move::setPower(const int power) void Move::setType(const int type) throw(BoundsException) { - if (pokemod()->typeIndex(type) == INT_MAX) + if (static_cast<const Pokemod*>(pokemod())->typeIndex(type) == INT_MAX) error<BoundsException>("type"); m_type = type; } @@ -212,7 +213,7 @@ void Move::setTarget(const int target) throw(BoundsException) void Move::setNumTargets(const int numTargets) throw(BoundsException) { - if (!numTargets || ((pokemod()->rules()->maxFight() * ((m_target == T_All) ? pokemod()->rules()->maxPlayers() : 1)) < numTargets)) + if (!numTargets || ((static_cast<const Pokemod*>(pokemod())->rules()->maxFight() * ((m_target == T_All) ? static_cast<const Pokemod*>(pokemod())->rules()->maxPlayers() : 1)) < numTargets)) error<BoundsException>("numTargets"); m_numTargets = numTargets; } @@ -370,19 +371,19 @@ int Move::effectCount() const MoveEffect* Move::newEffect() { - m_effects.append(new MoveEffect(pokemod(), newEffectId())); + m_effects.append(new MoveEffect(this, newEffectId())); return m_effects[effectCount() - 1]; } MoveEffect* Move::newEffect(const QDomElement& xml) { - m_effects.append(new MoveEffect(xml, pokemod(), newEffectId())); + m_effects.append(new MoveEffect(xml, this, newEffectId())); return m_effects[effectCount() - 1]; } MoveEffect* Move::newEffect(const MoveEffect& effect) { - m_effects.append(new MoveEffect(effect, pokemod(), newEffectId())); + m_effects.append(new MoveEffect(effect, this, newEffectId())); return m_effects[effectCount() - 1]; } |
