예제 #1
0
        public Competition(CompetitionConfig config)
        {
            if (config.Teams.Count < 4)
            {
                throw new ArgumentException("Competition requires at least 4 teams");
            }

            var matches = new List <Match>();

            foreach (var current in config.Teams)
            {
                foreach (var team in config.Teams)
                {
                    if (current != team)
                    {
                        matches.Add(new Match(current, team, config.AmountOfChallengesPerMatch));
                    }
                }
            }

            FixtureSchedule = new FixtureSchedule(config.Teams, matches);

            Table = new Table(config, matches);

            Rules = config.Rules;
        }
예제 #2
0
        internal Table(CompetitionConfig config, List <Match> matches)
        {
            _rules = config.Rules;
            var statistics = new List <TableStatistics>();

            foreach (var team in config.Teams)
            {
                var matchesForTeam = matches.Where(m => m.HomeTeam == team || m.AwayTeam == team).ToList();
                statistics.Add(new TableStatistics(team, matchesForTeam));
            }

            SortStatistics(statistics, matches);

            if (Statistics.Count != statistics.Count)
            {
                System.Diagnostics.Debugger.Break();
            }
        }