private static async Task GetGameResults(string apiKey, string userKey) { var command = new GetUsersGames(apiKey, userKey); var results = await command.ExecuteAsync(); var command2 = new GetGames(apiKey); int index = 1; foreach (var result in results.response.games) { command2.SetAppId(result.appid); var game = await command2.ExecuteAsync().ConfigureAwait(false); Console.WriteLine($"Game {index}: appName - {game.game.gameName} ,app_id - {result.appid}, playtime_forever - {result.playtime_forever}"); index++; } }
private async Task GetRandomGame(string apiKey, string userId) { //var command = new GetUsersGames(apiKey, userId); if (_userGameList == null) { _userGameList = await _steamApiClient.GetUsersGames(userId).ConfigureAwait(false); } var command2 = new GetGames(apiKey); GameData game; int id; do { var appIds = _userGameList.response.games.Select(x => x.appid).ToList(); //One Route int r = rnd.Next(appIds.Count); //TODO: Filter results id = appIds[r]; var gameToRemove = _userGameList.response.games.FirstOrDefault(x => x.appid == id); command2.SetAppId(id); game = await command2.ExecuteAsync().ConfigureAwait(false); if (game.game.gameName == null) { //REmove app id from list var removed = _userGameList.response.games.Remove(gameToRemove); if (removed) { Console.WriteLine($"INFO: App Id resulted in a null game name. Game Removed From List AppId: {id}"); } } if (game.game.gameName == "") { Console.WriteLine($"INFO: App Id resulted in a game name of \"\". Game NOT Removed From List AppId: {id}"); } } while (game.game.gameName == null); Console.WriteLine($"Random Game Name - {game.game.gameName} ,app_id - {id}"); }