示例#1
0
        private void LoadSummoner(SummonerCache.Item item)
        {
            SearchBox.BorderBrush    = App.ForeBrush;
            HistoryList.SelectedItem = Selected = item;

            if (item.Data != null)
            {
                SummonerName.Content = item.Data.Summoner.Name;
                SummonerIcon.Source  = DataDragon.GetProfileIconImage(DataDragon.GetIconData(item.Data.Summoner.ProfileIconId)).Load();
            }

            if (item.MatchHistory != null)
            {
                MatchesPane.Child = new MatchHistory(item);
            }

            if (item.Data != null && item.Data.SummonerLevel.Level < 30)
            {
                SummonerRank.Content = "Level " + item.Data.SummonerLevel;
            }
            else if (item.Leagues != null)
            {
                var league = item.Leagues.SummonerLeagues.FirstOrDefault(l => l.Queue.Equals(QueueType.RANKED_SOLO_5x5.Key));
                if (league != null)
                {
                    SummonerRank.Content = RankedTier.Values[league.Tier] + " " + league.Rank;
                }
            }
            Profile_Click(ProfileTab, null);
        }
示例#2
0
        public ChampMastery(ChampionDto champ, int rank)
        {
            InitializeComponent();

            ChampImage.Source = DataDragon.GetChampIconImage(champ).Load();
            RankImage.Source  = new BitmapImage(new Uri($"pack://application:,,,/RiotAPI;component/Resources/ChampMastery{rank + 1}.png"));
        }
示例#3
0
        private async Task <List <Champions.Champion> > GetChampionsFromIDAsync(string region, long[] ids)
        {
            List <Champions.Champion> listOfChamps = new List <Champions.Champion>();
            var ddjson = await DataDragon.GetDDVersionAsync(region);

            if (ddjson == "invalidregion".ToLower())
            {
                return(null);
            }
            else
            {
                DataDragon.Realms DataDragonRegion = JsonConvert.DeserializeObject <DataDragon.Realms>(ddjson);
                Uri url      = new Uri($"http://ddragon.leagueoflegends.com/cdn/{DataDragonRegion.n.champion}/data/en_US/champion.json");
                var jsonData = await webClient.GetStringAsync(url);

                var json = JsonConvert.DeserializeObject <Champions.RootChampions>(jsonData);

                for (int i = 0; i < ids.Length; ++i)
                {
                    foreach (var champion in json.Data)
                    {
                        if (champion.Value.key == ids[i].ToString())
                        {
                            listOfChamps.Add(champion.Value);
                            break;
                        }
                    }
                }
                return(listOfChamps);
            }
        }
示例#4
0
 private void GotSummoner(SummonerCache.Item item)
 {
     Dispatcher.Invoke(() => {
         ProfileIconImage.Source = DataDragon.GetProfileIconImage(DataDragon.GetIconData(item.Data.Summoner.ProfileIconId)).Load();
         NameLabel.Content       = item.Data.Summoner.Name;
     });
 }
示例#5
0
        public void GetRegion_ReturnsRU()
        {
            var dd = new DataDragon();

            var result = dd.GetRegion("Ru");

            Assert.AreEqual("ru", result);
        }
示例#6
0
        public void GetRegion_ReturnsOCE()
        {
            var dd = new DataDragon();

            var result = dd.GetRegion("OCE");

            Assert.AreEqual("oce", result);
        }
示例#7
0
        public void GetRegion_ReturnsInvalidRegion()
        {
            var dd = new DataDragon();

            var result = dd.GetRegion("hi");

            Assert.AreEqual("invalidregion", result);
        }
示例#8
0
        public void GetRegion_ReturnsEUNE()
        {
            var dd = new DataDragon();

            var result = dd.GetRegion("eune");

            Assert.AreEqual("eune", result);
        }
示例#9
0
        public void GetRegion_ReturnsKR()
        {
            var dd = new DataDragon();

            var result = dd.GetRegion("KR");

            Assert.AreEqual("kr", result);
        }
示例#10
0
        public void GetRegion_ReturnsLAS()
        {
            var dd = new DataDragon();

            var result = dd.GetRegion("las");

            Assert.AreEqual("las", result);
        }
示例#11
0
        public void GetRegion_ReturnsJP()
        {
            var dd = new DataDragon();

            var result = dd.GetRegion("JP");

            Assert.AreEqual("jp", result);
        }
示例#12
0
        public void DDVersionAsync_ReturnsInvalidRegion()
        {
            var dd = new DataDragon();

            var result = dd.GetDDVersionAsync("hi").GetAwaiter().GetResult();

            Assert.AreEqual("invalidregion", result);
        }
示例#13
0
        public ChampSelectPlayer(BotParticipant bot) : this()
        {
            var champ = DataDragon.ChampData.Value.data[bot.SummonerInternalName.Split('_')[1]];

            ChampImage.Source    = DataDragon.GetChampIconImage(champ).Load();
            NameLabel.Visibility = Visibility.Visible;
            NameLabel.Content    = champ.name;
            Unknown.Visibility   = Obscure.Visibility = Visibility.Collapsed;
        }
示例#14
0
 public LoginAccount(string login, string name, int profileicon) : this()
 {
     try {
         ProfileIcon.Source = DataDragon.GetProfileIconImage(DataDragon.GetIconData(profileicon)).Load();
     } catch { }
     NameLabel.Content = name;
     Username          = login;
     State             = LoginAccountState.Normal;
 }
示例#15
0
        private void UpdateList()
        {
            var images = new List <object>();

            foreach (var item in _spells)
            {
                images.Add(new { Image = DataDragon.GetSpellImage(item).Load(), Name = item.name, Data = item });
            }
            SpellGrid.ItemsSource = images;
        }
示例#16
0
        public void SetChampList(IEnumerable <MyChampDto> champions)
        {
            var groups = new Dictionary <string, List <object> >();

            champs = champions.ToList();
            var save   = new List <int>();
            var filter = SearchBox.Text;

            if (filter.Equals("Search"))
            {
                filter = "";
            }
            foreach (var item in champions.OrderBy(c => c.name).Where(c => Regex.IsMatch(c.name, filter, RegexOptions.IgnoreCase | RegexOptions.IgnorePatternWhitespace)))
            {
                save.Add(item.key);
                if (!groups.ContainsKey(item.tags[0]))
                {
                    groups[item.tags[0]] = new List <object>();
                }
                groups[item.tags[0]].Add(new { Image = DataDragon.GetChampIconImage(item).Load(), Name = item.name, Data = item });
            }
            if (last != null && save.SequenceEqual(last))
            {
                return;
            }
            last = save;

            GroupsList.Children.Clear();
            foreach (var group in groups)
            {
                var grid = new Grid();
                grid.RowDefinitions.Add(new RowDefinition {
                    Height = GridLength.Auto
                });
                grid.RowDefinitions.Add(new RowDefinition());

                var label = new Label {
                    Content = group.Key, FontSize = 18
                };
                grid.Children.Add(label);

                var items = new ItemsControl {
                    ItemsSource = group.Value
                };
                grid.Children.Add(items);

                Grid.SetRow(items, 1);
                GroupsList.Children.Add(grid);
            }

            ChampSelect.Visibility = Visibility.Visible;
            SkinSelect.Visibility  = Visibility.Collapsed;
        }
示例#17
0
 private void Update()
 {
     if (Member.IsBot)
     {
         var champ = DataDragon.ChampData.Value.data[Member.Name.Split('_')[1]];
         SummonerIcon = DataDragon.GetChampIconImage(champ).Load();
         UserName     = champ.name;
     }
     else
     {
         Session.Current.SummonerCache.GetData(Member.Name, GotSummonerData);
         UserName = Member.Name;
     }
 }
示例#18
0
        public void DDVersionAsync_ReturnsVersion()
        {
            // Arrange
            var        dd     = new DataDragon();
            Uri        url    = new Uri($"https://ddragon.leagueoflegends.com/realms/euw.json");
            HttpClient client = new HttpClient();

            //Act
            var jsondata = client.GetStringAsync(url).GetAwaiter().GetResult();
            var result   = dd.GetDDVersionAsync("euw").GetAwaiter().GetResult();

            //Assert
            Assert.AreEqual(jsondata, result);
        }
示例#19
0
        public async void UpdateChampList()
        {
            var champs = new List <MyChampDto>();

            foreach (var riot in await Session.Current.Account.GetAvailableChampions())
            {
                if ((!riot.Owned && !riot.FreeToPlay) || riot.Banned)
                {
                    continue;
                }
                champs.Add(DataDragon.GetChampData(riot.ChampionId));
            }
            SetChampList(champs);
        }
示例#20
0
        public MatchDetails(RiotACS.Game game, RiotACS.Delta delta, Action back = null)
        {
            InitializeComponent();

            this.back = back;
            if (back == null)
            {
                BackButton.Visibility = Visibility.Collapsed;
            }

            var blue = new List <object>();
            var red  = new List <object>();

            foreach (var player in game.Participants)
            {
                var champ  = DataDragon.GetChampData(player.ChampionId);
                var spell1 = DataDragon.GetSpellData(player.Spell1Id);
                var spell2 = DataDragon.GetSpellData(player.Spell2Id);

                var items = new[] { player.Stats.Item0, player.Stats.Item1, player.Stats.Item2, player.Stats.Item3, player.Stats.Item4, player.Stats.Item5, player.Stats.Item6 };

                var item = new {
                    ChampImage  = DataDragon.GetChampIconImage(champ),
                    Spell1Image = DataDragon.GetSpellImage(spell1),
                    Spell2Image = DataDragon.GetSpellImage(spell2),
                    Name        = champ.name,
                    Score       = $"{player.Stats.Kills} / {player.Stats.Deaths} / {player.Stats.Assists}",
                    Item0Image  = DataDragon.GetItemImage(items[0]),
                    Item1Image  = DataDragon.GetItemImage(items[1]),
                    Item2Image  = DataDragon.GetItemImage(items[2]),
                    Item3Image  = DataDragon.GetItemImage(items[3]),
                    Item4Image  = DataDragon.GetItemImage(items[4]),
                    Item5Image  = DataDragon.GetItemImage(items[5]),
                    Item6Image  = DataDragon.GetItemImage(items[6]),
                    CS          = player.Stats.TotalMinionsKilled,
                    Gold        = (player.Stats.GoldEarned / 1000.0).ToString("#.#k")
                };

                if (player.TeamId == 100)
                {
                    blue.Add(item);
                }
                else
                {
                    red.Add(item);
                }
            }
            BlueTeam.ItemsSource = blue;
            RedTeam.ItemsSource  = red;
        }
示例#21
0
        public RuneListItem(SummonerRune item, int count) : this()
        {
            Rune = item;

            var rune = DataDragon.RuneData.Value.data[item.RuneId.ToString()];

            if (rune.rune.type.Equals("black"))
            {
                RuneIcon.Width = RuneIcon.Height;
            }
            RuneIcon.Source = DataDragon.GetRuneImage(rune).Load();
            RuneName.Text   = rune.name;
            RuneStats.Text  = rune.description;
            RuneCount.Text  = "x" + count;
        }
示例#22
0
        public LobbyPlayer2(bool amCaptain, QueueLobbyMember member, int profileIconId)
        {
            InitializeComponent();

            KickButton.Visibility = GiveInviteButt.Visibility = Visibility.Collapsed;
            CanControl            = amCaptain;
            NameLabel.Content     = member.Name;
            Member = member;

            ProfileIconImage.Source = DataDragon.GetProfileIconImage(DataDragon.GetIconData(profileIconId)).Load();

            member.Changed += (s, e) => Update();
            Update();
            Session.Current.SummonerCache.GetData(member.Name, GotSummoner);
        }
示例#23
0
 private void SpellSelector_SpellSelected(object sender, SpellDto e)
 {
     Popup.BeginStoryboard(App.FadeOut);
     if (doSpell1)
     {
         spell1             = e;
         Spell1Image.Source = DataDragon.GetSpellImage(e).Load();
     }
     else
     {
         spell2             = e;
         Spell2Image.Source = DataDragon.GetSpellImage(e).Load();
     }
     game.SelectSpells(spell1.key, spell2.key);
 }
示例#24
0
        private void UpdateSkinList()
        {
            var images = new List <object>();

            foreach (var item in skins)
            {
                images.Add(new {
                    Image = DataDragon.GetChampLoadingImage(SelectedChampion, item.num),
                    Name  = item.name,
                    Data  = item
                });
            }
            SkinsGrid.ItemsSource = images;
            SkinScroll.ScrollToHorizontalOffset(294);
        }
示例#25
0
        public async Task CommandMastery(string region, string summonerName)
        {
            Enum.TryParse(typeof(Region), region, true, out var regionEnum);
            if (regionEnum == null)
            {
                throw new Exception("Region could not be parsed");
            }

            var latestDataDragonVersion = await DataDragon.GetLatestVersion();

            var summoner = await _api.Summoner.GetSummonerByNameAsync((Region)regionEnum, summonerName);

            var top5Mastery = await Summoner.GetMasteries((Region)regionEnum, summoner);

            if (!top5Mastery.Any())
            {
                await ReplyAsync("No mastery details could be found.");

                return;
            }

            var champions = await Champion.GetAllChampions(latestDataDragonVersion);

            var embed = new EmbedBuilder()
                        .WithTitle("Top 5 Champion Mastery's");

            var topChampionImage = champions.FirstOrDefault(x => x.Id == top5Mastery.FirstOrDefault()?.ChampionId)?.Image;

            if (topChampionImage != null)
            {
                var topChampionDataDragonImageUrl = Champion.GetImageUrl(latestDataDragonVersion, topChampionImage.Full);
                embed = embed.WithThumbnailUrl(topChampionDataDragonImageUrl);
            }

            foreach (var championMastery in top5Mastery)
            {
                var champion = champions.FirstOrDefault(x => x.Id == championMastery.ChampionId);
                if (champion == null)
                {
                    break;
                }

                embed = embed.AddField(champion.Name, $"{championMastery.ChampionPoints:n0} Points");
            }

            await ReplyAsync("", false, embed.Build());
        }
示例#26
0
 private void GotChampions(Task <ChampionDTO[]> Champs)
 {
     if (Champs.IsFaulted)
     {
         if (Debugger.IsAttached)
         {
             Debugger.Break();
         }
         return;
     }
     RiotChampions      = new List <ChampionDTO>(Champs.Result);
     AvailableChampions = new List <MyChampDTO>();
     foreach (var item in Champs.Result)
     {
         AvailableChampions.Add(DataDragon.GetChampData(item.ChampionId));
     }
 }
示例#27
0
        public MatchHistoryItem()
        {
            InitializeComponent();

            Loaded += (src, e) => {
                var game     = DataContext as RiotACS.Game;
                var identity = game.ParticipantIdentities.FirstOrDefault(i => i.Player.AccountId == Session.Current.Account.AccountID);
                var me       = game.Participants.FirstOrDefault(p => p.ParticipantId == identity.ParticipantId);

                var champ  = DataDragon.GetChampData(me.ChampionId);
                var spell1 = DataDragon.GetSpellData(me.Spell1Id);
                var spell2 = DataDragon.GetSpellData(me.Spell2Id);

                ChampImage.Source  = DataDragon.GetChampIconImage(champ).Load();
                Spell1Image.Source = DataDragon.GetSpellImage(spell1).Load();
                Spell2Image.Source = DataDragon.GetSpellImage(spell2).Load();

                MapLabel.Content = DataDragon.GameMaps[game.MapId];
                if (game.GameType.Equals("CUSTOM_GAME"))
                {
                    ModeLabel.Content = "Custom";
                }
                else if (game.GameType.Equals("TUTORIAL_GAME"))
                {
                    ModeLabel.Content = "Tutorial";
                }
                else
                {
                    ModeLabel.Content = GameMode.Values[game.GameMode].Value;
                }

                var items  = new[] { me.Stats.Item0, me.Stats.Item1, me.Stats.Item2, me.Stats.Item3, me.Stats.Item4, me.Stats.Item5, me.Stats.Item6 };
                var images = new[] { Item0Image, Item1Image, Item2Image, Item3Image, Item4Image, Item5Image, Item6Image };
                for (int i = 0; i < items.Length; i++)
                {
                    images[i].Source = DataDragon.GetItemImage(items[i]).Load();
                }

                ScoreLabel.Content = $"{me.Stats.Kills} / {me.Stats.Deaths} / {me.Stats.Assists}";
                var date = Session.Epoch.AddMilliseconds(game.GameCreation);

                DateLabel.Content = date.ToString("M / d / yyyy");
                TimeLabel.Content = date.ToString("h:mm tt");
            };
        }
示例#28
0
        private void GotSummonerData(SummonerCache.Item item)
        {
            if (item.Data != null)
            {
                SummonerIcon = DataDragon.GetProfileIconImage(DataDragon.GetIconData(item.Data.Summoner.ProfileIconId)).Load();
                LevelString  = "Level " + item.Data.SummonerLevel.Level;
                UserName     = item.Data.Summoner.Name;
            }

            if (item.Leagues != null)
            {
                var league = item.Leagues.SummonerLeagues.FirstOrDefault(l => l.Queue.Equals(QueueType.RANKED_SOLO_5x5.Key));
                if (league != null)
                {
                    RankString = RankedTier.Values[league.Tier] + " " + league.Rank;
                }
            }
        }
示例#29
0
        public async Task LSummoner(CommandContext ctx, string region, [RemainingText] string name)
        {
            var ddjson = await DataDragon.GetDDVersionAsync(region);

            if (ddjson == "invalidregion".ToLower())
            {
                await ctx.RespondAsync("Invalid Region");
            }
            else
            {
                RiotApi riotApi = RiotApi.NewInstance(GetAPIKey().LeagueAPI);
                try
                {
                    Region            platform         = GetRegion(region);
                    DataDragon.Realms DataDragonRegion = JsonConvert.DeserializeObject <DataDragon.Realms>(ddjson);
                    var summoner = await riotApi.SummonerV4.GetBySummonerNameAsync(platform, name);

                    LeagueEntry[] Entries = await riotApi.LeagueV4.GetLeagueEntriesForSummonerAsync(platform, summoner.Id);

                    string ranks = string.Empty;
                    for (int i = 0; i < Entries.Length; ++i)
                    {
                        ranks = ranks + $"**{Entries[i].QueueType}:** {Entries[i].Tier} {Entries[i].Rank}\n";
                    }
                    var embed0 = new DiscordEmbedBuilder()
                    {
                        Title        = $"Summoner: {summoner.Name}",
                        Description  = $"**Level:** {summoner.SummonerLevel}\n{ranks}",
                        ThumbnailUrl = $"http://ddragon.leagueoflegends.com/cdn/{DataDragonRegion.n.profileicon}/img/profileicon/{summoner.ProfileIconId}.png"
                    };
                    await ctx.RespondAsync(embed : embed0.Build());
                }
                catch (RiotResponseException ex)
                {
                    await ctx.RespondAsync(ex.Message);
                }
                catch (Exception)
                {
                    await ctx.RespondAsync("Couldn't find the summoner in the region.");
                }
            }
        }
示例#30
0
        public TBDPlayer(bool amCaptain, TBDLobbyMember slot, int profileIconId) : this()
        {
            KickButton.Visibility = GiveInviteButt.Visibility = Visibility.Collapsed;
            CanControl            = !slot.IsMe && amCaptain;

            this.slot     = slot;
            slot.Changed += Slot_Changed;

            NameLabel.Content = slot.Name;

            ProfileIconImage.Source = DataDragon.GetProfileIconImage(DataDragon.GetIconData(profileIconId)).Load();
            PlusPath.Visibility     = slot.HasInvitePower ? Visibility.Collapsed : Visibility.Visible;
            Session.Current.SummonerCache.GetData(slot.Name, GotSummoner);

            PrimaryCombo.Visibility = SecondaryCombo.Visibility = slot.IsMe ? Visibility.Visible : Visibility.Collapsed;

            PrimaryCombo.ItemsSource   = TBDRole.Values.Values;
            SecondaryCombo.ItemsSource = TBDRole.Values.Values;
            SecondaryCombo.IsEnabled   = false;
        }
示例#31
0
 private void DataDragon_UpdateProgress(object sender, DataDragon.ProgressEventArgs e) => Dispatcher.Invoke(Draw);
示例#32
0
		// ex
		// http://ddragon.leagueoflegends.com/cdn/5.23.1/img/champion/Jax.png
		public static DataDragon GetInstance() {
			if (_instance == null)
				_instance = new DataDragon();
			
			return _instance;
		}