GeorgeKolog %!s(int64=6) %!d(string=hai) anos
pai
achega
1cc558f515

+ 1 - 0
include/units/unit.h

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

+ 4 - 3
source/effects/meleedamage.cpp

@@ -16,11 +16,12 @@ void MeleeDamage::OperateOnUnitToCell(Unit* who, Cell* where){
 }
 
 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){
-    if(Type == 1)
+    if(Type == 1){
         OperateOnUnit(whom);
+    }
 }

+ 1 - 1
source/effects/selfheal.cpp

@@ -12,7 +12,7 @@ void SelfHeal::OperateOnCell(Cell* cell){
 }
 
 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
 }
 

+ 4 - 0
source/units/unit.cpp

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