Пример #1
0
        /// <summary>
        /// Transfers the armies.
        /// </summary>
        /// <returns></returns>
        public IEnumerable <ArmyTransfer> TransferArmies()
        {
            /*
             * Inspect Border Territories foreach super region
             * If there are no enemy armies sighted: let's conquer the continent
             *
             * If there are enemy armies sighted: let's move some troops to defend those invasion paths
             * */
            Transfers = new List <ArmyTransfer>();

            SuperRegions.ForEach(CalculateTransfers);

            //Don't attack the enemy if we are below the starting round, instead skip this move
            if (Configuration.Current.GetRoundNumber() < Configuration.Current.GetStartRoundNumber())
            {
                Transfers.ForEach(
                    transfer =>
                {
                    if (transfer.TargetRegion.IsOccupiedBy(PlayerType.Opponent))
                    {
                        Transfers.Remove(transfer);
                    }
                }
                    );
            }

            return(Transfers);
        }
Пример #2
0
 /// <summary>
 /// Calculates if there are border territories with enemy armies in this super region
 /// </summary>
 /// <param name="superRegion">The super region.</param>
 /// <param name="allSuperRegions">All super regions.</param>
 /// <returns></returns>
 public static bool EnemyBorderTerritories(SuperRegion superRegion, SuperRegions allSuperRegions)
 {
     /*
      * Searches all border territories with neighbours occupied by the opponent
      * Then checks if these border territories are occupied by me OR have neighbours in the same super region that are occuped by me
      * */
     return(superRegion.BorderTerritories
            .Where(bt => bt.Neighbours.Any(btn => btn.IsOccupiedBy(PlayerType.Opponent)))
            .Any(bt => (bt.IsOccupiedBy(PlayerType.Me)) || bt.Neighbours.Any(btn => btn.IsOccupiedBy(PlayerType.Me) && allSuperRegions.Get(btn) == superRegion)));
 }
Пример #3
0
 /**
  * Add a SuperRegion to the map
  * @param superRegion : SuperRegion to be Added
  */
 public void Add(SuperRegion superRegion)
 {
     foreach (SuperRegion sr in SuperRegions)
     {
         if (sr.Id == superRegion.Id)
         {
             Console.Error.WriteLine("SuperRegion cannot be Added: id already exists.");
             return;
         }
     }
     SuperRegions.Add(superRegion);
 }
Пример #4
0
        /// <summary>
        /// Adds the region.
        /// </summary>
        /// <param name="id">The identifier.</param>
        /// <param name="superRegionId">The super region identifier.</param>
        public void AddRegion(int id, int superRegionId)
        {
            var region = new Region {
                ID = id
            };

            Regions.Add(region);

            var superRegion = SuperRegions.Get(superRegionId);

            superRegion.AddChildRegion(region);
            region.SuperRegion = superRegion;
        }
Пример #5
0
 public int MapBonusArmiesAward()
 {
     return(SuperRegions.Sum(SR => SR.BonusArmiesAward));
 }
Пример #6
0
 /**
  * @param id : a SuperRegion id number
  * @return : the matching SuperRegion object
  */
 public SuperRegion GetSuperRegion(int id)
 {
     return(SuperRegions.Where(r => r.Id == id).FirstOrDefault());
 }
Пример #7
0
 /// <summary>
 /// Adds the super region.
 /// </summary>
 /// <param name="id">The identifier.</param>
 /// <param name="reward">The reward.</param>
 public void AddSuperRegion(int id, int reward)
 {
     SuperRegions.Add(new SuperRegion {
         ID = id, Reward = reward
     });
 }
Пример #8
0
 /// <summary>
 /// Prevents a default instance of the <see cref="Board"/> class from being created.
 /// </summary>
 private Board()
 {
     SuperRegions = new SuperRegions();
     Regions      = new Regions();
 }
Пример #9
0
 /// <summary>
 /// Calculates the super regions borders.
 /// </summary>
 public void CalculateSuperRegionsBorders()
 {
     SuperRegions.ForEach(CalculateSuperRegionBorders);
 }