@@ -34,7 +34,7 @@ public:
void setForCell(bool value);
virtual bool canCastToCell(Cell* destination, Cell* from);
-
+ bool isNeirbor(Cell* destination, Cell* from);
virtual void CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom) = 0;
QString getSpellName() const;
@@ -16,9 +16,8 @@ void MeleeDamage::OperateOnUnitToCell(Unit* who, Cell* where){
}
void MeleeDamage::OperateOnUnit(Unit* unit){
- //int temp = unit -> reduceIncomingDamage("p", count_);
- //unit ->setHealthPoints(unit -> getHealthPoints() - temp);
- //check_on_death
+// unit->setHealthPoints( unit->getHealthPoints() -
+// (count_ - 2.5 * double(count_) * double(unit->getPhysicDefence()) / 100.0));
void MeleeDamage::Execute(Cell* from, Cell* where, Unit* who, Unit* whom, TypeOfTrigger Type){
@@ -11,3 +11,7 @@
void MeleeDamageSpell::CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom){
effects_[0] -> OperateOnUnit(whom);
+
+bool MeleeDamageSpell::canCastToCell(Cell* destination, Cell* from){
+ return isNeirbor(Cell* destination, Cell* from);
+}
@@ -12,3 +12,7 @@
void SelfHealSpell::CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom){
effects_[0] -> OperateOnUnit(who);
+bool SelfHealSpell::canCastToCell(Cell* destination, Cell* from){
@@ -8,3 +8,7 @@
void SelfMoveSpell::CastSpell(Cell* from, Cell* where, Unit* who, Unit* whom){
effects_[0] -> OperateOnUnitToCell(who, where);
+bool SelfMoveSpell::canCastToCell(Cell* destination, Cell* from){
@@ -76,7 +76,12 @@ bool Spell::getForCell(){
void Spell::setForCell(bool value){
forCell_ = value;
-bool Spell::canCastToCell(Cell* destination, Cell* from){
- //if(from -> lenOfActualPath(destination) == 1) return true;
- return false;
+bool Spell::isNeirbor(Cell* destination, Cell* from){
+ return from -> getleft() == destination ||
+ from -> getleftDown() == destination ||
+ from -> getleftUp() == destination ||
+ from -> getright() == destination ||
+ from -> getrightDown() == destination ||
+ from -> getrightUp() == destination;