/// <summary> /// Updates the map. /// </summary> /// <param name="player">Player.</param> /// <param name="regionId">Region identifier.</param> /// <param name="armies">Armies.</param> public void UpdateMap(int regionId, string player, int armies) { if (VisibleMap.Regions.ContainsKey (regionId)) { Region originalRegion = VisibleMap.Regions [regionId]; originalRegion = VisibleMap.Regions [regionId]; originalRegion.Owner = player; originalRegion.Armies = armies; } else { Region originalRegion = CompleteMap.Regions [regionId]; Region newRegion; Continent continent; if (!VisibleMap.Continents.Contains (originalRegion.Continent)) { Continent originalContinent = originalRegion.Continent; Continent newContinent = new Continent (originalContinent.Id, originalContinent.Reward); VisibleMap.Continents.Add (newContinent); } continent = VisibleMap.ContinentForId (originalRegion.Continent.Id); newRegion = new Region (originalRegion.Id, continent); foreach (Region n in originalRegion.Neighbors) { if (VisibleMap.Regions.ContainsKey (n.Id)) { newRegion.AddNeighbor (VisibleMap.Regions[n.Id]); } } newRegion.Owner = player; newRegion.Armies = armies; VisibleMap.AddRegion (newRegion); } if (Logger.IsDebug ()) { Logger.Debug (string.Format("State:\tUpdated region {0} with owner {1} and {2} armies.", regionId, player, armies)); } }
/// <summary> /// Adds a neighbor to this region's list of neighbors. /// </summary> /// <param name="region">Region.</param> public void AddNeighbor(Region region) { if (!region.Equals (this) && !Neighbors.Contains (region)) { Neighbors.Add (region); region.AddNeighbor (this); if (IsBorderRegion ()) { Continent.BorderRegions.Add (this); } if (Logger.IsDebug ()) { Logger.Debug (string.Format("Region {0}:\tAdded neighbor {1}.", Id, region.Id)); } } }