Esempio n. 1
0
        public LiveGame(object accountId)
        {
            HttpClient          client   = new HttpClient();
            var                 t        = client.GetAsync($"https://na1.api.riotgames.com/lol/spectator/v4/active-games/by-summoner/{accountId}?api_key={API.apiKey}");
            HttpResponseMessage response = t.Result;

            if (response.Content.ToString().Contains("404"))
            {
                live = false;
            }

            else
            {
                dynamic liveGameJson = JObject.Parse(t.Result.Content.ReadAsStringAsync().Result.ToString());

                dynamic currentParticipantsJson = JArray.Parse(liveGameJson.participants.ToString());

                List <GameCustomizationObject> gameCustomizationObjects = new List <GameCustomizationObject>();
                foreach (var participant in currentParticipantsJson)
                {
                    dynamic participantGameCusomizationObjectsJson = JArray.Parse(participant.gameCustomizationObjects.ToString());
                    foreach (var gameCustomizaionObjectJson in participantGameCusomizationObjectsJson)
                    {
                        GameCustomizationObject gameCustomizationObject = new GameCustomizationObject(gameCustomizaionObjectJson.category.Value.ToString(), gameCustomizaionObjectJson.content.Value.ToString());
                        gameCustomizationObjects.Add(gameCustomizationObject);
                    }

                    CurrentGameParticipant currentGameParticipant = new CurrentGameParticipant(participant.summonerName.Value.ToString(), participant.championId.Value.ToString(), participant.summonerId.Value.ToString(), gameCustomizationObjects);
                    currentGameParticipants.Add(currentGameParticipant);
                }

                dynamic bannedChampionsJson = JArray.Parse(liveGameJson.bannedChampions.ToString());
                foreach (var ban in bannedChampionsJson)
                {
                    BannedChampion bannedChampion = new BannedChampion(ban.championId.Value.ToString(), ban.teamId.Value.ToString(), (Int32)ban.pickTurn.Value);
                    bannedChampions.Add(bannedChampion);
                }
                live = true;
            }
        }
Esempio n. 2
0
 public Ban(BannedChampion champ)
 {
     ChampionId = champ.ChampionId;
 }