private void ApplyMap(Domain.User user, Game game, Map map)
        {
            if (game.State == GameState.Ended)
            {
                return;
            }

            var visibleCountries = new List<Country>();

            var player = game.Teams.SelectMany(x => x.Players).FirstOrDefault(x => x.UserId == user.Id);
            if (player != null)
            {
                var team = game.Teams.First(x => x.Players.Any(p => p.Id == player.Id));

                var mapTemplate = this.MapTemplateProvider.GetTemplate(game.MapTemplate);
                var countryDict = map.Countries.ToDictionary(x => x.Identifier);

                foreach (var country in map.Countries)
                {
                    if (country.TeamId == team.Id // Country belongs to player's team
                    || mapTemplate
                            .GetConnectedCountries(country.Identifier)
                            .Select(x => countryDict[x])
                            .Any(x => x.TeamId == team.Id)) // Country is connected to a country which belongs to player's team
                    {
                        visibleCountries.Add(country);
                    }
                }
            }

            map.Countries = visibleCountries.ToArray();
        }
 private void ApplyMapUpdates(Map map, IEnumerable<Country> countryUpdates)
 {
     foreach (var countryUpdate in countryUpdates)
     {
         var country = map.Countries.Single(x => x.Identifier == countryUpdate.Identifier);
         country.Units = countryUpdate.Units;
         country.PlayerId = countryUpdate.PlayerId;
         country.TeamId = countryUpdate.TeamId;
     }
 }