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; })); }
public override string ToString() { return(PlayerName + "," + GameStats.GetAvgStats(Games.ToArray())); }
public string ToShortString() { return(PlayerName + "," + GameStats.GetAvgStats(Games.ToArray()).ToShortString()); }
public GameStats GetAvgGame() { return(GameStats.GetAvgStats(Games.ToArray())); }