#include "stdafx.h"
#include "Arbitrator.h"
#include "Layer1FSM.h"
#include "../../../../Utils/Utils.h"
#include "Commands/Command.h"

//void Arbitration::submitCommand(BWAPI::Unit* unit, const Command &command, ActionImportance importance)
//{
//  unused(importance);
//
//  command.execute(unit);
//}
//
//void Arbitration::submitCommand(const PersistentUnitGroup* group, const Command &command, ActionImportance importance)
//{
//  unused(importance);
//
//  command.execute(group);
//}

//void Arbitration::submitCommand(BWAPI::Unit* unit, const Command &command, Arbitration::ActionImportance importance)
//{
//  ArbitratorUnitData& data = dynamic_cast<ArbitratorUnitData&>(BWAPI::getUnitData(unit));
//  data.addSubmittedAction(command, importance);
//
//  m_unitsWithSubmittedActions.insert(unit);
//}
//
//void Arbitration::submitCommand(const PersistentUnitGroup* group, const Command &command, Arbitration::ActionImportance importance)
//{
//  // Special treatement for group actions?
//  
//  for (PersistentUnitGroup::const_iterator it = group->begin();
//       it != group->end();
//       ++it)
//  {
//    BWAPI::Unit* unit = *it;
//    ArbitratorUnitData& data = dynamic_cast<ArbitratorUnitData&>(BWAPI::getUnitData(unit));
//    data.addSubmittedAction(command, importance);
//
//    m_unitsWithSubmittedActions.insert(unit);
//  }
//
//  //group->addSubmittedAction(command, importance);
//  //m_groupsWithSubmittedActions.insert(group);
//}
//
//void Arbitration::executeActions()
//{
//  for (std::set<BWAPI::Unit*>::const_iterator it = m_unitsWithSubmittedActions.begin();
//       it != m_unitsWithSubmittedActions.end();
//       ++it)
//  {
//    BWAPI::Unit* unit = *it;
//    ArbitratorUnitData& data = dynamic_cast<ArbitratorUnitData&>(BWAPI::getUnitData(unit));
//    const Command* command = data.arbitrate();
//
//    if (command != NULL)
//    {
//      bool executed = command->execute(unit);
//      // Don't know when it's supposed to happen; may have something to do with BWAPI
//      //assert(executed);
//      unused(executed);
//    }
//  }
//  m_unitsWithSubmittedActions.clear();
//}