private void searchButton_Click(object sender, EventArgs e) { if (nameTextBox.Text.Trim() == "" || regionComboBox.SelectedIndex == -1) { MessageBox.Show("Please enter a name or select a region."); return; } summoner = info.LookupSummonerByName(nameTextBox.Text, regionComboBox.SelectedItem.ToString()); MessageBox.Show(summoner.Name);//21014383 summoner = info.LookupSummonerByID(regionComboBox.SelectedItem.ToString(), summoner.ID); gamesPlayed = summoner.GetRecentGames(); champs = info.GetChampions(); PlayerStatsSummaryList sum = summoner.GetStatSummary(Season.SEASON3); int i = 0; foreach(Game game in gamesPlayed) { DataRow row = table.NewRow(); row["Game"] = string.Format("Game {0}", i + 1); i++; //row["Champion"] = champs.FindById(game.ChampionId).Name; row["Queue"] = game.subType; row["WinLoss"] = game.Statistics.Win.ToString(); row["Type"] = game.GameType; row["Date"] = game.CreateDateTime.Date; string kda = ""; kda += game.Statistics.ChampionsKilled.ToString() + "/" + game.Statistics.Deaths.ToString() +"/" + game.Statistics.Assists.ToString(); row["K/D/A"] = kda; table.Rows.Add(row); } summonerInfoDataGrid.DataSource = table; }
/// <summary> /// Gets the last 10 played games of the summoner. Updated as of Gamev1.3 /// </summary> /// <returns></returns> public RecentGamesCollection GetRecentGames() { jSerializer = new DataContractJsonSerializer(typeof(RecentGamesCollection)); webClient = new WebClient(); RecentGamesCollection games = new RecentGamesCollection(); try { games = ((RecentGamesCollection)jSerializer.ReadObject(webClient.OpenRead(string.Format("http://prod.api.pvp.net/api/lol/{0}/v1.3/game/by-summoner/{1}/recent?api_key={2}", _region, _id, LolInfo.APIKEY)))); } catch (WebException e) { throw new Exception(e.Message); } return games; }
private void SummonerForm_Load(object sender, EventArgs e) { info = new InfoGrabber("na", LolInfo.APIKEY); table = new DataTable(); gamesPlayed = new RecentGamesCollection(); champs = new ChampionCollection(); table.Columns.Add("Date"); table.Columns.Add("Game"); table.Columns.Add("Type"); table.Columns.Add("Queue"); table.Columns.Add("Champion"); table.Columns.Add("WinLoss"); table.Columns.Add("K/D/A"); }
/// <summary> /// Looks up the most recent match history of a summoner /// </summary> /// <param name="region">The region to check</param> /// <param name="summonerID">Id of the summoner</param> /// <remarks>Version 1.3</remarks> /// <returns></returns> public RecentGamesCollection GetRecentGames(long summonerID) { RecentGamesCollection games = new RecentGamesCollection(); DataContractJsonSerializer jSerializer = new DataContractJsonSerializer(typeof(RecentGamesCollection)); WebClient webClient = new WebClient(); try { games = (RecentGamesCollection)jSerializer.ReadObject(webClient.OpenRead(String.Format("https://{0}.api.pvp.net/api/lol/{0}/v1.3/game/by-summoner/{1}/recent?api_key={2}", _region, summonerID, _apiKey))); } catch { throw; } return games; }