Beispiel #1
0
        protected override void CalculatePriorities(IEnumerable <TableRecord> records)
        {
            // If previous rules haven't solved any rows, the recursion must be stopped.
            if (records.Count() == Records.Count())
            {
                return;
            }

            short              tourneyId = records.First().tourneyId;
            IEnumerable <int>  teamIds   = records.Select(rg => rg.teamId);
            IEnumerable <Game> games     = gameBll.GetGamesByTourneyBetweenTeams(tourneyId, teamIds);

            if (!games.Any())
            {
                return;
            }

            TableBase table = new ClassicTable();

            table.BuildFromGames(tourneyId, games);

            IRanking ranking = new Implementations.Components.Ranking();

            ranking.CalculateTable(Rule, games);

            IEnumerable <TableRecord> prioritizedTable = ranking.CalculateTable(Rule, games);

            foreach (TableRecord record in records)
            {
                record.PointsVirtual = prioritizedTable.FirstOrDefault()?.PointsVirtual ?? 0;
            }
        }