Beispiel #1
0
        private async Task <MasteryBookDTO> GetUserMasterPage(string User)
        {
            PublicSummoner summoner = await RiotCalls.GetSummonerByName(User);

            MasteryBookDTO page = await RiotCalls.GetMasteryBook(summoner.SummonerId);

            return(page);
        }
        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);
        }
Beispiel #3
0
        public async Task <MasteryBookDTO> GetMasteryBook(Double summonerId)
        {
            int Id = Invoke("masteryBookService", "getMasteryBook", new object[] { summonerId });

            while (!results.ContainsKey(Id))
            {
                await Task.Delay(10);
            }
            TypedObject    messageBody = results[Id].GetTO("data").GetTO("body");
            MasteryBookDTO result      = new MasteryBookDTO(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();
        }
Beispiel #5
0
        private async void MasteryComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (!QuickLoad) //Make loading quicker
            {
                return;
            }

            bool           HasChanged = false;
            int            i          = 0;
            MasteryBookDTO bookDTO    = new MasteryBookDTO();

            bookDTO.SummonerId = Client.LoginPacket.AllSummonerData.Summoner.SumId;
            bookDTO.BookPages  = new List <MasteryBookPageDTO>();
            foreach (MasteryBookPageDTO MasteryPage in MyMasteries.BookPages)
            {
                string MasteryPageName = MasteryPage.Name;
                //Convert garbage to readable so we get the proper mastery page
                if (MasteryPageName.StartsWith("@@"))
                {
                    MasteryPageName = "Mastery Page " + ++i;
                }
                MasteryPage.Current = false;
                if (MasteryPageName == (string)MasteryComboBox.SelectedItem)
                {
                    MasteryPage.Current = true;
                    HasChanged          = true;
                    TextRange tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd);
                    tr.Text = "Selected " + MasteryPageName + " as Mastery Page" + Environment.NewLine;
                    tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White);
                }
                bookDTO.BookPages.Add(MasteryPage);
            }
            if (HasChanged)
            {
                await Client.PVPNet.SaveMasteryBook(bookDTO);
            }
        }
        private void Kappa_Authed(object sender, EventArgs e)
        {
            srcBook = this.session.Me.Masteries;

            book = new MasteryBook();
            foreach (var srcPage in srcBook.BookPages)
            {
                var page = new MasteryPage {
                    Id   = srcPage.PageId,
                    Name = srcPage.Name
                };
                if (srcPage.Current)
                {
                    book.Selected = page.Id;
                }

                foreach (var talent in srcPage.TalentEntries)
                {
                    page.Masteries.Add(talent.TalentId.ToString(), talent.Rank);
                }

                book.Pages.Add(page);
            }
        }
Beispiel #7
0
        public RemotingMessageReceivedEventArgs HandleMessage(object sender, RemotingMessageReceivedEventArgs e)
        {
            MasteryBookDTO MasteryBook = new MasteryBookDTO
            {
                SummonerId = int.MaxValue - 1,
                DateString = "Wed Apr 23 00:33:57 PDT 2014",
                BookPages  = new ArrayCollection
                {
                    new MasteryBookPageDTO
                    {
                        Current       = true,
                        SummonerId    = int.MaxValue - 1,
                        PageId        = 1.0,
                        Name          = "Mastery Page 1",
                        TalentEntries = new ArrayCollection()
                    }
                }
            };

            e.ReturnRequired = true;
            e.Data           = MasteryBook;

            return(e);
        }
Beispiel #8
0
        /// 9.)
        public void GetMasteryBook(Double summonerId, MasteryBookDTO.Callback callback)
        {
            MasteryBookDTO cb = new MasteryBookDTO(callback);

            InvokeWithCallback("masteryBookService", "getMasteryBook", new object[] { summonerId }, cb);
        }
Beispiel #9
0
 /// <summary>
 /// Saves the mastery book
 /// </summary>
 /// <param name="MasteryBookPage">The mastery book information</param>
 /// <returns>Returns the mastery book</returns>
 public static Task <MasteryBookDTO> SaveMasteryBook(MasteryBookDTO MasteryBookPage)
 {
     return(InvokeAsync <MasteryBookDTO>("masteryBookService", "saveMasteryBook", MasteryBookPage));
 }
 private static void SaveRiotMasteryBook(MasteryBook book)
 {
     MasterySetup[] array = (book.Setups ?? new MasterySetup[0]).Take<MasterySetup>(20).ToArray<MasterySetup>();
     MasteryBookPageDTO[] masteryBookPageDTOArray = array.Select<MasterySetup, MasteryBookPageDTO>(new Func<MasterySetup, MasteryBookPageDTO>(InventoryHelper.ToMasteryBookPage)).ToArray<MasteryBookPageDTO>();
     Dictionary<string, string[]> dictionary = (
         from x in (IEnumerable<MasteryBookPageDTO>)masteryBookPageDTOArray
         select x.Name).ToLookup<string, string>((string x) => x).ToDictionary<IGrouping<string, string>, string, string[]>((IGrouping<string, string> x) => x.Key, (IGrouping<string, string> x) => x.ToArray<string>());
     for (int i = 0; i < (int)masteryBookPageDTOArray.Length; i++)
     {
         MasteryBookPageDTO masteryBookPageDTO = masteryBookPageDTOArray[i];
         masteryBookPageDTO.PageId = (double)(i + 1);
         if (string.IsNullOrEmpty(masteryBookPageDTO.Name) || (int)dictionary[masteryBookPageDTO.Name].Length > 1)
         {
             masteryBookPageDTO.Name = string.Format("#{0:00}. {1}", i, masteryBookPageDTO.Name);
         }
         if (((IEnumerable<MasteryBookPageDTO>)masteryBookPageDTOArray).All<MasteryBookPageDTO>((MasteryBookPageDTO x) => !x.Current) && array[i].Id == book.ActiveId)
         {
             masteryBookPageDTO.Current = true;
         }
     }
     if ((int)masteryBookPageDTOArray.Length > 0)
     {
         if (((IEnumerable<MasteryBookPageDTO>)masteryBookPageDTOArray).All<MasteryBookPageDTO>((MasteryBookPageDTO x) => !x.Current))
         {
             masteryBookPageDTOArray[0].Current = true;
         }
     }
     RiotAccount[] all = JsApiService.AccountBag.GetAll();
     for (int j = 0; j < (int)all.Length; j++)
     {
         RiotAccount riotAccount = all[j];
         MasteryBookDTO masteryBookDTO = new MasteryBookDTO()
         {
             SummonerId = (double)riotAccount.SummonerId,
             BookPages = masteryBookPageDTOArray.ToList<MasteryBookPageDTO>()
         };
         riotAccount.InvokeAsync<object>("masteryBookService", "saveMasteryBook", masteryBookDTO);
         InventoryHelper.ClearMasteryCache(riotAccount);
     }
 }
Beispiel #11
0
        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;
        }
Beispiel #12
0
        private async void GetUserMasterPage(string User)
        {
            PublicSummoner summoner = await Client.PVPNet.GetSummonerByName(User);

            MasteryBookDTO page = await Client.PVPNet.GetMasteryBook(summoner.SummonerId);
        }
 public Task <MasteryBookDTO> SaveMasteryBook(MasteryBookDTO masteryBookPage)
 {
     return(this.InvokeAsync <MasteryBookDTO>("masteryBookService", "saveMasteryBook", (object)masteryBookPage));
 }
Beispiel #14
0
        public RemotingMessageReceivedEventArgs HandleMessage(object sender, RemotingMessageReceivedEventArgs e)
        {
            SummonerClient summonerSender = sender as SummonerClient;

            MasteryBookDTO MasteryBook = new MasteryBookDTO
            {
                SummonerId = summonerSender._sumId,
                DateString = "",
                BookPages  = new ArrayCollection()
                {
                    new MasteryBookPageDTO
                    {
                        Current    = true,
                        SummonerId = summonerSender._sumId,
                        PageId     = 1,
                        Name       = "Mastery Page 1",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 2,
                        Name       = "Mastery Page 2",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 3,
                        Name       = "Mastery Page 3",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 4,
                        Name       = "Mastery Page 4",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 5,
                        Name       = "Mastery Page 5",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 6,
                        Name       = "Mastery Page 6",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 7,
                        Name       = "Mastery Page 7",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 8,
                        Name       = "Mastery Page 8",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 9,
                        Name       = "Mastery Page 9",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 10,
                        Name       = "Mastery Page 10",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 11,
                        Name       = "Mastery Page 11",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 12,
                        Name       = "Mastery Page 12",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 13,
                        Name       = "Mastery Page 13",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 14,
                        Name       = "Mastery Page 14",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 15,
                        Name       = "Mastery Page 15",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 16,
                        Name       = "Mastery Page 16",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 17,
                        Name       = "Mastery Page 17",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 18,
                        Name       = "Mastery Page 18",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 19,
                        Name       = "Mastery Page 19",
                        Entries    = new ArrayCollection()
                    },
                    new MasteryBookPageDTO
                    {
                        Current    = false,
                        SummonerId = summonerSender._sumId,
                        PageId     = 20,
                        Name       = "Mastery Page 20",
                        Entries    = new ArrayCollection()
                    },
                }
            };

            e.ReturnRequired = true;
            e.Data           = MasteryBook;

            return(e);
        }
 private static void SaveRiotMasteryBook(MasteryBook book)
 {
   MasterySetup[] masterySetupArray = Enumerable.ToArray<MasterySetup>(Enumerable.Take<MasterySetup>((IEnumerable<MasterySetup>) (book.Setups ?? new MasterySetup[0]), 20));
   MasteryBookPageDTO[] masteryBookPageDtoArray = Enumerable.ToArray<MasteryBookPageDTO>(Enumerable.Select<MasterySetup, MasteryBookPageDTO>((IEnumerable<MasterySetup>) masterySetupArray, new Func<MasterySetup, MasteryBookPageDTO>(InventoryHelper.ToMasteryBookPage)));
   Dictionary<string, string[]> dictionary = Enumerable.ToDictionary<IGrouping<string, string>, string, string[]>((IEnumerable<IGrouping<string, string>>) Enumerable.ToLookup<string, string>(Enumerable.Select<MasteryBookPageDTO, string>((IEnumerable<MasteryBookPageDTO>) masteryBookPageDtoArray, (Func<MasteryBookPageDTO, 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 < masteryBookPageDtoArray.Length; ++index)
   {
     MasteryBookPageDTO masteryBookPageDto = masteryBookPageDtoArray[index];
     masteryBookPageDto.PageId = (double) (index + 1);
     if (string.IsNullOrEmpty(masteryBookPageDto.Name) || dictionary[masteryBookPageDto.Name].Length > 1)
       masteryBookPageDto.Name = string.Format("#{0:00}. {1}", (object) index, (object) masteryBookPageDto.Name);
     if (Enumerable.All<MasteryBookPageDTO>((IEnumerable<MasteryBookPageDTO>) masteryBookPageDtoArray, (Func<MasteryBookPageDTO, bool>) (x => !x.Current)) && masterySetupArray[index].Id == book.ActiveId)
       masteryBookPageDto.Current = true;
   }
   if (masteryBookPageDtoArray.Length > 0 && Enumerable.All<MasteryBookPageDTO>((IEnumerable<MasteryBookPageDTO>) masteryBookPageDtoArray, (Func<MasteryBookPageDTO, bool>) (x => !x.Current)))
     masteryBookPageDtoArray[0].Current = true;
   foreach (RiotAccount account in JsApiService.AccountBag.GetAll())
   {
     RiotAccount riotAccount = account;
     string destination = "masteryBookService";
     string method = "saveMasteryBook";
     MasteryBookDTO masteryBookDto1 = new MasteryBookDTO();
     masteryBookDto1.SummonerId = (double) account.SummonerId;
     masteryBookDto1.BookPages = Enumerable.ToList<MasteryBookPageDTO>((IEnumerable<MasteryBookPageDTO>) masteryBookPageDtoArray);
     MasteryBookDTO masteryBookDto2 = masteryBookDto1;
     riotAccount.InvokeAsync<object>(destination, method, (object) masteryBookDto2);
     InventoryHelper.ClearMasteryCache(account);
   }
 }
Beispiel #16
0
 /// <summary>
 /// Saves the mastery book
 /// </summary>
 /// <param name="masteryBookPage">The mastery book information</param>
 /// <returns>Returns the mastery book</returns>
 public Task <MasteryBookDTO> SaveMasteryBook(MasteryBookDTO masteryBookPage)
 {
     return(InvokeAsync <MasteryBookDTO>("saveMasteryBook", masteryBookPage));
 }