示例#1
0
        private void SetRankingInformation(LeagueSummoner summoner, SummonerDTO summonerDto)
        {
            ICollection <LeagueDTO> leagueDtos = _leagueRequestService.GetLeagues(summonerDto.Id);

            if (leagueDtos == null)
            {
                summoner.Tier     = "Unranked";
                summoner.Division = "";
                return;
            }

            LeagueDTO rankedSoloLeagueDto = leagueDtos.FirstOrDefault(l => l.Queue == _rankedSolo);

            if (rankedSoloLeagueDto == null)
            {
                summoner.Tier     = "Unranked";
                summoner.Division = "";
            }
            else
            {
                summoner.Tier = rankedSoloLeagueDto.Tier.ToCapitalized();

                //For solo queue there's only one entry, so we can just get it
                LeagueEntryDTO entryDto = rankedSoloLeagueDto.Entries.First();

                summoner.Division     = IsDivisionRequired(summoner.Tier) ? entryDto.Division : "";
                summoner.LeaguePoints = entryDto.LeaguePoints;
            }
        }
示例#2
0
        public async Task GetWinRatioSuccess()
        {
            using (var httpTest = new HttpTest())
            {
                //Arrange
                var playerName = "TestingPlayer";
                var regionName = "eune";
                var wins       = 10;
                var losses     = 10;
                var player     = new SummonerDTO
                {
                    Id = Guid.NewGuid().ToString()
                };
                var LeagueEntryDTOs = new LeagueEntryDTO[]
                {
                    new LeagueEntryDTO
                    {
                        QueueType = "RANKED_SOLO_5x5",
                        Wins      = wins,
                        Losses    = losses
                    }
                };
                var mockMemoryCache   = new Mock <IMemoryCache>();
                var mockIConfigration = new Mock <IConfiguration>();
                mockIConfigration.Setup(c => c[Constants.RIOT_APIKEY]).Returns("RiotApiKey");
                var riotApiService = new RiotApiService(mockMemoryCache.Object, mockIConfigration.Object);
                httpTest.RespondWithJson(player, 200);
                httpTest.RespondWithJson(LeagueEntryDTOs, 200);

                //Act

                var result = await riotApiService.GetWinRatio(playerName, regionName);

                //Assert
                httpTest.ShouldHaveCalled($"https://eun1.api.riotgames.com/lol/summoner/v4/summoners/by-name/{playerName}")
                .WithQueryParams("api_key")
                .WithVerb(HttpMethod.Get)
                .Times(1);

                httpTest.ShouldHaveCalled($"https://eun1.api.riotgames.com/lol/league/v4/entries/by-summoner/{player.Id}")
                .WithQueryParams("api_key")
                .WithVerb(HttpMethod.Get)
                .Times(1);

                var winRatio = 100 * wins / (wins + losses);
                Assert.Equal($"Solo Win Ratio: {winRatio}%\r\n", result);
            }
        }
示例#3
0
        public Fila(LeagueEntryDTO leagueEntryDTO)
        {
            if (leagueEntryDTO.queueType == "RANKED_SOLO_5x5")
            {
                nomeFila = "Ranqueado Solo/Duo";
            }
            else if (leagueEntryDTO.queueType == "RANKED_FLEX_SR")
            {
                nomeFila = "Ranqueado Flexível";
            }
            else
            {
                nomeFila = "Erro no Api League of legends";
            }

            vitorias = leagueEntryDTO.wins;
            derrotas = leagueEntryDTO.losses;
            pontos   = leagueEntryDTO.leaguePoints;
            rank     = leagueEntryDTO.rank;
            tier     = leagueEntryDTO.tier;
        }
示例#4
0
        public async Task GetDivisionsNull()
        {
            using (var httpTest = new HttpTest())
            {
                //Arrange
                var playerName = "TestingPlayer";
                var regionName = "eune";
                var player     = new SummonerDTO
                {
                    Id = Guid.NewGuid().ToString()
                };
                var leagueEntryDTOs   = new LeagueEntryDTO[0];
                var mockMemoryCache   = new Mock <IMemoryCache>();
                var mockIConfigration = new Mock <IConfiguration>();
                mockIConfigration.Setup(c => c[Constants.RIOT_APIKEY]).Returns("RiotApiKey");
                var riotApiService = new RiotApiService(mockMemoryCache.Object, mockIConfigration.Object);
                httpTest.RespondWithJson(player, 200);
                httpTest.RespondWithJson(leagueEntryDTOs, 200);

                //Act

                var result = await riotApiService.GetDivisions(playerName, regionName);

                //Assert
                httpTest.ShouldHaveCalled($"https://eun1.api.riotgames.com/lol/summoner/v4/summoners/by-name/{playerName}")
                .WithQueryParams("api_key")
                .WithVerb(HttpMethod.Get)
                .Times(1);

                httpTest.ShouldHaveCalled($"https://eun1.api.riotgames.com/lol/league/v4/entries/by-summoner/{player.Id}")
                .WithQueryParams("api_key")
                .WithVerb(HttpMethod.Get)
                .Times(1);

                Assert.Equal("Player got no division on any queue", result);
            }
        }
示例#5
0
        private async void General_Click(object sender, RoutedEventArgs e)
        {
            ChampionButton.Foreground = Brushes.MediumPurple;
            MatchButton.Foreground    = Brushes.MediumPurple;
            GeneralButton.Foreground  = Brushes.Purple;
            LiveButton.Foreground     = Brushes.MediumPurple;

            summoner_handler = new SummonerHandler(viewProfile.Region);
            SummonerDTO summoner = await summoner_handler.GetSummoner(viewProfile.SummonerName);

            if (summoner == null)
            {
                Console.WriteLine("Summoner was null...");
                Show_Notification(summoner_handler.ErrorMsg);
                return;
            }
            viewProfile.SummonerEntry   = summoner;
            viewProfile.ProfileIconPath = "http://ddragon.leagueoflegends.com/cdn/10.4.1/img/profileicon/" + (summoner.ProfileIconId).ToString() + ".png";

            league_entry_handler = new LeagueEntryHandler(viewProfile.Region);
            List <LeagueEntryDTO> league_entries = await league_entry_handler.GetLeagueEntry(summoner.Id);

            if (league_entry_handler.ErrorMsg != "")
            {
                Show_Notification(league_entry_handler.ErrorMsg);
                return;
            }
            if (league_entries == null)
            {
                Show_Notification("No league data to display");
                return;
            }
            LeagueEntryDTO league_entry = league_entries.Where(p => p.QueueType.Equals("RANKED_SOLO_5x5")).FirstOrDefault();

            if (league_entry == null)
            {
                league_entry              = new LeagueEntryDTO();
                league_entry.MiniSeries   = null;
                league_entry.HotStreak    = false;
                league_entry.FreshBlood   = false;
                league_entry.Veteran      = false;
                league_entry.Wins         = 0;
                league_entry.Losses       = 0;
                league_entry.Rank         = "";
                league_entry.Tier         = "Unranked";
                league_entry.LeaguePoints = 0;
                viewProfile.Winrate       = "0";
            }
            else
            {
                viewProfile.Winrate = (100 * league_entry.Wins / (league_entry.Losses + league_entry.Wins)).ToString();
            }

            viewProfile.LeagueEntry = league_entry;
            viewProfile.EmblemPath  = "pack://application:,,,/Assets/Emblem/Emblem_" + league_entry.Tier + ".png";

            champion_data_handler = new ChampionInfoHandler();
            ChampionInfo champData = await champion_data_handler.GetChampionData();

            viewProfile.FullChampionNames = champion_data_handler.ParseChampionData(champData.Data);

            MenuBar.Visibility = Visibility.Visible;
            Main.Content       = new General(viewProfile);
        }