Esempio n. 1
0
        public async Task LoadStats(string username, string platform)
        {
            //Using FortniteAPI
            Rootobject root  = new Rootobject();
            Error      error = new Error();
            string     uid   = await LoadUid(username);

            string url  = "https://fortnite-public-api.theapinetwork.com/prod09/users/public/br_stats?user_id=" + uid + "&platform=" + platform;
            string text = await url.GetStringAsync();

            root  = JsonConvert.DeserializeObject <Rootobject>(text);
            error = JsonConvert.DeserializeObject <Error>(text);
            Totals global     = root.totals;
            Stats  individual = root.stats;

            if (error.error == true)
            {
                string            message = "Error: " + error.numericErrorCode.ToString() + " " + error.errorMessage;
                MessageBoxButtons buttons = MessageBoxButtons.OK;
                DialogResult      result;
                result = MessageBox.Show(message, "Error", buttons, MessageBoxIcon.Error);
            }
            else
            {
                //Global stats load
                txtWins.Text    = global.wins.ToString();
                txtWr.Text      = global.winrate.ToString();
                txtKD.Text      = global.kd.ToString();
                txtKills.Text   = global.kills.ToString();
                txtMatches.Text = global.matchesplayed.ToString();

                //Solo stats load
                txtSoloWins.Text    = individual.placetop1_solo.ToString();
                txtSoloKills.Text   = individual.kills_solo.ToString();
                txtTop10Solo.Text   = individual.placetop10_solo.ToString();
                txtTop25Solo.Text   = individual.placetop25_solo.ToString();
                txtWrSolo.Text      = individual.winrate_solo.ToString();
                txtKdSolo.Text      = individual.kd_solo.ToString();
                txtSoloMatches.Text = individual.matchesplayed_solo.ToString() + " Matches";

                //Duo stats load
                txtDuoWins.Text    = individual.placetop1_duo.ToString();
                txtDuoKills.Text   = individual.kills_duo.ToString();
                txtDuoTop5.Text    = individual.placetop5_duo.ToString();
                txtDuoTop12.Text   = individual.placetop12_duo.ToString();
                txtDuoWr.Text      = individual.winrate_duo.ToString();
                txtDuoKd.Text      = individual.kd_duo.ToString();
                txtDuoMatches.Text = individual.matchesplayed_duo.ToString() + " Matches";

                //Squad stats load

                txtSquadWins.Text    = individual.placetop1_squad.ToString();
                txtSquadKills.Text   = individual.kills_squad.ToString();
                txtSquadTop3.Text    = individual.placetop3_squad.ToString();
                txtSquadTop6.Text    = individual.placetop6_squad.ToString();
                txtSquadWr.Text      = individual.winrate_squad.ToString();
                txtSquadKd.Text      = individual.kd_squad.ToString();
                txtSquadMatches.Text = individual.matchesplayed_squad.ToString() + " Matches";
            }
        }
Esempio n. 2
0
        //Load initial stats
        public async Task LoadInitial(string username, string platform)
        {
            string uid = await LoadUid(username);

            string url  = "https://fortnite-public-api.theapinetwork.com/prod09/users/public/br_stats?user_id=" + uid + "&platform=" + platform;
            string text = await url.GetStringAsync();

            root              = JsonConvert.DeserializeObject <Rootobject>(text);
            globalInitial     = root.totals;
            individualInitial = root.stats;
        }
Esempio n. 3
0
        public async void CompareStats(object source, ElapsedEventArgs e)
        {
            string     username = txtUname.Text;
            Rootobject newdata  = new Rootobject();

            newdata = await LoadWhileSession(username, "pc");

            Totals globalNew  = newdata.totals;
            var    newWins    = globalNew.wins - globalInitial.wins;
            var    newMatches = globalNew.matchesplayed - globalInitial.matchesplayed;
            var    newKills   = globalNew.kills - globalInitial.kills;
            float  newKd;
            float  newWinr;

            if (newKills == 0)
            {
                newKd = 0;
            }
            else if ((newMatches - newWins) == 0)
            {
                newKd = newKills;
            }
            else
            {
                newKd = newKills / (newMatches - newWins);
            }

            if (newMatches == 0)
            {
                newWinr = newWins * 100;
            }
            else
            {
                newWinr = (newWins * 100) / newMatches;
            }
            txtKills.Text   = newKills.ToString();
            txtKD.Text      = newKd.ToString();
            txtWr.Text      = (newWinr).ToString() + "%";
            txtWins.Text    = newWins.ToString();
            txtMatches.Text = newMatches.ToString();
        }