#pragma once
#include <BWAPI.h>
#include <BWTA.h>
#include <Arbitrator.h>
#include <WorkerManager.h>
#include <SupplyManager.h>
#include <BuildManager.h>
#include <BuildOrderManager.h>
#include <TechManager.h>
#include <UpgradeManager.h>
#include <BaseManager.h>
#include <ScoutManager.h>
#include <DefenseManager.h>
#include <UnderAttackManager.h>
#include <InformationManager.h>
#include <SpyManager.h>
#include <BorderManager.h>
#include <UnitGroupManager.h>
#include <SpendManager.h>
#include <ArmyManager.h>
#include <MoodManager.h>
#include <OpeningManager.h>
#include <PhotonManager.h>
#include <DragoonManager.h>
#include <RushPhotonManager.h>
#include <EnhancedUI.h>
#include <HashMap.h>
#include <MesurePrecision.h>
#include <Random.h>
#include <fstream>

class AiurModule : public BWAPI::AIModule
{
private:
	double	minDist;
	int		frame;
	int		lastFrameExpand;
	int		lastScout;

	BWTA::BaseLocation *closest;
	BWTA::BaseLocation *home;

	int				*dataGame;
	std::ofstream	inGame;
	std::ifstream	afterGame;
	std::ifstream	directories;
	bool			hasSwitchedToDefensive;

public:
	virtual void onStart		();
	virtual void onEnd			( bool );
	virtual void onFrame		();
	virtual void onUnitDiscover	( BWAPI::Unit* );
	virtual void onUnitEvade	( BWAPI::Unit* );
	virtual void onUnitMorph	( BWAPI::Unit* );
	virtual void onUnitRenegade	( BWAPI::Unit* );
	virtual void onUnitDestroy	( BWAPI::Unit* );
	virtual void onSendText		( std::string );
	virtual void onReceiveText	( BWAPI::Player*, std::string );

	~AiurModule(); //not part of BWAPI::AIModule

	void showStats(); //not part of BWAPI::AIModule
	void showPlayers();
	void showForces();
	bool analyzed;

	std::map<BWAPI::Unit*,BWAPI::UnitType>		buildings;
	Arbitrator::Arbitrator<BWAPI::Unit*,double> arbitrator;

	WorkerManager			*workerManager;
	SupplyManager			*supplyManager;
	BuildManager			*buildManager;
	TechManager				*techManager;
	UpgradeManager			*upgradeManager;
	BaseManager				*baseManager;
	ScoutManager			*scoutManager;
	SpendManager			*spendManager;
	BuildOrderManager		*buildOrderManager;
	DefenseManager			*defenseManager;
	UnderAttackManager		*underAttackManager;
	InformationManager		*informationManager;
	BorderManager			*borderManager;
	UnitGroupManager		*unitGroupManager;
	SpyManager				*spyManager;
	ArmyManager				*armyManager;
	MoodManager				*moodManager;
	OpeningManager			*openingManager;
	PhotonManager			*photonManager;
	RushPhotonManager		*rushPhotonManager;
	DragoonManager			*dragoonManager;
	EnhancedUI				*enhancedUI;
	Random					*randomExpand;
	HashMap					hashMap;
	int						timeToExpand;
	int						baseTimeToExpand;
	bool					showManagerAssignments;
	bool					debugMode;
	bool					destinationMineralSpotted;
	bool					cleaningPath;
	bool					ggAnswered;
	int						ggFrame;

	// time profile
	double diff, top;
	int sup55;
	CMesurePrecision compteur;
};