예제 #1
0
        private void quali_Click(object sender, EventArgs e)
        {
            var playersCount = int.Parse(PlayersCount.Text);
            var gPlayersCount = int.Parse(GPlayersCount.Text);
            var qualifyingCount = int.Parse(QCount.Text);
            var ps = Enumerable.Range(0, gPlayersCount).Select(i => new Player { Id = i + 1, Rank = i+1/* m_randomizer.Next(0, gPlayersCount)*/ });
            players.Items.Clear();
            players.Items.AddRange(ps.ToArray());
            var engine = new QualifyingPositioningEngine();
            var evPositions = engine.Evaluate(new QualifyingPositionParameters()
                                                {
                                                    PlayersCount = playersCount,
                                                    QualifyingCount = qualifyingCount,
                                                    Players = ps.ToArray()
                                                });
            positions.Items.Clear();
            var index = 1;
            foreach (var competitionPosition in evPositions)
            {

                positions.Items.Add(string.Format("{0}:{1}", index, competitionPosition.PlayerId));
                index++;
            }
        }
 private CompetitionPosition[] PositionQualifyingPlayers(CompetitionDetails details, CompetitionPlayer[] qualifyingPlayers)
 {
     var qualifyingPositioningEngine = new QualifyingPositioningEngine();
     var qualifyingPositioningParameters = new QualifyingPositionParameters
     {
         PlayersCount = details.Type.QualifyingPlayersCount,
         QualifyingCount = details.Type.QualifyingToFinalPlayersCount,
         Players = (from p in qualifyingPlayers.Take<CompetitionPlayer>(details.Type.QualifyingPlayersCount) select new Simple.SAMS.CompetitionEngine.Player
                                                                                                                        {
                                                                                                                            Id = p.Id, 
                                                                                                                            Rank = p.CompetitionRank,
                                                                                                                            AverageScore = p.AverageScore.GetValueOrDefault(),
                                                                                                                            AccumulatedScore = p.AccumulatedScore.GetValueOrDefault()
                                                                                                                        }).ToArray<Simple.SAMS.CompetitionEngine.Player>()
     };
     
     return qualifyingPositioningEngine.Evaluate(qualifyingPositioningParameters);
 }