Beispiel #1
0
        private string Top5Distances(StatsClass data)
        {
            string results = "";

            if (data.TopDistances.Count > 0)
            {
                data.TopDistances.ForEach(x => results += String.Format("{0} : {1}m  -  ", x.Key, x.Value));
            }
            return(results);
        }
Beispiel #2
0
 private void WriteDataToScreen(StatsClass data)
 {
     if (data != null)
     {
         txtName.Text             = data.PlayerName;
         txtWins.Text             = data.Wins.ToString();
         txtLoses.Text            = data.Losses.ToString();
         txtKills.Text            = data.Kills.ToString();
         txtWinPoints.Text        = data.WinPoints.ToString();
         txtKillPoints.Text       = data.KillPoints.ToString();
         txtTotalPoints.Text      = data.TotalPoints.ToString();
         txtGlobalRank.Text       = data.GlobalRank.ToString();
         txtRankName.Text         = data.RankName.ToString();
         txtWinPercentage.Text    = data.WinPercentage.ToString();
         txtKillsPerGame.Text     = data.KillsPerRound.ToString();
         txtKillsPerGun.Text      = Top5Guns(data).Replace("  -  ", Environment.NewLine);
         txtKillsPerDistance.Text = Top5Distances(data).Replace("  -  ", Environment.NewLine);
     }
 }
Beispiel #3
0
        private void ProcessResponse(dynamic response, string strTextlabel, bool IsHardcore)
        {
            StatsClass data = new StatsClass();

            data.PlayerName = response.name;
            data.IsHardcore = IsHardcore;
            data.Kills = response.kills;
            data.Wins = response.wins;
            data.Losses = response.losses;
            if (data.Kills > 0) data.KillsPerRound = Math.Round(decimal.Divide(data.Kills, (data.Wins + data.Losses)), 2);
            if (data.Wins > 0) data.WinPercentage = Math.Round(decimal.Divide(data.Wins, (data.Wins + data.Losses)) * 100, 2);
            data.GlobalRank = response.global_rank;
            data.WinPoints = response.win_points;
            data.KillPoints = response.kill_points;
            data.TotalPoints = response.total_points;
            data.RankName = response.rank_name;

            // Kills Per Gun
            JArray jarrGuns = JArray.Parse(response.top_5_guns.ToString());
            foreach (var item in jarrGuns.Children())
            {
                data.TopGuns.Add(new KeyValuePair<string, string>(item.SelectToken("gun").ToString(), item.SelectToken("count").ToString()));
            }
            // Kills Per Distance
            JArray jarrKills = JArray.Parse(response.top_5_kills.ToString());
            foreach (var item in jarrKills.Children())
            {
                data.TopDistances.Add(new KeyValuePair<string, string>(item.SelectToken("gun").ToString(), item.SelectToken("distance").ToString()));
            }

            lstStats.Add(data);
            
            string strGlobalRank = data.GlobalRank.ToString();
            string strWinPoints = data.WinPoints.ToString();
            string strKillPoints = data.KillPoints.ToString();
            string strTotalPoints = data.TotalPoints.ToString();
            string strRankName = data.RankName;
            string strWins = data.Wins.ToString();
            string strKills = data.Kills.ToString();
            string strLosses =data.Losses.ToString();
            string strKillsPerRound= data.KillsPerRound.ToString();
            string strWinPercentage = data.WinPercentage.ToString();
            string strAllData;
            string strTop5Guns = Top5Guns(data);
            string strTop5Distance = Top5Distances(data);

            strAllData = string.Format("Wins: {0} | Losses: {1} | Win %: {2} | Kills: {3} | Kills Per Round: {4} | Kills By Gun: {11} | Kills By Distance: {5} | Win Points: {6} | Kill Points: {7} | Total Points {8} | Rank Name: {10} | Global Rank: {9} | ", data.Wins, data.Losses, data.WinPercentage, data.Kills, data.KillsPerRound, strTop5Guns, data.WinPoints, data.KillPoints, data.TotalPoints, data.GlobalRank, data.RankName, strTop5Distance);

            if (chkIncludeLabels.Checked)
            {
                strTop5Guns = "Top 5 Guns by Kill: " + strTop5Guns;
                strTop5Distance = "Top 5 Kills by Distance: " + strTop5Distance;
                strKills = "Kills: " + data.Kills;
                strWins = "Wins: " + data.Wins;
                strLosses = "Losses: " + data.Losses;
                strKillsPerRound = "KPR: " + data.KillsPerRound;
                strWinPercentage = "Win %: " + data.WinPercentage;
                strGlobalRank = "Global Rank: " + data.GlobalRank;
                strWinPoints = "Win Points: " + data.WinPoints;
                strKillPoints = "Kill Points: " + data.KillPoints;
                strTotalPoints = "Total Points: " + data.TotalPoints;
                strRankName = "Rank Name: " + data.RankName;
            }

            File.WriteAllText(statsFolder + "/" + strTextlabel + "global_rank.txt", strGlobalRank);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "kills.txt", strKills);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "win_points.txt", strWinPoints);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "kill_points.txt", strKillPoints);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "total_points.txt", strTotalPoints);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "rank_name.txt", strRankName);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "wins.txt", strWins);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "losses.txt", strLosses);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "kills_per_round.txt", strKillsPerRound);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "win_percentage.txt", strWinPercentage);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "top_5_kills_by_guns.txt", strTop5Guns);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "top_5_kills_by_distance.txt", strTop5Distance);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "all_data.txt", strAllData);
        }
Beispiel #4
0
 private string Top5Distances(StatsClass data)
 {
     string results = "";
     if (data.TopDistances.Count > 0)
     {
         data.TopDistances.ForEach(x => results += String.Format("{0} : {1}m  -  ", x.Key, x.Value));
     }
     return results;
 }
Beispiel #5
0
        private void WriteDataToScreen(StatsClass data)
        {
            if (data != null){
                txtName.Text = data.PlayerName;
                txtWins.Text = data.Wins.ToString();
                txtLoses.Text = data.Losses.ToString();
                txtKills.Text = data.Kills.ToString();
                txtWinPoints.Text = data.WinPoints.ToString();
                txtKillPoints.Text = data.KillPoints.ToString();
                txtTotalPoints.Text = data.TotalPoints.ToString();
                txtGlobalRank.Text = data.GlobalRank.ToString();
                txtRankName.Text = data.RankName.ToString();
                txtWinPercentage.Text = data.WinPercentage.ToString();
                txtKillsPerGame.Text = data.KillsPerRound.ToString();
                txtKillsPerGun.Text = Top5Guns(data).Replace("  -  ", Environment.NewLine);
                txtKillsPerDistance.Text = Top5Distances(data).Replace("  -  ", Environment.NewLine);
            }

            
        }
Beispiel #6
0
        private void ProcessResponse(dynamic response, string strTextlabel, bool IsHardcore)
        {
            StatsClass data = new StatsClass();

            data.PlayerName = response.name;
            data.IsHardcore = IsHardcore;
            data.Kills      = response.kills;
            data.Wins       = response.wins;
            data.Losses     = response.losses;
            if (data.Kills > 0)
            {
                data.KillsPerRound = Math.Round(decimal.Divide(data.Kills, (data.Wins + data.Losses)), 2);
            }
            if (data.Wins > 0)
            {
                data.WinPercentage = Math.Round(decimal.Divide(data.Wins, (data.Wins + data.Losses)) * 100, 2);
            }
            data.GlobalRank  = response.global_rank;
            data.WinPoints   = response.win_points;
            data.KillPoints  = response.kill_points;
            data.TotalPoints = response.total_points;
            data.RankName    = response.rank_name;

            // Kills Per Gun
            JArray jarrGuns = JArray.Parse(response.top_5_guns.ToString());

            foreach (var item in jarrGuns.Children())
            {
                data.TopGuns.Add(new KeyValuePair <string, string>(item.SelectToken("gun").ToString(), item.SelectToken("count").ToString()));
            }
            // Kills Per Distance
            JArray jarrKills = JArray.Parse(response.top_5_kills.ToString());

            foreach (var item in jarrKills.Children())
            {
                data.TopDistances.Add(new KeyValuePair <string, string>(item.SelectToken("gun").ToString(), item.SelectToken("distance").ToString()));
            }

            lstStats.Add(data);

            string strGlobalRank    = data.GlobalRank.ToString();
            string strWinPoints     = data.WinPoints.ToString();
            string strKillPoints    = data.KillPoints.ToString();
            string strTotalPoints   = data.TotalPoints.ToString();
            string strRankName      = data.RankName;
            string strWins          = data.Wins.ToString();
            string strKills         = data.Kills.ToString();
            string strLosses        = data.Losses.ToString();
            string strKillsPerRound = data.KillsPerRound.ToString();
            string strWinPercentage = data.WinPercentage.ToString();
            string strAllData;
            string strTop5Guns     = Top5Guns(data);
            string strTop5Distance = Top5Distances(data);

            strAllData = string.Format("Wins: {0} | Losses: {1} | Win %: {2} | Kills: {3} | Kills Per Round: {4} | Kills By Gun: {11} | Kills By Distance: {5} | Win Points: {6} | Kill Points: {7} | Total Points {8} | Rank Name: {10} | Global Rank: {9} | ", data.Wins, data.Losses, data.WinPercentage, data.Kills, data.KillsPerRound, strTop5Guns, data.WinPoints, data.KillPoints, data.TotalPoints, data.GlobalRank, data.RankName, strTop5Distance);

            if (chkIncludeLabels.Checked)
            {
                strTop5Guns      = "Top 5 Guns by Kill: " + strTop5Guns;
                strTop5Distance  = "Top 5 Kills by Distance: " + strTop5Distance;
                strKills         = "Kills: " + data.Kills;
                strWins          = "Wins: " + data.Wins;
                strLosses        = "Losses: " + data.Losses;
                strKillsPerRound = "KPR: " + data.KillsPerRound;
                strWinPercentage = "Win %: " + data.WinPercentage;
                strGlobalRank    = "Global Rank: " + data.GlobalRank;
                strWinPoints     = "Win Points: " + data.WinPoints;
                strKillPoints    = "Kill Points: " + data.KillPoints;
                strTotalPoints   = "Total Points: " + data.TotalPoints;
                strRankName      = "Rank Name: " + data.RankName;
            }

            File.WriteAllText(statsFolder + "/" + strTextlabel + "global_rank.txt", strGlobalRank);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "kills.txt", strKills);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "win_points.txt", strWinPoints);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "kill_points.txt", strKillPoints);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "total_points.txt", strTotalPoints);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "rank_name.txt", strRankName);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "wins.txt", strWins);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "losses.txt", strLosses);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "kills_per_round.txt", strKillsPerRound);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "win_percentage.txt", strWinPercentage);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "top_5_kills_by_guns.txt", strTop5Guns);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "top_5_kills_by_distance.txt", strTop5Distance);
            File.WriteAllText(statsFolder + "/" + strTextlabel + "all_data.txt", strAllData);
        }