/**
 * \file GoalieTactics.h
 * \date 21.04.2002
 *
 * Interface for the GoalieTactics class
 */

#ifndef MODULES_GOALIETACTICS_H
#define MODULES_GOALIETACTICS_H

#include "Player/PlayerSkills.h"
#include "Common/Main.h"
#include "Common/Support/Debug.h"

const int CYCLES_TO_RUN_HOME_AFTER_KICK = 10;

/// What is the minimal required (expected) speed of ball on goal line 
/// (in order to detect shoot on goal)
const float SPEED_ON_GOAL_LINE_MIN = 0.05f;

/**
 * \class GoalieTactics
 * \author Lehuta Marek
 * \author Trebaticky Peter
 * \brief GoalieTactics module
 */

class GoalieTactics : public PlayerSkills
{
public:
// Construction and destruction
	GoalieTactics();
	virtual ~GoalieTactics() {}

// Operations
	/// Friend player nearest to ball
	/// \returns player; -1 -> this player
	int NearFriend(int* pCycles) const;
	/// Opponent player nearest to ball
	int NearEnemy(int* pCycles) const;
	
	int GetNearestEnemyTo(const Point& pos, int* pCycles) const;

	/// Is given point between two other points?
	bool InTheMiddle(const Point& tested, const Point& p1,
		const Point& p2) const;

	/// Most suitable player to pass to
	/// \returns player; -1 -> no suitable players
	int GetPassAbleFriend() const;

	/// Is this player responsible for ball?
//	bool DependentForBall() const;

	/// Is ball heading on our goal?
	bool BallHeadingOnOurGoal(float tolerance = 10.f);
	/// Get the nearest point, where goalie can catch the ball
	/// given he is running for life (does not care about stamina)
	Point GetNearestBallInterceptPos();

	/// Is enemy passing ball to his coleague near our goal?
	bool IsPassNearGoal();
	Point SolvePassNearGoal();

protected:
	virtual void BehaveWithBallGoalie();
	virtual void BehaveWithoutBallGoalie();
	virtual void BehaveWithoutBallKnowledgeGoalie();

	virtual Point GetHomePos();
	Point GetDefensePos();
	Point GetKickOffPos() const;

	float DistanceToGoal(const Point&, bool bOur = false) const;
	bool InPenaltyArea(const Point p, bool our = true);

	/// No opponents around, so dribble
	bool NoEnemiesAround() const;

	bool SmartDribleTo(const Point&);

private:
	Point homePos;
	bool caughtBall;
	bool inPosition;
	bool scaningSituation;
	int goalieKicked;
	bool enemyHadBall;

};

#endif	// MODULES_GOALIETACTICS_H
