/* * 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); }
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); }