/*
autor: Lubos Fazekas
tim: Gridders
ucel: implementacia triedy PlayerExperience
*/

#include "PlayerExperience.h"

// definuje konstanty pre jednotlive zony
const int PlayerExperience::KICK_ON_GOAL_ZONE_1 = 1;
const int PlayerExperience::KICK_ON_GOAL_ZONE_2 = 2;
const int PlayerExperience::KICK_ON_GOAL_ZONE_3 = 3;
const int PlayerExperience::KICK_ON_GOAL_ZONE_4 = 4;
const int PlayerExperience::KICK_ON_GOAL_ZONE_5 = 5;
const int PlayerExperience::KICK_ON_GOAL_ZONE_6 = 6;

// iniciuje vsetky skusenosti hraca
PlayerExperience::PlayerExperience(): m_KickOnGoalZone1("KICK_ON_GOAL_ZONE_1",0.1f,-0.000025f), m_KickOnGoalZone2("KICK_ON_GOAL_ZONE_2",0.2f,-0.000025f),m_KickOnGoalZone3("KICK_ON_GOAL_ZONE_3",0.3f,-0.000025f),
m_KickOnGoalZone4("KICK_ON_GOAL_ZONE_4",0.4f,-0.000025f),m_KickOnGoalZone5("KICK_ON_GOAL_ZONE_5",0.5f,-0.000025f),m_KickOnGoalZone6("KICK_ON_GOAL_ZONE_6",0.6f,-0.000025f)
{
	;
}
	
PlayerExperience::~PlayerExperience()
{
	;
}

float PlayerExperience::getLimitProbabilityFoxExperience(int p_ExperienceType)
{
	switch(p_ExperienceType){
	case KICK_ON_GOAL_ZONE_1:
		return m_KickOnGoalZone1.getLimit();
		break;
	case KICK_ON_GOAL_ZONE_2:
		return m_KickOnGoalZone2.getLimit();
		break;
	case KICK_ON_GOAL_ZONE_3:
		return m_KickOnGoalZone3.getLimit();
		break;
	case KICK_ON_GOAL_ZONE_4:
		return m_KickOnGoalZone4.getLimit();
		break;
	case KICK_ON_GOAL_ZONE_5:
		return m_KickOnGoalZone5.getLimit();
		break;
	case KICK_ON_GOAL_ZONE_6:
		return m_KickOnGoalZone6.getLimit();
		break;
	default:
		return -1.0f;
	}
}

int PlayerExperience::getKickOnGoalZone(float p_Distance)
{
	if(p_Distance < 5)
		return KICK_ON_GOAL_ZONE_1;
	else if(p_Distance < 10)
		return KICK_ON_GOAL_ZONE_2;
	else if(p_Distance < 15)
		return KICK_ON_GOAL_ZONE_3;
	else if(p_Distance < 20)
		return KICK_ON_GOAL_ZONE_4;
	else if(p_Distance < 30)
		return KICK_ON_GOAL_ZONE_5;
	else
		return KICK_ON_GOAL_ZONE_6;
}

void PlayerExperience::recordExperience(int p_ExperienceType,float p_EstimatedProbability,int p_EndSimTime)
{
	switch(p_ExperienceType){
	case KICK_ON_GOAL_ZONE_1:
		m_KickOnGoalZone1.activate(p_EndSimTime,p_EstimatedProbability);
		return;
		break;
	case KICK_ON_GOAL_ZONE_2:
		m_KickOnGoalZone2.activate(p_EndSimTime,p_EstimatedProbability);
		return;
		break;
	case KICK_ON_GOAL_ZONE_3:
		m_KickOnGoalZone3.activate(p_EndSimTime,p_EstimatedProbability);
		return;
		break;
	case KICK_ON_GOAL_ZONE_4:
		m_KickOnGoalZone4.activate(p_EndSimTime,p_EstimatedProbability);
		return;
		break;
	case KICK_ON_GOAL_ZONE_5:
		m_KickOnGoalZone5.activate(p_EndSimTime,p_EstimatedProbability);
		return;
		break;
	case KICK_ON_GOAL_ZONE_6:
		m_KickOnGoalZone6.activate(p_EndSimTime,p_EstimatedProbability);
		return;
		break;
	default:
		break;
	}
}

void PlayerExperience::onScore(int p_SimTime)
{
	m_KickOnGoalZone1.deactivate(p_SimTime);
	m_KickOnGoalZone2.deactivate(p_SimTime);
	m_KickOnGoalZone3.deactivate(p_SimTime);
	m_KickOnGoalZone4.deactivate(p_SimTime);
	m_KickOnGoalZone5.deactivate(p_SimTime);
	m_KickOnGoalZone6.deactivate(p_SimTime);
}

void PlayerExperience::evalExperience(int p_SimTime)
{
	// updatovat skusenosti
	m_KickOnGoalZone1.changeByTimeStep(p_SimTime);
	m_KickOnGoalZone2.changeByTimeStep(p_SimTime);
	m_KickOnGoalZone3.changeByTimeStep(p_SimTime);
	m_KickOnGoalZone4.changeByTimeStep(p_SimTime);
	m_KickOnGoalZone5.changeByTimeStep(p_SimTime);
	m_KickOnGoalZone6.changeByTimeStep(p_SimTime);
}
	