示例#1
0
        /// <summary>
        /// Unit the players attacking squads with the player defending squad.
        /// </summary>
        /// <param name="player"></param>
        /// <returns></returns>
        public async Task ReturnSquadsToBase(Player player)
        {
            var city = player.City;
            var army = player.Army;

            var squads = army.Squads
                         .Where(s => s.CityId != city.Id && s.CityId != null)
                         .ToList();

            var defendingSquad = army.Squads
                                 .Where(s => s.CityId == city.Id)
                                 .SingleOrDefault();

            foreach (var squad in squads)
            {
                await _squadService.UniteSquads(defendingSquad, squad);

                await _squadService.DeleteSquad(squad, army);
            }
        }