Ejemplo n.º 1
0
        public async Task <(bool, DiscordEmbed)> TryGenStoreEmbed(DiscordEmbedBuilder baseEmbed, uint id)
        {
            SteamAppDetails data = await _steamWebApiHelper.GetStoreDetails(id);

            baseEmbed
            .WithTitle(data.Name)
            .WithUrl(WebLinkPrefix_StorePage + data.SteamAppId)
            .WithThumbnail(data.HeaderImage)
            .WithDescription(data.ShortDescription.Length > 250 ? data.ShortDescription.Substring(0, 250).Trim() + "..." : data.ShortDescription);

            if (data.ReleaseDate.ComingSoon)
            {
                baseEmbed.AddField("Release Date", data.ReleaseDate.Date, true);
            }

            if (data.PriceOverview != null)
            {
                baseEmbed.AddField("Price", data.IsFree ? "Free" : data.PriceOverview.FinalFormatted, true);
            }

            if (data.Recommendations != null)
            {
                baseEmbed.AddField("Recommendatons", data.Recommendations.Total.ToString(), true);
            }

            if (data.Metacritic != null)
            {
                baseEmbed.AddField("Metacritic", $"[{data.Metacritic.Score}]({data.Metacritic.Url})", true);
            }

            baseEmbed.AddField("Steam Client Link", ClientLinkPrefix_StorePage + data.SteamAppId, true);

            return(true, baseEmbed.Build());
        }
Ejemplo n.º 2
0
        private async Task <int> AddGame(SteamAppDetails fullApp)
        {
            var releasedDate = fullApp.ReleaseDate.ReleaseDate;

            var fullGameModel = new FullGameAddModel
            {
                Title            = fullApp.Name,
                Type             = fullApp.Type,
                Website          = fullApp.Website,
                Description      = fullApp.Description,
                HeaderImage      = fullApp.HeaderImage,
                Background       = fullApp.Background,
                About            = fullApp.About,
                ShortDescription = fullApp.ShortDescription,
                ReleaseDate      = new ReleaseDateAddModel()
                {
                    ComingSoon   = fullApp.ReleaseDate.ComingSoon,
                    ReleasedDate = String.IsNullOrEmpty(releasedDate) ? "Not confirmed" : releasedDate
                },
                steamApp = new SteamAppAddModel()
                {
                    SteamAppId  = fullApp.SteamAppID,
                    SteamReview = fullApp.Reviews,
                    Valid       = true
                }
            };



            return(await _gameManager.AddFullGameAsync(fullGameModel));
        }
        private async Task <Dictionary <string, SteamAppDetails> > GetAppDetails(uint appId)
        {
            Url             url      = Url.Create($"https://store.steampowered.com/api/appdetails?key={apiKey}&appids={appId}");
            DocumentRequest request  = DocumentRequest.Get(url);
            IDocument       response = await context.OpenAsync(request);

            string content = response.Body.Text();
            Dictionary <string, SteamAppDetails> steamAppDetails = SteamAppDetails.FromJson(content);

            return(steamAppDetails);
        }
Ejemplo n.º 4
0
        private void addGameDeal(SteamAppDetails app, int gameId)
        {
            DateTime currentDateTime  = DateTime.Now;
            string   sqlFormattedDate = currentDateTime.ToString("yyyy-MM-dd HH:mm:ss.fff");


            var gamedeal = new GameDealAddModel
            {
                GameId   = gameId,
                DealDate = new DealDateAddModel {
                    DatePosted = sqlFormattedDate
                },
                Url    = _basedStoreURl + app.SteamAppID,
                IsFree = app.IsFree,
                Store  = new StoreAddModel {
                    Name = _storeName
                },
            };

            var priceOverview = app.PriceOverview;

            if (priceOverview != null)
            {
                gamedeal.PriceOverview = new PriceOverviewAddModel
                {
                    Price              = priceOverview.Initial,
                    PriceFormat        = priceOverview.InitialFormat,
                    FinalPrice         = priceOverview.Final,
                    FinalPriceFormat   = priceOverview.FinalFormat,
                    DiscountPercentage = priceOverview.DiscountPercentage,
                    Currency           = new CurrencyAddModel {
                        Code = priceOverview.Currency, Symbole = "£"
                    }
                };

                if (priceOverview.Initial != priceOverview.Final)
                {
                    gamedeal.DealDate.LimitedTimeDeal = true;
                }
            }
            _gameManager.AddGameDeal(gamedeal);
        }
Ejemplo n.º 5
0
        //private async void GatherFullData()
        //{

        //    for (var i = _currentIndex; i < _totalApps; i++)
        //    {
        //        var app = _apps[i];

        //        //var fullApp = await _steamAPI.GetAppBySteamID(app.appid);
        //        var fullApp = await _steamAPI.GetAppBySteamID(app.appid);
        //        await Task.Delay(_requestDelayTime);


        //        if (fullApp != null)
        //        {
        //            if (!String.IsNullOrEmpty(fullApp.Name))
        //            {


        //                AddFullGame(fullApp);
        //                updateSteamProfileIndexByOneSettingAsync();
        //            }
        //        }
        //    }
        //    Console.WriteLine("Database has finished");
        //}


        private async void AddFullGame(SteamAppDetails fullApp)
        {
            var gameId = await AddGame(fullApp);

            /// all synchronous methods best to get results or await
            /// to figure out the Exception thrown: 'System.Data.SqlClient.SqlException' in System.Private.CoreLib.dll
            /// as expections are thrown but not picked up


            AddDlcAsync(fullApp.DLC, gameId);
            addDeveloper(fullApp.Developers, gameId);
            addPublisher(fullApp.Publishers, gameId);
            AddVideos(fullApp.Movies, gameId, fullApp.Name);

            addGameDeal(fullApp, gameId);

            AddCategories(fullApp.Categories, gameId);
            AddGenre(fullApp.Genres, gameId);
            addSystemRequirements(fullApp, gameId);
        }
Ejemplo n.º 6
0
 private void addSystemRequirements(SteamAppDetails systemRequirement, int gameId)
 {
     if (systemRequirement.PcRequirement != null)
     {
         _gameManager.AddSystemRequirement(new SystemRequirementAddModel
         {
             GameId      = gameId,
             Minimum     = systemRequirement.PcRequirement.Minimum,
             Recommended = systemRequirement.PcRequirement.Recommended,
             Platform    = new PlatformAddModel {
                 Name = "pc"
             }
         });
     }
     if (systemRequirement.LinuxRequirement != null)
     {
         _gameManager.AddSystemRequirement(new SystemRequirementAddModel
         {
             GameId      = gameId,
             Minimum     = systemRequirement.LinuxRequirement.Minimum,
             Recommended = systemRequirement.LinuxRequirement.Recommended,
             Platform    = new PlatformAddModel {
                 Name = "linux"
             }
         });
     }
     if (systemRequirement.MacRequirement != null)
     {
         _gameManager.AddSystemRequirement(new SystemRequirementAddModel
         {
             GameId      = gameId,
             Minimum     = systemRequirement.MacRequirement.Minimum,
             Recommended = systemRequirement.MacRequirement.Recommended,
             Platform    = new PlatformAddModel {
                 Name = "mac"
             }
         });
     }
 }