public static Country GetConnectedFriendlyCountry(Game game, Player player, Country origin, MapTemplate mapTemplate)
 {
     return game.Teams.Where(x => x.Players.Contains(player))
             .SelectMany(t => t.Players)
             .SelectMany(p => p.Countries).First(c => mapTemplate.AreConnected(origin.CountryIdentifier, c.CountryIdentifier));
 }
示例#2
0
        internal void UpdateOwnership(Player oldPlayer, Player newPlayer, Country country)
        {
            if (oldPlayer != null)
            {
                if (this.PlayerToCountry.ContainsKey(oldPlayer.Id))
                {
                    this.PlayerToCountry[oldPlayer.Id].Remove(country);
                }
            }

            if (newPlayer != null)
            {
                if (this.PlayerToCountry.ContainsKey(newPlayer.Id))
                {
                    this.PlayerToCountry[newPlayer.Id].Add(country);
                }
                else
                {
                    this.PlayerToCountry.Add(newPlayer.Id, new List<Country> { country });
                }

                country.PlayerId = newPlayer.Id;
                country.TeamId = newPlayer.TeamId;
            }
            else
            {
                country.PlayerId = Guid.Empty;
                country.TeamId = Guid.Empty;
            }
        }
示例#3
0
 internal void UpdateOwnership(Player player, Country country)
 {
     this.UpdateOwnership(null, player, country);
 }
 public static Country GetConnectedEnemyCountry(Game game, Player player, Country origin, MapTemplate mapTemplate)
 {
     return GetEnemyTeams(game, player)
             .SelectMany(t => t.Players)
             .SelectMany(p => p.Countries).First(c => mapTemplate.AreConnected(origin.CountryIdentifier, c.CountryIdentifier));
 }