|
@@ -1,6 +1,7 @@
|
|
|
#include "AbstractFactory.h"
|
|
|
#include "units/Unit.h"
|
|
|
#include "Cell.h"
|
|
|
+#include "effects/effect.h"
|
|
|
|
|
|
#include <iostream>
|
|
|
#include <algorithm>
|
|
@@ -284,3 +285,36 @@ std::vector<QString> Unit::getUnitTraits() const {
|
|
|
QImage Unit::getUnitIcon() const {
|
|
|
return unit_icon_;
|
|
|
}
|
|
|
+
|
|
|
+void Unit::operateEffectList(){
|
|
|
+ for(std::vector<Effect*>::iterator it = beginIteratorEffectsList();
|
|
|
+ it != endIteratorEffectsList(); ++it){
|
|
|
+ (*it)->OperateOnUnit(this);
|
|
|
+ }
|
|
|
+}
|
|
|
+void Unit::add(Effect* effect){
|
|
|
+ if(effect == nullptr)
|
|
|
+ throw new std::string("Try to add undefined effect to unit");
|
|
|
+ effects_.push_back(effect);
|
|
|
+}
|
|
|
+void Unit::remove(std::vector<Effect*>::iterator it){
|
|
|
+ if(beginIteratorEffectsList() <= it && it < endIteratorEffectsList()){
|
|
|
+ effects_.erase(it);
|
|
|
+ }
|
|
|
+}
|
|
|
+void Unit::remove(Effect* effect){
|
|
|
+ for(std::vector<Effect*>::iterator it = beginIteratorEffectsList();
|
|
|
+ it != endIteratorEffectsList(); ++it){
|
|
|
+ if((*it) == effect){
|
|
|
+ remove(it);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+}
|
|
|
+std::vector<Effect*>::iterator Unit::beginIteratorEffectsList(){
|
|
|
+ return effects_.begin();
|
|
|
+}
|
|
|
+std::vector<Effect*>::iterator Unit::endIteratorEffectsList(){
|
|
|
+ return effects_.end();
|
|
|
+}
|
|
|
+
|