public static List <invitationRequest> PopulateGameInviteJson()
        {
            List <invitationRequest> ItemList = new List <invitationRequest>();

            PVPNetConnect.RiotObjects.Gameinvite.Contract.InvitationRequest Invite = new PVPNetConnect.RiotObjects.Gameinvite.Contract.InvitationRequest();
            if (Invite.GameMetaData != null)
            {
                string itemJSON = File.ReadAllText(Invite.GameMetaData);
                JavaScriptSerializer        serializer       = new JavaScriptSerializer();
                Dictionary <string, object> deserializedJSON = serializer.Deserialize <Dictionary <string, object> >(itemJSON);
                Dictionary <string, object> itemData         = deserializedJSON["data"] as Dictionary <string, object>;

                foreach (KeyValuePair <string, object> item in itemData)
                {
                    invitationRequest           newItem          = new invitationRequest();
                    Dictionary <string, object> singularItemData = item.Value as Dictionary <string, object>;
                    newItem.queueId          = singularItemData["queueId"] as int?;
                    newItem.isRanked         = singularItemData["isRanked"] as bool?;
                    newItem.rankedTeamName   = singularItemData["rankedTeamName"] as string;
                    newItem.mapId            = singularItemData["mapId"] as int?;
                    newItem.gameTypeConfigId = singularItemData["gameTypeConfigId"] as int?;
                    newItem.gameMode         = singularItemData["gameMode"] as string;
                    newItem.gameType         = singularItemData["gameType"] as string;

                    ItemList.Add(newItem);
                }
            }


            return(ItemList);
        }
        private void UpdateData()
        {
            foreach (KeyValuePair <String, InviteInfo> info in Client.InviteData)
            {
                InviteInfo data = info.Value;
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    ChatListView.Items.Clear();
                    InvitesNotification notification = new InvitesNotification();
                    notification.Accept.Click       += (s, e) => { Client.PVPNet.Accept(data.stats.InvitationId); Client.InviteData.Remove(data.stats.InvitationId); Client.SwitchPage(new TeamQueuePage(data.stats.InvitationId)); };
                    notification.Decline.Click      += (s, e) => { Client.PVPNet.Decline(data.stats.InvitationId); Client.InviteData.Remove(data.stats.InvitationId); };
                    notification.TitleLabel.Content  = "Game Invite";
                    notification.BodyTextbox.Text    = data.stats.Inviter + " has invited you to a game";

                    invitationRequest m = JsonConvert.DeserializeObject <invitationRequest>(data.stats.GameMetaData);

                    string MapName;

                    CultureInfo cultureInfo = Thread.CurrentThread.CurrentCulture;
                    TextInfo textInfo       = cultureInfo.TextInfo;
                    var gameModeLower       = textInfo.ToTitleCase(string.Format(m.gameMode.ToLower()));
                    var gameTypeLower       = textInfo.ToTitleCase(string.Format(m.gameType.ToLower()));
                    //Why do I have to do this Riot?
                    var gameTypeRemove = gameTypeLower.Replace("_game", "");
                    var removeAllUnder = gameTypeRemove.Replace("_", " ");

                    notification.BodyTextbox.Text += "Mode: " + gameModeLower;
                    if (m.mapId == 1)
                    {
                        MapName = "Summoners Rift";
                    }
                    else if (m.mapId == 10)
                    {
                        MapName = "The Twisted Treeline";
                    }
                    else if (m.mapId == 12)
                    {
                        MapName = "Howling Abyss";
                    }
                    else if (m.mapId == 8)
                    {
                        MapName = "The Crystal Scar";
                    }
                    else
                    {
                        MapName = "Unknown Map";
                    }
                    notification.BodyTextbox.Text += "Map: " + MapName;
                    notification.BodyTextbox.Text += "Type: " + removeAllUnder;
                    ChatListView.Items.Add(notification);
                }));
            }
        }
        public GameInvitePopup(InvitationRequest stats)
        {
            InitializeComponent();
            //IDK WHY I'M Receiving this stuff -.-
            Client.PVPNet.OnMessageReceived += Update_OnMessageReceived;
            GameMetaData            = stats.GameMetaData;
            InvitationStateAsString = stats.InvitationStateAsString;
            InvitationState         = stats.InvitationState;
            Inviter      = stats.Inviter.SummonerName;
            InvitationId = stats.InvitationId;

            if (InvitationId != null)
            {
                NoGame.Visibility = Visibility.Hidden;
            }

            //Get who the Inviter's Name


            //Simple way to get lobby data with Json.Net
            invitationRequest m = JsonConvert.DeserializeObject <invitationRequest>(stats.GameMetaData);

            queueId          = m.queueId;
            isRanked         = m.isRanked;
            rankedTeamName   = m.rankedTeamName;
            mapId            = m.mapId;
            gameTypeConfigId = m.gameTypeConfigId;
            gameMode         = m.gameMode;
            gameType         = m.gameType;

            Client.PVPNet.getLobbyStatusInviteId = InvitationId;

            //So if there is a new map, it won't get a null error
            string MapName = "Unknown Map";


            if (mapId == 1)
            {
                MapName = "Summoners Rift";
            }
            else if (mapId == 10)
            {
                MapName = "The Twisted Treeline";
            }
            else if (mapId == 12)
            {
                MapName = "Howling Abyss";
            }
            else if (mapId == 8)
            {
                MapName = "The Crystal Scar";
            }


            //This is used so we can call the ToTitleCase [first letter is capital rest are not]
            CultureInfo cultureInfo   = Thread.CurrentThread.CurrentCulture;
            TextInfo    textInfo      = cultureInfo.TextInfo;
            var         gameModeLower = textInfo.ToTitleCase(string.Format(gameMode.ToLower()));
            var         gameTypeLower = textInfo.ToTitleCase(string.Format(gameType.ToLower()));
            //Why do I have to do this Riot?
            var gameTypeRemove = gameTypeLower.Replace("_game", "");
            var removeAllUnder = gameTypeRemove.Replace("_", " ");

            if (Inviter == null)
            {
                RenderNotificationTextBox("An unknown player has invited you to a game");
                RenderNotificationTextBox("");
                RenderNotificationTextBox("Mode: " + gameModeLower);
                RenderNotificationTextBox("Map: " + MapName);
                RenderNotificationTextBox("Type: " + removeAllUnder);
            }
            else if (Inviter == "")
            {
                RenderNotificationTextBox("An unknown player has invited you to a game");
                RenderNotificationTextBox("");
                RenderNotificationTextBox("Mode: " + gameModeLower);
                RenderNotificationTextBox("Map: " + MapName);
                RenderNotificationTextBox("Type: " + removeAllUnder);
            }
            else if (Inviter != null && Inviter != "")
            {
                RenderNotificationTextBox(Inviter + " has invited you to a game");
                RenderNotificationTextBox("");
                RenderNotificationTextBox("Mode: " + gameModeLower);
                RenderNotificationTextBox("Map: " + MapName);
                RenderNotificationTextBox("Type: " + removeAllUnder);
            }
        }
Пример #4
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 { }
        }
        private void LoadGamePopupData(InvitationRequest stats)
        {
            InvitationStateAsString = stats.InvitationStateAsString;
            GameMetaData            = stats.GameMetaData;
            InvitationState         = stats.InvitationState;
            Inviter      = stats.Inviter.SummonerName;
            InvitationId = stats.InvitationId;

            if (InvitationId != null)
            {
                NoGame.Visibility = Visibility.Hidden;
            }
            invitationRequest m = JsonConvert.DeserializeObject <invitationRequest>(stats.GameMetaData);

            queueId          = m.queueId;
            isRanked         = m.isRanked;
            rankedTeamName   = m.rankedTeamName;
            mapId            = m.mapId;
            gameTypeConfigId = m.gameTypeConfigId;
            gameMode         = m.gameMode;
            gameType         = m.gameType;

            Client.PVPNet.getLobbyStatusInviteId = InvitationId;
            switch (mapId)
            {
            case 1:
                MapName = "Summoners Rift";
                break;

            case 8:
                MapName = "The Crystal Scar";
                break;

            case 10:
                MapName = "The Twisted Treeline";
                break;

            case 12:
                MapName = "Howling Abyss";
                break;

            default:
                MapName = "Unknown Map";
                break;
            }
            var gameModeLower  = Client.TitleCaseString(string.Format(gameMode.ToLower()));
            var gameTypeLower  = Client.TitleCaseString(string.Format(gameType.ToLower()));
            var gameTypeRemove = gameTypeLower.Replace("_game", "");
            var removeAllUnder = gameTypeRemove.Replace("_", " ");

            if (String.IsNullOrEmpty(Inviter))
            {
                Inviter = "An unknown player";
            }

            mode = gameModeLower;
            type = removeAllUnder;
            RenderNotificationTextBox(Inviter + " has invited you to a game");
            RenderNotificationTextBox("");
            RenderNotificationTextBox("Mode: " + gameModeLower);
            RenderNotificationTextBox("Map: " + MapName);
            RenderNotificationTextBox("Type: " + removeAllUnder);

            InviteInfo y = new InviteInfo();

            y.stats   = stats;
            y.popup   = this;
            y.Inviter = Inviter;

            Client.InviteData.Add(stats.InvitationId, y);
        }