Browse Source

Some fixes

GeorgeKolog 6 years ago
parent
commit
1cc558f515
4 changed files with 10 additions and 4 deletions
  1. 1 0
      include/units/unit.h
  2. 4 3
      source/effects/meleedamage.cpp
  3. 1 1
      source/effects/selfheal.cpp
  4. 4 0
      source/units/unit.cpp

+ 1 - 0
include/units/unit.h

@@ -39,6 +39,7 @@ public:
     int getStartingActivityPoints();
     int getStartingActivityPoints();
 
 
     int getHealthPoints();
     int getHealthPoints();
+    void setHealthPoints(int);
 
 
     int getMagicDefence();
     int getMagicDefence();
     int getPhysicDefence();
     int getPhysicDefence();

+ 4 - 3
source/effects/meleedamage.cpp

@@ -16,11 +16,12 @@ void MeleeDamage::OperateOnUnitToCell(Unit* who, Cell* where){
 }
 }
 
 
 void MeleeDamage::OperateOnUnit(Unit* unit){
 void MeleeDamage::OperateOnUnit(Unit* unit){
-//    unit->setHealthPoints(  unit->getHealthPoints() -
-//                            (count_ - 2.5 * double(count_) * double(unit->getPhysicDefence()) / 100.0));
+    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){
 void MeleeDamage::Execute(Cell* from, Cell* where, Unit* who, Unit* whom, TypeOfTrigger Type){
-    if(Type == 1)
+    if(Type == 1){
         OperateOnUnit(whom);
         OperateOnUnit(whom);
+    }
 }
 }

+ 1 - 1
source/effects/selfheal.cpp

@@ -12,7 +12,7 @@ void SelfHeal::OperateOnCell(Cell* cell){
 }
 }
 
 
 void SelfHeal::OperateOnUnit(Unit* unit){
 void SelfHeal::OperateOnUnit(Unit* unit){
-    //unit.setHealthPoints(std :: min(unit.getHealthPoints() + count_ > unit->getMaxHealthPoints());
+    unit->setHealthPoints(std :: min(unit->getHealthPoints() + count_, unit->getMaxHealthPoints()));
     //check_on_is_it_max
     //check_on_is_it_max
 }
 }
 
 

+ 4 - 0
source/units/unit.cpp

@@ -129,6 +129,10 @@ int Unit::getActivityPoints(){
 	return activity_points_;
 	return activity_points_;
 }
 }
 
 
+void Unit::setHealthPoints(int health){
+    health_points_ = std::min(40, health);
+}
+
 int Unit::getStartingActivityPoints() {
 int Unit::getStartingActivityPoints() {
 	return starting_activity_points_;
 	return starting_activity_points_;
 }
 }