Example #1
0
        public void CollectLeaguesByTier(string tier)
        {
            int leaguesFound   = 0;
            int summonersFound = 0;
            IEnumerable <LeagueEntity> leagues = dbHelper.GetLeaguesByTier(tier);

            foreach (LeagueEntity league in leagues)
            {
                LeagueList leagueList = new ApiRequest(requestStringHolder).League.Leagues(league.LeagueId);
                foreach (LeaguePosition leaguePosition in leagueList.entries)
                {
                    Summoner               summoner            = new ApiRequest(requestStringHolder).Summoner.SummonerByName(leaguePosition.playerOrTeamName);
                    IEnumerable <Match>    matches             = last10MatchesOrLess(summoner.accountId);
                    IEnumerable <Summoner> summonerFromMatches = getSummonersFromMatches(matches);
                    foreach (Summoner sum in summonerFromMatches)
                    {
                        LeaguePosition foundPosition = getSoloQLeaguePosition(sum.id);
                        if (foundPosition != null)
                        {
                            if (dbHelper.SubmitLeagueIfNotDuplicate(EntityFromRiotDto.GetLeague(foundPosition)))
                            {
                                leaguesFound++;
                            }
                            summonersFound++;
                        }
                        Console.Clear();
                        Console.WriteLine($"{summonersFound} Summoners Found : {leaguesFound} New Leagues Found");
                    }
                }
            }
        }
Example #2
0
        public ActionResult TeamSelections(TeamSelectionsViewModel model)
        {
            if (!ModelState.IsValid)
            {
                return(View(model));
            }

            //get league positions
            var selections = new List <LeaguePosition>();
            var properties = AttributeHelper.GetPropertiesWithAttribute <TeamSelectionsViewModel, LeaguePositionAttribute>();

            foreach (var prop in properties)
            {
                var lp     = new LeaguePosition();
                var attr   = AttributeHelper.GetAttributes <TeamSelectionsViewModel, LeaguePositionAttribute>(prop);
                var league = attr.League;
                lp.Team     = AttributeHelper.GetPropertyValue <TeamSelectionsViewModel>(model, prop);
                lp.Position = attr.Position;
                selections.Add(lp);
            }

            var email = User.Identity.GetUserName();

            using (var db = new leaguepredictorEntities())
            {
                var player = db.players.Where(p => p.email.Equals(email)).SingleOrDefault();
                if (player == null)
                {
                    player = new player {
                        email = email, name = model.Name
                    };
                    db.players.Add(player);
                    db.SaveChanges();
                }
                else
                {
                    //remove previous selections
                    foreach (var ps in player.players_selections.ToList())
                    {
                        db.players_selections.Remove(ps);
                    }
                }

                foreach (var sel in selections)
                {
                    var team = db.teams.Where(t => t.team_name == sel.Team).Single();
                    player.players_selections.Add(new players_selections
                    {
                        team     = team,
                        position = sel.Position
                    });
                }

                db.SaveChanges();
            }

            return(View(model));
        }
Example #3
0
        public static LeagueEntity GetLeague(LeaguePosition leaguePosition)
        {
            LeagueEntity result = new LeagueEntity();

            result.LeagueId = leaguePosition.leagueId;
            result.Name     = leaguePosition.leagueName;
            result.Queue    = leaguePosition.queueType;
            result.Tier     = leaguePosition.tier;
            return(result);
        }
Example #4
0
        private LeaguePosition getSoloQLeaguePosition(string summonerId)
        {
            IEnumerable <LeaguePosition> leaguePositions = new ApiRequest(requestStringHolder).League.LeaguePositions(summonerId);

            if (leaguePositions == null)
            {
                return(null);
            }
            LeaguePosition leaguePosition = leaguePositions.Where(x => x.queueType == "RANKED_SOLO_5x5").FirstOrDefault();

            return(leaguePosition);
        }
Example #5
0
        private string QueueFormat(LeaguePosition league)
        {
            switch (league.QueueType)
            {
            case "RANKED_SOLO_5x5":
                return("5v5 Solo/Duo");

            case "RANKED_FLEX_SR":
                return("5v5 Flex");

            default:
                return(league.QueueType);
            }
        }
        private async Task <Db_LccCachedPlayerStats> CreateCachedPlayerStatsFromMatchupInfo(ParticipantIdentity participantIdentity, Participant participant, Timeline timeline)
        {
            try
            {
                List <LeaguePosition> leaguePosition = await _riotApi.League.GetLeaguePositionsAsync(Region.euw, participantIdentity.Player.SummonerId);

                LeaguePosition rankedSoloLeague = leaguePosition.FirstOrDefault(x => x.QueueType == LeagueQueue.RankedSolo);

                return(new Db_LccCachedPlayerStats()
                {
                    SummonerId = participantIdentity.Player.SummonerId,
                    SummonerName = participantIdentity.Player.SummonerName,
                    Kills = participant.Stats.Kills,
                    Deaths = participant.Stats.Deaths,
                    Assists = participant.Stats.Assists,
                    MinionKills = participant.Stats.NeutralMinionsKilled + participant.Stats.TotalMinionsKilled,
                    RankedSoloDivision = rankedSoloLeague?.Rank,
                    RankedSoloTier = rankedSoloLeague?.Tier,
                    RankedSoloLeaguePoints = rankedSoloLeague?.LeaguePoints.ToString(),
                    RankedSoloWins = rankedSoloLeague.Wins,
                    RankedSoloLosses = rankedSoloLeague.Losses,
                    ItemOne = CreateCachedItemInformation(Convert.ToInt32(participant.Stats.Item0)),
                    ItemTwo = CreateCachedItemInformation(Convert.ToInt32(participant.Stats.Item1)),
                    ItemThree = CreateCachedItemInformation(Convert.ToInt32(participant.Stats.Item2)),
                    ItemFour = CreateCachedItemInformation(Convert.ToInt32(participant.Stats.Item3)),
                    ItemFive = CreateCachedItemInformation(Convert.ToInt32(participant.Stats.Item4)),
                    ItemSix = CreateCachedItemInformation(Convert.ToInt32(participant.Stats.Item5)),
                    Trinket = CreateCachedItemInformation(Convert.ToInt32(participant.Stats.Item6)),
                    SummonerOne = CreateCachedSummonerSpellInformation(participant.Spell1Id),
                    SummonerTwo = CreateCachedSummonerSpellInformation(participant.Spell2Id),
                    Champion = CreateCachedChampionInformation(participant.ChampionId),
                    ChampionLevel = participant.Stats.ChampLevel,
                    PrimaryRuneStyle = CreateCachedRuneInformation(Convert.ToInt32(participant.Stats.PerkPrimaryStyle)),
                    PrimaryRuneSubOne = CreateCachedRuneInformation(Convert.ToInt32(participant.Stats.Perk0)),
                    PrimaryRuneSubTwo = CreateCachedRuneInformation(Convert.ToInt32(participant.Stats.Perk1)),
                    PrimaryRuneSubThree = CreateCachedRuneInformation(Convert.ToInt32(participant.Stats.Perk2)),
                    PrimaryRuneSubFour = CreateCachedRuneInformation(Convert.ToInt32(participant.Stats.Perk3)),
                    SecondaryRuneStyle = CreateCachedRuneInformation(Convert.ToInt32(participant.Stats.PerkSubStyle)),
                    SecondaryRuneSubOne = CreateCachedRuneInformation(Convert.ToInt32(participant.Stats.Perk4)),
                    SecondaryRuneSubTwo = CreateCachedRuneInformation(Convert.ToInt32(participant.Stats.Perk5)),
                    Timeline = CreateMatchTimelineForParticipantFromRiotTimeline(timeline, participant.ParticipantId)
                });
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception thrown creating cahcedPlayerStatsFromMatchInfo : " + e.Message);
            }

            return(new Db_LccCachedPlayerStats());
        }
        public async Task <JsonResult> GetSummonerByName(string summonerName)
        {
            Summoner summoner = await _riotApi.Summoner.GetSummonerByNameAsync(RiotSharp.Misc.Region.euw, summonerName);

            List <LeaguePosition> leaguePositions = await _riotApi.League.GetLeaguePositionsAsync(RiotSharp.Misc.Region.euw, summoner.Id);

            LeaguePosition rankedSolo = leaguePositions.FirstOrDefault(x => x.QueueType == LeagueQueue.RankedSolo);

            LccSummoner lccSummoner = new LccSummoner()
            {
                SummonerName           = summoner.Name,
                SummonerLevel          = summoner.Level,
                RankedSoloWins         = rankedSolo.Wins,
                RankedSoloLosses       = rankedSolo.Losses,
                RankedSoloDivision     = rankedSolo.Rank,
                RankedSoloLeaguePoints = rankedSolo.LeaguePoints.ToString(),
                RankedSoloTier         = rankedSolo.Tier
            };

            return(new JsonResult(lccSummoner));
        }
Example #8
0
        //collect league information from summonerEntities.
        public void CollectLeagueNames(IEnumerable <SummonerEntity> summonerEntities)
        {
            int summonersQueried = 0;
            int leaguesFound     = 0;

            foreach (SummonerEntity summoner in summonerEntities)
            {
                IEnumerable <LeaguePosition> leaguesList = new ApiRequest(requestStringHolder).League.LeaguePositions(summoner.SummonerId);
                if (leaguesList != null)
                {
                    IEnumerable <LeaguePosition> soloQLeague = leaguesList.Where(x => x.queueType == "RANKED_SOLO_5x5");
                    LeaguePosition leaguePos = soloQLeague.FirstOrDefault();
                    LeagueEntity   league    = EntityFromRiotDto.GetLeague(leaguePos);
                    if (league != null && dbHelper.SubmitLeagueIfNotDuplicate(league))
                    {
                        leaguesFound++;
                    }
                }
                summonersQueried++;
                Console.Clear();
                Console.WriteLine($"{summonersQueried} Summoners From {leaguesFound} Leagues");
            }
        }
Example #9
0
 /// <summary>
 /// Formats a league position into a string that displays the rank and tier in a readable format
 /// </summary>
 /// <param name="league">League object to input</param>
 /// <returns>Rank and tier in readable form</returns>
 private string RankFormat(LeaguePosition league)
 {
     return(league.Tier[0] + league.Tier.Substring(1).ToLower() + " " + league.Rank);       // rank always appears in uppercase, so lower every char except the first
 }