소스 검색

did the CanCast?

igorbat99 6 년 전
부모
커밋
41b4a25ca9
6개의 변경된 파일23개의 추가작업 그리고 7개의 파일을 삭제
  1. 1 1
      include/spells/spell.h
  2. 2 3
      source/effects/meleedamage.cpp
  3. 4 0
      source/spells/meleedamagespell.cpp
  4. 4 0
      source/spells/selfhealspell.cpp
  5. 4 0
      source/spells/selfmovespell.cpp
  6. 8 3
      source/spells/spell.cpp

+ 1 - 1
include/spells/spell.h

@@ -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;

+ 2 - 3
source/effects/meleedamage.cpp

@@ -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){

+ 4 - 0
source/spells/meleedamagespell.cpp

@@ -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);
+}

+ 4 - 0
source/spells/selfhealspell.cpp

@@ -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){
+    return isNeirbor(Cell* destination, Cell* from);
+}

+ 4 - 0
source/spells/selfmovespell.cpp

@@ -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){
+    return isNeirbor(Cell* destination, Cell* from);
+}

+ 8 - 3
source/spells/spell.cpp

@@ -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;
 }