#pragma once
#include "../../../../PerceptualState/Locations/Static/AutoPopulated/AutoPopulatedLocation.h"
#include "../../../PerceptualState/Locations/Static/StaticLocation.h"
#include "../../../PerceptualState/Resources/Resources.h"
#include "../../../BWAPI_Addon.h"

class ActionResources
{
public:
  ActionResources()
    : m_buildingLocation(*this, NULL)
    , m_buildingType(BWAPI::UnitTypes::None)
  {}
  ActionResources(int minerals, int gas, int supply)
    : m_resources(static_cast<double>(minerals), 
                  static_cast<double>(gas),
                  static_cast<double>(supply))
    , m_buildingLocation(*this, NULL)
    , m_buildingType(BWAPI::UnitTypes::None)
  {}
  ActionResources(const Resources& resources)
    : m_resources(resources)
    , m_buildingLocation(*this, NULL)
    , m_buildingType(BWAPI::UnitTypes::None)
  {}
  ActionResources(int minerals, int gas, int supply, AutoPopulatedLocation* buildingLocation, BWAPI::UnitType buildingType)
    : m_resources(static_cast<double>(minerals), 
                  static_cast<double>(gas),
                  static_cast<double>(supply))
    , m_buildingLocation(*this, buildingLocation)
    , m_buildingType(buildingType)
  {}
  ActionResources(const Resources& resources, AutoPopulatedLocation* buildingLocation, BWAPI::UnitType buildingType)
    : m_resources(resources)
    , m_buildingLocation(*this, buildingLocation)
    , m_buildingType(buildingType)
  {}

  double getMinerals() const
  {
    return m_resources.getMinerals();
  }

  double getGas() const
  {
    return m_resources.getGas();
  }

  double getSupply() const
  {
    return m_resources.getSupply();
  }

  Resources getResources() const
  {
    return m_resources;
  }

  AutoPopulatedLocation* getBuildingLocation() const
  {
    return m_buildingLocation;
  }

  BWAPI::UnitType getBuildingType() const
  {
    return m_buildingType;
  }

  bool operator==(const ActionResources& resources)
  {
    return (resources.m_resources == m_resources && resources.m_buildingLocation == m_buildingLocation);
  }

  friend std::ostream& operator<<(std::ostream& out, const ActionResources& resources)
  {
    out << resources.m_resources;
    if (resources.m_buildingType != BWAPI::UnitTypes::None)
    {
      out << "[" << resources.m_buildingType << " at " << *resources.m_buildingLocation << "]";
    }
    return out;
  }

protected:
  Resources m_resources;
  AutoPtr<AutoPopulatedLocation> m_buildingLocation;
  BWAPI::UnitType m_buildingType;
};