Esempio n. 1
0
        private void SetRankingInformation(string region, LeagueSummoner summoner, SummonerDTO summonerDto)
        {
            IEnumerable<LeagueDTO> leagueDtos = _leagueRequestService.GetLeagues(region, 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;
            }
        }
Esempio n. 2
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;
            }
        }
Esempio n. 3
0
        public void Under_Level_30_Should_Return_250_Rating()
        {
            LeagueSummoner summoner = new LeagueSummoner()
            {
                Level = 25
            };

            int rating = _balancingService.GetRating(summoner);

            rating.Should().Be(250);
        }
Esempio n. 4
0
        public LeagueSummoner GetSummoner(string region, string summonerName)
        {
            SummonerDTO summonerDto = _leagueRequestService.GetSummoner(region ,summonerName);

            LeagueSummoner summoner = new LeagueSummoner()
            {
                Id = summonerDto.Id,
                Name = summonerDto.Name,
                Level = summonerDto.SummonerLevel
            };

            SetRankingInformation(region, summoner, summonerDto);

            return summoner;
        }
Esempio n. 5
0
        public LeagueSummoner GetSummoner(string summonerName)
        {
            SummonerDTO summonerDto = _leagueRequestService.GetSummoner(summonerName);

            LeagueSummoner summoner = new LeagueSummoner()
            {
                Id    = summonerDto.Id,
                Name  = summonerDto.Name,
                Level = summonerDto.SummonerLevel
            };

            SetRankingInformation(summoner, summonerDto);

            return(summoner);
        }
Esempio n. 6
0
        public LeagueSummoner GetSummoner(string summonerName)
        {
            SummonerDTO summonerDto = _leagueRequestService.GetSummoner(summonerName);

            LeagueSummoner summoner = new LeagueSummoner()
            {
                Name = summonerDto.Name,
                Level = summonerDto.SummonerLevel
            };

            ICollection<LeagueDTO> leagueDtos = _leagueRequestService.GetLeagues(summonerDto.Id);

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

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

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

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

                summoner.Division = entryDto.Division;
                summoner.LeaguePoints = entryDto.LeaguePoints;
            }

            return summoner;
        }
Esempio n. 7
0
        private LeagueSummoner GetSummonerHelper(string tier, string division, int lp)
        {
            LeagueSummoner summoner = new LeagueSummoner
            {
                Tier = tier,
                Division = division,
                LeaguePoints = lp,
                Level = 30
            };

            return summoner;
        }
Esempio n. 8
0
        public int GetRating(LeagueSummoner summoner)
        {
            if (summoner.Level < 30)
            {
                return 250;
            }

            int rating;

            switch (summoner.Tier)
            {
                case "Bronze":
                    rating = 0;
                    break;
                case "Silver":
                case "Unranked":
                    rating = 500;
                    break;
                case "Gold":
                    rating = 1000;
                    break;
                case "Platinum":
                    rating = 1500;
                    break;
                case "Diamond":
                    rating = 2000;
                    break;
                case "Master":
                    rating = 2500;
                    break;
                case "Challenger":
                    rating = 2500;
                    break;
                default:
                    throw new InvalidOperationException("Unsupported Ranked Tier");
            }

            switch (summoner.Division)
            {
                case "V":
                case "":
                    rating += 0;
                    break;
                case "IV":
                    rating += 100;
                    break;
                case "III":
                    rating += 200;
                    break;
                case "II":
                    rating += 300;
                    break;
                case "I":
                    rating += 400;
                    break;
                default:
                    throw new InvalidOperationException("Unsupported Ranked Division");
            }

            rating += summoner.LeaguePoints;

            return rating;
        }