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; }
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 all of the current League of Legends champions. /// </summary> /// <param name="region">The region to check</param> /// <remarks>Version 1.2</remarks> /// <returns></returns> public ChampionCollection GetChampions() { DataContractJsonSerializerSettings settings = new DataContractJsonSerializerSettings(); settings.UseSimpleDictionaryFormat = true; DataContractJsonSerializer jSerializer = new DataContractJsonSerializer(typeof(ChampionCollection), settings); WebClient webClient = new WebClient(); ChampionCollection staticChampCollectionCall = new ChampionCollection(); ChampionCollection champCollectionCall = new ChampionCollection(); try { champCollectionCall = (ChampionCollection)jSerializer.ReadObject(webClient.OpenRead(String.Format("https://{0}.api.pvp.net/api/lol/{0}/v1.2/champion?api_key={1}", _region, _apiKey))); staticChampCollectionCall = (ChampionCollection)jSerializer.ReadObject(webClient.OpenRead(String.Format("https://{0}.api.pvp.net/api/lol/static-data/{0}/v1.2/champion?champData=all&api_key={1}", _region, _apiKey))); foreach (Champion champion in staticChampCollectionCall) { Champion info = champCollectionCall.Find(champion.Id); champion.Active = info.Active; champion.BotEnabled = info.BotEnabled; champion.BotMmEnabled = info.BotMmEnabled; champion.FreeToPlay = info.FreeToPlay; champion.RankedPlayEnabled = info.RankedPlayEnabled; } } catch (WebException e) { throw new Exception(e.Message); } return staticChampCollectionCall; }