// Constructs a PlanetWars object instance, given a string containing a // description of a game state. public PlanetWars(string gameStatestring) { planets = new List<Planet>(); fleets = new Fleets(); ParseGameState(gameStatestring); //planets.Sort(new Comparer(this).Coordinates); Planets allPlanets = Planets(); Router.Init(allPlanets); planetHolders = new PlanetHolders(allPlanets.Count); foreach (Planet planet in allPlanets) { PlanetHolder planetHolder = new PlanetHolder(planet, FleetsGoingToPlanet(Fleets(), planet)); planetHolders.Add(planetHolder); } //FillMyPlanetsFrontLevel(); }
public int GetLastOwner(PlanetHolder planetHolder) { int lastOwner = planetHolder.GetPlanet().Owner(); if (planetHolder.OwnerSwitches.Count > 0) { lastOwner = planetHolder.OwnerSwitches[planetHolder.OwnerSwitches.Count - 1].NewOwner; } return lastOwner; }