コード例 #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
ファイル: Table.cs プロジェクト: Meilu/CompetitionSimulator
        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();
            }
        }