Esempio n. 1
0
        public void GetItemsAsync_Test()
        {
            var items = api.GetItemsAsync(Region.euw, ItemData.all);

            Assert.IsNotNull(items.Result.Items);
            Assert.IsTrue(items.Result.Items.Count > 0);
        }
Esempio n. 2
0
        protected override async void OnAppearing()
        {
            UserDialogs.Instance.ShowLoading("Loading", MaskType.Black);

            if (App.itemList.Count == 0)
            {
                var allItems = await staticApi.GetItemsAsync(Region.euw, new List <ItemData> {
                    ItemData.image, ItemData.gold
                });

                var tempItems = allItems.Items.Values.ToList();
                foreach (var item in tempItems)
                {
                    item.Icon = new UriImageSource
                    {
                        Uri            = new Uri(string.Format("https://ddragon.leagueoflegends.com/cdn/{0}/img/item/{1}", App.appVersion, item.Image.Full)),
                        CachingEnabled = false
                    };
                }
                App.itemList = tempItems;
            }

            if (App.summonerSpellList.Count == 0)
            {
                var allSpells = await staticApi.GetSummonerSpellsAsync(Region.euw, new List <SummonerSpellData> {
                    SummonerSpellData.image, SummonerSpellData.cooldown
                });

                var tempSpells = allSpells.SummonerSpells.Values.ToList();
                foreach (var spell in tempSpells)
                {
                    spell.Icon = new UriImageSource
                    {
                        Uri            = new Uri(string.Format("https://ddragon.leagueoflegends.com/cdn/{0}/img/spell/{1}", App.appVersion, spell.Image.Full)),
                        CachingEnabled = false
                    };
                }
                App.summonerSpellList = tempSpells;
            }
            base.OnAppearing();
            var MatchList = await loadMatchHistory(Summoner, Reg, this);

            contentVue.Content = MatchList;
            UserDialogs.Instance.HideLoading();
        }
Esempio n. 3
0
        //Loads the match history
        public static async Task <ListView> loadMatchHistory(Summoner summoner, Region region)
        {
            var allItems = await staticApi.GetItemsAsync(region, ItemData.image);

            var allSummonerSpells = await staticApi.GetSummonerSpellsAsync(region, SummonerSpellData.image);

            var previousMatches = await summoner.GetRecentGamesAsync();

            var previousAll = new List <Previous>();

            for (int i = 0; i < previousMatches.Count; i++)
            {
                var gameType    = gameTypeName(previousMatches[i].GameSubType);
                var champPlayed = await staticApi.GetChampionAsync(region, previousMatches[i].ChampionId, ChampionData.image);

                var summonerSpellList = new List <string>
                {
                    allSummonerSpells.SummonerSpells.FirstOrDefault(y => y.Value.Id == previousMatches[i].SummonerSpell1).Value.Image.Full,
                    allSummonerSpells.SummonerSpells.FirstOrDefault(y => y.Value.Id == previousMatches[i].SummonerSpell2).Value.Image.Full
                };
                var itemList = new List <ItemStatic>
                {
                    allItems.Items.FirstOrDefault((x) => x.Value.Id == previousMatches[i].Statistics.Item0).Value,
                    allItems.Items.FirstOrDefault((x) => x.Value.Id == previousMatches[i].Statistics.Item1).Value,
                    allItems.Items.FirstOrDefault((x) => x.Value.Id == previousMatches[i].Statistics.Item2).Value,
                    allItems.Items.FirstOrDefault((x) => x.Value.Id == previousMatches[i].Statistics.Item3).Value,
                    allItems.Items.FirstOrDefault((x) => x.Value.Id == previousMatches[i].Statistics.Item4).Value,
                    allItems.Items.FirstOrDefault((x) => x.Value.Id == previousMatches[i].Statistics.Item5).Value,
                    allItems.Items.FirstOrDefault((x) => x.Value.Id == previousMatches[i].Statistics.Item6).Value
                };
                var itemNameList = new List <string>();
                for (int j = 0; j < itemList.Count; j++)
                {
                    if (itemList[j] != null)
                    {
                        itemNameList.Add(itemList[j].Image.Full);
                    }
                    else
                    {
                        itemNameList.Add("Empty.png");
                    }
                }

                var prev = new Previous(
                    gameType,
                    previousMatches[i].Level,
                    previousMatches[i].Statistics.Win,
                    FormatNumber(previousMatches[i].Statistics.GoldEarned),
                    previousMatches[i].Statistics.MinionsKilled.ToString(),
                    itemNameList,
                    summonerSpellList,
                    champPlayed.Image.Full,
                    previousMatches[i].CreateDate.ToString("g"),
                    previousMatches[i].Statistics.ChampionsKilled + "/" + previousMatches[i].Statistics.NumDeaths + "/" + previousMatches[i].Statistics.Assists,
                    previousMatches[i]
                    );
                previousAll.Add(prev);
            }

            var imageTemplate = new DataTemplate(typeof(PreviousGameCell));

            var MatchList = new ListView
            {
                ItemTemplate  = imageTemplate,
                ItemsSource   = previousAll,
                HasUnevenRows = true
            };

            MatchList.ItemTapped += async(object sender, ItemTappedEventArgs e) =>
            {
                var myListView = (ListView)sender;
                var myItem     = (Previous)myListView.SelectedItem;
                UserDialogs.Instance.ShowLoading("Loading Game", MaskType.Black);
                try
                {
                    Debug.WriteLine(myItem.ThisGame.GameId);
                    await Task.Delay(1000);

                    var match = await api.GetMatchAsync(region, myItem.ThisGame.GameId);

                    var previousPage = await PreviousGamePage.loadPrevious(match, myItem.ThisGame, region, summoner, myItem.ThisGame.FellowPlayers);

                    UserDialogs.Instance.HideLoading();
                    await SearchPage.Navigation.PushAsync(previousPage);
                }
                catch (Exception ex)
                {
                    UserDialogs.Instance.HideLoading();
                    Debug.WriteLine(ex);
                    await UserDialogs.Instance.AlertAsync("Are you connected to the internet?\nTry again", "An Error Occured", "Okay");
                }
            };

            return(MatchList);
        }