public void RenderTopPlayedChampions(ChampionStatInfo[] TopChampions) { ViewAggregatedStatsButton.IsEnabled = false; TopChampionsListView.Items.Clear(); if (!TopChampions.Any()) { return; } TopChampionsLabel.Content = "Top Champions (" + TopChampions[0].TotalGamesPlayed + " Ranked Games)"; foreach (ChampionStatInfo info in TopChampions) { ViewAggregatedStatsButton.IsEnabled = true; if (!(Math.Abs(info.ChampionId) > 0)) { continue; } champions Champion = champions.GetChampion(Convert.ToInt32(info.ChampionId)); var player = new ChatPlayer { LevelLabel = { Visibility = Visibility.Hidden }, PlayerName = { Content = Champion.displayName }, PlayerStatus = { Content = info.TotalGamesPlayed + " games played" }, ProfileImage = { Source = champions.GetChampion(Champion.id).icon }, Background = new SolidColorBrush(Color.FromArgb(102, 80, 80, 80)), Height = 51.5, Width = 278 }; TopChampionsListView.Items.Add(player); } }
private void LoadStats() { string hi = "hi"; ChampionSelectListView.Items.Clear(); if (hi == "hi") { ChampList = new List <ChampionDTO>(Client.PlayerChampions); foreach (ChampionDTO champ in ChampList) { champions getChamp = champions.GetChampion(champ.ChampionId); if ((champ.Owned || champ.FreeToPlay)) { //Add to ListView ListViewItem item = new ListViewItem(); ChampionImage championImage = new ChampionImage(); championImage.ChampImage.Source = champions.GetChampion(champ.ChampionId).icon; if (champ.FreeToPlay) { championImage.FreeToPlayLabel.Visibility = Visibility.Visible; } championImage.Width = 64; championImage.Height = 64; item.Tag = champ.ChampionId; item.Content = championImage.Content; ChampionSelectListView.Items.Add(item); } } } }
private async void SkinSelectListView_PreviewMouseDown(object sender, MouseButtonEventArgs e) { var item = sender as ListViewItem; if (item != null) { if (item.Tag != null) { if (item.Tag is string) { string[] splitItem = ((string)item.Tag).Split(':'); int championId = Convert.ToInt32(splitItem[1]); champions Champion = champions.GetChampion(championId); await Client.PVPNet.SelectChampionSkin(championId, 0); TextRange tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); tr.Text = "Selected Default " + Champion.name + " as skin" + Environment.NewLine; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White); } else { championSkins skin = championSkins.GetSkin((int)item.Tag); await Client.PVPNet.SelectChampionSkin(skin.championId, skin.id); TextRange tr = new TextRange(ChatText.Document.ContentEnd, ChatText.Document.ContentEnd); tr.Text = "Selected " + skin.displayName + " as skin" + Environment.NewLine; tr.ApplyPropertyValue(TextElement.ForegroundProperty, Brushes.White); } } } }
private void SearchBox_TextChanged(object sender, TextChangedEventArgs e) { ChampionSelectListView.Items.Clear(); List <ChampionDTO> tempList = ChampList.ToList(); if (SearchTextBox.Text != "Search" && !String.IsNullOrEmpty(SearchTextBox.Text)) { tempList = tempList.Where(x => champions.GetChampion(x.ChampionId).displayName.ToLower().Contains(SearchTextBox.Text.ToLower())).ToList(); } foreach (ChampionDTO champ in tempList) { champions getChamp = champions.GetChampion(champ.ChampionId); if ((champ.Owned || champ.FreeToPlay)) { //Add to ListView ListViewItem item = new ListViewItem(); ChampionImage championImage = new ChampionImage(); championImage.ChampImage.Source = champions.GetChampion(champ.ChampionId).icon; if (champ.FreeToPlay) { championImage.FreeToPlayLabel.Visibility = Visibility.Visible; } championImage.Width = 64; championImage.Height = 64; item.Tag = champ.ChampionId; item.Content = championImage.Content; ChampionSelectListView.Items.Add(item); } } }
public void RenderChampions(int ChampionId) { champions Champ = champions.GetChampion(ChampionId); TheChamp = Champ; if (TheChamp.IsFavourite) { FavouriteLabel.Content = "Unfavourite"; } else { FavouriteLabel.Content = "Favourite"; } ChampionName.Content = Champ.displayName; ChampionTitle.Content = Champ.title; ChampionProfileImage.Source = Champ.icon; AttackProgressBar.Value = Champ.ratingAttack; DefenseProgressBar.Value = Champ.ratingDefense; AbilityProgressBar.Value = Champ.ratingMagic; DifficultyProgressBar.Value = Champ.ratingDifficulty; HPLabel.Content = string.Format("HP: {0} (+{1} per level)", Champ.healthBase, Champ.healthLevel); ResourceLabel.Content = string.Format("{0}: {1} (+{2} per level)", Champ.ResourceType, Champ.manaBase, Champ.manaLevel); HPRegenLabel.Content = string.Format("HP/5: {0} (+{1} per level)", Champ.healthRegenBase, Champ.healthRegenLevel); ResourceRegenLabel.Content = string.Format("{0}/5: {1} (+{2} per level)", Champ.ResourceType, Champ.manaRegenBase, Champ.manaRegenLevel); MagicResistLabel.Content = string.Format("MR: {0} (+{1} per level)", Champ.magicResistBase, Champ.magicResistLevel); ArmorLabel.Content = string.Format("Armor: {0} (+{1} per level)", Champ.armorBase, Champ.armorLevel); AttackDamageLabel.Content = string.Format("AD: {0} (+{1} per level)", Champ.attackBase, Champ.attackLevel); RangeLabel.Content = string.Format("Range: {0}", Champ.range); MovementSpeedLabel.Content = string.Format("Speed: {0}", Champ.moveSpeed); foreach (Dictionary <string, object> Skins in Champ.Skins) { int Skin = Convert.ToInt32(Skins["id"]); ListViewItem item = new ListViewItem(); Image skinImage = new Image(); var uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", championSkins.GetSkin(Skin).portraitPath); skinImage.Source = Client.GetImage(uriSource); skinImage.Width = 96.25; skinImage.Height = 175; skinImage.Stretch = Stretch.UniformToFill; item.Tag = Skin; item.Content = skinImage; SkinSelectListView.Items.Add(item); } foreach (Spell Sp in Champ.Spells) { ChampionDetailAbility detailAbility = new ChampionDetailAbility(); detailAbility.DataContext = Sp; var uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "spell", Sp.Image); detailAbility.AbilityImage.Source = Client.GetImage(uriSource); AbilityListView.Items.Add(detailAbility); } ChampionImage.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", Champ.splashPath)); LoreText.Text = Champ.Lore.Replace("<br>", Environment.NewLine); TipsText.Text = string.Format("Tips while playing {0}:{1}{2}{2}{2}Tips while playing aginst {0}:{3}", Champ.displayName, Champ.tips.Replace("*", Environment.NewLine + "*"), Environment.NewLine, Champ.opponentTips.Replace("*", Environment.NewLine + "*")); }
private void FilterChampions() { ChampionSelectListView.Items.Clear(); List <ChampionDTO> tempList = ChampionList.ToList(); if (!String.IsNullOrEmpty(SearchTextBox.Text)) { tempList = tempList.Where(x => champions.GetChampion(x.ChampionId).displayName.ToLower().Contains(SearchTextBox.Text.ToLower())).ToList(); } bool AllChampions = false; bool OwnedChampions = false; bool NotOwnedChampions = false; bool AvaliableChampions = false; switch ((string)FilterComboBox.SelectedValue) { case "All": AllChampions = true; break; case "Owned": OwnedChampions = true; break; case "Not Owned": NotOwnedChampions = true; break; default: AvaliableChampions = true; break; } foreach (ChampionDTO champ in tempList) { if ((AvaliableChampions && (champ.Owned || champ.FreeToPlay)) || (AllChampions) || (OwnedChampions && champ.Owned) || (NotOwnedChampions && !champ.Owned)) { ProfileChampionImage championImage = new ProfileChampionImage(); champions champion = champions.GetChampion(champ.ChampionId); championImage.ChampImage.Source = champion.icon; if (champ.FreeToPlay) { championImage.FreeToPlayLabel.Visibility = System.Windows.Visibility.Visible; } championImage.ChampName.Content = champion.displayName; if (!champ.Owned && !champ.FreeToPlay) { championImage.ChampImage.Opacity = 0.5; } championImage.Tag = champ.ChampionId; ChampionSelectListView.Items.Add(championImage); } } }
private void GotStats(AggregatedStats stats) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { SelectedAggregatedStats = stats; ViewAggregatedStatsButton.IsEnabled = false; TopChampionsListView.Items.Clear(); List <AggregatedChampion> ChampionStats = new List <AggregatedChampion>(); int i = 0; if (SelectedAggregatedStats.LifetimeStatistics != null) { if (SelectedAggregatedStats.LifetimeStatistics.Count() > 0) { foreach (AggregatedStat stat in SelectedAggregatedStats.LifetimeStatistics) { AggregatedChampion Champion = null; Champion = ChampionStats.Find(x => x.ChampionId == stat.ChampionId); if (Champion == null) { Champion = new AggregatedChampion(); Champion.ChampionId = stat.ChampionId; ChampionStats.Add(Champion); } var type = typeof(AggregatedChampion); string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", ""); var f = type.GetField(fieldName); f.SetValue(Champion, stat.Value); } ChampionStats.Sort((x, y) => y.TotalSessionsPlayed.CompareTo(x.TotalSessionsPlayed)); foreach (AggregatedChampion info in ChampionStats) { if (i++ > 6) { break; } ViewAggregatedStatsButton.IsEnabled = true; if (info.ChampionId != 0.0) { ChatPlayer player = new ChatPlayer(); champions Champion = champions.GetChampion(Convert.ToInt32(info.ChampionId)); player.LevelLabel.Visibility = System.Windows.Visibility.Hidden; player.PlayerName.Content = Champion.displayName; player.PlayerStatus.Content = info.TotalSessionsPlayed + " games played"; player.ProfileImage.Source = champions.GetChampion(Champion.id).icon; TopChampionsListView.Items.Add(player); } } } } })); }
private void StartTeambuilder() { ListViewItem item = new ListViewItem(); Image skinImage = new Image(); ChampList = new List <ChampionDTO>(Client.PlayerChampions); champions Champion = champions.GetChampion(ChampionId); string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", Champion.portraitPath); //Retrieve masteries and runes MyMasteries = Client.LoginPacket.AllSummonerData.MasteryBook; MyRunes = Client.LoginPacket.AllSummonerData.SpellBook; Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { //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; } })); foreach (ChampionDTO champ in ChampList) { if (champ.ChampionId == ChampionId) { foreach (ChampionSkinDTO skin in champ.ChampionSkins) { if (skin.Owned) { item = new ListViewItem(); skinImage = new Image(); uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "champions", championSkins.GetSkin(skin.SkinId).portraitPath); skinImage.Source = Client.GetImage(uriSource); skinImage.Width = 191; skinImage.Stretch = Stretch.UniformToFill; item.Tag = skin.SkinId; item.Content = skinImage; SkinSelectListView.Items.Add(item); } } } } skinImage.Source = Client.GetImage(uriSource); skinImage.Width = 191; skinImage.Stretch = Stretch.UniformToFill; item.Tag = "0:" + ChampionId; //Hack item.Content = skinImage; SkinSelectListView.Items.Add(item); }
public SelectChampOverlay(TeamQueuePage tqp) { InitializeComponent(); Change(); this.tqp = tqp; ChampionSelectListView.Items.Clear(); if (true) { ChampList = new List <ChampionDTO>(Client.PlayerChampions); ChampList.Sort( (x, y) => String.Compare(champions.GetChampion(x.ChampionId) .displayName, champions.GetChampion(y.ChampionId).displayName, StringComparison.Ordinal)); foreach (ChampionDTO champ in ChampList) { champions getChamp = champions.GetChampion(champ.ChampionId); if ((!champ.Owned && !champ.FreeToPlay)) { continue; } //Add to ListView var item = new ListViewItem(); var championImage = new ChampionImage { ChampImage = { Source = champions.GetChampion(champ.ChampionId).icon } }; if (champ.FreeToPlay) { championImage.FreeToPlayLabel.Visibility = Visibility.Visible; } championImage.Width = 64; championImage.Height = 64; item.Tag = champ.ChampionId; item.Content = championImage.Content; ChampionSelectListView.Items.Add(item); } var items = new ListViewItem(); var img = new ChampionImage { ChampImage = { Source = Client.GetImage("getNone") }, Width = 64, Height = 64 }; items.Tag = 0; items.Content = img.Content; ChampionSelectListView.Items.Add(items); } }
/// <summary> /// Render all champions /// </summary> /// <param name="RenderBans">Render champions for ban</param> internal void RenderChamps(bool RenderBans) { ChampionSelectListView.Items.Clear(); if (!RenderBans) { foreach (ChampionDTO champ in ChampList) { champions getChamp = champions.GetChampion(champ.ChampionId); if ((champ.Owned || champ.FreeToPlay) && getChamp.displayName.ToLower().Contains(SearchTextBox.Text.ToLower())) { //Add to ListView ListViewItem item = new ListViewItem(); ChampionImage championImage = new ChampionImage(); championImage.ChampImage.Source = champions.GetChampion(champ.ChampionId).icon; if (getChamp.IsFavourite) { championImage.FavoriteImage.Visibility = Visibility.Visible; } if (champ.FreeToPlay) { championImage.FreeToPlayLabel.Visibility = Visibility.Visible; } championImage.Width = 64; championImage.Height = 64; item.Tag = champ.ChampionId; item.Content = championImage.Content; ChampionSelectListView.Items.Add(item); } } } else { foreach (ChampionBanInfoDTO champ in ChampionsForBan) { champions getChamp = champions.GetChampion(champ.ChampionId); if (champ.EnemyOwned && getChamp.displayName.ToLower().Contains(SearchTextBox.Text.ToLower())) { //Add to ListView ListViewItem item = new ListViewItem(); ChampionImage championImage = new ChampionImage(); championImage.ChampImage.Source = champions.GetChampion(champ.ChampionId).icon; championImage.Width = 64; championImage.Height = 64; item.Tag = champ.ChampionId; item.Content = championImage.Content; ChampionSelectListView.Items.Add(item); } } } }
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); }
private async void TradeButton_Click(object sender, RoutedEventArgs e) { KeyValuePair <PlayerChampionSelectionDTO, PlayerParticipant> p = (KeyValuePair <PlayerChampionSelectionDTO, PlayerParticipant>)((Button)sender).Tag; await Client.PVPNet.AttemptTrade(p.Value.SummonerInternalName, p.Key.ChampionId); PlayerTradeControl.Visibility = System.Windows.Visibility.Visible; champions MyChampion = champions.GetChampion((int)MyChampId); PlayerTradeControl.MyChampImage.Source = MyChampion.icon; PlayerTradeControl.MyChampLabel.Content = MyChampion.displayName; champions TheirChampion = champions.GetChampion((int)p.Key.ChampionId); PlayerTradeControl.TheirChampImage.Source = TheirChampion.icon; PlayerTradeControl.TheirChampLabel.Content = TheirChampion.displayName; PlayerTradeControl.RequestLabel.Content = "Sent trade request..."; PlayerTradeControl.AcceptButton.Visibility = System.Windows.Visibility.Hidden; PlayerTradeControl.DeclineButton.Content = "Cancel"; }
private void ParseStats(AggregatedStats stats) { foreach (AggregatedStat stat in stats.LifetimeStatistics) { AggregatedChampion champion = ChampionStats.Find(x => x.ChampionId == stat.ChampionId); if (champion == null) { champion = new AggregatedChampion { ChampionId = stat.ChampionId }; ChampionStats.Add(champion); } Type type = typeof(AggregatedChampion); string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", ""); FieldInfo f = type.GetField(fieldName); f.SetValue(champion, stat.Value); } ChampionStats.Sort((x, y) => y.TotalSessionsPlayed.CompareTo(x.TotalSessionsPlayed)); //AllStats = ChampionStats; foreach (AggregatedChampion championStat in ChampionStats) { if (championStat.ChampionId == 0) { continue; } var item = new ListViewItem(); var championImage = new ProfileChampionImage(); champions champ = champions.GetChampion((int)championStat.ChampionId); championImage.ChampImage.Source = champ.icon; championImage.ChampName.Content = champ.displayName; championImage.Width = 96; championImage.Height = 84; item.Tag = championStat; item.Content = championImage.Content; ChampionsListView.Items.Add(item); } }
public SelectChampOverlay(TeamQueuePage tqp) { InitializeComponent(); this.tqp = tqp; ChampionSelectListView.Items.Clear(); if (true) { ChampList = new List <ChampionDTO>(Client.PlayerChampions); ChampList.Sort((x, y) => champions.GetChampion(x.ChampionId).displayName.CompareTo(champions.GetChampion(y.ChampionId).displayName)); foreach (ChampionDTO champ in ChampList) { champions getChamp = champions.GetChampion(champ.ChampionId); if ((champ.Owned || champ.FreeToPlay)) { //Add to ListView ListViewItem item = new ListViewItem(); ChampionImage championImage = new ChampionImage(); championImage.ChampImage.Source = champions.GetChampion(champ.ChampionId).icon; if (champ.FreeToPlay) { championImage.FreeToPlayLabel.Visibility = Visibility.Visible; } championImage.Width = 64; championImage.Height = 64; item.Tag = champ.ChampionId; item.Content = championImage.Content; ChampionSelectListView.Items.Add(item); } } ListViewItem items = new ListViewItem(); ChampionImage img = new ChampionImage(); img.ChampImage.Source = Client.GetImage("getNone"); img.Width = 64; img.Height = 64; items.Tag = 0; items.Content = img.Content; ChampionSelectListView.Items.Add(items); } }
private void ParseStats(AggregatedStats stats) { foreach (AggregatedStat stat in stats.LifetimeStatistics) { AggregatedChampion Champion = null; Champion = ChampionStats.Find(x => x.ChampionId == stat.ChampionId); if (Champion == null) { Champion = new AggregatedChampion(); Champion.ChampionId = stat.ChampionId; ChampionStats.Add(Champion); } var type = typeof(AggregatedChampion); string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", ""); var f = type.GetField(fieldName); f.SetValue(Champion, stat.Value); } ChampionStats.Sort((x, y) => y.TotalSessionsPlayed.CompareTo(x.TotalSessionsPlayed)); AllStats = ChampionStats[0]; foreach (AggregatedChampion ChampionStat in ChampionStats) { if (ChampionStat.ChampionId != 0) { ProfileChampionImage championImage = new ProfileChampionImage(); champions champion = champions.GetChampion((int)ChampionStat.ChampionId); championImage.DataContext = champion; championImage.Width = 96; championImage.Height = 84; championImage.Tag = ChampionStat; ChampionsListView.Items.Add(championImage); } } }
static void InsertChampions() { string json = ""; using (StreamReader r = new StreamReader(resourcePath + "champions.json")) { json = r.ReadToEnd(); } champions champs = JsonConvert.DeserializeObject <champions>(json); IList <object> allChamps = Map(champs); foreach (object obj in allChamps) { if (obj.GetType() == typeof(data.ChampionClassLink)) { db.ChampionClassLink.Add((data.ChampionClassLink)obj); } else { db.ChampionOriginLink.Add((data.ChampionOriginLink)obj); } } }
public void RenderTopPlayedChampions(ChampionStatInfo[] TopChampions) { ViewAggregatedStatsButton.IsEnabled = false; TopChampionsListView.Items.Clear(); if (TopChampions.Count() > 0) { TopChampionsLabel.Content = "Top Champions (" + TopChampions[0].TotalGamesPlayed + " Ranked Games)"; foreach (ChampionStatInfo info in TopChampions) { ViewAggregatedStatsButton.IsEnabled = true; if (info.ChampionId != 0.0) { ChatPlayer player = new ChatPlayer(); champions Champion = champions.GetChampion(Convert.ToInt32(info.ChampionId)); player.LevelLabel.Visibility = System.Windows.Visibility.Hidden; player.PlayerName.Content = Champion.displayName; player.PlayerStatus.Content = info.TotalGamesPlayed + " games played"; player.ProfileImage.Source = champions.GetChampion(Champion.id).icon; TopChampionsListView.Items.Add(player); } } } }
public async Task <string[]> Load(double ID) { RecentGames result = await Client.PVPNet.GetRecentGames(ID); result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); GamesWithChamp = 0; foreach (PlayerGameStats game in result.GameStatistics) { game.GameType = Client.TitleCaseString(game.GameType.Replace("_GAME", "").Replace("MATCHED", "NORMAL")); var match = new MatchStats(); foreach (RawStat stat in game.Statistics) { Type type = typeof(MatchStats); string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", ""); FieldInfo f = type.GetField(fieldName); f.SetValue(match, stat.Value); } match.Game = game; GameStats.Add(match); } int AKills, ChampKills; int ADeaths, ChampDeaths; int AAssists, ChampAssists; int AGamesPlayed, ChampGamesPlayed; int Wins, ChampWins; AKills = 0; ADeaths = 0; AAssists = 0; AGamesPlayed = 0; ChampKills = 0; ChampDeaths = 0; ChampAssists = 0; ChampGamesPlayed = 0; Wins = 0; ChampWins = 0; //Load average KDA for past 20 games if possible foreach (MatchStats stats in GameStats) { if (stats.Win == 1) { Wins++; } champions gameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); AKills = AKills + (Int32)stats.ChampionsKilled; ADeaths = ADeaths + (Int32)stats.NumDeaths; AAssists = AAssists + (Int32)stats.Assists; AGamesPlayed++; if (ChampID == (int)Math.Round(stats.Game.ChampionId)) { if (stats.Win == 1) { ChampWins++; } ChampKills = ChampKills + (Int32)stats.ChampionsKilled; ChampDeaths = ChampDeaths + (Int32)stats.NumDeaths; ChampAssists = ChampAssists + (Int32)stats.Assists; ChampGamesPlayed++; GamesWithChamp++; } } WinLossRatio = (Wins / AGamesPlayed) * 100; try { WinLossChampRatio = (ChampWins / ChampGamesPlayed) * 100; } catch { } string KDAString = string.Format("{0}/{1}/{2}", (AKills / AGamesPlayed), (ADeaths / AGamesPlayed), (AAssists / AGamesPlayed)); string ChampKDAString = ""; try { ChampKDAString = string.Format("{0}/{1}/{2}", (ChampKills / ChampGamesPlayed), (ChampDeaths / ChampGamesPlayed), (ChampAssists / ChampGamesPlayed)); } catch { ChampKDAString = "NO RECENT GAMES!!!"; } //GetKDA String OverallKDA = new KDA() { Kills = AKills, Deaths = ADeaths, Assists = AAssists, Games = AGamesPlayed }; //Get champ KDA Champkda = new KDA() { Kills = ChampKills, Deaths = ChampDeaths, Assists = ChampAssists, Games = ChampGamesPlayed }; return(new List <string>() { ChampKDAString, KDAString }.ToArray()); }
public ChampStats(int champName, int playerName) { Champ = champions.GetChampion(champName); ChampID = Champ.id; Load(playerName); }
public ChampStats(string champName, string playerName) { Champ = champions.GetChampion(champName); ChampID = Champ.id; LoadName(playerName); }
/// <summary> /// Loads the particiapants for the game /// </summary> /// <param name="allParticipants"></param> /// <param name="n"></param> /// <param name="list"></param> private async void LoadPar(List <Participant> allParticipants, PlatformGameLifecycleDTO n, ListView list) { bool isYourTeam = false; list.Items.Clear(); list.Items.Refresh(); try { string mmrJson; string url = Client.Region.SpectatorLink + "consumer/getGameMetaData/" + Client.Region.InternalName + "/" + n.Game.Id + "/token"; using (var client = new WebClient()) mmrJson = client.DownloadString(url); var serializer = new JavaScriptSerializer(); var deserializedJson = serializer.Deserialize <Dictionary <string, object> >(mmrJson); MMRLabel.Content = "Game MMR ≈ " + deserializedJson["interestScore"]; } catch { MMRLabel.Content = "Unable to calculate Game MMR"; } foreach (Participant par in allParticipants) { if (par is PlayerParticipant) { PublicSummoner scoutersum = await RiotCalls.GetSummonerByName(GSUsername); if ((par as PlayerParticipant).AccountId == scoutersum.AcctId) { isYourTeam = true; } } } foreach (Participant par in allParticipants) { if (par is PlayerParticipant) { var participant = par as PlayerParticipant; foreach (PlayerChampionSelectionDTO championSelect in n.Game.PlayerChampionSelections.Where(championSelect => championSelect.SummonerInternalName == participant.SummonerInternalName)) { GameScouterPlayer control = new GameScouterPlayer(); control.Tag = championSelect; GameStats = new List <MatchStats>(); control.Username.Content = championSelect.SummonerInternalName; //Make it so you can see yourself if (championSelect.SummonerInternalName == GSUsername) { control.Username.Foreground = (Brush)(new BrushConverter().ConvertFrom("#FF007A53")); } control.ChampIcon.Source = champions.GetChampion(championSelect.ChampionId).icon; if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id))))) { var UriSource = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell1Id))), UriKind.Absolute); control.SumIcon1.Source = new BitmapImage(UriSource); } if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))))) { var UriSource = new System.Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName(Convert.ToInt32(championSelect.Spell2Id))), UriKind.Absolute); control.SumIcon2.Source = new BitmapImage(UriSource); } GameStats.Clear(); try { PublicSummoner summoner = await RiotCalls.GetSummonerByName(championSelect.SummonerInternalName.Replace("summoner", string.Empty)); if (File.Exists(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", summoner.ProfileIconId.ToString() + ".png"))) { control.ProfileIcon.Source = Client.GetImage(Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", summoner.ProfileIconId.ToString() + ".png")); } RecentGames result = await RiotCalls.GetRecentGames(summoner.AcctId); result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); foreach (PlayerGameStats game in result.GameStatistics) { game.GameType = Client.TitleCaseString(game.GameType.Replace("_GAME", "").Replace("MATCHED", "NORMAL")); var match = new MatchStats(); foreach (RawStat stat in game.Statistics) { Type type = typeof(MatchStats); string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", ""); FieldInfo f = type.GetField(fieldName); f.SetValue(match, stat.Value); } match.Game = game; GameStats.Add(match); } int Kills, ChampKills; int Deaths, ChampDeaths; int Assists, ChampAssists; int GamesPlayed, ChampGamesPlayed; Kills = 0; Deaths = 0; Assists = 0; GamesPlayed = 0; ChampKills = 0; ChampDeaths = 0; ChampAssists = 0; ChampGamesPlayed = 0; //Load average KDA for past 20 games if possible foreach (MatchStats stats in GameStats) { champions gameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); Kills = Kills + (int)stats.ChampionsKilled; Deaths = Deaths + (int)stats.NumDeaths; Assists = Assists + (int)stats.Assists; GamesPlayed++; if (championSelect.ChampionId == (int)Math.Round(stats.Game.ChampionId)) { ChampKills = ChampKills + (int)stats.ChampionsKilled; ChampDeaths = ChampDeaths + (int)stats.NumDeaths; ChampAssists = ChampAssists + (int)stats.Assists; ChampGamesPlayed++; } } //GetKDA string string KDAString = string.Format("{0}/{1}/{2}", (Kills / GamesPlayed), (Deaths / GamesPlayed), (Assists / GamesPlayed)); string ChampKDAString = ""; try { ChampKDAString = string.Format("{0}/{1}/{2}", (ChampKills / ChampGamesPlayed), (ChampDeaths / ChampGamesPlayed), (ChampAssists / ChampGamesPlayed)); } catch { } if (ChampGamesPlayed == 0) { ChampKDAString = "No Games lately"; } control.AverageKDA.Content = KDAString; control.ChampAverageKDA.Content = ChampKDAString; BrushConverter bc = new BrushConverter(); if (isYourTeam) { bc = new BrushConverter(); if (ChampKills < ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C"); } else if (ChampKills == ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D"); } else { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E"); } bc = new BrushConverter(); if (Kills < Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C"); } else if (Kills == Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D"); } else { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E"); } } else { bc = new BrushConverter(); if (ChampKills > ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C"); } else if (ChampKills == ChampDeaths) { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D"); } else { control.ChampKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E"); } bc = new BrushConverter(); if (Kills > Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FFC51C1C"); } else if (Kills == Deaths) { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF8D8D8D"); } else { control.GameKDAColor.Fill = (Brush)bc.ConvertFrom("#FF1EBF1E"); } } } catch { Client.Log("Failed to get stats about player", "GAME_SCOUTER_ERROR"); } if (participant.TeamParticipantId != null) { try { Brush myColor = color[(double)participant.TeamParticipantId]; control.QueueTeamColor.Fill = myColor; control.QueueTeamColor.Visibility = Visibility.Visible; } catch { BrushConverter bc = new BrushConverter(); Brush brush = Brushes.White; //I know that there is a better way in the InGamePage //I find that sometimes the colors (colours) are very hard to distinguish from eachother //This makes sure that each color is easy to see //because of hexa hill I put 12 in just in case switch (ColorId) { case 0: //blue brush = (Brush)bc.ConvertFrom("#FF00E8FF"); break; case 2: //Lime Green brush = (Brush)bc.ConvertFrom("#FF00FF00"); break; case 3: //Yellow brush = (Brush)bc.ConvertFrom("#FFFFFF00"); break; case 4: //Blue Green brush = (Brush)bc.ConvertFrom("#FF007A53"); break; case 5: //Purple brush = (Brush)bc.ConvertFrom("#FF5100FF"); break; case 6: //Pink brush = (Brush)bc.ConvertFrom("#FFCB46C5"); break; case 7: //Dark Green brush = (Brush)bc.ConvertFrom("#FF006409"); break; case 8: //Brown brush = (Brush)bc.ConvertFrom("#FF643200"); break; case 9: //White brush = (Brush)bc.ConvertFrom("#FFFFFFFF"); break; case 10: //Grey brush = (Brush)bc.ConvertFrom("#FF363636"); break; case 11: //Red Pink brush = (Brush)bc.ConvertFrom("#FF8F4242"); break; case 12: //Grey Blue brush = (Brush)bc.ConvertFrom("#FFFF0000"); break; } color.Add((double)participant.TeamParticipantId, brush); ColorId++; control.QueueTeamColor.Fill = brush; control.QueueTeamColor.Visibility = Visibility.Visible; } } //control.MouseMove += controlMouseEnter; control.MouseEnter += controlMouseEnter; control.MouseLeave += control_MouseLeave; control.MouseDown += control_MouseDown; TinyRuneMasteryData smallData = new TinyRuneMasteryData(); //Now store data in the tags so that all of the event handlers work Dictionary <string, object> data = new Dictionary <string, object>(); data.Add("MasteryDataControl", smallData); data.Add("RuneData", await GetUserRunesPage(GSUsername)); data.Add("MasteryData", await GetUserRunesPage(GSUsername)); control.Tag = data; list.Items.Add(control); } } } }
public bool IsFreeToPlay(champions champion) { return(IsFreeToPlay(champion.id)); }
private void ChatPlayerMouseOver(object sender, MouseEventArgs e) { var item = (ChatPlayer)sender; var playerItem = (ChatPlayerItem)item.Tag; if (PlayerItem == null) { PlayerItem = new LargeChatPlayer(); Client.MainGrid.Children.Add(PlayerItem); Panel.SetZIndex(PlayerItem, 5); PlayerItem.Tag = playerItem; PlayerItem.PlayerName.Content = playerItem.Username; PlayerItem.PlayerLeague.Content = playerItem.LeagueTier + " " + playerItem.LeagueDivision; PlayerItem.PlayerStatus.Text = playerItem.Status; if (playerItem.RankedWins == 0) { PlayerItem.PlayerWins.Content = playerItem.Wins + " Normal Wins"; } else { PlayerItem.PlayerWins.Content = playerItem.RankedWins + " Ranked Wins"; } PlayerItem.LevelLabel.Content = playerItem.Level; PlayerItem.UsingLegendary.Visibility = playerItem.UsingLegendary ? Visibility.Visible : Visibility.Hidden; //PlayerItem.Dev.Visibility = playerItem.IsLegendaryDev ? System.Windows.Visibility.Visible : System.Windows.Visibility.Hidden; string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", playerItem.ProfileIcon + ".png"); PlayerItem.ProfileImage.Source = Client.GetImage(uriSource); if (playerItem.Status != null) { } else if (playerItem.Status == null) { Client.hidelegendaryaddition = true; } else { PlayerItem.PlayerStatus.Text = ""; } if (playerItem.GameStatus != "outOfGame") { var elapsed = new TimeSpan(); if (playerItem.Timestamp != 0) { elapsed = DateTime.Now.Subtract(Client.JavaTimeStampToDateTime(playerItem.Timestamp)); } switch (playerItem.GameStatus) { case "inGame": champions inGameChamp = champions.GetChampion(playerItem.Champion); if (inGameChamp != null) { PlayerItem.InGameStatus.Text = "In Game" + Environment.NewLine + "Playing as " + inGameChamp.displayName + Environment.NewLine + "For " + string.Format("{0} Minutes and {1} Seconds", elapsed.Minutes, elapsed.Seconds); } else { PlayerItem.InGameStatus.Text = "In Game"; } break; case "hostingPracticeGame": PlayerItem.InGameStatus.Text = "Creating Custom Game"; break; case "inQueue": PlayerItem.InGameStatus.Text = "In Queue" + Environment.NewLine + "For " + string.Format("{0} Minutes and {1} Seconds", elapsed.Minutes, elapsed.Seconds); break; case "spectating": PlayerItem.InGameStatus.Text = "Spectating"; break; case "championSelect": PlayerItem.InGameStatus.Text = "In Champion Select" + Environment.NewLine + "For " + string.Format("{0} Minutes and {1} Seconds", elapsed.Minutes, elapsed.Seconds); break; case "hostingRankedGame": PlayerItem.InGameStatus.Text = "Creating Ranked Game"; break; case "teamSelect": PlayerItem.InGameStatus.Text = "In Team Select"; break; case "hostingNormalGame": PlayerItem.InGameStatus.Text = "Creating Normal Game"; break; case "hostingCoopVsAIGame": PlayerItem.InGameStatus.Text = "Creating Co-op vs. AI Game"; break; case "inTeamBuilder": PlayerItem.InGameStatus.Text = "In Team Builder"; break; case "tutorial": PlayerItem.InGameStatus.Text = "In Tutorial"; break; } PlayerItem.InGameStatus.Visibility = Visibility.Visible; } PlayerItem.Width = 250; PlayerItem.HorizontalAlignment = HorizontalAlignment.Right; PlayerItem.VerticalAlignment = VerticalAlignment.Top; } Point mouseLocation = e.GetPosition(Client.MainGrid); double yMargin = mouseLocation.Y; if (yMargin + 195 > Client.MainGrid.ActualHeight) { yMargin = Client.MainGrid.ActualHeight - 195; } PlayerItem.Margin = new Thickness(0, yMargin, 250, 0); }
public void GotRecentGames(RecentGames result) { GameStats.Clear(); try { result.GameStatistics.Sort((s1, s2) => s2.CreateDate.CompareTo(s1.CreateDate)); foreach (PlayerGameStats Game in result.GameStatistics) { Game.GameType = Client.TitleCaseString(Game.GameType.Replace("_GAME", "").Replace("MATCHED", "NORMAL")); var Match = new MatchStats(); foreach (RawStat Stat in Game.Statistics) { Type type = typeof(MatchStats); string fieldName = Client.TitleCaseString(Stat.StatType.Replace('_', ' ')).Replace(" ", ""); FieldInfo f = type.GetField(fieldName); f.SetValue(Match, Stat.Value); } Match.Game = Game; GameStats.Add(Match); } } catch { Client.Log("Can't load player recent games", "ERROR"); } Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { GamesListView.Items.Clear(); BlueListView.Items.Clear(); ItemsListView.Items.Clear(); PurpleListView.Items.Clear(); GameStatsListView.Items.Clear(); foreach (MatchStats stats in GameStats) { var item = new RecentGameOverview(); champions GameChamp = champions.GetChampion((int)Math.Round(stats.Game.ChampionId)); item.ChampionImage.Source = GameChamp.icon; item.ChampionNameLabel.Content = GameChamp.displayName; item.ScoreLabel.Content = string.Format("{0}/{1}/{2} ", stats.ChampionsKilled, stats.NumDeaths, stats.Assists); switch (stats.Game.QueueType) { case "NORMAL": item.ScoreLabel.Content += "(Normal)"; break; case "NORMAL_3x3": item.ScoreLabel.Content += "(Normal 3v3)"; break; case "ARAM_UNRANKED_5x5": item.ScoreLabel.Content += "(ARAM)"; break; case "NONE": item.ScoreLabel.Content += "(Custom)"; break; case "RANKED_SOLO_5x5": item.ScoreLabel.Content += "(Ranked 5v5)"; break; case "RANKED_TEAM_5x5": item.ScoreLabel.Content += "(Ranked Team 5v5)"; break; case "RANKED_TEAM_3x3": item.ScoreLabel.Content += "(Ranked Team 3v3)"; break; case "CAP_5x5": item.ScoreLabel.Content += "(Team Builder)"; break; case "BOT": item.ScoreLabel.Content += "(Bots)"; break; default: Client.Log(stats.Game.QueueType); item.ScoreLabel.Content += "Please upload this log to github."; break; } item.CreepScoreLabel.Content = stats.MinionsKilled + " minions"; item.DateLabel.Content = stats.Game.CreateDate; item.IpEarnedLabel.Content = "+" + stats.Game.IpEarned + " IP"; item.PingLabel.Content = stats.Game.UserServerPing + "ms"; var bc = new BrushConverter(); var brush = (Brush)bc.ConvertFrom("#FF609E74"); if (stats.Lose == 1) { brush = (Brush)bc.ConvertFrom("#FF9E6060"); } else if (stats.Game.IpEarned == 0) { brush = (Brush)bc.ConvertFrom("#FFE27100"); } item.GridView.Background = brush; item.GridView.Width = 250; GamesListView.Items.Add(item); } if (GamesListView.Items.Count > 0) { GamesListView.SelectedIndex = 0; } })); }
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); }
private void UpdateChat(object sender, System.Timers.ElapsedEventArgs e) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { if (Client.CurrentStatus != StatusBox.Text && StatusBox.Text != "Set your status message") { Client.CurrentStatus = StatusBox.Text; } else if (StatusBox.Text == "Set your status message") { Client.CurrentStatus = "Online"; } Properties.Settings.Default.StatusMsg = StatusBox.Text; Properties.Settings.Default.Save(); if (Client.UpdatePlayers) { Client.UpdatePlayers = false; ChatListView.Children.Clear(); foreach (Group g in Client.Groups) { ListView PlayersListView = new ListView(); PlayersListView.HorizontalAlignment = HorizontalAlignment.Stretch; PlayersListView.VerticalContentAlignment = VerticalAlignment.Stretch; PlayersListView.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); PlayersListView.Foreground = Brushes.White; PlayersListView.Background = null; PlayersListView.BorderBrush = null; PlayersListView.SelectionChanged += ChatListView_SelectionChanged; PlayersListView.PreviewMouseWheel += PlayersListView_PreviewMouseWheel; int Players = 0; foreach (KeyValuePair <string, ChatPlayerItem> ChatPlayerPair in Client.AllPlayers.ToArray()) { ChatPlayer player = new ChatPlayer(); player.Tag = ChatPlayerPair.Value; player.DataContext = ChatPlayerPair.Value; player.ContextMenu = (ContextMenu)Resources["PlayerChatMenu"]; if (ChatPlayerPair.Value.IsOnline && g.GroupName == ChatPlayerPair.Value.Group) { player.Width = 250; BrushConverter bc = new BrushConverter(); Brush brush = (Brush)bc.ConvertFrom("#FFFFFFFF"); player.PlayerStatus.Foreground = brush; var uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", ChatPlayerPair.Value.ProfileIcon + ".png"); player.ProfileImage.Source = Client.GetImage(uriSource); if (ChatPlayerPair.Value.GameStatus != "outOfGame") { switch (ChatPlayerPair.Value.GameStatus) { case "inGame": champions InGameChamp = champions.GetChampion(ChatPlayerPair.Value.Champion); if (InGameChamp != null) { player.PlayerStatus.Content = "In Game as " + InGameChamp.displayName; } else { player.PlayerStatus.Content = "In Game"; } break; case "hostingPracticeGame": player.PlayerStatus.Content = "Creating Custom Game"; break; case "inQueue": player.PlayerStatus.Content = "In Queue"; break; case "spectating": player.PlayerStatus.Content = "Spectating"; break; case "championSelect": player.PlayerStatus.Content = "In Champion Select"; break; } brush = (Brush)bc.ConvertFrom("#FFFFFF99"); player.PlayerStatus.Foreground = brush; } player.MouseMove += ChatPlayerMouseOver; player.MouseLeave += player_MouseLeave; PlayersListView.Items.Add(player); Players++; } else if (!ChatPlayerPair.Value.IsOnline && g.GroupName == "Offline") { player.Width = 250; player.Height = 30; player.PlayerName.Margin = new Thickness(5, 2.5, 0, 0); player.LevelLabel.Visibility = System.Windows.Visibility.Hidden; player.ProfileImage.Visibility = System.Windows.Visibility.Hidden; PlayersListView.Items.Add(player); Players++; } } ChatGroup GroupControl = new ChatGroup(); GroupControl.Width = 230; GroupControl.PlayersLabel.Content = Players; GroupControl.NameLabel.Content = g.GroupName; GroupControl.GroupListView.Children.Add(PlayersListView); if (g.IsOpen) { GroupControl.ExpandLabel.Content = "-"; GroupControl.GroupListView.Visibility = System.Windows.Visibility.Visible; } ChatListView.Children.Add(GroupControl); } } })); }
private void RenderStats(EndOfGameStats Statistics) { TimeSpan t = TimeSpan.FromSeconds(Statistics.GameLength); TimeLabel.Content = string.Format("{0:D2}:{1:D2}", t.Minutes, t.Seconds); ModeLabel.Content = Statistics.GameMode; TypeLabel.Content = Statistics.GameType; GainedIP.Content = "+" + Statistics.IpEarned + " IP"; TotalIP.Content = Statistics.IpTotal.ToString().Replace(".0", "") + " IP Total"; string game = " XP"; List <PlayerParticipantStatsSummary> AllParticipants = new List <PlayerParticipantStatsSummary>(Statistics.TeamPlayerParticipantStats.ToArray()); AllParticipants.AddRange(Statistics.OtherTeamPlayerParticipantStats); foreach (PlayerParticipantStatsSummary summary in AllParticipants) { EndOfGamePlayer playerStats = new EndOfGamePlayer(); champions Champ = champions.GetChampion(summary.SkinName); //Misleading variable name playerStats.ChampImage.Source = Champ.icon; playerStats.ChampLabel.Content = Champ.name; playerStats.PlayerLabel.Content = summary.SummonerName; var uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)summary.Spell1Id)), UriKind.Absolute); playerStats.Spell1Image.Source = new BitmapImage(uriSource); uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "spell", SummonerSpell.GetSpellImageName((int)summary.Spell2Id)), UriKind.Absolute); playerStats.Spell2Image.Source = new BitmapImage(uriSource); double ChampionsKilled = 0; double Assists = 0; double Deaths = 0; bool victory = false; foreach (RawStatDTO stat in summary.Statistics) { if (stat.StatTypeName.ToLower() == "win") { victory = true; } } if (Statistics.Ranked) { game = " LP"; GainedXP.Content = (victory ? "+" : "-") + Statistics.ExperienceEarned + game; TotalXP.Content = Statistics.ExperienceTotal + game; } else { GainedXP.Content = "+" + Statistics.ExperienceEarned + game; TotalXP.Content = Statistics.ExperienceTotal + game; } foreach (RawStatDTO stat in summary.Statistics) { if (stat.StatTypeName.StartsWith("ITEM") && stat.Value != 0) { System.Windows.Controls.Image item = new System.Windows.Controls.Image(); uriSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "item", stat.Value + ".png"), UriKind.Absolute); item.Source = new BitmapImage(uriSource); playerStats.ItemsListView.Items.Add(item); } switch (stat.StatTypeName) { case "GOLD_EARNED": if (stat.Value > 0) { playerStats.GoldLabel.Content = string.Format("{0:N1}k", stat.Value / 1000); } break; case "MINIONS_KILLED": playerStats.CSLabel.Content = stat.Value; break; case "LEVEL": playerStats.LevelLabel.Content = stat.Value; break; case "CHAMPIONS_KILLED": ChampionsKilled = stat.Value; break; case "ASSISTS": Assists = stat.Value; break; case "NUM_DEATHS": Deaths = stat.Value; break; default: break; } } playerStats.ScoreLabel.Content = ChampionsKilled + "/" + Deaths + "/" + Assists; PlayersListView.Items.Add(playerStats); } PlayersListView.Items.Insert(AllParticipants.Count / 2, new Separator()); championSkins Skin = championSkins.GetSkin(Statistics.SkinIndex); try { if (Skin != null) { var skinSource = new Uri(Path.Combine(Client.ExecutingDirectory, "Assets", "champions", Skin.splashPath), UriKind.Absolute); SkinImage.Source = new BitmapImage(skinSource); } } catch { } }
private void UpdateChat(object sender, ElapsedEventArgs e) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { if (Client.CurrentStatus != StatusBox.Text && StatusBox.Text != "Set your status message") { Client.CurrentStatus = StatusBox.Text; } else if (StatusBox.Text == "Set your status message") { Client.CurrentStatus = "Online"; } Settings.Default.StatusMsg = StatusBox.Text; Settings.Default.Save(); if (!Client.UpdatePlayers) { return; } Client.UpdatePlayers = false; ChatListView.Children.Clear(); foreach (Group g in Client.Groups) { var playersListView = new ListView { HorizontalAlignment = HorizontalAlignment.Stretch, VerticalContentAlignment = VerticalAlignment.Stretch }; playersListView.SetValue(ScrollViewer.HorizontalScrollBarVisibilityProperty, ScrollBarVisibility.Disabled); playersListView.Foreground = Brushes.White; playersListView.Background = null; playersListView.BorderBrush = null; playersListView.MouseDoubleClick += PlayersListView_MouseDoubleClick; playersListView.SelectionChanged += ChatListView_SelectionChanged; playersListView.PreviewMouseWheel += PlayersListView_PreviewMouseWheel; int players = 0; foreach (var chatPlayerPair in Client.AllPlayers.ToArray().OrderBy(u => u.Value.Username)) { var player = new ChatPlayer { Tag = chatPlayerPair.Value, DataContext = chatPlayerPair.Value, ContextMenu = (ContextMenu)Resources["PlayerChatMenu"], PlayerName = { Content = chatPlayerPair.Value.Username }, LevelLabel = { Content = chatPlayerPair.Value.Level } }; var bc = new BrushConverter(); var brush = (Brush)bc.ConvertFrom("#FFFFFFFF"); player.PlayerStatus.Content = chatPlayerPair.Value.Status; player.PlayerStatus.Foreground = brush; if (chatPlayerPair.Value.IsOnline && g.GroupName == chatPlayerPair.Value.Group) { player.Width = 250; bc = new BrushConverter(); brush = (Brush)bc.ConvertFrom("#FFFFFFFF"); player.PlayerStatus.Foreground = brush; string uriSource = Path.Combine(Client.ExecutingDirectory, "Assets", "profileicon", chatPlayerPair.Value.ProfileIcon + ".png"); player.ProfileImage.Source = Client.GetImage(uriSource); if (chatPlayerPair.Value.GameStatus != "outOfGame") { switch (chatPlayerPair.Value.GameStatus) { case "inGame": champions inGameChamp = champions.GetChampion(chatPlayerPair.Value.Champion); if (inGameChamp != null) { player.PlayerStatus.Content = "In Game as " + inGameChamp.displayName; } else { player.PlayerStatus.Content = "In Game"; } break; case "hostingPracticeGame": player.PlayerStatus.Content = "Creating Custom Game"; break; case "inQueue": player.PlayerStatus.Content = "In Queue"; break; case "spectating": player.PlayerStatus.Content = "Spectating"; break; case "championSelect": player.PlayerStatus.Content = "In Champion Select"; break; case "hostingRankedGame": player.PlayerStatus.Content = "Creating Ranked Game"; break; case "teamSelect": player.PlayerStatus.Content = "In Team Select"; break; case "hostingNormalGame": player.PlayerStatus.Content = "Creating Normal Game"; break; case "hostingCoopVsAIGame": player.PlayerStatus.Content = "Creating Co-op vs. AI Game"; break; case "inTeamBuilder": player.PlayerStatus.Content = "In Team Builder"; break; case "tutorial": player.PlayerStatus.Content = "In Tutorial"; break; } brush = (Brush)bc.ConvertFrom("#FFFFFF99"); player.PlayerStatus.Foreground = brush; } player.MouseRightButtonDown += player_MouseRightButtonDown; player.MouseMove += ChatPlayerMouseOver; player.MouseLeave += player_MouseLeave; playersListView.Items.Add(player); players++; } else if (!chatPlayerPair.Value.IsOnline && g.GroupName == "Offline") { player.Width = 250; player.Height = 30; player.PlayerName.Margin = new Thickness(5, 2.5, 0, 0); player.LevelLabel.Visibility = Visibility.Hidden; player.ProfileImage.Visibility = Visibility.Hidden; playersListView.Items.Add(player); players++; } } var groupControl = new ChatGroup { Width = 230, PlayersLabel = { Content = players }, NameLabel = { Content = g.GroupName } }; groupControl.GroupListView.Children.Add(playersListView); if (g.IsOpen) { groupControl.ExpandLabel.Content = "-"; groupControl.GroupListView.Visibility = Visibility.Visible; } if (!String.IsNullOrEmpty(g.GroupName)) { ChatListView.Children.Add(groupControl); } else { Client.Log("Removed a group"); } } if (ChatListView.Children.Count > 0 && ChatListView.Children[0] is ChatGroup) { (ChatListView.Children[0] as ChatGroup).GroupGrid_MouseDown(null, null); } })); }
private void GotStats(AggregatedStats stats) { Dispatcher.BeginInvoke(DispatcherPriority.Input, new ThreadStart(() => { SelectedAggregatedStats = stats; ViewAggregatedStatsButton.IsEnabled = false; TopChampionsListView.Items.Clear(); var ChampionStats = new List <AggregatedChampion>(); int i = 0; if (SelectedAggregatedStats.LifetimeStatistics == null) { return; } if (!SelectedAggregatedStats.LifetimeStatistics.Any()) { return; } foreach (AggregatedStat stat in SelectedAggregatedStats.LifetimeStatistics) { AggregatedChampion Champion = ChampionStats.Find(x => x.ChampionId == stat.ChampionId); if (Champion == null) { Champion = new AggregatedChampion { ChampionId = stat.ChampionId }; ChampionStats.Add(Champion); } Type type = typeof(AggregatedChampion); string fieldName = Client.TitleCaseString(stat.StatType.Replace('_', ' ')).Replace(" ", ""); FieldInfo f = type.GetField(fieldName); f.SetValue(Champion, stat.Value); } ChampionStats.Sort((x, y) => y.TotalSessionsPlayed.CompareTo(x.TotalSessionsPlayed)); foreach (AggregatedChampion info in ChampionStats.TakeWhile(info => i++ <= 6)) { ViewAggregatedStatsButton.IsEnabled = true; if (!(Math.Abs(info.ChampionId) > 0)) { continue; } champions Champion = champions.GetChampion(Convert.ToInt32(info.ChampionId)); var player = new ChatPlayer { LevelLabel = { Visibility = Visibility.Hidden }, PlayerName = { Content = Champion.displayName }, PlayerStatus = { Content = info.TotalSessionsPlayed + " games played" }, ProfileImage = { Source = champions.GetChampion(Champion.id).icon }, Background = new SolidColorBrush(Color.FromArgb(102, 80, 80, 80)), Width = 270 }; TopChampionsListView.Items.Add(player); } })); }