示例#1
0
 void RunTest(List <string> arguments)
 {
     string         summonerName   = GetSummonerName(arguments[0]);
     PublicSummoner publicSummoner = RPC.GetSummonerByName(summonerName);
     //SummonerLeaguesDTO league = RPC.GetAllLeaguesForPlayer(publicSummoner.summonerId);
     AllSummonerData data = RPC.GetAllSummonerDataByAccount(publicSummoner.acctId);
 }
示例#2
0
        public void SetStats(PublicSummoner summoner, PlayerLifetimeStats stats)
        {
            if (summoner == null || stats == null)
            {
                return;
            }

            if (InvokeRequired)
            {
                Invoke(new Action <PublicSummoner, PlayerLifetimeStats>(SetStats), summoner, stats);
                return;
            }

            SetLevel(summoner.SummonerLevel);
            RemoveAll(p => (p.Tag as string) == "Stats");

            foreach (var stat in stats.PlayerStatSummaries.PlayerStatSummarySet)
            {
                var sc = new StatsControl {
                    Dock = DockStyle.Fill, Tag = "Stats"
                };
                sc.SetStatSummary(stat);

                var tab = new TabPage(MinifyStatType(stat.PlayerStatSummaryType))
                {
                    BackColor = this.BackColor,
                    Tag       = "Stats"
                };
                tab.Controls.Add(sc);
                AddTab(tab);
            }
        }
示例#3
0
        private async Task <SummonerRuneInventory> GetUserRunesPage(string User)
        {
            PublicSummoner summoner = await RiotCalls.GetSummonerByName(User);

            SummonerRuneInventory runes = await RiotCalls.GetSummonerRuneInventory(summoner.SummonerId);

            return(runes);
        }
示例#4
0
        private async Task <MasteryBookDTO> GetUserMasterPage(string User)
        {
            PublicSummoner summoner = await RiotCalls.GetSummonerByName(User);

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

            return(page);
        }
示例#5
0
        private async void AddFriendButton_Click(object sender, RoutedEventArgs e)
        {
            PublicSummoner user = await RiotCalls.GetSummonerByName(FriendAddBox.Text);

            var Jid = new Jid("sum" + user.SummonerId, Client.XmppConnection.Server, "");

            Client.PresManager.Subscribe(Jid);
            FriendAddBox.Text = "";
        }
示例#6
0
		public async Task<PublicSummoner> GetSummonerByName(String summonerName)
		{
			int Id = Invoke("summonerService", "getSummonerByName", new object[] { summonerName });
			while (!results.ContainsKey(Id))
				await Task.Delay(10);
			TypedObject messageBody = results[Id].GetTO("data").GetTO("body");
			PublicSummoner result = new PublicSummoner(messageBody);
			results.Remove(Id);
			return result;
		}
示例#7
0
        private async void AddFriendButton_Click(object sender, RoutedEventArgs e)
        {
            PublicSummoner JID = await Client.PVPNet.GetSummonerByName(FriendAddBox.Text);

            var jid = new JID("sum" + JID.SummonerId, Client.ChatClient.Server, "");

            string[] groups = new List <String>(new[] { "Online" }).ToArray();
            Client.ChatClient.Subscribe(jid, "", groups);
            FriendAddBox.Text = "";
        }
示例#8
0
        private async void Load(RoomParticipant participant)
        {
            summoner = await Client.PVPNet.GetSummonerByName(participant.Nick);

            PlayerName.Content = summoner.Name;
            LevelLabel.Content = summoner.SummonerLevel;
            var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", summoner.ProfileIconId + ".png"), UriKind.RelativeOrAbsolute);

            ProfileImage.Source = new BitmapImage(uriSource);
        }
示例#9
0
        //Returns true if the summoner was updated successfully, false otherwise
        public OperationResult FindSummoner(string summonerName, ref Summoner outputSummoner)
        {
            if (!Connected)
            {
                return(OperationResult.NotConnected);
            }

            try
            {
                Summoner summoner = StatisticsService.GetSummoner(Region, summonerName);
                if (summoner != null)
                {
                    //The summoner is already in the database, don't update them, just provide the account ID
                    //This behaviour is more convenient for the general use case
                }
                else
                {
                    //The summoner name is not in the database
                    //Retrieve the account ID to see if it's actually a new summoner or just somebody who changed their name
                    PublicSummoner publicSummoner = RPC.GetSummonerByName(summonerName);
                    if (publicSummoner == null)
                    {
                        //No such summoner
                        return(OperationResult.NotFound);
                    }

                    using (var connection = Provider.GetConnection())
                    {
                        summoner = StatisticsService.GetSummoner(Region, publicSummoner.acctId);
                        if (summoner != null)
                        {
                            //It's a summoner who was already in the database, just their name changed
                            UpdateSummonerFields(summoner, connection);
                        }
                        else
                        {
                            //It's a new summoner
                            summoner = new Summoner(publicSummoner, Region);
                            InsertNewSummoner(summoner, connection);
                            StatisticsService.AddSummonerToCache(Region, summoner);
                        }
                    }
                }
                outputSummoner = summoner;
                return(OperationResult.Success);
            }
            catch (RPCTimeoutException)
            {
                return(OperationResult.Timeout);
            }
            catch (RPCNotConnectedException)
            {
                return(OperationResult.NotConnected);
            }
        }
示例#10
0
        private async void Download_Click(object sender, RoutedEventArgs e)
        {
            if (User)
            {
                PublicSummoner summoner = await RiotCalls.GetSummonerByName(Command.Text);

                if (string.IsNullOrWhiteSpace(summoner.Name))
                {
                    var overlay = new MessageOverlay
                    {
                        MessageTitle   = { Content = "No Summoner Found" },
                        MessageTextBox = { Text = "The summoner \"" + Command.Text + "\" does not exist." }
                    };
                    Client.OverlayContainer.Content    = overlay.Content;
                    Client.OverlayContainer.Visibility = Visibility.Visible;

                    return;
                }
                HintLabel.Content    = "retrieving replay";
                HintLabel.Visibility = Visibility.Visible;
                var fadeLabelInAnimationx = new DoubleAnimation(1, TimeSpan.FromSeconds(0.1));
                HintLabel.BeginAnimation(OpacityProperty, fadeLabelInAnimationx);
                PlatformGameLifecycleDTO n = await RiotCalls.RetrieveInProgressSpectatorGameInfo(Command.Text);

                if (n == null)
                {
                    var overlay = new MessageOverlay
                    {
                        MessageTitle   = { Content = "No Game Found" },
                        MessageTextBox = { Text = "The summoner \"" + Command.Text + "\" is not currently in game." }
                    };
                    Client.OverlayContainer.Content    = overlay.Content;
                    Client.OverlayContainer.Visibility = Visibility.Visible;

                    return;
                }
                if (n.GameName != null)
                {
                    string ip     = n.PlayerCredentials.ObserverServerIp + ":" + n.PlayerCredentials.ObserverServerPort;
                    string key    = n.PlayerCredentials.ObserverEncryptionKey;
                    var    gameId = (int)n.PlayerCredentials.GameId;
                    recorder = new ReplayRecorder(ip, gameId, Client.Region.InternalName, key);
                    recorder.OnReplayRecorded += recorder_OnReplayRecorded;
                    recorder.OnGotChunk       += recorder_OnGotChunk;

                    var fadeGridOutAnimation = new DoubleAnimation(0, TimeSpan.FromSeconds(0.1));
                    Command.Visibility   = Visibility.Hidden;
                    Download.Visibility  = Visibility.Hidden;
                    HintLabel.Visibility = Visibility.Visible;
                    HintLabel.Content    = "Starting replay download";
                }
                HintLabel.Content    = "That player is not in a game";
                HintLabel.Visibility = Visibility.Visible;
            }
        }
示例#11
0
        private async void Download_Click(object sender, RoutedEventArgs e)
        {
            if (User == true)
            {
                PublicSummoner Summoner = await Client.PVPNet.GetSummonerByName(Command.Text);

                if (String.IsNullOrWhiteSpace(Summoner.Name))
                {
                    MessageOverlay overlay = new MessageOverlay();
                    overlay.MessageTitle.Content       = "No Summoner Found";
                    overlay.MessageTextBox.Text        = "The summoner \"" + Command.Text + "\" does not exist.";
                    Client.OverlayContainer.Content    = overlay.Content;
                    Client.OverlayContainer.Visibility = Visibility.Visible;
                    return;
                }
                HintLabel.Content    = "retrieving replay";
                HintLabel.Visibility = Visibility.Visible;
                var fadeLabelInAnimationx = new DoubleAnimation(1, TimeSpan.FromSeconds(0.1));
                HintLabel.BeginAnimation(Label.OpacityProperty, fadeLabelInAnimationx);
                PlatformGameLifecycleDTO n = await Client.PVPNet.RetrieveInProgressSpectatorGameInfo(Command.Text);

                if (n.GameName != null)
                {
                    int    port = n.PlayerCredentials.ServerPort;
                    string IP;
                    if (port == 0)
                    {
                        IP = n.PlayerCredentials.ObserverServerIp + ":8088";
                    }
                    else
                    {
                        IP = n.PlayerCredentials.ObserverServerIp + ":" + port;
                    }
                    string Key    = n.PlayerCredentials.ObserverEncryptionKey;
                    int    GameID = (Int32)n.PlayerCredentials.GameId;
                    recorder = new ReplayRecorder(IP, GameID, Client.Region.InternalName, Key);
                    recorder.OnReplayRecorded += recorder_OnReplayRecorded;
                    recorder.OnGotChunk       += recorder_OnGotChunk;

                    var fadeGridOutAnimation = new DoubleAnimation(0, TimeSpan.FromSeconds(0.1));
                    Command.Visibility   = Visibility.Hidden;
                    Download.Visibility  = Visibility.Hidden;
                    HintLabel.Visibility = Visibility.Visible;
                    HintLabel.Content    = "Starting replay download";
                    return;
                }
                else
                {
                    HintLabel.Content    = "That player is not in a game";
                    HintLabel.Visibility = Visibility.Visible;
                    return;
                }
            }
        }
示例#12
0
        public SummonerSummary(PublicSummoner pub)
        {
            InternalName = pub.InternalName;
            SummonerId   = pub.SummonerId;
            AccountId    = pub.AcctId;

            Name = pub.Name;

            Level = pub.SummonerLevel;
            Icon  = pub.ProfileIconId;
        }
示例#13
0
        bool GetRecentGames(string summonerName, ref PublicSummoner publicSummoner, ref List <PlayerGameStats> recentGames)
        {
            publicSummoner = RPC.GetSummonerByName(summonerName);
            if (publicSummoner == null)
            {
                return(false);
            }
            RecentGames recentGameData = RPC.GetRecentGames(publicSummoner.acctId);

            recentGames = recentGameData.gameStatistics;
            recentGames.Sort(CompareGames);
            return(true);
        }
示例#14
0
        private static async Task <bool> IsUserValid(string Username)
        {
            PublicSummoner sum = await RiotCalls.GetSummonerByName(Username);

            if (string.IsNullOrEmpty(sum.Name))
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
示例#15
0
        private async void LeaguesListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (LeaguesListView.SelectedItem != null)
            {
                LeagueItem item = (LeagueItem)LeaguesListView.SelectedItem;
                TopChampionsListView.Items.Clear();
                PublicSummoner x = await RiotCalls.GetSummonerByName((string)item.PlayerLabel.Content);

                AggregatedStats stats = await RiotCalls.GetAggregatedStats(x.AcctId, "CLASSIC", Client.LoginPacket.ClientSystemStates.currentSeason.ToString());

                GotStats(stats);
                PlayerLabel.Content = item.PlayerLabel.Content;
            }
        }
示例#16
0
        private async void RemoveFriend_Click(object sender, RoutedEventArgs e)
        {
            if (LastPlayerItem != null)
            {
                PublicSummoner sum = await RiotCalls.GetSummonerByName(LastPlayerItem.Username);

                var Jid = new Jid("sum" + sum.SummonerId, Client.XmppConnection.Server, "");
                Client.PresManager.Unsubscribe(Jid);
                //Client.PresManager.Remove(Jid);
                Client.AllPlayers.Remove(Jid.User);
                Client.UpdatePlayers = true;
                UpdateChat(null, null);
            }
        }
示例#17
0
        public async Task <PublicSummoner> GetSummonerByName(String summonerName)
        {
            int Id = Invoke("summonerService", "getSummonerByName", new object[] { summonerName });

            while (!results.ContainsKey(Id))
            {
                await Task.Delay(10);
            }
            TypedObject    messageBody = results[Id].GetTO("data").GetTO("body");
            PublicSummoner result      = new PublicSummoner(messageBody);

            results.Remove(Id);
            return(result);
        }
示例#18
0
        private async void LeaguesListView_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            if (LeaguesListView.SelectedItem == null)
            {
                return;
            }

            var item = (LeagueItem)LeaguesListView.SelectedItem;

            PlayerLabel.Content = item.PlayerLabel.Content;
            PublicSummoner x = await Client.PVPNet.GetSummonerByName((string)item.PlayerLabel.Content);

            Client.PVPNet.GetAggregatedStats(x.AcctId, "CLASSIC", "3", GotStats);
        }
示例#19
0
        private async void RemoveFriend_Click(object sender, RoutedEventArgs e)
        {
            if (LastPlayerItem != null)
            {
                PublicSummoner JID = await Client.PVPNet.GetSummonerByName(LastPlayerItem.Username);

                var jid = new JID("sum" + JID.SummonerId, Client.ChatClient.Server, "");
                Client.ChatClient.RemoveRosterItem(jid);
                Client.RostManager.Remove(jid);
                Client.AllPlayers.Remove(jid.User);
                Client.UpdatePlayers = true;
                UpdateChat(null, null);
            }
        }
示例#20
0
        public void SetStats(PublicSummoner summoner, SummonerLeaguesDTO leagueInfo, PlayerLifetimeStats stats)
        {
            if (summoner == null || stats == null)
            {
                return;
            }

            if (InvokeRequired)
            {
                Invoke(new Action <PublicSummoner, SummonerLeaguesDTO, PlayerLifetimeStats>(SetStats), summoner, leagueInfo, stats);
                return;
            }

            RemoveAll(p => (p.Tag as string) == "Stats");

            var nameMap = new Dictionary <string, string>()
            {
                { "RankedSolo5x5", "RANKED_SOLO_5x5" },
                { "RankedTeam5x5", "RANKED_TEAM_5x5" },
                { "RankedTeam3x3", "RANKED_TEAM_3x3" }
            };

            foreach (var stat in stats.PlayerStatSummaries.PlayerStatSummarySet)
            {
                var sc = new StatsControl {
                    Dock = DockStyle.Fill, Tag = "Stats"
                };

                Dictionary <string, object> queueInfo = null;
                if (leagueInfo != null)
                {
                    string queueType;
                    if (nameMap.TryGetValue(stat.PlayerStatSummaryTypeString, out queueType))
                    {
                        queueInfo = leagueInfo.GetQueueByName(queueType);
                    }
                }

                sc.SetStatSummary(stat, SummonerLeaguesDTO.GetRanking(queueInfo));

                var tab = new TabPage(MinifyStatType(stat.PlayerStatSummaryType))
                {
                    BackColor = this.BackColor,
                    Tag       = "Stats"
                };
                tab.Controls.Add(sc);
                AddTab(tab);
            }
        }
示例#21
0
        void RankedStatistics(List <string> arguments, bool sortByGames, bool currentOnly)
        {
            string         summonerName   = GetSummonerName(arguments[0]);
            PublicSummoner publicSummoner = RPC.GetSummonerByName(summonerName);

            if (publicSummoner == null)
            {
                NoSuchSummoner();
                return;
            }
            string[] seasonStrings =
            {
                "CURRENT",
                "TWO",
                "ONE",
            };

            foreach (string seasonString in seasonStrings)
            {
                Output.WriteLine("Season: \"{0}\"", seasonString);
                AggregatedStats aggregatedStatistics = RPC.GetAggregatedStats(publicSummoner.acctId, "CLASSIC", seasonString);
                if (aggregatedStatistics == null)
                {
                    Output.WriteLine("Unable to retrieve aggregated statistics");
                    return;
                }
                List <ChampionStatistics> statistics = ChampionStatistics.GetChampionStatistics(aggregatedStatistics);
                foreach (var entry in statistics)
                {
                    entry.Name = GetChampionName(entry.ChampionId);
                }
                if (sortByGames)
                {
                    statistics.Sort(CompareChampionGames);
                }
                else
                {
                    statistics.Sort(CompareChampionNames);
                }
                foreach (var entry in statistics)
                {
                    Output.WriteLine("{0}: {1} {2}, {3}/{4}/{5} ({6})", entry.Name, entry.Games, entry.Games == 1 ? "game" : "games", Round(entry.KillsPerGame()), Round(entry.DeathsPerGame()), Round(entry.AssistsPerGame()), Round(entry.KillsAndAssistsPerDeath()));
                }
                if (currentOnly)
                {
                    break;
                }
            }
        }
示例#22
0
        private async void refreshRoom()
        {
            ParticipantList.Items.Clear();
            foreach (RoomParticipant par in newRoom.Participants)
            {
                GroupChatPlayer player = new GroupChatPlayer();
                player.SName.Content = par.Nick;
                PublicSummoner summoner = await Client.PVPNet.GetSummonerByName(par.Nick);

                var uriSource = System.IO.Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", summoner.ProfileIconId + ".png");
                player.sIcon.Source = Client.GetImage(uriSource);
                ParticipantList.Items.Add(player);
                //add to ParticipantList
            }
            ParticipantList.Items.Refresh();
        }
示例#23
0
 private async void GroupChatClient_OnParticipantJoin(Room room, RoomParticipant participant)
 {
     await Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() =>
     {
         TextRange tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd);
         tr.Text = participant.Nick + " joined the room." + Environment.NewLine;
         tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.Yellow);
         ChatText.ScrollToEnd();
         var x = new GroupChatPlayer();
         x.SName.Content = participant.Nick;
         PublicSummoner summoner = await Client.PVPNet.GetSummonerByName(participant.Nick);
         var uriSource = System.IO.Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", summoner.ProfileIconId + ".png");
         x.sIcon.Source = Client.GetImage(uriSource);
         ParticipantList.Items.Add(x);
         ParticipantList.Items.Refresh();
     }));
 }
示例#24
0
        void AnalyseSummonerId(List <string> arguments)
        {
            int        summonerId  = Convert.ToInt32(arguments[0]);
            List <int> summonerIds = new List <int>();

            summonerIds.Add(summonerId);
            var names = RPC.GetSummonerNames(summonerIds);

            if (names == null)
            {
                Console.WriteLine("Invalid ID");
                return;
            }
            foreach (var name in names)
            {
                PublicSummoner publicSummoner = RPC.GetSummonerByName(name);
                Console.WriteLine("{0} ({1})", publicSummoner.name, publicSummoner.acctId);
            }
        }
示例#25
0
        void RunePages(List <string> arguments)
        {
            string         summonerName = GetSummonerName(arguments[0]);
            PublicSummoner summoner     = RPC.GetSummonerByName(summonerName);

            if (summoner == null)
            {
                NoSuchSummoner();
                return;
            }

            AllPublicSummonerDataDTO allSummonerData = RPC.GetAllPublicSummonerDataByAccount(summoner.acctId);

            if (allSummonerData == null)
            {
                Console.WriteLine("Unable to retrieve all public summoner data");
                return;
            }

            if (allSummonerData.spellBook == null)
            {
                Console.WriteLine("Spell book not available");
                return;
            }

            if (allSummonerData.spellBook.bookPages == null)
            {
                Console.WriteLine("Spell book pages not available");
                return;
            }

            foreach (var page in allSummonerData.spellBook.bookPages)
            {
                Console.WriteLine("[{0}] {1} ({2})", page.createDate, page.name, page.current ? "active" : "not active");
                foreach (var slot in page.slotEntries)
                {
                    Console.WriteLine("Slot {0}: {1}", slot.runeSlotId, slot.runeId);
                }
            }
        }
示例#26
0
        public void SetLeagueInfo(PublicSummoner summoner, SummonerLeaguesDTO leagueInfo)
        {
            if (summoner == null || leagueInfo == null)
            {
                return;
            }

            if (InvokeRequired)
            {
                Invoke(new Action <PublicSummoner, SummonerLeaguesDTO>(SetLeagueInfo), summoner, leagueInfo);
                return;
            }
            foreach (var entry in leagueInfo.summonerLeagues)
            {
                foreach (var entry2 in entry.entries)
                {
                    if (entry2.PlayerOrTeamName.Equals(summoner.Name))
                    {
                        division.Text = entry2.Tier + "." + ToInt(entry2.Rank) + "." + entry2.LeaguePoints;
                        return;
                    }
                }
            }
        }
示例#27
0
        public void Initialise(PublicSummoner publicSummoner, RegionType summonerRegion)
        {
            //Id cannot be set yet

            Region = summonerRegion;

            AccountId  = publicSummoner.acctId;
            SummonerId = publicSummoner.summonerId;

            SummonerName = publicSummoner.name;
            InternalName = publicSummoner.internalName;

            SummonerLevel = publicSummoner.summonerLevel;
            ProfileIcon   = publicSummoner.profileIconId;

            HasBeenUpdated = false;

            UpdateAutomatically = false;

            int time = (int)Time.UnixTime();

            TimeCreated = time;
            TimeUpdated = time;
        }
示例#28
0
        async void LoadName(string Name)
        {
            PublicSummoner summoner = await Client.PVPNet.GetSummonerByName(Name);

            await Load(summoner.AcctId);
        }
示例#29
0
        private void RenderLobbyData()
        {
            try
            {
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() =>
                {
                    CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                    TextInfo textInfo       = cultureInfo.TextInfo;

                    Client.InviteListView.Items.Clear();
                    TeamListView.Items.Clear();
                    IsOwner = false;

                    if (CurrentLobby.Owner.SummonerName == Client.LoginPacket.AllSummonerData.Summoner.Name)
                    {
                        IsOwner = true;
                    }

                    foreach (Invitee statsx in CurrentLobby.Invitees)
                    {
                        var InviteeState                 = string.Format(statsx.inviteeState.ToLower());
                        var InviteeStateTitleCase        = textInfo.ToTitleCase(InviteeState);
                        InvitePlayer invitePlayer        = new InvitePlayer();
                        invitePlayer.StatusLabel.Content = InviteeStateTitleCase;
                        invitePlayer.PlayerLabel.Content = statsx.SummonerName;
                        Client.InviteListView.Items.Add(invitePlayer);
                    }

                    if (IsOwner == true)
                    {
                        InviteButton.IsEnabled    = true;
                        StartGameButton.IsEnabled = true;
                        Client.isOwnerOfGame      = true;
                    }
                    else if (IsOwner == false)
                    {
                        InviteButton.IsEnabled    = false;
                        StartGameButton.IsEnabled = false;
                        Client.isOwnerOfGame      = false;
                    }
                    invitationRequest m = JsonConvert.DeserializeObject <invitationRequest>(CurrentLobby.GameData);
                    queueId             = m.queueId;
                    isRanked            = m.isRanked;
                    rankedTeamName      = m.rankedTeamName;
                    mapId            = m.mapId;
                    gameTypeConfigId = m.gameTypeConfigId;
                    gameMode         = m.gameMode;
                    gameType         = m.gameType;

                    foreach (Member stats in CurrentLobby.Members)
                    {
                        //Your kidding me right
                        TeamControl TeamPlayer         = new TeamControl();
                        TeamPlayerStats                = TeamPlayer;
                        TeamPlayer.Name.Content        = stats.SummonerName;
                        TeamPlayer.SumID.Content       = stats.SummonerName;
                        TeamPlayer.Kick.Tag            = stats;
                        TeamPlayer.Inviter.Tag         = stats;
                        TeamPlayer.Profile.Tag         = stats;
                        TeamPlayer.Owner.Tag           = stats;
                        TeamPlayer.HorizontalAlignment = HorizontalAlignment.Stretch;

                        TeamPlayer.Kick.Click    += Kick_Click;
                        TeamPlayer.Inviter.Click += Inviter_Click;
                        TeamPlayer.Profile.Click += Profile_Click;
                        TeamPlayer.Owner.Click   += Owner_Click;

                        PublicSummoner Summoner = await Client.PVPNet.GetSummonerByName(stats.SummonerName);

                        //Populate the ProfileIcon
                        int ProfileIconID = Summoner.ProfileIconId;
                        var uriSource     = System.IO.Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", ProfileIconID + ".png");

                        TeamPlayer.ProfileIcon.Source = Client.GetImage(uriSource);

                        //Make it so you cant kick yourself
                        if (stats.SummonerName == Client.LoginPacket.AllSummonerData.Summoner.Name)
                        {
                            TeamPlayer.Kick.Visibility    = Visibility.Hidden;
                            TeamPlayer.Inviter.Visibility = Visibility.Hidden;
                            TeamPlayer.Profile.Visibility = Visibility.Hidden;
                            TeamPlayer.Owner.Visibility   = Visibility.Hidden;
                            if (stats.hasDelegatedInvitePower == true && IsOwner == false)
                            {
                                InviteButton.IsEnabled = true;
                            }
                            else if (stats.hasDelegatedInvitePower == false && IsOwner == false)
                            {
                                InviteButton.IsEnabled = false;
                            }
                        }
                        if (IsOwner == false)
                        {
                            //So you don't crash trying to kick someone when you can't
                            TeamPlayer.Kick.Visibility    = Visibility.Hidden;
                            TeamPlayer.Inviter.Visibility = Visibility.Hidden;
                            TeamPlayer.Owner.Visibility   = Visibility.Hidden;
                        }
                        TeamListView.Items.Add(TeamPlayer);
                    }
                }));
            }
            catch { }
        }
示例#30
0
        /// <summary>
        /// Loads the particiapants for the game
        /// </summary>
        /// <param name="allParticipants"></param>
        /// <param name="n"></param>
        /// <param name="list"></param>
        private async void LoadPar(List <Participant> allParticipants, PlatformGameLifecycleDTO n, ListView list)
        {
            bool isYourTeam = false;

            list.Items.Clear();
            list.Items.Refresh();
            try
            {
                string mmrJson;
                string url = Client.Region.SpectatorLink + "consumer/getGameMetaData/" + Client.Region.InternalName +
                             "/" + n.Game.Id + "/token";
                using (var client = new WebClient())
                    mmrJson = client.DownloadString(url);

                var serializer       = new JavaScriptSerializer();
                var deserializedJson = serializer.Deserialize <Dictionary <string, object> >(mmrJson);
                MMRLabel.Content = "Game MMR ≈ " + deserializedJson["interestScore"];
            }
            catch
            {
                MMRLabel.Content = "Unable to calculate Game MMR";
            }

            foreach (Participant par in allParticipants)
            {
                if (par is PlayerParticipant)
                {
                    PublicSummoner scoutersum = await RiotCalls.GetSummonerByName(GSUsername);

                    if ((par as PlayerParticipant).AccountId == scoutersum.AcctId)
                    {
                        isYourTeam = true;
                    }
                }
            }
            foreach (Participant par in allParticipants)
            {
                if (par is PlayerParticipant)
                {
                    var participant = par as PlayerParticipant;
                    foreach (PlayerChampionSelectionDTO championSelect in n.Game.PlayerChampionSelections.Where(championSelect =>
                                                                                                                championSelect.SummonerInternalName == participant.SummonerInternalName))
                    {
                        GameScouterPlayer control = new GameScouterPlayer();
                        control.Tag = championSelect;
                        GameStats   = new List <MatchStats>();
                        control.Username.Content = championSelect.SummonerInternalName;
                        //Make it so you can see yourself
                        if (championSelect.SummonerInternalName == GSUsername)
                        {
                            control.Username.Foreground = (Brush)(new BrushConverter().ConvertFrom("#FF007A53"));
                        }
                        control.ChampIcon.Source = champions.GetChampion(championSelect.ChampionId).icon;
                        if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id)))))
                        {
                            var UriSource = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id))), UriKind.Absolute);
                            control.SumIcon1.Source = new BitmapImage(UriSource);
                        }
                        if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id)))))
                        {
                            var UriSource = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))), UriKind.Absolute);
                            control.SumIcon2.Source = new BitmapImage(UriSource);
                        }
                        GameStats.Clear();
                        try
                        {
                            PublicSummoner summoner = await RiotCalls.GetSummonerByName(championSelect.SummonerInternalName.Replace("summoner", string.Empty));

                            if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", summoner.ProfileIconId.ToString() + ".png")))
                            {
                                control.ProfileIcon.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", summoner.ProfileIconId.ToString() + ".png"));
                            }
                            RecentGames result = await RiotCalls.GetRecentGames(summoner.AcctId);

                            result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate));
                            foreach (PlayerGameStats game in result.GameStatistics)
                            {
                                game.GameType = Client.TitleCaseString(game.GameType.Replace("_GAME", "").Replace("MATCHED", "NORMAL"));
                                var match = new MatchStats();

                                foreach (RawStat stat in game.Statistics)
                                {
                                    Type      type      = typeof(MatchStats);
                                    string    fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", "");
                                    FieldInfo f         = type.GetField(fieldName);
                                    f.SetValue(match, stat.Value);
                                }
                                match.Game = game;
                                GameStats.Add(match);
                            }
                            int Kills, ChampKills;
                            int Deaths, ChampDeaths;
                            int Assists, ChampAssists;
                            int GamesPlayed, ChampGamesPlayed;
                            Kills = 0; Deaths = 0; Assists = 0; GamesPlayed = 0; ChampKills = 0; ChampDeaths = 0; ChampAssists = 0; ChampGamesPlayed = 0;
                            //Load average KDA for past 20 games if possible
                            foreach (MatchStats stats in GameStats)
                            {
                                champions gameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId));
                                Kills   = Kills + (int)stats.ChampionsKilled;
                                Deaths  = Deaths + (int)stats.NumDeaths;
                                Assists = Assists + (int)stats.Assists;
                                GamesPlayed++;
                                if (championSelect.ChampionId == (int)Math.Round(stats.Game.ChampionId))
                                {
                                    ChampKills   = ChampKills + (int)stats.ChampionsKilled;
                                    ChampDeaths  = ChampDeaths + (int)stats.NumDeaths;
                                    ChampAssists = ChampAssists + (int)stats.Assists;
                                    ChampGamesPlayed++;
                                }
                            }
                            //GetKDA string
                            string KDAString = string.Format("{0}/{1}/{2}",
                                                             (Kills / GamesPlayed),
                                                             (Deaths / GamesPlayed),
                                                             (Assists / GamesPlayed));
                            string ChampKDAString = "";
                            try
                            {
                                ChampKDAString = string.Format("{0}/{1}/{2}",
                                                               (ChampKills / ChampGamesPlayed),
                                                               (ChampDeaths / ChampGamesPlayed),
                                                               (ChampAssists / ChampGamesPlayed));
                            }
                            catch { }

                            if (ChampGamesPlayed == 0)
                            {
                                ChampKDAString = "No Games lately";
                            }
                            control.AverageKDA.Content      = KDAString;
                            control.ChampAverageKDA.Content = ChampKDAString;
                            BrushConverter bc = new BrushConverter();
                            if (isYourTeam)
                            {
                                bc = new BrushConverter();
                                if (ChampKills < ChampDeaths)
                                {
                                    control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C");
                                }
                                else if (ChampKills == ChampDeaths)
                                {
                                    control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D");
                                }
                                else
                                {
                                    control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E");
                                }

                                bc = new BrushConverter();
                                if (Kills < Deaths)
                                {
                                    control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C");
                                }
                                else if (Kills == Deaths)
                                {
                                    control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D");
                                }
                                else
                                {
                                    control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E");
                                }
                            }
                            else
                            {
                                bc = new BrushConverter();
                                if (ChampKills > ChampDeaths)
                                {
                                    control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C");
                                }
                                else if (ChampKills == ChampDeaths)
                                {
                                    control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D");
                                }
                                else
                                {
                                    control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E");
                                }

                                bc = new BrushConverter();
                                if (Kills > Deaths)
                                {
                                    control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C");
                                }
                                else if (Kills == Deaths)
                                {
                                    control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D");
                                }
                                else
                                {
                                    control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E");
                                }
                            }
                        }
                        catch
                        {
                            Client.Log("Failed to get stats about player", "GAME_SCOUTER_ERROR");
                        }
                        if (participant.TeamParticipantId != null)
                        {
                            try
                            {
                                Brush myColor = color[(double)participant.TeamParticipantId];
                                control.QueueTeamColor.Fill       = myColor;
                                control.QueueTeamColor.Visibility = Visibility.Visible;
                            }
                            catch
                            {
                                BrushConverter bc    = new BrushConverter();
                                Brush          brush = Brushes.White;
                                //I know that there is a better way in the InGamePage
                                //I find that sometimes the colors (colours) are very hard to distinguish from eachother
                                //This makes sure that each color is easy to see
                                //because of hexa hill I put 12 in just in case
                                switch (ColorId)
                                {
                                case 0:
                                    //blue
                                    brush = (Brush)bc.ConvertFrom("#FF00E8FF");
                                    break;

                                case 2:
                                    //Lime Green
                                    brush = (Brush)bc.ConvertFrom("#FF00FF00");
                                    break;

                                case 3:
                                    //Yellow
                                    brush = (Brush)bc.ConvertFrom("#FFFFFF00");
                                    break;

                                case 4:
                                    //Blue Green
                                    brush = (Brush)bc.ConvertFrom("#FF007A53");
                                    break;

                                case 5:
                                    //Purple
                                    brush = (Brush)bc.ConvertFrom("#FF5100FF");
                                    break;

                                case 6:
                                    //Pink
                                    brush = (Brush)bc.ConvertFrom("#FFCB46C5");
                                    break;

                                case 7:
                                    //Dark Green
                                    brush = (Brush)bc.ConvertFrom("#FF006409");
                                    break;

                                case 8:
                                    //Brown
                                    brush = (Brush)bc.ConvertFrom("#FF643200");
                                    break;

                                case 9:
                                    //White
                                    brush = (Brush)bc.ConvertFrom("#FFFFFFFF");
                                    break;

                                case 10:
                                    //Grey
                                    brush = (Brush)bc.ConvertFrom("#FF363636");
                                    break;

                                case 11:
                                    //Red Pink
                                    brush = (Brush)bc.ConvertFrom("#FF8F4242");
                                    break;

                                case 12:
                                    //Grey Blue
                                    brush = (Brush)bc.ConvertFrom("#FFFF0000");
                                    break;
                                }
                                color.Add((double)participant.TeamParticipantId, brush);
                                ColorId++;
                                control.QueueTeamColor.Fill       = brush;
                                control.QueueTeamColor.Visibility = Visibility.Visible;
                            }
                        }
                        //control.MouseMove += controlMouseEnter;
                        control.MouseEnter += controlMouseEnter;
                        control.MouseLeave += control_MouseLeave;
                        control.MouseDown  += control_MouseDown;
                        TinyRuneMasteryData smallData = new TinyRuneMasteryData();
                        //Now store data in the tags so that all of the event handlers work
                        Dictionary <string, object> data = new Dictionary <string, object>();
                        data.Add("MasteryDataControl", smallData);
                        data.Add("RuneData", await GetUserRunesPage(GSUsername));
                        data.Add("MasteryData", await GetUserRunesPage(GSUsername));
                        control.Tag = data;
                        list.Items.Add(control);
                    }
                }
            }
        }
        private async void ChampPlayer_MouseOver(object sender, MouseEventArgs e)
        {
            if (Client.TrueCurrentPage.GetType() != typeof(ChampSelectPage) ||
                PlayerName.Content.ToString().StartsWith("Summoner "))
            {
                return;
            }

            try
            {
                if (_stats == null)
                {
                    _stats = new PlayerStatisticsChampSelect();
                    PublicSummoner summoner = await Client.PVPNet.GetSummonerByName(PlayerName.Content.ToString());

                    if (summoner == null || _stats == null || summoner.InternalName.Contains("bot"))
                    {
                        _stats = null;
                        return;
                    }
                    ChampionStatInfo[] topChampions =
                        await Client.PVPNet.RetrieveTopPlayedChampions(summoner.AcctId, "CLASSIC");

                    _stats.PlayerName.Content = summoner.Name;

                    if (topChampions.Length > 0)
                    {
                        _stats.MostPlayed.Source = champions.GetChampion((int)topChampions[0].ChampionId).icon;
                        _stats.Champion1.Content =
                            champions.GetChampion((int)topChampions[0].ChampionId).displayName + " - Games: " +
                            topChampions[0].TotalGamesPlayed;
                        double wins  = 0.0;
                        double total = 0.0;
                        foreach (AggregatedStat stat in topChampions[0].Stats)
                        {
                            switch (stat.StatType)
                            {
                            case "TOTAL_SESSIONS_WON":
                                wins = stat.Value;
                                break;

                            case "TOTAL_SESSIONS_PLAYED":
                                total = stat.Value;
                                break;
                            }
                        }

                        if ((Math.Abs(wins / total * 100.0) > 0) && Math.Abs(total) > 0)
                        {
                            _stats.Champ1ProgressBar.Value = wins / total * 100.0;
                        }
                        else
                        {
                            _stats.Champ1ProgressBar.Visibility = Visibility.Hidden;
                        }
                    }
                    else
                    {
                        _stats.Champ1ProgressBar.Visibility = Visibility.Hidden;
                        _stats.Champion1.Visibility         = Visibility.Hidden;
                    }

                    if (topChampions.Length > 1)
                    {
                        _stats.Champion2.Content =
                            champions.GetChampion((int)topChampions[1].ChampionId).displayName + " - Games: " +
                            topChampions[1].TotalGamesPlayed;
                        double wins  = 0.0;
                        double total = 0.0;
                        foreach (AggregatedStat stat in topChampions[1].Stats)
                        {
                            if (stat.StatType == "TOTAL_SESSIONS_WON")
                            {
                                wins = stat.Value;
                            }
                            else if (stat.StatType == "TOTAL_SESSIONS_PLAYED")
                            {
                                total = stat.Value;
                            }
                        }

                        if ((Math.Abs(wins / total * 100.0) > 0) && Math.Abs(total) > 0)
                        {
                            _stats.Champ2ProgressBar.Value = wins / total * 100.0;
                        }
                        else
                        {
                            _stats.Champ2ProgressBar.Visibility = Visibility.Hidden;
                        }
                    }
                    else
                    {
                        _stats.Champ2ProgressBar.Visibility = Visibility.Hidden;
                        _stats.Champion2.Visibility         = Visibility.Hidden;
                    }

                    if (topChampions.Length > 2)
                    {
                        _stats.Champion3.Content =
                            champions.GetChampion((int)topChampions[2].ChampionId).displayName + " - Games: " +
                            topChampions[2].TotalGamesPlayed;
                        double wins  = 0.0;
                        double total = 0.0;
                        foreach (AggregatedStat stat in topChampions[2].Stats)
                        {
                            if (stat.StatType == "TOTAL_SESSIONS_WON")
                            {
                                wins = stat.Value;
                            }
                            else if (stat.StatType == "TOTAL_SESSIONS_PLAYED")
                            {
                                total = stat.Value;
                            }
                        }

                        if ((Math.Abs(wins / total * 100.0) > 0) && Math.Abs(total) > 0)
                        {
                            _stats.Champ3ProgressBar.Value = wins / total * 100.0;
                        }
                        else
                        {
                            _stats.Champ3ProgressBar.Visibility = Visibility.Hidden;
                        }
                    }
                    else
                    {
                        _stats.Champ3ProgressBar.Visibility = Visibility.Hidden;
                        _stats.Champion3.Visibility         = Visibility.Hidden;
                    }
                    Client.MainGrid.Children.Add(_stats);
                }
                Point  mouseLocation = e.GetPosition(Client.MainGrid);
                double yMargin       = mouseLocation.Y - 25;
                if (Mouse.GetPosition(Client.MainGrid).X < 200)
                {
                    _stats.HorizontalAlignment = HorizontalAlignment.Left;
                    _stats.VerticalAlignment   = VerticalAlignment.Top;
                    _stats.Margin = new Thickness(142, yMargin, 0, 0);
                }
                else
                {
                    _stats.HorizontalAlignment = HorizontalAlignment.Right;
                    _stats.VerticalAlignment   = VerticalAlignment.Top;
                    _stats.Margin = new Thickness(0, yMargin, 155, 0);
                }
            }
            catch (Exception)
            {
            }
        }
示例#32
0
		public void GetSummonerByName(String summonerName, PublicSummoner.Callback callback)
		{
			PublicSummoner cb = new PublicSummoner(callback);
			InvokeWithCallback("summonerService", "getSummonerByName", new object[] { summonerName }, cb);
		}