Esempio n. 1
0
        public static async Task <List <Game> > GetUserDetaileData(string UserAccountID, int ChampionCode, int GameType)
        {
            List <Game> games  = new List <Game>();
            JArray      jArray = await GetResultToArray($"{serverDomain}/GetUserDetaileData.php?accountID={UserAccountID}&championCode={ChampionCode}&gameType={GameType}");

            foreach (JToken jToken in jArray)
            {
                string kdaValue = string.Empty;

                if (jToken.Value <float>("deaths") != 0)
                {
                    kdaValue = string.Format("{0:F2}", (jToken.Value <float>("kills") + jToken.Value <float>("assists")) / jToken.Value <float>("deaths"));
                }
                else
                {
                    kdaValue = "퍼팩트";
                }

                DateTime gametime = new DateTime(2000, 1, 1, 0, 0, 0, DateTimeKind.Local).AddSeconds(jToken.Value <double>("gameDuration"));
                DateTime date     = new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Local).AddMilliseconds(jToken.Value <double>("gameCreation"));
                string   kpValue  = string.Empty;
                if (jToken.Value <int>("teamKill") == 0)
                {
                    kpValue = "0%";
                }
                else
                {
                    kpValue = $"{((jToken.Value<int>("kills") + jToken.Value<int>("assists")) * 100 / jToken.Value<int>("teamKill")).ToString()}% ";
                }
                games.Add(new Game()
                {
                    gameHistoryUser = new GameHistoryUser()
                    {
                        win          = $"/LOLAutoSearching;component/ResourceDictionarys/{jToken.Value<string>("win")}.png",
                        championData = new ChampionData()
                        {
                            kill   = jToken.Value <string>("kills"),
                            death  = jToken.Value <string>("deaths"),
                            assist = jToken.Value <string>("assists"),
                            cs     = $"{jToken.Value<string>("cs")}({jToken.Value<string>("cspm")})",
                            kda    = kdaValue,
                            kp     = kpValue,
                        },
                        spellData = new SpellData()
                        {
                            spell1ID = $"http://ddragon.leagueoflegends.com/cdn/9.18.1/img/spell/{SpellData.GetSpellName(jToken.Value<int>("sell1Id"))}.png",
                            spell2ID = $"http://ddragon.leagueoflegends.com/cdn/9.18.1/img/spell/{SpellData.GetSpellName(jToken.Value<int>("sell2Id"))}.png",
                        }
                        ,
                        itemData = new ItemData()
                        {
                            itemImage0 = $"http://ddragon.leagueoflegends.com/cdn/9.18.1/img/item/{jToken.Value<string>("item0")}.png",
                            itemImage1 = $"http://ddragon.leagueoflegends.com/cdn/9.18.1/img/item/{jToken.Value<string>("item1")}.png",
                            itemImage2 = $"http://ddragon.leagueoflegends.com/cdn/9.18.1/img/item/{jToken.Value<string>("item2")}.png",
                            itemImage3 = $"http://ddragon.leagueoflegends.com/cdn/9.18.1/img/item/{jToken.Value<string>("item3")}.png",
                            itemImage4 = $"http://ddragon.leagueoflegends.com/cdn/9.18.1/img/item/{jToken.Value<string>("item4")}.png",
                            itemImage5 = $"http://ddragon.leagueoflegends.com/cdn/9.18.1/img/item/{jToken.Value<string>("item5")}.png",
                        },
                    },
                    date     = $"{date.Year - 2000}/{date.Month}/{date.Day}",
                    gameTime = $"{gametime.Minute}m {gametime.Second}s",
                });
            }
            return(games);
        }