Ejemplo n.º 1
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="propToValueMap"></param>
    /// <returns></returns>
    public static ParticipantIdentity DictionaryToParticipantIdentity(Dictionary <String, Object> propToValueMap)
    {
        ParticipantIdentity participantIdentity = new ParticipantIdentity();

        #region ParticipantId Property

        if (propToValueMap.ContainsKey(ParticipantIdentity.PropertyNames.ParticipantId) && propToValueMap[ParticipantIdentity.PropertyNames.ParticipantId] is int)
        {
            participantIdentity.ParticipantId = (int)propToValueMap[ParticipantIdentity.PropertyNames.ParticipantId];
        }

        #endregion

        #region Player Property

        if (propToValueMap.ContainsKey(ParticipantIdentity.PropertyNames.Player) && propToValueMap[ParticipantIdentity.PropertyNames.Player] is Dictionary <string, object> )
        {
            Dictionary <String, Object> participantIdentityPropValueMap = (Dictionary <String, Object>)propToValueMap[ParticipantIdentity.PropertyNames.Player];
            Player player = PlayerConverter.DictionaryToPlayer(participantIdentityPropValueMap);

            participantIdentity.Player = player;
        }

        #endregion

        return(participantIdentity);
    }
        private async Task <Db_LccCachedTeamInformation> CreateCachedTeamInformationFromRiotMatch(RiotSharp.Endpoints.MatchEndpoint.Match match, IEnumerable <Participant> teamParticipants, Timeline timeline, int teamId)
        {
            Db_LccCachedTeamInformation teamInformation = new Db_LccCachedTeamInformation
            {
                TotalKills      = teamParticipants.Sum(x => x.Stats.Kills),
                TotalDeaths     = teamParticipants.Sum(x => x.Stats.Kills),
                TotalAssists    = teamParticipants.Sum(x => x.Stats.Kills),
                DragonKills     = match.Teams.FirstOrDefault(x => x.TeamId == teamId).DragonKills,
                BaronKills      = match.Teams.FirstOrDefault(x => x.TeamId == teamId).BaronKills,
                RiftHeraldKills = match.Teams.FirstOrDefault(x => x.TeamId == teamId).RiftHeraldKills,
                InhibitorKills  = match.Teams.FirstOrDefault(x => x.TeamId == teamId).InhibitorKills
            };

            teamInformation.Players = new List <Db_LccCachedPlayerStats>();
            foreach (Participant participant in teamParticipants)
            {
                ParticipantIdentity participantIdentity = match.ParticipantIdentities.FirstOrDefault(x => x.ParticipantId == participant.ParticipantId);
                teamInformation.Players.Add(await
                                            CreateCachedPlayerStatsFromMatchupInfo
                                            (
                                                participantIdentity,
                                                participant,
                                                timeline
                                            )
                                            );
            }

            return(teamInformation);
        }
Ejemplo n.º 3
0
 public HelperParticipant(GameParticipant participant, ParticipantIdentity identity)
 {
     ParticipantId = participant.ParticipantId;
     ChampionId    = participant.ChampionId;
     Spell1Id      = participant.Spell1Id;
     Spell2Id      = participant.Spell2Id;
     Stats         = participant.Stats;
     Identity      = identity.Player;
 }
Ejemplo n.º 4
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="participantIdentity"></param>
    /// <returns></returns>
    public static Dictionary <String, Object> ParticipantIdentityToDictionary(ParticipantIdentity participantIdentity)
    {
        if (participantIdentity == null)
        {
            throw new ArgumentException("parameter player is required.");
        }

        Dictionary <String, Object> propToValueMap = new Dictionary <String, Object>();

        /*#region ??? Property
         *
         * //propToValueMap.Add( Player.PropertyNames.???, player.??? );
         *
         #endregion*/

        return(propToValueMap);
    }
Ejemplo n.º 5
0
 public ParticipantExtend(Participant participant, ParticipantIdentity participantIdentity)
 {
     Participant         = participant ?? throw new ArgumentNullException(nameof(participant));
     ParticipantIdentity = participantIdentity ?? throw new ArgumentNullException(nameof(participantIdentity));
 }
Ejemplo n.º 6
0
    /// <summary>
    /// Converts a ParticipantIdentity into a dictionary
    /// </summary>
    /// <param name="type">Optional - the type of the value parameter</param>
    /// <param name="value">Optional - the instance that is to be converted into a dictionary</param>
    /// <returns>A Dictionary containing the data contained in the value parameter</returns>
    public override Dictionary <String, Object> WriteJson(Type type, Object value)
    {
        ParticipantIdentity participantIdentity = (ParticipantIdentity)value;

        return(ParticipantIdentityToDictionary(participantIdentity));
    }
Ejemplo n.º 7
0
    /// <summary>
    ///
    /// </summary>
    /// <param name="propToValueMap"></param>
    /// <returns></returns>
    public static MatchDetail DictionaryToMatchDetail(Dictionary <String, Object> propToValueMap)
    {
        MatchDetail matchDetail = new MatchDetail();

        #region MapId Property

        if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.MapId) && propToValueMap[MatchDetail.PropertyNames.MapId] is int)
        {
            matchDetail.MapId = (int)propToValueMap[MatchDetail.PropertyNames.MapId];
        }

        #endregion

        #region MatchCreation Property

        if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.MatchCreation) && propToValueMap[MatchDetail.PropertyNames.MatchCreation] is long)
        {
            matchDetail.MatchCreation = (long)propToValueMap[MatchDetail.PropertyNames.MatchCreation];
        }

        #endregion

        #region MatchDuration Property

        if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.MatchDuration) && propToValueMap[MatchDetail.PropertyNames.MatchDuration] is int)
        {
            matchDetail.MatchDuration = (int)propToValueMap[MatchDetail.PropertyNames.MatchDuration];
        }

        else if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.MatchDuration) && propToValueMap[MatchDetail.PropertyNames.MatchDuration] is long)
        {
            matchDetail.MatchDuration = (long)propToValueMap[MatchDetail.PropertyNames.MatchDuration];
        }

        #endregion

        #region MatchId Property

        if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.MatchId) && propToValueMap[MatchDetail.PropertyNames.MatchId] is int)
        {
            matchDetail.MatchId = (int)propToValueMap[MatchDetail.PropertyNames.MatchId];
        }

        else if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.MatchId) && propToValueMap[MatchDetail.PropertyNames.MatchId] is long)
        {
            matchDetail.MatchId = (long)propToValueMap[MatchDetail.PropertyNames.MatchId];
        }

        #endregion

        #region MatchMode Property

        if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.MatchMode) && propToValueMap[MatchDetail.PropertyNames.MatchMode] is String)
        {
            matchDetail.MatchMode = (String)propToValueMap[MatchDetail.PropertyNames.MatchMode];
        }

        #endregion

        #region MatchType Property

        if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.MatchType) && propToValueMap[MatchDetail.PropertyNames.MatchType] is String)
        {
            matchDetail.MatchType = (String)propToValueMap[MatchDetail.PropertyNames.MatchType];
        }

        #endregion

        #region MatchVersion Property

        if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.MatchVersion) && propToValueMap[MatchDetail.PropertyNames.MatchVersion] is String)
        {
            matchDetail.MatchVersion = (String)propToValueMap[MatchDetail.PropertyNames.MatchVersion];
        }

        #endregion

        #region ParticipantIdentities Property !!!!!!!!!(Not yet implemented)!!!!!!!!!!!!!

        if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.ParticipantIdentities) && propToValueMap[MatchDetail.PropertyNames.ParticipantIdentities] is Dictionary <string, Object>[])
        {
            Dictionary <String, Object>[] participantIdentitiesPropValueMaps = (Dictionary <String, Object>[])propToValueMap[MatchDetail.PropertyNames.ParticipantIdentities];

            if (participantIdentitiesPropValueMaps.Length > 0)
            {
                ParticipantIdentity[] participantIdentities = new ParticipantIdentity[participantIdentitiesPropValueMaps.Length];

                for (int mapIndex = 0; mapIndex < participantIdentitiesPropValueMaps.Length; ++mapIndex)
                {
                    Dictionary <String, Object> participantIdentitiesPropValueMap = participantIdentitiesPropValueMaps[mapIndex];
                    ParticipantIdentity         participantIdentity = ParticipantIdentityConverter.DictionaryToParticipantIdentity(participantIdentitiesPropValueMap);
                    participantIdentities[mapIndex] = participantIdentity;
                }

                matchDetail.ParticipantIdentities = participantIdentities;
            }
        }

        #endregion

        #region Participants Property

        if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.Participants) && propToValueMap[MatchDetail.PropertyNames.Participants] is Dictionary <string, object>[])
        {
            Dictionary <String, Object>[] participantPropValueMaps = (Dictionary <String, Object>[])propToValueMap[MatchDetail.PropertyNames.Participants];

            if (participantPropValueMaps.Length > 0)
            {
                Participant[] participants = new Participant[participantPropValueMaps.Length];

                for (int mapIndex = 0; mapIndex < participantPropValueMaps.Length; ++mapIndex)
                {
                    Dictionary <String, Object> participantPropValueMap = participantPropValueMaps[mapIndex];
                    Participant participant = ParticipantConverter.DictionaryToParticipant(participantPropValueMap);
                    participants[mapIndex] = participant;
                }

                matchDetail.Participants = participants;
            }
        }

        #endregion

        #region PlatformId Property

        if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.PlatformId) && propToValueMap[MatchDetail.PropertyNames.PlatformId] is String)
        {
            matchDetail.PlatformId = (String)propToValueMap[MatchDetail.PropertyNames.PlatformId];
        }

        #endregion

        #region QueueType Property

        if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.QueueType) && propToValueMap[MatchDetail.PropertyNames.QueueType] is String)
        {
            matchDetail.QueueType = (String)propToValueMap[MatchDetail.PropertyNames.QueueType];
        }

        #endregion

        #region Region Property

        if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.Region) && propToValueMap[MatchDetail.PropertyNames.Region] is String)
        {
            matchDetail.Region = (String)propToValueMap[MatchDetail.PropertyNames.Region];
        }

        #endregion

        #region Season Property

        if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.Season) && propToValueMap[MatchDetail.PropertyNames.Season] is String)
        {
            matchDetail.Season = (String)propToValueMap[MatchDetail.PropertyNames.Season];
        }

        #endregion

        #region Teams Property !!!!!!!!!(Not Yet IMPLEMENTED)!!!!!!!!!!!!!!!!

        /* if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.Teams) && propToValueMap[MatchDetail.PropertyNames.Teams] is String)
         * {
         *  matchDetail.Teams = (String)propToValueMap[MatchDetail.PropertyNames.Teams];
         * }*/

        #endregion

        #region Timeline Property !!!!!!!!!(Not Yet IMPLEMENTED)!!!!!!!!!!!!!!!!

        /*if (propToValueMap.ContainsKey(MatchDetail.PropertyNames.Timeline) && propToValueMap[MatchDetail.PropertyNames.Timeline] is String)
         * {
         *  matchDetail.Timeline = (String)propToValueMap[MatchDetail.PropertyNames.Timeline];
         * }*/

        #endregion

        return(matchDetail);
    }
Ejemplo n.º 8
0
        private static ParticipantForDisplay SetParticipantForDisplay(Match match, Participant participant, ParticipantIdentity participantIdentity)
        {
            var pathBuilder    = new UrlPathBuilder();
            var summonerSpells = GetSummonerSpellsPaths(participant);
            var runes          = GetRunesPaths(participant);

            return(new ParticipantForDisplay()
            {
                ChampionIconUrl = pathBuilder.GetChampionIconUrl(participant.ChampionId),
                SummonerSpell1IconUrl = pathBuilder.GetSummonerSpellIcon(summonerSpells.Item1.Replace("/lol-game-data/assets/", "").ToLower()),
                SummonerSpell2IconUrl = pathBuilder.GetSummonerSpellIcon(summonerSpells.Item2.Replace("/lol-game-data/assets/", "").ToLower()),
                RuneKeystoneIconUrl = runes.Item1,
                RuneSecondaryPathIconUrl = runes.Item2,
                KillParticipationPercentage = GetKillParticipation(match, participant),
                Items = GetItems(participant),
                ChampionName = Champions.FirstOrDefault(x => x.Key == participant.ChampionId.ToString()) == null ? "Default" : Champions.FirstOrDefault(x => x.Key == participant.ChampionId.ToString()).Name,
                Participant = participant,
                ParticipantIdentity = participantIdentity
            });
        }
        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());
        }