コード例 #1
0
 public override void Apply(ImperaPlus.Domain.User user, Game game)
 {
     // Do not modify anything
 }
コード例 #2
0
 public override void Apply(ImperaPlus.Domain.User user, Game game)
 {
     this.ApplyMap(user, game, game.Map);
 }
コード例 #3
0
        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();
        }
コード例 #4
0
 public abstract void Apply(ImperaPlus.Domain.User user, Game game);