GetOwnedGames() public method

public GetOwnedGames ( Player player ) : IList
player Player
return IList
Ejemplo n.º 1
0
        public List <GamePlayers> Compare(IList <Player> players)
        {
            var gameCount = new Dictionary <int, Tuple <Game, List <Player> > >();

            foreach (var player in players)
            {
                foreach (var game in _api.GetOwnedGames(player))
                {
                    // Remove beta games and tools
                    if (bannedAppIds.Contains(game.AppId))
                    {
                        continue;
                    }

                    var gamePlayTime = game.HoursPlayed;

                    if (!gameCount.ContainsKey(game.AppId))
                    {
                        gameCount.Add(game.AppId, Tuple.Create(game, new List <Player>()));
                        gameCount[game.AppId].Item1.HoursPlayed = 0; // Reset playtime
                    }

                    gameCount[game.AppId].Item1.HoursPlayed += gamePlayTime;
                    gameCount[game.AppId].Item2.Add(player);
                }
            }

            return((from g in gameCount
                    where g.Value.Item2.Count > 1
                    orderby g.Value.Item2.Count descending, g.Value.Item1.HoursPlayed descending
                    select new GamePlayers()
            {
                AppId = g.Value.Item1.AppId,
                IconUrl = g.Value.Item1.IconUrl,
                LogoUrl = g.Value.Item1.LogoUrl,
                StoreUrl = g.Value.Item1.StoreUrl,
                Name = g.Value.Item1.Name,
                HoursPlayed = g.Value.Item1.HoursPlayed,
                Players = g.Value.Item2
            }).ToList());
        }