Пример #1
0
        public void TryToCreateTrainingWar()
        {
            using (var trs = transactionScopeProvider.CreateTransactionScope())
                if (warRepository.Any(w => w.IsTrainingWar) == false)
                {
                    var anyCountry  = countryRepository.First();
                    var anyRegion   = anyCountry.Regions.First();
                    var trainingWar = new War()
                    {
                        AttackerCountryID = anyCountry.ID,
                        DefenderCountryID = anyCountry.ID,
                        Active            = true,
                        StartDay          = GameHelper.CurrentDay,
                        IsTrainingWar     = true
                    };

                    warRepository.Add(trainingWar);
                    warRepository.SaveChanges();

                    var battle = new Battle()
                    {
                        Active     = true,
                        WarID      = trainingWar.ID,
                        WallHealth = 99999,
                        RegionID   = anyRegion.ID,
                        StartTime  = DateTime.Now,
                        StartDay   = GameHelper.CurrentDay,
                    };

                    battleRepository.Add(battle);
                    battleRepository.SaveChanges();

                    trs.Complete();
                }
        }