/// <summary>Gets the region count that are opponents for the owner inlcuding neutral.</summary>
 public static int GetOpponentCountForPlayer(this IEnumerable <Region> regions, PlayerType owner, MapState state)
 {
     return(regions.Count(region => !state.HasOwner(region, owner)));
 }
 /// <summary>Returns true if all regions have the specified owener.</summary>
 public static bool HaveOwner(this IEnumerable <Region> regions, PlayerType owner, MapState state)
 {
     return(regions.All(region => state.HasOwner(region, owner)));
 }
 /// <summary>Gets the regions that are enermies for the owner excluding neutral.</summary>
 public static IEnumerable <Region> GetEnemriesForPlayer(this IEnumerable <Region> regions, PlayerType owner, MapState state)
 {
     return(regions.Where(region => state.Owner(region) != PlayerType.neutral && !state.HasOwner(region, owner)));
 }
 /// <summary>Gets the attacking force of the regions.</summary>
 public static int AttackingForce(this IEnumerable <Region> regions, MapState state)
 {
     return(regions
            .Where(region => state.Owner(region) != PlayerType.neutral)
            .Sum(region => state.Armies(region) - 1));
 }
 /// <summary>Gets the regions that are opponents for the owner inlcuding neutral.</summary>
 public static IEnumerable <Region> GetOpponentsForPlayer(this IEnumerable <Region> regions, PlayerType owner, MapState state)
 {
     return(regions.Where(region => !state.HasOwner(region, owner)));
 }
 /// <summary>Gets the regions that are enermies for the owner excluding neutral.</summary>
 public static IEnumerable <Region> GetRegionsForPlayerWithOpponents(this IEnumerable <Region> regions, PlayerType owner, MapState state)
 {
     return(regions.Where(region =>
                          state.HasOwner(region, owner) &&
                          region.Neighbors
                          .Any(neighbor => !state.HasOwner(neighbor, owner))));
 }
 /// <summary>Gets the regions that are enermies for the owner excluding neutral.</summary>
 public static IEnumerable <Region> GetRegionsForPlayerWithEnermies(this IEnumerable <Region> regions, PlayerType owner, MapState state)
 {
     return(regions.Where(region =>
                          state.HasOwner(region, owner) &&
                          region.Neighbors
                          .Any(neighbor =>
                               state.Owner(neighbor) != PlayerType.neutral &&
                               !state.HasOwner(neighbor, owner))));
 }
Ejemplo n.º 8
0
 /// <summary>Gets the super region bonus for a player excluding the default stack.</summary>
 public int GetSuperRegionBonus(PlayerType player, MapState state)
 {
     return(this.SuperRegions
            .Where(super => super.All(region => state.HasOwner(region, player)))
            .Sum(super => super.BonusArmiesReward));
 }
Ejemplo n.º 9
0
 public static IEnumerable <SuperRegion> GetConquerables(this IEnumerable <SuperRegion> superregions, PlayerType player, MapState state)
 {
     return(superregions
            .Where(s => s.SelfAndNeighbors
                   .Any(region => state.HasOwner(region, player)) && s.SelfAndNeighbors
                   .Any(region => !state.HasOwner(region, player))));
 }