コード例 #1
0
        public IEnumerable <PlayerInfo> CreateRater(CalcScoreType mode, int timePeriod = 0)
        {
            var rater = new List <PlayerInfo>();

            Factors = FactorsForm.GetFactors();

            DateTime startTime = timePeriod == 0 ? default : DateTime.Today - new TimeSpan(timePeriod, 0, 0, 0);

                                 UpdateFactors(mode, startTime);

                                 Dictionary <int, List <Game> > playersGames = Games.Where(g => g.GameDate >= startTime).GroupBy(g => g.PlayerId).ToDictionary(k => k.Key.Value, v => v.ToList());

                                 if (!playersGames.Any())
                                 {
                                     return(new List <PlayerInfo>());
                                 }

                                 foreach (KeyValuePair <int, List <Game> > player in playersGames)
                                 {
                                     IEnumerable <GameStats> games = player.Value.Select(g => new GameStats(g));
                                     var scores  = CalcScores(games, mode, timePeriod, false);
                                     var avgGame = GameStats.GetAvgStats(games.ToArray());
                                     avgGame.Score = scores["Score"];
                                     var playerT =
                                         new PlayerInfo(Players.First(p => p.ID == player.Key), new[] { new Game(avgGame, -1, player.Key) })
                                     {
                                         Scores = scores,
                                     };
                                     rater.Add(playerT);
                                 }

                                 return(rater.OrderByDescending(p => p.Scores["Score"]).Select((r, i) =>
            {
                r.RaterPos = ++i;
                return r;
            }));
        }
コード例 #2
0
 public override string ToString()
 {
     return(PlayerName + "," + GameStats.GetAvgStats(Games.ToArray()));
 }
コード例 #3
0
 public string ToShortString()
 {
     return(PlayerName + "," + GameStats.GetAvgStats(Games.ToArray()).ToShortString());
 }
コード例 #4
0
 public GameStats GetAvgGame()
 {
     return(GameStats.GetAvgStats(Games.ToArray()));
 }