Esempio n. 1
0
        public static ChallengeList GetSeasonChallenges()
        {
            Console.WriteLine("Retrieving challenges from Fortnite API...");
            Console.Write("Which season do you want challenges for: ");
            string season = Console.ReadLine();
            HttpResponseMessage response = client.GetAsync($"challenges/get?season=" + season).Result;

            if (!response.IsSuccessStatusCode)
            {
                throw new WebException("Failed to get challenges");
            }

            string        content  = response.Content.ReadAsStringAsync().Result;
            ChallengeList FortChal = JsonConvert.DeserializeObject <ChallengeList>(content);

            Console.WriteLine("Successfully retrieve challenges from Fortnite API...");
            return(FortChal);
        }
Esempio n. 2
0
        public static void Main(string[] args)
        {
            client             = new HttpClient();
            client.BaseAddress = new Uri("https://fortnite-api.theapinetwork.com/");
            client.DefaultRequestHeaders.Add("Authorization", apiKey);
            client.DefaultRequestHeaders.Accept.Add(
                new MediaTypeWithQualityHeaderValue("application/json"));

            List <UnreleasedProduct> FortMap      = new List <UnreleasedProduct>();
            List <BRNews>            FortNews     = new List <BRNews>();
            List <WeaponInfo>        FortWeapon   = new List <WeaponInfo>();
            List <CreativeInfo>      FortCreative = new List <CreativeInfo>();
            List <ItemShop>          FortStore    = new List <ItemShop>();
            ChallengeList            FortChal     = new ChallengeList();

            try
            {
                Console.WriteLine("Enter UI for Upcoming Items");
                Console.WriteLine("Enter GN for In Game News");
                Console.WriteLine("Enter WL for Weapons List");
                Console.WriteLine("Enter CL for Creative List");
                Console.WriteLine("Enter IS for Item Shop");
                Console.WriteLine("Enter CH for Challenges");
                Console.WriteLine("");
                Console.Write("Select what you want to see: ");
                string ans = Console.ReadLine();

                switch (ans)
                {
                case "UI":
                    FortMap = GetUpcomingItems();

                    Console.WriteLine($"Number of upcoming items = {FortMap.Count}");

                    for (int index = 0; index < FortMap.Count; index++)
                    {
                        UnreleasedProduct currentProduct = FortMap[index];
                        Console.WriteLine("");

                        Console.WriteLine($"ItemId = {currentProduct.ItemId} ");

                        Console.WriteLine($"Name = { currentProduct.Item.Name }    Type = { currentProduct.Item.Type}    Rarity = { currentProduct.Item.Rarity} ");
                        Console.WriteLine($"Description = { currentProduct.Item.Description }    Cost = { currentProduct.Item.Cost }    Upcoming = { currentProduct.Item.Upcoming }");

                        Console.WriteLine($"Icon = { currentProduct.Item.Images.Icon }    Featured = { currentProduct.Item.Images.Featured }");
                        Console.WriteLine($"Background = { currentProduct.Item.Images.Background }    Information = { currentProduct.Item.Images.Information }");
                    }
                    Console.WriteLine("");
                    break;

                case "GN":
                    FortNews = GetInGameNews();

                    Console.WriteLine($"Number of in game news = {FortNews.Count}");

                    for (int index = 0; index < FortNews.Count; index++)
                    {
                        BRNews ingameNews = FortNews[index];
                        Console.WriteLine("");

                        Console.WriteLine($"Title = { ingameNews.Title }    Body = { ingameNews.Body } ");
                        Console.WriteLine($"Image = { ingameNews.Image}");
                    }
                    Console.WriteLine("");
                    break;

                case "WL":
                    FortWeapon = GetWeaponList();

                    Console.WriteLine($"Number of weapons = {FortWeapon.Count}");

                    for (int index = 0; index < FortWeapon.Count; index++)
                    {
                        WeaponInfo weaponArsenal = FortWeapon[index];
                        Console.WriteLine("");

                        Console.WriteLine($"Identifier = { weaponArsenal.Identifier }    Name = { weaponArsenal.Name}");
                        Console.WriteLine($"Rarity = { weaponArsenal.Rarity }    Image = { weaponArsenal.Image }");

                        Console.WriteLine($"Dps = { weaponArsenal.Stats.Dps }    HitBody = { weaponArsenal.Stats.HitBody }");
                        Console.WriteLine($"HitHead = { weaponArsenal.Stats.HitHead }    FireRate = { weaponArsenal.Stats.FireRate }");
                        Console.WriteLine($"MagazineSize = { weaponArsenal.Stats.MagazineSize }    ReloadTime = { weaponArsenal.Stats.ReloadTime }");
                        Console.WriteLine($"AmmoCost = { weaponArsenal.Stats.AmmoCost }");
                    }
                    Console.WriteLine("");
                    break;

                case "CL":
                    FortCreative = GetCreativeList();

                    Console.WriteLine($"Number of featured creative islands = {FortCreative.Count}");

                    for (int index = 0; index < FortCreative.Count; index++)
                    {
                        CreativeInfo currentIslands = FortCreative[index];
                        Console.WriteLine("");

                        Console.WriteLine($"Island Code = {currentIslands.Island.Code}    Island Name = {currentIslands.Island.Name}");
                        Console.WriteLine($"Island Description = {currentIslands.Island.Description}");

                        Console.WriteLine($"Creator Username = {currentIslands.Island.Creator.Username}");
                    }
                    Console.WriteLine("");
                    break;

                case "IS":
                    FortStore = GetItemShop();

                    Console.WriteLine($"Number of items in the shop = {FortStore.Count}");

                    for (int index = 0; index < FortStore.Count; index++)
                    {
                        ItemShop currentItems = FortStore[index];
                        Console.WriteLine("");

                        Console.WriteLine($"ItemId = {currentItems.ItemId} ");

                        Console.WriteLine($"Featured = {currentItems.Store.IsFeatured}    Refundable = {currentItems.Store.IsRefundable}");
                        Console.WriteLine($"Cost = {currentItems.Store.Cost}    New = {currentItems.Store.IsNew}");

                        Console.WriteLine($"Name = {currentItems.Item.Name}    Type = {currentItems.Item.Type}");
                        Console.WriteLine($"Rarity = {currentItems.Item.Rarity}");

                        Console.WriteLine($"Icon = {currentItems.Item.Images.Icon}    Background = {currentItems.Item.Images.Background}");
                        Console.WriteLine($"Information = {currentItems.Item.Images.Information}");
                    }
                    Console.WriteLine("");
                    break;

                case "CH":
                    FortChal = GetSeasonChallenges();

                    int challengeCount = 0;
                    FortChal.Challenges.ForEach(week => { challengeCount += week.Entries.Count; });

                    Console.WriteLine($"Number of challenges = {challengeCount}");
                    Console.WriteLine($"Language = {FortChal.Language}    Season = {FortChal.Season}    Star = {FortChal.Star}");

                    for (int index = 0; index < FortChal.Challenges.Count; index++)
                    {
                        ChallengeInfo seasonChallenge = FortChal.Challenges[index];
                        Console.WriteLine("");

                        Console.WriteLine($"Week = {seasonChallenge.Week}    Value = {seasonChallenge.Value}");

                        seasonChallenge.Entries.ForEach(challenge =>
                        {
                            Console.WriteLine($"Identifier = {challenge.Identifier}    Challenge = {challenge.Challenge}");
                            Console.WriteLine($"Total = {challenge.Total}    Stars = {challenge.Stars}");
                            Console.WriteLine($"Difficulty = {challenge.Difficulty}");
                        });
                    }
                    Console.WriteLine("");
                    break;
                }
            }


            catch (Exception e)
            {
                Console.WriteLine(e.Message);
            }
            Console.ReadLine();
        }