Ejemplo n.º 1
0
        private async Task GetLoginData(LoginDataPacket loginDataPacket)
        {
            Data.AccountId  = (int)loginDataPacket.AllSummonerData.Summoner.AccountId;
            Data.Summoner   = loginDataPacket.AllSummonerData.Summoner.Name;
            Data.SummonerId = (int)loginDataPacket.AllSummonerData.Summoner.SummonerId;
            Data.Level      = (int)loginDataPacket.AllSummonerData.SummonerLevel.Level;
            Data.RpBalance  = (int)loginDataPacket.RpBalance;
            Data.IpBalance  = (int)loginDataPacket.IpBalance;
            Data.RunePages  = loginDataPacket.AllSummonerData.SpellBook.BookPages.Count;
            Data.LastPlay   = loginDataPacket.AllSummonerData.Summoner.LastGameDate;

            if (loginDataPacket.EmailStatus != null)
            {
                var emailStatus = loginDataPacket.EmailStatus.Replace('_', ' ');
                Data.EmailStatus = char.ToUpper(emailStatus[0]) + emailStatus.Substring(1);
            }
            else
            {
                Data.EmailStatus = "Unknown";
            }

            string prevSeasonRank = loginDataPacket.AllSummonerData.Summoner.PreviousSeasonHighestTier;

            Data.PreviousSeasonRank = !string.IsNullOrEmpty(prevSeasonRank)
                ? prevSeasonRank[0] + prevSeasonRank.Substring(1).ToLower()
                : "Unranked";
        }
Ejemplo n.º 2
0
        private async Task <bool> CheckForReconnect()
        {
            if (_processHelper != null)
            {
                return(true);
            }

            // This is a MUST need fix
            // if a process crashes we reconnect, but we need to reget the loginDataPacket on start.
            _loginDataPacket = await _client.GetLoginDataPacketForUser();

            var reconnectInfo = _loginDataPacket.ReconnectInfo;

            if (reconnectInfo != null && reconnectInfo.playerCredentials != null)
            {
                Log.Write("[{0}] Reconnecting!", _account.Username);
                if (Master)
                {
                    _lastGameTime = DateTime.Now;
                }

                _processHelper = new ProcessHelper();
                _processHelper.Launch(reconnectInfo.playerCredentials);
                return(true);
            }

            return(false);
        }
Ejemplo n.º 3
0
        internal Account(LoginSession session, LoginDataPacket packet)
        {
            LoginSession = session;
            LoginPacket  = packet;

            SelectedRunePage    = Runes.BookPages.FirstOrDefault(p => p.Current);
            SelectedMasteryPage = Masteries.BookPages.FirstOrDefault(p => p.Current);
        }
Ejemplo n.º 4
0
        private async void GotPlayerData(LoginDataPacket packet)
        {
            Client.RtmpConnection.MessageReceived += OnMessageReceived;
            AllSummonerData PlayerData = packet.AllSummonerData;

            SummonerNameLabel.Content = PlayerData.Summoner.Name;
            if (Client.LoginPacket.AllSummonerData.SummonerLevel.Level < 30)
            {
                PlayerProgressBar.Value            = (PlayerData.SummonerLevelAndPoints.ExpPoints / PlayerData.SummonerLevel.ExpToNextLevel) * 100;
                PlayerProgressLabel.Content        = String.Format("Level {0}", PlayerData.SummonerLevel.Level);
                PlayerCurrentProgressLabel.Content = String.Format("{0}XP", PlayerData.SummonerLevelAndPoints.ExpPoints);
                PlayerAimProgressLabel.Content     = String.Format("{0}XP", PlayerData.SummonerLevel.ExpToNextLevel);
            }
            else
            {
                SummonerLeaguesDTO MyLeagues = await RiotCalls.GetAllLeaguesForPlayer(PlayerData.Summoner.SumId);

                GotLeaguesForPlayer(MyLeagues);
            }

            if (packet.BroadcastNotification.broadcastMessages != null)
            {
                Dictionary <string, object> Message = packet.BroadcastNotification.broadcastMessages[0] as Dictionary <string, object>;
                BroadcastMessage.Text = Convert.ToString(Message["content"]);
            }

            foreach (PlayerStatSummary x in packet.PlayerStatSummaries.PlayerStatSummarySet)
            {
                if (x.PlayerStatSummaryTypeString == "Unranked")
                {
                    Client.IsRanked     = false;
                    Client.AmountOfWins = x.Wins;
                }
                if (x.PlayerStatSummaryTypeString == "RankedSolo5x5")
                {
                    Client.IsRanked     = true;
                    Client.AmountOfWins = x.Wins;
                    break;
                }
            }

            if (packet.ReconnectInfo != null)
            {
                ;
            }

            Client.InfoLabel.Content = "IP: " + Client.LoginPacket.IpBalance + " ∙ RP: " + Client.LoginPacket.RpBalance;
            int    ProfileIconID = Client.LoginPacket.AllSummonerData.Summoner.ProfileIconId;
            string uriSource     = Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", ProfileIconID + ".png");

            ProfileImage.Source         = Client.GetImage(uriSource);
            Client.MainPageProfileImage = ProfileImage;

            RefreshTimer          = new System.Windows.Forms.Timer();
            RefreshTimer.Tick    += new EventHandler(RefreshTimer_Tick);
            RefreshTimer.Interval = 300000; // 5 minutes
            RefreshTimer.Start();
        }
Ejemplo n.º 5
0
        internal async static Task <LoginDataPacket> AddAccount(LoginDataPacket packet)
        {
            if (packet == null)
            {
                return(new LoginDataPacket());
            }

            accountslist.Add(packet.AllSummonerData.Summoner.Name, packet);
            return(packet);
        }
Ejemplo n.º 6
0
        private async void LeagueProcess_Exited(object sender, EventArgs e)
        {
            Client.Status("Restart League of Legends.", AccountName);
            Packets = await Connections.GetLoginDataPacketForUser();

            if (Packets.ReconnectInfo != null && Packets.ReconnectInfo.Game != null)
            {
                OnMessageReceived(sender, (object)Packets.ReconnectInfo.PlayerCredentials);
            }
        }
Ejemplo n.º 7
0
        private void GotPlayerData(LoginDataPacket packet)
        {
            Client.PVPNet.OnMessageReceived += PVPNet_OnMessageReceived;
            AllSummonerData PlayerData = packet.AllSummonerData;

            SummonerNameLabel.Content = PlayerData.Summoner.Name;
            if (Client.LoginPacket.AllSummonerData.SummonerLevel.Level < 30)
            {
                PlayerProgressBar.Value            = (PlayerData.SummonerLevelAndPoints.ExpPoints / PlayerData.SummonerLevel.ExpToNextLevel) * 100;
                PlayerProgressLabel.Content        = String.Format("Level {0}", PlayerData.SummonerLevel.Level);
                PlayerCurrentProgressLabel.Content = String.Format("{0}XP", PlayerData.SummonerLevelAndPoints.ExpPoints);
                PlayerAimProgressLabel.Content     = String.Format("{0}XP", PlayerData.SummonerLevel.ExpToNextLevel);
            }
            else
            {
                Client.PVPNet.GetAllLeaguesForPlayer(PlayerData.Summoner.SumId, new SummonerLeaguesDTO.Callback(GotLeaguesForPlayer));
            }

            if (packet.BroadcastNotification.BroadcastMessages != null)
            {
                Dictionary <string, object> Message = packet.BroadcastNotification.BroadcastMessages[0] as Dictionary <string, object>;
                BroadcastMessage.Text = Convert.ToString(Message["content"]);
            }

            foreach (PlayerStatSummary x in packet.PlayerStatSummaries.PlayerStatSummarySet)
            {
                if (x.PlayerStatSummaryTypeString == "Unranked")
                {
                    Client.IsRanked     = false;
                    Client.AmountOfWins = x.Wins;
                }
                if (x.PlayerStatSummaryTypeString == "RankedSolo5x5")
                {
                    Client.IsRanked     = true;
                    Client.AmountOfWins = x.Wins;
                    break;
                }
            }

            if (packet.ReconnectInfo != null)
            {
                ;
            }

            //Client.InfoLabel.Content = "IP: " + Client.LoginPacket.IpBalance + " ∙ RP: " + Client.LoginPacket.RpBalance;
            int ProfileIconID = Client.LoginPacket.AllSummonerData.Summoner.ProfileIconId;
            var uriSource     = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", ProfileIconID + ".png"), UriKind.RelativeOrAbsolute);

            ProfileImage.Source         = new BitmapImage(uriSource);
            Client.MainPageProfileImage = ProfileImage;
        }
Ejemplo n.º 8
0
        private void OnLogin(object sender, string username, string ipAddress)
        {
            new Thread(async() =>
            {
                try
                {
                    Packets = await Connections.GetLoginDataPacketForUser();
                }
                catch (NotSupportedException)
                {
                    // Restarting BotClient;
                    Controller.Restart();
                }

                if (Packets.AllSummonerData == null)
                {
                    NewPlayerAccout();
                    OnLogin(sender, username, ipAddress);
                    return;
                }

                await Connections.Subscribe("bc", Packets.AllSummonerData.Summoner.AcctId);
                await Connections.Subscribe("cn", Packets.AllSummonerData.Summoner.AcctId);
                await Connections.Subscribe("gn", Packets.AllSummonerData.Summoner.AcctId);

                if (Packets.AllSummonerData.Summoner.ProfileIconId == -1)
                {
                    SetSummonerIcon();
                }

                SummonerLevel = Packets.AllSummonerData.SummonerLevel.Level;
                SummonerName  = Packets.AllSummonerData.Summoner.Name;
                SummonerId    = Packets.AllSummonerData.Summoner.SumId;
                HeroesArray   = await Connections.GetAvailableChampions();
                Debug.WriteLine(JsonConvert.SerializeObject(HeroesArray.Where(ho => ho.Owned || ho.FreeToPlay)));

                WebService.SetLevel(Account.Id, (int)SummonerLevel);
                WebService.SetMoney(Account.Id, (int)Packets.IpBalance);


                if (SummonerLevel > Account.Maxlevel || Convert.ToInt32(SummonerLevel) == Account.Maxlevel)
                {
                    Client.Status("Maximum level reached!", AccountName);
                    return;
                }

                Hero = await Connections.CreatePlayer();
                OnMessageReceived(sender, new ClientBeforeStart());
                Thread.Sleep(2000);
            }).Start();
        }
Ejemplo n.º 9
0
        public async Task <LoginDataPacket> GetLoginDataPacketForUser()
        {
            int Id = Invoke("clientFacadeService", "getLoginDataPacketForUser", new object[] { });

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

            results.Remove(Id);
            return(result);
        }
Ejemplo n.º 10
0
        async void exeProcess_Exited(object sender, EventArgs e)
        {
            updateStatus("Restart League of Legends.", Accountname);
            loginPacket = await connection.GetLoginDataPacketForUser();

            if (this.loginPacket.ReconnectInfo != null && this.loginPacket.ReconnectInfo.Game != null)
            {
                this.connection_OnMessageReceived(sender, (object)this.loginPacket.ReconnectInfo.PlayerCredentials);
            }
            else
            {
                this.connection_OnMessageReceived(sender, (object)new EndOfGameStats());
            }
        }
Ejemplo n.º 11
0
        private async void updateSmurfInfo()
        {
            try
            {
                loginPacket = await connection.GetLoginDataPacketForUser();

                smurf.currentrp    = loginPacket.RpBalance;
                smurf.currentLevel = loginPacket.AllSummonerData.SummonerLevel.Level;
                smurf.currentip    = loginPacket.IpBalance;
                smurf.updateSelfOnRemote();
            }
            catch (Exception ex)
            {
            }
        }
Ejemplo n.º 12
0
        internal void RtmpConnect()
        {
            Console.WriteLine("Connecting to RTMPS with Token: " + loginToken);
            var authLoginPacket = new AuthenticationCredentials();

            authLoginPacket.Username      = credentials.Username;
            authLoginPacket.Password      = credentials.Password;
            authLoginPacket.Domain        = "lolclient.lol.riotgames.com";
            authLoginPacket.Locale        = "en_US";
            authLoginPacket.ClientVersion = ClientVersion.Get(credentials.Region);
            authLoginPacket.IpAddress     = GetIPAddress();
            authLoginPacket.AuthToken     = loginToken;
            rtmpClient.ConnectAsync().Wait();
            var loginTask = InvokeAsync <Session>("loginService", "login", authLoginPacket);

            loginTask.Wait();
            clientSession = loginTask.Result;
            rtmpClient.SubscribeAsync("my-rtmps", "messagingDestination", "bc", "bc-" + clientSession.AccountSummary.AccountId.ToString()).Wait();
            rtmpClient.SubscribeAsync("my-rtmps", "messagingDestination", "gn-" + clientSession.AccountSummary.AccountId.ToString(), "gn-" + clientSession.AccountSummary.AccountId.ToString()).Wait();
            rtmpClient.SubscribeAsync("my-rtmps", "messagingDestination", "cn-" + clientSession.AccountSummary.AccountId.ToString(), "cn-" + clientSession.AccountSummary.AccountId.ToString()).Wait();
            RtmpLogin();
            var loginPacketTask = InvokeAsync <LoginDataPacket>("clientFacadeService", "getLoginDataPacketForUser");

            loginPacketTask.Wait();
            this.loginPacket = loginPacketTask.Result;
            if (loginPacket.AllSummonerData == null)
            {
                SetSummonerNameForNewAccount();
            }
            notifications = loginPacket.BroadcastNotification.broadcastMessages;
            var stateTask = InvokeAsync <String>("accountService", "getAccountStateForCurrentSession");

            stateTask.Wait();
            String state = stateTask.Result;

            if (state != "ENABLED")
            {
                if (loggedIn)
                {
                    RtmpLogout();
                }
                return; //Keep the client but mark it as logged out
            }
            beginHeartbeat();
        }
        private async void GotLoginPacket(LoginDataPacket packet)
        {
            Client.LoginPacket     = packet;
            Client.PlayerChampions = await RiotCalls.GetAvailableChampions();

            //Client.PVPNet.OnError -= PVPNet_OnError;
            Client.GameConfigs = packet.GameTypeConfigs;
            Client.IsLoggedIn  = true;

            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
            {
                Client.StatusContainer.Visibility = System.Windows.Visibility.Visible;
                Client.Container.Margin           = new Thickness(0, 0, 0, 40);

                //Setup chat
                Client.ChatClient.AutoReconnect         = 30;
                Client.ChatClient.KeepAlive             = 10;
                Client.ChatClient.NetworkHost           = Dns.GetHostAddresses("chat." + Client.Region.ChatName + ".lol.riotgames.com")[0].ToString();
                Client.ChatClient.Port                  = 5223;
                Client.ChatClient.Server                = "pvp.net";
                Client.ChatClient.SSL                   = true;
                Client.ChatClient.User                  = LoginUsernameBox.Text;
                Client.ChatClient.Password              = "******" + LoginPasswordBox.Password;
                Client.ChatClient.OnInvalidCertificate += Client.ChatClient_OnInvalidCertificate;
                Client.ChatClient.OnMessage            += Client.ChatClient_OnMessage;
                Client.ChatClient.Connect();

                Client.RostManager               = new RosterManager();
                Client.RostManager.Stream        = Client.ChatClient;
                Client.RostManager.AutoSubscribe = true;
                Client.RostManager.AutoAllow     = jabber.client.AutoSubscriptionHanding.AllowAll;
                Client.RostManager.OnRosterItem += Client.RostManager_OnRosterItem;
                Client.RostManager.OnRosterEnd  += new bedrock.ObjectHandler(Client.ChatClientConnect);

                Client.PresManager        = new PresenceManager();
                Client.PresManager.Stream = Client.ChatClient;
                Client.PresManager.OnPrimarySessionChange += Client.PresManager_OnPrimarySessionChange;

                Client.ConfManager        = new ConferenceManager();
                Client.ConfManager.Stream = Client.ChatClient;

                Client.SwitchPage(new MainPage());
            }));
        }
Ejemplo n.º 14
0
        /// <summary>
        /// Connects to the
        /// </summary>
        /// <param name="User"></param>
        /// <param name="Shard"></param>
        /// <returns></returns>
        public async Task <bool> Connect()
        {
            //Connects to the RTMPS client
            await _client.ConnectAsync();

            //Decrypts the users password when logging in
            string password = DPAPI.Decrypt(_user.Password);

            AuthenticationCredentials auth = new AuthenticationCredentials
            {
                Username      = _user.Username,
                Password      = password,
                ClientVersion = PoroServer.ClientVersion,
                IpAddress     = "209.133.52.232",
                Locale        = _shard.Locale,
                Domain        = "lolclient.lol.riotgames.com",
                AuthToken     = GetAuthKey(_user.Username, password, _shard.LoginQueue)
            };

            //Gets the current login session
            Session login = await Login(_client, auth);

            _accountId = login.Summary.AccountId;

            //Subscribes to server messages
            await _client.SubscribeAsync("my-rtmps", "messagingDestination", "bc", "bc-" + login.Summary.AccountId.ToString());

            await _client.SubscribeAsync("my-rtmps", "messagingDestination", "gn-" + login.Summary.AccountId.ToString(), "gn-" + login.Summary.AccountId.ToString());

            await _client.SubscribeAsync("my-rtmps", "messagingDestination", "cn-" + login.Summary.AccountId.ToString(), "cn-" + login.Summary.AccountId.ToString());

            bool LoggedIn = await _client.LoginAsync(_user.Username.ToLower(), login.Token);

            //TODO: Find easier way of getting summoner name and id without having to download a huge packet
            LoginDataPacket dataPacket = await GetLoginPacket(_client);

            _packet       = dataPacket;
            _summonerId   = dataPacket.AllSummonerData.Summoner.SumId;
            _summonerName = dataPacket.AllSummonerData.Summoner.Name;

            return(LoggedIn);
        }
Ejemplo n.º 15
0
        private async Task GetLoginData(LoginDataPacket loginDataPacket)
        {
            Data.AccountId  = (int)loginDataPacket.AllSummonerData.Summoner.AccountId;
            Data.Summoner   = loginDataPacket.AllSummonerData.Summoner.Name;
            Data.SummonerId = (int)loginDataPacket.AllSummonerData.Summoner.SummonerId;
            Data.Level      = (int)loginDataPacket.AllSummonerData.SummonerLevel.Level;
            Data.RpBalance  = (int)loginDataPacket.RpBalance;
            Data.IpBalance  = (int)loginDataPacket.IpBalance;
            Data.RunePages  = loginDataPacket.AllSummonerData.SpellBook.BookPages.Count;
            Data.LastPlay   = loginDataPacket.AllSummonerData.Summoner.LastGameDate;

            if (loginDataPacket.EmailStatus != null)
            {
                var emailStatus = loginDataPacket.EmailStatus.Replace('_', ' ');
                Data.EmailStatus = char.ToUpper(emailStatus[0]) + emailStatus.Substring(1);
            }
            else
            {
                Data.EmailStatus = "Unknown";
            }

            string prevSeasonRank = loginDataPacket.AllSummonerData.Summoner.PreviousSeasonHighestTier;

            Data.PreviousSeasonRank = !string.IsNullOrEmpty(prevSeasonRank)
                ? prevSeasonRank[0] + prevSeasonRank.Substring(1).ToLower()
                : "Unranked";

            if (Data.Level == 30)
            {
                var myLeagues = await _pvpnet.GetMyLeaguePositions();

                var soloqLeague = myLeagues.SummonerLeagues.FirstOrDefault(l => l.QueueType == "RANKED_SOLO_5x5");
                Data.SoloQRank = soloqLeague != null
                    ? $"{char.ToUpper(soloqLeague.Tier[0])}{soloqLeague.Tier.Substring(1).ToLower()} {soloqLeague.Rank}"
                    : "Unranked";
            }
            else
            {
                Data.SoloQRank = "Unranked";
            }
        }
Ejemplo n.º 16
0
        private async void handleGameEnder(object sender, object message)
        {
            EndOfGameStats eog = new EndOfGameStats();

            connection_OnMessageReceived(sender, eog);
            exeProcess.Exited -= exeProcess_Exited;
            exeProcess.Kill();
            Thread.Sleep(500);
            if (exeProcess.Responding && !m_disposed)
            {
                Process.Start("taskkill /F /IM \"League of Legends.exe\"");
            }
            loginPacket = await this.connection.GetLoginDataPacketForUser();

            var oldLevel = currentLevel;

            currentLevel = loginPacket.AllSummonerData.SummonerLevel.Level;
            if (oldLevel != currentLevel)
            {
                levelUp();
            }
            smurf.updateTimer(15);
        }
Ejemplo n.º 17
0
        public async void connection_OnMessageReceived(object sender, object message)
        {
            if (message is GameDTO)
            {
                GameDTO game = message as GameDTO;
                switch (game.GameState)
                {
                case "CHAMP_SELECT":
                    firstTimeInCustom   = true;
                    firstTimeInQueuePop = true;
                    if (firstTimeInLobby)
                    {
                        firstTimeInLobby = false;
                        updateStatus("In Champion Select", Accountname);
                        await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT");

                        if (queueType != QueueTypes.ARAM)
                        {
                            if (Core.championId != "")
                            {
                                await connection.SelectChampion(Enums.championToId(Core.championId));

                                await connection.ChampionSelectCompleted();
                            }
                            else
                            {
                                await connection.SelectChampion(availableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId);

                                await connection.ChampionSelectCompleted();
                            }
                        }
                        break;
                    }
                    else
                    {
                        break;
                    }

                case "POST_CHAMP_SELECT":
                    firstTimeInLobby = false;
                    updateStatus("(Post Champ Select)", Accountname);
                    break;

                case "PRE_CHAMP_SELECT":
                    updateStatus("(Pre Champ Select)", Accountname);
                    break;

                case "GAME_START_CLIENT":
                    updateStatus("Game client ran", Accountname);
                    break;

                case "GameClientConnectedToServer":
                    updateStatus("Client connected to the server", Accountname);
                    break;

                case "IN_QUEUE":
                    updateStatus("In Queue", Accountname);
                    break;

                case "TERMINATED":
                    updateStatus("Re-entering queue", Accountname);
                    firstTimeInQueuePop = true;
                    break;

                case "JOINING_CHAMP_SELECT":
                    if (firstTimeInQueuePop)
                    {
                        updateStatus("Queue popped", Accountname);
                        if (game.StatusOfParticipants.Contains("1"))
                        {
                            updateStatus("Accepted Queue", Accountname);
                            firstTimeInQueuePop = false;
                            firstTimeInLobby    = true;
                            await connection.AcceptPoppedGame(true);
                        }
                    }
                    break;
                }
            }
            else if (message is PlayerCredentialsDto)
            {
                PlayerCredentialsDto dto = message as PlayerCredentialsDto;
                if (!HasLaunchedGame)
                {
                    HasLaunchedGame = true;
                    new Thread((ThreadStart)(() =>
                    {
                        LaunchGame(dto);
                        Thread.Sleep(3000);
                    })).Start();
                }
            }
            else if (!(message is GameNotification) && !(message is SearchingForMatchNotification))
            {
                if (message is EndOfGameStats)
                {
                    MatchMakerParams matchParams = new MatchMakerParams();
                    //Set BotParams
                    if (queueType == QueueTypes.INTRO_BOT)
                    {
                        matchParams.BotDifficulty = "INTRO";
                    }
                    else if (queueType == QueueTypes.BEGINNER_BOT)
                    {
                        matchParams.BotDifficulty = "EASY";
                    }
                    else if (queueType == QueueTypes.MEDIUM_BOT)
                    {
                        matchParams.BotDifficulty = "MEDIUM";
                    }
                    //Check if is available to join queue.
                    if (sumLevel == 3 && actualQueueType == QueueTypes.NORMAL_5x5)
                    {
                        queueType = actualQueueType;
                    }
                    else if (sumLevel == 6 && actualQueueType == QueueTypes.ARAM)
                    {
                        queueType = actualQueueType;
                    }
                    else if (sumLevel == 7 && actualQueueType == QueueTypes.NORMAL_3x3)
                    {
                        queueType = actualQueueType;
                    }
                    matchParams.QueueIds = new Int32[1] {
                        (int)queueType
                    };
                    SearchingForMatchNotification m = await connection.AttachToQueue(matchParams);

                    if (m.PlayerJoinFailures == null)
                    {
                        updateStatus("In Queue: " + queueType.ToString(), Accountname);
                    }
                    else
                    {
                        updateStatus("Couldn't enter Queue! Please contact us @ volibot.com", Accountname);
                    }
                }
                else
                {
                    if (message.ToString().Contains("EndOfGameStats"))
                    {
                        EndOfGameStats eog = new EndOfGameStats();
                        connection_OnMessageReceived(sender, eog);
                        exeProcess.Kill();
                        loginPacket = await this.connection.GetLoginDataPacketForUser();

                        archiveSumLevel = sumLevel;
                        sumLevel        = loginPacket.AllSummonerData.SummonerLevel.Level;
                        if (sumLevel != archiveSumLevel)
                        {
                            levelUp();
                        }
                    }
                }
            }
        }
        private async void LoginButton_Click(object sender, RoutedEventArgs args)
        {
            if (RememberPasswordCheckbox.IsChecked == true)
            {
                Properties.Settings.Default.SavedPassword = LoginPasswordBox.Password;
            }
            else
            {
                Properties.Settings.Default.SavedPassword = "";
            }

            if (RememberUsernameCheckbox.IsChecked == true)
            {
                Properties.Settings.Default.SavedUsername = LoginUsernameBox.Text;
            }
            else
            {
                Properties.Settings.Default.SavedUsername = "";
            }

            Properties.Settings.Default.AutoLogin = (bool)AutoLoginCheckBox.IsChecked;
            Properties.Settings.Default.Region    = (string)RegionComboBox.SelectedValue;
            Properties.Settings.Default.Save();

            HideGrid.Visibility              = Visibility.Hidden;
            ErrorTextBox.Visibility          = Visibility.Hidden;
            LoggingInLabel.Visibility        = Visibility.Visible;
            LoggingInProgressRing.Visibility = Visibility.Visible;
            BaseRegion SelectedRegion = BaseRegion.GetRegion((string)RegionComboBox.SelectedValue);

            Client.Region = SelectedRegion;

            var context = RiotCalls.RegisterObjects();

            Client.RtmpConnection = new RtmpClient(new Uri("rtmps://" + SelectedRegion.Server + ":2099"), context, ObjectEncoding.Amf3);
            Client.RtmpConnection.MessageReceived   += Client.OnMessageReceived;
            Client.RtmpConnection.CallbackException += Client.CallbackException;
            RiotCalls.OnInvocationError             += Client.CallbackException;
            await Client.RtmpConnection.ConnectAsync();

            AuthenticationCredentials newCredentials = new AuthenticationCredentials();

            newCredentials.Username      = LoginUsernameBox.Text;
            newCredentials.Password      = LoginPasswordBox.Password;
            newCredentials.ClientVersion = Client.Version;
            newCredentials.IpAddress     = RiotCalls.GetIpAddress();
            newCredentials.Locale        = SelectedRegion.Locale;
            newCredentials.Domain        = "lolclient.lol.riotgames.com";
            try
            {
                newCredentials.AuthToken = RiotCalls.GetAuthKey(LoginUsernameBox.Text, LoginPasswordBox.Password, SelectedRegion.LoginQueue);
            }
            catch (Exception e)
            {
                HideGrid.Visibility              = Visibility.Visible;
                ErrorTextBox.Visibility          = Visibility.Visible;
                LoggingInProgressRing.Visibility = Visibility.Hidden;
                LoggingInLabel.Visibility        = Visibility.Hidden;
                if (e.Message.Contains("The remote name could not be resolved"))
                {
                    ErrorTextBox.Text = "Please make sure you are connected the internet!";
                }
                else if (e.Message.Contains("(403) Forbidden"))
                {
                    ErrorTextBox.Text = "Your username or password is incorrect!";
                }
                else
                {
                    ErrorTextBox.Text = "Unable to get Auth Key";
                }

                ErrorTextBox.Text += string.Format("{0}{1}{0}{2}", Environment.NewLine, e.Message, e.StackTrace);
                return;
            }

            Session login = await RiotCalls.Login(newCredentials);

            Client.PlayerSession = login;
            await Client.RtmpConnection.SubscribeAsync("my-rtmps", "messagingDestination", "bc", "bc-" + login.AccountSummary.AccountId.ToString());

            await Client.RtmpConnection.SubscribeAsync("my-rtmps", "messagingDestination", "gn-" + login.AccountSummary.AccountId.ToString(), "gn-" + login.AccountSummary.AccountId.ToString());

            await Client.RtmpConnection.SubscribeAsync("my-rtmps", "messagingDestination", "cn-" + login.AccountSummary.AccountId.ToString(), "cn-" + login.AccountSummary.AccountId.ToString());

            bool LoggedIn = await Client.RtmpConnection.LoginAsync(LoginUsernameBox.Text.ToLower(), login.Token);

            LoginDataPacket packet = await RiotCalls.GetLoginDataPacketForUser();

            string State = await RiotCalls.GetAccountState();

            if (State != "ENABLED")
            {
                HideGrid.Visibility              = Visibility.Visible;
                ErrorTextBox.Visibility          = Visibility.Visible;
                LoggingInProgressRing.Visibility = Visibility.Hidden;
                LoggingInLabel.Visibility        = Visibility.Hidden;
                ErrorTextBox.Text = "Your account state was invalid: " + State;
                return;
            }

            GotLoginPacket(packet);
        }
Ejemplo n.º 19
0
        private async Task GetLoginData(LoginDataPacket loginDataPacket)
        {
            Data.AccountId = (int)loginDataPacket.AllSummonerData.Summoner.AccountId;
            Data.Summoner = loginDataPacket.AllSummonerData.Summoner.Name;
            Data.SummonerId = (int)loginDataPacket.AllSummonerData.Summoner.SummonerId;
            Data.Level = (int)loginDataPacket.AllSummonerData.SummonerLevel.Level;
            Data.RpBalance = (int)loginDataPacket.RpBalance;
            Data.IpBalance = (int)loginDataPacket.IpBalance;
            Data.RunePages = loginDataPacket.AllSummonerData.SpellBook.BookPages.Count;
            Data.LastPlay = loginDataPacket.AllSummonerData.Summoner.LastGameDate;

            if (loginDataPacket.EmailStatus != null)
            {
                var emailStatus = loginDataPacket.EmailStatus.Replace('_', ' ');
                Data.EmailStatus = char.ToUpper(emailStatus[0]) + emailStatus.Substring(1);
            }
            else
            {
                Data.EmailStatus = "Unknown";
            }

            string prevSeasonRank = loginDataPacket.AllSummonerData.Summoner.PreviousSeasonHighestTier;

            Data.PreviousSeasonRank = !string.IsNullOrEmpty(prevSeasonRank) 
                ? prevSeasonRank[0] + prevSeasonRank.Substring(1).ToLower()
                : "Unranked";

            if (Data.Level == 30)
            {
                var myLeagues = await _pvpnet.GetMyLeaguePositions();
                var soloqLeague = myLeagues.SummonerLeagues.FirstOrDefault(l => l.QueueType == "RANKED_SOLO_5x5");
                Data.SoloQRank = soloqLeague != null
                    ? $"{char.ToUpper(soloqLeague.Tier[0])}{soloqLeague.Tier.Substring(1).ToLower()} {soloqLeague.Rank}"
                    : "Unranked";
            }
            else
            {
                Data.SoloQRank = "Unranked";
            }
        }
Ejemplo n.º 20
0
        public async void connection_OnMessageReceived(object sender, object message)
        {
            if (message is GameDTO)
            {
                GameDTO game = message as GameDTO;
                switch (game.GameState)
                {
                case "TEAM_SELECT":
                    int totalPlayers = game.TeamOne.Count + game.TeamTwo.Count;
                    this.updateStatus("In custom lobby, playerCount:" + totalPlayers, Accountname);
                    if (totalPlayers == 6 && game.OwnerSummary.AccountId == this.connection.AccountID())
                    {
                        await connection.StartChampionSelection(game.Id, game.OptimisticLock);
                    }
                    break;

                case "CHAMP_SELECT":
                    Program.QueueValid = true;
                    if (this.firstTimeInLobby)
                    {
                        QueueFlag        = true;
                        firstTimeInLobby = false;
                        updateStatus("In Champion Selection", Accountname);
                        object obj = await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT");

                        if (queueType != QueueTypes.ARAM)
                        {
                            if (Program.championId != "" && Program.championId != "RANDOM")
                            {
                                int Spell1;
                                int Spell2;
                                if (!Program.rndSpell)
                                {
                                    Spell1 = Enums.spellToId(Program.spell1);
                                    Spell2 = Enums.spellToId(Program.spell2);
                                }
                                else
                                {
                                    var random    = new Random();
                                    var spellList = new List <int> {
                                        13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4
                                    };

                                    int index  = random.Next(spellList.Count);
                                    int index2 = random.Next(spellList.Count);

                                    int randomSpell1 = spellList[index];
                                    int randomSpell2 = spellList[index2];

                                    if (randomSpell1 == randomSpell2)
                                    {
                                        int index3 = random.Next(spellList.Count);
                                        randomSpell2 = spellList[index3];
                                    }

                                    Spell1 = Convert.ToInt32(randomSpell1);
                                    Spell2 = Convert.ToInt32(randomSpell2);
                                }

                                await connection.SelectSpells(Spell1, Spell2);

                                await connection.SelectChampion(Enums.championToId(Program.championId));

                                await connection.ChampionSelectCompleted();
                            }
                            else if (Program.championId == "RANDOM")
                            {
                                int Spell1;
                                int Spell2;
                                if (!Program.rndSpell)
                                {
                                    Spell1 = Enums.spellToId(Program.spell1);
                                    Spell2 = Enums.spellToId(Program.spell2);
                                }
                                else
                                {
                                    var random    = new Random();
                                    var spellList = new List <int> {
                                        13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4
                                    };

                                    int index  = random.Next(spellList.Count);
                                    int index2 = random.Next(spellList.Count);

                                    int randomSpell1 = spellList[index];
                                    int randomSpell2 = spellList[index2];

                                    if (randomSpell1 == randomSpell2)
                                    {
                                        int index3 = random.Next(spellList.Count);
                                        randomSpell2 = spellList[index3];
                                    }

                                    Spell1 = Convert.ToInt32(randomSpell1);
                                    Spell2 = Convert.ToInt32(randomSpell2);
                                }

                                await connection.SelectSpells(Spell1, Spell2);

                                var randAvailableChampsArray = availableChampsArray.Shuffle();
                                int randomAdc = randAvailableChampsArray.First(champ => (champ.Owned || champ.FreeToPlay) && (champ.ChampionId == 22 || champ.ChampionId == 51 || champ.ChampionId == 42 || champ.ChampionId == 119 || champ.ChampionId == 81 || champ.ChampionId == 104 || champ.ChampionId == 222 || champ.ChampionId == 429 || champ.ChampionId == 96 || champ.ChampionId == 236 || champ.ChampionId == 21 || champ.ChampionId == 133 || champ.ChampionId == 15 || champ.ChampionId == 18 || champ.ChampionId == 29 || champ.ChampionId == 110 || champ.ChampionId == 67)).ChampionId;
                                await connection.SelectChampion(randomAdc);


                                await connection.ChampionSelectCompleted();
                            }
                            else
                            {
                                int Spell1;
                                int Spell2;
                                if (!Program.rndSpell)
                                {
                                    Spell1 = Enums.spellToId(Program.spell1);
                                    Spell2 = Enums.spellToId(Program.spell2);
                                }
                                else
                                {
                                    var random    = new Random();
                                    var spellList = new List <int> {
                                        13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4
                                    };

                                    int index  = random.Next(spellList.Count);
                                    int index2 = random.Next(spellList.Count);

                                    int randomSpell1 = spellList[index];
                                    int randomSpell2 = spellList[index2];

                                    if (randomSpell1 == randomSpell2)
                                    {
                                        int index3 = random.Next(spellList.Count);
                                        randomSpell2 = spellList[index3];
                                    }

                                    Spell1 = Convert.ToInt32(randomSpell1);
                                    Spell2 = Convert.ToInt32(randomSpell2);
                                }

                                await connection.SelectSpells(Spell1, Spell2);

                                var randAvailableChampsArray = availableChampsArray.Shuffle();
                                int randomAdc = randAvailableChampsArray.First(champ => (champ.Owned || champ.FreeToPlay) && (champ.ChampionId == 22 || champ.ChampionId == 51 || champ.ChampionId == 42 || champ.ChampionId == 119 || champ.ChampionId == 81 || champ.ChampionId == 104 || champ.ChampionId == 222 || champ.ChampionId == 429 || champ.ChampionId == 96 || champ.ChampionId == 236 || champ.ChampionId == 21 || champ.ChampionId == 133 || champ.ChampionId == 15 || champ.ChampionId == 18 || champ.ChampionId == 29 || champ.ChampionId == 110 || champ.ChampionId == 67)).ChampionId;

                                await connection.SelectChampion(randomAdc);

                                await connection.ChampionSelectCompleted();
                            }
                        }
                        break;
                    }
                    else
                    {
                        break;
                    }

                case "POST_CHAMP_SELECT":
                    firstTimeInLobby = false;
                    this.updateStatus("Last 10 seconds to start game", Accountname);
                    break;

                case "PRE_CHAMP_SELECT":
                    this.updateStatus("Last seconds to set champion", Accountname);
                    break;

                case "GAME_START_CLIENT":
                    this.updateStatus("In Game", Accountname);
                    break;

                case "GameClientConnectedToServer":
                    this.updateStatus("Connected to server", Accountname);
                    break;

                case "IN_QUEUE":
                    this.updateStatus("In Queue", Accountname);
                    QueueFlag = true;
                    break;

                case "TERMINATED":
                    this.updateStatus("Re entering to queue", Accountname);
                    this.firstTimeInQueuePop = true;
                    if (queueType == QueueTypes.CUSTOM)
                    {
                        CreatePracticeGame();
                    }
                    break;

                case "JOINING_CHAMP_SELECT":
                    if (this.firstTimeInQueuePop && game.StatusOfParticipants.Contains("1"))
                    {
                        this.updateStatus("Game accepted", Accountname);
                        this.firstTimeInQueuePop = false;
                        this.firstTimeInLobby    = true;
                        object obj = await this.connection.AcceptPoppedGame(true);

                        break;
                    }
                    else
                    {
                        break;
                    }

                case "LEAVER_BUSTED":
                    this.updateStatus("You are leaver busted", Accountname);
                    break;
                }
            }
            else if (message is PlayerCredentialsDto)
            {
                string str = Enumerable.Last <string>((IEnumerable <string>)Enumerable.OrderBy <string, DateTime>(Directory.EnumerateDirectories((this.ipath ?? "") + "RADS\\solutions\\lol_game_client_sln\\releases\\"), (Func <string, DateTime>)(f => new DirectoryInfo(f).CreationTime))) + "\\deploy\\";
                LoLLauncher.RiotObjects.Platform.Game.PlayerCredentialsDto credentials = message as PlayerCredentialsDto;
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.CreateNoWindow   = false;
                startInfo.WorkingDirectory = str;
                if (Program.replaceConfig)
                {
                    startInfo.WindowStyle = ProcessWindowStyle.Hidden;
                }
                startInfo.FileName  = "League of Legends.exe";
                startInfo.Arguments = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + credentials.ServerIp + " " +
                                      credentials.ServerPort + " " + credentials.EncryptionKey + " " + credentials.SummonerId + "\"";
                updateStatus("Starting Game", Accountname);
                new Thread((ThreadStart)(() =>
                {
                    exeProcess = Process.Start(startInfo);
                    exeProcess.Exited += exeProcess_Exited;
                    while (exeProcess.MainWindowHandle == IntPtr.Zero)
                    {
                        ;
                    }
                    exeProcess.PriorityClass = ProcessPriorityClass.Idle;
                    exeProcess.EnableRaisingEvents = true;
                    if (!Program.bolRunning)
                    {
                        Thread.Sleep(3000);
                        BasicInject.Inject(exeProcess, Program.dllPath);
                    }
                })).Start();
            }
            else if (!(message is GameNotification) && !(message is SearchingForMatchNotification))
            {
                if (message is EndOfGameStats)
                {
                    EndOfGameStats eog = message as EndOfGameStats;
                    this.joinQueue();
                }
                else
                {
                    if (message.ToString().Contains("EndOfGameStats"))
                    {
                        updateStatus("Game ending, calculating results", Accountname);
                        EndOfGameStats eog = new EndOfGameStats();
                        connection_OnMessageReceived(sender, eog);
                        exeProcess.Exited -= exeProcess_Exited;
                        exeProcess.Kill();
                        Thread.Sleep(500);
                        if (exeProcess.Responding)
                        {
                            Process.Start("taskkill /F /IM \"League of Legends.exe\"");
                        }
                        loginPacket = await this.connection.GetLoginDataPacketForUser();

                        archiveSumLevel = sumLevel;
                        sumLevel        = loginPacket.AllSummonerData.SummonerLevel.Level;
                        if (sumLevel != archiveSumLevel)
                        {
                            levelUp();
                        }
                    }
                }
            }
        }
Ejemplo n.º 21
0
        private async void Process()
        {
            try
            {
                if (_client == null)
                {
                    return;
                }

                if (await CheckForReconnect())
                {
                    return;
                }

                if (Completed())
                {
                    _account.FinishedLeveling(this, null);
                    return;
                }

                if (_account.Level >= 3)
                {
                    _loginDataPacket = await _client.GetLoginDataPacketForUser();

                    var expBoosts = await _client.GetSumonerActiveBoosts();

                    if (_loginDataPacket.RpBalance >= 260 && new DateTime((long)expBoosts.XpBoostEndDate * 10000) < DateTime.Now)
                    {
                        var url = await _client.GetStoreUrl();

                        BuyBoost(url);
                    }
                }

                if (!Globals.Configuration.CoopVsAI)
                {
                    if (Master)
                    {
                        CreateRoom();
                        return;
                    }

                    var practiceGames = await _client.ListAllPracticeGames();

                    var practiceGame = practiceGames.ToList().Find(g => g.Name.Equals(_container.GameName));

                    if (practiceGame != null)
                    {
                        await _client.JoinGame(practiceGame.Id, _container.GamePassword);

                        return;
                    }

                    Process();
                    return;
                }

                if (Master && _lobbyStatus == null)
                {
                    var queues = await _client.GetAvailableQueues();

                    var queue = queues.ToList().Find(q => q.Type == "BOT" && q.NumPlayersPerTeam == 5 && q.GameMode == "CLASSIC");
                    _queueId = queue.Id;
                    Log.Write("Creating lobbhy for queue.");

                    var lobby = await _client.CreateArrangedBotTeamLobby(queue.Id, "MEDIUM");

                    _lobbyStatus = lobby;

                    Log.Write("Lobby created. {0}", lobby.InvitationID);

                    _container.Bots.ForEach((bot) => {
                        if (!bot.Master && bot.SummonerId != 0)
                        {
                            _client.Invite(bot.SummonerId);
                        }
                    });
                }
                else if (Master && _lobbyStatus != null)
                {
                    _container.Bots.FindAll(b => Array.IndexOf(_lobbyStatus.Members, b.SummonerId) == -1).ForEach((bot) => {
                        if (!bot.Master)
                        {
                            _client.Invite(bot.SummonerId);
                        }
                    });
                }
            }
            catch (RtmpSharp.Net.ClientDisconnectedException ex)
            {
                if (_disconnectRequested)
                {
                    return;
                }
            }
            catch (RtmpSharp.Messaging.InvocationException ex)
            {
                if (_disconnectRequested)
                {
                    return;
                }

                if (ex.FaultString.Contains("Security"))
                {
                    Quit();
                    Start();
                    return;
                }
                Log.Error("[{0}] join error: {1}", _account.Username, ex.Message);
            }

            Process();
        }
Ejemplo n.º 22
0
        public async Task <StartStatus> Start()
        {
            _disconnectRequested = false;
            Log.Write("Logging in as: {0} | {1}", _account.Username, _account.Password);

            CreateClient();
            var connected = await _client.Connect(_account.Username, _account.Password);

            if (!connected)
            {
                return(StartStatus.Failed);
            }

            _lastAction = DateTime.Now;

            _loginDataPacket = await _client.GetLoginDataPacketForUser();

            // Setup default values
            if (_account.Level == 1 && _loginDataPacket.AllSummonerData == null)
            {
                var summoner = await _client.CreateDefaultSummoner(_account.Username.Length >= 16?_account.Username.Substring(0, 15) : _account.Username);

                while (summoner == null)
                {
                    summoner = await _client.CreateDefaultSummoner(string.Format("NameFail{0}", Program.GenerateString(5)));
                }
            }
            else
            {
                _account.Level = (int)_loginDataPacket.AllSummonerData.SummonerLevel.Level;
            }

            if (_loginDataPacket.AllSummonerData == null || _loginDataPacket.AllSummonerData.Summoner.DisplayEloQuestionaire)
            {
                await _client.ProcessEloQuestionaire();

                await _client.UpdateProfileIcon(1);

                await _client.SaveSeenTutorialFlag();

                _loginDataPacket = await _client.GetLoginDataPacketForUser();
            }

            _summonerId = _loginDataPacket.AllSummonerData.Summoner.SumId;

            if (Completed())
            {
                return(StartStatus.Finished);
            }

            var champs = await _client.GetAvailableChampions();

            _champions = champs.ToList().FindAll(c => c.FreeToPlay);

            if (Master)
            {
                _container.GenerateGamePair();
            }

            Process();
            return(StartStatus.Ok);
        }
Ejemplo n.º 23
0
        public async void connection_OnMessageReceived(object sender, object message)
        {
            if (message is GameDTO)
            {
                GameDTO game = message as GameDTO;
                switch (game.GameState)
                {
                case "START_REQUESTED":
                    break;

                case "FAILED_TO_START":
                    parent.updateStatus(msgStatus.ERROR, "Failed to Start", Accountname);
                    break;

                case "CHAMP_SELECT":
                    firstTimeInCustom   = true;
                    firstTimeInQueuePop = true;
                    if (firstTimeInLobby)
                    {
                        firstTimeInLobby = false;
                        updateStatus("In Champion Select", Accountname);
                        object obj = await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT");

                        if (queueType != QueueTypes.ARAM)
                        {
                            if (parent.championToPick != "" && parent.championToPick != "RANDOM")
                            {
                                int Spell1;
                                int Spell2;
                                if (!parent.randomSpell)
                                {
                                    Spell1 = Enums.spellToId(parent.spell1);
                                    Spell2 = Enums.spellToId(parent.spell2);
                                }
                                else
                                {
                                    var random    = new Random();
                                    var spellList = new List <int> {
                                        13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4
                                    };

                                    int index  = random.Next(spellList.Count);
                                    int index2 = random.Next(spellList.Count);

                                    int randomSpell1 = spellList[index];
                                    int randomSpell2 = spellList[index2];

                                    if (randomSpell1 == randomSpell2)
                                    {
                                        int index3 = random.Next(spellList.Count);
                                        randomSpell2 = spellList[index3];
                                    }

                                    Spell1 = Convert.ToInt32(randomSpell1);
                                    Spell2 = Convert.ToInt32(randomSpell2);
                                }

                                await connection.SelectSpells(Spell1, Spell2);

                                await connection.SelectChampion(Enums.championToId(parent.championToPick));

                                await connection.ChampionSelectCompleted();
                            }
                            else if (parent.championToPick == "RANDOM")
                            {
                                int Spell1;
                                int Spell2;
                                if (!parent.randomSpell)
                                {
                                    Spell1 = Enums.spellToId(parent.spell1);
                                    Spell2 = Enums.spellToId(parent.spell2);
                                }
                                else
                                {
                                    var random    = new Random();
                                    var spellList = new List <int> {
                                        13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4
                                    };

                                    int index  = random.Next(spellList.Count);
                                    int index2 = random.Next(spellList.Count);

                                    int randomSpell1 = spellList[index];
                                    int randomSpell2 = spellList[index2];

                                    if (randomSpell1 == randomSpell2)
                                    {
                                        int index3 = random.Next(spellList.Count);
                                        randomSpell2 = spellList[index3];
                                    }

                                    Spell1 = Convert.ToInt32(randomSpell1);
                                    Spell2 = Convert.ToInt32(randomSpell2);
                                }

                                await connection.SelectSpells(Spell1, Spell2);

                                var randAvailableChampsArray = availableChampsArray.Shuffle();
                                await connection.SelectChampion(randAvailableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId);

                                await connection.ChampionSelectCompleted();
                            }
                            else
                            {
                                int Spell1;
                                int Spell2;
                                if (!parent.randomSpell)
                                {
                                    Spell1 = Enums.spellToId(parent.spell1);
                                    Spell2 = Enums.spellToId(parent.spell2);
                                }
                                else
                                {
                                    var random    = new Random();
                                    var spellList = new List <int> {
                                        13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4
                                    };

                                    int index  = random.Next(spellList.Count);
                                    int index2 = random.Next(spellList.Count);

                                    int randomSpell1 = spellList[index];
                                    int randomSpell2 = spellList[index2];

                                    if (randomSpell1 == randomSpell2)
                                    {
                                        int index3 = random.Next(spellList.Count);
                                        randomSpell2 = spellList[index3];
                                    }

                                    Spell1 = Convert.ToInt32(randomSpell1);
                                    Spell2 = Convert.ToInt32(randomSpell2);
                                }

                                await connection.SelectSpells(Spell1, Spell2);

                                await connection.SelectChampion(availableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId);

                                await connection.ChampionSelectCompleted();
                            }
                        }
                        break;
                    }
                    else
                    {
                        break;
                    }

                case "POST_CHAMP_SELECT":
                    firstTimeInLobby = false;
                    if (firstTimeInPostChampSelect)
                    {
                        firstTimeInPostChampSelect = false;
                        updateStatus("(Post Champ Select)", Accountname);
                    }
                    break;

                case "IN_QUEUE":
                    updateStatus("In Queue", Accountname);
                    break;

                case "TERMINATED":
                    updateStatus("Re-entering queue", Accountname);
                    firstTimeInPostChampSelect = true;
                    firstTimeInQueuePop        = true;
                    break;

                case "JOINING_CHAMP_SELECT":
                    if (this.firstTimeInQueuePop && game.StatusOfParticipants.Contains("1"))
                    {
                        updateStatus("Accepted Queue", Accountname);
                        firstTimeInQueuePop = false;
                        firstTimeInLobby    = true;
                        object obj = await connection.AcceptPoppedGame(true);

                        break;
                    }
                    else
                    {
                        break;
                    }

                default:
                    updateStatus("[DEFAULT]" + game.GameStateString, Accountname);
                    break;
                }
            }
            else if (message.GetType() == typeof(TradeContractDTO))
            {
                var tradeDto = message as TradeContractDTO;
                if (tradeDto == null)
                {
                    return;
                }
                switch (tradeDto.State)
                {
                case "PENDING":
                {
                    if (tradeDto != null)
                    {
                        await connection.AcceptTrade(tradeDto.RequesterInternalSummonerName, (int)tradeDto.RequesterChampionId);
                    }
                }
                break;
                }
                return;
            }
            else if (message is PlayerCredentialsDto)
            {
                firstTimeInPostChampSelect = true;
                PlayerCredentialsDto dto       = message as PlayerCredentialsDto;
                ProcessStartInfo     startInfo = new ProcessStartInfo();
                startInfo.CreateNoWindow   = false;
                startInfo.WorkingDirectory = FindLoLExe();
                startInfo.FileName         = "League of Legends.exe";
                startInfo.Arguments        = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + dto.ServerIp + " " +
                                             dto.ServerPort + " " + dto.EncryptionKey + " " + dto.SummonerId + "\"";
                updateStatus("Launching League of Legends\n", Accountname);

                new Thread(() =>
                {
                    exeProcess         = Process.Start(startInfo);
                    exeProcess.Exited += new EventHandler(exeProcess_Exited);
                    while (exeProcess.MainWindowHandle == IntPtr.Zero)
                    {
                    }
                    exeProcess.PriorityClass       = ProcessPriorityClass.Idle;
                    exeProcess.EnableRaisingEvents = true;
                    //Thread.Sleep(1000);
                }).Start();
            }
            else if (message is EndOfGameStats)
            {
                if (exeProcess != null)
                {
                    exeProcess.Exited -= exeProcess_Exited;
                    exeProcess.Kill();
                    Thread.Sleep(500);
                    if (exeProcess.Responding)
                    {
                        Process.Start("taskkill /F /IM \"League of Legends.exe\"");
                    }
                    loginPacket = await this.connection.GetLoginDataPacketForUser();

                    archiveSumLevel = sumLevel;
                    sumLevel        = loginPacket.AllSummonerData.SummonerLevel.Level;
                    if (sumLevel != archiveSumLevel)
                    {
                        levelUp();
                    }
                }
                AttachToQueue();
            }
        }
Ejemplo n.º 24
0
 private void connection_OnLogin(object sender, string username, string ipAddress)
 {
     new Thread((ThreadStart)(async() =>
     {
         updateStatus("Connecting...", Accountname);
         loginPacket = await connection.GetLoginDataPacketForUser();
         if (loginPacket.AllSummonerData == null)
         {
             Random rnd = new Random();
             String summonerName = Accountname;
             if (summonerName.Length > 16)
             {
                 summonerName = summonerName.Substring(0, 11) + new Random().Next(1000, 9999).ToString();
             }
             updateStatus("Create Summoner: " + summonerName, Accountname);
             await connection.CreateDefaultSummoner(summonerName);
         }
         await connection.Subscribe("bc", loginPacket.AllSummonerData.Summoner.AcctId);
         await connection.Subscribe("cn", loginPacket.AllSummonerData.Summoner.AcctId);
         await connection.Subscribe("gn", loginPacket.AllSummonerData.Summoner.AcctId);
         sumLevel = loginPacket.AllSummonerData.SummonerLevel.Level;
         sumName = loginPacket.AllSummonerData.Summoner.Name;
         sumId = loginPacket.AllSummonerData.Summoner.SumId;
         rpBalance = loginPacket.RpBalance;
         if (sumLevel > parent.maxLevel || sumLevel == parent.maxLevel)
         {
             connection.Disconnect();
             updateStatus("Summoner: " + sumName + " is already max level.", Accountname);
             updateStatus("Log into new account.", Accountname);
             parent.lognNewAccount();
             return;
         }
         if (sumLevel < 3.0 && queueType == QueueTypes.NORMAL_5x5)
         {
             this.updateStatus("Need to be Level 3 before NORMAL_5x5 queue.", Accountname);
             this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 3", Accountname);
             queueType = QueueTypes.BEGINNER_BOT;
             actualQueueType = QueueTypes.NORMAL_5x5;
         }
         else if (sumLevel < 6.0 && queueType == QueueTypes.ARAM)
         {
             this.updateStatus("Need to be Level 6 before ARAM queue.", Accountname);
             this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 6", Accountname);
             queueType = QueueTypes.BEGINNER_BOT;
             actualQueueType = QueueTypes.ARAM;
         }
         else if (sumLevel < 7.0 && queueType == QueueTypes.NORMAL_3x3)
         {
             this.updateStatus("Need to be Level 7 before NORMAL_3x3 queue.", Accountname);
             this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 7", Accountname);
             queueType = QueueTypes.BEGINNER_BOT;
             actualQueueType = QueueTypes.NORMAL_3x3;
         }
         if ((loginPacket.AllSummonerData.Summoner.ProfileIconId == -1 || loginPacket.AllSummonerData.Summoner.ProfileIconId == 1))
         {
             double[] ids = new double[Convert.ToInt32(sumId)];
             string icons = await connection.GetSummonerIcons(ids);
             List <int> availableIcons = new List <int> {
             };
             var random = new Random();
             for (int i = 0; i < 29; i++)
             {
                 availableIcons.Add(i);
             }
             foreach (var id in icons)
             {
                 availableIcons.Add(Convert.ToInt32(id));
             }
             int index = random.Next(availableIcons.Count);
             int randomIcon = availableIcons[index];
             await connection.UpdateProfileIconId(randomIcon);
         }
         if (rpBalance == 400.0 && parent.buyBoost && sumLevel < 5)
         {
             updateStatus("Buying XP Boost", Accountname);
             try
             {
                 Task t = new Task(buyBoost);
                 t.Start();
             }
             catch (Exception exception)
             {
                 updateStatus("Couldn't buy RP Boost.\n" + exception, Accountname);
             }
         }
         updateStatus("Logged in as " + loginPacket.AllSummonerData.Summoner.Name + " @ level " + loginPacket.AllSummonerData.SummonerLevel.Level, Accountname);
         availableChampsArray = await connection.GetAvailableChampions();
         PlayerDTO player = await connection.CreatePlayer();
         if (loginPacket.ReconnectInfo != null && loginPacket.ReconnectInfo.Game != null)
         {
             connection_OnMessageReceived(sender, (object)loginPacket.ReconnectInfo.PlayerCredentials);
         }
         else
         {
             connection_OnMessageReceived(sender, (object)new EndOfGameStats());
         }
     })).Start();
 }
Ejemplo n.º 25
0
        public async void connection_OnMessageReceived(object sender, object message)
        {
            if (message is GameDTO)
            {
                GameDTO game = message as GameDTO;
                switch (game.GameState)
                {
                case "CHAMP_SELECT":
                    if (this.firstTimeInLobby)
                    {
                        firstTimeInLobby = false;
                        updateStatus("In Champion Select", Accountname);
                        object obj = await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT");

                        if (queueType != QueueTypes.ARAM)
                        {
                            if (Program.championId != "")
                            {
                                await connection.SelectChampion(Enums.championToId(Program.championId));

                                await connection.ChampionSelectCompleted();
                            }
                            else
                            {
                                await connection.SelectChampion(availableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId);

                                await connection.ChampionSelectCompleted();

                                int Spell1;
                                int Spell2;
                                if (!Program.rndSpell)
                                {
                                    Spell1 = Enums.spellToId(Program.spell1);
                                    Spell2 = Enums.spellToId(Program.spell2);
                                }
                                else
                                {
                                    var random    = new Random();
                                    var spellList = new List <int> {
                                        13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4
                                    };

                                    int index  = random.Next(spellList.Count);
                                    int index2 = random.Next(spellList.Count);

                                    int randomSpell1 = spellList[index];
                                    int randomSpell2 = spellList[index2];

                                    if (randomSpell1 == randomSpell2)
                                    {
                                        int index3 = random.Next(spellList.Count);
                                        randomSpell2 = spellList[index3];
                                    }

                                    Spell1 = Convert.ToInt32(randomSpell1);
                                    Spell2 = Convert.ToInt32(randomSpell2);
                                }

                                await connection.SelectSpells(Spell1, Spell2);
                            }
                        }
                        break;
                    }
                    else
                    {
                        break;
                    }

                case "POST_CHAMP_SELECT":
                    firstTimeInLobby = false;
                    this.updateStatus("(Post Champ Select)", Accountname);
                    break;

                case "PRE_CHAMP_SELECT":
                    this.updateStatus("(Pre Champ Select)", Accountname);
                    break;

                case "GAME_START_CLIENT":
                    this.updateStatus("Game client ran", Accountname);
                    break;

                case "GameClientConnectedToServer":
                    this.updateStatus("Client connected to the server", Accountname);
                    break;

                case "IN_QUEUE":
                    this.updateStatus("In Queue", Accountname);
                    break;

                case "TERMINATED":
                    this.updateStatus("Re-entering queue", Accountname);
                    this.firstTimeInQueuePop = true;
                    break;

                case "JOINING_CHAMP_SELECT":
                    if (this.firstTimeInQueuePop && game.StatusOfParticipants.Contains("1"))
                    {
                        this.updateStatus("Accepted Queue", Accountname);
                        this.firstTimeInQueuePop = false;
                        this.firstTimeInLobby    = true;
                        object obj = await this.connection.AcceptPoppedGame(true);

                        break;
                    }
                    else
                    {
                        break;
                    }
                }
            }
            else if (message is PlayerCredentialsDto)
            {
                string str = Enumerable.Last <string>((IEnumerable <string>)Enumerable.OrderBy <string, DateTime>(Directory.EnumerateDirectories((this.ipath ?? "") + "RADS\\solutions\\lol_game_client_sln\\releases\\"), (Func <string, DateTime>)(f => new DirectoryInfo(f).CreationTime))) + "\\deploy\\";
                LoLLauncher.RiotObjects.Platform.Game.PlayerCredentialsDto credentials = message as PlayerCredentialsDto;
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.CreateNoWindow   = false;
                startInfo.WorkingDirectory = str;
                startInfo.FileName         = "League of Legends.exe";
                startInfo.Arguments        = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + credentials.ServerIp + " " +
                                             credentials.ServerPort + " " + credentials.EncryptionKey + " " + credentials.SummonerId + "\"";
                updateStatus("Launching League of Legends", Accountname);
                new Thread((ThreadStart)(() =>
                {
                    exeProcess = Process.Start(startInfo);
                    exeProcess.Exited += exeProcess_Exited;
                    while (exeProcess.MainWindowHandle == IntPtr.Zero)
                    {
                        ;
                    }
                    exeProcess.PriorityClass = ProcessPriorityClass.Idle;
                    exeProcess.EnableRaisingEvents = true;
                })).Start();
            }
            else if (!(message is GameNotification) && !(message is SearchingForMatchNotification))
            {
                if (message is EndOfGameStats)
                {
                    LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams matchParams = new LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams();
                    if (queueType == QueueTypes.INTRO_BOT)
                    {
                        matchParams.BotDifficulty = "INTRO";
                    }
                    else if (queueType == QueueTypes.BEGINNER_BOT)
                    {
                        matchParams.BotDifficulty = "EASY";
                    }
                    else if (queueType == QueueTypes.MEDIUM_BOT)
                    {
                        matchParams.BotDifficulty = "MEDIUM";
                    }

                    if (sumLevel == 3 && actualQueueType == QueueTypes.NORMAL_5x5)
                    {
                        queueType = actualQueueType;
                    }
                    else if (sumLevel == 6 && actualQueueType == QueueTypes.ARAM)
                    {
                        queueType = actualQueueType;
                    }
                    else if (sumLevel == 7 && actualQueueType == QueueTypes.NORMAL_3x3)
                    {
                        queueType = actualQueueType;
                    }

                    matchParams.QueueIds = new Int32[1] {
                        (int)queueType
                    };
                    LoLLauncher.RiotObjects.Platform.Matchmaking.SearchingForMatchNotification m = await connection.AttachToQueue(matchParams);

                    if (m.PlayerJoinFailures == null)
                    {
                        this.updateStatus("In Queue: " + queueType.ToString(), Accountname);
                    }
                    else
                    {
                        try
                        {
                            updateStatus("Couldn't enter Q - " + m.PlayerJoinFailures.Summoner.Name + " : " + m.PlayerJoinFailures.ReasonFailed, Accountname);
                        }
                        catch (Exception) { Console.WriteLine("Something went wrong, couldn't enter queue. Check accounts.txt for correct queue type."); connection.Disconnect(); }
                    }
                }
                else
                {
                    if (message.ToString().Contains("EndOfGameStats"))
                    {
                        EndOfGameStats eog = new EndOfGameStats();
                        connection_OnMessageReceived(sender, eog);
                        exeProcess.Exited -= exeProcess_Exited;
                        exeProcess.Kill();
                        loginPacket = await this.connection.GetLoginDataPacketForUser();

                        archiveSumLevel = sumLevel;
                        sumLevel        = loginPacket.AllSummonerData.SummonerLevel.Level;
                        if (sumLevel != archiveSumLevel)
                        {
                            levelUp();
                        }
                    }
                }
            }
        }
Ejemplo n.º 26
0
#pragma warning disable 4014 //Code does not need to be awaited


        private async void GotLoginPacket(LoginDataPacket packet)
        {
            if (packet.AllSummonerData == null)
            {
                //Just Created Account, need to put logic here.
                Client.done = false;
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    var createSummoner = new CreateSummonerNameOverlay();
                    Client.OverlayContainer.Content    = createSummoner.Content;
                    Client.OverlayContainer.Visibility = Visibility.Visible;
                }));
                while (!Client.done)
                {
                }
                Client.PVPNet.Connect(LoginUsernameBox.Text, LoginPasswordBox.Password, Client.Region.PVPRegion,
                                      Client.Version);
                return;
            }
            Client.LoginPacket = packet;
            if (packet.AllSummonerData.Summoner.ProfileIconId == -1)
            {
                Client.done = false;
                Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() =>
                {
                    Client.OverlayContainer.Content    = new ChooseProfilePicturePage().Content;
                    Client.OverlayContainer.Visibility = Visibility.Visible;
                }));
                while (!Client.done)
                {
                }
                Client.PVPNet.Connect(LoginUsernameBox.Text, LoginPasswordBox.Password, Client.Region.PVPRegion,
                                      Client.Version);

                return;
            }
            Client.PlayerChampions = await Client.PVPNet.GetAvailableChampions();

            Client.PVPNet.OnError -= PVPNet_OnError;
            Client.GameConfigs     = packet.GameTypeConfigs;
            Client.PVPNet.Subscribe("bc", packet.AllSummonerData.Summoner.AcctId);
            Client.PVPNet.Subscribe("cn", packet.AllSummonerData.Summoner.AcctId);
            Client.PVPNet.Subscribe("gn", packet.AllSummonerData.Summoner.AcctId);
            Client.IsLoggedIn = true;


            Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() =>
            {
                Client.StatusContainer.Visibility = Visibility.Visible;
                Client.Container.Margin           = new Thickness(0, 0, 0, 40);

                var newCredentials = new AuthenticationCredentials
                {
                    Username      = LoginUsernameBox.Text,
                    Password      = LoginPasswordBox.Password,
                    ClientVersion = Client.Version,
                    IpAddress     = GetNewIpAddress(),
                    Locale        = Client.Region.Locale,
                    Domain        = "lolclient.lol.riotgames.com"
                };
                //Almost like the lol client now
                string os        = Environment.OSVersion.ToString();
                string[] ossplit = os.Split('.');
                if (ossplit[0] == "Windows 8")
                {
                    if (ossplit[1] == "1")
                    {
                        os = "Windows 8.1";
                    }
                }
                else
                {
                    os = ossplit[0];
                }

                newCredentials.OperatingSystem = os;

                Session login        = await Client.PVPNet.Login(newCredentials);
                Client.PlayerSession = login;

                //Setup chat
                if (!Client.Garena)
                {
                    Client.ChatClient.AutoReconnect = 30;
                    Client.ChatClient.KeepAlive     = 10;
                    Client.ChatClient.NetworkHost   = "chat." + Client.Region.ChatName + ".lol.riotgames.com";
                    Client.ChatClient.Port          = 5223;
                    Client.ChatClient.Server        = "pvp.net";
                    Client.ChatClient.SSL           = true;
                    Client.ChatClient.User          = LoginUsernameBox.Text;
                    Client.ChatClient.Password      = "******" + LoginPasswordBox.Password;
                    Client.userpass = new KeyValuePair <String, String>(LoginUsernameBox.Text,
                                                                        "AIR_" + LoginPasswordBox.Password);
                    Client.ChatClient.OnInvalidCertificate += Client.ChatClient_OnInvalidCertificate;
                    Client.ChatClient.OnMessage            += Client.ChatClient_OnMessage;
                    Client.ChatClient.OnPresence           += Client.ChatClient_OnPresence;
                    Client.ChatClient.OnDisconnect         += Client.ChatClient_OnDisconnect;
                    Client.ChatClient.Connect();
                }
                else
                {
                    Client.ChatClient.AutoReconnect = 30;
                    Client.ChatClient.KeepAlive     = 10;
                    Client.ChatClient.NetworkHost   = Client.Region.ChatName;
                    Client.ChatClient.Port          = 5223;
                    Client.ChatClient.Server        = "pvp.net";
                    Client.ChatClient.SSL           = true;
                    Client.ChatClient.User          = packet.AllSummonerData.Summoner.AcctId.ToString();
                    Client.ChatClient.Password      = "******" + GetLast(packet.AllSummonerData.Summoner.AcctId.ToString(), 5);
                    Client.userpass = new KeyValuePair <String, String>(packet.AllSummonerData.Summoner.AcctId.ToString(),
                                                                        "AIR_pass" + GetLast(packet.AllSummonerData.Summoner.AcctId.ToString(), 5));
                    Client.ChatClient.OnInvalidCertificate += Client.ChatClient_OnInvalidCertificate;
                    Client.ChatClient.OnMessage            += Client.ChatClient_OnMessage;
                    Client.ChatClient.OnPresence           += Client.ChatClient_OnPresence;
                    Client.ChatClient.OnDisconnect         += Client.ChatClient_OnDisconnect;
                    Client.ChatClient.Connect();
                }

                Client.RostManager = new RosterManager
                {
                    Stream    = Client.ChatClient,
                    AutoAllow = AutoSubscriptionHanding.AllowAll
                };
                Client.RostManager.OnRosterItem += Client.RostManager_OnRosterItem;
                Client.RostManager.OnRosterEnd  += Client.ChatClientConnect;

                Client.PresManager = new PresenceManager
                {
                    Stream = Client.ChatClient
                };
                Client.PresManager.OnPrimarySessionChange += Client.PresManager_OnPrimarySessionChange;

                Client.ConfManager = new ConferenceManager
                {
                    Stream = Client.ChatClient
                };
                //switch
                Client.Log("Connected to " + Client.Region.RegionName + " and logged in as " +
                           Client.LoginPacket.AllSummonerData.Summoner.Name);

                //Gather data and convert it that way that it does not cause errors
                PlatformGameLifecycleDTO data = Client.LoginPacket.ReconnectInfo;

                if (data != null && data.Game != null)
                {
                    Client.Log(data.PlayerCredentials.ChampionId.ToString(CultureInfo.InvariantCulture));
                    Client.CurrentGame = data.PlayerCredentials;
                    Client.GameType    = data.Game.GameType;
                    Client.SwitchPage(new InGame());
                }
                else
                {
                    uiLogic.UpdateMainPage();
                }

                Client.ClearPage(typeof(LoginPage));
            }));
        }
Ejemplo n.º 27
0
 private void GotPlayerData(LoginDataPacket packet)
 {
     Client.PVPNet.OnMessageReceived += PVPNet_OnMessageReceived;
     UpdateSummonerInformation();
 }
        public async void connection_OnMessageReceived(object sender, object message)
        {
            //=======================
            if (message is GameDTO)
            {
                GameDTO game = message as GameDTO;
                switch (game.GameState)
                {
                case "CHAMP_SELECT":
                    if (this.firstTimeInLobby)
                    {
                        updateStatus("Bắt đầu trận thứ : " + solandachoi, "");
                        firstTimeInLobby = false;
                        updateStatus("Đang chọn tướng !", Accountname);
                        object obj = await connection.SetClientReceivedGameMessage(game.Id, "CHAMP_SELECT_CLIENT");

                        if (queueType != QueueTypes.ARAM)
                        {
                            if (Program.championId != "" && Program.championId != "RANDOM")
                            {
                                int Spell1;
                                int Spell2;
                                if (!Program.rndSpell)
                                {
                                    Spell1 = Enums.spellToId(Program.spell1);
                                    Spell2 = Enums.spellToId(Program.spell2);
                                }
                                else
                                {
                                    var random    = new Random();
                                    var spellList = new List <int> {
                                        13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4
                                    };

                                    int index  = random.Next(spellList.Count);
                                    int index2 = random.Next(spellList.Count);

                                    int randomSpell1 = spellList[index];
                                    int randomSpell2 = spellList[index2];

                                    if (randomSpell1 == randomSpell2)
                                    {
                                        int index3 = random.Next(spellList.Count);
                                        randomSpell2 = spellList[index3];
                                    }

                                    Spell1 = Convert.ToInt32(randomSpell1);
                                    Spell2 = Convert.ToInt32(randomSpell2);
                                }

                                await connection.SelectSpells(Spell1, Spell2);

                                await connection.SelectChampion(Enums.championToId(Program.championId));

                                updateStatus("Bạn chọn tướng : " + Program.championId, Accountname);
                                updateStatus("Phép bổ trợ 1 : " + Program.spell1, Accountname);
                                updateStatus("Phép bổ trợ 2 : " + Program.spell2, Accountname);
                                await connection.ChampionSelectCompleted();
                            }
                            else if (Program.championId == "RANDOM")
                            {
                                int Spell1;
                                int Spell2;
                                if (!Program.rndSpell)
                                {
                                    Spell1 = Enums.spellToId(Program.spell1);
                                    Spell2 = Enums.spellToId(Program.spell2);
                                }
                                else
                                {
                                    var random    = new Random();
                                    var spellList = new List <int> {
                                        13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4
                                    };

                                    int index  = random.Next(spellList.Count);
                                    int index2 = random.Next(spellList.Count);

                                    int randomSpell1 = spellList[index];
                                    int randomSpell2 = spellList[index2];

                                    if (randomSpell1 == randomSpell2)
                                    {
                                        int index3 = random.Next(spellList.Count);
                                        randomSpell2 = spellList[index3];
                                    }

                                    Spell1 = Convert.ToInt32(randomSpell1);
                                    Spell2 = Convert.ToInt32(randomSpell2);
                                }

                                await connection.SelectSpells(Spell1, Spell2);

                                var randAvailableChampsArray = availableChampsArray.Shuffle();
                                await connection.SelectChampion(randAvailableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId);

                                updateStatus("Chọn tướng ngẫu nhiên ", Accountname);
                                updateStatus("Bạn chọn tướng : " + randAvailableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId, Accountname);
                                updateStatus("Phép bổ trợ 1 : " + Spell1, Accountname);
                                updateStatus("Phép bổ trợ 2 : " + Spell2, Accountname);
                                await connection.ChampionSelectCompleted();
                            }
                            else
                            {
                                int Spell1;
                                int Spell2;
                                if (!Program.rndSpell)
                                {
                                    Spell1 = Enums.spellToId(Program.spell1);
                                    Spell2 = Enums.spellToId(Program.spell2);
                                }
                                else
                                {
                                    var random    = new Random();
                                    var spellList = new List <int> {
                                        13, 6, 7, 10, 1, 11, 21, 12, 3, 14, 2, 4
                                    };

                                    int index  = random.Next(spellList.Count);
                                    int index2 = random.Next(spellList.Count);

                                    int randomSpell1 = spellList[index];
                                    int randomSpell2 = spellList[index2];

                                    if (randomSpell1 == randomSpell2)
                                    {
                                        int index3 = random.Next(spellList.Count);
                                        randomSpell2 = spellList[index3];
                                    }

                                    Spell1 = Convert.ToInt32(randomSpell1);
                                    Spell2 = Convert.ToInt32(randomSpell2);
                                }

                                await connection.SelectSpells(Spell1, Spell2);

                                await connection.SelectChampion(availableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId);

                                updateStatus("Chọn tướng đầu tiên", Accountname);
                                updateStatus("Bạn chọn tướng : " + availableChampsArray.First(champ => champ.Owned || champ.FreeToPlay).ChampionId, Accountname);
                                updateStatus("Phép bổ trợ 1 : " + Spell1, Accountname);
                                updateStatus("Phép bổ trợ 2 : " + Spell2, Accountname);
                                await connection.ChampionSelectCompleted();
                            }
                        }
                        break;
                    }
                    else
                    {
                        break;
                    }

                case "POST_CHAMP_SELECT":
                    firstTimeInLobby = false;
                    this.updateStatus("(Post Champ Select)", Accountname);
                    break;

                case "PRE_CHAMP_SELECT":
                    this.updateStatus("(Pre Champ Select)", Accountname);
                    break;

                case "GAME_START_CLIENT":
                    this.updateStatus("Trò chơi bắt đầu .", Accountname);
                    break;

                case "GameClientConnectedToServer":
                    this.updateStatus("Client kết nối tới sever .", Accountname);
                    break;

                case "IN_QUEUE":
                    this.updateStatus("Đang tìm trận ...", Accountname);
                    QueueFlag = true;
                    break;

                case "TERMINATED":

                    if (solandachoi <= solanchoi)
                    {
                        updateStatus("Xong trận thứ : " + solandachoi, "");
                        this.updateStatus("Vào lại hàng chờ !", Accountname);
                        solandachoi++;
                    }
                    else
                    {
                        connection.Disconnect();
                        updateStatus("Hết số lần chơi ! . Thoát LOL ...", "");
                        Process[] processes = Process.GetProcessesByName("RitoBot");
                        foreach (Process process in processes)
                        {
                            process.Kill();
                            process.WaitForExit();
                        }
                    }
                    Thread.Sleep(2000);
                    this.firstTimeInQueuePop = true;
                    break;

                case "JOINING_CHAMP_SELECT":
                    if (this.firstTimeInQueuePop && game.StatusOfParticipants.Contains("1"))
                    {
                        this.updateStatus("Đang chờ người chơi !", Accountname);
                        this.firstTimeInQueuePop = false;
                        this.firstTimeInLobby    = true;
                        object obj = await this.connection.AcceptPoppedGame(true);

                        break;
                    }
                    else
                    {
                        break;
                    }

                case "LEAVER_BUSTED":
                    this.updateStatus("Leave busted", Accountname);
                    break;
                }
            }
            else if (message is PlayerCredentialsDto)
            {
                string str = ipath + "GAME\\";

                /* string str = Enumerable.Last<string>((IEnumerable<string>)Enumerable.OrderBy<string, DateTime>(Directory.EnumerateDirectories((this.ipath ?? "")
                 + "RADS\\solutions\\lol_game_client_sln\\releases\\"), (Func<string, DateTime>)(f => new DirectoryInfo(f).CreationTime))) + "\\deploy\\";*/
                LoLLauncher.RiotObjects.Platform.Game.PlayerCredentialsDto credentials = message as PlayerCredentialsDto;
                System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
                startInfo.CreateNoWindow   = false;
                startInfo.WorkingDirectory = str;
                startInfo.FileName         = "League of Legends.exe";
                startInfo.Arguments        = "\"8394\" \"LoLLauncher.exe\" \"\" \"" + credentials.ServerIp + " " +
                                             credentials.ServerPort + " " + credentials.EncryptionKey + " " + credentials.SummonerId + "\"";
                updateStatus("League of Legends đang chạy !", Accountname);
                new Thread((ThreadStart)(() =>
                {
                    exeProcess = Process.Start(startInfo);
                    exeProcess.Exited += exeProcess_Exited;
                    while (exeProcess.MainWindowHandle == IntPtr.Zero)
                    {
                        ;
                    }
                    exeProcess.PriorityClass = ProcessPriorityClass.Idle;
                    exeProcess.EnableRaisingEvents = true;
                })).Start();
            }
            else if (!(message is GameNotification) && !(message is SearchingForMatchNotification))
            {
                if (message is EndOfGameStats)
                {
                    LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams matchParams = new LoLLauncher.RiotObjects.Platform.Matchmaking.MatchMakerParams();
                    if (queueType == QueueTypes.INTRO_BOT)
                    {
                        matchParams.BotDifficulty = "INTRO";
                    }
                    else if (queueType == QueueTypes.BEGINNER_BOT)
                    {
                        matchParams.BotDifficulty = "EASY";
                    }
                    else if (queueType == QueueTypes.MEDIUM_BOT)
                    {
                        matchParams.BotDifficulty = "MEDIUM";
                    }

                    if (sumLevel == 3 && actualQueueType == QueueTypes.NORMAL_5x5)
                    {
                        queueType = actualQueueType;
                    }
                    else if (sumLevel == 6 && actualQueueType == QueueTypes.ARAM)
                    {
                        queueType = actualQueueType;
                    }
                    else if (sumLevel == 7 && actualQueueType == QueueTypes.NORMAL_3x3)
                    {
                        queueType = actualQueueType;
                    }

                    matchParams.QueueIds = new Int32[1] {
                        (int)queueType
                    };
                    LoLLauncher.RiotObjects.Platform.Matchmaking.SearchingForMatchNotification m = await connection.AttachToQueue(matchParams);

                    if (m.PlayerJoinFailures == null)
                    {
                        this.updateStatus("Chế độ chơi : " + queueType.ToString(), Accountname);
                    }
                    else
                    {
                        try
                        {
                            updateStatus("Couldn't enter Q - " + m.PlayerJoinFailures.Summoner.Name + " : " + m.PlayerJoinFailures.ReasonFailed, Accountname);
                        }
                        catch (Exception)
                        {
                            if (QueueFlag)
                            {
                                Console.WriteLine(
                                    "Something went wrong, couldn't enter queue. Check accounts.txt for correct queue type.");
                                connection.Disconnect();
                            }
                            else
                            {
                                this.updateStatus("Bạn đang bị vào hàng chờ thấp ... VCC", Accountname);
                                this.updateStatus("Tool đang check . đợi xíu . 1 phút 1 lần !", Accountname);
                                Thread.Sleep(1000 * 60);
                                EndOfGameStats eog = new EndOfGameStats();
                                connection_OnMessageReceived(sender, eog);
                            }
                        }
                    }
                }
                else
                {
                    if (message.ToString().Contains("EndOfGameStats"))
                    {
                        EndOfGameStats eog = new EndOfGameStats();
                        connection_OnMessageReceived(sender, eog);
                        exeProcess.Exited -= exeProcess_Exited;
                        exeProcess.Kill();
                        loginPacket = await this.connection.GetLoginDataPacketForUser();

                        archiveSumLevel = sumLevel;
                        sumLevel        = loginPacket.AllSummonerData.SummonerLevel.Level;
                        if (sumLevel != archiveSumLevel)
                        {
                            levelUp();
                        }
                    }
                }
            }
            //=======================
        }
Ejemplo n.º 29
0
        public async void connection_OnMessageReceived(object sender, object message)
        {
            if (message is GameDTO)
            {
                GameDTO gameDTO = message as GameDTO;
                string  gameState;
                switch (gameState = gameDTO.GameState)
                {
                case "START_REQUESTED":
                    return;

                case "FAILED_TO_START":
                    this.parent.updateStatus(msgStatus.ERROR, "Failed to Start", this.Accountname);
                    return;

                case "CHAMP_SELECT":
                {
                    this.firstTimeInCustom   = true;
                    this.firstTimeInQueuePop = true;
                    if (!this.firstTimeInLobby)
                    {
                        return;
                    }
                    this.firstTimeInLobby = false;
                    this.updateStatus("In Champion Select", this.Accountname);
                    await this.connection.SetClientReceivedGameMessage(gameDTO.Id, "CHAMP_SELECT_CLIENT");

                    if (this.queueType == QueueTypes.ARAM)
                    {
                        return;
                    }
                    if (this.parent.championToPick != "" && this.parent.championToPick != "RANDOM")
                    {
                        int spellOneId;
                        int spellTwoId;
                        if (!this.parent.randomSpell)
                        {
                            spellOneId = Enums.spellToId(this.parent.spell1);
                            spellTwoId = Enums.spellToId(this.parent.spell2);
                        }
                        else
                        {
                            Random     random = new Random();
                            List <int> list   = new List <int>
                            {
                                13,
                                6,
                                7,
                                10,
                                1,
                                11,
                                21,
                                12,
                                3,
                                14,
                                2,
                                4
                            };
                            int index  = random.Next(list.Count);
                            int index2 = random.Next(list.Count);
                            int num2   = list[index];
                            int num3   = list[index2];
                            if (num2 == num3)
                            {
                                int index3 = random.Next(list.Count);
                                num3 = list[index3];
                            }
                            spellOneId = Convert.ToInt32(num2);
                            spellTwoId = Convert.ToInt32(num3);
                        }
                        await this.connection.SelectSpells(spellOneId, spellTwoId);

                        await this.connection.SelectChampion(Enums.championToId(this.parent.championToPick));

                        await this.connection.ChampionSelectCompleted();

                        return;
                    }
                    if (this.parent.championToPick == "RANDOM")
                    {
                        int spellOneId2;
                        int spellTwoId2;
                        if (!this.parent.randomSpell)
                        {
                            spellOneId2 = Enums.spellToId(this.parent.spell1);
                            spellTwoId2 = Enums.spellToId(this.parent.spell2);
                        }
                        else
                        {
                            Random     random2 = new Random();
                            List <int> list2   = new List <int>
                            {
                                13,
                                6,
                                7,
                                10,
                                1,
                                11,
                                21,
                                12,
                                3,
                                14,
                                2,
                                4
                            };
                            int index4 = random2.Next(list2.Count);
                            int index5 = random2.Next(list2.Count);
                            int num4   = list2[index4];
                            int num5   = list2[index5];
                            if (num4 == num5)
                            {
                                int index6 = random2.Next(list2.Count);
                                num5 = list2[index6];
                            }
                            spellOneId2 = Convert.ToInt32(num4);
                            spellTwoId2 = Convert.ToInt32(num5);
                        }
                        await this.connection.SelectSpells(spellOneId2, spellTwoId2);

                        IEnumerable <ChampionDTO> source = this.availableChampsArray.Shuffle <ChampionDTO>();
                        await this.connection.SelectChampion(source.First((ChampionDTO champ) => champ.Owned || champ.FreeToPlay).ChampionId);

                        await this.connection.ChampionSelectCompleted();

                        return;
                    }
                    int spellOneId3;
                    int spellTwoId3;
                    if (!this.parent.randomSpell)
                    {
                        spellOneId3 = Enums.spellToId(this.parent.spell1);
                        spellTwoId3 = Enums.spellToId(this.parent.spell2);
                    }
                    else
                    {
                        Random     random3 = new Random();
                        List <int> list3   = new List <int>
                        {
                            13,
                            6,
                            7,
                            10,
                            1,
                            11,
                            21,
                            12,
                            3,
                            14,
                            2,
                            4
                        };
                        int index7 = random3.Next(list3.Count);
                        int index8 = random3.Next(list3.Count);
                        int num6   = list3[index7];
                        int num7   = list3[index8];
                        if (num6 == num7)
                        {
                            int index9 = random3.Next(list3.Count);
                            num7 = list3[index9];
                        }
                        spellOneId3 = Convert.ToInt32(num6);
                        spellTwoId3 = Convert.ToInt32(num7);
                    }
                    await this.connection.SelectSpells(spellOneId3, spellTwoId3);

                    await this.connection.SelectChampion(this.availableChampsArray.First((ChampionDTO champ) => champ.Owned || champ.FreeToPlay).ChampionId);

                    await this.connection.ChampionSelectCompleted();

                    return;
                }

                case "POST_CHAMP_SELECT":
                    this.firstTimeInLobby = false;
                    if (this.firstTimeInPostChampSelect)
                    {
                        this.firstTimeInPostChampSelect = false;
                        this.updateStatus("(Post Champ Select)", this.Accountname);
                        return;
                    }
                    return;

                case "IN_QUEUE":
                    this.updateStatus("In Queue", this.Accountname);
                    return;

                case "TERMINATED":
                    this.updateStatus("Re-entering queue", this.Accountname);
                    this.firstTimeInPostChampSelect = true;
                    this.firstTimeInQueuePop        = true;
                    return;

                case "JOINING_CHAMP_SELECT":
                    if (this.firstTimeInQueuePop && gameDTO.StatusOfParticipants.Contains("1"))
                    {
                        this.updateStatus("Accepted Queue", this.Accountname);
                        this.firstTimeInQueuePop = false;
                        this.firstTimeInLobby    = true;
                        await this.connection.AcceptPoppedGame(true);

                        return;
                    }
                    return;
                }
                this.updateStatus("[DEFAULT]" + gameDTO.GameStateString, this.Accountname);
            }
            else if (message.GetType() == typeof(TradeContractDTO))
            {
                TradeContractDTO tradeContractDTO = message as TradeContractDTO;
                if (tradeContractDTO != null)
                {
                    string expr_CDE = tradeContractDTO.State;
                    if (expr_CDE != null && expr_CDE == "PENDING" && tradeContractDTO != null)
                    {
                        await this.connection.AcceptTrade(tradeContractDTO.RequesterInternalSummonerName, (int)tradeContractDTO.RequesterChampionId);
                    }
                }
            }
            else if (message is PlayerCredentialsDto)
            {
                this.firstTimeInPostChampSelect = true;
                PlayerCredentialsDto playerCredentialsDto = message as PlayerCredentialsDto;
                ProcessStartInfo     startInfo            = new ProcessStartInfo();
                startInfo.CreateNoWindow   = false;
                startInfo.WorkingDirectory = this.FindLoLExe();
                startInfo.FileName         = "League of Legends.exe";
                startInfo.Arguments        = string.Concat(new object[]
                {
                    "\"8394\" \"LoLLauncher.exe\" \"\" \"",
                    playerCredentialsDto.ServerIp,
                    " ",
                    playerCredentialsDto.ServerPort,
                    " ",
                    playerCredentialsDto.EncryptionKey,
                    " ",
                    playerCredentialsDto.SummonerId,
                    "\""
                });
                this.updateStatus("Launching League of Legends\n", this.Accountname);
                new Thread(delegate
                {
                    this.exeProcess         = Process.Start(startInfo);
                    this.exeProcess.Exited += new EventHandler(this.exeProcess_Exited);
                    while (this.exeProcess.MainWindowHandle == IntPtr.Zero)
                    {
                    }
                    this.exeProcess.PriorityClass       = ProcessPriorityClass.Idle;
                    this.exeProcess.EnableRaisingEvents = true;
                }).Start();
            }
            else if (message is EndOfGameStats)
            {
                if (this.exeProcess != null)
                {
                    this.exeProcess.Exited -= new EventHandler(this.exeProcess_Exited);
                    this.exeProcess.Kill();
                    Thread.Sleep(500);
                    if (this.exeProcess.Responding)
                    {
                        Process.Start("taskkill /F /IM \"League of Legends.exe\"");
                    }
                    this.loginPacket = await this.connection.GetLoginDataPacketForUser();

                    this.archiveSumLevel = this.sumLevel;
                    this.sumLevel        = this.loginPacket.AllSummonerData.SummonerLevel.Level;
                    if (this.sumLevel != this.archiveSumLevel)
                    {
                        this.levelUp();
                    }
                }
                this.AttachToQueue();
            }
        }
        private void connection_OnLogin(object sender, string username, string ipAddress)
        {
            new Thread((ThreadStart)(async() =>
            {
                updateStatus("Connecting...", Accountname);
                this.RegisterNotifications();
                this.loginPacket = await this.connection.GetLoginDataPacketForUser();
                if (loginPacket.AllSummonerData == null)
                {
                    Random rnd = new Random();
                    String summonerName = Accountname;
                    if (summonerName.Length > 16)
                    {
                        summonerName = summonerName.Substring(0, 12) + new Random().Next(1000, 9999).ToString();
                    }
                    LoLLauncher.RiotObjects.Platform.Summoner.AllSummonerData sumData = await connection.CreateDefaultSummoner(summonerName);
                    loginPacket.AllSummonerData = sumData;
                    updateStatus("Created Summonername " + summonerName, Accountname);
                }
                sumLevel = loginPacket.AllSummonerData.SummonerLevel.Level;
                string sumName = loginPacket.AllSummonerData.Summoner.Name;
                double sumId = loginPacket.AllSummonerData.Summoner.SumId;
                rpBalance = loginPacket.RpBalance;
                if (sumLevel > Program.maxLevel || sumLevel == Program.maxLevel)
                {
                    connection.Disconnect();
                    updateStatus("Summoner: " + sumName + " is already max level.", Accountname);
                    updateStatus("Log into new account.", Accountname);
                    Program.lognNewAccount();
                    return;
                }
                if (rpBalance == 400.0 && Program.buyBoost)
                {
                    updateStatus("Buying XP Boost", Accountname);
                    try
                    {
                        Task t = new Task(buyBoost);
                        t.Start();
                    }
                    catch (Exception exception)
                    {
                        updateStatus("Couldn't buy RP Boost.\n" + exception, Accountname);
                    }
                }
                if (sumLevel < 3.0 && queueType == QueueTypes.NORMAL_5x5)
                {
                    this.updateStatus("Need to be Level 3 before NORMAL_5x5 queue.", Accountname);
                    this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 3", Accountname);
                    queueType = QueueTypes.BEGINNER_BOT;
                    actualQueueType = QueueTypes.NORMAL_5x5;
                }
                else if (sumLevel < 6.0 && queueType == QueueTypes.ARAM)
                {
                    this.updateStatus("Need to be Level 6 before ARAM queue.", Accountname);
                    this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 6", Accountname);
                    queueType = QueueTypes.BEGINNER_BOT;
                    actualQueueType = QueueTypes.ARAM;
                }
                else if (sumLevel < 7.0 && queueType == QueueTypes.NORMAL_3x3)
                {
                    this.updateStatus("Need to be Level 7 before NORMAL_3x3 queue.", Accountname);
                    this.updateStatus("Joins Co-Op vs AI (Beginner) queue until 7", Accountname);
                    queueType = QueueTypes.BEGINNER_BOT;
                    actualQueueType = QueueTypes.NORMAL_3x3;
                }

                /* Should be randomize the summonericon on every login,
                 * but only works with extra icons, so it crashes if you only got the standards.
                 * double[] ids = new double[Convert.ToInt32(sumId)];
                 * string icons = await connection.GetSummonerIcons(ids);
                 * List<int> availableIcons = new List<int> { };
                 * var random = new Random();
                 * foreach (var id in icons)
                 * {
                 *  availableIcons.Add(Convert.ToInt32(id));
                 *  Console.WriteLine("[DEBUG]: Added Icon: " + id);
                 * }
                 * int index = random.Next(availableIcons.Count);
                 * Console.WriteLine(" | Random Icon: " + index);
                 * int randomIcon = availableIcons[index];
                 * Console.WriteLine(" | Choose from List: " + randomIcon);
                 * await connection.UpdateProfileIconId(randomIcon);*/
                updateStatus("Đăng nhập : " + loginPacket.AllSummonerData.Summoner.Name + " @ level " + loginPacket.AllSummonerData.SummonerLevel.Level, Accountname);
                availableChampsArray = await connection.GetAvailableChampions();
                LoLLauncher.RiotObjects.Team.Dto.PlayerDTO player = await connection.CreatePlayer();
                if (this.loginPacket.ReconnectInfo != null && this.loginPacket.ReconnectInfo.Game != null)
                {
                    this.connection_OnMessageReceived(sender, (object)this.loginPacket.ReconnectInfo.PlayerCredentials);
                }
                else
                {
                    this.connection_OnMessageReceived(sender, (object)new EndOfGameStats());
                }
            })).Start();
        }
Ejemplo n.º 31
0
        /// 1.)
        public void GetLoginDataPacketForUser(LoginDataPacket.Callback callback)
        {
            LoginDataPacket cb = new LoginDataPacket(callback);

            InvokeWithCallback("clientFacadeService", "getLoginDataPacketForUser", new object[] { }, cb);
        }