#pragma once
#include "../../../../Utils/Process/FSM/Condition.h"

/**
 * @brief Condition that is satisfied if all units of a group are idle.
 * @tparam std::set<BWAPI::Unit*> the type of group to evaluate the condition against.
 */
template <class UnitGroup>
class IsGroupIdle : public Condition
{
public:
  IsGroupIdle(const UnitGroup& group)
    : m_group(group) {}
  bool evaluate() const
  {
    bool idle = true;
    for (UnitGroup::const_iterator it = m_group.begin();
         idle && it != m_group.end();
         ++it)
    {
      idle = (*it)->isIdle();
    }
    return idle;
  }
protected:
  const UnitGroup& m_group;
};

class IsUnitIdle : public Condition
{
public:
  IsUnitIdle(BWAPI::Unit* unit)
    : m_unit(unit) {}
  bool evaluate() const
  {
    return m_unit->isIdle();
  }
protected:
  BWAPI::Unit* const m_unit;

private:
  //const member prevent the use of the assigment operator
  IsUnitIdle& operator=(const IsUnitIdle&);
};