function FocusedPlayer(name, race, homeworld)
{
	this.Construct(name, race, homeworld);
	
	this.enemy = null;
	this.targetPlanet = null;
}
FocusedPlayer.prototype = new AIPlayerBase();
FocusedPlayer.prototype.type = "FocusedPlayer";
FocusedPlayer.className = "FocusedPlayer";
Player.Classes["FocusedPlayer"] = FocusedPlayer;



FocusedPlayer.prototype.Plan = function()
{
	// yearly maintenance
	this.Reports = [];

	this.ColonizePlanets();
		
	//if (!this.targetPlanet || this.targetPlanet.owner == this || Math.random < 0.5)
	{
		this.ChooseNewTarget();
	}
	
	for (var a=0; a<this.Planets.length; a++)
	{
	
		if (a % 3 == 0)
		{
			this.ChooseNewTarget();
		}


		var planet = this.Planets[a];
		this.PlanPlanet(planet);
	}
}

FocusedPlayer.prototype.ChooseNewTarget = function()
{
	if (this.enemy)
	{
		// choose an enemy planet
	}
	
	var planets = Planet.ListInRange(this);
	if (planets.length == 0)
	{
		return;
	}

	var startIndex = Util.RandInt(planets.length)-1;
//	for (var a=startIndex+1; a != startIndex; a=(a+1) % planets.length)
	var a=startIndex+1;
	var i=0;
	while (a != startIndex && i++ < planets.length)
	{
		if (a < planets.length)
		{

			var planet = planets[a];
			if (   (planet.owner && planet.owner != this)
				|| (!planet.owner && (!this.HasExplored(planet) || this.ShouldColonize(planet)))  )
			{


				this.targetPlanet = planet;
				return;
			}
		}
		a=(a+1) % planets.length;
	}
}

FocusedPlayer.prototype.PlanPlanet = function(planet)
{

	planet.priority[Planet.Priorities.Ship] = 20;
	
	if (this.shipLevel == 3)
	{
		// maxed out on tech.  Time to start building fleets in earnest.
		planet.priority[Planet.Priorities.Ship] = 60;
		planet.priority[Planet.Priorities.Research] = 0;
	}


	if (!this.targetPlanet)
	{
		// no planets in range.  Nothing for fleets to do.
		planet.priority[Planet.Priorities.Ship] = 0;
		planet.priority[Planet.Priorities.Research] = Util.GetMin(20, planet.priority[Planet.Priorities.Research]);
		return;
	}


	var fleet = Fleet.GetByPlanetAndOwner(planet, this);
	var fleetThere = Fleet.GetByPlanetAndOwner(this.targetPlanet, this);


if (Universe.turn > 100 && 	this.targetPlanet.name=="Sol")
{
	//Util.AlertMulti(this.HasExplored(this.targetPlanet), this.targetPlanet.owner, fleetThere, fleet);
}

	
	if (!this.targetPlanet.owner)
	{
		// uninhabited

		if (!this.HasExplored(this.targetPlanet))
		{
			// TODO - this.HasSentScouts(targetPlanet)
			if (fleet && fleet.GetShipCount() >= 1)
			{
				fleet.SendTo(this.targetPlanet, [1,1,1,1]);
			}
		}
		else if (this.ShouldColonize(this.targetPlanet) && fleet && fleet.GetShipFirepower() >= Ship.ColonyFirepower)
		{
			fleet.SendTo(this.targetPlanet, [32,16,8,4]);
		}
		else
		{
			// This planet sucks.  Let's look at another one.
			this.ChooseNewTarget();
		}

	}
	else if (this.targetPlanet.owner != this)
	{
		// enemy (TODO: friend)
		if (fleetThere && !fleetThere.IsEmpty() && planet.population > 60 && Math.random() > 0.2)
		{
			// fleet in orbit of the target planet, and we have armies to send
			planet.TransportTo(this.targetPlanet, 20);
		}
		else if (fleet && fleet.GetShipCount() > 10 && Math.random()>0.8)
		{
			fleet.SendTo(this.targetPlanet, [1000,1000,1000,1000]);
		}
	}
	else
	{
		// mine
		if (this.targetPlanet.population < 20 && planet.population > 80)
		{
			// planet needs more people.
			planet.TransportTo(this.targetPlanet, 20);
		}
			
	}
	
	
	

/*
	if (this.targetPlanet && this.targetPlanet.owner != this)
	{		
		var fleet = Fleet.GetByPlanetAndOwner(planet, this);
		if (fleet && fleet.GetShipCount() > 10 && Math.random()>0.8)
		{
			fleet.SendTo(this.targetPlanet, [10,20,40,80]);
		}
		else if (planet.population > 60 && (!this.targetPlanet.owner || Fleet.GetByPlanetAndOwner(this.targetPlanet, this)))
		{
			// we have enough people to invade, and the planet is either empty or has one of our fleets in orbit
			
			planet.TransportTo(this.targetPlanet, 20);
		}
	}
*/

}

