#pragma once
#include "../Scenario.h"
#include "../../PerceptualState/Locations/Static/AutoPopulated/Map.h"

class TestCancelBuildScenario : public Scenario<TestCancelBuildScenario>
{
public:
  TestCancelBuildScenario()
    : m_build(*this)
  {}

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

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

protected:
  virtual void onSparStarted(void* data)
  {
    std::pair<Map::base_location_const_iterator, Map::base_location_const_iterator> baseLocations = 
      Spar->getPerceptualState()->getMap()->getBaseLocations();

    assert(baseLocations.first != baseLocations.second);

    m_build = Layer2Managers::getInstance().instantiateBuild(
        this,
        100,
        *baseLocations.first, 
        BWAPI::UnitTypes::Protoss_Nexus      
      );
    m_build->start();
  }

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

  ProcessContainer<Build> m_build;
};