private void CreateGameButton_Click(object sender, RoutedEventArgs e) { NameInvalidLabel.Visibility = Visibility.Hidden; PracticeGameConfig gameConfig = GenerateGameConfig(); Client.PVPNet.CreatePracticeGame(gameConfig, new GameDTO.Callback(CreatedGame)); }
public async Task CreateGame(dynamic args) { string allowSpectators = GameJsApiService.GetAllowSpectators((string)args.spectators); int num = (int)args.mapId; string str = (string)args.name; string str1 = (string)args.password; int num1 = (int)args.gctId; int num2 = (int)args.players; RiotAccount riotAccount = JsApiService.RiotAccount; PracticeGameConfig practiceGameConfig = new PracticeGameConfig() { AllowSpectators = allowSpectators }; PracticeGameConfig practiceGameConfig1 = practiceGameConfig; GameMap gameMap = new GameMap() { MapId = num, TotalPlayers = num2 }; practiceGameConfig1.GameMap = gameMap; practiceGameConfig.GameMode = GameJsApiService.GetGameMode(num); practiceGameConfig.GameName = str; practiceGameConfig.GamePassword = str1; practiceGameConfig.GameTypeConfig = num1; practiceGameConfig.MaxNumPlayers = num2; await riotAccount.InvokeAsync<object>("gameService", "createPracticeGame", practiceGameConfig); }
private void GenerateSpectatorCode() { try { PracticeGameConfig gameConfig = GenerateGameConfig(); TournamentCodeTextbox.Text = "pvpnet://lol/customgame/joinorcreate"; TournamentCodeTextbox.Text += "/map" + gameConfig.GameMap.MapId; TournamentCodeTextbox.Text += "/pick" + gameConfig.GameTypeConfig; TournamentCodeTextbox.Text += "/team" + gameConfig.MaxNumPlayers * 0.5; TournamentCodeTextbox.Text += "/spec" + gameConfig.AllowSpectators; string json = ""; if (String.IsNullOrEmpty(gameConfig.GamePassword)) { json = "{ \"name\": \"" + gameConfig.GameName + "\" }"; } else { json = "{ \"name\": \"" + gameConfig.GameName + "\", \"password\": \"" + gameConfig.GamePassword + "\" }"; } //Also "report" to get riot to send a report back, and "extra" to have data sent so you can identify it (passbackDataPacket) var plainTextBytes = System.Text.Encoding.UTF8.GetBytes(json); TournamentCodeTextbox.Text += "/" + System.Convert.ToBase64String(plainTextBytes); } catch { } }
private async void CreateGame(object sender, RoutedEventArgs e) { ErrorLabel.Visibility = Visibility.Collapsed; var config = new PracticeGameConfig(); config.GameName = GameName.Text; config.GamePassword = GamePass.Text; config.MaxNumPlayers = ((int)TeamSize.SelectedItem) * 2; config.GameTypeConfig = (GameType.SelectedItem as GameConfig).Key; config.AllowSpectators = (Spectators.SelectedItem as SpectatorState).Key; config.GameMap = selected; switch (selected.MapId) { case 8: config.GameMode = "ODIN"; break; case 10: case 11: config.GameMode = "CLASSIC"; break; case 12: case 14: config.GameMode = "ARAM"; break; } try { var lobby = await CustomLobby.CreateLobby(config); LoLClient.QueueManager.JoinLobby(lobby); } catch { ErrorLabel.Visibility = Visibility.Visible; } }
private async void CreateGameButton_Click(object sender, RoutedEventArgs e) { NameInvalidLabel.Visibility = Visibility.Hidden; PracticeGameConfig gameConfig = GenerateGameConfig(); CreatedGame(await RiotCalls.CreatePracticeGame(gameConfig)); }
private async void CreateGameButton_Click(object sender, RoutedEventArgs e) { NameInvalidLabel.Visibility = Visibility.Hidden; PracticeGameConfig gameConfig = GenerateGameConfig(); try { GameDTO dto = await RiotCalls.CreatePracticeGame(gameConfig); CreatedGame(dto); } catch (ClientDisconnectedException ex) { ErrorTextBox.Text = "Client has been disconnected. Please retry."; ErrorTextBox.Visibility = System.Windows.Visibility.Visible; } catch (InvocationException ex) { if (ex.Message.Contains("GameModeNotSupported")) { ErrorTextBox.Text = "Game mode not supported."; } else { ErrorTextBox.Text = "Unable to create custom game."; } ErrorTextBox.Visibility = System.Windows.Visibility.Visible; } }
private async void CreateRoom() { try { var config = new PracticeGameConfig(); if (Globals.Configuration.Dominion) { config.GameMap = GameMap.TheCrystalScar; } else { config.GameMap = GameMap.TheTwistedTreeline; } config.MaxNumPlayers = Globals.Configuration.Dominion ? 10 : 6; if (Globals.Configuration.Dominion3v3) { config.MaxNumPlayers = 6; } config.AllowSpectators = "ALL"; config.GameName = _container.GameName; if (Globals.Configuration.Dominion) { config.GameMode = "ODIN"; } else { config.GameMode = "CLASSIC"; } config.GameTypeConfig = 1; config.GamePassword = _container.GamePassword; _currentGame = await _client.CreatePracticeGame(config); Log.Write("[{0}] Master client created game: {1}:{2}", _account.Username, _container.GameName, _container.GamePassword); _lobbyTimer = new Timer(); _lobbyTimer.Elapsed += _lobbyTimer_Elapsed; _lobbyTimer.Interval = TimeSpan.FromMinutes(7).TotalMilliseconds; _lobbyTimer.Start(); } catch (RtmpSharp.Messaging.InvocationException ex) { Log.Error("[{0}] {1}", _account.Username, ex); _container.GenerateGamePair(); CreateRoom(); } }
public async Task <GameDTO> CreatePracticeGame(PracticeGameConfig practiceGameConfig) { int Id = Invoke("gameService", "createPracticeGame", new object[] { practiceGameConfig.GetBaseTypedObject() }); while (!results.ContainsKey(Id)) { await Task.Delay(10); } TypedObject messageBody = results[Id].GetTO("data").GetTO("body"); GameDTO result = new GameDTO(messageBody); results.Remove(Id); return(result); }
public static async Task <CustomLobby> CreateLobby(PracticeGameConfig config) { var lobby = new CustomLobby(); Session.Current.CurrentLobby = lobby; GameDTO game = await RiotServices.GameService.CreatePracticeGame(config); if (game?.Name == null) { throw new Exception("Invalid name"); } else { lobby.GotGameData(game); return(lobby); } }
/// <summary> /// Creates a practice game. /// </summary> /// <param name="config">The configuration for the practice game</param> /// <returns>Returns a GameDTO if successfully created, otherwise null</returns> public Task <GameDTO> CreatePracticeGame(PracticeGameConfig config) { return(InvokeAsync <GameDTO>("createPracticeGame", config)); }
/// 46.) public void CreatePracticeGame(PracticeGameConfig practiceGameConfig, GameDTO.Callback callback) { GameDTO cb = new GameDTO(callback); InvokeWithCallback("gameService", "createPracticeGame", new object[] { practiceGameConfig.GetBaseTypedObject() }, cb); }
/// <summary> /// Creates a practice game. /// </summary> /// <param name="Config">The configuration for the practice game</param> /// <returns>Returns a GameDTO if successfully created, otherwise null</returns> public static Task <GameDTO> CreatePracticeGame(PracticeGameConfig Config) { return(InvokeAsync <GameDTO>("gameService", "createPracticeGame", Config)); }
public GameDTO createPracticeGame(PracticeGameConfig gameCfg) { return((new InternalCallContext <GameDTO>(CreatePracticeGame, new object[] { gameCfg })).Execute()); }
private PracticeGameConfig GenerateGameConfig() { try { NameInvalidLabel.Visibility = Visibility.Hidden; PracticeGameConfig gameConfig = new PracticeGameConfig(); gameConfig.GameName = NameTextBox.Text; gameConfig.GamePassword = PasswordTextBox.Text; gameConfig.MaxNumPlayers = Convert.ToInt32(TeamSizeComboBox.SelectedItem) * 2; switch ((string)GameTypeComboBox.SelectedItem) { case "Blind Pick": gameConfig.GameTypeConfig = 1; break; case "No Ban Draft": gameConfig.GameTypeConfig = 3; break; case "All Random": gameConfig.GameTypeConfig = 4; break; case "Open Pick": gameConfig.GameTypeConfig = 5; break; case "Blind Draft": gameConfig.GameTypeConfig = 7; break; case "Infinite Time Blind Pick": gameConfig.GameTypeConfig = 11; break; case "One for All": gameConfig.GameTypeConfig = 14; break; case "Captain Pick": gameConfig.GameTypeConfig = 12; break; default: //Tournament Draft gameConfig.GameTypeConfig = 6; break; } switch ((string)((Label)MapListBox.SelectedItem).Content) { case "The Crystal Scar": gameConfig.GameMap = GameMap.TheCrystalScar; gameConfig.GameMode = "ODIN"; break; case "Howling Abyss": gameConfig.GameMap = GameMap.HowlingAbyss; gameConfig.GameMode = "ARAM"; break; case "The Twisted Treeline": gameConfig.GameMap = GameMap.TheTwistedTreeline; gameConfig.GameMode = "CLASSIC"; break; default: gameConfig.GameMap = GameMap.NewSummonersRift; gameConfig.GameMode = "CLASSIC"; break; } switch ((string)AllowSpectatorsComboBox.SelectedItem) { case "None": gameConfig.AllowSpectators = "NONE"; break; case "Lobby Only": gameConfig.AllowSpectators = "LOBBYONLY"; break; case "Friends List Only": gameConfig.AllowSpectators = "DROPINONLY"; break; default: gameConfig.AllowSpectators = "ALL"; break; } CreateGameButton.IsEnabled = true; return(gameConfig); } catch { return(null); } }
public Task <GameDTO> CreatePracticeGame(PracticeGameConfig config) { return(this.InvokeAsync <GameDTO>("gameService", "createPracticeGame", (object)config)); }
public async void connection_OnMessageReceived(object sender, object message) { if (message is GameDTO) { GameDTO game = message as GameDTO; switch (game.GameState) { case "TEAM_SELECT": if (Program.IsGameCreated == true && Program.LobbyPlayers == Program.maxBots && Program.LobbyOwner.Equals(Accountname) && leader) { Thread.Sleep(2000); this.updateStatus("Start Custom Game", Accountname); await connection.StartChampionSelection(Program.GameID, game.OptimisticLock); } break; 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 != "" && 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)); this.updateStatus("Champion Pick : " + Program.championId, this.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); this.updateStatus("Random Champion", this.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); this.updateStatus("Random Champion", this.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("Game client ran", Accountname); break; case "GameClientConnectedToServer": this.updateStatus("Client connected to the server", Accountname); break; case "IN_QUEUE": this.updateStatus("In Queue", Accountname); QueueFlag = true; break; case "TERMINATED": 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; } case "LEAVER_BUSTED": this.updateStatus("Leave busted", Accountname); break; } } else if (message is PlayerCredentialsDto) { string str = ipath + "GAME\\"; 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(); p = true; Program.IsGameCreated = false; totalgame++; } else if (message is EndOfGameStats) { EndOfGameStats eog = message as EndOfGameStats; if (p) { Console.ForegroundColor = ConsoleColor.Magenta; this.updateStatus("========Result========", this.Accountname); var tempxp = eog.ExperienceEarned + eog.BoostXpEarned; var tempip = eog.IpEarned + eog.BoostIpEarned; ip = ip + tempip; xp = xp + tempxp; bool tempvic = false; var allParticipants = new List <PlayerParticipantStatsSummary>(eog.TeamPlayerParticipantStats.ToArray()); foreach (PlayerParticipantStatsSummary summary in allParticipants) { foreach (RawStatDTO stat in summary.Statistics.Where(stat => stat.StatTypeName.ToLower() == "win")) { if (summary.SummonerName == loginPacket.AllSummonerData.Summoner.Name) { win++; tempvic = true; } } } if (tempvic) { this.updateStatus("Victory!", this.Accountname); } else { this.updateStatus("Defeat!", this.Accountname); } this.updateStatus("IP Earned: " + tempip, this.Accountname); this.updateStatus("XP Earned: " + tempxp, this.Accountname); var winrate = (win / totalgame) * 100; this.updateStatus("Win Rate: " + winrate + "%" + "(Win: " + win + " TotalGame: " + totalgame + ")", this.Accountname); if (loginPacket.AllSummonerData.SummonerLevel.Level < 30) { var xpnextlevel = loginPacket.AllSummonerData.SummonerLevel.ExpToNextLevel; this.updateStatus("Exp to Next Level : " + xpnextlevel, this.Accountname); } this.updateStatus("====================", this.Accountname); Console.ForegroundColor = ConsoleColor.Green; Console.Title = " Current Connected: " + Program.connectedAccs + " Total IP: " + ip + " Total XP:" + xp + " Total Game: " + totalgame + " WinRate: " + winrate + "%"; exeProcess.Exited -= exeProcess_Exited; exeProcess.Kill(); p = false; loginPacket = await this.connection.GetLoginDataPacketForUser(); archiveSumLevel = sumLevel; sumLevel = loginPacket.AllSummonerData.SummonerLevel.Level; if (sumLevel != archiveSumLevel) { levelUp(); } this.updateStatus("Re-entering queue", Accountname); } if (queueType == QueueTypes.CUSTOM_DOM_3x3 || queueType == QueueTypes.CUSTOM_HA_3x3) { if (Program.IsGameCreated == false && leader) { PracticeGameConfig cfg = new PracticeGameConfig(); BotParticipant bcg = new BotParticipant(); GameMap map = new GameMap(); if (queueType == QueueTypes.CUSTOM_DOM_3x3) { map.Description = "desc"; map.DisplayName = "Crystal Scar"; map.TotalPlayers = 6; map.Name = "Crystal Scar"; map.MapId = (int)GameMode.Dominion; map.MinCustomPlayers = 1; cfg.GameMode = StringEnum.GetStringValue(GameMode.Dominion); } else { map.Description = "desc"; map.DisplayName = "Howling Abyss"; map.TotalPlayers = 6; map.Name = "Howling Abyss"; map.MapId = (int)GameMode.HowlingAbyss; map.MinCustomPlayers = 1; cfg.GameMode = StringEnum.GetStringValue(GameMode.HowlingAbyss); } cfg.GameName = RandomString(10); cfg.GamePassword = "******"; cfg.GameMap = map; cfg.MaxNumPlayers = 6; cfg.GameTypeConfig = 1; cfg.AllowSpectators = "NONE"; GameDTO result = await connection.CreatePracticeGame(cfg); // Custom game has been created; Program.IsGameCreated = true; Program.GameID = result.Id; Program.LobbyOwner = Accountname; Program.LobbyPlayers = 1; // Notify updateStatus(" Game [" + Program.GameID + "] has been created. Lobby password: "******"Waiting Leader Create Room", Accountname); } while (!Program.IsGameCreated); if (Program.IsGameCreated == true && Program.LobbyOwner != Accountname && Program.LobbyPlayers < Program.maxBots && !leader) { Program.LobbyPlayers++; await connection.JoinGame(Program.GameID, "Paruru"); updateStatus(" Player has joined the lobby! Players: [" + Program.LobbyPlayers + "/" + Program.maxBots + "]", Accountname); System.Threading.Thread.Sleep(5000); } } } else { 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 { foreach (QueueDodger current in m.PlayerJoinFailures) { if (current.ReasonFailed == "LEAVER_BUSTED") { m_accessToken = current.AccessToken; if (current.LeaverPenaltyMillisRemaining > this.m_leaverBustedPenalty) { this.m_leaverBustedPenalty = current.LeaverPenaltyMillisRemaining; } } } if (!string.IsNullOrEmpty(this.m_accessToken)) { this.updateStatus("Waiting For Leaver Busted: " + (float)(this.m_leaverBustedPenalty / 1000) / 60f + " Minute", this.Accountname); Thread.Sleep(TimeSpan.FromMilliseconds((double)this.m_leaverBustedPenalty)); m = await connection.AttachToLowPriorityQueue(matchParams, this.m_accessToken); if (m.PlayerJoinFailures == null) { this.updateStatus("In Queue: " + queueType.ToString(), this.Accountname); } else { this.updateStatus("There was an error in joining lower priority queue.\nDisconnecting.", this.Accountname); this.connection.Disconnect(); } } } } } else { } }
public Task <GameDTO> CreatePracticeGame(PracticeGameConfig config) { return(Invoke <GameDTO>("gameService", "createPracticeGame", config)); }
private PracticeGameConfig GenerateGameConfig() { try { NameInvalidLabel.Visibility = Visibility.Hidden; var gameConfig = new PracticeGameConfig { GameName = NameTextBox.Text + "– " + Team1.Text + " vs. " + Team2.Text, GamePassword = PasswordTextBox.Text }; if (EasyCreate.IsChecked != null && (bool)EasyCreate.IsChecked) { gameConfig.GameName = "FACTIONS – " + Team1.Text + " vs. " + Team2.Text; gameConfig.GamePassword = "******"; } gameConfig.MaxNumPlayers = Convert.ToInt32(TeamSizeComboBox.SelectedItem) * 2; switch ((string)GameTypeComboBox.SelectedItem) { case "Blind Pick": gameConfig.GameTypeConfig = 1; break; case "No Ban Draft": gameConfig.GameTypeConfig = 3; break; case "All Random": gameConfig.GameTypeConfig = 4; break; case "Open Pick": gameConfig.GameTypeConfig = 5; break; case "Blind Draft": gameConfig.GameTypeConfig = 7; break; case "Infinite Time Blind Pick": gameConfig.GameTypeConfig = 11; break; case "One for All": gameConfig.GameTypeConfig = 14; break; case "Captain Pick": gameConfig.GameTypeConfig = 12; break; default: //Tournament Draft gameConfig.GameTypeConfig = 6; break; } switch ((string)((Label)MapListBox.SelectedItem).Content) { case "The Crystal Scar": gameConfig.GameMap = GameMap.TheCrystalScar; gameConfig.GameMode = "ODIN"; break; case "Howling Abyss": gameConfig.GameMap = GameMap.HowlingAbyss; gameConfig.GameMode = "ARAM"; break; case "The Twisted Treeline": gameConfig.GameMap = GameMap.TheTwistedTreeline; gameConfig.GameMode = "CLASSIC"; if (gameConfig.MaxNumPlayers < 3) { NameInvalidLabel.Content = "Team size must be lower or equal to 3"; NameInvalidLabel.Visibility = Visibility.Visible; CreateGameButton.IsEnabled = false; return(gameConfig); } break; default: gameConfig.GameMap = GameMap.SummonersRift; gameConfig.GameMode = "CLASSIC"; break; } switch ((string)AllowSpectatorsComboBox.SelectedItem) { case "None": gameConfig.AllowSpectators = "NONE"; break; case "Lobby Only": gameConfig.AllowSpectators = "LOBBYONLY"; break; case "Friends List Only": gameConfig.AllowSpectators = "DROPINONLY"; break; default: gameConfig.AllowSpectators = "ALL"; break; } CreateGameButton.IsEnabled = true; return(gameConfig); } catch { return(null); } }
private static async void doRoomStuff() { Client.selectedChampion = false; if (!handlersRegistered) { Client.RtmpConnection.MessageReceived += RoomMessageHandler; Client.RtmpConnection.MessageReceived += ChampSelectHandler; handlersRegistered = true; } bool playLvL30Dominion = false; //Our group already finished? if (System.IO.File.Exists("Logs/" + hostName + ".gfinished")) { System.Environment.Exit(0); } if (gameStarted) { return; } //try //{ // await RiotCalls.Leave(); //} //catch (Exception) //{ } //try //{ // await RiotCalls.QuitGame(); //} //catch (Exception) //{ } //Check if we are in an active game?!!! //if (botLevelLimit == "LEVEL_30") //{ // try // { // var gameInfo = await RiotCalls.RetrieveInProgressGameInfo(); // if (gameInfo.PlayerCredentials != null) // { // groupSplitted = true; // Console.WriteLine("Active Game Found: " + gameInfo.GameName); // StartClient(gameInfo.PlayerCredentials); // return; // } // } // catch (Exception ingameException) // { // return; // } //} if (botLevelLimit == "LEVEL_30") { //As soon as HOST or HOST2 hits LVL15 they will split the group in two pieces string _roomName = ""; string _hostName = ""; if (Client.botType == "HOST" || lvlGroupType == "ZERO") { _roomName = roomName; _hostName = hostName; } if (Client.botType == "HOST2" || lvlGroupType == "ONE") { _roomName = roomNameTwo; _hostName = hostNameTwo; } if (gameStarted) { return; } //Wait for HOSTS! Console.Write("Waiting for Hosts! | "); while (System.IO.File.Exists("Logs/AccountInfo/" + hostName + ".info") == false || System.IO.File.Exists("Logs/AccountInfo/" + hostNameTwo + ".info") == false) { Thread.Sleep(10000); } Console.WriteLine("OK"); //Get HOST and HOST2 Info dynamic hostInfo = Config.Load("Logs/AccountInfo/" + hostName + ".info"); dynamic hostTwoInfo = Config.Load("Logs/AccountInfo/" + hostNameTwo + ".info"); //Did HOSt or HOST2 hit lvl15? if (hostInfo.Info.Level >= 10 || hostTwoInfo.Info.Level >= 10) { groupSplitted = true; //If we are HOST or HOST2 if (Client.botType == "HOST" || Client.botType == "HOST2") { CREATE_LOBBY: try { //LobbyStatus lobbyStatus = await RiotCalls.CreateArrangedBotTeamLobby(33, "MEDIUM"); LobbyStatus lobbyStatus = await RiotCalls.CreateArrangedBotTeamLobby(25, "EASY"); } catch (Exception e) { if (!e.Message.Contains("AlreadyMemberOfInvitation")) { Console.WriteLine("EXCEPTION WHILE CREATING LOBBY:" + e.Message); Thread.Sleep(60000 * 5); restart(); return; } } inInviteLobby = true; await InvitePlayers(); } else //Normal Bot Instance here { bool noFile = false; string inviteFile = ""; try { //Are we alread in the list? inviteFile = System.IO.File.ReadAllText("Logs/Rooms/" + _hostName + ".invitationlist"); } catch (Exception) { noFile = true; } if (!inviteFile.Contains(Convert.ToInt32(lastSummonerData.Summoner.SumId).ToString())) { Console.WriteLine("Writing sumID: " + Convert.ToInt32(lastSummonerData.Summoner.SumId).ToString()); System.IO.File.AppendAllText("Logs/Rooms/" + _hostName + ".invitationlist", Convert.ToInt32(lastSummonerData.Summoner.SumId).ToString() + ":"); } } } else //So we wanna play Dominion then! { playLvL30Dominion = true; } } if (botLevelLimit == "LEVEL_5" || botLevelLimit == "LEVEL_10" || playLvL30Dominion) //LEVEL_5 & LEVEL_10 { try { if (Client.botType == "HOST") { CreatePracticeRoom: //Console.WriteLine("Creating Room..."); try { //Create Room PracticeGameConfig config = new PracticeGameConfig(); config.GameTypeConfig = 1; config.AllowSpectators = "DROPINONLY"; config.GamePassword = "******"; config.PassbackUrl = null; config.PassbackDataPacket = null; config.GameName = roomName; config.GameMode = "ODIN"; config.GameMap = GameMap.TheCrystalScar; config.MaxNumPlayers = 10; roomDto = await RiotCalls.CreatePracticeGame(config); System.IO.File.WriteAllText("Logs/Rooms/" + hostName + ".roomID", roomDto.Id.ToString()); Console.WriteLine("Room created! : " + roomDto.Id.ToString()); gameState = roomDto.GameState; } catch (Exception e) { //Players[] already in Game - Error I guess, dunno "already" should be enough - TODO: Fix this later! if (e.Message.Contains("already")) { try { RiotCalls.QuitGame(); } catch (Exception) { } try { RiotCalls.Leave(); } catch (Exception) { } Console.WriteLine("Players already in game | GUESSING SO | WAITING 1 Minute |" + e.Message); System.Threading.Thread.Sleep(60000); } else { Console.WriteLine(e.Message); } System.Threading.Thread.Sleep(10000); goto CreatePracticeRoom; } } else if ((Client.botType == "BOT" || Client.botType == "HOST2")) { int joinTry = 0; Console.WriteLine("Waiting for host..."); JoinRoom: double gameId = 0; while (gameId == 0) { try { gameId = Convert.ToDouble(System.IO.File.ReadAllText("Logs/Rooms/" + hostName + ".roomID")); } catch (Exception e) { gameId = 0; } System.Threading.Thread.Sleep(1000); } bool roomJoined = false; try { Console.WriteLine("Joining Room... : " + gameId.ToString()); await RiotCalls.JoinGame(gameId, "1234"); roomJoined = true; Console.WriteLine("Joined Room! = " + gameId.ToString()); gameState = "TEAM_SELECT"; return; } catch (Exception e) { if (e.Message.Contains("NotFound")) { try { System.IO.File.Delete("Logs/Rooms/" + hostName + ".roomID"); } catch (Exception fileDel) { } Console.WriteLine("Host room is no longer available!"); } else { Console.WriteLine(e.Message); } roomJoined = false; } if (!roomJoined) { ++joinTry; if (joinTry == 4) { restart(); } if (!roomJoined) { //Console.WriteLine("Could not join game!"); System.Threading.Thread.Sleep(20000); try { RiotCalls.QuitGame(); } catch (Exception) { } goto JoinRoom; } } gameState = "TEAM_SELECT"; } } catch (Exception e) { Console.WriteLine("Exception! - Reconnecting..."); Client.RtmpConnection = null; System.Threading.Thread.Sleep(1000); restart(); //Console.WriteLine("Reconnecting..."); //Application.Restart(); //System.Environment.Exit(-1); } } }