Ejemplo n.º 1
0
        public LastMatches GetLastMatchesBySummoner(string region, string summonerName)
        {
            var summoner         = _summonerService.GetSummonerByName(region, summonerName);
            var matches          = _matchService.GetMatchlistByAccountId(region, summoner.AccountId);
            var lastFiveMatchIds = matches.matches.Take(5).Select(x => x.gameId).ToList();
            var wins             = new List <bool>();
            var time             = new List <string>();

            foreach (var matchId in lastFiveMatchIds)
            {
                var match       = _matchService.GetMatchByMatchId(region, matchId.ToString());
                var playerId    = match.participantIdentities.Where(x => x.player.currentAccountId == summoner.AccountId).Select(x => x.participantId);
                var win         = match.participants[playerId.FirstOrDefault() - 1].stats.win;
                var gameEndTime = UnixTimeStampToDateTime(match.gameCreation, match.gameDuration);
                wins.Add(win);
                time.Add(gameEndTime.ToString());
            }

            var lastMatches = new LastMatches
            {
                summonerName = summonerName,
                victory      = wins,
                time         = time
            };

            return(lastMatches);
        }
Ejemplo n.º 2
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;
        }
Ejemplo n.º 3
0
 internal void AddMatch(ulong id, int max = 5)
 {
     if (LastMatches.Contains(id))
     {
         LastMatches.Remove(id);
     }
     LastMatches.Add(id);
     if (LastMatches.Count > max)
     {
         LastMatches.RemoveAt(0);
     }
 }