public SummonerInfo(SummonerInfo si) { name = si.name; region = si.region; level = si.level; soloWinrate = si.soloWinrate; flexWinrate = si.flexWinrate; soloRank = si.soloRank; flexRank = si.flexRank; }
public SummonerInfo GetSummoner(string name, string region) { var pathBuilder = new UrlPathBuilder(); var summonerInfo = new SummonerInfo(); summonerInfo.Summoner = GetSummonerByName(name, region); if (summonerInfo.Summoner.AccountId == null) { return(null); } summonerInfo.MatchHistory = GetMatchHistoryOfSummoner(summonerInfo.Summoner.AccountId, region); summonerInfo.LeagueEntries = GetLeagueEntriesOfSummoner(summonerInfo.Summoner.Id, region); summonerInfo.ProfileIconUrl = pathBuilder.GetProfileIconUrl(summonerInfo.Summoner.ProfileIconId); summonerInfo.LastPlayed = SummonerInfoUtils.GetLastTimePlayedStr(summonerInfo.MatchHistory); summonerInfo.Region = region; return(summonerInfo); }
//Search with(name/level/region) public SummonerInfo GetName(string SummonerName, Region region) { SummonerInfo summonerInfo = new SummonerInfo("Unknown"); var api = RiotApi.GetDevelopmentInstance(apiKey); try { var summoner = api.Summoner.GetSummonerByNameAsync(region, SummonerName).Result; summonerInfo.name = summoner.Name; summonerInfo.region = summoner.Region.ToString(); } catch { Console.WriteLine($"{SummonerName} has not been found in {region}"); return(summonerInfo); } Console.WriteLine($"{SummonerName} has been found in {region}"); return(summonerInfo); }
public async Task <SummonerTeamCreationView> GetSummonersToCreateTeamAsync() { var seasonInfo = await _seasonInfoRepository.GetCurrentSeasonAsync(); var summonersTask = _summonerInfoRepository.GetAllValidSummonersAsync(); var rostersTask = _teamRosterRepository.GetAllTeamsAsync(seasonInfo.Id); var summoners = (await summonersTask).Where(x => x.IsValidPlayer).ToList(); var rosters = await rostersTask; var view = new SummonerTeamCreationView { SummonerInfos = new List <SummonerInfo>() }; var unassignedPlayers = summoners.ToList(); foreach (var roster in rosters) { var summonerIds = (await _teamPlayerRepository.ReadAllForRosterAsync(roster.Id)).Select(x => x.SummonerId); foreach (var summonerId in summonerIds) { var summoner = summoners.FirstOrDefault(x => x.Id == summonerId); if (summoner != null) { unassignedPlayers.Remove(summoner); } } } foreach (var unassignedPlayer in unassignedPlayers) { var info = new SummonerInfo { SummonerId = unassignedPlayer.Id, SummonerName = unassignedPlayer.SummonerName }; view.SummonerInfos.Add(info); } return(view); }
public void SearchSummoner(string Summoner) { #region Control_TextBox LoadCircle.Visible = true; if (Summoner == "") { MessageLabel.Visible = true; MessageLabel.Text = "Enter summoner name!"; //CONTROL EMPTY TEXTOBX emptyTextBoxControlTimer.Enabled = true; LoadCircle.Visible = false; } #endregion else { try { #region GetSummonerAndIcon SummonerInfo summonerInfo = GetSummoner.ReturnSummoner(Summoner, regionsComboBox.Text, apiKey); SummonerIconPictureBox.Image = ProfileIcon.ReturnIcon(summonerInfo.profileIconId.ToString(), version); SummonerNameLabel.Text = summonerInfo.name; levelLabel.Text = "Level: " + summonerInfo.summonerLevel; #endregion //---------------------------------------------------------------------------------#ff000000------#ff010101----------------------------------------------------------------------------------------------------------------------// #region DataTable DataTable dt = new DataTable(); dt.Columns.Add("Champion"); dt.Columns.Add("KDA"); dt.Columns.Add("Games played"); dt.Columns.Add("Wins"); dt.Columns.Add("Minions"); dt.Columns.Add("Golds"); dt.Columns.Add("Penta Kills"); dt.Columns.Add("Quadra Kills"); dt.Columns.Add("Triple Kills"); dt.Columns.Add("Double Kills"); dt.Columns.Add("Max kills"); dt.Columns.Add("Max deaths"); dt.Columns.Add("Turrets destroyed"); if (summonerInfo.summonerLevel == 30) { WebClient statclient = new WebClient(); Stream statdata = statclient.OpenRead("https://" + regionsComboBox.Text.ToLower() + ".api.pvp.net/api/lol/" + regionsComboBox.Text.ToLower() + "/v1.3/stats/by-summoner/" + summonerInfo.id + "/ranked?api_key=" + apiKey); StreamReader statreader = new StreamReader(statdata); //GET STATS string result = statreader.ReadLine(); StatsInfo statsInfo = JsonConvert.DeserializeObject <StatsInfo>(result); //DESERIALIZE JSON STRING //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// Champion TotalStatus = new Champion(); List <Champion> listChampions = new List <Champion>(); foreach (Champion champion in statsInfo.champions) { if (champion.id == 0) { TotalStatus = champion; } listChampions.Add(champion); } listChampions.Sort(delegate(Champion c1, Champion c2) { return(c2.stats.totalSessionsPlayed.CompareTo(c1.stats.totalSessionsPlayed)); }); string joinedIDs = ""; int countChampion = 0; foreach (Champion champ in listChampions) { joinedIDs += champ.id.ToString() + ","; countChampion++; //RETURN CHAMPIONS BY IDS AND RETURN VERSION OF CHAMPION POOL } joinedIDs = joinedIDs.Remove(joinedIDs.Length - 1); string[] Champions = Transform.ReturnChampion(JSON, joinedIDs, countChampion); version = Transform.returnVersion(JSON); //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// int x = 0; foreach (Champion champion in statsInfo.champions) //SORT STATS INFO { if (x != 0) { float WonPercentage = ((float)listChampions[x].stats.totalSessionsWon / (float)listChampions[x].stats.totalSessionsPlayed) * 100; int wonPercToInt = (int)WonPercentage; dt.Rows.Add(Champions[x], Math.Round(listChampions[x].stats.totalChampionKills / listChampions[x].stats.totalSessionsPlayed) + "/" + Math.Round(listChampions[x].stats.totalDeathsPerSession / listChampions[x].stats.totalSessionsPlayed) + "/" + Math.Round(listChampions[x].stats.totalAssists / listChampions[x].stats.totalSessionsPlayed), listChampions[x].stats.totalSessionsPlayed, listChampions[x].stats.totalSessionsWon + " (" + wonPercToInt + "%)", listChampions[x].stats.totalMinionKills / listChampions[x].stats.totalSessionsPlayed, listChampions[x].stats.totalGoldEarned / listChampions[x].stats.totalSessionsPlayed, listChampions[x].stats.totalPentaKills, listChampions[x].stats.totalQuadraKills, listChampions[x].stats.totalTripleKills, listChampions[x].stats.totalDoubleKills, listChampions[x].stats.maxChampionsKilled, listChampions[x].stats.maxNumDeaths, listChampions[x].stats.totalTurretsKilled); } x++; } float AvgWon = ((float)listChampions[0].stats.totalSessionsWon / (float)listChampions[0].stats.totalSessionsPlayed) * 100; int avgWonINT = (int)AvgWon; WLlabel.Text = (TotalStatus.stats.totalSessionsWon + "/" + TotalStatus.stats.totalSessionsLost) + " (" + avgWonINT.ToString() + "%)"; avgKDAlabel.Text = Math.Round(listChampions[0].stats.totalChampionKills / listChampions[0].stats.totalSessionsPlayed) + "/" + Math.Round(listChampions[0].stats.totalDeathsPerSession / listChampions[0].stats.totalSessionsPlayed) + "/" + Math.Round(listChampions[0].stats.totalAssists / listChampions[0].stats.totalSessionsPlayed); avgPentakillsLabel.Text = listChampions[0].stats.totalPentaKills.ToString(); avgMinionsLabel.Text = (listChampions[0].stats.totalMinionKills / listChampions[0].stats.totalSessionsPlayed).ToString(); } else //UNDER LV30 { WLlabel.Text = "-"; avgKDAlabel.Text = "-"; avgPentakillsLabel.Text = "-"; avgMinionsLabel.Text = "-"; } ChampionsInfoGrid.DataSource = dt; foreach (DataGridViewColumn column in ChampionsInfoGrid.Columns) { column.SortMode = DataGridViewColumnSortMode.NotSortable; //column.Width = 75; } //ChampionsInfoGrid.Sort(ChampionsInfoGrid.Columns[1], ListSortDirection.Descending); if (ChampionsInfoGrid.Rows.Count == 0) { ChampionSearchTextBox.Enabled = false; } else { ChampionSearchTextBox.Enabled = true; } #endregion //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// #region GetDivison string DivisionResult = ""; Image DivisionImage = new Bitmap(LoLAssistant.Properties.Resources.provisional); try { WebClient DivisionClient = new WebClient(); string s = "https://" + regionsComboBox.Text.ToLower() + ".api.pvp.net/api/lol/" + regionsComboBox.Text.ToLower().ToLower() + "/v2.5/league/by-summoner/" + summonerInfo.id + "/entry?api_key=" + apiKey; Stream DivisionData = DivisionClient.OpenRead(s); StreamReader DivisionReader = new StreamReader(DivisionData); DivisionResult = DivisionReader.ReadLine(); } catch (WebException ex) { if (ex.Status == WebExceptionStatus.ProtocolError) { HttpWebResponse response = (HttpWebResponse)ex.Response; if (response.StatusCode == HttpStatusCode.NotFound) { DivisionImage = new Bitmap(LoLAssistant.Properties.Resources.provisional); } } } if (summonerInfo.summonerLevel == 30 && DivisionResult != "") { DivisionResult = DivisionResult.Replace("{\"" + summonerInfo.id + "\":", string.Empty); DivisionResult = DivisionResult.Replace("}]}]}", "}]}]"); List <Division> divisions = JsonConvert.DeserializeObject <List <Division> >(DivisionResult); foreach (Division div in divisions) { if (div.queue == "RANKED_SOLO_5x5") { DivisionLabel.Text = div.tier + " " + div.entries[0].division + " " + "(" + div.entries[0].leaguePoints + "lp)"; switch (div.tier) { case "BRONZE": DivisionImage = new Bitmap(LoLAssistant.Properties.Resources.bronze); break; case "SILVER": DivisionImage = new Bitmap(LoLAssistant.Properties.Resources.silver); break; case "GOLD": DivisionImage = new Bitmap(LoLAssistant.Properties.Resources.gold); break; case "PLATINUM": DivisionImage = new Bitmap(LoLAssistant.Properties.Resources.platinum); break; case "DIAMOND": DivisionImage = new Bitmap(LoLAssistant.Properties.Resources.diamond); break; case "MASTER": DivisionImage = new Bitmap(LoLAssistant.Properties.Resources.master); break; case "CHALLENGER": DivisionImage = new Bitmap(LoLAssistant.Properties.Resources.challenger); break; } } } } else //UNRANKED OR NOT 30LV { DivisionImage = new Bitmap(LoLAssistant.Properties.Resources.provisional); DivisionLabel.Text = "UNRANKED"; } DivisionImage = new Bitmap(DivisionImage, new Size(150, 150)); DivisionPictureBox.Image = DivisionImage; #endregion //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// #region PageNavigation basicPage.Hide(); SummonerInfoPanel.Show(); SummonerInfoPanel.BringToFront(); LoadCircle.Visible = false; //PAGE NAVIGATION TypeLabel.Text = "Ranked Statistics"; TypeLabel.Visible = true; #endregion } catch (WebException ex) { if (ex.Status == WebExceptionStatus.ProtocolError) { var response = (HttpWebResponse)ex.Response; if (response.StatusCode == HttpStatusCode.NotFound) { MessageLabel.Visible = true; MessageLabel.Text = "Summoner does not exist!"; emptyTextBoxControlTimer.Enabled = true; LoadCircle.Visible = false; } } } } }
public void SearchMatch() { string SummonerName = ""; string Region = ""; int MenuListCount = 0; TextBoxSummonerName.Invoke(new MethodInvoker(delegate { SummonerName = TextBoxSummonerName.Text; })); regionsComboBox.Invoke(new MethodInvoker(delegate { Region = regionsComboBox.Text; })); VersionClass ver = GetVersion.ReturnVersion(Region, apiKey); version = ver.n.champion; this.Invoke((MethodInvoker) delegate { MenuListCount = MenuControls.Count; }); try { for (int a = 0; a < MenuListCount; a++) { SetControlPropertyThreadSafe(MenuControls[a], "Enabled", false); } SummonerInfo summonerInfo = GetSummoner.ReturnSummoner(SummonerName, Region, apiKey); MatchInfo = MatchSearch.GetMatch(Region, summonerInfo.id, apiKey); string[] Keys = MatchSearch.GetKeys(JSON, MatchInfo); string[] Names = MatchSearch.GetName(JSON, MatchInfo); SetControlPropertyThreadSafe(Summoner1, "Text", MatchInfo.participants[0].summonerName); SetControlPropertyThreadSafe(Summoner2, "Text", MatchInfo.participants[1].summonerName); SetControlPropertyThreadSafe(Summoner3, "Text", MatchInfo.participants[2].summonerName); SetControlPropertyThreadSafe(Summoner4, "Text", MatchInfo.participants[3].summonerName); SetControlPropertyThreadSafe(Summoner5, "Text", MatchInfo.participants[4].summonerName); SetControlPropertyThreadSafe(Summoner6, "Text", MatchInfo.participants[5].summonerName); SetControlPropertyThreadSafe(Summoner7, "Text", MatchInfo.participants[6].summonerName); SetControlPropertyThreadSafe(Summoner8, "Text", MatchInfo.participants[7].summonerName); SetControlPropertyThreadSafe(Summoner9, "Text", MatchInfo.participants[8].summonerName); SetControlPropertyThreadSafe(Summoner10, "Text", MatchInfo.participants[9].summonerName); PictureBox[] pb = new PictureBox[10] { TeamMatePictureBox0, TeamMatePictureBox1, TeamMatePictureBox2, TeamMatePictureBox3, TeamMatePictureBox4, TeamMatePictureBox5, TeamMatePictureBox6, TeamMatePictureBox7, TeamMatePictureBox8, TeamMatePictureBox9 }; for (int i = 0; i < 10; i++) { pb[i].Load("http://ddragon.leagueoflegends.com/cdn/" + version + "/img/champion/" + Keys[i] + ".png"); this.Invoke((MethodInvoker) delegate { LoLToolTip.SetToolTip(pb[i], Names[i]); }); } if (MatchInfo.gameQueueConfigId == 4 || MatchInfo.gameQueueConfigId == 6 || MatchInfo.gameQueueConfigId == 9 || MatchInfo.gameQueueConfigId == 41 || MatchInfo.gameQueueConfigId == 42) { PictureBox[] pbBans = new PictureBox[6] { banPB1, banPB2, banPB3, banPB4, banPB5, banPB6 }; for (int i = 10; i < Keys.Length; i++) { pbBans[i - 10].Load("http://ddragon.leagueoflegends.com/cdn/" + version + "/img/champion/" + Keys[i] + ".png"); this.Invoke((MethodInvoker) delegate { LoLToolTip.SetToolTip(pbBans[i - 10], Names[i]); }); } } PictureBox[] summonerSpell_1 = new PictureBox[10] { Summoner1Spell1, Summoner2Spell1, Summoner3Spell1, Summoner4Spell1, Summoner5Spell1, Summoner6Spell1, Summoner7Spell1, Summoner8Spell1, Summoner9Spell1, Summoner10Spell1 }; PictureBox[] summonerSpell_2 = new PictureBox[10] { Summoner1Spell2, Summoner2Spell2, Summoner3Spell2, Summoner4Spell2, Summoner5Spell2, Summoner6Spell2, Summoner7Spell2, Summoner8Spell2, Summoner9Spell2, Summoner10Spell2 }; List <Spells> summonerSpell = SummonerSpells.GetSpells(Region, apiKey); int x = 0; string[] SummID = new string[10]; foreach (Participant part in MatchInfo.participants) { SummID[x] = part.summonerId.ToString(); foreach (var item in summonerSpell) { if (item.Id == part.spell1Id) { summonerSpell_1[x].Load("http://ddragon.leagueoflegends.com/cdn/" + version + "/img/spell/" + item.Key + ".png"); this.Invoke((MethodInvoker) delegate { LoLToolTip.SetToolTip(summonerSpell_1[x], item.Name); }); } if (item.Id == part.spell2Id) { summonerSpell_2[x].Load("http://ddragon.leagueoflegends.com/cdn/" + version + "/img/spell/" + item.Key + ".png"); this.Invoke((MethodInvoker) delegate { LoLToolTip.SetToolTip(summonerSpell_2[x], item.Name); }); } } x++; } PictureBox[] DivisionsPB = new PictureBox[10] { divPb1, divPB2, divPB3, divPB4, divPB5, divPB6, divPB7, divPB8, divPB9, divPB10 }; Label[] divLabels = new Label[10] { DivString1, DivString2, DivString3, DivString4, DivString5, DivString6, DivString7, DivString8, DivString9, DivString10 }; ReturnDivision divisionsImages = ReturnDivisionInfo.GetDivisions(Region, apiKey, SummID); for (int i = 0; i < divisionsImages.divList.Count(); i++) { SetControlPropertyThreadSafe(divLabels[i], "Text", divisionsImages.divList[i].Division); SetControlPropertyThreadSafe(DivisionsPB[i], "Image", divisionsImages.image[i]); this.Invoke((MethodInvoker) delegate { LoLToolTip.SetToolTip((Control)DivisionsPB[i], divisionsImages.divList[i].Name); }); } //-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------// SetControlPropertyThreadSafe(LoadCircle, "Visible", false); for (int a = 0; a < MenuListCount; a++) { SetControlPropertyThreadSafe(MenuControls[a], "Enabled", true); } this.Invoke((MethodInvoker) delegate { basicPage.Hide(); FIVEvsFIVEpanel.Show(); FIVEvsFIVEpanel.BringToFront(); }); } catch (WebException ex) { MessageBox.Show(ex.ToString()); if (ex.Status == WebExceptionStatus.ProtocolError) { var response = (HttpWebResponse)ex.Response; if (response.StatusCode == HttpStatusCode.NotFound) { SetControlPropertyThreadSafe(MessageLabel, "Visible", true); SetControlPropertyThreadSafe(MessageLabel, "Text", "The summoner " + SummonerName + " is not currently in a game!"); this.Invoke((MethodInvoker) delegate { emptyTextBoxControlTimer.Enabled = true; }); SetControlPropertyThreadSafe(LoadCircle, "Visible", false); for (int a = 0; a < MenuListCount; a++) { SetControlPropertyThreadSafe(MenuControls[a], "Enabled", true); } } } for (int a = 0; a < MenuListCount; a++) { SetControlPropertyThreadSafe(MenuControls[a], "Enabled", true); } SetControlPropertyThreadSafe(LoadCircle, "Visible", false); } }
/* * This processes the raw images given by parseLoadingScreen() */ SummonerInfo getSummonerInfo(Bitmap screenImage, int left, int top, double scale, int champNumber) { try { SummonerInfo si = new SummonerInfo(); Bitmap champImg, sSpell1, sSpell2, temp; double minRMS1 = double.MaxValue; double minRMS2 = double.MaxValue; //Rounding seems to be slightly off when processing the 5th summoner so I'm trying Ceiling/Floor rounding instead //Rect spell1Rect = new Rectangle(left + (int)Math.Round(72 * scale), top + (int)Math.Round(298 * scale), (int)Math.Round(23 * scale), (int)Math.Round(24 * scale)); Rect spell1Rect = new Rectangle(left + (int)Math.Floor(72 * scale), top + (int)Math.Ceiling(298 * scale), (int)Math.Round(23 * scale), (int)Math.Round(24 * scale)); //check the color on sSpell1 if it is black summoner is not connected if (spell1Rect.Right >= screenImage.Width || spell1Rect.Bottom >= screenImage.Height) return null; int blackCount = 0; for (int y = spell1Rect.Y; y <= spell1Rect.Y + spell1Rect.Height; y++) { for (int x = spell1Rect.X; x <= spell1Rect.X + spell1Rect.Width; x++) { var c = screenImage.GetPixel(x, y); if (c.R < 20 && c.G < 20 && c.B < 20) blackCount++; } } //form.scriptControl.log("Black Count: " + blackCount); if (blackCount >= ((spell1Rect.Width * spell1Rect.Height) * 0.7)) return null; try { champImg = screenImage.Clone(new Rectangle(left, top, (int)Math.Round(185 * scale), (int)Math.Round(305 * scale)), System.Drawing.Imaging.PixelFormat.DontCare); sSpell1 = screenImage.Clone(spell1Rect, System.Drawing.Imaging.PixelFormat.DontCare); //Rounding seems to be slightly off when processing the 5th summoner so I'm trying Ceiling/Floor rounding instead //sSpell2 = screenImage.Clone(new Rectangle(left + (int)Math.Round(99 * scale), top + (int)Math.Round(298 * scale), (int)Math.Round(23 * scale), (int)Math.Round(24 * scale)), System.Drawing.Imaging.PixelFormat.DontCare); sSpell2 = screenImage.Clone(new Rectangle(left + (int)Math.Floor(99 * scale), top + (int)Math.Ceiling(298 * scale), (int)Math.Round(23 * scale), (int)Math.Round(24 * scale)), System.Drawing.Imaging.PixelFormat.DontCare); champImg.Save("./LoadScreen/champ" + champNumber + ".bmp", System.Drawing.Imaging.ImageFormat.Bmp); sSpell1.Save("./LoadScreen/champ" + champNumber + "Spell1.bmp", System.Drawing.Imaging.ImageFormat.Bmp); sSpell2.Save("./LoadScreen/champ" + champNumber + "Spell2.bmp", System.Drawing.Imaging.ImageFormat.Bmp); } catch { return null; } temp = sSpell1; sSpell1 = new Bitmap(sSpell1, 64, 64); temp.Dispose(); temp = sSpell2; sSpell2 = new Bitmap(sSpell2, 64, 64); temp.Dispose(); foreach (KeyValuePair<string, SummonerSpellInfo> kvp in summonerSpellInfo) { temp = kvp.Value.image; double rms = calcRMSDiff(sSpell1, temp); if (rms < minRMS1) { si.summonerSpell1 = kvp.Key; minRMS1 = rms; } rms = calcRMSDiff(sSpell2, temp); if (rms < minRMS2) { si.summonerSpell2 = kvp.Key; minRMS2 = rms; } } //Added this because somehow they can end up being null (no keys in summonerSpellInfo??) if (si.summonerSpell1 == null || si.summonerSpell2 == null) { sSpell1.Dispose(); sSpell2.Dispose(); champImg.Dispose(); return null; } System.Diagnostics.Debug.WriteLine("S1 = " + si.summonerSpell1 + " minrms of" + minRMS1); System.Diagnostics.Debug.WriteLine("S2 = " + si.summonerSpell2); double minChampionRMS = double.MaxValue; temp = champImg; champImg = new Bitmap(champImg, 307, 557); temp.Dispose(); Rectangle compareRect = new Rectangle(0, 0, 307, 100); foreach (ChampNameAndImage champ in champData) { temp = champ.image; double rms = calcRMSDiff(champImg, temp, compareRect); if (rms < minChampionRMS) { si.championCodeName = champ.codeName; minChampionRMS = rms; //form.scriptControl.log(champ.codeName + " Has a lower RMS = " + rms); } } System.Diagnostics.Debug.WriteLine("champion is " + si.championCodeName); sSpell1.Dispose(); sSpell2.Dispose(); champImg.Dispose(); return si; } catch (Exception e) { sc.log("[ERROR] (" + e.Source + "): " + e.Message + "\n" + e.StackTrace); throw; } }
/* * This scans the loading screen image untill it finds a pixel which is not black. Then it * starts from the middle of the image (that is, the middle height wise) and works upwards until it finds * a black pixel, denoting a safe bottom point of the champion image. * * Then, starting from the safe bottom point, it starts upwards again untill it finds a pixel that is non-black * and notes the location of the pixel in the y frame. * * It then captures that area with a rectangle using the start point and the known bottom point. */ public void parseLoadingScreen() { try { Image b = form.windowImage; loadScreenInfo = new LoadScreenInfo(); LoadScreenInfo lsi = loadScreenInfo; lsi.minX = b.Width - 1; lsi.maxX = 0; lsi.minXBot = b.Width - 1; lsi.maxXBot = 0; bool foundNonBlack = false; for (int x = 5; x < b.Width - 5; x++) { var c = ((Bitmap)b).GetPixel(x, b.Height / 4); if (c.B != 0 || c.R != 0 || c.G != 0) { if (x < lsi.minX) lsi.minX = x; if (x > lsi.maxX) lsi.maxX = x; foundNonBlack = true; } c = ((Bitmap)b).GetPixel(x, 3 * b.Height / 4); if (c.B != 0 || c.R != 0 || c.G != 0) { if (x < lsi.minXBot) lsi.minXBot = x; if (x > lsi.maxXBot) lsi.maxXBot = x; } } if (lsi.minX >= lsi.maxX || lsi.minXBot >= lsi.maxXBot || !foundNonBlack) { loadScreenInfo = null; return; } //find a safe bottom point int bot = b.Height / 2; for (int y = b.Height / 2; y >= 0; y--) { var c = ((Bitmap)b).GetPixel(lsi.minX + 20, y); if (c.B == 0 && c.R == 0 && c.G == 0) { bot = y; break; } } //get the champion heights lsi.minY = b.Height - 1; lsi.maxY = 0; for (int y = 5; y < bot; y++) { var c = ((Bitmap)b).GetPixel(lsi.minX + 20, y); if (c.B != 0 || c.R != 0 || c.G != 0) { if (y < lsi.minY) lsi.minY = y; if (y > lsi.maxY) lsi.maxY = y; } } if (lsi.minY >= lsi.maxY) { loadScreenInfo = null; return; } lsi.scale = (lsi.maxY - lsi.minY) / 341.0; lsi.topChampionCount = (int)((lsi.maxX - lsi.minX) / (185 * lsi.scale - 5)); lsi.botChampionCount = (int)((lsi.maxXBot - lsi.minXBot) / (185 * lsi.scale - 5)); if (lsi.topChampionCount <= 0 || lsi.botChampionCount <= 0) { loadScreenInfo = null; return; } lsi.championWidth = (int)Math.Round(190 * lsi.scale); lsi.championHeight = (int)Math.Round(341 * lsi.scale); lsi.xpadding = (int)Math.Round(10 * lsi.scale); lsi.topPadding = lsi.minY; //System.Diagnostics.Debug.WriteLine("Top champions:" + lsi.topChampionCount); //System.Diagnostics.Debug.WriteLine("Bottom champions:" + lsi.botChampionCount); summonerInfo[0] = new SummonerInfo[lsi.topChampionCount]; summonerInfo[1] = new SummonerInfo[lsi.botChampionCount]; form.scriptControl.log("LoadScreen: " + lsi.topChampionCount + " (top) " + lsi.topChampionCount + " (bot)"); } catch (Exception e) { sc.log("[ERROR] (" + e.Source + "): " + e.Message + "\n" + e.StackTrace); throw; } }
public SummonerInfo GetInfo(string SummonerName, Region region) { SummonerInfo summonerInfo = new SummonerInfo("Unknown"); string summonername; var api = RiotApi.GetDevelopmentInstance(apiKey); summonername = SummonerName; try { //General info about account var summoner = api.Summoner.GetSummonerByNameAsync(region, summonername).Result; summonerInfo.name = summoner.Name; summonerInfo.region = summoner.Region.ToString(); summonerInfo.level = summoner.Level.ToString(); var accountid = summoner.AccountId; Console.WriteLine("Name:" + summonerInfo.name); Console.WriteLine("Region:" + summonerInfo.region); Console.WriteLine("Level:" + summonerInfo.level); try { List <LeagueEntry> rank = api.League.GetLeagueEntriesBySummonerAsync(summoner.Region, summoner.Id).Result; if (rank[0].QueueType == "RANKED_SOLO_5x5") { try { //Getting players ranks Console.WriteLine("Rank solo:" + rank[0].Tier + " " + rank[0].Rank); summonerInfo.soloRank = rank[0].Tier + " " + rank[0].Rank; Console.WriteLine("Rank flex:" + rank[1].Tier + " " + rank[1].Rank); summonerInfo.flexRank = rank[1].Tier + " " + rank[1].Rank; } catch { Console.WriteLine("\nProblems with solorank\n"); } try { //Getting players winrates float sWinrate = (float)rank[0].Wins / ((float)rank[0].Wins + (float)rank[0].Losses); sWinrate *= 100; Console.WriteLine("Solo ranked winrate:" + Math.Round(sWinrate, 1) + "%"); summonerInfo.soloWinrate = Math.Round(sWinrate, 1).ToString(); float fWinrate = (float)rank[1].Wins / ((float)rank[1].Wins + (float)rank[1].Losses); fWinrate *= 100; Console.WriteLine("Flex ranked winrate:" + Math.Round(fWinrate, 1) + "%"); summonerInfo.flexWinrate = Math.Round(fWinrate, 1).ToString(); } catch { Console.WriteLine("\nProblems with winrates\n"); } } else { try { //Getting players ranks Console.WriteLine("Rank flex:" + rank[0].Tier + " " + rank[0].Rank); summonerInfo.flexRank = rank[0].Tier + " " + rank[0].Rank; Console.WriteLine("Rank solo:" + rank[1].Tier + " " + rank[1].Rank); summonerInfo.soloRank = rank[1].Tier + " " + rank[1].Rank; } catch { Console.WriteLine("\nProblems with solorank\n"); } try { //Getting players winrates float fWinrate = (float)rank[0].Wins / ((float)rank[0].Wins + (float)rank[0].Losses); fWinrate *= 100; Console.WriteLine("Flex ranked winrate:" + Math.Round(fWinrate, 1) + "%"); summonerInfo.flexWinrate = Math.Round(fWinrate, 1).ToString(); float sWinrate = (float)rank[1].Wins / ((float)rank[1].Wins + (float)rank[1].Losses); sWinrate *= 100; Console.WriteLine("Solo ranked winrate:" + Math.Round(sWinrate, 1) + "%"); summonerInfo.soloWinrate = Math.Round(sWinrate, 1).ToString(); } catch { Console.WriteLine("\nProblems with winrates\n"); } } } catch { Console.WriteLine("\nProblems with rank\n"); return(summonerInfo); } return(summonerInfo); } catch { Console.WriteLine("\nPlayer not found (or smth else)\n"); return(summonerInfo); } }
public Bot() { BotUser = new DiscordClient(x => { x.LogLevel = LogSeverity.Info; }); BotUser.Log.Message += (s, e) => Console.WriteLine($"[{e.Severity}] {e.Source}: {e.Message}"); BotUser.UsingCommands(x => { x.PrefixChar = '-'; x.AllowMentionPrefix = true; }); commands = BotUser.GetService <CommandService>(); RoleManagementCommands rmc = new RoleManagementCommands(BotUser, commands); AccountManagementCommands amc = new AccountManagementCommands(BotUser, commands); RoleManagementTrigger roleManagementTrigger = new RoleManagementTrigger(BotUser, commands); RegionCommands regionCommands = new RegionCommands(BotUser, commands); RoleCommand roleCommand = new RoleCommand(BotUser, commands); ManagementTools managementTools = new ManagementTools(BotUser, commands); ServerInfoCommands serverInfoCommands = new ServerInfoCommands(BotUser, commands); MasteryCommands masteryCommands = new MasteryCommands(BotUser, commands); ServerManagement serverManagement = new ServerManagement(BotUser, commands); RankCommands rankCommands = new RankCommands(BotUser, commands); SummonerInfo summonerInfo = new SummonerInfo(commands); BotManagement botManagement = new BotManagement(commands, BotUser); Interaction inter = new Interaction(BotUser, commands); CreateRoles createRoles = new CreateRoles(commands); Matchmaking_Settings matchmakingSettings = new Matchmaking_Settings(commands); CoachCommands coachCommands = new CoachCommands(commands); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); MatchmakingTrigger trigger = new MatchmakingTrigger(BotUser, commands); MatchmakingCommands matchmakingCommands = new MatchmakingCommands(commands, BotUser, trigger); new HelpCommand(BotUser, commands); Task.Run(() => trigger.TimedClear(stopwatch)); matchmakingCommands.CreateCommands(); matchmakingSettings.ChannelSettings(); coachCommands.CreateCommands(); createRoles.CreateRank(); summonerInfo.SelfInfo(); summonerInfo.OtherInfo(); serverManagement.ServerAdded(); serverManagement.VerifyServer(); serverInfoCommands.InviteLink(); amc.ClaimAccount(); amc.Claim(); rankCommands.GetRank(); new Universal_Role(BotUser, commands).UniversalRole(); regionCommands.GetRegion(); roleCommand.GetRole(); rmc.Update(); rmc.GetRoles(); managementTools.ChangeType(); managementTools.ChangeCommandAllowed(); managementTools.OverrideSystem(); serverInfoCommands.ServerInfo(); serverInfoCommands.Description(); serverManagement.CheckForNewServer(); managementTools.Admin(); roleCommand.GetRoleParameter(); Legal(); roleManagementTrigger.JoiningRoleGive(); masteryCommands.GetMasteryPoints(); managementTools.AdminMastery(); Test(); BotUser.ExecuteAndWait(async() => { await BotUser.Connect(global::Keys.Keys.discordKey, TokenType.Bot); }); }