Example #1
0
 public IEnumerable<Match> FlatMatch(Match match)
 {
     if (match.Count() > 0)
     {
         foreach (var child in match)
         {
             foreach (var m in FlatMatch(child))
             {
                 yield return m;
             }
         }
     }
     else
     {
         yield return match;
     }
 }
Example #2
0
        private async Task <int> CountMatches(string guid, Func <Match, bool> criteria, int minPage, int maxPage, Throttle throttle, ProgressData progressData)
        {
            IEnumerable <Match> pageMatches = new Match[0];

            // Try to find some page that is at least as high as the highest valid match.
            do
            {
                pageMatches = await GetMatchesPageAsync(guid, maxPage, false, throttle, progressData);

                if (pageMatches.Any(match => !criteria(match)) || !pageMatches.Any())
                {
                    break;
                }
                maxPage *= 2;
            } while (true);

            // Back down to find the the page that is exactly as high as the highest valid match
            var midPage = minPage;

            while (maxPage > minPage)
            {
                midPage     = (maxPage + minPage) / 2;
                pageMatches = await GetMatchesPageAsync(guid, midPage, false, throttle, progressData);

                if (pageMatches.Any(match => criteria(match)))
                {
                    if (pageMatches.Any(match => !criteria(match)))
                    {
                        break;
                    }
                    minPage = midPage + 1;
                }
                else
                {
                    maxPage = midPage;
                }
            }

            return((midPage - 1) * _matchesPerPage + pageMatches.Count(match => criteria(match)));
        }
Example #3
0
 public double LoserNewRating(double current, Match match)
 {
     return(current - WinnerExtraPoints(match.ContenderRating(), current, match.Count()));
 }
Example #4
0
 public double LoserNewRating(double current, Match match)
 {
     return(current - _increase * match.Count());
 }