Exemplo n.º 1
0
        public async Task <UserGameListData> ExecuteAsync()
        {
            try
            {
                //TODO: Make this into an extension method that checks for null values
                var path = $"IPlayerService/GetOwnedGames/v0001/?key={_apiKey}&steamid={_userSteamId}&format=json";

                HttpResponseMessage response = await SteamClient.GetAsync(path).ConfigureAwait(false);

                var results = new UserGameListData();

                if (response.IsSuccessStatusCode)
                {
                    var dataAsString = await response.Content.ReadAsStringAsync().ConfigureAwait(false);

                    results = JsonConvert.DeserializeObject <UserGameListData>(dataAsString);
                }

                return(results);
            }
            catch (Exception e)
            {
                Console.Write($"Stock Intel Exception Thrown: {e.Message}");
                return(null);
            }
        }
Exemplo n.º 2
0
        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}");
        }