/**
 * \file Player.cpp
 * \date 12.04.2003
 *
 * Interface for the Player object class
 */

#include "Player/World/Player.h"
#include "Player/World/Myself.h"

Player::Player(World* w) : Movable(w)
{
	side = UNKNOWN;
	uniform = 0;
	goalie = false;

	absDir = RadAngle(0);
	neckDir = RadAngle(0);
	dirValid = false;
	armValid = false;

	if(world->params->types == NULL) type = NULL;
	else type = world->params->types[0];
}

Player::Player(const Player& player) : Movable(player)
{
	side = player.side;
	uniform = player.uniform;
	goalie = player.goalie;

	absDir = player.absDir;
	neckDir = player.neckDir;
	dirValid = player.dirValid;
	armDir = player.armDir;
	armValid = player.armValid;

	type = player.type;
}

Player& Player::operator=(const Player& player)
{
	if(&player == this) return *this;

	Movable::operator=(player);

	side = player.side;
	uniform = player.uniform;
	goalie = player.goalie;

	absDir = player.absDir;
	neckDir = player.neckDir;
	dirValid = player.dirValid;
	armDir = player.armDir;
	armValid = player.armValid;

	type = player.type;

	return *this;
}

void Player::Step()
{
	pos += vel;
	vel *= type->player_decay;
	age++;
}

void Player::SetType(int i)
{
	if(world->params->types == NULL) return;

	if(uniform == 0 || side != OUR)
	{
		type = world->params->types[0];
	}
	else
	{
		world->friendTypes[uniform] = world->params->types[i];
		type = world->params->types[i];
	}
}

void Player::SetUniform(int u)
{
	uniform = u;

	if(world->params->types == NULL) return;

	if(side != OUR) type = world->params->types[0];
	else type = world->friendTypes[uniform];
}

void Player::SetSide(Side s)
{
	side = s;

	if(world->params->types == NULL) return;

	if(side != OUR) type = world->params->types[0];
	else type = world->friendTypes[uniform];
}

Player::~Player()
{
}
