コード例 #1
0
        /*
         * gamesFed
         * gamesCarried
         * gamesGotCarried
         */
        public PlayerInformationDto Get(string summonerName, string region)
        {
            DamageService damageService = new DamageService();
            SummonerDto   summoner      = new Summoner().GetByName(summonerName, region);

            if (summoner == null)
            {
                return(null);
            }

            MatchlistDto matchesHistory = new Matches().Get(summoner.accountId, region);

            if (matchesHistory == null)
            {
                return(null);
            }

            var detailedGames = Retrieve.DetailedGames(matchesHistory.matches, region);

            var playerSummary = new PlayerInformationDto
            {
                name                   = summoner.name,
                lanesPlayedCount       = new LanesService().ComputeLanesPlayedCount(matchesHistory.matches),
                playerScores           = new ScoreService().ComputePlayerScore(detailedGames, summoner.accountId),
                gamesSummary           = new GamesSummaryService().ComputeGamesSummary(detailedGames, summoner.accountId),
                damageDealt            = damageService.ComputeAverageDamageDealtByPlayer(detailedGames, summoner.accountId),
                damageDealtByTeammates = damageService.ComputeDamageDealtByTeam(detailedGames, summoner.accountId, true),
                damageDealtByEnemies   = damageService.ComputeDamageDealtByTeam(detailedGames, summoner.accountId, false)
            };

            return(playerSummary);
        }
コード例 #2
0
        public GamesSummary ComputeGamesSummary(List <MatchDto> matchHistory, long accountId)
        {
            GamesSummary gamesSummary  = new GamesSummary();
            DamageDealt  byPlayer      = new DamageDealt();
            DamageDealt  highestInTeam = new DamageDealt();
            PlayerScores playerScores  = new PlayerScores();

            ScoreService scoreService = new ScoreService();

            DamageService damageService = new DamageService();

            matchHistory.ForEach(delegate(MatchDto match)
            {
                int participantId = Retrieve.ParticipantIdForCurrentMatch(match.participantsIdentities, accountId);
                int teamId        = Retrieve.PlayerTeamId(match.participants, participantId);

                Boolean hasWon = HasWon(match.participants, participantId);

                playerScores.ReplaceScores(scoreService.GetPlayerScoresForCurrentMatch(match.participants, participantId));

                byPlayer.ReplaceDamage(damageService.ComputeDamageDealtByPlayer(match.participants, participantId));
                highestInTeam.ReplaceDamage(damageService.GetHighestDamageDealerInTeam(match.participants, teamId, participantId));
                gamesSummary.Add(
                    HasCarried(byPlayer, highestInTeam, hasWon) ? 1 : 0,
                    HasFed(playerScores) ? 1 : 0,
                    HasGottenCarried(playerScores, byPlayer, highestInTeam, hasWon) ? 1 : 0
                    );
            });

            return(gamesSummary);
        }
コード例 #3
0
        private double ComputeAverageCreepsCount(List <MatchDto> matches, long accountId)
        {
            double averageCsCount = 0;

            matches.ForEach(delegate(MatchDto match)
            {
                int participantId = Retrieve.ParticipantIdForCurrentMatch(match.participantsIdentities, accountId);
                averageCsCount   += GetCsForCurrentMatch(match.participants, participantId);
            });

            return(Math.Round(averageCsCount / matches.Count, 2));
        }
コード例 #4
0
        private PlayerScores ComputePlayerKDA(List <MatchDto> matches, long accountId)
        {
            PlayerScores playerScores = new PlayerScores();

            matches.ForEach(delegate(MatchDto match)
            {
                int participantId = Retrieve.ParticipantIdForCurrentMatch(match.participantsIdentities, accountId);

                playerScores.AddScores(GetPlayerScoresForCurrentMatch(match.participants, participantId));
            });

            playerScores.NormalizeScores(matches.Count);

            return(playerScores);
        }
コード例 #5
0
        public DamageDealt ComputeAverageDamageDealtByPlayer(List <MatchDto> matches, long accountId)
        {
            DamageDealt dmgDealtByPlayer = new DamageDealt();
            int         totalGames       = matches.Count;

            matches.ForEach(delegate(MatchDto match)
            {
                int playerParticipantId = Retrieve.ParticipantIdForCurrentMatch(match.participantsIdentities, accountId);

                dmgDealtByPlayer.Add(ComputeDamageDealtByPlayer(match.participants, playerParticipantId));
            });

            dmgDealtByPlayer.Normalize(matches.Count);

            return(dmgDealtByPlayer);
        }
コード例 #6
0
        public DamageDealt ComputeDamageDealtByTeam(List <MatchDto> matches, long accountId, Boolean isPlayerTeam)
        {
            DamageDealt dmgDealtByTeam = new DamageDealt();

            matches.ForEach(delegate(MatchDto match)
            {
                int playerParticipantId = Retrieve.ParticipantIdForCurrentMatch(match.participantsIdentities, accountId);

                int playerTeamId = Retrieve.PlayerTeamId(match.participants, playerParticipantId);

                dmgDealtByTeam.Add(ComputeDamageDealtByTeam(match.participants, playerTeamId, playerParticipantId));
            });

            dmgDealtByTeam.Normalize(matches.Count * (isPlayerTeam ? 4 : 5));

            return(dmgDealtByTeam);
        }