Ejemplo n.º 1
0
        private void QualifyInConsolation(MatchHeaderInfo match)
        {
            var competitionId = match.CompetitionId;
            var winner        = match.Winner == MatchWinner.Player1 ? match.Player1 : match.Player2;
            var competitionMatchesRepository = ServiceProvider.Get <ICompetitionMatchesRepository>();
            var qualifyToMatch = default(MatchHeaderInfo);
            var playersCount   = 32;
            var map            = new ConsolationMap();
            var nextPosition   = map.GetNextPosition(playersCount, match.Position);

            qualifyToMatch = competitionMatchesRepository.GetMatchByPosition(competitionId,
                                                                             CompetitionSection.Consolation,
                                                                             nextPosition.Item1);

            if (qualifyToMatch.IsNotNull() && winner != null)
            {
                competitionMatchesRepository.UpdatePlayersPosition(competitionId,
                                                                   new[]
                {
                    new UpdatePlayerPositionInfo
                    {
                        MatchId  = qualifyToMatch.Id,
                        PlayerId = winner.Id,
                        Position = nextPosition.Item2
                    }
                });
            }
        }
Ejemplo n.º 2
0
        private void QualifyToConsolation(MatchHeaderInfo match)
        {
            var playersCount = 32;
            var competitionMatchesRepository = ServiceProvider.Get <ICompetitionMatchesRepository>();
            var round          = 0;
            var rounds         = competitionMatchesRepository.GetCompetitionSectionRounds(match.CompetitionId, CompetitionSection.Final);
            var qualifyToMatch = default(MatchHeaderInfo);

            if (match.Round == (6 - rounds))
            {
                qualifyToMatch = competitionMatchesRepository.GetMatchByRelativePosition(match.CompetitionId,
                                                                                         CompetitionSection.Consolation,
                                                                                         round,
                                                                                         match.Position / 2);
            }
            else
            {
                var map      = new ConsolationMap();
                var position = map.Position(playersCount, match.Position);
                qualifyToMatch = competitionMatchesRepository.GetMatchByPosition(match.CompetitionId,
                                                                                 CompetitionSection.Consolation, position);
            }

            var looser = (match.Winner == MatchWinner.Player1 ? match.Player2 : match.Player1);

            if (looser != null && qualifyToMatch != null)
            {
                var roundMatchesCount = competitionMatchesRepository.GetRoundMatchesCount(match.CompetitionId,
                                                                                          CompetitionSection.Consolation,
                                                                                          qualifyToMatch.Round);
                var updatePlayerInfo = new UpdatePlayerPositionInfo()
                {
                    MatchId  = qualifyToMatch.Id,
                    PlayerId = looser.Id,
                    Position = match.Round == (6 - rounds) ?  (qualifyToMatch.Player1 == null? 0 : 1) : (qualifyToMatch.RoundRelativePosition < roundMatchesCount / 2 ? 1 : 0)
                };



                competitionMatchesRepository.UpdatePlayersPosition(match.CompetitionId, new[] { updatePlayerInfo });
            }
        }