private static LiveEvent ParseLeagueOfLegends(Link link) { var json = JObject.Parse(_client.GetStringAsync(link.Uri).Result); LiveEvent ev = new LiveEvent(); ev.Sport = SportEnum.LeagueOfLegends; ev.GameTime = int.Parse(json["game_time"].ToString()); ev.MapNumber = link.MapNumber; ev.LeagueName = link.LeagueName; ev.BestOf = link.BestOf; switch (json["first_tower"].ToString()) { case "red": ev.FirstTower = 2; break; case "blue": ev.FirstTower = 1; break; } switch (json["first_blood"].ToString()) { case "red": ev.FirstBlood = 2; break; case "blue": ev.FirstBlood = 1; break; } LiveTeam homeTeam = new LiveTeam(); homeTeam.WinsInSeries = link.ScoreHome; homeTeam.Players = new List <LivePlayer>(); homeTeam.TeamName = json["blue_team"]["name"].ToString(); homeTeam.Gold = int.Parse(json["blue"]["gold"].ToString()); homeTeam.Kills = int.Parse(json["blue"]["score"].ToString()); LiveTeam awayTeam = new LiveTeam(); awayTeam.WinsInSeries = link.ScoreAway; awayTeam.Players = new List <LivePlayer>(); awayTeam.TeamName = json["red_team"]["name"].ToString(); awayTeam.Gold = int.Parse(json["red"]["gold"].ToString()); awayTeam.Kills = int.Parse(json["red"]["score"].ToString()); foreach (var player in json["blue"]["players"]) { LivePlayer pl = new LivePlayer(); pl.Nickname = player["name"].ToString(); pl.ChampionName = player["hero"]["name"].ToString(); pl.ChampionImageUrl = player["hero"]["image_url"].ToString(); if (player["color"].ToString() == "blue") { homeTeam.Players.Add(pl); } } foreach (var player in json["red"]["players"]) { LivePlayer pl = new LivePlayer(); pl.Nickname = player["name"].ToString(); pl.ChampionName = player["hero"]["name"].ToString(); pl.ChampionImageUrl = player["hero"]["image_url"].ToString(); if (player["color"].ToString() == "red") { awayTeam.Players.Add(pl); } } if (link.HomeTeamName.ToLowerInvariant() == awayTeam.TeamName.ToLowerInvariant()) //hack for reversed team names { ev.HomeTeam = awayTeam; ev.AwayTeam = homeTeam; ev.HomeTeam.WinsInSeries = link.ScoreHome; ev.AwayTeam.WinsInSeries = link.ScoreAway; return(ev); } ev.HomeTeam = homeTeam; ev.AwayTeam = awayTeam; return(ev); }
internal HockeyGame(LiveTeam home, LiveTeam away, DateTime?date = null) : base(home, away, date) { }