summaryrefslogtreecommitdiffstats
path: root/pokemod/Move.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'pokemod/Move.cpp')
-rw-r--r--pokemod/Move.cpp21
1 files changed, 15 insertions, 6 deletions
diff --git a/pokemod/Move.cpp b/pokemod/Move.cpp
index 20e49c21..1c676eac 100644
--- a/pokemod/Move.cpp
+++ b/pokemod/Move.cpp
@@ -368,20 +368,23 @@ int Move::effectCount() const
MoveEffect* Move::newEffect()
{
- m_effects.append(new MoveEffect(this, newEffectId()));
- return m_effects[effectCount() - 1];
+ return newEffect(new MoveEffect(this, newEffectId()));
}
MoveEffect* Move::newEffect(const QDomElement& xml)
{
- m_effects.append(new MoveEffect(xml, this, newEffectId()));
- return m_effects[effectCount() - 1];
+ return newEffect(new MoveEffect(xml, this, newEffectId()));
}
MoveEffect* Move::newEffect(const MoveEffect& effect)
{
- m_effects.append(new MoveEffect(effect, this, newEffectId()));
- return m_effects[effectCount() - 1];
+ return newEffect(new MoveEffect(effect, this, newEffectId()));
+}
+
+MoveEffect* Move::newEffect(MoveEffect* effect)
+{
+ m_effects.append(effect);
+ return effect;
}
void Move::deleteEffect(const int index) throw(IndexException)
@@ -428,3 +431,9 @@ Move& Move::operator=(const Move& rhs)
COPY_SUB(MoveEffect, effects);
return *this;
}
+
+void Move::clear()
+{
+ while (effectCount())
+ deleteEffect(0);
+}