#include "init_phase.hpp" //ctor InitPhase::InitPhase( IEngineDescriptor* engine, std::vector< std::string> & items) : m_engine( engine) { for(std::vector< std::string>::iterator it = items.begin(); it != items.end(); ++it) { //initialize list with tuple m_items.push_back( std::make_pair< std::string, bool>(*it, false)); } } int InitPhase::GetAction() { for( item_list::iterator it = m_items.begin(); it != m_items.end(); ++it) { //item has not been found yet if(!it->second) { if(m_engine->HasAgentItem(it->first)) { // whether agent got item in previous tick it->second = true; } else { // did not //gather it return m_engine->GatherItemAction( it->first); } } } return m_engine->GetIdleAction(); } bool InitPhase::Ended() { //dummy solution, but list is short for( item_list::iterator it = m_items.begin(); it != m_items.end(); ++it) { if(!it->second) { if(m_engine->HasAgentItem(it->first)) { it->second = true; } else {/**/ return false; } } } return true; }