Beispiel #1
0
        private List <GamesCycle> ScheduleLeagueGroup(Group group, GameSettings settings)
        {
            List <int> groupTeamsIds              = group.GroupsTeams.Where(gt => gt.Team.IsArchive == false).OrderBy(gt => gt.Pos).Select(gt => gt.TeamId).ToList();
            int        numberOfCycles             = group.NumberOfCycles.HasValue ? group.NumberOfCycles.Value : 1;
            List <Tuple <int, int> > combinations = RoundRobin.GetMatches(groupTeamsIds);

            combinations = CreateCombinationCycles(numberOfCycles, combinations);
            List <GamesCycle> groupGames = CreateGamesFromCombinations(combinations);

            groupGames.ForEach(g =>
            {
                g.GroupeId = group.GroupId;
                g.StageId  = group.StageId;
            });
            int numberOfTeams            = groupTeamsIds.Count;
            int numberOfGamesInRound     = numberOfTeams / 2;
            int numberOfRoundsInOneCycle = GetNumberOfRoundsInOneCycle(group.TypeId, numberOfTeams);
            var totalNumberOfRoundes     = numberOfRoundsInOneCycle * numberOfCycles;

            SchedualGames(settings.ActualStartDate, settings.SettingsDays, settings.SequenceRounds, numberOfGamesInRound, totalNumberOfRoundes, groupGames);
            SaveGamesList(groupGames);
            return(groupGames);
        }