public PlayerStatsPageViewModel GetPlayerStatSummary(string playerName, string serverName, int lastGameId) { PlayerStatsPageViewModel vm = new PlayerStatsPageViewModel { UserName = playerName, Server = serverName }; //Get player total summary first PlayerStatSummaryData summaryData = _playerStatDal.GetPlayerSummary(playerName, serverName); if (summaryData == null) { vm.HasFoundUser = false; return(vm); } vm.UserName = summaryData.PlayerName; vm.HasFoundUser = true; vm.Wins = summaryData.Win; vm.Losses = summaryData.Loss; vm.WLPercent = $"{(vm.Wins*1.0/(vm.Wins + vm.Losses)):0.0%}"; vm.LastPlayedDateTime = summaryData.LastGamePlayed; double avgPlayerKills = (summaryData.TotalPlayerKills * 1.0 / summaryData.TotalPlayerGameCount); double avgPlayerDeaths = (summaryData.TotalPlayerDeaths * 1.0 / summaryData.TotalPlayerGameCount); double avgPlayerAssists = (summaryData.TotalPlayerAssists * 1.0 / summaryData.TotalPlayerGameCount); vm.AveragePlayerKills = avgPlayerKills.ToString("0.0"); vm.AveragePlayerDeaths = avgPlayerDeaths.ToString("0.0"); vm.AveragePlayerAssists = avgPlayerAssists.ToString("0.0"); vm.AveragePlayerKDA = ((avgPlayerKills + avgPlayerAssists) / avgPlayerDeaths) .ToString("0.00"); //Get player hero summary List <PlayerHeroStatSummaryData> heroStatSummaryData = _playerStatDal.GetPlayerHeroSummary(summaryData.PlayerId); List <PlayerHeroStatsViewModel> vmHeroStats = new List <PlayerHeroStatsViewModel>(); foreach (PlayerHeroStatSummaryData heroSummary in heroStatSummaryData) { PlayerHeroStatsViewModel vmHero = new PlayerHeroStatsViewModel { HeroImageURL = ContentURL.GetHeroIconURL(heroSummary.HeroUnitTypeID), HeroName = heroSummary.HeroName, HeroWins = heroSummary.Wins, HeroLosses = heroSummary.Losses, HeroWLPercent = $"{(heroSummary.Wins*1.0/(heroSummary.Wins + heroSummary.Losses)):0.0%}" }; double avgHeroKills = (heroSummary.HeroTotalKills * 1.0 / heroSummary.HeroTotalPlayCount); double avgHeroDeaths = (heroSummary.HeroTotalDeaths * 1.0 / heroSummary.HeroTotalPlayCount); double avgHeroAssists = (heroSummary.HeroTotalAssists * 1.0 / heroSummary.HeroTotalPlayCount); vmHero.HeroAverageKills = avgHeroKills.ToString("0.0"); vmHero.HeroAverageDeaths = avgHeroDeaths.ToString("0.0"); vmHero.HeroAverageAssists = avgHeroAssists.ToString("0.0"); vmHero.HeroAverageKDA = ((avgHeroKills + avgHeroAssists) / avgHeroDeaths).ToString("0.00"); double heroKDA = ((avgHeroKills + avgHeroAssists) / avgHeroDeaths); vmHero.HeroAverageKDA = heroKDA.ToString("0.00"); vmHero.HeroKDAColor = CSSColorizer.GetKDAColor(heroKDA); vmHeroStats.Add(vmHero); } vm.PlayerHeroStatSummaryData = vmHeroStats; vm.PlayerGameSummaryData = GetPlayerGameSummary(summaryData.PlayerId, lastGameId, ""); vm.LastGameID = vm.PlayerGameSummaryData.Min(x => x.GameID); vm.SearchableServantData = _servantSearchDal.GetSearchableServants(); return(vm); }
public MainModule(IResourceLinker linker, GameSL gameSl, PlayerStatSL playerStatsSl, GhostCommSL ghostCommSl, StatisticsSL statisticsSl, GameDetailSL gameDetailSl, BanListSL banListSl) { Get["/"] = _ => { Context.EnableOutputCache(15); MainPageViewModel mpVm = new MainPageViewModel { CurrentBotTime = DateTime.Now, RecentGameDataList = gameSl.GetRecentGames(10) }; return(View["Views/MainPage.sshtml", mpVm]); }; Post["/Search"] = param => Response.AsRedirect($"/PlayerStats/USEast/{Request.Form.searchPlayerName}"); Get["/GameList"] = param => { Context.EnableOutputCache(10); return(View["Views/GameList.sshtml", ghostCommSl.GetGameList()]); }; Get["/About"] = Param => View["Views/About.sshtml"]; Get["/ServantStatistics"] = Param => { Context.EnableOutputCache(30); return(View["Views/ServantStatistics.sshtml", statisticsSl.GetServantStatistics()]); }; Get["/LeaderBoards"] = Param => { Context.EnableOutputCache(30); return(View["Views/LeaderBoards.sshtml"]); }; Get["/Downloads"] = Param => View["Views/Downloads.sshtml", ConfigHandler.MapName]; Get["/PlayerGameBuildDetail/{GameID}/{PlayerName}"] = param => { PlayerGameBuildViewModel vm = gameDetailSl.GetPlayerGameBuild(param.GameID, param.PlayerName); return(View["Views/PlayerGameBuildDetail.sshtml", vm]); }; Get["/Log"] = x => { string gameLog = gameSl.GetGameLog(Request.Query.gameId); return(View["Views/Log.sshtml", gameLog]); }; Get["/PlayerStats/{server}/{playerName}"] = param => { PlayerStatsPageViewModel summaryData = playerStatsSl.GetPlayerStatSummary(param.playerName, param.server, int.MaxValue); return(View["Views/PlayerStatsPage.sshtml", summaryData]); }; Get["/Maintenance"] = param => View["Views/Maintenance.sshtml"]; Get["/Login"] = param => View["Views/Login.sshtml", new LoginViewModel()]; Get["/BanList"] = param => { Context.EnableOutputCache(60); return(View["Views/BanList.sshtml", banListSl.GetBannedPlayers()]); }; }