private static async void KickAndBan_Click(object sender, RoutedEventArgs e) { var button = sender as Button; if (button == null) { return; } var player = button.Tag as PlayerParticipant; if (player != null) { PlayerParticipant banPlayer = player; await Client.PVPNet.BanUserFromGame(Client.GameID, banPlayer.AccountId); } else { var tag = button.Tag as BotParticipant; if (tag == null) { return; } BotParticipant banPlayer = tag; await Client.PVPNet.RemoveBotChampion(champions.GetChampion(banPlayer.SummonerInternalName.Split('_')[1]).id, banPlayer); } }
public GameMember(BotParticipant bot, int pickTurn) : this(bot.SummonerInternalName) { Name = bot.SummonerName; var key = bot.SummonerInternalName.Split('_')[1]; Champion = DataDragon.ChampData.Value.data[key].key; Spell1 = Spell2 = 0; Active = bot.PickTurn == pickTurn; }
public ChampSelectPlayer(BotParticipant bot) : this() { var champ = DataDragon.ChampData.Value.data[bot.SummonerInternalName.Split('_')[1]]; ChampImage.Source = DataDragon.GetChampIconImage(champ).Load(); NameLabel.Visibility = Visibility.Visible; NameLabel.Content = champ.name; Unknown.Visibility = Obscure.Visibility = Visibility.Collapsed; }
/// 48.) public async Task <object> RemoveBotChampion(Int32 arg0, BotParticipant arg1) { int Id = Invoke("gameService", "removeBotChampion", new object[] { arg0, arg1.GetBaseTypedObject() }); while (!results.ContainsKey(Id)) { await Task.Delay(10); } results.Remove(Id); return(null); }
private BotControl RenderBot(BotParticipant BotPlayer) { BotControl botPlayer = new BotControl(); botPlayer.PlayerName.Content = BotPlayer.SummonerName; var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", BotPlayer.Champion + ".png"), UriKind.RelativeOrAbsolute); botPlayer.ProfileImage.Source = new BitmapImage(uriSource); botPlayer.BanButton.Tag = BotPlayer; botPlayer.BanButton.Click += KickAndBan_Click; return(botPlayer); }
private async void AddBotBlueTeam_Click(object sender, RoutedEventArgs e) { Int32 champint = getRandomChampInt(); champions champions = champions.GetChampion(champint); ChampionDTO champDTO = new ChampionDTO(); champDTO.Active = true; champDTO.Banned = false; champDTO.BotEnabled = true; champDTO.ChampionId = champint; champDTO.DisplayName = champions.displayName; List <ChampionSkinDTO> skinlist = new List <ChampionSkinDTO>(); foreach (Dictionary <string, object> Skins in champions.Skins) { ChampionSkinDTO skin = new ChampionSkinDTO(); skin.ChampionId = champint; skin.FreeToPlayReward = false; Int32 SkinInt = Convert.ToInt32(Skins["id"]); skin.SkinId = SkinInt; List <ChampionDTO> champs = new List <ChampionDTO>(Client.PlayerChampions); foreach (ChampionDTO x in champs) { foreach (ChampionSkinDTO myskin in x.ChampionSkins) { if (myskin.Owned) { } } } skin.Owned = true; skinlist.Add(skin); } champDTO.ChampionSkins = skinlist; BotParticipant par = new BotParticipant(); par.BotSkillLevelName = "Basic"; par.BotSkillLevel = 0; par.Champion = champDTO; await Client.PVPNet.SelectBotChampion(champint, par); await Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { })); }
private BotControl RenderBot(BotParticipant BotPlayer) { var botPlayer = new BotControl(); champions champ = champions.GetChampion(BotPlayer.SummonerInternalName.Split('_')[1]); var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champion", champ.name + ".png")); botPlayer.Width = 400; botPlayer.Margin = new Thickness(0, 0, 0, 5); botPlayer.PlayerName.Content = BotPlayer.SummonerName; botPlayer.ProfileImage.Source = new BitmapImage(uriSource); botPlayer.blueSide = BotPlayer.SummonerInternalName.Split('_')[2] == "100"; botPlayer.difficulty = BotPlayer.BotSkillLevel; botPlayer.cmbSelectDificulty.Visibility = Client.isOwnerOfGame ? Visibility.Visible : Visibility.Hidden; botPlayer.cmbSelectDificulty.Items.Add("Beginner"); botPlayer.cmbSelectDificulty.Items.Add("Intermediate"); botPlayer.cmbSelectDificulty.Items.Add("Doom"); botPlayer.cmbSelectDificulty.Items.Add("Intro"); botPlayer.cmbSelectDificulty.SelectedIndex = BotPlayer.BotSkillLevel; foreach (int bot in bots) { botPlayer.cmbSelectChamp.Items.Add(champions.GetChampion(bot).name); } botPlayer.cmbSelectChamp.Visibility = Client.isOwnerOfGame ? Visibility.Visible : Visibility.Hidden; botPlayer.cmbSelectChamp.SelectedItem = champ.name; botPlayer.BanButton.Visibility = Client.isOwnerOfGame ? Visibility.Visible : Visibility.Hidden; botPlayer.BanButton.Tag = BotPlayer; botPlayer.BanButton.Click += KickAndBan_Click; botPlayer.cmbSelectChamp.SelectionChanged += async(a, b) => { champions c = champions.GetChampion((string)botPlayer.cmbSelectChamp.SelectedValue); await Client.PVPNet.RemoveBotChampion(champ.id, BotPlayer); AddBot(c.id, botPlayer.blueSide, botPlayer.difficulty); }; botPlayer.cmbSelectDificulty.SelectionChanged += async(a, b) => { champions c = champions.GetChampion((string)botPlayer.cmbSelectChamp.SelectedValue); await Client.PVPNet.RemoveBotChampion(champ.id, BotPlayer); AddBot(c.id, botPlayer.blueSide, botPlayer.cmbSelectDificulty.SelectedIndex); }; return(botPlayer); }
internal virtual void Update(GameMember now) { Team = now.Team; if (now.IsPlayer && IsPlayer) { player = now.player; } else if (now.IsBot && IsBot) { bot = now.bot; } else { throw new Exception("Cant update"); } OnChange(); }
private void GameLobby_OnMessageReceived(object sender, object message) { if (message.GetType() == typeof(GameDTO)) { GameDTO dto = message as GameDTO; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { if (!HasConnectedToChat) { //Run once BaseMap map = BaseMap.GetMap(dto.MapId); MapLabel.Content = map.DisplayName; ModeLabel.Content = Client.TitleCaseString(dto.GameMode); GameTypeConfigDTO configType = Client.LoginPacket.GameTypeConfigs.Find(x => x.Id == dto.GameTypeConfigId); TypeLabel.Content = GetGameMode(configType.Id); SizeLabel.Content = dto.MaxNumPlayers / 2 + "v" + dto.MaxNumPlayers / 2; HasConnectedToChat = true; try { string ObfuscatedName = Client.GetObfuscatedChatroomName(dto.Name.ToLower() + Convert.ToInt32(dto.Id), ChatPrefixes.Arranging_Practice); string JID = Client.GetChatroomJID(ObfuscatedName, dto.RoomPassword, false); newRoom = Client.ConfManager.GetRoom(new jabber.JID(JID)); newRoom.Nickname = Client.LoginPacket.AllSummonerData.Summoner.Name; newRoom.OnRoomMessage += newRoom_OnRoomMessage; newRoom.OnParticipantJoin += newRoom_OnParticipantJoin; newRoom.Join(dto.RoomPassword); } catch { } } if (dto.GameState == "TEAM_SELECT") { OptomisticLock = dto.OptimisticLock; LaunchedTeamSelect = false; BlueTeamListView.Items.Clear(); PurpleTeamListView.Items.Clear(); List <Participant> AllParticipants = new List <Participant>(dto.TeamOne.ToArray()); AllParticipants.AddRange(dto.TeamTwo); int i = 0; bool PurpleSide = false; foreach (Participant playerTeam in AllParticipants) { i++; CustomLobbyPlayer lobbyPlayer = new CustomLobbyPlayer(); BotControl botPlayer = new BotControl(); if (playerTeam is PlayerParticipant) { PlayerParticipant player = playerTeam as PlayerParticipant; lobbyPlayer = RenderPlayer(player, dto.OwnerSummary.SummonerId == player.SummonerId); IsOwner = dto.OwnerSummary.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId; StartGameButton.IsEnabled = IsOwner; AddBotBlueTeam.IsEnabled = IsOwner; AddBotPurpleTeam.IsEnabled = IsOwner; if (Client.Whitelist.Count > 0) { if (!Client.Whitelist.Contains(player.SummonerName.ToLower())) { await Client.PVPNet.BanUserFromGame(Client.GameID, player.AccountId); } } } else if (playerTeam is BotParticipant) { BotParticipant botParticipant = playerTeam as BotParticipant; botPlayer = RenderBot(botParticipant); } if (i > dto.TeamOne.Count) { i = 0; PurpleSide = true; } if (!PurpleSide) { BlueTeamListView.Items.Add(lobbyPlayer); } else { PurpleTeamListView.Items.Add(lobbyPlayer); } } } else if (dto.GameState == "CHAMP_SELECT" || dto.GameState == "PRE_CHAMP_SELECT") { if (!LaunchedTeamSelect) { Client.ChampSelectDTO = dto; Client.LastPageContent = Client.Container.Content; Client.SwitchPage(new ChampSelectPage(this)); Client.GameStatus = "championSelect"; Client.SetChatHover(); LaunchedTeamSelect = true; } } })); } }
private static async void AddBot(int id, bool blueSide, int difficulty) { Int32 champint = (id == 0 ? GetRandomChampInt() : id); champions champions = champions.GetChampion(champint); var champDTO = new ChampionDTO { Active = true, Banned = false, BotEnabled = true, ChampionId = champint, DisplayName = champions.displayName }; List <ChampionSkinDTO> skinlist = (from Dictionary <string, object> skins in champions.Skins select new ChampionSkinDTO { ChampionId = champint, SkinId = Convert.ToInt32(skins["id"]), SkinIndex = Convert.ToInt32(skins["num"]), StillObtainable = true }).ToList(); champDTO.ChampionSkins = skinlist; var par = new BotParticipant { Champion = champDTO, pickMode = 0, IsGameOwner = false, PickTurn = 0, IsMe = false, Badges = 0, TeamName = null, Team = 0, SummonerName = champions.displayName + " bot" }; if (blueSide) { par.teamId = "100"; par.SummonerInternalName = "bot_" + champions.name + "_100"; } else { par.teamId = "200"; par.SummonerInternalName = "bot_" + champions.name + "_200"; } switch (difficulty) { case 0: par.botSkillLevelName = "Beginner"; par.BotSkillLevel = difficulty; break; case 1: par.botSkillLevelName = "Intermediate"; par.BotSkillLevel = difficulty; break; } await Client.PVPNet.SelectBotChampion(champint, par); }
/// <summary> /// Main logic behind Champion Select /// </summary> /// <param name="sender"></param> /// <param name="message"></param> private void ChampSelect_OnMessageReceived(object sender, object message) { if (message.GetType() == typeof(GameDTO)) { #region In Champion Select GameDTO ChampDTO = message as GameDTO; LatestDto = ChampDTO; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { //Allow all champions to be selected (reset our modifications) ListViewItem[] ChampionArray = new ListViewItem[ChampionSelectListView.Items.Count]; ChampionSelectListView.Items.CopyTo(ChampionArray, 0); foreach (ListViewItem y in ChampionArray) { y.IsHitTestVisible = true; y.Opacity = 1; } //Push all teams into one array to save a foreach call (looks messy) List <Participant> AllParticipants = new List <Participant>(ChampDTO.TeamOne.ToArray()); AllParticipants.AddRange(ChampDTO.TeamTwo); foreach (Participant p in AllParticipants) { if (p is PlayerParticipant) { PlayerParticipant play = (PlayerParticipant)p; //If it is our turn to pick if (play.PickTurn == ChampDTO.PickTurn) { if (play.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId) { ChampionSelectListView.IsHitTestVisible = true; ChampionSelectListView.Opacity = 1; GameStatusLabel.Content = "Your turn to pick!"; break; } } } //Otherwise block selection of champions unless in dev mode if (!DevMode) { ChampionSelectListView.IsHitTestVisible = false; ChampionSelectListView.Opacity = 0.5; } GameStatusLabel.Content = "Waiting for others to pick..."; } //Champion select was cancelled if (ChampDTO.GameState == "TEAM_SELECT") { if (CountdownTimer != null) { CountdownTimer.Stop(); } FixChampSelect(); FakePage fakePage = new FakePage(); fakePage.Content = LobbyContent; Client.SwitchPage(fakePage); return; } else if (ChampDTO.GameState == "PRE_CHAMP_SELECT") { //Banning phase. Enable banning phase and this will render only champions for ban BanningPhase = true; PurpleBansLabel.Visibility = Visibility.Visible; BlueBansLabel.Visibility = Visibility.Visible; BlueBanListView.Visibility = Visibility.Visible; PurpleBanListView.Visibility = Visibility.Visible; GameStatusLabel.Content = "Bans are on-going"; counter = configType.BanTimerDuration - 3; #region Render Bans BlueBanListView.Items.Clear(); PurpleBanListView.Items.Clear(); foreach (var x in ChampDTO.BannedChampions) { Image champImage = new Image(); champImage.Height = 58; champImage.Width = 58; champImage.Source = champions.GetChampion(x.ChampionId).icon; if (x.TeamId == 100) { BlueBanListView.Items.Add(champImage); } else { PurpleBanListView.Items.Add(champImage); } foreach (ListViewItem y in ChampionArray) { if ((int)y.Tag == x.ChampionId) { ChampionSelectListView.Items.Remove(y); //Remove from arrays foreach (ChampionDTO PlayerChamps in ChampList.ToArray()) { if (x.ChampionId == PlayerChamps.ChampionId) { ChampList.Remove(PlayerChamps); break; } } foreach (ChampionBanInfoDTO BanChamps in ChampionsForBan.ToArray()) { if (x.ChampionId == BanChamps.ChampionId) { ChampionsForBan.Remove(BanChamps); break; } } } } } #endregion Render Bans } else if (ChampDTO.GameState == "CHAMP_SELECT") { //Picking has started. If pickturn has changed reset timer LastPickTurn = ChampDTO.PickTurn; BanningPhase = false; } else if (ChampDTO.GameState == "POST_CHAMP_SELECT") { //Post game has started. Allow trading CanTradeWith = await Client.PVPNet.GetPotentialTraders(); HasLockedIn = true; GameStatusLabel.Content = "All players have picked!"; if (configType != null) { counter = configType.PostPickTimerDuration - 2; } else { counter = 10; } } else if (ChampDTO.GameState == "START_REQUESTED") { GameStatusLabel.Content = "The game is about to start!"; DodgeButton.IsEnabled = false; //Cannot dodge past this point! counter = 1; } else if (ChampDTO.GameState == "TERMINATED") { //TODO } #region Display players BlueListView.Items.Clear(); PurpleListView.Items.Clear(); int i = 0; bool PurpleSide = false; //Aram hack, view other players champions & names (thanks to Andrew) List <PlayerChampionSelectionDTO> OtherPlayers = new List <PlayerChampionSelectionDTO>(ChampDTO.PlayerChampionSelections.ToArray()); bool AreWePurpleSide = false; foreach (Participant participant in AllParticipants) { Participant tempParticipant = participant; i++; ChampSelectPlayer control = new ChampSelectPlayer(); //Cast AramPlayers as PlayerParticipants. This removes reroll data if (tempParticipant is AramPlayerParticipant) { tempParticipant = new PlayerParticipant(tempParticipant.GetBaseTypedObject()); } if (tempParticipant is PlayerParticipant) { PlayerParticipant player = tempParticipant as PlayerParticipant; control.PlayerName.Content = player.SummonerName; foreach (PlayerChampionSelectionDTO selection in ChampDTO.PlayerChampionSelections) { #region Disable picking selected champs foreach (ListViewItem y in ChampionArray) { if ((int)y.Tag == selection.ChampionId) { y.IsHitTestVisible = false; y.Opacity = 0.5; if (configType != null) { if (configType.DuplicatePick) { y.IsHitTestVisible = true; y.Opacity = 1; } } } } #endregion Disable picking selected champs if (selection.SummonerInternalName == player.SummonerInternalName) { //Clear our teams champion selection for aram hack OtherPlayers.Remove(selection); control = RenderPlayer(selection, player); //If we have locked in render skin select if (HasLockedIn && selection.SummonerInternalName == Client.LoginPacket.AllSummonerData.Summoner.InternalName && !DevMode) { if (PurpleSide) { AreWePurpleSide = true; } RenderLockInGrid(selection); if (player.PointSummary != null) { LockInButton.Content = string.Format("Reroll ({0}/{1})", player.PointSummary.CurrentPoints, player.PointSummary.PointsCostToRoll); if (player.PointSummary.NumberOfRolls > 0) { LockInButton.IsEnabled = true; } else { LockInButton.IsEnabled = false; } } } } } } else if (tempParticipant is ObfuscatedParticipant) { control.PlayerName.Content = "Summoner " + i; } else if (tempParticipant is BotParticipant) { BotParticipant bot = tempParticipant as BotParticipant; string botChamp = bot.SummonerName.Split(' ')[0]; //Why is this internal name rito? champions botSelectedChamp = champions.GetChampion(botChamp); PlayerParticipant part = new PlayerParticipant(); PlayerChampionSelectionDTO selection = new PlayerChampionSelectionDTO(); selection.ChampionId = botSelectedChamp.id; part.SummonerName = botSelectedChamp.displayName + " bot"; control = RenderPlayer(selection, part); } else { control.PlayerName.Content = "Unknown Summoner"; } //Display purple side if we have gone through our team if (i > ChampDTO.TeamOne.Count) { i = 0; PurpleSide = true; } if (!PurpleSide) { BlueListView.Items.Add(control); } else { PurpleListView.Items.Add(control); } } //Do aram hack! if (OtherPlayers.Count > 0) { if (AreWePurpleSide) { BlueListView.Items.Clear(); } else { PurpleListView.Items.Clear(); } foreach (PlayerChampionSelectionDTO hackSelection in OtherPlayers) { ChampSelectPlayer control = new ChampSelectPlayer(); PlayerParticipant player = new PlayerParticipant(); player.SummonerName = hackSelection.SummonerInternalName; control = RenderPlayer(hackSelection, player); if (AreWePurpleSide) { BlueListView.Items.Add(control); } else { PurpleListView.Items.Add(control); } } } #endregion Display players })); #endregion In Champion Select } else if (message.GetType() == typeof(PlayerCredentialsDto)) { #region Launching Game PlayerCredentialsDto dto = message as PlayerCredentialsDto; Client.CurrentGame = dto; if (!HasLaunchedGame) { HasLaunchedGame = true; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { if (CountdownTimer != null) { CountdownTimer.Stop(); } QuitCurrentGame(); })); Client.LaunchGame(); } #endregion Launching Game } else if (message.GetType() == typeof(TradeContractDTO)) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { TradeContractDTO TradeDTO = message as TradeContractDTO; if (TradeDTO.State == "PENDING") { PlayerTradeControl.Visibility = System.Windows.Visibility.Visible; PlayerTradeControl.Tag = TradeDTO; PlayerTradeControl.AcceptButton.Visibility = System.Windows.Visibility.Visible; PlayerTradeControl.DeclineButton.Content = "Decline"; champions MyChampion = champions.GetChampion((int)TradeDTO.ResponderChampionId); PlayerTradeControl.MyChampImage.Source = MyChampion.icon; PlayerTradeControl.MyChampLabel.Content = MyChampion.displayName; champions TheirChampion = champions.GetChampion((int)TradeDTO.RequesterChampionId); PlayerTradeControl.TheirChampImage.Source = TheirChampion.icon; PlayerTradeControl.TheirChampLabel.Content = TheirChampion.displayName; PlayerTradeControl.RequestLabel.Content = string.Format("{0} wants to trade!", TradeDTO.RequesterInternalSummonerName); } else if (TradeDTO.State == "CANCELED" || TradeDTO.State == "DECLINED" || TradeDTO.State == "BUSY") { PlayerTradeControl.Visibility = System.Windows.Visibility.Hidden; NotificationPopup pop = new NotificationPopup(ChatSubjects.INVITE_STATUS_CHANGED, string.Format("{0} has {1} this trade", TradeDTO.RequesterInternalSummonerName, TradeDTO.State)); if (TradeDTO.State == "BUSY") { pop.NotificationTextBox.Text = string.Format("{0} is currently busy", TradeDTO.RequesterInternalSummonerName); } pop.Height = 200; pop.OkButton.Visibility = System.Windows.Visibility.Visible; pop.HorizontalAlignment = HorizontalAlignment.Right; pop.VerticalAlignment = VerticalAlignment.Bottom; Client.NotificationGrid.Children.Add(pop);//*/ } })); } }
internal GameMember(BotParticipant bot, int team, Lobby lobby) : base(lobby) { this.bot = bot; Team = team; }
internal CustomLobbyMember(BotParticipant bot, int team, CustomLobby lobby) : base(bot, team, lobby) { }
public Task <object> SelectBotChampion(int champId, BotParticipant item) { return(InvokeAsync <object>("gameService", "selectBotChampion", (object)champId, (object)item)); }
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 static Task <object> SelectBotChampion(Int32 champID, BotParticipant bot) { return(InvokeAsync <object>("gameService", "selectBotChampion", champID, bot)); }