示例#1
0
        private MatchDetailsModel AddChampionDetails(MatchDetailsModel m, List <ChampionModel> champions)
        {
            var c = champions.Where(x => x.PaladinsChampionId == m.PaladinsChampionId).FirstOrDefault();

            m.ChampionIconUrl = c.ChampionIconUrl.AbsoluteUri;
            m.ChampionName    = c.Name;
            return(m);
        }
示例#2
0
 public ActionResult Index()
 {
     if (TempData["userData"] == null)
     {
         ViewBag.ShowList = false;
         return(View());
     }
     else
     {
         MatchDetailsModel lst = (MatchDetailsModel)TempData["userData"];
         ViewBag.ShowList = true;
         return(View(lst));
     }
 }
示例#3
0
        public ActionResult About()
        {
            //ViewBag.Message = "About the author: https://github.com/apatel-gpsw";

            //return View();
            if (TempData["userData"] == null)
            {
                ViewBag.ShowList = false;
                return(View());
            }
            else
            {
                MatchDetailsModel lst = (MatchDetailsModel)TempData["userData"];
                ViewBag.ShowList = true;
                return(View(lst));
            }
        }
示例#4
0
        /// <summary>
        /// Gets match details for a single match, this includes player builds and details. Requires "MatchClass".
        /// </summary>
        public static MatchDetailsModel GetMatchDetail(long matchid)
        {
            string response = DownloadSteamAPIString(MATCHDETAILSURL, API + "&match_id=" + matchid);

            var detail = JsonConvert.DeserializeObject <MatchDetailsRootObject>(response);
            MatchDetailsModel match = detail.Result;

            #region MetaData

            if (LobbyType.TryGetValue(match.Lobby_Type, out string lobby))
            {
                match.Lobbytype = lobby;
            }

            if (GameModes.TryGetValue(match.Game_Mode, out string mode))
            {
                match.Game_ModeStr = mode;
            }

            match.StartTime = StringManipulation.UnixTimeStampToDateTime(match.Start_Time);
            string playedTimeAgo = "";

            if ((DateTime.Now - match.StartTime).TotalDays < 1)
            {
                playedTimeAgo = Math.Ceiling((DateTime.Now - match.StartTime).TotalHours).ToString() + " hours ago";
            }
            else
            {
                playedTimeAgo = Math.Ceiling((DateTime.Now - match.StartTime).TotalDays).ToString() + " days ago";
            }

            match.PlayedTimeAgo = playedTimeAgo;

            TimeSpan timeToConvert = TimeSpan.FromSeconds(match.Duration);
            match.DurationStr = timeToConvert.ToString(@"mm\:ss");

            timeToConvert             = TimeSpan.FromSeconds(match.First_Blood_Time);
            match.First_Blood_TimeStr = timeToConvert.ToString(@"mm\:ss");

            timeToConvert       = TimeSpan.FromSeconds(match.Start_Time);
            match.Start_TimeStr = match.StartTime.ToString(@"dd MMM yyyy HH\:mm\:ss");

            #endregion

            #region PlayerInfo

            foreach (var player in match.Players)
            {
                player.Name      = ConvertIDtoName(player.Hero_ID, Heroes);
                player.HeroImage = ConvertIDtoImageUrl(player.Hero_ID, Heroes);
                player.Steamid64 = StringManipulation.SteamIDConverter(player.Account_ID);
                player.Steamid32 = StringManipulation.SteamIDConverter64to32(player.Steamid64);

                SteamAccountPlayerModel steamaccount = GetSteamAccount(player.Account_ID);
                player.PlayerName = string.IsNullOrEmpty(steamaccount.PersonaName) ? "Anonymous" : steamaccount.PersonaName;

                player.Tower_Damage = player.Tower_Damage == 0 ? 0 : player.Tower_Damage;

                // getting item names based on the id number
                player.Item0      = player.Item_0 > 0 ? ConvertIDtoName(player.Item_0, Items) : null;
                player.Item0Image = player.Item_0 > 0 ? ConvertIDtoImageUrl(player.Item_0, Items) : BLANKIMG;

                player.Item1      = player.Item_1 > 0 ? ConvertIDtoName(player.Item_1, Items) : null;
                player.Item1Image = player.Item_1 > 0 ? ConvertIDtoImageUrl(player.Item_1, Items) : BLANKIMG;

                player.Item2      = player.Item_2 > 0 ? ConvertIDtoName(player.Item_2, Items) : null;
                player.Item2Image = player.Item_2 > 0 ? ConvertIDtoImageUrl(player.Item_2, Items) : BLANKIMG;

                player.Item3      = player.Item_3 > 0 ? ConvertIDtoName(player.Item_3, Items) : null;
                player.Item3Image = player.Item_3 > 0 ? ConvertIDtoImageUrl(player.Item_3, Items) : BLANKIMG;

                player.Item4      = player.Item_4 > 0 ? ConvertIDtoName(player.Item_4, Items) : null;
                player.Item4Image = player.Item_4 > 0 ? ConvertIDtoImageUrl(player.Item_4, Items) : BLANKIMG;

                player.Item5      = player.Item_5 > 0 ? ConvertIDtoName(player.Item_5, Items) : null;
                player.Item5Image = player.Item_5 > 0 ? ConvertIDtoImageUrl(player.Item_5, Items) : BLANKIMG;

                player.Backpack0      = player.Backpack_0 > 0 ? ConvertIDtoName(player.Backpack_0, Items) : null;
                player.Backpack0Image = player.Backpack_0 > 0 ? ConvertIDtoImageUrl(player.Backpack_0, Items) : BLANKIMG;

                player.Backpack1      = player.Backpack_1 > 0 ? ConvertIDtoName(player.Backpack_1, Items) : null;
                player.Backpack1Image = player.Backpack_1 > 0 ? ConvertIDtoImageUrl(player.Backpack_1, Items) : BLANKIMG;

                player.Backpack2      = player.Backpack_2 > 0 ? ConvertIDtoName(player.Backpack_2, Items) : null;
                player.Backpack2Image = player.Backpack_2 > 0 ? ConvertIDtoImageUrl(player.Backpack_2, Items) : BLANKIMG;

                if (player.Ability_Upgrades != null)
                {
                    foreach (var ability in player.Ability_Upgrades)
                    {
                        // clean up the object a bit and put
                        // id where it should be.
                        ability.ID = ability.Ability;

                        // map the id to a readable name.
                        ability.Name = ConvertIDtoName(Convert.ToInt32(ability.Ability), Abilities);

                        // add the upgrade seconds to the original start
                        // time to get the upgrade time.
                        ability.UpgradeTime = match.StartTime.AddSeconds(ability.Time);
                    }
                }
                else
                {
                    // sb.AppendLine("No abilities data");
                }
            }

            #endregion

            return(match);
        }