Esempio n. 1
0
        public List <ServantStatisticsViewModel> GetServantStatistics()
        {
            List <ServantStatisticsData>      statisticsData = _statisticsDal.GetServantStatistics();
            List <ServantStatisticsViewModel> vm             = new List <ServantStatisticsViewModel>();

            foreach (ServantStatisticsData data in statisticsData)
            {
                ServantStatisticsViewModel vmInner = new ServantStatisticsViewModel
                {
                    HeroTypeId       = $"{data.HeroTypeId}",
                    HeroImageURL     = ContentURL.GetHeroIconURL(data.HeroUnitTypeID),
                    AvgDamageDealt   = $"{data.AvgDamageDealt:n0}",
                    AvgDamageTaken   = $"{data.AvgDamageTaken:n0}",
                    AvgGoldSpent     = $"{data.AvgGoldSpent:n0}",
                    HeroName         = data.HeroName,
                    HeroTitle        = data.HeroTitle,
                    PlayCount        = data.WinCount + data.LossCount,
                    WinRatioVal      = data.WinCount * 1.0 / (data.WinCount + data.LossCount),
                    ProgressBarColor = data.WinCount < data.LossCount || data.WinCount == 0 ? "progressbar red" : "progressbar blue",
                    AvgKDA           = ((data.AvgKills + data.AvgAssists) / data.AvgDeaths).ToString("0.00")
                };
                vmInner.WinRatio = $"{vmInner.WinRatioVal:0.0%}";
                vm.Add(vmInner);
            }
            vm = vm.OrderByDescending(x => x.WinRatioVal).ThenByDescending(y => y.PlayCount).ToList();
            return(vm);
        }
Esempio n. 2
0
        private List <PlayerGameSummaryViewModel> GetPlayerGameSummary(int playerId, int lastGameId, string heroUnitTypeId)
        {
            //Get player game summary
            List <PlayerGameSummaryData>      playerGameSummaryData = _playerStatDal.GetPlayerGameSummaryData(playerId, lastGameId, heroUnitTypeId);
            List <PlayerGameSummaryViewModel> vmGameSummary         = new List <PlayerGameSummaryViewModel>();

            foreach (PlayerGameSummaryData gameSummary in playerGameSummaryData)
            {
                PlayerGameSummaryViewModel vmGame = new PlayerGameSummaryViewModel
                {
                    GameID      = gameSummary.GameID,
                    PlayedDate  = gameSummary.PlayedDate.ToShortDateString(),
                    GoldSpent   = $"{gameSummary.GoldSpent:n0}",
                    GameResult  = gameSummary.GameResult,
                    HeroKills   = gameSummary.HeroKills,
                    HeroDeaths  = gameSummary.HeroDeaths,
                    HeroAssists = gameSummary.HeroAssists,
                    HeroLevel   = gameSummary.HeroLevel,
                    DamageDealt = $"{((int)gameSummary.DamageDealt):n0}",
                    DamageTaken = $"{((int)gameSummary.DamageTaken):n0}",

                    HeroImageURL = ContentURL.GetHeroIconURL(gameSummary.HeroUnitTypeID),
                };

                double heroKDA =
                    (gameSummary.HeroKills * 1.0 + gameSummary.HeroAssists) / gameSummary.HeroDeaths;
                vmGame.HeroKDA      = heroKDA.ToString("0.00");
                vmGame.HeroKDAColor = CSSColorizer.GetKDAColor(heroKDA);

                //Flip the wins if player is in team 2
                if (gameSummary.Team == "2")
                {
                    vmGame.TeamOneWinCount = gameSummary.TeamTwoWinCount;
                    vmGame.TeamTwoWinCount = gameSummary.TeamOneWinCount;
                }
                else
                {
                    vmGame.TeamOneWinCount = gameSummary.TeamOneWinCount;
                    vmGame.TeamTwoWinCount = gameSummary.TeamTwoWinCount;
                }
                foreach (PlayerGameTeamPlayerData gameTeamPlayerData in gameSummary.TeamList)
                {
                    gameTeamPlayerData.HeroImageURL = ContentURL.GetHeroIconURL(gameTeamPlayerData.HeroUnitTypeID);
                    if (gameTeamPlayerData.Team == "1")
                    {
                        vmGame.Team1List.Add(gameTeamPlayerData);
                    }
                    else
                    {
                        vmGame.Team2List.Add(gameTeamPlayerData);
                    }
                }
                vmGameSummary.Add(vmGame);
            }
            return(vmGameSummary);
        }
Esempio n. 3
0
 private void PopulateImageURL(GamePlayerDetailData data)
 {
     data.HeroImageURL         = ContentURL.GetHeroIconURL(data.HeroUnitTypeID);
     data.GodsHelpImageURLList = new List <string>();
     foreach (string url in data.GodsHelpAbilIDList.Where(x => !String.IsNullOrEmpty(x))
              .Select(ContentURL.GetGodsHelpIconURL)
              .Where(url => !String.IsNullOrEmpty(url)))
     {
         data.GodsHelpImageURLList.Add(url);
     }
 }
Esempio n. 4
0
        public PlayerGameBuildViewModel GetPlayerGameBuild(int gameId, string playerName)
        {
            PlayerGameBuildViewModel vm   = new PlayerGameBuildViewModel();
            PlayerGameBuildData      data = _detailDal.GetPlayerGameBuildDetail(playerName, gameId);

            //TO DO: Is there any cleaner way of doing this?
            vm.PlayerName       = playerName;
            vm.HeroIconURL      = ContentURL.GetHeroIconURL(data.HeroUnitTypeId);
            vm.Strength         = data.StatBuildDic.GetValueOrDefault("A02W");
            vm.Agility          = data.StatBuildDic.GetValueOrDefault("A03D");
            vm.Intelligence     = data.StatBuildDic.GetValueOrDefault("A03E");
            vm.Attack           = data.StatBuildDic.GetValueOrDefault("A03W");
            vm.Armor            = data.StatBuildDic.GetValueOrDefault("A03X");
            vm.HealthRegen      = data.StatBuildDic.GetValueOrDefault("A03Y");
            vm.ManaRegen        = data.StatBuildDic.GetValueOrDefault("A03Z");
            vm.MoveSpeed        = data.StatBuildDic.GetValueOrDefault("A04Y");
            vm.GoldRegen        = data.StatBuildDic.GetValueOrDefault("A0A9");
            vm.PrelatiMana      = data.StatBuildDic.GetValueOrDefault("A0CJ");
            vm.WardCount       += data.PurchasedItemsDic.GetValueOrDefault("I003");
            vm.WardCount       += data.PurchasedItemsDic.GetValueOrDefault("I00N");
            vm.WardCount       += data.PurchasedItemsDic.GetValueOrDefault("SWAR");
            vm.FamiliarCount   += data.PurchasedItemsDic.GetValueOrDefault("I002");
            vm.FamiliarCount   += data.PurchasedItemsDic.GetValueOrDefault("I005");
            vm.SpiritLinkCount += data.PurchasedItemsDic.GetValueOrDefault("I00G");
            vm.SpiritLinkCount += data.PurchasedItemsDic.GetValueOrDefault("I00R");
            vm.FirstCS          = data.CommandSealDic.GetValueOrDefault("A094");
            vm.SecondCS         = data.CommandSealDic.GetValueOrDefault("A043");
            vm.ThirdCS          = data.CommandSealDic.GetValueOrDefault("A044");
            vm.FourthCS         = data.CommandSealDic.GetValueOrDefault("A05Q");

            vm.AttributeList = new List <PlayerGameBuildAttribute>();
            foreach (Tuple <string, string> attributeData in data.LearnedAttributeList)
            {
                PlayerGameBuildAttribute attr = new PlayerGameBuildAttribute
                {
                    AttributeImgUrl = ContentURL.GetAttributeIconURL(attributeData.Item1),
                    AttributeName   = attributeData.Item2
                };
                vm.AttributeList.Add(attr);
            }
            return(vm);
        }
Esempio n. 5
0
        private void SetPlayerFateGameInfo(GameListProgressData gameProgressData)
        {
            if (gameProgressData.FRSEventList == null)
            {
                return;
            }
            List <string> servantSelections = gameProgressData.FRSEventList.Where(x => x.StartsWith("SS")).ToList();

            gameProgressData.Team1DataList = new List <GameListPlayerData>();
            gameProgressData.Team2DataList = new List <GameListPlayerData>();
            foreach (string s in servantSelections)
            {
                string[] splitStr       = s.Split('/');
                string   playerName     = splitStr[1];
                int      slotNum        = int.Parse(splitStr[2]);
                string   heroUnitTypeId = splitStr[3];
                int      teamNum        = int.Parse(splitStr[4]);

                if (teamNum <= 0)
                {
                    continue;
                }

                GameListPlayerData gpd =
                    gameProgressData.PlayerDataList.FirstOrDefault(x => string.Equals(x.PlayerName, playerName, StringComparison.InvariantCultureIgnoreCase));

                if (gpd == null)
                {
                    gpd = new GameListPlayerData
                    {
                        PlayerName = playerName,
                        Ping       = "0"
                    };
                }
                gpd.SlotNumber  = slotNum;
                gpd.HeroIconURL = ContentURL.GetHeroIconURL(heroUnitTypeId);
                gpd.TeamNumber  = teamNum;

                GameListKDAData kdaData = gameProgressData.PlayerKills?.FirstOrDefault(x => x.PlayerID == gpd.SlotNumber);
                if (kdaData != null)
                {
                    gpd.Kills = kdaData.Kills;
                }

                GameListKDAData deathsData = gameProgressData.PlayerDeaths?.FirstOrDefault(x => x.PlayerID == gpd.SlotNumber);
                if (deathsData != null)
                {
                    gpd.Deaths = deathsData.Deaths;
                }

                GameListKDAData assistsData = gameProgressData.PlayerAssists?.FirstOrDefault(x => x.PlayerID == gpd.SlotNumber);
                if (assistsData != null)
                {
                    gpd.Assists = assistsData.Assists;
                }

                switch (gpd.TeamNumber)
                {
                case 1:
                    gameProgressData.Team1DataList.Add(gpd);
                    break;

                case 2:
                    gameProgressData.Team2DataList.Add(gpd);
                    break;
                }
            }

            List <string> roundVictories =
                gameProgressData.FRSEventList.Where(x => x.StartsWith("RoundVictory")).ToList();

            gameProgressData.Team1Wins = roundVictories.Count(x => x.Contains("T1"));
            gameProgressData.Team2Wins = roundVictories.Count(x => x.Contains("T2"));
        }
Esempio n. 6
0
        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);
        }