Exemplo n.º 1
0
 public async Task<LeagueDto> SearchLeague(long id)
 {
     Requester req = new Requester(@"https://br.api.pvp.net/api/lol/br/v2.5/league/by-summoner/" + id.ToString() + "/entry?api_key=8eee2093-91d0-4a8f-bc85-c366e7de1c33");
     string json = await req.GetJson();
     LeagueDto league = new LeagueDto();
     league = JsonConvert.DeserializeObject<Dictionary<string, List<LeagueDto>>>(json).Values.First()[0];
     return league;
 }
Exemplo n.º 2
0
        public async Task <LeagueDto> SearchLeague(long id)
        {
            Requester req  = new Requester(@"https://br.api.pvp.net/api/lol/br/v2.5/league/by-summoner/" + id.ToString() + "/entry?api_key=8eee2093-91d0-4a8f-bc85-c366e7de1c33");
            string    json = await req.GetJson();

            LeagueDto league = new LeagueDto();

            league = JsonConvert.DeserializeObject <Dictionary <string, List <LeagueDto> > >(json).Values.First()[0];
            return(league);
        }
Exemplo n.º 3
0
 private async void PhoneApplicationPage_Loaded(object sender, RoutedEventArgs e)
 {
     string nameSummoner = NavigationContext.QueryString["name"];
     SummonerDto summoner = new SummonerDto();
     try
     {
         summoner = await summoner.SearchSummoner(nameSummoner);
         textBlockNomeInv.Text = summoner.Nome;
     }
     catch
     {
         MessageBox.Show("Não existe um invocador com esse nome.");
         NavigationService.GoBack();
         return;
     }
     textBlockLevel.Text += summoner.SummonerLevel.ToString();
     try
     {
         LeagueDto leagueSummoner = new LeagueDto();
         leagueSummoner = await leagueSummoner.SearchLeague(summoner.Id);
         textBlockElo.Text = leagueSummoner.Tier + " " + leagueSummoner.Entries[0].Division;
         textBlockVit.Text = leagueSummoner.Entries[0].Wins > 1 ? leagueSummoner.Entries[0].Wins.ToString() + " vitórias" : leagueSummoner.Entries[0].Wins.ToString() + " vitória";
         textBlockDer.Text = leagueSummoner.Entries[0].Losses > 1 ? leagueSummoner.Entries[0].Losses.ToString() + " derrotas" : leagueSummoner.Entries[0].Losses.ToString() + " derrota";
     }
     catch
     {
         MessageBox.Show("Informações de derrotas e vitórias são apenas para jogadores ranqueados.", "Informação", MessageBoxButton.OK);
         textBlockElo.Text = "Unranked";
         textBlockVit.Text = "0 vitória";
         textBlockDer.Text = "0 derrota";
     }
     imageInvocador.Source = await summoner.GetProfileIcon();
     RecentGamesDto gamesRecent = await new RecentGamesDto().GetLatestGamesById(summoner.Id);
     List<int> lastChampionsPlayed = new List<int>();
     foreach (GameDto game in gamesRecent.Games)
     {
         lastChampionsPlayed.Add(game.ChampionId);
         LastMatches controlMatch = new LastMatches(game);
         controlMatch.Margin = new Thickness(0, 0, 0, 10);
         controlMatch.Load();
         listboxPartidas.Items.Add(controlMatch);
     }
     int idChampPref = lastChampionsPlayed[new Random().Next(lastChampionsPlayed.Count - 1)];
     ImageBrush imgBrush = new ImageBrush();
     BitmapImage source = (await ChampionDto.SearchChampionAllData(idChampPref)).GetChampionSplash(0);
     imgBrush.ImageSource = source;
     imgBrush.Stretch = Stretch.UniformToFill;
     LayoutRoot.Background = imgBrush;
 }