#pragma once
#include "../Condition.h"

/**
 * @brief Condition that is satisfied if no allies in the group is wounded.
 * @tparam UnitGroup type of unit group.
 */
template<class UnitGroup>
class AlliesWounded : public Condition
{
public:
  AlliesWounded(const UnitGroup* allies)
    : m_allies(allies)
  {
  }
  bool evaluate() const
  {
    bool wounded = false;
    for(UnitGroup::const_iterator i = m_allies->begin();
        !wounded && i != m_allies->end();
        ++i)
    {
      wounded = ((*i)->getHitPoints() < (*i)->getType().maxHitPoints());
    }
    return wounded;
  }

protected:
  const UnitGroup* const m_allies;
};

/**
 * @brief Condition that is satisfied if all units if the group have full health.
 * @tparam UnitGroup type of unit group.
 */
template<class UnitGroup>
class AlliesHealed : public Condition
{
public:
  AlliesHealed(const UnitGroup* allies)
    : m_alliesWounded(allies)
  {
  }
  bool evaluate() const
  {
    return !m_alliesWounded.evaluate();
  }

protected:
  AlliesWounded<UnitGroup> m_alliesWounded;
};