public void setEndOfGameStats(byte[] content) { if (content == null) { this.hasResult = false; return; } this.endOfGameStatsBytes = content; this.gameStats = new EndOfGameStats(this.endOfGameStatsBytes); if (!this.gameStats.DecodeData()) { this.hasResult = false; return; } if (this.gameStats.Players != null && this.gameStats.Players.Count > 0) { this.players = new PlayerInfo[this.gameStats.Players.Count]; for (int i = 0; i < this.gameStats.Players.Count; i++) { this.players[i] = new PlayerInfo(); this.players[i].championName = this.gameStats.Players[i].SkinName; this.players[i].playerName = this.gameStats.Players[i].SummonerName; this.players[i].team = this.gameStats.Players[i].TeamId; this.players[i].clientID = i; } } this.hasResult = true; }
public StatsEntry(EndOfGameStats game, PlayerStatsSummary stats) { GameMode = game.GameMode; GameType = game.GameType; Summary = stats; TimeStamp = game.TimeStamp; }
private bool OnEndOfGameStats(EndOfGameStats stats) { this.state.IpEarned = stats.IpEarned; this.state.IpTotal = session.Me.IP; this.state.IpLifetime = stats.IpTotal; this.state.Chatroom = rooms.JoinPostGame(stats); OnStateChanged(); return(true); }
public EndOfGamePage(EndOfGameStats stats) { InitializeComponent(); chatRoom = StaticVars.ActiveClient.XmppClient.MessageManager.JoinRoom(stats.RoomName + "@sec.pvp.net", stats.RoomPassword); StaticVars.ActiveClient.XmppClient.OnMessageRecieved += OnMessage; Dispatcher.BeginInvoke(DispatcherPriority.Render, (Action)(() => { RenderStats(stats); })); }
public void LoadGame(EndOfGameStats eog, GameMetaData meta, BasicInfo pi, bool bluewin) { EOG = eog; META = meta; PI = pi; BWINS = bluewin; gameInfoControl1.LoadGame(eog, meta, pi, bluewin); LoadStats(); LoadCharts(pi.SummonerName); MethodInvoker mi = new MethodInvoker(LoadEvents); mi.BeginInvoke(null, null); }
public async Task <EndOfGameStats> GetTeamEndOfGameStats(TeamId arg0, Double arg1) { int Id = Invoke("playerStatsService", "getTeamEndOfGameStats", new object[] { arg0.GetBaseTypedObject(), arg1 }); while (!results.ContainsKey(Id)) { await Task.Delay(10); } TypedObject messageBody = results[Id].GetTO("data").GetTO("body"); EndOfGameStats result = new EndOfGameStats(messageBody); results.Remove(Id); return(result); }
public void CommitGame(EndOfGameStats game) { Stopwatch sw; lock (DatabaseLock) { sw = Stopwatch.StartNew(); RecordGame(game); Database.Commit(); } sw.Stop(); StaticLogger.Debug(string.Format("EndOfGameStats committed in {0}ms", sw.ElapsedMilliseconds)); }
private async void WaitForStats(EndOfGameStats stats) { while (true) { try { var details = await session.MatchHistoryService.GetMatchDetails(stats.ReportGameId); Debug.WriteLine("Fetched stats: " + details.GameMode); OnNewMatch(details); return; } catch (WebException) { await Task.Delay(1000); } } }
public EndOfGamePage(EndOfGameStats Statistics) { InitializeComponent(); RenderStats(Statistics); Client.SwitchPage(new MainPage()); Client.runonce = false; string ObfuscatedName = Client.GetObfuscatedChatroomName(Statistics.RoomName, ChatPrefixes.Post_Game); string JID = Client.GetChatroomJID(Statistics.RoomName, Statistics.RoomPassword, false); newRoom = Client.ConfManager.GetRoom(new jabber.JID(JID)); newRoom.Nickname = Client.LoginPacket.AllSummonerData.Summoner.Name; newRoom.OnRoomMessage += newRoom_OnRoomMessage; newRoom.OnParticipantJoin += newRoom_OnParticipantJoin; newRoom.Join(Statistics.RoomPassword); }
public Guid JoinPostGame(EndOfGameStats stats) { string id; if (string.IsNullOrEmpty(stats.RoomName)) { id = "endGame" + (stats.ReportGameId > 0 ? stats.ReportGameId : stats.GameId); } else { id = stats.RoomName; } var jid = ChatUtils.GetChatroomJID(id, "pg", "post-game"); return(JoinRoom(jid, stats.RoomPassword)); }
public EndOfGamePage(EndOfGameStats statistics) { InitializeComponent(); RenderStats(statistics); Client.SwitchPage(Client.MainPage); Client.runonce = false; Client.ChampId = -1; RoomJid = Client.GetChatroomJid(statistics.RoomName, statistics.RoomPassword, false); newRoom = new MucManager(Client.XmppConnection); Client.XmppConnection.OnMessage += XmppConnection_OnMessage; Client.XmppConnection.OnPresence += XmppConnection_OnPresence; Client.RiotConnection.MessageReceived += RiotConnection_MessageReceived; newRoom.AcceptDefaultConfiguration(new Jid(RoomJid)); newRoom.JoinRoom(new Jid(RoomJid), Client.LoginPacket.AllSummonerData.Summoner.Name); }
public EndOfGamePage(EndOfGameStats statistics) { InitializeComponent(); RenderStats(statistics); uiLogic.UpdateMainPage(); Client.runonce = false; //string obfuscatedName = Client.GetObfuscatedChatroomName(statistics.RoomName, ChatPrefixes.Post_Game); string jid = Client.GetChatroomJID(statistics.RoomName, statistics.RoomPassword, false); _newRoom = Client.ConfManager.GetRoom(new JID(jid)); _newRoom.Nickname = Client.LoginPacket.AllSummonerData.Summoner.Name; _newRoom.OnRoomMessage += newRoom_OnRoomMessage; _newRoom.OnParticipantJoin += newRoom_OnParticipantJoin; _newRoom.Join(statistics.RoomPassword); }
void item_MouseDown(object sender, MouseButtonEventArgs e) { ReplayItem item = (ReplayItem)sender; EndOfGameStats stats = (EndOfGameStats)item.Tag; selectedStats = stats; ReplayOverviewGrid.Visibility = Visibility.Visible; var fadeGridInAnimation = new DoubleAnimation(1, TimeSpan.FromSeconds(0.1)); ReplayOverviewGrid.BeginAnimation(Grid.OpacityProperty, fadeGridInAnimation); GameId.Content = stats.Difficulty; GameType.Content = stats.GameMode.ToLower(); double seconds = stats.GameLength % 60; double minutes = stats.GameLength / 60; GameTime.Content = string.Format("{0:0}:{1:00}", minutes, seconds); TeamOnePanel.Children.Clear(); TeamTwoPanel.Children.Clear(); foreach (PlayerParticipantStatsSummary summary in stats.TeamPlayerParticipantStats) { PlayerItemReplay player = new PlayerItemReplay(); player.PlayerNameLabel.Content = summary.SummonerName; Uri UriSource = new Uri("/LegendaryReplays;component/champion/" + summary.SkinName + ".png", UriKind.RelativeOrAbsolute); player.ChampionIcon.ChampionImage.Source = new BitmapImage(UriSource); TeamOnePanel.Children.Add(player); } foreach (PlayerParticipantStatsSummary summary in stats.OtherTeamPlayerParticipantStats) { PlayerItemReplay player = new PlayerItemReplay(); player.PlayerNameLabel.Content = summary.SummonerName; Uri UriSource = new Uri("/LegendaryReplays;component/champion/" + summary.SkinName + ".png", UriKind.RelativeOrAbsolute); player.ChampionIcon.ChampionImage.Source = new BitmapImage(UriSource); TeamTwoPanel.Children.Add(player); } }
public EndOfGameStats RecordGame(EndOfGameStats game) { if (game == null) { throw new ArgumentNullException("game"); } var match = Database.Query <EndOfGameStats>().FirstOrDefault(m => m.GameId == game.GameId); if (match != null) { //If the object read is older then don't bother adding it. //However it may have new player information so don't return. if (game.TimeStamp > match.TimeStamp) { Database.Delete(match); Database.Store(game.CloneT()); } } else { Database.Store(game.CloneT()); } //No reason to record players here? //We should have gotten them all in the GameDTO //var statslist = game.TeamPlayerStats.Union(game.OtherTeamPlayerStats).ToList(); //for (int i = 0; i < statslist.Count; i++) //{ // var entry = GetPlayer(statslist[i].UserId); // if (entry == null) // { // entry = new PlayerEntry(statslist[i]); // RecordPlayer(entry, false); // } //} return(match); }
private async void handleGameEnder(object sender, object message) { EndOfGameStats eog = new EndOfGameStats(); connection_OnMessageReceived(sender, eog); exeProcess.Exited -= exeProcess_Exited; exeProcess.Kill(); Thread.Sleep(500); if (exeProcess.Responding && !m_disposed) { Process.Start("taskkill /F /IM \"League of Legends.exe\""); } loginPacket = await this.connection.GetLoginDataPacketForUser(); var oldLevel = currentLevel; currentLevel = loginPacket.AllSummonerData.SummonerLevel.Level; if (oldLevel != currentLevel) { levelUp(); } smurf.updateTimer(15); }
public void LoadGame(EndOfGameStats eog, GameMetaData meta, BasicInfo pi, bool bluewin) { try { // RiotSharp.MatchEndpoint.MatchDetail m = Program.MainFormInstance.API.GetMatch(RiotTool.PlatformToRegion(meta.gameKey.platformId), (long)eog.GameId); TeamStats blueteam = new TeamStats(); TeamStats redteam = new TeamStats(); BluePanel.Controls.Clear(); RedPanel.Controls.Clear(); if (!bluewin) { metroLabel1.Text = "Red Team Wins"; metroLabel1.Style = MetroFramework.MetroColorStyle.Red; } if (meta.gameKey.platformId != "PBE1") { ginfo.Text = RiotTool.ToMapString((RiotSharp.MapType)pi.Map) + ", " + RiotTool.ToQueueString((QueueType)pi.Queue) + " - " + RiotTool.PlatformToRegion(meta.gameKey.platformId).ToString().ToUpper(); } else { ginfo.Text = eog.GameMode + ", " + eog.GameType.Replace("_", " ") + " - " + RiotTool.PlatformToRegion(meta.gameKey.platformId).ToString().ToUpper(); } if (eog != null) { foreach (PlayerParticipantStatsSummary p in eog.TeamPlayerParticipantStats) { Player2Ctrl p2 = new Player2Ctrl(p.TeamId == 200); p2.LoadPlayer(p, p.SummonerName, p.SkinName, ref blueteam); p2.Dock = DockStyle.Top; if (p.TeamId == 100) { BluePanel.Controls.Add(p2); } else { RedPanel.Controls.Add(p2); } } foreach (PlayerParticipantStatsSummary p in eog.OtherTeamPlayerParticipantStats) { Player2Ctrl p2 = new Player2Ctrl(p.TeamId == 200); p2.LoadPlayer(p, p.SummonerName, p.SkinName, ref redteam); p2.Dock = DockStyle.Top; if (p.TeamId == 100) { BluePanel.Controls.Add(p2); } else { RedPanel.Controls.Add(p2); } } } bluewk.Text = blueteam.WD.ToString(); bluewp.Text = blueteam.WP.ToString(); bluecreeps.Text = blueteam.CREEPS.ToString(); bluekda.Text = blueteam.Kill + " / " + blueteam.Deaths + " / " + blueteam.Assists; bluetd.Text = blueteam.TD.ToString(); redwk.Text = redteam.WD.ToString(); redwp.Text = redteam.WP.ToString(); redcreeps.Text = redteam.CREEPS.ToString(); redkda.Text = redteam.Kill + " / " + redteam.Deaths + " / " + redteam.Assists; redtd.Text = redteam.TD.ToString(); BluePanel.Controls.Add(panel5); RedPanel.Controls.Add(panel4); } catch (Exception ex) { Logger.Instance.Log.Error("Failed to load game", ex); } }
void StatsRead(EndOfGameStats game) { Task.Factory.StartNew(() => CommitGame(game), TaskCreationOptions.LongRunning); }
public async void connection_OnMessageReceived(object sender, object message) { if (message is GameDTO) { GameDTO game = message as GameDTO; switch (game.GameState) { case "CHAMP_SELECT": if (this.firstTimeInLobby) { firstTimeInLobby = false; updateStatus("In Champion Select", Accountname); object obj = await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT"); if (queueType != QueueTypes.ARAM) { if (Program.championId != "") { await connection.SelectChampion(Enums.championToId(Program.championId)); await connection.ChampionSelectCompleted(); } else { await connection.SelectChampion(availableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId); await connection.ChampionSelectCompleted(); int Spell1; int Spell2; if (!Program.rndSpell) { Spell1 = Enums.spellToId(Program.spell1); Spell2 = Enums.spellToId(Program.spell2); } else { var random = new Random(); var spellList = new List <int> { 13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4 }; int index = random.Next(spellList.Count); int index2 = random.Next(spellList.Count); int randomSpell1 = spellList[index]; int randomSpell2 = spellList[index2]; if (randomSpell1 == randomSpell2) { int index3 = random.Next(spellList.Count); randomSpell2 = spellList[index3]; } Spell1 = Convert.ToInt32(randomSpell1); Spell2 = Convert.ToInt32(randomSpell2); } await connection.SelectSpells(Spell1, Spell2); } } break; } else { break; } case "POST_CHAMP_SELECT": firstTimeInLobby = false; this.updateStatus("(Post Champ Select)", Accountname); break; case "PRE_CHAMP_SELECT": this.updateStatus("(Pre Champ Select)", Accountname); break; case "GAME_START_CLIENT": this.updateStatus("Game client ran", Accountname); break; case "GameClientConnectedToServer": this.updateStatus("Client connected to the server", Accountname); break; case "IN_QUEUE": this.updateStatus("In Queue", Accountname); break; case "TERMINATED": this.updateStatus("Re-entering queue", Accountname); this.firstTimeInQueuePop = true; break; case "JOINING_CHAMP_SELECT": if (this.firstTimeInQueuePop && game.StatusOfParticipants.Contains("1")) { this.updateStatus("Accepted Queue", Accountname); this.firstTimeInQueuePop = false; this.firstTimeInLobby = true; object obj = await this.connection.AcceptPoppedGame(true); break; } else { break; } } } else if (message is PlayerCredentialsDto) { string str = Enumerable.Last <string>((IEnumerable <string>)Enumerable.OrderBy <string, DateTime>(Directory.EnumerateDirectories((this.ipath ?? "") + "RADS\\solutions\\lol_game_client_sln\\releases\\"), (Func <string, DateTime>)(f => new DirectoryInfo(f).CreationTime))) + "\\deploy\\"; LoLLauncher.RiotObjects.Platform.Game.PlayerCredentialsDto credentials = message as PlayerCredentialsDto; System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.CreateNoWindow = false; startInfo.WorkingDirectory = str; startInfo.FileName = "League of Legends.exe"; startInfo.Arguments = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + credentials.ServerIp + " " + credentials.ServerPort + " " + credentials.EncryptionKey + " " + credentials.SummonerId + "\""; updateStatus("Launching League of Legends", Accountname); new Thread((ThreadStart)(() => { exeProcess = Process.Start(startInfo); exeProcess.Exited += exeProcess_Exited; while (exeProcess.MainWindowHandle == IntPtr.Zero) { ; } exeProcess.PriorityClass = ProcessPriorityClass.Idle; exeProcess.EnableRaisingEvents = true; })).Start(); } else if (!(message is GameNotification) && !(message is SearchingForMatchNotification)) { if (message is EndOfGameStats) { LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams matchParams = new LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams(); if (queueType == QueueTypes.INTRO_BOT) { matchParams.BotDifficulty = "INTRO"; } else if (queueType == QueueTypes.BEGINNER_BOT) { matchParams.BotDifficulty = "EASY"; } else if (queueType == QueueTypes.MEDIUM_BOT) { matchParams.BotDifficulty = "MEDIUM"; } if (sumLevel == 3 && actualQueueType == QueueTypes.NORMAL_5x5) { queueType = actualQueueType; } else if (sumLevel == 6 && actualQueueType == QueueTypes.ARAM) { queueType = actualQueueType; } else if (sumLevel == 7 && actualQueueType == QueueTypes.NORMAL_3x3) { queueType = actualQueueType; } matchParams.QueueIds = new Int32[1] { (int)queueType }; LoLLauncher.RiotObjects.Platform.Matchmaking.SearchingForMatchNotification m = await connection.AttachToQueue(matchParams); if (m.PlayerJoinFailures == null) { this.updateStatus("In Queue: " + queueType.ToString(), Accountname); } else { try { updateStatus("Couldn't enter Q - " + m.PlayerJoinFailures.Summoner.Name + " : " + m.PlayerJoinFailures.ReasonFailed, Accountname); } catch (Exception) { Console.WriteLine("Something went wrong, couldn't enter queue. Check accounts.txt for correct queue type."); connection.Disconnect(); } } } else { if (message.ToString().Contains("EndOfGameStats")) { EndOfGameStats eog = new EndOfGameStats(); connection_OnMessageReceived(sender, eog); exeProcess.Exited -= exeProcess_Exited; exeProcess.Kill(); loginPacket = await this.connection.GetLoginDataPacketForUser(); archiveSumLevel = sumLevel; sumLevel = loginPacket.AllSummonerData.SummonerLevel.Level; if (sumLevel != archiveSumLevel) { levelUp(); } } } } }
internal static void OnMessageReceived(object sender, MessageReceivedEventArgs message) { MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { if (message.Body is StoreAccountBalanceNotification) { StoreAccountBalanceNotification newBalance = (StoreAccountBalanceNotification)message.Body; InfoLabel.Content = "IP: " + newBalance.Ip + " ∙ RP: " + newBalance.Rp; LoginPacket.IpBalance = newBalance.Ip; LoginPacket.RpBalance = newBalance.Rp; } else if (message.Body is GameNotification) { GameNotification notification = (GameNotification)message.Body; MessageOverlay messageOver = new MessageOverlay(); messageOver.MessageTitle.Content = notification.Type; switch (notification.Type) { case "PLAYER_BANNED_FROM_GAME": messageOver.MessageTitle.Content = "Banned from custom game"; messageOver.MessageTextBox.Text = "You have been banned from this custom game!"; break; case "PLAYER_QUIT": string[] Name = await RiotCalls.GetSummonerNames(new double[1] { Convert.ToDouble((string)notification.MessageArgument) }); messageOver.MessageTitle.Content = "Player has left the queue"; messageOver.MessageTextBox.Text = Name[0] + " has left the queue"; break; default: messageOver.MessageTextBox.Text = notification.MessageCode + Environment.NewLine; messageOver.MessageTextBox.Text += Convert.ToString(notification.MessageArgument); break; } OverlayContainer.Content = messageOver.Content; OverlayContainer.Visibility = Visibility.Visible; QuitCurrentGame(); } else if (message.Body is EndOfGameStats) { EndOfGameStats stats = message.Body as EndOfGameStats; EndOfGamePage EndOfGame = new EndOfGamePage(stats); OverlayContainer.Visibility = Visibility.Visible; OverlayContainer.Content = EndOfGame.Content; } else if (message.Body is StoreFulfillmentNotification) { PlayerChampions = await RiotCalls.GetAvailableChampions(); } else if (message.Body is GameDTO) { GameDTO Queue = message.Body as GameDTO; if (!IsInGame && Queue.GameState != "TERMINATED" && Queue.GameState != "TERMINATED_IN_ERROR") { MainWin.Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { Client.OverlayContainer.Content = new QueuePopOverlay(Queue).Content; Client.OverlayContainer.Visibility = Visibility.Visible; })); } } else if (message.Body is SearchingForMatchNotification) { SearchingForMatchNotification Notification = message.Body as SearchingForMatchNotification; if (Notification.PlayerJoinFailures != null && Notification.PlayerJoinFailures.Count > 0) { MessageOverlay messageOver = new MessageOverlay(); messageOver.MessageTitle.Content = "Could not join the queue"; foreach (QueueDodger x in Notification.PlayerJoinFailures) { messageOver.MessageTextBox.Text += x.Summoner.Name + " is unable to join the queue as they recently dodged a game." + Environment.NewLine; TimeSpan time = TimeSpan.FromMilliseconds(x.PenaltyRemainingTime); messageOver.MessageTextBox.Text += "You have " + string.Format("{0:D2}m:{1:D2}s", time.Minutes, time.Seconds) + " remaining until you may queue again"; } OverlayContainer.Content = messageOver.Content; OverlayContainer.Visibility = Visibility.Visible; } } })); }
/// 26.) public void GetTeamEndOfGameStats(TeamId arg0, Double arg1, EndOfGameStats.Callback callback) { EndOfGameStats cb = new EndOfGameStats(callback); InvokeWithCallback("playerStatsService", "getTeamEndOfGameStats", new object[] { arg0.GetBaseTypedObject(), arg1 }, cb); }
public async void connection_OnMessageReceived(object sender, object message) { if (message is GameDTO) { GameDTO game = message as GameDTO; switch (game.GameState) { case "CHAMP_SELECT": firstTimeInCustom = true; firstTimeInQueuePop = true; if (firstTimeInLobby) { firstTimeInLobby = false; Tools.ConsoleMessage("You are in champion select.", ConsoleColor.White); object obj = await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT"); //select champion and spells for non ARAM games if (queueType != QueueTypes.ARAM) { int Spell1; int Spell2; if (!Program.randomSpell) { Spell1 = Enums.GetSpell(Program.spell1); Spell2 = Enums.GetSpell(Program.spell2); } else { var random = new Random(); var spellList = new List <int> { 13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4 }; int index = random.Next(spellList.Count); int index2 = random.Next(spellList.Count); int randomSpell1 = spellList[index]; int randomSpell2 = spellList[index2]; if (randomSpell1 == randomSpell2) { int index3 = random.Next(spellList.Count); randomSpell2 = spellList[index3]; } Spell1 = Convert.ToInt32(randomSpell1); Spell2 = Convert.ToInt32(randomSpell2); } await connection.SelectSpells(Spell1, Spell2); string championPick = ""; int championPickID = 0; int champRand = Generator.CreateRandom(1, 5); switch (champRand) { case 1: championPickID = Enums.GetChampion(Program.firstChampionPick); championPick = Program.firstChampionPick; break; case 2: championPickID = Enums.GetChampion(Program.secondChampionPick); championPick = Program.secondChampionPick; break; case 3: championPickID = Enums.GetChampion(Program.thirdChampionPick); championPick = Program.thirdChampionPick; break; case 4: championPickID = Enums.GetChampion(Program.fourthChampionPick); championPick = Program.fourthChampionPick; break; case 5: championPickID = Enums.GetChampion(Program.fifthChampionPick); championPick = Program.fifthChampionPick; break; } await connection.SelectChampion(championPickID); Tools.ConsoleMessage("Selected Champion: " + championPick.ToUpper(), ConsoleColor.DarkYellow); await connection.ChampionSelectCompleted(); } //select spells for ARAM if (queueType == QueueTypes.ARAM) { int Spell1; int Spell2; if (!Program.randomSpell) { Spell1 = Enums.GetSpell(Program.spell1); Spell2 = Enums.GetSpell(Program.spell2); } else { var random = new Random(); var spellList = new List <int> { 13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4 }; int index = random.Next(spellList.Count); int index2 = random.Next(spellList.Count); int randomSpell1 = spellList[index]; int randomSpell2 = spellList[index2]; if (randomSpell1 == randomSpell2) { int index3 = random.Next(spellList.Count); randomSpell2 = spellList[index3]; } Spell1 = Convert.ToInt32(randomSpell1); Spell2 = Convert.ToInt32(randomSpell2); } await connection.SelectSpells(Spell1, Spell2); await connection.ChampionSelectCompleted(); } break; } else { break; } case "POST_CHAMP_SELECT": firstTimeInLobby = false; if (firstTimeInPostChampSelect) { firstTimeInPostChampSelect = false; Tools.ConsoleMessage("Waiting for league of legends to respond.", ConsoleColor.White); } break; case "IN_QUEUE": Tools.ConsoleMessage("You are now in queue.", ConsoleColor.White); break; case "TERMINATED": //Tools.ConsoleMessage("Re-entering queue.", ConsoleColor.White); firstTimeInPostChampSelect = true; firstTimeInQueuePop = true; break; case "LEAVER_BUSTED": Tools.ConsoleMessage("You have leave buster.", ConsoleColor.White); break; case "JOINING_CHAMP_SELECT": if (firstTimeInQueuePop && game.StatusOfParticipants.Contains("1")) { Tools.ConsoleMessage("Match found and accepted.", ConsoleColor.White); firstTimeInQueuePop = false; firstTimeInLobby = true; object obj = await connection.AcceptPoppedGame(true); break; } else { break; } } } else if (message.GetType() == typeof(TradeContractDTO)) { var tradeDto = message as TradeContractDTO; if (tradeDto == null) { return; } switch (tradeDto.State) { case "PENDING": { if (tradeDto != null) { } } break; } return; } else if (message is PlayerCredentialsDto) { firstTimeInPostChampSelect = true; PlayerCredentialsDto dto = message as PlayerCredentialsDto; ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.CreateNoWindow = false; startInfo.WorkingDirectory = GetLeagueClient(); startInfo.FileName = "League of Legends.exe"; startInfo.Arguments = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + dto.ServerIp + " " + dto.ServerPort + " " + dto.EncryptionKey + " " + dto.SummonerId + "\""; new Thread(() => { exeProcess = Process.Start(startInfo); exeProcess.Exited += new EventHandler(exeProcess_Exited); while (exeProcess.MainWindowHandle == IntPtr.Zero) { } if (Program.LOWPriority) { exeProcess.PriorityClass = ProcessPriorityClass.Idle; } else { exeProcess.PriorityClass = ProcessPriorityClass.High; } exeProcess.EnableRaisingEvents = true; //Thread.Sleep(1000); }).Start(); Tools.ConsoleMessage("Launching League of Legends.", ConsoleColor.White); } else if (!(message is GameNotification) && !(message is SearchingForMatchNotification)) { if (message is EndOfGameStats) { EnterQueue(); } else { if (message.ToString().Contains("EndOfGameStats")) { try { if (exeProcess != null) { EndOfGameStats eog = new EndOfGameStats(); connection_OnMessageReceived(sender, eog); exeProcess.Exited -= exeProcess_Exited; exeProcess.Kill(); Thread.Sleep(500); if (exeProcess.Responding) { Process.Start("taskkill /F /IM \"League of Legends.exe\""); } loginPacket = await this.connection.GetLoginDataPacketForUser(); archiveSumLevel = sumLevel; sumLevel = loginPacket.AllSummonerData.SummonerLevel.Level; if (sumLevel != archiveSumLevel) { OnLevelUp(); } } } catch (Exception ex) { Tools.Log(ex.Message.ToString()); } } } } }
public async void connection_OnMessageReceived(object sender, object message) { if (message is GameDTO) { GameDTO game = message as GameDTO; switch (game.GameState) { case "CHAMP_SELECT": firstTimeInCustom = true; firstTimeInQueuePop = true; if (firstTimeInLobby) { firstTimeInLobby = false; updateStatus("In Champion Select", Accountname); await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT"); if (queueType != QueueTypes.ARAM) { if (Core.championId != "") { await connection.SelectChampion(Enums.championToId(Core.championId)); await connection.ChampionSelectCompleted(); } else { await connection.SelectChampion(availableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId); await connection.ChampionSelectCompleted(); } } break; } else { break; } case "POST_CHAMP_SELECT": firstTimeInLobby = false; updateStatus("(Post Champ Select)", Accountname); break; case "PRE_CHAMP_SELECT": updateStatus("(Pre Champ Select)", Accountname); break; case "GAME_START_CLIENT": updateStatus("Game client ran", Accountname); break; case "GameClientConnectedToServer": updateStatus("Client connected to the server", Accountname); break; case "IN_QUEUE": updateStatus("In Queue", Accountname); break; case "TERMINATED": updateStatus("Re-entering queue", Accountname); firstTimeInQueuePop = true; break; case "JOINING_CHAMP_SELECT": if (firstTimeInQueuePop) { updateStatus("Queue popped", Accountname); if (game.StatusOfParticipants.Contains("1")) { updateStatus("Accepted Queue", Accountname); firstTimeInQueuePop = false; firstTimeInLobby = true; await connection.AcceptPoppedGame(true); } } break; } } else if (message is PlayerCredentialsDto) { PlayerCredentialsDto dto = message as PlayerCredentialsDto; if (!HasLaunchedGame) { HasLaunchedGame = true; new Thread((ThreadStart)(() => { LaunchGame(dto); Thread.Sleep(3000); })).Start(); } } else if (!(message is GameNotification) && !(message is SearchingForMatchNotification)) { if (message is EndOfGameStats) { MatchMakerParams matchParams = new MatchMakerParams(); //Set BotParams if (queueType == QueueTypes.INTRO_BOT) { matchParams.BotDifficulty = "INTRO"; } else if (queueType == QueueTypes.BEGINNER_BOT) { matchParams.BotDifficulty = "EASY"; } else if (queueType == QueueTypes.MEDIUM_BOT) { matchParams.BotDifficulty = "MEDIUM"; } //Check if is available to join queue. if (sumLevel == 3 && actualQueueType == QueueTypes.NORMAL_5x5) { queueType = actualQueueType; } else if (sumLevel == 6 && actualQueueType == QueueTypes.ARAM) { queueType = actualQueueType; } else if (sumLevel == 7 && actualQueueType == QueueTypes.NORMAL_3x3) { queueType = actualQueueType; } matchParams.QueueIds = new Int32[1] { (int)queueType }; SearchingForMatchNotification m = await connection.AttachToQueue(matchParams); if (m.PlayerJoinFailures == null) { updateStatus("In Queue: " + queueType.ToString(), Accountname); } else { updateStatus("Couldn't enter Queue! Please contact us @ volibot.com", Accountname); } } else { if (message.ToString().Contains("EndOfGameStats")) { EndOfGameStats eog = new EndOfGameStats(); connection_OnMessageReceived(sender, eog); exeProcess.Kill(); loginPacket = await this.connection.GetLoginDataPacketForUser(); archiveSumLevel = sumLevel; sumLevel = loginPacket.AllSummonerData.SummonerLevel.Level; if (sumLevel != archiveSumLevel) { levelUp(); } } } } }
//TODO: Clean this up public void SimulateEndOfGame() { EndOfGameStats fakeStats = new EndOfGameStats(); fakeStats.TalentPointsGained = 0; fakeStats.Ranked = false; fakeStats.LeveledUp = false; fakeStats.SkinIndex = 6001; fakeStats.QueueBonusEarned = 14; fakeStats.GameType = "MATCHED_GAME"; fakeStats.ExperienceEarned = 0; fakeStats.ImbalancedTeamsNoPoints = false; fakeStats.BasePoints = 32; fakeStats.ReportGameId = 22036662; fakeStats.Difficulty = null; fakeStats.GameLength = 1411; fakeStats.BoostXpEarned = 0; fakeStats.Invalid = false; fakeStats.OtherTeamInfo = null; fakeStats.RoomName = "endGame22036662"; fakeStats.CustomMinutesLeftToday = 120; fakeStats.UserId = 200006292; fakeStats.CoOpVsAiMinutesLeftToday = 180; fakeStats.LoyaltyBoostIpEarned = 0; fakeStats.RpEarned = 0; fakeStats.CompletionBonusPoints = 0; fakeStats.CoOpVsAiMsecsUntilReset = 0; fakeStats.BoostIpEarned = 0; fakeStats.ExperienceTotal = 23; fakeStats.GameId = 125432223; fakeStats.TimeUntilNextFirstWinBonus = 0; fakeStats.LoyaltyBoostXpEarned = 0; fakeStats.RoomPassword = "******"; fakeStats.Elo = 0; fakeStats.IpEarned = 0; fakeStats.FirstWinBonus = 0; fakeStats.SendStatsToTournamentProvider = false; fakeStats.EloChange = 0; fakeStats.GameMode = "ARAM"; fakeStats.QueueType = "ARAM_UNRANKED_5x5"; fakeStats.OdinBonusIp = 0; fakeStats.IpTotal = 295513; fakeStats.CustomMsecsUntilReset = -1; fakeStats.TeamPlayerParticipantStats = new List <PlayerParticipantStatsSummary>(); fakeStats.OtherTeamPlayerParticipantStats = new List <PlayerParticipantStatsSummary>(); for (int i = 0; i < 10; i++) { PlayerParticipantStatsSummary fakePlayer = new PlayerParticipantStatsSummary(); fakePlayer.SkinName = "Urgot"; fakePlayer.GameId = 22035552; fakePlayer.ProfileIconId = 550; fakePlayer.Elo = 0; fakePlayer.Leaver = false; fakePlayer.Leaves = 3; fakePlayer.TeamId = 200; fakePlayer.EloChange = 0; fakePlayer.Level = 30; fakePlayer.BotPlayer = false; fakePlayer.UserId = 331458; fakePlayer.Spell2Id = 4; fakePlayer.Spell1Id = 21; fakePlayer.Losses = 59; fakePlayer.SummonerName = "Snowl"; fakePlayer.Wins = 64; fakePlayer.Statistics = new List <RawStatDTO>(); RawStatDTO Item0 = new RawStatDTO(); Item0.StatTypeName = "ITEM0"; Item0.Value = 3181; fakePlayer.Statistics.Add(Item0); RawStatDTO Item1 = new RawStatDTO(); Item1.StatTypeName = "ITEM1"; Item1.Value = 3046; fakePlayer.Statistics.Add(Item1); RawStatDTO Item2 = new RawStatDTO(); Item2.StatTypeName = "ITEM2"; Item2.Value = 3006; fakePlayer.Statistics.Add(Item2); RawStatDTO Item3 = new RawStatDTO(); Item3.StatTypeName = "ITEM3"; Item3.Value = 3031; fakePlayer.Statistics.Add(Item3); RawStatDTO Item4 = new RawStatDTO(); Item4.StatTypeName = "ITEM4"; Item4.Value = 1055; fakePlayer.Statistics.Add(Item4); RawStatDTO Item5 = new RawStatDTO(); Item5.StatTypeName = "ITEM5"; Item5.Value = 1036; fakePlayer.Statistics.Add(Item5); RawStatDTO Item6 = new RawStatDTO(); Item6.StatTypeName = "ITEM6"; Item6.Value = 0; fakePlayer.Statistics.Add(Item6); RawStatDTO GOLDEARNED = new RawStatDTO(); GOLDEARNED.StatTypeName = "GOLD_EARNED"; GOLDEARNED.Value = 11736; fakePlayer.Statistics.Add(GOLDEARNED); RawStatDTO Assists = new RawStatDTO(); Assists.StatTypeName = "ASSISTS"; Assists.Value = 23; RawStatDTO NUMDEATHS = new RawStatDTO(); NUMDEATHS.StatTypeName = "NUM_DEATHS"; NUMDEATHS.Value = 0; fakePlayer.Statistics.Add(NUMDEATHS); RawStatDTO LEVEL = new RawStatDTO(); LEVEL.StatTypeName = "LEVEL"; LEVEL.Value = 17; fakePlayer.Statistics.Add(LEVEL); RawStatDTO CHAMPIONSKILLED = new RawStatDTO(); CHAMPIONSKILLED.StatTypeName = "CHAMPIONS_KILLED"; CHAMPIONSKILLED.Value = 99; fakePlayer.Statistics.Add(CHAMPIONSKILLED); RawStatDTO MinionsKILLED = new RawStatDTO(); MinionsKILLED.StatTypeName = "MINIONS_KILLED"; MinionsKILLED.Value = 60; fakePlayer.Statistics.Add(MinionsKILLED); RawStatDTO WIN = new RawStatDTO(); WIN.StatTypeName = "WIN"; WIN.Value = 1; fakePlayer.Statistics.Add(WIN); if (i < 5) { fakeStats.OtherTeamPlayerParticipantStats.Add(fakePlayer); } else { fakeStats.TeamPlayerParticipantStats.Add(fakePlayer); } } MessageReceived(fakeStats); }
private void item_MouseDown(object sender, MouseButtonEventArgs e) { var item = (ReplayItem)sender; var stats = (EndOfGameStats)item.Tag; selectedStats = stats; ReplayOverviewGrid.Visibility = Visibility.Visible; var fadeGridInAnimation = new DoubleAnimation(1, TimeSpan.FromSeconds(0.1)); ReplayOverviewGrid.BeginAnimation(OpacityProperty, fadeGridInAnimation); GameId.Content = stats.Difficulty; GameType.Content = stats.GameMode.ToLower(); double seconds = stats.GameLength % 60; double minutes = stats.GameLength / 60; GameTime.Content = string.Format("{0:0}:{1:00}", minutes, seconds); TeamOnePanel.Children.Clear(); TeamTwoPanel.Children.Clear(); foreach (PlayerParticipantStatsSummary summary in stats.TeamPlayerParticipantStats) { double k = -1, d = -1, a = -1; var player = new PlayerItemReplay { PlayerNameLabel = { Content = summary.SummonerName } }; foreach (RawStatDTO stat in summary.Statistics) { if (stat.StatTypeName.StartsWith("ITEM") && stat.Value != 0) { switch (stat.StatTypeName) { case "ITEM1": player.gameItem1.ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png")); break; case "ITEM2": player.gameItem2.ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png")); break; case "ITEM3": player.gameItem3.ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png")); break; case "ITEM4": player.gameItem4.ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png")); break; case "ITEM5": player.gameItem5.ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png")); break; case "ITEM6": player.gameTrinket.ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png")); break; } } switch (stat.StatTypeName) { case "CHAMPIONS_KILLED": k = stat.Value; break; case "NUM_DEATHS": d = stat.Value; break; case "ASSISTS": a = stat.Value; break; } } foreach ( object element in player.getChildElements() .Where( element => element is SmallChampionItem && ((SmallChampionItem)element).Name.StartsWith("game"))) { ((SmallChampionItem)element).MouseMove += img_MouseMove; ((SmallChampionItem)element).MouseLeave += img_MouseLeave; } player.ChampionIcon.ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "champion", summary.SkinName + ".png")); player.File.Content = summary.SkinName; player.KDA.Content = k + "/" + d + "/" + a; TeamOnePanel.Children.Add(player); } foreach (PlayerParticipantStatsSummary summary in stats.OtherTeamPlayerParticipantStats) { double k = -1, d = -1, a = -1; var player = new PlayerItemReplay { PlayerNameLabel = { Content = summary.SummonerName } }; foreach (RawStatDTO stat in summary.Statistics) { if (stat.StatTypeName.StartsWith("ITEM") && stat.Value != 0) { switch (stat.StatTypeName) { case "ITEM1": player.gameItem1.ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png")); break; case "ITEM2": player.gameItem2.ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png")); break; case "ITEM3": player.gameItem3.ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png")); break; case "ITEM4": player.gameItem4.ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png")); break; case "ITEM5": player.gameItem5.ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png")); break; case "ITEM6": player.gameTrinket.ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png")); break; } } switch (stat.StatTypeName) { case "CHAMPIONS_KILLED": k = stat.Value; break; case "NUM_DEATHS": d = stat.Value; break; case "ASSISTS": a = stat.Value; break; } } foreach ( object element in player.getChildElements() .Where( element => element is SmallChampionItem && ((SmallChampionItem)element).Name.StartsWith("game"))) { ((SmallChampionItem)element).MouseMove += img_MouseMove; ((SmallChampionItem)element).MouseLeave += img_MouseLeave; } player.File.Content = summary.SkinName; player.ChampionIcon.ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "champion", summary.SkinName + ".png")); player.KDA.Content = k + "/" + d + "/" + a; TeamTwoPanel.Children.Add(player); } }
private async void connection_OnMessageReceived(object sender, object message) { if (message is GameDTO) { GameDTO game = message as GameDTO; Console.WriteLine("Message Type:" + game.GameState); switch (game.GameState) { case "START_REQUESTED": break; case "FAILED_TO_START": Console.WriteLine("Failed to Start!"); break; case "CHAMP_SELECT": firstTimeInCustom = true; firstTimeInQueuePop = true; if (firstTimeInLobby) { firstTimeInLobby = false; object obj = await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT"); if (QueueType != QueueTypes.ARAM) { int Spell1; int Spell2; var random = new Random(); var spellList = new List <int> { 13, 6, 7, 1, 11, 21, 12, 3, 14, 2, 4 }; int index = random.Next(spellList.Count); int index2 = random.Next(spellList.Count); int randomSpell1 = spellList[index]; int randomSpell2 = spellList[index2]; if (randomSpell1 == randomSpell2) { int index3 = random.Next(spellList.Count); randomSpell2 = spellList[index3]; } Spell1 = Convert.ToInt32(randomSpell1); Spell2 = Convert.ToInt32(randomSpell2); await connection.SelectSpells(Spell1, Spell2); var randAvailableChampsArray = myChampions.Shuffle(); await connection.SelectChampion(randAvailableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId); await connection.ChampionSelectCompleted(); } break; } else { break; } case "PRE_CHAMP_SELECT": updateStatus(msgStatus.INFO, "Champion selection in progress"); break; case "POST_CHAMP_SELECT": firstTimeInLobby = false; if (firstTimeInPostChampSelect) { firstTimeInPostChampSelect = false; updateStatus(msgStatus.INFO, "Champion selection is done, waiting for game to start"); break; } else { break; } case "IN_QUEUE": updateStatus(msgStatus.INFO, "In Queue"); break; case "TERMINATED": updateStatus(msgStatus.INFO, "Re-entering queue"); firstTimeInPostChampSelect = true; firstTimeInQueuePop = true; break; case "JOINING_CHAMP_SELECT": if (firstTimeInQueuePop && game.StatusOfParticipants.Contains("1")) { updateStatus(msgStatus.INFO, "Accepted Queue"); firstTimeInQueuePop = false; firstTimeInLobby = true; object obj = await connection.AcceptPoppedGame(true); break; } else { break; } default: updateStatus(msgStatus.INFO, "[DEFAULT]" + game.GameStateString); break; } } else if (message.GetType() == typeof(TradeContractDTO)) { TradeContractDTO tradeDto = message as TradeContractDTO; if (tradeDto != null) { switch (tradeDto.State) { case "PENDING": if (tradeDto != null) { object obj = await connection.AcceptTrade(tradeDto.RequesterInternalSummonerName, (int)tradeDto.RequesterChampionId); break; } else { break; } } } } else if (message is PlayerCredentialsDto) { firstTimeInPostChampSelect = true; PlayerCredentialsDto dto = message as PlayerCredentialsDto; ProcessStartInfo startInfo = new ProcessStartInfo(); startInfo.WorkingDirectory = FindLoLExe(); startInfo.FileName = "League of Legends.exe"; startInfo.Arguments = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + dto.ServerIp + " " + dto.ServerPort + " " + dto.EncryptionKey + " " + dto.SummonerId + "\""; updateStatus(msgStatus.INFO, "Launching League of Legends"); new Thread(() => { exeProcess = Process.Start(startInfo); exeProcess.EnableRaisingEvents = true; exeProcess.Exited += new EventHandler(exeProcess_Exited); while (exeProcess.MainWindowHandle == IntPtr.Zero) { } Console.WriteLine(exeProcess.MainWindowTitle); Thread.Sleep(1000); App.gameMask.addGame(info.username, info.region.ToString(), exeProcess); }).Start(); } else if (!(message is GameNotification) && !(message is SearchingForMatchNotification)) { if (message is EndOfGameStats) { object obj4 = await connection.ackLeaverBusterWarning(); object obj5 = await connection.callPersistenceMessaging(new SimpleDialogMessageResponse() { AccountID = loginDataPacket.AllSummonerData.Summoner.SumId, MsgID = loginDataPacket.AllSummonerData.Summoner.SumId, Command = "ack" }); MatchMakerParams matchParams = new MatchMakerParams(); checkAndUpdateQueueType(); if (QueueType == QueueTypes.INTRO_BOT) { matchParams.BotDifficulty = "INTRO"; } else if (QueueType == QueueTypes.BEGINNER_BOT) { matchParams.BotDifficulty = "EASY"; } else if (QueueType == QueueTypes.MEDIUM_BOT) { matchParams.BotDifficulty = "MEDIUM"; } if (QueueType != 0) { matchParams.QueueIds = new Int32[1] { (int)QueueType }; SearchingForMatchNotification m = await connection.AttachToQueue(matchParams); if (m.PlayerJoinFailures == null) { updateStatus(msgStatus.INFO, "In Queue: " + QueueType.ToString()); } else { foreach (var failure in m.PlayerJoinFailures) { if (failure.ReasonFailed == "LEAVER_BUSTED") { m_accessToken = failure.AccessToken; if (failure.LeaverPenaltyMillisRemaining > m_leaverBustedPenalty) { m_leaverBustedPenalty = failure.LeaverPenaltyMillisRemaining; } } Console.WriteLine("Start Failed:" + failure.ReasonFailed); } if (string.IsNullOrEmpty(m_accessToken)) { foreach (var failure in m.PlayerJoinFailures) { updateStatus(msgStatus.INFO, "Dodge Remaining Time: " + Convert.ToString((failure.DodgePenaltyRemainingTime / 1000 / (float)60)).Replace(",", ":") + "..."); } } else { double minutes = m_leaverBustedPenalty / 1000 / (float)60; updateStatus(msgStatus.INFO, "Waiting out leaver buster: " + minutes + " minutes!"); t = TimeSpan.FromMinutes((int)minutes); //Tick(); -> Enable to get visual time remaining Thread.Sleep(TimeSpan.FromMilliseconds(m_leaverBustedPenalty)); m = await connection.AttachToLowPriorityQueue(matchParams, m_accessToken); if (m.PlayerJoinFailures == null) { updateStatus(msgStatus.INFO, "Succesfully joined lower priority queue!"); } else { updateStatus(msgStatus.ERROR, "There was an error in joining lower priority queue.\nDisconnecting."); connection.Disconnect(); } } } } } else if (message.ToString().Contains("EndOfGameStats")) { EndOfGameStats eog = new EndOfGameStats(); exeProcess.Exited -= new EventHandler(exeProcess_Exited); exeProcess.Kill(); Thread.Sleep(500); if (exeProcess.Responding) { Process.Start("taskkill /F /IM \"League of Legends.exe\""); } loginDataPacket = await connection.GetLoginDataPacketForUser(); if (type == RotationType.SmurfDone) { if (info.desiredLevel > loginDataPacket.AllSummonerData.SummonerLevel.Level) { connection_OnMessageReceived(sender, eog); } else { connection.Disconnect(); } } else { connection_OnMessageReceived(sender, eog); } } } }
private void RenderStats(EndOfGameStats Statistics) { TimeSpan t = TimeSpan.FromSeconds(Statistics.GameLength); TimeLabel.Content = string.Format("{0:D2}:{1:D2}", t.Minutes, t.Seconds); ModeLabel.Content = Statistics.GameMode; TypeLabel.Content = Statistics.GameType; GainedIP.Content = "+" + Statistics.IpEarned + " IP"; TotalIP.Content = Statistics.IpTotal.ToString().Replace(".0", "") + " IP Total"; string game = " XP"; List <PlayerParticipantStatsSummary> AllParticipants = new List <PlayerParticipantStatsSummary>(Statistics.TeamPlayerParticipantStats.ToArray()); AllParticipants.AddRange(Statistics.OtherTeamPlayerParticipantStats); foreach (PlayerParticipantStatsSummary summary in AllParticipants) { EndOfGamePlayer playerStats = new EndOfGamePlayer(); champions Champ = champions.GetChampion(summary.SkinName); //Misleading variable name playerStats.ChampImage.Source = Champ.icon; playerStats.ChampLabel.Content = Champ.name; playerStats.PlayerLabel.Content = summary.SummonerName; var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)summary.Spell1Id)), UriKind.Absolute); playerStats.Spell1Image.Source = new BitmapImage(uriSource); uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)summary.Spell2Id)), UriKind.Absolute); playerStats.Spell2Image.Source = new BitmapImage(uriSource); double ChampionsKilled = 0; double Assists = 0; double Deaths = 0; bool victory = false; foreach (RawStatDTO stat in summary.Statistics) { if (stat.StatTypeName.ToLower() == "win") { victory = true; } } if (Statistics.Ranked) { game = " LP"; GainedXP.Content = (victory ? "+" : "-") + Statistics.ExperienceEarned + game; TotalXP.Content = Statistics.ExperienceTotal + game; } else { GainedXP.Content = "+" + Statistics.ExperienceEarned + game; TotalXP.Content = Statistics.ExperienceTotal + game; } foreach (RawStatDTO stat in summary.Statistics) { if (stat.StatTypeName.StartsWith("ITEM") && stat.Value != 0) { System.Windows.Controls.Image item = new System.Windows.Controls.Image(); uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png"), UriKind.Absolute); item.Source = new BitmapImage(uriSource); playerStats.ItemsListView.Items.Add(item); } switch (stat.StatTypeName) { case "GOLD_EARNED": if (stat.Value > 0) { playerStats.GoldLabel.Content = string.Format("{0:N1}k", stat.Value / 1000); } break; case "MINIONS_KILLED": playerStats.CSLabel.Content = stat.Value; break; case "LEVEL": playerStats.LevelLabel.Content = stat.Value; break; case "CHAMPIONS_KILLED": ChampionsKilled = stat.Value; break; case "ASSISTS": Assists = stat.Value; break; case "NUM_DEATHS": Deaths = stat.Value; break; default: break; } } playerStats.ScoreLabel.Content = ChampionsKilled + "/" + Deaths + "/" + Assists; PlayersListView.Items.Add(playerStats); } PlayersListView.Items.Insert(AllParticipants.Count / 2, new Separator()); championSkins Skin = championSkins.GetSkin(Statistics.SkinIndex); try { if (Skin != null) { var skinSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", Skin.splashPath), UriKind.Absolute); SkinImage.Source = new BitmapImage(skinSource); } } catch { } }
void UpdateReplays() { GamePanel.Children.Clear(); var dir = new DirectoryInfo("cabinet"); var directories = dir.EnumerateDirectories() .OrderBy(d => d.CreationTime); string[] Replays = Directory.GetDirectories("cabinet"); foreach (DirectoryInfo di in directories) { string d = di.Name; if (!File.Exists(Path.Combine("cabinet", d, "token")) || !File.Exists(Path.Combine("cabinet", d, "key")) || !File.Exists(Path.Combine("cabinet", d, "endOfGameStats"))) continue; byte[] Base64Stats = Convert.FromBase64String(File.ReadAllText(Path.Combine("cabinet", d, "endOfGameStats"))); AmfReader statsReader = new AmfReader(new MemoryStream(Base64Stats), context); EndOfGameStats stats = (EndOfGameStats)statsReader.ReadAmf3Item(); ReplayItem item = new ReplayItem(); //Use unoccupied variable stats.Difficulty = d; item.Tag = stats; item.GameId.Content = d; item.GameType.Content = stats.GameMode.ToLower(); item.GameDate.Content = di.CreationTime.ToShortTimeString() + " " + di.CreationTime.ToShortDateString(); double seconds = stats.GameLength % 60; double minutes = stats.GameLength / 60; item.GameTime.Content = string.Format("{0:0}:{1:00}", minutes, seconds); item.Margin = new Thickness(0, 5, 0, 0); foreach (PlayerParticipantStatsSummary summary in stats.TeamPlayerParticipantStats) { SmallChampionItem image = new SmallChampionItem(); image.Width = 38; image.Height = 38; Uri UriSource = new Uri("/LegendaryReplays;component/champion/" + summary.SkinName + ".png", UriKind.RelativeOrAbsolute); image.ChampionImage.Source = new BitmapImage(UriSource); item.TeamOnePanel.Children.Add(image); } foreach (PlayerParticipantStatsSummary summary in stats.OtherTeamPlayerParticipantStats) { SmallChampionItem image = new SmallChampionItem(); image.Width = 38; image.Height = 38; Uri UriSource = new Uri("/LegendaryReplays;component/champion/" + summary.SkinName + ".png", UriKind.RelativeOrAbsolute); image.ChampionImage.Source = new BitmapImage(UriSource); item.TeamTwoPanel.Children.Add(image); } item.MouseDown += item_MouseDown; //Insert on top GamePanel.Children.Insert(0, item); } }
public async void connection_OnMessageReceived(object sender, object message) { if (message is GameDTO) { GameDTO game = message as GameDTO; switch (game.GameState) { case "TEAM_SELECT": int totalPlayers = game.TeamOne.Count + game.TeamTwo.Count; this.updateStatus("In custom lobby, playerCount:" + totalPlayers, Accountname); if (totalPlayers == 6 && game.OwnerSummary.AccountId == this.connection.AccountID()) { await connection.StartChampionSelection(game.Id, game.OptimisticLock); } break; case "CHAMP_SELECT": Program.QueueValid = true; if (this.firstTimeInLobby) { QueueFlag = true; firstTimeInLobby = false; updateStatus("In Champion Selection", Accountname); object obj = await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT"); if (queueType != QueueTypes.ARAM) { if (Program.championId != "" && Program.championId != "RANDOM") { int Spell1; int Spell2; if (!Program.rndSpell) { Spell1 = Enums.spellToId(Program.spell1); Spell2 = Enums.spellToId(Program.spell2); } else { var random = new Random(); var spellList = new List <int> { 13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4 }; int index = random.Next(spellList.Count); int index2 = random.Next(spellList.Count); int randomSpell1 = spellList[index]; int randomSpell2 = spellList[index2]; if (randomSpell1 == randomSpell2) { int index3 = random.Next(spellList.Count); randomSpell2 = spellList[index3]; } Spell1 = Convert.ToInt32(randomSpell1); Spell2 = Convert.ToInt32(randomSpell2); } await connection.SelectSpells(Spell1, Spell2); await connection.SelectChampion(Enums.championToId(Program.championId)); await connection.ChampionSelectCompleted(); } else if (Program.championId == "RANDOM") { int Spell1; int Spell2; if (!Program.rndSpell) { Spell1 = Enums.spellToId(Program.spell1); Spell2 = Enums.spellToId(Program.spell2); } else { var random = new Random(); var spellList = new List <int> { 13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4 }; int index = random.Next(spellList.Count); int index2 = random.Next(spellList.Count); int randomSpell1 = spellList[index]; int randomSpell2 = spellList[index2]; if (randomSpell1 == randomSpell2) { int index3 = random.Next(spellList.Count); randomSpell2 = spellList[index3]; } Spell1 = Convert.ToInt32(randomSpell1); Spell2 = Convert.ToInt32(randomSpell2); } await connection.SelectSpells(Spell1, Spell2); var randAvailableChampsArray = availableChampsArray.Shuffle(); int randomAdc = randAvailableChampsArray.First(champ => (champ.Owned || champ.FreeToPlay) && (champ.ChampionId == 22 || champ.ChampionId == 51 || champ.ChampionId == 42 || champ.ChampionId == 119 || champ.ChampionId == 81 || champ.ChampionId == 104 || champ.ChampionId == 222 || champ.ChampionId == 429 || champ.ChampionId == 96 || champ.ChampionId == 236 || champ.ChampionId == 21 || champ.ChampionId == 133 || champ.ChampionId == 15 || champ.ChampionId == 18 || champ.ChampionId == 29 || champ.ChampionId == 110 || champ.ChampionId == 67)).ChampionId; await connection.SelectChampion(randomAdc); await connection.ChampionSelectCompleted(); } else { int Spell1; int Spell2; if (!Program.rndSpell) { Spell1 = Enums.spellToId(Program.spell1); Spell2 = Enums.spellToId(Program.spell2); } else { var random = new Random(); var spellList = new List <int> { 13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4 }; int index = random.Next(spellList.Count); int index2 = random.Next(spellList.Count); int randomSpell1 = spellList[index]; int randomSpell2 = spellList[index2]; if (randomSpell1 == randomSpell2) { int index3 = random.Next(spellList.Count); randomSpell2 = spellList[index3]; } Spell1 = Convert.ToInt32(randomSpell1); Spell2 = Convert.ToInt32(randomSpell2); } await connection.SelectSpells(Spell1, Spell2); var randAvailableChampsArray = availableChampsArray.Shuffle(); int randomAdc = randAvailableChampsArray.First(champ => (champ.Owned || champ.FreeToPlay) && (champ.ChampionId == 22 || champ.ChampionId == 51 || champ.ChampionId == 42 || champ.ChampionId == 119 || champ.ChampionId == 81 || champ.ChampionId == 104 || champ.ChampionId == 222 || champ.ChampionId == 429 || champ.ChampionId == 96 || champ.ChampionId == 236 || champ.ChampionId == 21 || champ.ChampionId == 133 || champ.ChampionId == 15 || champ.ChampionId == 18 || champ.ChampionId == 29 || champ.ChampionId == 110 || champ.ChampionId == 67)).ChampionId; await connection.SelectChampion(randomAdc); await connection.ChampionSelectCompleted(); } } break; } else { break; } case "POST_CHAMP_SELECT": firstTimeInLobby = false; this.updateStatus("Last 10 seconds to start game", Accountname); break; case "PRE_CHAMP_SELECT": this.updateStatus("Last seconds to set champion", Accountname); break; case "GAME_START_CLIENT": this.updateStatus("In Game", Accountname); break; case "GameClientConnectedToServer": this.updateStatus("Connected to server", Accountname); break; case "IN_QUEUE": this.updateStatus("In Queue", Accountname); QueueFlag = true; break; case "TERMINATED": this.updateStatus("Re entering to queue", Accountname); this.firstTimeInQueuePop = true; if (queueType == QueueTypes.CUSTOM) { CreatePracticeGame(); } break; case "JOINING_CHAMP_SELECT": if (this.firstTimeInQueuePop && game.StatusOfParticipants.Contains("1")) { this.updateStatus("Game accepted", Accountname); this.firstTimeInQueuePop = false; this.firstTimeInLobby = true; object obj = await this.connection.AcceptPoppedGame(true); break; } else { break; } case "LEAVER_BUSTED": this.updateStatus("You are leaver busted", Accountname); break; } } else if (message is PlayerCredentialsDto) { string str = Enumerable.Last <string>((IEnumerable <string>)Enumerable.OrderBy <string, DateTime>(Directory.EnumerateDirectories((this.ipath ?? "") + "RADS\\solutions\\lol_game_client_sln\\releases\\"), (Func <string, DateTime>)(f => new DirectoryInfo(f).CreationTime))) + "\\deploy\\"; LoLLauncher.RiotObjects.Platform.Game.PlayerCredentialsDto credentials = message as PlayerCredentialsDto; System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.CreateNoWindow = false; startInfo.WorkingDirectory = str; if (Program.replaceConfig) { startInfo.WindowStyle = ProcessWindowStyle.Hidden; } startInfo.FileName = "League of Legends.exe"; startInfo.Arguments = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + credentials.ServerIp + " " + credentials.ServerPort + " " + credentials.EncryptionKey + " " + credentials.SummonerId + "\""; updateStatus("Starting Game", Accountname); new Thread((ThreadStart)(() => { exeProcess = Process.Start(startInfo); exeProcess.Exited += exeProcess_Exited; while (exeProcess.MainWindowHandle == IntPtr.Zero) { ; } exeProcess.PriorityClass = ProcessPriorityClass.Idle; exeProcess.EnableRaisingEvents = true; if (!Program.bolRunning) { Thread.Sleep(3000); BasicInject.Inject(exeProcess, Program.dllPath); } })).Start(); } else if (!(message is GameNotification) && !(message is SearchingForMatchNotification)) { if (message is EndOfGameStats) { EndOfGameStats eog = message as EndOfGameStats; this.joinQueue(); } else { if (message.ToString().Contains("EndOfGameStats")) { updateStatus("Game ending, calculating results", Accountname); EndOfGameStats eog = new EndOfGameStats(); connection_OnMessageReceived(sender, eog); exeProcess.Exited -= exeProcess_Exited; exeProcess.Kill(); Thread.Sleep(500); if (exeProcess.Responding) { Process.Start("taskkill /F /IM \"League of Legends.exe\""); } loginPacket = await this.connection.GetLoginDataPacketForUser(); archiveSumLevel = sumLevel; sumLevel = loginPacket.AllSummonerData.SummonerLevel.Level; if (sumLevel != archiveSumLevel) { levelUp(); } } } } }
public async void connection_OnMessageReceived(object sender, object message) { //======================= if (message is GameDTO) { GameDTO game = message as GameDTO; switch (game.GameState) { case "CHAMP_SELECT": if (this.firstTimeInLobby) { updateStatus("Bắt đầu trận thứ : " + solandachoi, ""); firstTimeInLobby = false; updateStatus("Đang chọn tướng !", Accountname); object obj = await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT"); if (queueType != QueueTypes.ARAM) { if (Program.championId != "" && Program.championId != "RANDOM") { int Spell1; int Spell2; if (!Program.rndSpell) { Spell1 = Enums.spellToId(Program.spell1); Spell2 = Enums.spellToId(Program.spell2); } else { var random = new Random(); var spellList = new List <int> { 13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4 }; int index = random.Next(spellList.Count); int index2 = random.Next(spellList.Count); int randomSpell1 = spellList[index]; int randomSpell2 = spellList[index2]; if (randomSpell1 == randomSpell2) { int index3 = random.Next(spellList.Count); randomSpell2 = spellList[index3]; } Spell1 = Convert.ToInt32(randomSpell1); Spell2 = Convert.ToInt32(randomSpell2); } await connection.SelectSpells(Spell1, Spell2); await connection.SelectChampion(Enums.championToId(Program.championId)); updateStatus("Bạn chọn tướng : " + Program.championId, Accountname); updateStatus("Phép bổ trợ 1 : " + Program.spell1, Accountname); updateStatus("Phép bổ trợ 2 : " + Program.spell2, Accountname); await connection.ChampionSelectCompleted(); } else if (Program.championId == "RANDOM") { int Spell1; int Spell2; if (!Program.rndSpell) { Spell1 = Enums.spellToId(Program.spell1); Spell2 = Enums.spellToId(Program.spell2); } else { var random = new Random(); var spellList = new List <int> { 13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4 }; int index = random.Next(spellList.Count); int index2 = random.Next(spellList.Count); int randomSpell1 = spellList[index]; int randomSpell2 = spellList[index2]; if (randomSpell1 == randomSpell2) { int index3 = random.Next(spellList.Count); randomSpell2 = spellList[index3]; } Spell1 = Convert.ToInt32(randomSpell1); Spell2 = Convert.ToInt32(randomSpell2); } await connection.SelectSpells(Spell1, Spell2); var randAvailableChampsArray = availableChampsArray.Shuffle(); await connection.SelectChampion(randAvailableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId); updateStatus("Chọn tướng ngẫu nhiên ", Accountname); updateStatus("Bạn chọn tướng : " + randAvailableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId, Accountname); updateStatus("Phép bổ trợ 1 : " + Spell1, Accountname); updateStatus("Phép bổ trợ 2 : " + Spell2, Accountname); await connection.ChampionSelectCompleted(); } else { int Spell1; int Spell2; if (!Program.rndSpell) { Spell1 = Enums.spellToId(Program.spell1); Spell2 = Enums.spellToId(Program.spell2); } else { var random = new Random(); var spellList = new List <int> { 13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4 }; int index = random.Next(spellList.Count); int index2 = random.Next(spellList.Count); int randomSpell1 = spellList[index]; int randomSpell2 = spellList[index2]; if (randomSpell1 == randomSpell2) { int index3 = random.Next(spellList.Count); randomSpell2 = spellList[index3]; } Spell1 = Convert.ToInt32(randomSpell1); Spell2 = Convert.ToInt32(randomSpell2); } await connection.SelectSpells(Spell1, Spell2); await connection.SelectChampion(availableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId); updateStatus("Chọn tướng đầu tiên", Accountname); updateStatus("Bạn chọn tướng : " + availableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId, Accountname); updateStatus("Phép bổ trợ 1 : " + Spell1, Accountname); updateStatus("Phép bổ trợ 2 : " + Spell2, Accountname); await connection.ChampionSelectCompleted(); } } break; } else { break; } case "POST_CHAMP_SELECT": firstTimeInLobby = false; this.updateStatus("(Post Champ Select)", Accountname); break; case "PRE_CHAMP_SELECT": this.updateStatus("(Pre Champ Select)", Accountname); break; case "GAME_START_CLIENT": this.updateStatus("Trò chơi bắt đầu .", Accountname); break; case "GameClientConnectedToServer": this.updateStatus("Client kết nối tới sever .", Accountname); break; case "IN_QUEUE": this.updateStatus("Đang tìm trận ...", Accountname); QueueFlag = true; break; case "TERMINATED": if (solandachoi <= solanchoi) { updateStatus("Xong trận thứ : " + solandachoi, ""); this.updateStatus("Vào lại hàng chờ !", Accountname); solandachoi++; } else { connection.Disconnect(); updateStatus("Hết số lần chơi ! . Thoát LOL ...", ""); Process[] processes = Process.GetProcessesByName("RitoBot"); foreach (Process process in processes) { process.Kill(); process.WaitForExit(); } } Thread.Sleep(2000); this.firstTimeInQueuePop = true; break; case "JOINING_CHAMP_SELECT": if (this.firstTimeInQueuePop && game.StatusOfParticipants.Contains("1")) { this.updateStatus("Đang chờ người chơi !", Accountname); this.firstTimeInQueuePop = false; this.firstTimeInLobby = true; object obj = await this.connection.AcceptPoppedGame(true); break; } else { break; } case "LEAVER_BUSTED": this.updateStatus("Leave busted", Accountname); break; } } else if (message is PlayerCredentialsDto) { string str = ipath + "GAME\\"; /* string str = Enumerable.Last<string>((IEnumerable<string>)Enumerable.OrderBy<string, DateTime>(Directory.EnumerateDirectories((this.ipath ?? "") + "RADS\\solutions\\lol_game_client_sln\\releases\\"), (Func<string, DateTime>)(f => new DirectoryInfo(f).CreationTime))) + "\\deploy\\";*/ LoLLauncher.RiotObjects.Platform.Game.PlayerCredentialsDto credentials = message as PlayerCredentialsDto; System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo(); startInfo.CreateNoWindow = false; startInfo.WorkingDirectory = str; startInfo.FileName = "League of Legends.exe"; startInfo.Arguments = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + credentials.ServerIp + " " + credentials.ServerPort + " " + credentials.EncryptionKey + " " + credentials.SummonerId + "\""; updateStatus("League of Legends đang chạy !", Accountname); new Thread((ThreadStart)(() => { exeProcess = Process.Start(startInfo); exeProcess.Exited += exeProcess_Exited; while (exeProcess.MainWindowHandle == IntPtr.Zero) { ; } exeProcess.PriorityClass = ProcessPriorityClass.Idle; exeProcess.EnableRaisingEvents = true; })).Start(); } else if (!(message is GameNotification) && !(message is SearchingForMatchNotification)) { if (message is EndOfGameStats) { LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams matchParams = new LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams(); if (queueType == QueueTypes.INTRO_BOT) { matchParams.BotDifficulty = "INTRO"; } else if (queueType == QueueTypes.BEGINNER_BOT) { matchParams.BotDifficulty = "EASY"; } else if (queueType == QueueTypes.MEDIUM_BOT) { matchParams.BotDifficulty = "MEDIUM"; } if (sumLevel == 3 && actualQueueType == QueueTypes.NORMAL_5x5) { queueType = actualQueueType; } else if (sumLevel == 6 && actualQueueType == QueueTypes.ARAM) { queueType = actualQueueType; } else if (sumLevel == 7 && actualQueueType == QueueTypes.NORMAL_3x3) { queueType = actualQueueType; } matchParams.QueueIds = new Int32[1] { (int)queueType }; LoLLauncher.RiotObjects.Platform.Matchmaking.SearchingForMatchNotification m = await connection.AttachToQueue(matchParams); if (m.PlayerJoinFailures == null) { this.updateStatus("Chế độ chơi : " + queueType.ToString(), Accountname); } else { try { updateStatus("Couldn't enter Q - " + m.PlayerJoinFailures.Summoner.Name + " : " + m.PlayerJoinFailures.ReasonFailed, Accountname); } catch (Exception) { if (QueueFlag) { Console.WriteLine( "Something went wrong, couldn't enter queue. Check accounts.txt for correct queue type."); connection.Disconnect(); } else { this.updateStatus("Bạn đang bị vào hàng chờ thấp ... VCC", Accountname); this.updateStatus("Tool đang check . đợi xíu . 1 phút 1 lần !", Accountname); Thread.Sleep(1000 * 60); EndOfGameStats eog = new EndOfGameStats(); connection_OnMessageReceived(sender, eog); } } } } else { if (message.ToString().Contains("EndOfGameStats")) { EndOfGameStats eog = new EndOfGameStats(); connection_OnMessageReceived(sender, eog); exeProcess.Exited -= exeProcess_Exited; exeProcess.Kill(); loginPacket = await this.connection.GetLoginDataPacketForUser(); archiveSumLevel = sumLevel; sumLevel = loginPacket.AllSummonerData.SummonerLevel.Level; if (sumLevel != archiveSumLevel) { levelUp(); } } } } //======================= }
private void RenderStats(EndOfGameStats statistics) { TimeSpan t = TimeSpan.FromSeconds(statistics.GameLength); TimeLabel.Content = $"{t.Minutes:D2}:{t.Seconds:D2}"; ModeLabel.Content = statistics.GameMode; TypeLabel.Content = statistics.GameType; MatchStatsOnline = "http://matchhistory.na.leagueoflegends.com/en/#match-details/" + StaticVars.ActiveClient.RegionData.RegionName + "/" + statistics.ReportGameId + "/" + statistics.UserId; GainedIP.Content = "+" + statistics.IpEarned + " IP"; TotalIP.Content = statistics.IpEarned.ToString(CultureInfo.InvariantCulture).Replace(".0", "") + " IP Total"; string game = " XP"; var allParticipants = new List <PlayerParticipantStatsSummary>(statistics.TeamPlayerParticipantStats.ToArray()); allParticipants.AddRange(statistics.OtherTeamPlayerParticipantStats); var readFile = Path.Combine(StaticVars.IcyWindLocation, "IcyWindAssets", "SumSpell", "summoner.json"); var text = File.ReadAllText(readFile); var internalSpellData = JsonConvert.DeserializeObject <SumSpellData>(text); var readFile2 = Path.Combine(StaticVars.IcyWindLocation, "IcyWindAssets", "ChampIcons", "champion.json"); var text2 = File.ReadAllText(readFile2); var internalChampData = JsonConvert.DeserializeObject <ChampionData>(text2); foreach (PlayerParticipantStatsSummary summary in allParticipants) { var playerStats = new EndOfGamePlayer(summary.UserId, summary.GameId, summary.SummonerName, statistics.TeamPlayerParticipantStats.Contains(summary)); //champions champ = champions.GetChampion(summary.SkinName); //Misleading variable name var champ = internalChampData.Data.First(x => x.Value.Key == summary.ChampionId.ToString()); playerStats.ChampImage.Source = new BitmapImage(new Uri( Path.Combine(StaticVars.IcyWindLocation, "IcyWindAssets", "SumSpell", champ.Value.Image.Full))); playerStats.ChampLabel.Content = summary.SkinName; playerStats.PlayerLabel.Content = summary.SummonerName; var spell1 = internalSpellData.Data.FirstOrDefault(x => x.Value.Key == summary.Spell1Id.ToString()); var spell2 = internalSpellData.Data.FirstOrDefault(x => x.Value.Key == summary.Spell1Id.ToString()); if (File.Exists(Path.Combine(StaticVars.IcyWindLocation, "IcyWindAssets", "SumSpell", spell1.Value.Image.Full))) { playerStats.Spell1Image.Source = new BitmapImage(new Uri( Path.Combine(StaticVars.IcyWindLocation, "IcyWindAssets", "SumSpell", spell1.Value.Image.Full))); } if (File.Exists(Path.Combine(StaticVars.IcyWindLocation, "IcyWindAssets", "SumSpell", spell2.Value.Image.Full))) { playerStats.Spell2Image.Source = new BitmapImage(new Uri( Path.Combine(StaticVars.IcyWindLocation, "IcyWindAssets", "SumSpell", spell2.Value.Image.Full))); } double championsKilled = 0; double assists = 0; double deaths = 0; foreach (var stat in summary.Statistics.Where(stat => stat.StatTypeName.ToLower() == "win")) { if (summary.SummonerName != StaticVars.ActiveClient.LoginDataPacket.AllSummonerData.Summoner.Name) { continue; } GameResultLabel.Content = "Victory"; } if (statistics.Ranked) { game = " LP"; //GainedXP.Content = (victory ? "+" : "-") + statistics.ExperienceEarned + game; //TotalXP.Content = statistics.ExperienceTotal + game; } else { //GainedXP.Content = "+" + statistics.ExperienceEarned + game; //TotalXP.Content = statistics.ExperienceTotal + game; } foreach (RawStatDTO stat in summary.Statistics) { if (stat.StatTypeName.StartsWith("ITEM") && Math.Abs(stat.Value) > 0) { var item = new Image(); if (File.Exists(Path.Combine(StaticVars.IcyWindLocation, "Assets", "item", stat.Value + ".png"))) { var UriSource = new System.Uri(Path.Combine(StaticVars.IcyWindLocation, "Assets", "item", stat.Value + ".png"), UriKind.Absolute); item.Source = new BitmapImage(UriSource); } playerStats.ItemsListView.Items.Add(item); } switch (stat.StatTypeName) { case "GOLD_EARNED": if (stat.Value > 0) { playerStats.GoldLabel.Content = $"{stat.Value / 1000:N1}k"; } break; case "MINIONS_KILLED": playerStats.CsLabel.Content = stat.Value; break; case "LEVEL": playerStats.LevelLabel.Content = stat.Value; break; case "CHAMPIONS_KILLED": championsKilled = stat.Value; break; case "ASSISTS": assists = stat.Value; break; case "NUM_DEATHS": deaths = stat.Value; break; } } playerStats.ScoreLabel.Content = championsKilled + "/" + deaths + "/" + assists; PlayersListView.Items.Add(playerStats); } PlayersListView.Items.Insert(allParticipants.Count / 2, new Separator()); /* * championSkins skin = championSkins.GetSkin(statistics.SkinIndex); * try * { * if (skin == null) * return; * * var skinSource = * new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", skin.splashPath), * UriKind.Absolute); * SkinImage.Source = new BitmapImage(skinSource); * } * catch (Exception) * { * } */ }