//todo:need to refactor public IEnumerable<PlayerStatistics> GetPlayerStatisticsByName(string name) { if (!OponentNames.Contains(name)) throw new Exception(string.Format("Player with name {0} is not found!", name)); var playerGames = _context.Games.GetGamesForPlayer(name).ToList(); var limits = playerGames.GetDistinctLimits(); foreach (var l in limits) { SeatType limit = l; var limitGames = playerGames.GetGamesForLimit(limit).ToList(); var limitGameCount = limitGames.Count(); var valPutCount = limitGames.VPIPCountForPlayer(name); var preflopRaiseCount = limitGames.PFRCountForPlayer(name); var atsPercent = limitGames.GetATSPercentForPlayer(name); var afpfPercent = limitGames.GetAFPercentForPlayer(name); var playerStatistics = new PlayerStatistics { Name = name, Limit = l, VPIP = decimal.Round((decimal)valPutCount/(decimal)limitGameCount*100,2), PFR = decimal.Round((decimal)preflopRaiseCount / (decimal)limitGameCount * 100, 2), ATS = decimal.Round((decimal)atsPercent, 2), AF = decimal.Round((decimal)afpfPercent, 2) }; yield return playerStatistics; } }
//todo:need to refactor public IEnumerable <PlayerStatistics> GetPlayerStatisticsByName(string name) { if (!OponentNames.Contains(name)) { throw new Exception(string.Format("Player with name {0} is not found!", name)); } var playerGames = _context.Games.GetGamesForPlayer(name).ToList(); var limits = playerGames.GetDistinctLimits(); foreach (var l in limits) { SeatType limit = l; var limitGames = playerGames.GetGamesForLimit(limit).ToList(); var limitGameCount = limitGames.Count(); var valPutCount = limitGames.VPIPCountForPlayer(name); var preflopRaiseCount = limitGames.PFRCountForPlayer(name); var atsPercent = limitGames.GetATSPercentForPlayer(name); var afpfPercent = limitGames.GetAFPercentForPlayer(name); var playerStatistics = new PlayerStatistics { Name = name, Limit = l, VPIP = decimal.Round((decimal)valPutCount / (decimal)limitGameCount * 100, 2), PFR = decimal.Round((decimal)preflopRaiseCount / (decimal)limitGameCount * 100, 2), ATS = decimal.Round((decimal)atsPercent, 2), AF = decimal.Round((decimal)afpfPercent, 2) }; yield return(playerStatistics); } }