private void searchButton_Click(object sender, EventArgs e) { Riot = RiotApi.NewInstance(ApiKey); if (StatsByLeague) { GetLeagueByDivisionSync(regionBox, divisionBox, leagueBox, top10Summoners); Role Top = new Role(); Top.RoleName = "Top"; Role Jungle = new Role(); Jungle.RoleName = "Jungle"; Role Mid = new Role(); Mid.RoleName = "Mid"; Role Support = new Role(); Support.RoleName = "Support"; Role ADC = new Role(); ADC.RoleName = "ADC"; foreach (SummonerData current in DataList) { CalculateTopChampsSync(top10Summoners, current, Top, Jungle, Mid, Support, ADC); } PopulateTopChampsSync(Top, Jungle, Mid, Support, ADC); SummonerData Collective = new SummonerData(); Collective.Roles.Clear(); Collective.Roles.Add(Top); Collective.Roles.Add(Jungle); Collective.Roles.Add(Mid); Collective.Roles.Add(Support); Collective.Roles.Add(ADC); Collective.Name = "Collective"; PopulatePopularDataSync(Collective); } else { if (CheckResponse(regionBox, summonerNameBox.Text, Riot, ApiKey)) { GetSummonerSync(regionBox, summonerNameBox.Text); GetRoleInfoSync(regionBox, DataList[0]); CalculateTopChampsSync(top10Summoners, DataList[0]); PopulatePopularDataSync(DataList[0]); } else { // Invalid response from server progressBarStatusLabel1.BackColor = Color.FromName("Crimson"); progressBarStatusLabel1.Text = "No Response"; } } }
private void CalculateTopChampsSync(ListBox listBox, SummonerData current) { listBox.Items.Add(current.Name); foreach (Role r in current.Roles) { FindTopChamps(r); PopulateTopChampsSync(r); } }
private static void GetSummonerSync(ComboBox region, string name) { Summoner summoner; summoner = Riot.SummonerV4.GetBySummonerName(Utility.GetRegion(region.Text), name); SummonerData currentData = new SummonerData(); currentData.Name = summoner.Name; currentData.AccountId = summoner.AccountId; DataList.Add(currentData); }
private void CalculateTopChampsSync(ListBox listBox, SummonerData current, Role Top, Role Jungle, Role Mid, Role Support, Role ADC) { listBox.Items.Add(current.Name); foreach (Role r in current.Roles) { switch (r.RoleName) { case "Top": CombineRoles(r, Top); break; case "Jungle": CombineRoles(r, Jungle); break; case "Mid": CombineRoles(r, Mid); break; case "Support": CombineRoles(r, Support); break; case "ADC": CombineRoles(r, ADC); break; default: break; } } FindTopChamps(Top); PopulateTopChampsSync(Top); FindTopChamps(Jungle); PopulateTopChampsSync(Jungle); FindTopChamps(Mid); PopulateTopChampsSync(Mid); FindTopChamps(Support); PopulateTopChampsSync(Support); FindTopChamps(ADC); PopulateTopChampsSync(ADC); }
private static void GetLeagueByDivisionSync(ComboBox region, ComboBox division, ComboBox league, ListBox list) { var leagueEntries = Riot.LeagueExpV4.GetLeagueEntries(Utility.GetRegion(region.Text), QueueType.RANKED_SOLO_5x5, Utility.GetTier(league.Text), Utility.GetDivision(division.Text)); for (int i = 0; i < 10; i++) { SummonerData current = new SummonerData(); Summoner summoner = new Summoner(); summoner = Riot.SummonerV4.GetBySummonerName(Utility.GetRegion(region.Text), leagueEntries[i].SummonerName); current.Name = leagueEntries[i].SummonerName; current.AccountId = summoner.AccountId; GetRoleInfoSync(region, current); DataList.Add(current); } }
private void PopulatePopularDataSync(SummonerData data) { Role mostPlayed = new Role(); foreach (Role r in data.Roles) { if (r.MatchCount > mostPlayed.MatchCount) { mostPlayed = r; } } commonRoleBox.Text = mostPlayed.RoleName; switch (mostPlayed.RoleName) { case "Top": commonLaneBox.Text = "Top"; break; case "Jungle": commonLaneBox.Text = "Jungle"; break; case "Mid": commonLaneBox.Text = "Mid"; break; case "Support": commonLaneBox.Text = "Bottom"; break; case "ADC": commonLaneBox.Text = "Bottom"; break; default: break; } }
private static void GetRoleInfoSync(ComboBox region, SummonerData current) { Matchlist matchlist; matchlist = Riot.MatchV4.GetMatchlist(Utility.GetRegion(region.Text), current.AccountId); foreach (MatchReference m in matchlist.Matches) { switch (m.Lane) { case "TOP": current.Roles[0].MatchCount++; if (current.Roles[0].ChampionMap.ContainsKey(m.Champion)) { current.Roles[0].ChampionMap[m.Champion]++; } else { current.Roles[0].ChampionMap.Add(m.Champion, 1); } break; case "JUNGLE": current.Roles[1].MatchCount++; if (current.Roles[1].ChampionMap.ContainsKey(m.Champion)) { current.Roles[1].ChampionMap[m.Champion]++; } else { current.Roles[1].ChampionMap.Add(m.Champion, 1); } break; case "MID": current.Roles[2].MatchCount++; if (current.Roles[2].ChampionMap.ContainsKey(m.Champion)) { current.Roles[2].ChampionMap[m.Champion]++; } else { current.Roles[2].ChampionMap.Add(m.Champion, 1); } break; case "BOTTOM": if (m.Role.Contains("CARRY")) { current.Roles[4].MatchCount++; if (current.Roles[4].ChampionMap.ContainsKey(m.Champion)) { current.Roles[4].ChampionMap[m.Champion]++; } else { current.Roles[4].ChampionMap.Add(m.Champion, 1); } } else { current.Roles[3].MatchCount++; if (current.Roles[3].ChampionMap.ContainsKey(m.Champion)) { current.Roles[3].ChampionMap[m.Champion]++; } else { current.Roles[3].ChampionMap.Add(m.Champion, 1); } } break; default: if (m.Lane.Equals("NONE")) { if (m.Role.Contains("SUPPORT")) { current.Roles[3].MatchCount++; if (current.Roles[3].ChampionMap.ContainsKey(m.Champion)) { current.Roles[3].ChampionMap[m.Champion]++; } else { current.Roles[3].ChampionMap.Add(m.Champion, 1); } } else if (m.Role.Equals("DUO")) { break; } else if (m.Role.Contains("CARRY")) { current.Roles[4].MatchCount++; if (current.Roles[4].ChampionMap.ContainsKey(m.Champion)) { current.Roles[4].ChampionMap[m.Champion]++; } else { current.Roles[4].ChampionMap.Add(m.Champion, 1); } } } break; } } }