Example #1
0
 public DeleteServices(ApplicationDbContext dbContext, IRunwaysServices runwaysServices,
                       IRallyPilotsServices pilotsServices)
 {
     this.dbContext = dbContext;
     this.runways   = runwaysServices;
     this.pilots    = pilotsServices;
 }
Example #2
0
 public CarServices(ApplicationDbContext dbContext, IRallyPilotsServices rallyPilots,
                    IRallyNavigatorsServices rallyNavigators, IMoneyAccountServices accountServices)
 {
     this.dbContext       = dbContext;
     this.rallyPilots     = rallyPilots;
     this.rallyNavigators = rallyNavigators;
     this.money           = accountServices;
 }
Example #3
0
 public EditServices(ApplicationDbContext dbContext, IRunwaysServices runwaysServices, IRallyPilotsServices pilotsServices,
                     ICompetitionsServices competitionsServices)
 {
     this.dbContext    = dbContext;
     this.runways      = runwaysServices;
     this.pilots       = pilotsServices;
     this.competitions = competitionsServices;
 }
Example #4
0
 public TeamsController(ILogger <TeamsController> logger, IRallyPilotsServices dbPilot,
                        IRallyNavigatorsServices dbNavigator, ITeamServices teamServices)
 {
     _logger   = logger;
     pilot     = dbPilot;
     navigator = dbNavigator;
     this.team = teamServices;
 }
Example #5
0
 public TrainingController(ILogger <HomeController> logger, ITrainingServices dbTraining,
                           IMoneyAccountServices moneyAccountServices, IRallyPilotsServices rallyPilotsServices, IRallyNavigatorsServices rallyNavigatorsServices)
 {
     _logger        = logger;
     training       = dbTraining;
     this.money     = moneyAccountServices;
     this.pilot     = rallyPilotsServices;
     this.navigator = rallyNavigatorsServices;
 }
Example #6
0
 public TeamServices(ApplicationDbContext dbContext, ICarServices carServices, IMoneyAccountServices moneyAccountServices,
                     IRallyPilotsServices rallyPilots, IRallyNavigatorsServices navigatorsServices)
 {
     this.dbContext = dbContext;
     this.car       = carServices;
     this.money     = moneyAccountServices;
     this.pilot     = rallyPilots;
     this.navigator = navigatorsServices;
 }
Example #7
0
 public CompetitionsController(ILogger <CompetitionsController> logger, ICarServices carServices, ICompetitionsServices competitionsServices,
                               ITeamServices teamServices, IRallyPilotsServices rallyPilots, IRallyNavigatorsServices rallyNavigators, IRunwaysServices runwaysServices)
 {
     this._logger      = logger;
     this.cars         = carServices;
     this.competitions = competitionsServices;
     this.teams        = teamServices;
     this.pilots       = rallyPilots;
     this.navigators   = rallyNavigators;
     this.runways      = runwaysServices;
 }
Example #8
0
        private async Task RepairParts(Parts typeParts, IRallyPilotsServices rallyPilots, int idPilot,
                                       IRallyNavigatorsServices rallyNavigators, int idNavigator)
        {
            var energy = 100 - typeParts.Strength;

            typeParts.Strength = 100;
            rallyPilots.IsWorking(idPilot);
            rallyPilots.DecreaseEnergy(idPilot, Decimal.ToInt32(energy));
            rallyNavigators.IsWorking(idNavigator);
            rallyNavigators.DecreaseEnergy(idNavigator, Decimal.ToInt32(energy));
            await dbContext.SaveChangesAsync();
        }
Example #9
0
 public AdminController(ILogger <AdminController> logger, ICreateServices createServices,
                        IOpinionsServices opinionsServices, IRunwaysServices runwaysServices, IRallyPilotsServices pilotsServices, IEditServices editServices,
                        IDeleteServices deleteServices, ICompetitionsServices competitionsServices)
 {
     this._logger      = logger;
     this.create       = createServices;
     this.opinions     = opinionsServices;
     this.runways      = runwaysServices;
     this.pilots       = pilotsServices;
     this.edit         = editServices;
     this.delete       = deleteServices;
     this.competitions = competitionsServices;
 }
 public CompetitionsServices(ApplicationDbContext dbContext, ICarServices carServices, ITeamServices teamServices,
                             IRallyPilotsServices pilotsServices, IRallyNavigatorsServices navigatorsServices, IRunwaysServices runwaysServices,
                             IRaceHistoryServices raceHistoryServices, IPeople people, IRatingListServices ratingListServices,
                             IMoneyAccountServices moneyAccountServices)
 {
     this.dbContext   = dbContext;
     this.cars        = carServices;
     this.team        = teamServices;
     this.pilots      = pilotsServices;
     this.navigators  = navigatorsServices;
     this.runways     = runwaysServices;
     this.raceHistory = raceHistoryServices;
     this.people      = people;
     this.money       = moneyAccountServices;
     this.ratingList  = ratingListServices;
 }
        private void CompetitiveStage(IRallyPilotsServices pilots, IPeople people, IRallyNavigatorsServices navigators,
                                      ITeamServices team, IRaceHistoryServices raceHistory, ICarServices cars, List <CompetitionsTeams> teams,
                                      RallyRunway runway, int count, List <CompetitionsTeams> crashed, decimal stages, int numberStage)
        {
            string input = string.Empty;

            for (int i = 0; i < count; i++)
            {
                var pilot       = pilots.GetPilotNoTracking(teams[i].PilotId);
                var energyPilot = pilots.EnergyPilot(teams[i].PilotId) - stages * damageConstant;
                people.ReduceEnergy(pilot, energyPilot);
                var navigator       = navigators.GetNavigator(teams[i].NavigatorId);
                var energyNavigator = navigators.EnergyNavigator(teams[i].NavigatorId) - stages * damageConstant;
                people.ReduceEnergy(navigator, energyNavigator);
                var teamRace = team.FindUserAsync(teams[i].TeamId).GetAwaiter().GetResult();
                int drive;

                if (numberStage == 1)
                {
                    if (i == 0)
                    {
                        if (teams[i].Drive == DriveType.Aggressive)
                        {
                            input = $"Първи стартира отборът на {teamRace.Name}, с пилот {pilot.FirstName}, който тръгва с мръсна газ. Наблюдаваме доста агресивно" +
                                    $" каране дано, навигатор до него {navigator.FirstName} му влее малко разум.";
                            drive = 3;
                        }
                        else if (teams[i].Drive == DriveType.Normal)
                        {
                            input = $"Първи стартира отборът на {teamRace.Name}, с пилот {pilot.FirstName}" +
                                    $" и навигатор до него {navigator.FirstName} ";
                            drive = 2;
                        }
                        else
                        {
                            input = $"Първи стартира отборът на {teamRace.Name}, с пилот {pilot.FirstName}, който потегля доста плахо. С това предпазливо каране, ще " +
                                    $"изостане доста в класацията, дано навигатор до него {navigator.FirstName} му повлияе полужително.";
                            drive = 1;
                        }
                    }
                    else
                    {
                        if (teams[i].Drive == DriveType.Aggressive)
                        {
                            input = $"Следващ е отборът на {teamRace.Name}, с пилот {pilot.FirstName}, който тръгва с мръсна газ. Наблюдаваме доста агресивно" +
                                    $" каране дано, навигатор до него {navigator.FirstName} му влее малко разум.";
                            drive = 3;
                        }
                        else if (teams[i].Drive == DriveType.Normal)
                        {
                            input = $"Следващия отборът на старта е {teamRace.Name}, с пилот {pilot.FirstName}" +
                                    $" и навигатор до него {navigator.FirstName} ";
                            drive = 2;
                        }
                        else
                        {
                            input = $"Към старт линията се приближава отборът на {teamRace.Name}, с пилот {pilot.FirstName}, който потегля доста плахо. С това предпазливо каране, ще " +
                                    $"изостане доста в класацията, дано навигатор до него {navigator.FirstName} му повлияе полужително.";
                            drive = 1;
                        }
                    }
                }
                else
                {
                    if (teams[i].Drive == DriveType.Aggressive)
                    {
                        input = $"Пилот {pilot.FirstName} от отборът на {teamRace.Name}, продължава с агресивното шофиране. Не съм обеден че това ще му донесе привилегии " +
                                $" за напред. Дано, навигатор до него {navigator.FirstName} го успокой за да не станем свидетели на катастрофа.";
                        drive = 3;
                    }
                    else if (teams[i].Drive == DriveType.Normal)
                    {
                        input = $"Пилот {pilot.FirstName} от отборът на {teamRace.Name}, продължава с едно чудестно представяне.";

                        drive = 2;
                    }
                    else
                    {
                        input = $"Пилот {pilot.FirstName} от отборът на {teamRace.Name}, продължава с плахото шофиране. Очаквах повече от този пилот " +
                                $"Дано навигатор до него {navigator.FirstName} даде малко смелост да натисне педала.";
                        drive = 1;
                    }
                }

                raceHistory.AddHistory(input);

                var random = RandomEvents(pilot, navigator, runway.Difficulty, drive);
                if (random == "the end")
                {
                    input = $"Мик невнимание и пилота {pilot.FirstName} изпусна завоя, колата се преобърна в канавката. Дано всички са наред. " +
                            $"Това беше края на състезанието за отбор: {teamRace.Name}";
                    var date = new DateTime();
                    ratingList.AddInRatingList(teamRace, date);
                    crashed.Add(teams[i]);
                }
                else if (random == "Ok")
                {
                    input = $"Без проблеми отборрът на {teamRace.Name} с {pilot.FirstName} зад волана и навигатор до него {navigator.FirstName}" +
                            $"преминаха през втората контрола";
                    var turbo = cars.GetTurbo(teamRace.User);
                    if (turbo != null && teams[i].UseOfTurboType == UseOfTurboType.Medium)
                    {
                        var    speed    = (cars.GetMaxCurrentSpeed(teamRace.User) + cars.GetTurbo(teamRace.User).Speed) / 60; //to convene in km / h
                        double time     = (double)stages / (double)speed;
                        var    date     = new DateTime();
                        var    realTime = date.AddMinutes(time);
                        ratingList.AddInRatingList(teamRace, realTime);
                    }
                    else
                    {
                        var    speed    = cars.GetMaxCurrentSpeed(teamRace.User) / 60; //to convene in km / h
                        double time     = (double)stages / (double)speed;
                        var    date     = new DateTime();
                        var    realTime = date.AddMinutes(time);
                        ratingList.AddInRatingList(teamRace, realTime);
                    }
                }
                else
                {
                    input = $"Пилота {pilot.FirstName} от отбора на {teamRace.Name}, се разсея за момент и излезе от идеалната линия. Това му костваше цени секунди";
                    var turbo = cars.GetTurbo(teamRace.User);
                    if (turbo != null && teams[i].UseOfTurboType == UseOfTurboType.Medium)
                    {
                        var    speed    = (cars.GetMaxSpeed(teamRace.User) + cars.GetTurbo(teamRace.User).Speed) / 60; //to convene in km / h
                        double time     = (double)stages / (double)speed;
                        var    date     = new DateTime();
                        var    realTime = date.AddMinutes(time).AddSeconds(double.Parse(random));
                        ratingList.AddInRatingList(teamRace, realTime);
                    }
                    else
                    {
                        var    speed    = cars.GetMaxSpeed(teamRace.User) / 60; //to convene in km / h
                        double time     = (double)stages / (double)speed;
                        var    date     = new DateTime();
                        var    realTime = date.AddMinutes(time).AddSeconds(double.Parse(random));
                        ratingList.AddInRatingList(teamRace, realTime);
                    }
                }

                raceHistory.AddHistory(input);

                pilots.DecreaseEnergy(pilot.Id, 100 - (int)energyPilot);
                pilots.IncreaseExperience(pilot.Id, numberStage);            //2 comes from the number of Stage - stageTwo
                navigators.DecreaseEnergy(navigator.Id, 100 - (int)energyNavigator);
                navigators.IncreaseExperience(navigator.Id, numberStage);    //2 comes from the number of Stage - stageTwo
                cars.Damage(teamRace.CarId, numberStage, runway.Difficulty); //2 comes from the number of Stage - stageTwo
            }
        }
Example #12
0
 public TrainingServices(ApplicationDbContext dbContext, IRallyPilotsServices pilotsServices, IRallyNavigatorsServices navigatorsServices)
 {
     this.dbContext  = dbContext;
     this.pilots     = pilotsServices;
     this.navigators = navigatorsServices;
 }