public bool SetOutpost(Player player, BoardVertice vertice) { // Disqualify if insufficiant resources. if (resources.GetDilithium() < 1 || resources.GetTritanium() < 1 || resources.GetFood() < 1 || resources.GetOxygen() < 1) { return(false); } // Disqualify if outpost already present. if (vertice.HasOutpost()) { return(false); } // Disqualify if outpost at adjacent vertices and no starship present. bool hasStarship = false; foreach (BoardVerticePath path in vertice.GetPaths()) { if (path.HasStarship() && path.GetStarship().GetOwner().GetOrder() == order) { hasStarship = true; } if (path.GetToVertice().HasOutpost()) { return(false); } } if (!hasStarship) { return(false); } // Evaluate second degree starship foreach (BoardVerticePath path in vertice.GetPaths()) { if (path.HasStarship()) { foreach (BoardVerticePath nextDegreePath in path.GetToVertice().GetPaths()) { if (nextDegreePath.HasStarship() && nextDegreePath.GetStarship().GetOwner().GetOrder() == order && nextDegreePath.GetToVertice().GetLocation() != vertice.GetLocation()) { //create outpost Outpost newOutpost = new Outpost(player, vertice); // Add outpost to player outposts.Add(newOutpost); // Add outpost to vertice vertice.SetOutpost(newOutpost); // Remove resources from player resources.RemoveDilithium(1); resources.RemoveTritanium(1); resources.RemoveFood(1); resources.RemoveOxygen(1); // Add points points++; return(true); } } } } // No second degree starship present. return(false); }
public bool SetFirstOutpost(Player player, BoardVertice vertice) { if (vertice.HasOutpost()) { return(false); } else { //create outpost Outpost newOutpost = new Outpost(player, vertice); // add outpost to player outposts.Add(newOutpost); // add outpost to vertice vertice.SetOutpost(newOutpost); //add points points++; return(true); } }