private CustomLobbyPlayer RenderPlayer(PlayerParticipant player, bool IsOwner) { CustomLobbyPlayer lobbyPlayer = new CustomLobbyPlayer(); lobbyPlayer.PlayerName.Content = player.SummonerName; var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", player.ProfileIconId + ".png"), UriKind.RelativeOrAbsolute); lobbyPlayer.ProfileImage.Source = new BitmapImage(uriSource); if (IsOwner) { lobbyPlayer.OwnerLabel.Visibility = Visibility.Visible; } lobbyPlayer.Width = 400; lobbyPlayer.Margin = new Thickness(0, 0, 0, 5); if ((player.SummonerId == Client.LoginPacket.AllSummonerData.Summoner.SumId) || (player.SummonerId != Client.LoginPacket.AllSummonerData.Summoner.SumId && !this.IsOwner)) { lobbyPlayer.BanButton.Visibility = Visibility.Hidden; } lobbyPlayer.BanButton.Tag = player; lobbyPlayer.BanButton.Click += KickAndBan_Click; return(lobbyPlayer); }
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(PlayerParticipant player, PlayerChampionSelectionDTO selection, TradeContractDTO trade, bool canTrade, int pickTurn) : this(player.SummonerInternalName) { Name = player.SummonerName; Champion = selection?.ChampionId ?? 0; Spell1 = selection?.Spell1Id ?? 0; Spell2 = selection?.Spell2Id ?? 0; Active = player.PickTurn == pickTurn; switch (trade?.State) { case null: Trade = canTrade ? TradeState.POSSIBLE : TradeState.INVALID; break; case "PENDING": Trade = trade.RequesterInternalSummonerName == player.SummonerInternalName ? TradeState.RECEIVED : TradeState.SENT; break; case "CANCELED": Trade = TradeState.CANCELLED; break; case "DECLINED": Trade = TradeState.POSSIBLE; break; default: Trade = TradeState.INVALID; break; } }
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(); }
public ChampSelectPlayer(PlayerParticipant player, PlayerChampionSelectionDTO selection) : this() { if (player.SummonerId == Session.Current.Account.SummonerID) { Glow.Opacity = 1; } DisplaySelection(selection); NameLabel.Content = player.SummonerName; if (string.IsNullOrWhiteSpace(player.SummonerName)) { NameLabel.Visibility = Visibility.Collapsed; } else { NameLabel.Visibility = Visibility.Visible; } }
public void Update(PlatformGameLifecycleDTO CurrentGame) { Game = CurrentGame; BlueBansLabel.Visibility = System.Windows.Visibility.Hidden; PurpleBansLabel.Visibility = System.Windows.Visibility.Hidden; PurpleBanListView.Items.Clear(); BlueBanListView.Items.Clear(); BlueListView.Items.Clear(); PurpleListView.Items.Clear(); ImageGrid.Children.Clear(); List <Participant> AllParticipants = new List <Participant>(CurrentGame.Game.TeamOne.ToArray()); AllParticipants.AddRange(CurrentGame.Game.TeamTwo); int i = 0; int y = 0; foreach (Participant part in AllParticipants) { ChampSelectPlayer control = new ChampSelectPlayer(); if (part is PlayerParticipant) { PlayerParticipant participant = part as PlayerParticipant; foreach (PlayerChampionSelectionDTO championSelect in CurrentGame.Game.PlayerChampionSelections) { if (championSelect.SummonerInternalName == participant.SummonerInternalName) { control.ChampionImage.Source = champions.GetChampion(championSelect.ChampionId).icon; var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id))), UriKind.Absolute); control.SummonerSpell1.Source = new BitmapImage(uriSource); uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))), UriKind.Absolute); control.SummonerSpell2.Source = new BitmapImage(uriSource); #region Generate Background Image m = new Image(); Canvas.SetZIndex(m, -2); m.Stretch = Stretch.None; m.Width = 100; m.Opacity = 0.50; m.HorizontalAlignment = System.Windows.HorizontalAlignment.Left; m.VerticalAlignment = System.Windows.VerticalAlignment.Stretch; m.Margin = new System.Windows.Thickness(y++ *100, 0, 0, 0); System.Drawing.Rectangle cropRect = new System.Drawing.Rectangle(new System.Drawing.Point(100, 0), new System.Drawing.Size(100, 560)); System.Drawing.Bitmap src = System.Drawing.Image.FromFile(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", champions.GetChampion(championSelect.ChampionId).portraitPath)) as System.Drawing.Bitmap; System.Drawing.Bitmap target = new System.Drawing.Bitmap(cropRect.Width, cropRect.Height); using (System.Drawing.Graphics g = System.Drawing.Graphics.FromImage(target)) { g.DrawImage(src, new System.Drawing.Rectangle(0, 0, target.Width, target.Height), cropRect, System.Drawing.GraphicsUnit.Pixel); } m.Source = Client.ToWpfBitmap(target); ImageGrid.Children.Add(m); #endregion Generate Background } } control.PlayerName.Content = participant.SummonerName; if (participant.TeamParticipantId != null) { byte[] values = BitConverter.GetBytes((double)participant.TeamParticipantId); if (!BitConverter.IsLittleEndian) { Array.Reverse(values); } byte r = values[2]; byte b = values[3]; byte g = values[4]; System.Drawing.Color myColor = System.Drawing.Color.FromArgb(r, b, g); var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#" + myColor.Name); control.TeamRectangle.Fill = brush; control.TeamRectangle.Visibility = System.Windows.Visibility.Visible; } } i++; if (i <= 5) { BlueListView.Items.Add(control); } else { PurpleListView.Items.Add(control); } } if (CurrentGame.Game.BannedChampions.Count > 0) { BlueBansLabel.Visibility = System.Windows.Visibility.Visible; PurpleBansLabel.Visibility = System.Windows.Visibility.Visible; } foreach (var x in CurrentGame.Game.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); } } try { string mmrJSON = ""; string url = Client.Region.SpectatorLink + "consumer/getGameMetaData/" + Client.Region.InternalName + "/" + CurrentGame.Game.Id + "/token"; using (WebClient client = new WebClient()) { mmrJSON = client.DownloadString(url); } JavaScriptSerializer serializer = new JavaScriptSerializer(); Dictionary <string, object> deserializedJSON = serializer.Deserialize <Dictionary <string, object> >(mmrJSON); MMRLabel.Content = "≈" + deserializedJSON["interestScore"]; } catch { MMRLabel.Content = "N/A"; } }
public async void InitializePop(GameDTO InitialDTO) { List <Participant> AllParticipants = InitialDTO.TeamOne; AllParticipants.AddRange(InitialDTO.TeamTwo); if (InitialDTO.TeamOne[0] is ObfuscatedParticipant) { ReverseString = true; } AllParticipants = AllParticipants.Distinct().ToList(); //Seems to have fixed the queuepopoverlay page crashing. //whichever team you're on sometimes duplicates and could not find a reason as it doesn't happen a lot. int i = 1; foreach (Participant p in AllParticipants) { QueuePopPlayer player = new QueuePopPlayer(); player.Width = 264; player.Height = 70; if (p is PlayerParticipant) { PlayerParticipant playerPart = (PlayerParticipant)p; if (!String.IsNullOrEmpty(playerPart.SummonerName)) { player.PlayerLabel.Content = playerPart.SummonerName; player.RankLabel.Content = ""; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(async() => { var playerLeagues = await Client.PVPNet.GetAllLeaguesForPlayer(playerPart.SummonerId); foreach (LeagueListDTO x in playerLeagues.SummonerLeagues) { if (x.Queue == "RANKED_SOLO_5x5") { player.RankLabel.Content = x.Tier + " " + x.RequestorsRank; } } if (String.IsNullOrEmpty(player.RankLabel.Content.ToString())) { player.RankLabel.Content = "Unranked"; } })); Team1ListBox.Items.Add(player); } else { Client.Log(playerPart.SummonerId.ToString()); player.PlayerLabel.Content = "Summoner " + i; i++; player.RankLabel.Content = ""; Team2ListBox.Items.Add(player); } } else { ObfuscatedParticipant oPlayer = p as ObfuscatedParticipant; player.PlayerLabel.Content = "Summoner " + (oPlayer.GameUniqueId - (oPlayer.GameUniqueId > 5 ? 5 : 0)); player.RankLabel.Content = ""; Team2ListBox.Items.Add(player); } } if (Client.AutoAcceptQueue) { await Client.PVPNet.AcceptPoppedGame(true); } }
public PlayerEntry(PlayerParticipant plr) : this() { Name = plr.Name; Id = plr.SummonerId; }
public void UpdateLists(GameDTO lobby) { if (InvokeRequired) { BeginInvoke(new Action <GameDTO>(UpdateLists), lobby); return; } var teamids = new List <Int64>(); var teams = new List <TeamParticipants> { lobby.TeamOne, lobby.TeamTwo }; var lists = new List <TeamControl> { teamControl1, teamControl2 }; for (int i = 0; i < lists.Count; i++) { var list = lists[i]; var team = teams[i]; for (int o = 0; o < list.Players.Count; o++) { if (o < team.Count) { PlayerControl plycontrol = list.Players[o] as PlayerControl; plycontrol.UpdateAcceptedStatus(Convert.ToInt32(lobby.StatusOfParticipants.Substring(i * 5 + o, 1))); //plycontrol.acce } } } /*var cmd = new PlayerCommands(Connection); * GameDTO tempGame = cmd.GetGame(Convert.ToInt32(lobby.Id)); * Console.WriteLine("test"); * Console.WriteLine(tempGame.Name); * for (int q = 0; q < tempGame.TeamOne.Count; q++) * { * Console.WriteLine((tempGame.TeamTwo[q] as PlayerParticipant).InternalName); * } * for (int q = 0; q < tempGame.TeamTwo.Count; q++) * { * Console.WriteLine((tempGame.TeamTwo[q] as PlayerParticipant).InternalName); * }*/ // correlating names for ARAM if (lobby.GameMode.Equals("ARAM")) { int blankCount = 0; int teamIdx = 1; if (SelfSummoner != null && lobby.TeamOne.Find(p => p is PlayerParticipant && ((PlayerParticipant)p).SummonerId == SelfSummoner.SummonerId) != null) { teamIdx = 0; } for (int i = 0; i < lobby.PlayerChampionSelections.Count; i++) { if ((lobby.PlayerChampionSelections[i].Spell1Id == 0.0)) { PlayerParticipant player = new PlayerParticipant(); player.AccountId = 1; player.InternalName = lobby.PlayerChampionSelections[i].SummonerInternalName; player.Name = lobby.PlayerChampionSelections[i].SummonerInternalName; player.PickMode = 1; player.PickTurn = 0; player.ProfileIconId = 2; player.QueueRating = 18; player.SummonerId = 1; player.TeamParticipantId = 0;// (teams[1 - teamIdx][blankCount] as PlayerParticipant).TeamParticipantId; teams[1 - teamIdx][blankCount++] = player; } } } if (CurrentGame != null) { var oldteams = new List <TeamParticipants> { CurrentGame.TeamOne, CurrentGame.TeamTwo }; var newteams = new List <TeamParticipants> { lobby.TeamOne, lobby.TeamTwo }; for (int i = 0; i < lobby.PlayerChampionSelections.Count; i++) { Console.WriteLine("i:" + i + " : " + lobby.PlayerChampionSelections[i].SummonerInternalName); for (int j = 0; j < lobby.TeamOne.Count; j++) { Console.WriteLine("j:" + j + " : " + (lobby.TeamOne[j] as PlayerParticipant).InternalName); if (lobby.PlayerChampionSelections[i].SummonerInternalName.Equals((lobby.TeamOne[j] as PlayerParticipant).InternalName)) { teamControl1[j].SetCurrentChamp(lobby.PlayerChampionSelections[i].ChampionId); break; } if (lobby.PlayerChampionSelections[i].SummonerInternalName.Equals((lobby.TeamTwo[j] as PlayerParticipant).InternalName)) { teamControl2[j].SetCurrentChamp(lobby.PlayerChampionSelections[i].ChampionId); break; } } } } if (CurrentGame == null || CurrentGame.Id != lobby.Id) { CurrentGame = lobby; } else { //Check if the teams are the same. //If they are the same that means nothing has changed and we can return. var oldteams = new List <TeamParticipants> { CurrentGame.TeamOne, CurrentGame.TeamTwo }; var newteams = new List <TeamParticipants> { lobby.TeamOne, lobby.TeamTwo }; bool same = true; for (int i = 0; i < oldteams.Count && i < newteams.Count; i++) { if (!oldteams[i].SequenceEqual(newteams[i])) { same = false; break; } } if (same) { return; } CurrentGame = lobby; } //Load the opposite team first. Not currently useful with the way things are loaded. /*if (SelfSummoner != null && lobby.TeamOne.Find(p => p is PlayerParticipant && ((PlayerParticipant)p).SummonerId == SelfSummoner.SummonerId) != null) * { * teams.Reverse(); * lists.Reverse(); * }*/ for (int i = 0; i < lists.Count; i++) { var list = lists[i]; var team = teams[i]; if (team == null) { list.Visible = false; continue; } list.Visible = true; for (int o = 0; o < list.Players.Count; o++) { list.Players[o].Tag = null; if (o < team.Count) { var plycontrol = list.Players[o]; plycontrol.Visible = true; var ply = team[o] as PlayerParticipant; if (ply != null) // && ply.SummonerId != 0) { //Used for synchronization. //Ensures that when the loaded data comes back to the UI thread that its what we wanted. plycontrol.Tag = ply; plycontrol.SetLoading(true); plycontrol.SetEmpty(); plycontrol.SetParticipant(ply); Task.Factory.StartNew(() => LoadPlayer(ply, plycontrol), TaskCreationOptions.LongRunning); } else { plycontrol.SetEmpty(); plycontrol.SetParticipant(team[o]); } if (ply != null) { if (ply.TeamParticipantId != 0) { var idx = teamids.FindIndex(t => t == ply.TeamParticipantId); if (idx == -1) { idx = teamids.Count; teamids.Add(ply.TeamParticipantId); } plycontrol.SetTeam(idx + 1); } } } else { list.Players[o].Visible = false; list.Players[o].SetEmpty(); } } } }
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; } } })); } }
/// <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(PlayerParticipant player, int team, Lobby lobby) : base(lobby) { this.player = player; Team = team; }
public async void InitializePop(GameDTO InitialDTO) { List <Participant> AllParticipants = InitialDTO.TeamOne; AllParticipants.AddRange(InitialDTO.TeamTwo); if (InitialDTO.TeamOne[0] is ObfuscatedParticipant) { ReverseString = true; } foreach (Participant p in AllParticipants) { QueuePopPlayer player = new QueuePopPlayer(); player.Width = 300; player.Height = 100; if (p is PlayerParticipant) { PlayerParticipant playerPart = (PlayerParticipant)p; player.PlayerLabel.Content = playerPart.SummonerName; player.RankLabel.Content = ""; Team1ListBox.Items.Add(player); } else { player.PlayerLabel.Content = "Enemy"; player.RankLabel.Content = ""; Team2ListBox.Items.Add(player); } } int i = 0; foreach (Participant p in AllParticipants) { if (p is PlayerParticipant) { QueuePopPlayer player = (QueuePopPlayer)Team1ListBox.Items[i]; PlayerParticipant playerPart = (PlayerParticipant)p; SummonerLeaguesDTO playerLeagues = await RiotCalls.GetAllLeaguesForPlayer(playerPart.SummonerId); foreach (LeagueListDTO x in playerLeagues.SummonerLeagues) { if (x.Queue == "RANKED_SOLO_5x5") { player.RankLabel.Content = x.Tier + " " + x.RequestorsRank; } } //People can be ranked without having solo queue so don't put if statement checking List.Length if (String.IsNullOrEmpty((string)player.RankLabel.Content)) { player.RankLabel.Content = "Unranked"; } i++; } } if (Client.AutoAcceptQueue) { await RiotCalls.AcceptPoppedGame(true); } }
internal CustomLobbyMember(PlayerParticipant player, int team, CustomLobby lobby) : base(player, team, lobby) { }
/// <summary> /// Query and cache player data /// </summary> /// <param name="player">Player to load</param> /// <param name="control">Control to update</param> void LoadPlayer(PlayerParticipant player, PlayerControl control) { PlayerCache existing; var ply = new PlayerCache(); try { lock (PlayersCache) { //Clear the cache every 1000 players to prevent crashing afk lobbies. if (PlayersCache.Count > 1000) { PlayersCache.Clear(); } //Does the player already exist in the cache? if ((existing = PlayersCache.Find(p => p.Player != null && p.Player.Id == player.SummonerId)) == null) { PlayersCache.Add(ply); } } //If another thread is loading the player data, lets wait for it to finish and use its data. if (existing != null) { existing.LoadWait.WaitOne(); LoadPlayerUIFinish(existing, control); return; } using (SimpleLogTimer.Start("Player query")) { var entry = Recorder.GetPlayer(player.SummonerId); ply.Player = entry ?? ply.Player; } using (SimpleLogTimer.Start("Stats query")) { var cmd = new PlayerCommands(Connection); var summoner = cmd.GetPlayerByName(player.Name); if (summoner != null) { ply.Summoner = summoner; ply.Stats = cmd.RetrievePlayerStatsByAccountId(summoner.AccountId); ply.RecentChamps = cmd.RetrieveTopPlayedChampions(summoner.AccountId, "CLASSIC"); ply.Games = cmd.GetRecentGames(summoner.AccountId); } else { StaticLogger.Debug(string.Format("Player {0} not found", player.Name)); ply.LoadWait.Set(); return; } } using (SimpleLogTimer.Start("Seen query")) { if (SelfSummoner != null && SelfSummoner.SummonerId != ply.Summoner.SummonerId && ply.Games != null) { ply.SeenCount = ply.Games.GameStatistics.Count(pgs => pgs.FellowPlayers.Any(fp => fp.SummonerId == SelfSummoner.SummonerId)); } } ply.LoadWait.Set(); LoadPlayerUIFinish(ply, control); } catch (Exception ex) { ply.LoadWait.Set(); // StaticLogger.Warning(ex); } }
private async void KickAndBan_Click(object sender, RoutedEventArgs e) { var button = sender as Button; PlayerParticipant BanPlayer = (PlayerParticipant)button.Tag; await Client.PVPNet.BanUserFromGame(Client.GameID, BanPlayer.AccountId); }
/// <summary> /// Render individual players /// </summary> /// <param name="selection">The champion the player has selected</param> /// <param name="player">The participant details of the player</param> /// <returns></returns> internal ChampSelectPlayer RenderPlayer(PlayerChampionSelectionDTO selection, PlayerParticipant player) { ChampSelectPlayer control = new ChampSelectPlayer(); //Render champion if (selection.ChampionId != 0) { control.ChampionImage.Source = champions.GetChampion(selection.ChampionId).icon; } //Render summoner spells if (selection.Spell1Id != 0) { string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)selection.Spell1Id)); control.SummonerSpell1.Source = Client.GetImage(uriSource); uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)selection.Spell2Id)); control.SummonerSpell2.Source = Client.GetImage(uriSource); } //Set our summoner spells in client if (player.SummonerName == Client.LoginPacket.AllSummonerData.Summoner.Name) { string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)selection.Spell1Id)); SummonerSpell1Image.Source = Client.GetImage(uriSource); uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)selection.Spell2Id)); SummonerSpell2Image.Source = Client.GetImage(uriSource); MyChampId = selection.ChampionId; } //Has locked in if (player.PickMode == 2) { string uriSource = "/LegendaryClient;component/Locked.png"; control.LockedInIcon.Source = Client.GetImage(uriSource); } //Make obvious whos pick turn it is if (player.PickTurn != LatestDto.PickTurn && (LatestDto.GameState == "CHAMP_SELECT" || LatestDto.GameState == "PRE_CHAMP_SELECT")) { control.Opacity = 0.5; } else { //Full opacity when not picking or banning control.Opacity = 1; } //If trading with this player is possible if (CanTradeWith != null && (CanTradeWith.PotentialTraders.Contains(player.SummonerInternalName) || DevMode)) { control.TradeButton.Visibility = System.Windows.Visibility.Visible; } //If this player is duo/trio/quadra queued with players if (player.TeamParticipantId != null && (double)player.TeamParticipantId != 0) { //Byte hack to get individual hex colors byte[] values = BitConverter.GetBytes((double)player.TeamParticipantId); if (!BitConverter.IsLittleEndian) { Array.Reverse(values); } byte r = values[2]; byte b = values[3]; byte g = values[4]; System.Drawing.Color myColor = System.Drawing.Color.FromArgb(r, b, g); var converter = new System.Windows.Media.BrushConverter(); var brush = (Brush)converter.ConvertFromString("#" + myColor.Name); control.TeamRectangle.Fill = brush; control.TeamRectangle.Visibility = System.Windows.Visibility.Visible; } control.LockedInIcon.Visibility = System.Windows.Visibility.Visible; control.TradeButton.Tag = new KeyValuePair <PlayerChampionSelectionDTO, PlayerParticipant>(selection, player); control.TradeButton.Click += TradeButton_Click; control.PlayerName.Content = player.SummonerName; return(control); }
public async void InitializePop(GameDTO InitialDTO) { List <Participant> allParticipants = InitialDTO.TeamOne; allParticipants.AddRange(InitialDTO.TeamTwo); if (InitialDTO.TeamOne[0] is ObfuscatedParticipant) { ReverseString = true; } allParticipants = allParticipants.Distinct().ToList(); //Seems to have fixed the queuepopoverlay page crashing. //whichever team you're on sometimes duplicates and could not find a reason as it doesn't happen a lot. int i = 1; foreach (Participant p in allParticipants) { var player = new QueuePopPlayer { Width = 264, Height = 70 }; var part = p as PlayerParticipant; if (part != null) { PlayerParticipant playerPart = part; if (!string.IsNullOrEmpty(playerPart.SummonerName)) { player.PlayerLabel.Content = playerPart.SummonerName; player.RankLabel.Content = ""; player.Tag = part; Team1ListBox.Items.Add(player); } else { Client.Log(playerPart.SummonerId.ToString(CultureInfo.InvariantCulture)); player.PlayerLabel.Content = "Summoner " + i; i++; player.RankLabel.Content = ""; Team2ListBox.Items.Add(player); } } else { var oPlayer = p as ObfuscatedParticipant; if (oPlayer != null) { player.PlayerLabel.Content = "Summoner " + (oPlayer.GameUniqueId - (oPlayer.GameUniqueId > 5 ? 5 : 0)); } player.RankLabel.Content = ""; Team2ListBox.Items.Add(player); } } GetPlayerLeagues(); if (!Client.AutoAcceptQueue) { return; } await RiotCalls.AcceptPoppedGame(true); accepted = true; }
public void GameLobbyUpdate(GameDTO lobby) { //StaticLogger.Info("Game Mode: " + lobby.GameMode); //StaticLogger.Info("Game Type: " + lobby.GameType); //StaticLogger.Info("Pre InvokeRequired"); if (InvokeRequired) { BeginInvoke(new Action <GameDTO>(GameLobbyUpdate), lobby); return; } //StaticLogger.Info("Game State: " + lobby.GameState); if (CurrentGame == null || CurrentGame.Id != lobby.Id) { //StaticLogger.Info("CurrentGame is null OR the Ids don't match."); teammates = new List <string>(); bans = new List <int>(); APIRequestMade = false; CurrentGame = lobby; } //CurrentGame.QueueTypeName.Equals("RANKED_SOLO_5x5") //StaticLogger.Info("Pre main IF"); //StaticLogger.Info("Teammates count: " + teammates.Count); //StaticLogger.Info("Current Game State: " + CurrentGame.GameState); if (lobby.QueueTypeName.Equals("RANKED_SOLO_5x5") && lobby.GameState.Equals("PRE_CHAMP_SELECT") && teammates.Count == 0) { //StaticLogger.Info("Inside main if"); IncludeBans.Enabled = false; int teamNumber = 0; List <TeamParticipants> teams = new List <TeamParticipants> { lobby.TeamOne, lobby.TeamTwo }; // Determine what team we're on for (int i = 0; i < teams.Count; i++) { TeamParticipants team = teams[i]; for (int j = 0; j < team.Count; j++) { PlayerParticipant player = team[j] as PlayerParticipant; if (player != null && player.SummonerId != 0) { if (player.SummonerId == SelfSummoner.SummonerId) { teamNumber = i; } } } } TeamParticipants myTeam = teams[teamNumber]; for (int i = 0; i < myTeam.Count; i++) { PlayerParticipant player = myTeam[i] as PlayerParticipant; teammates.Add(player.Name); } SummonerNamesLabel.Visible = true; //StaticLogger.Info("Team: " + string.Join(", ", teammates)); } else if (lobby.QueueTypeName.Equals("RANKED_SOLO_5x5") && lobby.GameState.Equals("TERMINATED") || lobby.GameState.Equals("START_REQUESTED") || lobby.GameState.Equals("POST_CHAMP_SELECT")) { IncludeBans.Enabled = true; SummonerNamesLabel.Visible = false; BansLabel.Visible = false; GenRecLabel.Visible = false; CopyURLButton.Visible = false; OpenURLinBrowser.Visible = false; } //StaticLogger.Info("Pre POST Ifs"); if (lobby.QueueTypeName.Equals("RANKED_SOLO_5x5") && lobby.GameState.Equals("PRE_CHAMP_SELECT") && !IncludeBans.Checked && !APIRequestMade) { GenRecLabel.Visible = true; //StaticLogger.Info("Not including bans..."); using (WebClient wb = new WebClient()) { NameValueCollection data = new NameValueCollection(); data["call"] = "generateRecommendations"; data["region"] = Settings.Region.ToString().ToLower(); data["summonerNames"] = string.Join(",", teammates); data["bans"] = ""; //StaticLogger.Info("Generating recommendations: " + data.ToString()); Byte[] response = wb.UploadValues(@"http://www.elophant.com/api.aspx", "POST", data); TeamIdJson = System.Text.Encoding.UTF8.GetString(response); //StaticLogger.Info("Response: " + TeamIdJson); APIRequestMade = true; } CopyURLButton.Visible = true; OpenURLinBrowser.Visible = true; } else if (lobby.QueueTypeName.Equals("RANKED_SOLO_5x5") && lobby.GameState.Equals("CHAMP_SELECT") && IncludeBans.Checked && !APIRequestMade) { //StaticLogger.Info("Including bans..."); foreach (var ban in lobby.BannedChampions) { bans.Add(ban.ChampionId); } BansLabel.Visible = true; GenRecLabel.Visible = true; using (WebClient wb = new WebClient()) { NameValueCollection data = new NameValueCollection(); data["call"] = "generateRecommendations"; data["region"] = Settings.Region.ToString().ToLower(); data["summonerNames"] = string.Join(",", teammates); data["bans"] = string.Join(",", bans); //StaticLogger.Info("region: " + Settings.Region.ToString().ToLower() + " summonerNames: " + string.Join(",", teammates) + " bans: " + string.Join(",", bans)); Byte[] response = wb.UploadValues(@"http://www.elophant.com/api.aspx", "POST", data); TeamIdJson = System.Text.Encoding.UTF8.GetString(response); //StaticLogger.Info("Response: " + TeamIdJson); APIRequestMade = true; } CopyURLButton.Visible = true; OpenURLinBrowser.Visible = true; } }