/// <summary> /// Initializes all data required for champion select. Also retrieves latest GameDTO /// </summary> private async void StartChampSelect() { //Force client to popup once in champion select Client.FocusClient(); //Get champions and sort alphabetically ChampList = new List<ChampionDTO>(Client.PlayerChampions); ChampList.Sort((x, y) => champions.GetChampion(x.ChampionId).displayName.CompareTo(champions.GetChampion(y.ChampionId).displayName)); //Retrieve masteries and runes MyMasteries = Client.LoginPacket.AllSummonerData.MasteryBook; MyRunes = Client.LoginPacket.AllSummonerData.SpellBook; //Put masteries & runes into combo boxes int i = 0; foreach (MasteryBookPageDTO MasteryPage in MyMasteries.BookPages) { string MasteryPageName = MasteryPage.Name; //Stop garbage mastery names if (MasteryPageName.StartsWith("@@")) { MasteryPageName = "Mastery Page " + ++i; } MasteryComboBox.Items.Add(MasteryPageName); if (MasteryPage.Current) MasteryComboBox.SelectedValue = MasteryPageName; } i = 0; foreach (SpellBookPageDTO RunePage in MyRunes.BookPages) { string RunePageName = RunePage.Name; //Stop garbage rune names if (RunePageName.StartsWith("@@")) { RunePageName = "Rune Page " + ++i; } RuneComboBox.Items.Add(RunePageName); if (RunePage.Current) RuneComboBox.SelectedValue = RunePageName; } //Allow runes & masteries to be changed QuickLoad = true; //Signal to the server we are in champion select await Client.PVPNet.SetClientReceivedGameMessage(Client.GameID, "CHAMP_SELECT_CLIENT"); //Retrieve the latest GameDTO GameDTO latestDTO = await Client.PVPNet.GetLatestGameTimerState(Client.GameID, Client.ChampSelectDTO.GameState, Client.ChampSelectDTO.PickTurn); //Find the game config for timers configType = Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == latestDTO.GameTypeConfigId); if (configType == null) //Invalid config... abort! { Client.QuitCurrentGame(); MessageOverlay overlay = new MessageOverlay(); overlay.MessageTextBox.Text = "Invalid Config ID (" + latestDTO.GameTypeConfigId.ToString() + "). Report to Snowl [https://github.com/Snowl/LegendaryClient/issues/new]"; overlay.MessageTitle.Content = "Invalid Config"; Client.OverlayContainer.Content = overlay.Content; Client.OverlayContainer.Visibility = Visibility.Visible; return; } counter = configType.MainPickTimerDuration - 5; //Seems to be a 5 second inconsistancy with riot and what they actually provide CountdownTimer = new System.Windows.Forms.Timer(); CountdownTimer.Tick += new EventHandler(CountdownTimer_Tick); CountdownTimer.Interval = 1000; // 1 second CountdownTimer.Start(); LatestDto = latestDTO; //Get the champions for the other team to ban & sort alpabetically ChampionBanInfoDTO[] ChampsForBan = await Client.PVPNet.GetChampionsForBan(); ChampionsForBan = new List<ChampionBanInfoDTO>(ChampsForBan); ChampionsForBan.Sort((x, y) => champions.GetChampion(x.ChampionId).displayName.CompareTo(champions.GetChampion(y.ChampionId).displayName)); //Join champion select chatroom string JID = Client.GetChatroomJID(latestDTO.RoomName.Replace("@sec", ""), latestDTO.RoomPassword, false); Chatroom = Client.ConfManager.GetRoom(new jabber.JID(JID)); Chatroom.Nickname = Client.LoginPacket.AllSummonerData.Summoner.Name; Chatroom.OnRoomMessage += Chatroom_OnRoomMessage; Chatroom.OnParticipantJoin += Chatroom_OnParticipantJoin; Chatroom.Join(latestDTO.RoomPassword); //Render our champions RenderChamps(false); //Start recieving champ select ChampSelect_OnMessageReceived(this, latestDTO); Client.OnFixChampSelect += ChampSelect_OnMessageReceived; Client.PVPNet.OnMessageReceived += ChampSelect_OnMessageReceived; }
private async void StartChampSelect() { Client.FocusClient(); Champions = Client.PlayerChampions; MyMasteries = Client.LoginPacket.AllSummonerData.MasteryBook; MyRunes = Client.LoginPacket.AllSummonerData.SpellBook; int i = 0; foreach (MasteryBookPageDTO MasteryPage in MyMasteries.BookPages) { string MasteryPageName = MasteryPage.Name; if (MasteryPageName.StartsWith("@@")) { MasteryPageName = "Mastery Page " + ++i; } MasteryComboBox.Items.Add(MasteryPageName); if (MasteryPage.Current) MasteryComboBox.SelectedValue = MasteryPageName; } i = 0; foreach (SpellBookPageDTO RunePage in MyRunes.BookPages) { string RunePageName = RunePage.Name; if (RunePageName.StartsWith("@@")) { RunePageName = "Rune Page " + ++i; } RuneComboBox.Items.Add(RunePageName); if (RunePage.Current) RuneComboBox.SelectedValue = RunePageName; } QuickLoad = true; await Client.PVPNet.SetClientReceivedGameMessage(Client.GameID, "CHAMP_SELECT_CLIENT"); GameDTO latestDTO = await Client.PVPNet.GetLatestGameTimerState(Client.GameID, Client.ChampSelectDTO.GameState, Client.ChampSelectDTO.PickTurn); configType = Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == latestDTO.GameTypeConfigId); if (configType == null) //Invalid config... abort! { Client.PVPNet.OnMessageReceived -= ChampSelect_OnMessageReceived; await Client.PVPNet.QuitGame(); Client.ClearPage(this); Client.SwitchPage(new MainPage()); MessageOverlay overlay = new MessageOverlay(); overlay.MessageTextBox.Text = "Invalid Config ID (" + latestDTO.GameTypeConfigId.ToString() + "). Report to Snowl [https://github.com/Snowl/LegendaryClient/issues/new]"; overlay.MessageTitle.Content = "Invalid Config"; Client.OverlayContainer.Content = overlay.Content; Client.OverlayContainer.Visibility = Visibility.Visible; return; } counter = configType.MainPickTimerDuration - 5; //Seems to be a 5 second inconsistancy with riot and what they actually provide CountdownTimer = new System.Windows.Forms.Timer(); CountdownTimer.Tick += new EventHandler(CountdownTimer_Tick); CountdownTimer.Interval = 1000; // 1 second CountdownTimer.Start(); LatestDto = latestDTO; string JID = Client.GetChatroomJID(latestDTO.RoomName.Replace("@sec", ""), latestDTO.RoomPassword, false); Chatroom = Client.ConfManager.GetRoom(new jabber.JID(JID)); Chatroom.Nickname = Client.LoginPacket.AllSummonerData.Summoner.Name; Chatroom.OnRoomMessage += Chatroom_OnRoomMessage; Chatroom.OnParticipantJoin += Chatroom_OnParticipantJoin; Chatroom.Join(latestDTO.RoomPassword); List<ChampionDTO> champList = new List<ChampionDTO>(Champions); champList.Sort((x, y) => champions.GetChampion(x.ChampionId).displayName.CompareTo(champions.GetChampion(y.ChampionId).displayName)); foreach (ChampionDTO champ in champList) { if (champ.Owned || champ.FreeToPlay) { MyChamps.Add(champ); //Add to ListView ListViewItem item = new ListViewItem(); ChampionImage championImage = new ChampionImage(); championImage.ChampImage.Source = champions.GetChampion(champ.ChampionId).icon; if (champ.FreeToPlay) championImage.FreeToPlayLabel.Visibility = Visibility.Visible; championImage.Width = 64; championImage.Height = 64; item.Tag = champ.ChampionId; item.Content = championImage.Content; ChampionSelectListView.Items.Add(item); } } ChampSelect_OnMessageReceived(this, latestDTO); Client.PVPNet.OnMessageReceived += ChampSelect_OnMessageReceived; }