#pragma once
#include "../../DecisionMaking/Layer1Reactive/Layer1FSM/Old/AvoidEnemiesBehavior.h"
#include "../../DecisionMaking/Layer1Reactive/Layer1FSM/Old/WanderBehavior.h"
#include "../Scenario.h"

class MedicVsZerglingsScenario : public Scenario<MedicVsZerglingsScenario>
{
public:
  template <class SparAIFactory>
  SparAIContainer* instantiateSparAIImpl(SparAIFactory& sparFactory)
  {
    typedef SparAIModule<Layer1GameState, Layer2Cueing, Layer3TacticalRecognition, Layer4StrategicRecognition,
                         Layer1FSM, InactiveLayer2, InactiveLayer3, InactiveLayer4> SPAR;

    return sparFactory.instantiate<Layer1GameState, Layer2Cueing, Layer3TacticalRecognition, Layer4StrategicRecognition,
                                   Layer1FSM, InactiveLayer2, InactiveLayer3, InactiveLayer4>(this);
  }

protected:
  virtual void onSparStarted(void* data)
  {
    const std::set<BWAPI::Unit*>& units = BWAPI::Broodwar->self()->getUnits();
    for (std::set<BWAPI::Unit*>::const_iterator it = units.begin();
         it != units.end();
         ++it)
    {
      BWAPI::Unit* unit = (*it);
      if (unit->getType() == BWAPI::UnitTypes::Terran_Medic)
      {
        Behavior* behavior = new WanderBehavior(this, 100, unit);
        behavior->zombifyOnTerminate();
        behavior->start();
      }
      Behavior* behavior = new AvoidEnemiesBehavior(this, 100, unit);
      behavior->zombifyOnTerminate();
      behavior->start();
    }
  }

  void _output(std::ostream &out) const
  {
    out << "MedicVsZerglings Scenario";
  }
};