// Stores personal history in a dictionary. public void StorePersonalHistory(String summonerName, TextBox status) { String summonerIdUrl = Coder.GetSummonerIdUrl(region, summonerName); String summonerIdJson = reader.Request(summonerIdUrl); String summonerId = Parser.GetSummonerId(summonerIdJson); int matchNumber = 0; // loops until there is no more match history while (true) { String matchHistoryUrl = Coder.GetMatchHistoryUrl(region, summonerId, matchNumber, matchNumber + MATCH_SEARCH_LIMIT); String matchHistoryJson = reader.Request(matchHistoryUrl); // there is no more match history if (matchHistoryJson.Equals("{}") | matchHistoryJson.Equals(String.Empty)) { break; } MatchHistory matchHistory = Parser.ParseMatchHistory(matchHistoryJson); status.Text = (matchNumber + matchHistory.matches.Count) + " games found"; status.Refresh(); foreach (MatchHistoryNameSpace.Match match in matchHistory.matches) { MatchHistoryNameSpace.Participant participant = match.participants[0]; personalHistory[match.matchId] = new PersonalParticipant(match.participants[0].teamId, participant.stats.winner, participant.championId); } matchNumber += MATCH_SEARCH_LIMIT; } }
// Event: go is clicked. Gets data for summoner and region and populates // champions. The alphabetically first champion is chosen and // champions_TextChanged() is called. private void go_Click(object sender, EventArgs e) { overallWin.Text = String.Empty; overallWin.Refresh(); status.Text = String.Empty; status.Visible = true; status.Refresh(); champions.Items.Clear(); champions.Text = String.Empty; champions.Refresh(); data.DataSource = null; data.Refresh(); String regionLower = region.Text.ToLower(); model = new Model(regionLower); String summonerIdUrl = Coder.GetSummonerIdUrl(regionLower, summoner.Text); // invalid summoner name and or region if (model.reader.Request(summonerIdUrl).Equals(String.Empty)) { System.Windows.Forms.MessageBox.Show("invalid summoner name and or region"); return; } String summonerIdJson = model.reader.Request(summonerIdUrl); model.StorePersonalHistory(summoner.Text, status); model.StoreGlobalHistory(status); model.CalcChampionStats(); foreach (int championId in model.championStats.Keys) { champions.Items.Add(model.championNames[championId]); } champions.SelectedIndex = 0; champions_SelectedIndexChanged(String.Empty, new EventArgs()); champions.Visible = true; status.Text = "done with " + model.CountMatches() + " games"; status.Refresh(); }