private void StartTeambuilder() { ListViewItem item = new ListViewItem(); Image skinImage = new Image(); ChampList = new List <ChampionDTO>(Client.PlayerChampions); champions Champion = champions.GetChampion(ChampionId); string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", Champion.portraitPath); //Retrieve masteries and runes MyMasteries = Client.LoginPacket.AllSummonerData.MasteryBook; MyRunes = Client.LoginPacket.AllSummonerData.SpellBook; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { //Allow all champions to be selected (reset our modifications) ListViewItem[] ChampionArray = new ListViewItem[ChampionSelectListView.Items.Count]; ChampionSelectListView.Items.CopyTo(ChampionArray, 0); foreach (ListViewItem y in ChampionArray) { y.IsHitTestVisible = true; y.Opacity = 1; } })); foreach (ChampionDTO champ in ChampList) { if (champ.ChampionId == ChampionId) { foreach (ChampionSkinDTO skin in champ.ChampionSkins) { if (skin.Owned) { item = new ListViewItem(); skinImage = new Image(); uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", championSkins.GetSkin(skin.SkinId).portraitPath); skinImage.Source = Client.GetImage(uriSource); skinImage.Width = 191; skinImage.Stretch = Stretch.UniformToFill; item.Tag = skin.SkinId; item.Content = skinImage; SkinSelectListView.Items.Add(item); } } } } skinImage.Source = Client.GetImage(uriSource); skinImage.Width = 191; skinImage.Stretch = Stretch.UniformToFill; item.Tag = "0:" + ChampionId; //Hack item.Content = skinImage; SkinSelectListView.Items.Add(item); }
public async Task <SpellBookDTO> GetSpellBook(Double summonerId) { int Id = Invoke("spellBookService", "getSpellBook", new object[] { summonerId }); while (!results.ContainsKey(Id)) { await Task.Delay(10); } TypedObject messageBody = results[Id].GetTO("data").GetTO("body"); SpellBookDTO result = new SpellBookDTO(messageBody); results.Remove(Id); return(result); }
//TeamBuilder is just a little insane. This code is very messy too. :P public TeamBuilderPage(bool iscreater) { InitializeComponent(); if (iscreater == false) { Invite.IsEnabled = false; } //Start teambuilder CallWithArgs(Guid.NewGuid().ToString(), "cap", "retrieveFeatureToggles", "{}"); MyMasteries = Client.LoginPacket.AllSummonerData.MasteryBook; MyRunes = Client.LoginPacket.AllSummonerData.SpellBook; //StartTeambuilder(); LoadStats(); Client.PVPNet.OnMessageReceived += PVPNet_OnMessageReceived; AddPlayer(); }
private void Kappa_Authed(object sender, EventArgs e) { srcBook = this.session.Me.Runes; book = new RuneBook(); foreach (var srcPage in srcBook.BookPages) { var page = new RunePage { Id = srcPage.PageId, Name = srcPage.Name }; if (srcPage.Current) { book.Selected = page.Id; } foreach (var entry in srcPage.SlotEntries) { page.Runes.Add(entry.RuneSlotId.ToString(), entry.RuneId); } book.Pages.Add(page); } }
/// 36.) public void GetSpellBook(Double summonerId, SpellBookDTO.Callback callback) { SpellBookDTO cb = new SpellBookDTO(callback); InvokeWithCallback("spellBookService", "getSpellBook", new object[] { summonerId }, cb); }
/// <summary> /// Saves the players spellbook /// </summary> /// <param name="Spellbook">The players SpellBookDTO</param> public static Task <Object> SaveSpellBook(SpellBookDTO Spellbook) { return(InvokeAsync <Object>("spellBookService", "saveSpellBook", Spellbook)); }
public static async Task SetRuneSetups(string realm, string summonerName, JToken obj) { RiotAccount account = InventoryHelper.GetAccount(realm, summonerName); string item = (string)obj["activeId"]; List<SpellBookPageDTO> list = obj["setups"].Select<JToken, InventoryHelper.RuneSetup>(new Func<JToken, InventoryHelper.RuneSetup>(InventoryHelper.ToRuneSetup)).Select<InventoryHelper.RuneSetup, SpellBookPageDTO>(new Func<InventoryHelper.RuneSetup, SpellBookPageDTO>(InventoryHelper.ToSpellBookPage)).ToList<SpellBookPageDTO>(); List<SpellBookPageDTO> spellBookPageDTOs = list; IEnumerable<double> pageId = from x in spellBookPageDTOs select x.PageId; double[] array = ( from x in pageId orderby x select x).ToArray<double>(); for (int i = 0; i < (int)array.Length; i++) { list[i].PageId = array[i]; } List<SpellBookPageDTO> spellBookPageDTOs1 = list; IEnumerable<string> name = from x in spellBookPageDTOs1 select x.Name; ILookup<string, string> lookup = name.ToLookup<string, string>((string x) => x); Func<IGrouping<string, string>, string> key = (IGrouping<string, string> x) => x.Key; Dictionary<string, string[]> dictionary = lookup.ToDictionary<IGrouping<string, string>, string, string[]>(key, (IGrouping<string, string> x) => x.ToArray<string>()); for (int j = 0; j < list.Count; j++) { SpellBookPageDTO summonerId = list[j]; summonerId.SummonerId = (double)account.SummonerId; if (string.IsNullOrEmpty(summonerId.Name) || (int)dictionary[summonerId.Name].Length > 1) { summonerId.Name = string.Format("#{0:00}. {1}", j, summonerId.Name); } if (summonerId.PageId.ToString(CultureInfo.InvariantCulture) == item) { summonerId.Current = true; } } if (list.Count > 0) { List<SpellBookPageDTO> spellBookPageDTOs2 = list; if (spellBookPageDTOs2.All<SpellBookPageDTO>((SpellBookPageDTO x) => !x.Current)) { list[0].Current = true; } } RiotAccount riotAccount = account; SpellBookDTO spellBookDTO = new SpellBookDTO() { SummonerId = (double)account.SummonerId, BookPages = list }; await riotAccount.InvokeAsync<object>("spellBookService", "saveSpellBook", spellBookDTO); InventoryHelper.ClearRuneCache(account); }
private async void StartChampSelect() { //Force client to popup once in champion select Client.FocusClient(); Client.IsInGame = true; //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! { QuitCurrentGame(); MessageOverlay overlay = new MessageOverlay(); overlay.MessageTextBox.Text = "Invalid Config ID (" + latestDTO.GameTypeConfigId.ToString() + "). Report to Eddy5641 [https://github.com/Eddy5641/LegendaryClient/issues/new]"; overlay.MessageTitle.Content = "Invalid Config"; Client.OverlayContainer.Content = overlay.Content; Client.OverlayContainer.Visibility = Visibility.Visible; } 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; }
public Task <SpellBookDTO> SaveSpellBook(SpellBookDTO spellbook) { return(this.InvokeAsync <SpellBookDTO>("spellBookService", "saveSpellBook", (object)spellbook)); }
public static async Task SetRuneSetups(string realm, string summonerName, JToken obj) { RiotAccount account = InventoryHelper.GetAccount(realm, summonerName); string activeId = (string) obj[(object) "activeId"]; List<SpellBookPageDTO> pages = Enumerable.ToList<SpellBookPageDTO>(Enumerable.Select<InventoryHelper.RuneSetup, SpellBookPageDTO>(Enumerable.Select<JToken, InventoryHelper.RuneSetup>((IEnumerable<JToken>) obj[(object) "setups"], new Func<JToken, InventoryHelper.RuneSetup>(InventoryHelper.ToRuneSetup)), new Func<InventoryHelper.RuneSetup, SpellBookPageDTO>(InventoryHelper.ToSpellBookPage))); double[] pageIds = Enumerable.ToArray<double>((IEnumerable<double>) Enumerable.OrderBy<double, double>(Enumerable.Select<SpellBookPageDTO, double>((IEnumerable<SpellBookPageDTO>) pages, (Func<SpellBookPageDTO, double>) (x => x.PageId)), (Func<double, double>) (x => x))); for (int index = 0; index < pageIds.Length; ++index) pages[index].PageId = pageIds[index]; Dictionary<string, string[]> duplicatesLookup = Enumerable.ToDictionary<IGrouping<string, string>, string, string[]>((IEnumerable<IGrouping<string, string>>) Enumerable.ToLookup<string, string>(Enumerable.Select<SpellBookPageDTO, string>((IEnumerable<SpellBookPageDTO>) pages, (Func<SpellBookPageDTO, string>) (x => x.Name)), (Func<string, string>) (x => x)), (Func<IGrouping<string, string>, string>) (x => x.Key), (Func<IGrouping<string, string>, string[]>) (x => Enumerable.ToArray<string>((IEnumerable<string>) x))); for (int index = 0; index < pages.Count; ++index) { SpellBookPageDTO spellBookPageDto = pages[index]; spellBookPageDto.SummonerId = (double) account.SummonerId; if (string.IsNullOrEmpty(spellBookPageDto.Name) || duplicatesLookup[spellBookPageDto.Name].Length > 1) spellBookPageDto.Name = string.Format("#{0:00}. {1}", (object) index, (object) spellBookPageDto.Name); if (spellBookPageDto.PageId.ToString((IFormatProvider) CultureInfo.InvariantCulture) == activeId) spellBookPageDto.Current = true; } if (pages.Count > 0 && Enumerable.All<SpellBookPageDTO>((IEnumerable<SpellBookPageDTO>) pages, (Func<SpellBookPageDTO, bool>) (x => !x.Current))) pages[0].Current = true; RiotAccount riotAccount = account; string destination = "spellBookService"; string method = "saveSpellBook"; SpellBookDTO spellBookDto = new SpellBookDTO(); spellBookDto.SummonerId = (double) account.SummonerId; spellBookDto.BookPages = pages; SpellBookDTO spellBookDto1 = spellBookDto; object obj1 = await riotAccount.InvokeAsync<object>(destination, method, (object) spellBookDto1); InventoryHelper.ClearRuneCache(account); }
/// <summary> /// Saves the players spellbook /// </summary> /// <param name="spellbook">The players SpellBookDTO</param> public Task <object> SaveSpellBook(SpellBookDTO spellbook) { return(InvokeAsync <object>("saveSpellBook", spellbook)); }