public async void AddGame(CurrentGame currentGame, string summonerName, Region region) { await Task.Factory.StartNew(() => { foreach (Participant p in currentGame.Participants) { if (p.SummonerName != summonerName) { if (!KeyValueExists(PLAYERS_TABLE, p.SummonerId.ToString(), currentGame.GameId.ToString())) { InsertRow(PLAYERS_TABLE, p.SummonerId.ToString(), currentGame.GameId.ToString()); } } } }); }
public CurrentGamePanel(CurrentGame currentGame, string summonerName, RiotSharp.Region region, List<ChampionStatic> championStatics, Dictionary<long, List<League>> leagues) { // Set panel properties Size = new Size(320, 180); // Set team info List<long> teamIds = new List<long>(); List<int> teamNumPlayers = new List<int>(); foreach (Participant p in currentGame.Participants) { // Add new team for the game if it does not exist if (!teamIds.Contains(p.TeamId)) { teamIds.Add(p.TeamId); teamNumPlayers.Add(0); } // Get team index int teamIndex = teamIds.IndexOf(p.TeamId); // Get champion icon string iconLocation = "http://ddragon.leagueoflegends.com/cdn/" + Program.PatchVersion + "/img/champion/" + championStatics[currentGame.Participants.IndexOf(p)].Image.Full; // Check if participant is self bool isSelf = false; if (p.SummonerName.Replace(" ", "").ToLower() == summonerName.Replace(" ", "").ToLower()) { isSelf = true; } // Get ranked stats List<League> rankedStats = new List<League>(); if (leagues.ContainsKey(p.SummonerId)) { rankedStats = leagues[p.SummonerId]; } // Create player panel CurrentGamePlayerPanel playerPanel = new CurrentGamePlayerPanel(p, region, isSelf, iconLocation, rankedStats); playerPanel.Location = new Point(155 * teamIndex, 36 * teamNumPlayers[teamIndex]); teamNumPlayers[teamIndex]++; // Add player panel Controls.Add(playerPanel); } }
public static async Task<CurrentGamePanel> GetCurrentGamePanelAsync(CurrentGame currentGame, string summonerName, Region region) { CurrentGamePanel currentGamePanel; if (currentGame != null) { // Get champion data List<ChampionStatic> championStatics = new List<ChampionStatic>(); List<int> summonerIds = new List<int>(); foreach (Participant p in currentGame.Participants) { summonerIds.Add((int)p.SummonerId); ChampionStatic championStatic = await Program.StaticRiotApi.GetChampionAsync(region, (int)p.ChampionId, ChampionData.image); championStatics.Add(championStatic); } // Get league data Dictionary<long, List<League>> leagues = await Program.RiotApi.GetLeaguesAsync(region, summonerIds); currentGamePanel = new CurrentGamePanel(currentGame, summonerName, region, championStatics, leagues); } else { currentGamePanel = null; } return currentGamePanel; }
private void OnGameStatusChanged(GameStatus status, CurrentGame currentGame = null) { if (GameStatusChanged != null) { GameStatusChanged(this, new GameStatusChangedEventArgs(status, currentGame)); } }
public GameStatusChangedEventArgs(GameStatus status, CurrentGame currentGame = null) { Status = status; CurrentGame = currentGame; }