public ActionResult Index(string steamId = "76561198257065483") { var modelFaceitmatch = new Faceitmatch(); var _faceitAbstraction = new SimpleFaceitAverageStats(); var _client = new SimpleFaceitLiveMatch(); var _Lifetime = new SimpleFaceitLifetimeStats(); var providerFaceitDetails = _faceitAbstraction.FaceitUserDetails(steamId); // Get FaceitGUID & FaceitNickname if (providerFaceitDetails != null) { modelFaceitmatch = _client.getFaceitMatchDetails(providerFaceitDetails.Item1, providerFaceitDetails.Item2); FacaeitLifetimeStats LifetimeStats = _Lifetime.getFaceitLifetimeStats(providerFaceitDetails.Item1, providerFaceitDetails.Item2); FaceitUserStats providerFaceitStats = _faceitAbstraction.FaceitAvgElo(providerFaceitDetails.Item1); if (modelFaceitmatch != null) { Plugin = new Streamplugin(modelFaceitmatch, LifetimeStats, providerFaceitStats); Plugin.Live = 1; } else { Plugin = new Streamplugin(null, LifetimeStats, providerFaceitStats); Plugin.Live = 0; } return(View(Plugin)); } else { ViewData["Name"] = steamId; return(View("noFaceit")); } }
/// <summary> /// Rückgabe des Mittelwertes der Stats /// </summary> /// <param name="user"></param> /// <param name="count"></param> /// <returns></returns> public FaceitUserStats getAvgStats(FaceitUserStats user, int count) { var Userstats = new FaceitUserStats(); if (count == 0) { count = 1; } Userstats.avgKills = user.avgKills / count; Userstats.avgHs = user.avgHs / count; Userstats.avgKd = (float)Math.Round(user.avgKd / 100 / count, 2); Userstats.avgKr = (float)Math.Round(user.avgKr / 100 / count, 2); return(Userstats); }
public Streamplugin(Faceitmatch model, FacaeitLifetimeStats lifetime, FaceitUserStats stats) : this() { if (model != null) { _ownTeamName = model.ownTeamName; _ownTeamElo = model.ownTeamElo; _ownTeamWinElo = model.ownTeamWinElo; _enemyTeamName = model.enemyTeamName; _enemyTeamElo = model.enemyTeamElo; _enemyTeamWinElo = model.enemyTeamWinElo; } _elo = lifetime.lifetime.Elo; _WonMatches = lifetime.lifetime.WonMatches; _PlayedMatches = lifetime.lifetime.PlayedMatches; _WinPercentage = lifetime.lifetime.WinPercentage; _avgKills = stats.avgKills; _avgHs = stats.avgHs; _avgKd = stats.avgKd; _avgKr = stats.avgKr; }
// GET: /FaceitAvgStats/ public IActionResult Index(string steamId) { var _faceitAbstraction = new SimpleFaceitAverageStats(); var providerFaceitDetails = _faceitAbstraction.FaceitUserDetails(steamId); // Get FaceitGUID & FaceitNickname if (providerFaceitDetails != null) { FaceitUserStats providerFaceitStats = _faceitAbstraction.FaceitAvgElo(providerFaceitDetails.Item1); // Get FaceitGUID & FaceitNickname ViewData["Name"] = providerFaceitDetails.Item2; ViewData["Kills"] = providerFaceitStats.avgKills; ViewData["HS"] = providerFaceitStats.avgHs; ViewData["KD"] = providerFaceitStats.avgKd; ViewData["KR"] = providerFaceitStats.avgKr; return(View()); } else { ViewData["Name"] = steamId; return(View("noFaceit")); } }
/// <summary> /// Get FaceitAvg Stats with the historyLength and the calculationLength /// </summary> /// <param name="faceitId"></param> /// <param name="historyLength"></param> /// <param name="calculationLength"></param> /// <returns></returns> public FaceitUserStats FaceitAvgElo(string faceitId, int historyLength = 50, int calculationLength = 20) { int count = 0; var userStats = new FaceitUserStats(); var _faceitApi = new Faceitapi(); FaceitLastMatch[] UserHistory = _faceitApi.getFaceitHistory(faceitId, historyLength); //get Object of all Matches foreach (dynamic Matches in UserHistory) { if (Matches.gameMode == "5v5") { count++; userStats = getSumOfStats(Matches, userStats); if (count >= calculationLength) { break; } } } userStats = getAvgStats(userStats, count); return(userStats); }