void UpdateSummonerGames(Summoner summoner, RecentGames recentGameData, DbConnection connection) { var recentGames = recentGameData.gameStatistics; recentGames.Sort(CompareGames); foreach (var game in recentGames) { UpdateSummonerGame(summoner, game, connection); } }
public void ExtensionGetRecentGames() { ApiService.ApiKey = APIKEY;//you must add your project, if you dont use ninject Summoner data = new Summoner() { Id = summonerId1, Region = Region }; RecentGames data1 = data.GetRecentGames();//extension Assert.IsNotNull(data1); }
bool GetRecentGames(string summonerName, ref PublicSummoner publicSummoner, ref List <PlayerGameStats> recentGames) { publicSummoner = RPC.GetSummonerByName(summonerName); if (publicSummoner == null) { return(false); } RecentGames recentGameData = RPC.GetRecentGames(publicSummoner.acctId); recentGames = recentGameData.gameStatistics; recentGames.Sort(CompareGames); return(true); }
public async Task <RecentGames> GetRecentGames(Double accountId) { int Id = Invoke("playerStatsService", "getRecentGames", new object[] { accountId }); while (!results.ContainsKey(Id)) { await Task.Delay(10); } TypedObject messageBody = results[Id].GetTO("data").GetTO("body"); RecentGames result = new RecentGames(messageBody); results.Remove(Id); return(result); }
public RecentGames GetRecentGames(long summonerId, region region, bool useCaching = false) { RecentGames val = Cache.Get <RecentGames>(summonerId.ToString(), region.ToString()); //cache getting if (val != null) { return(val); } RecentGames data = new Summoner() { Id = summonerId, Region = region } .GetRecentGames(); if (useCaching) { Cache.AddOrUpdate(new cacheObject <RecentGames>(new cacheParam <RecentGames>(summonerId, region), data, new TimeSpan(0, 22, 0))); } return(data); }
void GetRecentGameData(RecentGames recentGameData) { RecentGameData = recentGameData; ProcessReply(); }
public async Task <string[]> Load(double ID) { RecentGames result = await Client.PVPNet.GetRecentGames(ID); result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); GamesWithChamp = 0; foreach (PlayerGameStats game in result.GameStatistics) { game.GameType = Client.TitleCaseString(game.GameType.Replace("_GAME", "").Replace("MATCHED", "NORMAL")); var match = new MatchStats(); foreach (RawStat stat in game.Statistics) { Type type = typeof(MatchStats); string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", ""); FieldInfo f = type.GetField(fieldName); f.SetValue(match, stat.Value); } match.Game = game; GameStats.Add(match); } int AKills, ChampKills; int ADeaths, ChampDeaths; int AAssists, ChampAssists; int AGamesPlayed, ChampGamesPlayed; int Wins, ChampWins; AKills = 0; ADeaths = 0; AAssists = 0; AGamesPlayed = 0; ChampKills = 0; ChampDeaths = 0; ChampAssists = 0; ChampGamesPlayed = 0; Wins = 0; ChampWins = 0; //Load average KDA for past 20 games if possible foreach (MatchStats stats in GameStats) { if (stats.Win == 1) { Wins++; } champions gameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); AKills = AKills + (Int32)stats.ChampionsKilled; ADeaths = ADeaths + (Int32)stats.NumDeaths; AAssists = AAssists + (Int32)stats.Assists; AGamesPlayed++; if (ChampID == (int)Math.Round(stats.Game.ChampionId)) { if (stats.Win == 1) { ChampWins++; } ChampKills = ChampKills + (Int32)stats.ChampionsKilled; ChampDeaths = ChampDeaths + (Int32)stats.NumDeaths; ChampAssists = ChampAssists + (Int32)stats.Assists; ChampGamesPlayed++; GamesWithChamp++; } } WinLossRatio = (Wins / AGamesPlayed) * 100; try { WinLossChampRatio = (ChampWins / ChampGamesPlayed) * 100; } catch { } string KDAString = string.Format("{0}/{1}/{2}", (AKills / AGamesPlayed), (ADeaths / AGamesPlayed), (AAssists / AGamesPlayed)); string ChampKDAString = ""; try { ChampKDAString = string.Format("{0}/{1}/{2}", (ChampKills / ChampGamesPlayed), (ChampDeaths / ChampGamesPlayed), (ChampAssists / ChampGamesPlayed)); } catch { ChampKDAString = "NO RECENT GAMES!!!"; } //GetKDA String OverallKDA = new KDA() { Kills = AKills, Deaths = ADeaths, Assists = AAssists, Games = AGamesPlayed }; //Get champ KDA Champkda = new KDA() { Kills = ChampKills, Deaths = ChampDeaths, Assists = ChampAssists, Games = ChampGamesPlayed }; return(new List <string>() { ChampKDAString, KDAString }.ToArray()); }
/// <summary> /// Loads the particiapants for the game /// </summary> /// <param name="allParticipants"></param> /// <param name="n"></param> /// <param name="list"></param> private async void LoadPar(List <Participant> allParticipants, PlatformGameLifecycleDTO n, ListView list) { bool isYourTeam = false; list.Items.Clear(); list.Items.Refresh(); try { string mmrJson; string url = Client.Region.SpectatorLink + "consumer/getGameMetaData/" + Client.Region.InternalName + "/" + n.Game.Id + "/token"; using (var client = new WebClient()) mmrJson = client.DownloadString(url); var serializer = new JavaScriptSerializer(); var deserializedJson = serializer.Deserialize <Dictionary <string, object> >(mmrJson); MMRLabel.Content = "Game MMR ≈ " + deserializedJson["interestScore"]; } catch { MMRLabel.Content = "Unable to calculate Game MMR"; } foreach (Participant par in allParticipants) { if (par is PlayerParticipant) { PublicSummoner scoutersum = await RiotCalls.GetSummonerByName(GSUsername); if ((par as PlayerParticipant).AccountId == scoutersum.AcctId) { isYourTeam = true; } } } foreach (Participant par in allParticipants) { if (par is PlayerParticipant) { var participant = par as PlayerParticipant; foreach (PlayerChampionSelectionDTO championSelect in n.Game.PlayerChampionSelections.Where(championSelect => championSelect.SummonerInternalName == participant.SummonerInternalName)) { GameScouterPlayer control = new GameScouterPlayer(); control.Tag = championSelect; GameStats = new List <MatchStats>(); control.Username.Content = championSelect.SummonerInternalName; //Make it so you can see yourself if (championSelect.SummonerInternalName == GSUsername) { control.Username.Foreground = (Brush)(new BrushConverter().ConvertFrom("#FF007A53")); } control.ChampIcon.Source = champions.GetChampion(championSelect.ChampionId).icon; if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id))))) { var UriSource = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id))), UriKind.Absolute); control.SumIcon1.Source = new BitmapImage(UriSource); } if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))))) { var UriSource = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))), UriKind.Absolute); control.SumIcon2.Source = new BitmapImage(UriSource); } GameStats.Clear(); try { PublicSummoner summoner = await RiotCalls.GetSummonerByName(championSelect.SummonerInternalName.Replace("summoner", string.Empty)); if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", summoner.ProfileIconId.ToString() + ".png"))) { control.ProfileIcon.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", summoner.ProfileIconId.ToString() + ".png")); } RecentGames result = await RiotCalls.GetRecentGames(summoner.AcctId); result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); foreach (PlayerGameStats game in result.GameStatistics) { game.GameType = Client.TitleCaseString(game.GameType.Replace("_GAME", "").Replace("MATCHED", "NORMAL")); var match = new MatchStats(); foreach (RawStat stat in game.Statistics) { Type type = typeof(MatchStats); string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", ""); FieldInfo f = type.GetField(fieldName); f.SetValue(match, stat.Value); } match.Game = game; GameStats.Add(match); } int Kills, ChampKills; int Deaths, ChampDeaths; int Assists, ChampAssists; int GamesPlayed, ChampGamesPlayed; Kills = 0; Deaths = 0; Assists = 0; GamesPlayed = 0; ChampKills = 0; ChampDeaths = 0; ChampAssists = 0; ChampGamesPlayed = 0; //Load average KDA for past 20 games if possible foreach (MatchStats stats in GameStats) { champions gameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); Kills = Kills + (int)stats.ChampionsKilled; Deaths = Deaths + (int)stats.NumDeaths; Assists = Assists + (int)stats.Assists; GamesPlayed++; if (championSelect.ChampionId == (int)Math.Round(stats.Game.ChampionId)) { ChampKills = ChampKills + (int)stats.ChampionsKilled; ChampDeaths = ChampDeaths + (int)stats.NumDeaths; ChampAssists = ChampAssists + (int)stats.Assists; ChampGamesPlayed++; } } //GetKDA string string KDAString = string.Format("{0}/{1}/{2}", (Kills / GamesPlayed), (Deaths / GamesPlayed), (Assists / GamesPlayed)); string ChampKDAString = ""; try { ChampKDAString = string.Format("{0}/{1}/{2}", (ChampKills / ChampGamesPlayed), (ChampDeaths / ChampGamesPlayed), (ChampAssists / ChampGamesPlayed)); } catch { } if (ChampGamesPlayed == 0) { ChampKDAString = "No Games lately"; } control.AverageKDA.Content = KDAString; control.ChampAverageKDA.Content = ChampKDAString; BrushConverter bc = new BrushConverter(); if (isYourTeam) { bc = new BrushConverter(); if (ChampKills < ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C"); } else if (ChampKills == ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D"); } else { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E"); } bc = new BrushConverter(); if (Kills < Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C"); } else if (Kills == Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D"); } else { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E"); } } else { bc = new BrushConverter(); if (ChampKills > ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C"); } else if (ChampKills == ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D"); } else { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E"); } bc = new BrushConverter(); if (Kills > Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C"); } else if (Kills == Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D"); } else { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E"); } } } catch { Client.Log("Failed to get stats about player", "GAME_SCOUTER_ERROR"); } if (participant.TeamParticipantId != null) { try { Brush myColor = color[(double)participant.TeamParticipantId]; control.QueueTeamColor.Fill = myColor; control.QueueTeamColor.Visibility = Visibility.Visible; } catch { BrushConverter bc = new BrushConverter(); Brush brush = Brushes.White; //I know that there is a better way in the InGamePage //I find that sometimes the colors (colours) are very hard to distinguish from eachother //This makes sure that each color is easy to see //because of hexa hill I put 12 in just in case switch (ColorId) { case 0: //blue brush = (Brush)bc.ConvertFrom("#FF00E8FF"); break; case 2: //Lime Green brush = (Brush)bc.ConvertFrom("#FF00FF00"); break; case 3: //Yellow brush = (Brush)bc.ConvertFrom("#FFFFFF00"); break; case 4: //Blue Green brush = (Brush)bc.ConvertFrom("#FF007A53"); break; case 5: //Purple brush = (Brush)bc.ConvertFrom("#FF5100FF"); break; case 6: //Pink brush = (Brush)bc.ConvertFrom("#FFCB46C5"); break; case 7: //Dark Green brush = (Brush)bc.ConvertFrom("#FF006409"); break; case 8: //Brown brush = (Brush)bc.ConvertFrom("#FF643200"); break; case 9: //White brush = (Brush)bc.ConvertFrom("#FFFFFFFF"); break; case 10: //Grey brush = (Brush)bc.ConvertFrom("#FF363636"); break; case 11: //Red Pink brush = (Brush)bc.ConvertFrom("#FF8F4242"); break; case 12: //Grey Blue brush = (Brush)bc.ConvertFrom("#FFFF0000"); break; } color.Add((double)participant.TeamParticipantId, brush); ColorId++; control.QueueTeamColor.Fill = brush; control.QueueTeamColor.Visibility = Visibility.Visible; } } //control.MouseMove += controlMouseEnter; control.MouseEnter += controlMouseEnter; control.MouseLeave += control_MouseLeave; control.MouseDown += control_MouseDown; TinyRuneMasteryData smallData = new TinyRuneMasteryData(); //Now store data in the tags so that all of the event handlers work Dictionary <string, object> data = new Dictionary <string, object>(); data.Add("MasteryDataControl", smallData); data.Add("RuneData", await GetUserRunesPage(GSUsername)); data.Add("MasteryData", await GetUserRunesPage(GSUsername)); control.Tag = data; list.Items.Add(control); } } } }
public void GotRecentGames(RecentGames result) { if (result.GameStatistics == null) { return; } _gameStats.Clear(); result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); foreach (var game in result.GameStatistics) { game.GameType = Client.TitleCaseString(game.GameType.Replace("_GAME", string.Empty).Replace("MATCHED", "NORMAL")); var match = new MatchStats(); foreach (var stat in game.Statistics) { var type = typeof(MatchStats); var fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", string.Empty); var f = type.GetField(fieldName); f.SetValue(match, stat.Value); } match.Game = game; _gameStats.Add(match); } Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { GamesListView.Items.Clear(); BlueListView.Items.Clear(); ItemsListView.Items.Clear(); PurpleListView.Items.Clear(); GameStatsListView.Items.Clear(); foreach (var stats in _gameStats) { var item = new RecentGameOverview(); var gameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); item.ChampionImage.Source = gameChamp.icon; item.ChampionNameLabel.Content = gameChamp.displayName; item.ScoreLabel.Content = string.Format("{0}/{1}/{2} ", stats.ChampionsKilled, stats.NumDeaths, stats.Assists); switch (stats.Game.QueueType) { case "NORMAL": item.ScoreLabel.Content += "(Normal)"; break; case "NORMAL_3x3": item.ScoreLabel.Content += "(Normal 3v3)"; break; case "ARAM_UNRANKED_5x5": item.ScoreLabel.Content += "(ARAM)"; break; case "NONE": item.ScoreLabel.Content += "(Custom)"; break; case "RANKED_SOLO_5x5": item.ScoreLabel.Content += "(Ranked 5v5)"; break; case "RANKED_TEAM_5x5": item.ScoreLabel.Content += "(Ranked Team 5v5)"; break; case "RANKED_TEAM_3x3": item.ScoreLabel.Content += "(Ranked Team 3v3)"; break; case "CAP_5x5": item.ScoreLabel.Content += "(Team Builder)"; break; case "BOT": item.ScoreLabel.Content += "(Bots)"; break; case "KING_PORO": item.ScoreLabel.Content += "(King Poro)"; break; case "COUNTER_PICK": item.ScoreLabel.Content += "(Nemesis Draft)"; break; default: Client.Log(stats.Game.QueueType); item.ScoreLabel.Content += "Please upload this log to github."; break; } item.CreepScoreLabel.Content = stats.MinionsKilled + " minions"; item.DateLabel.Content = stats.Game.CreateDate; item.IPEarnedLabel.Content = "+" + stats.Game.IpEarned + " IP"; item.PingLabel.Content = stats.Game.UserServerPing + "ms"; var bc = new BrushConverter(); var brush = (Brush)bc.ConvertFrom("#FF609E74"); if (Math.Abs(stats.Lose - 1) < .00001) { brush = (Brush)bc.ConvertFrom("#FF9E6060"); } else if (Math.Abs(stats.Game.IpEarned) < .00001) { brush = (Brush)bc.ConvertFrom("#FFE27100"); } item.GridView.Background = brush; item.GridView.Width = 280; GamesListView.Items.Add(item); } if (GamesListView.Items.Count > 0) { GamesListView.SelectedIndex = 0; } })); }
public void GotRecentGames(RecentGames result) { GameStats.Clear(); try { result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); foreach (PlayerGameStats Game in result.GameStatistics) { Game.GameType = Client.TitleCaseString(Game.GameType.Replace("_GAME", "").Replace("MATCHED", "NORMAL")); var Match = new MatchStats(); foreach (RawStat Stat in Game.Statistics) { Type type = typeof(MatchStats); string fieldName = Client.TitleCaseString(Stat.StatType.Replace('_', ' ')).Replace(" ", ""); FieldInfo f = type.GetField(fieldName); f.SetValue(Match, Stat.Value); } Match.Game = Game; GameStats.Add(Match); } } catch { Client.Log("Can't load player recent games", "ERROR"); } Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { GamesListView.Items.Clear(); BlueListView.Items.Clear(); ItemsListView.Items.Clear(); PurpleListView.Items.Clear(); GameStatsListView.Items.Clear(); foreach (MatchStats stats in GameStats) { var item = new RecentGameOverview(); champions GameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); item.ChampionImage.Source = GameChamp.icon; item.ChampionNameLabel.Content = GameChamp.displayName; item.ScoreLabel.Content = string.Format("{0}/{1}/{2} ", stats.ChampionsKilled, stats.NumDeaths, stats.Assists); switch (stats.Game.QueueType) { case "NORMAL": item.ScoreLabel.Content += "(Normal)"; break; case "NORMAL_3x3": item.ScoreLabel.Content += "(Normal 3v3)"; break; case "ARAM_UNRANKED_5x5": item.ScoreLabel.Content += "(ARAM)"; break; case "NONE": item.ScoreLabel.Content += "(Custom)"; break; case "RANKED_SOLO_5x5": item.ScoreLabel.Content += "(Ranked 5v5)"; break; case "RANKED_TEAM_5x5": item.ScoreLabel.Content += "(Ranked Team 5v5)"; break; case "RANKED_TEAM_3x3": item.ScoreLabel.Content += "(Ranked Team 3v3)"; break; case "CAP_5x5": item.ScoreLabel.Content += "(Team Builder)"; break; case "BOT": item.ScoreLabel.Content += "(Bots)"; break; default: Client.Log(stats.Game.QueueType); item.ScoreLabel.Content += "Please upload this log to github."; break; } item.CreepScoreLabel.Content = stats.MinionsKilled + " minions"; item.DateLabel.Content = stats.Game.CreateDate; item.IpEarnedLabel.Content = "+" + stats.Game.IpEarned + " IP"; item.PingLabel.Content = stats.Game.UserServerPing + "ms"; var bc = new BrushConverter(); var brush = (Brush)bc.ConvertFrom("#FF609E74"); if (stats.Lose == 1) { brush = (Brush)bc.ConvertFrom("#FF9E6060"); } else if (stats.Game.IpEarned == 0) { brush = (Brush)bc.ConvertFrom("#FFE27100"); } item.GridView.Background = brush; item.GridView.Width = 250; GamesListView.Items.Add(item); } if (GamesListView.Items.Count > 0) { GamesListView.SelectedIndex = 0; } })); }
public async void RetrieveRecentGamesTest() { RecentGames recentGames = await golf1052.RetrieveRecentGames(); Assert.Equal(26040955, recentGames.summonerId); }
public void GotRecentGames(RecentGames result) { GameStats.Clear(); result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); foreach (PlayerGameStats Game in result.GameStatistics) { Game.GameType = Client.TitleCaseString(Game.GameType.Replace("_GAME", "").Replace("MATCHED", "NORMAL")); MatchStats Match = new MatchStats(); foreach (RawStat Stat in Game.Statistics) { var type = typeof(MatchStats); string fieldName = Client.TitleCaseString(Stat.StatType.Replace('_', ' ')).Replace(" ", ""); var f = type.GetField(fieldName); f.SetValue(Match, Stat.Value); } Match.Game = Game; GameStats.Add(Match); } Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { GamesListView.Items.Clear(); BlueListView.Items.Clear(); ItemsListView.Items.Clear(); PurpleListView.Items.Clear(); GameStatsListView.Items.Clear(); foreach (MatchStats stats in GameStats) { RecentGameOverview item = new RecentGameOverview(); champions GameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); item.ChampionImage.Source = GameChamp.icon; item.ChampionNameLabel.Content = GameChamp.displayName; item.ScoreLabel.Content = string.Format("{0}/{1}/{2} ({3})", stats.ChampionsKilled, stats.NumDeaths, stats.Assists, stats.Game.GameType); item.CreepScoreLabel.Content = stats.MinionsKilled + " minions"; item.DateLabel.Content = stats.Game.CreateDate; item.IPEarnedLabel.Content = "+" + stats.Game.IpEarned + " IP"; item.PingLabel.Content = stats.Game.UserServerPing + "ms"; BrushConverter bc = new BrushConverter(); Brush brush = (Brush)bc.ConvertFrom("#FF609E74"); if (stats.Lose == 1) { brush = (Brush)bc.ConvertFrom("#FF9E6060"); } else if (stats.Game.IpEarned == 0) { brush = (Brush)bc.ConvertFrom("#FFE27100"); } item.GridView.Background = brush; item.GridView.Width = 250; GamesListView.Items.Add(item); } })); }
protected override async void OnNavigatedTo(NavigationEventArgs e) { List <object> parameters = e.Parameter as List <object>; summoner = parameters[0] as Summoner; summonerNameTextBlock.Text = summoner.name; summonerProfileIconImage.Source = AppConstants.SetImageSource(new Uri(AppConstants.SummonerProfileIconUrl() + summoner.profileIconId.ToString() + ".png")); if (summoner.summonerLevel == 30) { leagues = await summoner.RetrieveLeague(); if (leagues != null) { League league = null; LeagueEntry summonerLeagueEntry = null; foreach (League l in leagues[summoner.id.ToString()]) { if (l.queue == GameConstants.Queue.Solo5) { league = l; ComboBoxItem temp = new ComboBoxItem(); temp.Content = "Solo"; queueTypeComboBox.Items.Add(temp); } else if (l.queue == GameConstants.Queue.Team5) { ComboBoxItem temp = new ComboBoxItem(); temp.Content = "5 v 5"; queueTypeComboBox.Items.Add(temp); } else if (l.queue == GameConstants.Queue.Team3) { ComboBoxItem temp = new ComboBoxItem(); temp.Content = "3 v 3"; queueTypeComboBox.Items.Add(temp); } leagueKey.Add(l); } if (queueTypeComboBox.Items.Count != 0) { queueTypeComboBox.SelectedIndex = 0; } if (league != null) { summonerLeagueEntry = FindLeagueEntry(league, summoner.id.ToString()); currentDivision = summonerLeagueEntry.division; currentLeague = league; DisplayDisvison(league, summonerLeagueEntry.division); } } else { rankedLeaguesHubSection.Visibility = Windows.UI.Xaml.Visibility.Collapsed; } } recentGames = await summoner.RetrieveRecentGames(); foreach (Game game in recentGames.games) { recentGamesCollection.Add(new RecentGameListViewBinding(game)); } runePages = await summoner.RetrieveRunePages(); LoadRuneImages(); foreach (RunePage page in runePages[summoner.id.ToString()].pages) { ComboBoxItem item = new ComboBoxItem(); if (page.current) { item.Content = page.name + " - Active"; } else { item.Content = page.name; } runePageComboBox.Items.Add(item); } runePageComboBox.SelectedIndex = 0; LoadRunePage(runePages[summoner.id.ToString()].pages[0]); justLoaded = false; }
void UpdateSummoner(Summoner summoner, AllPublicSummonerDataDTO publicSummonerData, AggregatedStats[] aggregatedStats, PlayerLifeTimeStats lifeTimeStatistics, RecentGames recentGames, DbConnection connection) { int accountId = summoner.AccountId; lock (ActiveAccountIds) { // Avoid concurrent updates of the same account, it's asking for trouble and is redundant anyways // We might obtain outdated results in one query but that's a minor issue in comparison to corrupted database results if (ActiveAccountIds.Contains(accountId)) { return; } ActiveAccountIds.Add(accountId); } // Use a transaction because we're going to insert a fair amount of data using (var transaction = connection.BeginTransaction()) { UpdateSummonerFields(summoner, connection, true); UpdateRunes(summoner, publicSummonerData, connection); UpdateSummonerRatings(summoner, lifeTimeStatistics, connection); // A season value of zero indicates the current season only for (int season = 0; season < aggregatedStats.Length; season++) { UpdateSummonerRankedStatistics(summoner, season, aggregatedStats[season], connection); } UpdateSummonerGames(summoner, recentGames, connection); transaction.Commit(); } lock (ActiveAccountIds) ActiveAccountIds.Remove(accountId); }
public void SetGames(RecentGames games) { if (games == null || games.GameStatistics.Count < 1) { return; } if (InvokeRequired) { Invoke(new Action <RecentGames>(SetGames), games); return; } RemoveAll(p => (p.Tag as string) == "Recent"); var layout = new TableLayoutPanel { Dock = DockStyle.Fill, Margin = Padding.Empty, }; const int rows = 5; const int cols = 2; var list = games.GameStatistics.OrderByDescending(p => p.GameId).ToList(); for (int x = 0; x < cols; x++) { for (int y = 0; y < rows; y++) { int idx = y + (x * rows); if (idx >= list.Count) { break; } var game = list[idx]; if (game.ChampionId == 0) { continue; } var won = game.Statistics.GetInt(RawStat.WIN) != 0; var kills = game.Statistics.GetInt(RawStat.CHAMPION_KILLS); var deaths = game.Statistics.GetInt(RawStat.DEATHS); var assists = game.Statistics.GetInt(RawStat.ASSISTS); var left = game.Leaver; var botgame = game.QueueType == "BOT"; var wonlabel = CreateLabel(string.Format("{0}{1}", left ? "[L] " : "", won ? "Won" : "Lost")); wonlabel.ForeColor = won ? Color.Green : Color.Red; var kdrlbl = CreateLabel(string.Format("({0}/{1}/{2})", kills, deaths, assists)); kdrlbl.ForeColor = GetKdrColor(kills, deaths); var champicon = new PictureBox { Image = ChampIcons.Get(game.ChampionId), Margin = Padding.Empty, SizeMode = PictureBoxSizeMode.StretchImage, Size = new Size(20, 20) }; if (botgame) { wonlabel.ForeColor = kdrlbl.ForeColor = Color.Black; } var controls = new List <Control> { champicon, wonlabel, kdrlbl, CreateSpellPicture(game.Spell1), CreateSpellPicture(game.Spell2) }; //Add a space between the last column in each set. controls[controls.Count - 1].Margin = new Padding(0, 0, 5, 0); for (int i = 0; i < controls.Count; i++) { layout.AddControl(controls[i], i + x * controls.Count, y); } } } var tab = new TabPage("Recent") { BackColor = this.BackColor, Tag = "Recent" }; tab.Controls.Add(layout); AddTab(tab); }
/// 22.) public void GetRecentGames(Double accountId, RecentGames.Callback callback) { RecentGames cb = new RecentGames(callback); InvokeWithCallback("playerStatsService", "getRecentGames", new object[] { accountId }, cb); }
private bool GetSettingsFromRegistry() { Dictionary <string, string> regmap = new Dictionary <string, string>() { // [<registry name>] = <setting name> ["ScEdTabWidth"] = "TabSize", ["TestGameStyle"] = "TestGameWindowStyle", ["MessageBoxOnCompileErrors"] = "MessageBoxOnCompile", ["IndentUsingTabs"] = "IndentUseTabs", ["SpriteImportTransparency"] = "SpriteImportMethod", ["RemapPaletteBackgrounds"] = "RemapPalettizedBackgrounds" }; RegistryKey key = Registry.CurrentUser.OpenSubKey(AGSEditor.AGS_REGISTRY_KEY); List <string> gameNames = new List <string>(); List <string> gamePaths = new List <string>(); bool success = true; if (key != null) { foreach (string regname in key.GetValueNames()) { string value; try { value = key.GetValue(regname).ToString(); } catch { // failed to read as a string success = false; continue; } if (regname.StartsWith("Recent")) { if (regname.StartsWith("RecentPath")) { gamePaths.Add(value); } else if (regname.StartsWith("RecentName")) { gameNames.Add(value); } else if (regname.StartsWith("RecentSearch") && RecentSearches.Count < MAX_RECENT_SEARCHES) { RecentSearches.Insert(0, value); } } else { string name = regmap.ContainsKey(regname) ? regmap[regname] : regname; int numeric; try { // will throw SettingsPropertyNotFoundException // for legacy settings which no longer exist Type type = this[name].GetType(); // will throw System.InvalidCastException if can't be converted if (type.BaseType == typeof(Enum)) { this[name] = Enum.Parse(type, value); } else if (int.TryParse(value, out numeric)) { this[name] = Convert.ChangeType(numeric, type); } else { this[name] = Convert.ChangeType(value, type); } } catch (Exception ex) { if (!(ex is SettingsPropertyNotFoundException)) { success = false; } // continue } } } key.Close(); int gameCount = Math.Min(gameNames.Count, gamePaths.Count); for (int i = 0; i < gameCount; i++) { if (RecentGames.Count >= MAX_RECENT_GAMES) { break; } RecentGames.Add(new RecentGame(gameNames[i], gamePaths[i])); } } return(success); }
public async void Update(double AccountId) { RecentGames games = await RiotCalls.GetRecentGames(AccountId); GotRecentGames(games); }