Exemple #1
0
        public static void Fortnite()
        {
            Console.Clear();
            Console.Write("Enter FortNite username: "******"\nEnter platform (psn, xbl, pc): ");
            string      platform = Console.ReadLine();
            FortniteAPI player   = new FortniteAPI(name, platform);

            Console.ForegroundColor = ConsoleColor.White;
            FortnitePlayer p = player.getPlayer();

            if (p != null)
            {
                Console.WriteLine(p.ToString());
            }
            else
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine("\n\nPlayer not found!\n\n");
                Console.ForegroundColor = ConsoleColor.Gray;
            }

            Console.ReadLine();
        }
Exemple #2
0
        public async Task <FortnitePlayer> PullData()
        {
            using (HttpClient client = new HttpClient())
            {
                client.DefaultRequestHeaders.TryAddWithoutValidation("TRN-Api-Key", "8a6f583a-5d48-47f3-baa2-3ca659ed8eb5"); //Fortnite API Authorization and key
                using (HttpResponseMessage response = await client.GetAsync("https://api.fortnitetracker.com/v1/profile/" + platform + "/" + username + ""))
                {
                    using (HttpContent content = response.Content)
                    {
                        this.content = await content.ReadAsStringAsync();

                        this.data = JObject.Parse(this.content);
                        FortnitePlayer player = new FortnitePlayer();
                        //Basic User Data
                        player.accountID        = this.data.accountId;
                        player.epicUserHandle   = this.data.epicUserHandle;
                        player.platformNameLong = this.data.platformNameLong;
                        //Lifetime Solo Stats
                        player.ltSoloWins          = this.data.stats.p2.top1.displayValue;
                        player.ltSoloScore         = this.data.stats.p2.score.displayValue;
                        player.ltSoloTop10         = this.data.stats.p2.top10.displayValue;
                        player.ltSoloTop25         = this.data.stats.p2.top25.displayValue;
                        player.ltSoloKD            = this.data.stats.p2.kd.displayValue;
                        player.ltSoloWinRatio      = this.data.stats.p2.winRatio.displayValue;
                        player.ltSoloTotalMatches  = this.data.stats.p2.matches.displayValue;
                        player.ltSoloKills         = this.data.stats.p2.kills.displayValue;
                        player.ltSoloKPG           = this.data.stats.p2.kpg.displayValue;
                        player.ltSoloScorePerMatch = this.data.stats.p2.scorePerMatch.displayValue;
                        //Lifetime Duo Stats
                        player.ltDuoWins          = this.data.stats.p10.top1.displayValue;
                        player.ltDuoScore         = this.data.stats.p10.score.displayValue;
                        player.ltDuoTop5          = this.data.stats.p10.top5.displayValue;
                        player.ltDuoTop12         = this.data.stats.p10.top12.displayValue;
                        player.ltDuoKD            = this.data.stats.p10.kd.displayValue;
                        player.ltDuoWinRatio      = this.data.stats.p10.winRatio.displayValue;
                        player.ltDuoTotalMatches  = this.data.stats.p10.matches.displayValue;
                        player.ltDuoKills         = this.data.stats.p10.kills.displayValue;
                        player.ltDuoKPG           = this.data.stats.p10.kpg.displayValue;
                        player.ltDuoScorePerMatch = this.data.stats.p10.scorePerMatch.displayValue;
                        //Lifetime Squad Stats
                        player.ltSquadWins          = this.data.stats.p9.top1.displayValue;
                        player.ltSquadScore         = this.data.stats.p9.score.displayValue;
                        player.ltSquadTop3          = this.data.stats.p9.top3.displayValue;
                        player.ltSquadTop6          = this.data.stats.p9.top6.displayValue;
                        player.ltSquadKD            = this.data.stats.p9.kd.displayValue;
                        player.ltSquadWinRatio      = this.data.stats.p9.winRatio.displayValue;
                        player.ltSquadTotalMatches  = this.data.stats.p9.matches.displayValue;
                        player.ltSquadKills         = this.data.stats.p9.kills.displayValue;
                        player.ltSquadKPG           = this.data.stats.p9.kpg.displayValue;
                        player.ltSquadScorePerMatch = this.data.stats.p9.scorePerMatch.displayValue;

                        return(player);
                    }
                }
            }
        }
Exemple #3
0
        public FortnitePlayer getPlayer()
        {
            FortnitePlayer p = null;

            try
            {
                Task.Run(async() => { p = await PullData(); }).GetAwaiter().GetResult();
            }
            catch (Exception e)
            {
                Program.Main(null);
                return(null);
            }

            return(p);
        }