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;
 }
示例#2
0
 private void connection_OnLogin(object sender, string username, string ipAddress)
 {
     new Thread((ThreadStart)(async () =>
     {
         updateStatus("Connecting...", Accountname);
         loginPacket = await connection.GetLoginDataPacketForUser();
         await connection.Subscribe("bc", loginPacket.AllSummonerData.Summoner.AcctId);
         await connection.Subscribe("cn", loginPacket.AllSummonerData.Summoner.AcctId);
         await connection.Subscribe("gn", loginPacket.AllSummonerData.Summoner.AcctId);
         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();
             await connection.CreateDefaultSummoner(summonerName);
             updateStatus("Created Summoner: " + summonerName, Accountname);
         }
         sumLevel = loginPacket.AllSummonerData.SummonerLevel.Level;
         string sumName = loginPacket.AllSummonerData.Summoner.Name;
         double sumId = loginPacket.AllSummonerData.Summoner.SumId;
         rpBalance = loginPacket.RpBalance;
         if (sumLevel > Core.maxLevel || sumLevel == Core.maxLevel)
         {
             connection.Disconnect();
             updateStatus("Summoner: " + sumName + " is already max level.", Accountname);
             updateStatus("Log into new account.", Accountname);
             Core.lognNewAccount();
             return;
         }
         if (rpBalance == 400.0 && Core.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;
         }
         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);
         }
         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();
 }
 /// 1.)
 public void GetLoginDataPacketForUser(LoginDataPacket.Callback callback)
 {
     LoginDataPacket cb = new LoginDataPacket(callback);
     InvokeWithCallback("clientFacadeService", "getLoginDataPacketForUser", new object[] { }, cb);
 }
示例#4
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! >.<", 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();
                 }
             }
         }
     }
 }