/// <summary>
 /// MatchHistorySummary constructor
 /// </summary>
 /// <param name="assists">Number of assists</param>
 /// <param name="dateLong">Date of match specified as epoch milliseconds</param>
 /// <param name="deaths">Number of deaths</param>
 /// <param name="gameId">Game ID</param>
 /// <param name="gameModeString">Game mode represented as a string</param>
 /// <param name="invalid">Is invalid?</param>
 /// <param name="kills">Number of kills</param>
 /// <param name="mapId">Map ID as a number</param>
 /// <param name="opposingTeamKills">Opposing team kills</param>
 /// <param name="opposingTeamName">Opposing team name</param>
 /// <param name="win">If the team won or not</param>
 public MatchHistorySummary(int assists,
                            long dateLong,
                            int deaths,
                            long gameId,
                            string gameModeString,
                            bool invalid,
                            int kills,
                            int mapId,
                            int opposingTeamKills,
                            string opposingTeamName,
                            bool win)
 {
     this.assists        = assists;
     this.dateLong       = dateLong;
     date                = CreepScore.EpochToDateTime(dateLong);
     this.deaths         = deaths;
     this.gameId         = gameId;
     this.gameModeString = gameModeString;
     gameMode            = GameConstants.SetGameMode(gameModeString);
     this.invalid        = invalid;
     this.kills          = kills;
     this.mapId          = mapId;
     map = GameConstants.SetMap(mapId);
     this.opposingTeamKills = opposingTeamKills;
     this.opposingTeamName  = opposingTeamName;
     this.win = win;
 }
 public PlayerStatsSummaryList(JArray playerStatSummariesA, long summonerId, CreepScore.Season season)
 {
     playerStatSummaries = new List<PlayerStatsSummary>();
     LoadPlayerStatSummaries(playerStatSummariesA);
     this.summonerId = summonerId;
     this.season = season;
 }
示例#3
0
        public async Task <RecentGames> RetrieveRecentGames()
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.gameAPIVersion, UrlConstants.gamePart)
                      .AppendPathSegments(UrlConstants.bySummonerPart, id.ToString(), UrlConstants.recentPart);

            url.SetQueryParams(new
            {
                api_key = CreepScore.apiKey
            });
            Uri uri = new Uri(url.ToString());

            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadRecentGames(JObject.Parse(responseString)));
        }
示例#4
0
 /// <summary>
 /// Little summmoner constructor
 /// </summary>
 /// <param name="id">Summoner ID</param>
 /// <param name="name">Summoner Name</param>
 public Summoner(long id, string name, CreepScore.Region region)
 {
     this.id = id;
     this.name = name;
     isLittleSummoner = true;
     this.region = region;
 }
示例#5
0
        public async Task <Dictionary <string, RunePages> > RetrieveRunePages()
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.summonerAPIVersion, UrlConstants.summonerPart)
                      .AppendPathSegments(id.ToString(), UrlConstants.runesPart);

            url.SetQueryParams(new
            {
                api_key = CreepScore.apiKey
            });
            Uri uri = new Uri(url.ToString());

            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadRunePages(responseString));
        }
示例#6
0
        public async Task <Dictionary <string, List <Team> > > RetrieveTeams()
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.teamAPIVersion, UrlConstants.teamPart)
                      .AppendPathSegments(UrlConstants.bySummonerPart, id.ToString());

            url.SetQueryParams(new
            {
                api_key = CreepScore.apiKey
            });
            Uri uri = new Uri(url.ToString());

            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(HelperMethods.LoadTeams(responseString));
        }
示例#7
0
        public async Task <RankedStats> RetrieveRankedStats(CreepScore.Season season)
        {
            if (summonerLevel == 30)
            {
                Url url = UrlConstants.UrlBuilder(region, UrlConstants.statsAPIVersion, UrlConstants.statsPart)
                          .AppendPathSegments(UrlConstants.bySummonerPart, id.ToString(), UrlConstants.rankedPart);
                url.SetQueryParams(new
                {
                    season  = CreepScore.GetSeason(season),
                    api_key = CreepScore.apiKey
                });
                Uri uri = new Uri(url.ToString());
                await CreepScore.GetPermission(region);

                string responseString;
                try
                {
                    responseString = await CreepScore.GetWebData(uri);
                }
                catch (CreepScoreException)
                {
                    throw;
                }
                return(LoadRankedStats(JObject.Parse(responseString), season));
            }
            else
            {
                throw new CreepScoreException("The summoner is not level 30. They do not have ranked stats.");
            }
        }
示例#8
0
        public async Task <PlayerStatsSummaryList> RetrievePlayerStatsSummaries(CreepScore.Season season)
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.statsAPIVersion, UrlConstants.statsPart)
                      .AppendPathSegments(UrlConstants.bySummonerPart, id.ToString(), UrlConstants.summaryPart);

            url.SetQueryParams(new
            {
                season  = CreepScore.GetSeason(season),
                api_key = CreepScore.apiKey
            });
            Uri uri = new Uri(url.ToString());
            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadPlayerStatSummariesList(JObject.Parse(responseString), season));
        }
示例#9
0
 /// <summary>
 /// CurrentGameInfo constructor
 /// </summary>
 /// <param name="bannedChampionsA"></param>
 /// <param name="gameId"></param>
 /// <param name="gameLength"></param>
 /// <param name="gameMode"></param>
 /// <param name="gameQueueConfigId"></param>
 /// <param name="gameStartTime"></param>
 /// <param name="gameType"></param>
 /// <param name="mapId"></param>
 /// <param name="observersO"></param>
 /// <param name="participantsA"></param>
 /// <param name="platformId"></param>
 public CurrentGameInfoLive(JArray bannedChampionsA,
                            long gameId,
                            long gameLength,
                            string gameMode,
                            long gameQueueConfigId,
                            long gameStartTime,
                            string gameType,
                            long mapId,
                            JObject observersO,
                            JArray participantsA,
                            string platformId)
 {
     this.bannedChampions       = HelperMethods.LoadBans(bannedChampionsA);
     this.gameId                = gameId;
     this.gameLengthLong        = gameLength;
     this.gameLength            = TimeSpan.FromSeconds(gameLength);
     this.gameModeString        = gameMode;
     this.gameMode              = GameConstants.SetGameMode(gameMode);
     this.gameQueueConfigIdLong = gameQueueConfigId;
     this.gameQueueConfigId     = AdvancedMatchHistoryConstants.SetQueueType(gameQueueConfigId);
     this.gameStartTimeLong     = gameStartTime;
     this.gameStartTime         = CreepScore.EpochToDateTime(gameStartTime);
     this.gameTypeString        = gameType;
     this.gameType              = GameConstants.SetGameType(gameType);
     this.mapIdLong             = mapId;
     this.mapId        = GameConstants.SetMap((int)mapId);
     this.observers    = LoadObservers(observersO);
     this.participants = LoadParticipants(participantsA);
     this.platformId   = platformId;
 }
示例#10
0
 /// <summary>
 /// RankedStats constructor
 /// </summary>
 /// <param name="championsA">JArray of champions</param>
 /// <param name="modifyDateLong">Date stats were last modified specified as epoch milliseconds</param>
 /// <param name="summonerId">Summoner ID</param>
 /// <param name="season">The season that represents this data</param>
 public RankedStats(JArray championsA, long modifyDateLong, long summonerId, CreepScore.Season season)
 {
     champions = new List <ChampionStats>();
     LoadChampions(championsA);
     this.modifyDateLong = modifyDateLong;
     modifyDate          = CreepScore.EpochToDateTime(modifyDateLong);
     this.summonerId     = summonerId;
     this.season         = season;
 }
示例#11
0
 /// <summary>
 /// RankedStats constructor
 /// </summary>
 /// <param name="championsA">JArray of champions</param>
 /// <param name="modifyDateLong">Date stats were last modified specified as epoch milliseconds</param>
 /// <param name="summonerId">Summoner ID</param>
 /// <param name="season">The season that represents this data</param>
 public RankedStats(JArray championsA, long modifyDateLong, long summonerId, CreepScore.Season season)
 {
     champions = new List<ChampionStats>();
     LoadChampions(championsA);
     this.modifyDateLong = modifyDateLong;
     modifyDate = CreepScore.EpochToDateTime(modifyDateLong);
     this.summonerId = summonerId;
     this.season = season;
 }
示例#12
0
        // Karma = 43
        // golf1052 = 26040955
        // Chaox = 7460

        public SummonerTests()
        {
            creepScore = new CreepScore(ApiKey.apiKey);
            List<string> summonerNames = new List<string>();
            summonerNames.Add("golf1052");
            List<Summoner> summoners = new List<Summoner>();
            Task task = Task.Run(async () => { summoners = await creepScore.RetrieveSummoners(CreepScore.Region.NA, summonerNames); });
            task.Wait();
            golf1052 = summoners[0];
        }
示例#13
0
 /// <summary>
 /// Full summoner constructor
 /// </summary>
 /// <param name="summonerO">JObject representing summoner</param>
 public Summoner(JObject summonerO, CreepScore.Region region)
 {
     id = (long)summonerO["id"];
     name = (string)summonerO["name"];
     profileIconId = (int)summonerO["profileIconId"];
     revisionDateLong = (long)summonerO["revisionDate"];
     SetRevisionDate(revisionDateLong);
     summonerLevel = (long)summonerO["summonerLevel"];
     isLittleSummoner = false;
     this.region = region;
 }
示例#14
0
 /// <summary>
 /// TeamMemberInfo constructor
 /// </summary>
 /// <param name="inviteDateLong">Date invited to the team specified as epoch milliseconds</param>
 /// <param name="joinDateLong">Date joined the team specified as epoch milliseconds.
 /// This can be null if the player has not joined the team yet.</param>
 /// <param name="playerId">Player ID</param>
 /// <param name="status">Player status</param>
 public TeamMemberInfo(long inviteDateLong, long?joinDateLong, long playerId, string status)
 {
     this.inviteDateLong = inviteDateLong;
     inviteDate          = CreepScore.EpochToDateTime(inviteDateLong);
     this.joinDateLong   = joinDateLong;
     if (joinDateLong != null)
     {
         joinDate = CreepScore.EpochToDateTime((long)joinDateLong);
     }
     this.playerId = playerId;
     this.status   = status;
 }
示例#15
0
 /// <summary>
 /// Team constructor
 /// </summary>
 /// <param name="createDateLong">Date when team was created specified as epoch milliseconds</param>
 /// <param name="lastGameDateLong">Date of last game specified as epoch milliseconds</param>
 /// <param name="lastJoinDateLong">Date when summoner last joined the team specified as epoch milliseconds</param>
 /// <param name="lastJoinedRankedTeamQueueDateLong">Date when this team last joined queue specified as epoch milliseconds</param>
 /// <param name="matchHistoryA">JArray of match history summaries</param>
 /// <param name="modifyDateLong">Date this team was last modified specified as epoch milliseconds</param>
 /// <param name="name">Name of the team</param>
 /// <param name="rosterO">JObject representing the team roster</param>
 /// <param name="secondLastJoinDateLong">Second to last summoner join date specified as epoch milliseconds</param>
 /// <param name="status">Team status</param>
 /// <param name="tag">Team tag</param>
 /// <param name="teamIdO">JObject representing the team ID</param>
 /// <param name="teamStatDetailsA">JArray representing the team stat details</param>
 /// <param name="thirdLastJoinDateLong">Third to last summoner join date specified as epoch milliseconds</param>
 public Team(long createDateLong,
             string fullId,
             long?lastGameDateLong,
             long lastJoinDateLong,
             long lastJoinedRankedTeamQueueDateLong,
             JArray matchHistoryA,
             long modifyDateLong,
             string name,
             JObject rosterO,
             long?secondLastJoinDateLong,
             string status,
             string tag,
             JArray teamStatDetailsA,
             long?thirdLastJoinDateLong)
 {
     teamStatDetails       = new List <TeamStatDetail>();
     matchHistory          = new List <MatchHistorySummary>();
     this.createDateLong   = createDateLong;
     createDate            = CreepScore.EpochToDateTime(createDateLong);
     this.fullId           = fullId;
     this.lastGameDateLong = lastGameDateLong;
     if (lastGameDateLong != null)
     {
         lastGameDate = CreepScore.EpochToDateTime((long)lastGameDateLong);
     }
     this.lastJoinDateLong = lastJoinDateLong;
     lastJoinDate          = CreepScore.EpochToDateTime(lastJoinDateLong);
     this.lastJoinedRankedTeamQueueDateLong = lastJoinedRankedTeamQueueDateLong;
     lastJoinedRankedTeamQueueDate          = CreepScore.EpochToDateTime(lastJoinedRankedTeamQueueDateLong);
     if (matchHistoryA != null)
     {
         LoadMatchHistory(matchHistoryA);
     }
     this.modifyDateLong = modifyDateLong;
     modifyDate          = CreepScore.EpochToDateTime(modifyDateLong);
     this.name           = name;
     LoadRoster(rosterO);
     this.secondLastJoinDateLong = secondLastJoinDateLong;
     if (secondLastJoinDateLong != null)
     {
         secondLastJoinDate = CreepScore.EpochToDateTime((long)secondLastJoinDateLong);
     }
     this.status = status;
     this.tag    = tag;
     LoadTeamStatDetails(teamStatDetailsA);
     this.thirdLastJoinDateLong = thirdLastJoinDateLong;
     if (thirdLastJoinDateLong != null)
     {
         thirdLastJoinDate = CreepScore.EpochToDateTime((long)thirdLastJoinDateLong);
     }
 }
示例#16
0
 /// <summary>
 /// PlayerStatsSummary constructor
 /// </summary>
 /// <param name="aggregatedStatsO">JArray of aggregated stats</param>
 /// <param name="losses">Number of losses for this queue type. Returned only for ranked queue types only. Always 0 for normal queues</param>
 /// <param name="modifyDateLong">Date stats were last modified specified as epoch milliseconds</param>
 /// <param name="playerStatSummaryTypeString">Player stats summary type as a string</param>
 /// <param name="wins">Number of wins for this queue type</param>
 /// <param name="season">The season that this day represents</param>
 public PlayerStatsSummary(JObject aggregatedStatsO,
                           int?losses,
                           long modifyDateLong,
                           string playerStatSummaryTypeString,
                           int wins)
 {
     LoadAggregatedStats(aggregatedStatsO);
     this.losses         = losses;
     this.modifyDateLong = modifyDateLong;
     modifyDate          = CreepScore.EpochToDateTime(modifyDateLong);
     this.playerStatSummaryTypeString = playerStatSummaryTypeString;
     playerStatSummaryType            = GameConstants.SetPlayerStatSummaryType(playerStatSummaryTypeString);
     this.wins = wins;
 }
示例#17
0
        public async Task<ChampionListStatic> RetrieveChampionsData(CreepScore.Region region, StaticDataConstants.ChampData champData, string locale = "", string version = "", bool dataById = false)
        {
            string url = UrlConstants.GetBaseUrl(region) +
                UrlConstants.staticDataPart + "/" +
                UrlConstants.GetRegion(region) +
                UrlConstants.staticDataAPIVersion +
                UrlConstants.championPart + "?";

            if (locale != "")
            {
                url += "locale=" + locale + "&";
            }

            if (version != "")
            {
                url += "version=" + version + "&";
            }

            url += "dataById=" + dataById.ToString() + "&";

            if (champData == StaticDataConstants.ChampData.None)
            {
                url += "api_key=" +
                    apiKey;
            }
            else
            {
                url += "champData=" +
                    StaticDataConstants.GetChampData(champData) +
                    UrlConstants.andApiKeyPart +
                    apiKey;
            }

            Uri uri = new Uri(url);

            string responseString = await GetWebData(uri);

            if (GoodStatusCode(responseString))
            {
                return LoadChampionListStatic(JObject.Parse(responseString));
            }
            else
            {
                errorString = responseString;
                return null;
            }
        }
示例#18
0
        /// <summary>
        /// Game constructor
        /// </summary>
        /// <param name="championId">Champion ID associated with game</param>
        /// <param name="createDateLong">Date that end game data was recorded, specified as epoch milliseconds</param>
        /// <param name="fellowPlayersA">JArray of other players associated with the game</param>
        /// <param name="gameId">Game ID</param>
        /// <param name="gameModeString">Game mode as a string</param>
        /// <param name="gameTypeString">Game type as a string</param>
        /// <param name="invalid">Invalid flag</param>
        /// <param name="level">Level</param>
        /// <param name="ipEarned">IP earned</param>
        /// <param name="mapId">Map ID number</param>
        /// <param name="spell1Id">ID of first summoner spell</param>
        /// <param name="spell2Id">ID of second summoner spell</param>
        /// <param name="statisticsO">JArray of statistics associated with the game for this summoner</param>
        /// <param name="subTypeString">Game sub-type</param>
        /// <param name="teamId">Team ID associated with game</param>
        public Game(int championId,
                    long createDateLong,
                    JArray fellowPlayersA,
                    long gameId,
                    string gameModeString,
                    string gameTypeString,
                    bool invalid,
                    int ipEarned,
                    int level,
                    int mapId,
                    int spell1Id,
                    int spell2Id,
                    JObject statisticsO,
                    string subTypeString,
                    int teamIdInt)
        {
            fellowPlayers = new List <Player>();

            this.championId     = championId;
            this.createDateLong = createDateLong;
            createDate          = CreepScore.EpochToDateTime(createDateLong);
            LoadFellowPlayers(fellowPlayersA);
            this.gameId         = gameId;
            this.gameModeString = gameModeString;
            gameMode            = GameConstants.SetGameMode(gameModeString);
            this.gameTypeString = gameTypeString;
            gameType            = GameConstants.SetGameType(gameTypeString);
            this.invalid        = invalid;
            this.level          = level;
            this.ipEarned       = ipEarned;
            this.mapId          = mapId;
            map           = GameConstants.SetMap(mapId);
            this.spell1Id = spell1Id;
            this.spell2Id = spell2Id;
            spell1        = GameConstants.SetSpellType(spell1Id);
            spell2        = GameConstants.SetSpellType(spell2Id);
            LoadStatistics(statisticsO);
            this.subTypeString = subTypeString;
            subType            = GameConstants.SetSubType(subTypeString);
            this.teamIdInt     = teamIdInt;
            teamId             = GameConstants.SetTeamId(teamIdInt);
        }
示例#19
0
 public MatchReferenceAdvanced(long champion,
                               string lane,
                               long matchId,
                               string platformId,
                               string queue,
                               string role,
                               string season,
                               long timestamp)
 {
     this.champion      = champion;
     this.laneString    = lane;
     this.lane          = AdvancedMatchHistoryConstants.SetLane(lane);
     this.matchId       = matchId;
     this.platformId    = platformId;
     this.queueString   = queue;
     this.queue         = GameConstants.SetQueue(queue);
     this.roleString    = role;
     this.role          = AdvancedMatchHistoryConstants.SetRole(role);
     this.seasonString  = season;
     this.season        = AdvancedMatchHistoryConstants.SetSeason(season);
     this.timestampLong = timestamp;
     this.timestamp     = CreepScore.EpochToDateTime(timestamp);
 }
示例#20
0
        public async Task <CurrentGameInfoLive> RetrieveCurrentGameInfo()
        {
            Url url = new Url(UrlConstants.GetBaseUrl(region)).AppendPathSegments(UrlConstants.observerModeRestpart,
                                                                                  "/consumer/getSpectatorGameInfo/", UrlConstants.GetPlatformId(region), id.ToString());

            url.SetQueryParams(new
            {
                api_key = CreepScore.apiKey
            });
            Uri uri = new Uri(url.ToString());
            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(HelperMethods.LoadCurrentGameInfo(JObject.Parse(responseString)));
        }
示例#21
0
        public async Task <FeaturedGamesLive> RetrieveFeaturedGames(CreepScore.Region region)
        {
            Url url = new Url(UrlConstants.GetBaseUrl(region)).AppendPathSegments(UrlConstants.observerModeRestpart,
                                                                                  "/featured");

            url.SetQueryParams(new
            {
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());
            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(LoadFeaturedGames(JObject.Parse(responseString)));
        }
示例#22
0
        public async Task<List<Champion>> RetrieveChampions(CreepScore.Region region, bool freeToPlay = false)
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.championAPIVersion, UrlConstants.championPart);
            url.SetQueryParams(new
            {
                freeToPlay = freeToPlay.ToString(),
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());
            await GetPermission(region);
            string responseString = await GetWebData(uri);

            if (GoodStatusCode(responseString))
            {
                return LoadChampions(JObject.Parse(responseString));
            }
            else
            {
                errorString = responseString;
                return null;
            }
        }
示例#23
0
        // Karma = 43
        // golf1052 = 26040955
        // Chaox = 7460

        public CreepScoreTests()
        {
            creepScore = new CreepScore(ApiKey.apiKey);
        }
示例#24
0
        public async Task<Dictionary<string, Team>> RetrieveTeam(CreepScore.Region region, List<string> teamIds)
        {
            string ids = "";
            if (teamIds.Count > 10)
            {
                errorString = "Cannot retrieve more than 10 teams at once";
                return null;
            }

            for (int i = 0; i < teamIds.Count; i++)
            {
                if (i != teamIds.Count - 1)
                {
                    ids += teamIds[i] + ",";
                }
                else
                {
                    ids += teamIds[i];
                }
            }

            Uri uri;
            if (ids != "")
            {
                Url url = UrlConstants.UrlBuilder(region, UrlConstants.teamAPIVersion, UrlConstants.teamPart)
                    .AppendPathSegment(ids);
                url.SetQueryParams(new
                {
                    api_key = apiKey
                });
                uri = new Uri(url.ToString());
            }
            else
            {
                errorString = "Cannot have an empty list of team ids";
                return null;
            }

            await GetPermission(region);
            string responseString = await GetWebData(uri);

            if (CreepScore.GoodStatusCode(responseString))
            {
                return HelperMethods.LoadTeam(responseString);
            }
            else
            {
                return null;
            }
        }
示例#25
0
        public async Task<List<Summoner>> RetrieveSummonerNames(CreepScore.Region region, List<long> summonerIds)
        {
            string summonerIdsPart = "";
            if (summonerIds.Count > 40)
            {
                errorString = "Cannot retrieve more than 40 summoners at once";
                return null;
            }

            for (int i = 0; i < summonerIds.Count; i++)
            {
                if (i != summonerIds.Count - 1)
                {
                    summonerIdsPart += summonerIds[i].ToString() + ",";
                }
                else
                {
                    summonerIdsPart += summonerIds[i].ToString();
                }
            }

            Url url = UrlConstants.UrlBuilder(region, UrlConstants.summonerAPIVersion, UrlConstants.summonerPart)
                .AppendPathSegments(summonerIdsPart, UrlConstants.namePart);
            url.SetQueryParams(new
            {
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());

            await GetPermission(region);
            string responseString = await GetWebData(uri);

            if (GoodStatusCode(responseString))
            {
                Dictionary<string, string> values = JsonConvert.DeserializeObject<Dictionary<string, string>>(responseString);
                List<Summoner> littleSummoners = new List<Summoner>();

                foreach (KeyValuePair<string, string> value in values)
                {
                    littleSummoners.Add(new Summoner(long.Parse(value.Key), value.Value, region));
                }

                return littleSummoners;
            }
            else
            {
                errorString = responseString;
                return null;
            }
        }
示例#26
0
        public async Task<MatchDetailAdvanced> RetrieveMatch(CreepScore.Region region, long matchId, bool includeTimeline = false)
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.matchAPIVersion, UrlConstants.matchPart)
                .AppendPathSegment(matchId.ToString());
            url.SetQueryParams(new
            {
                includeTimeline = includeTimeline.ToString(),
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());
            await GetPermission(region);
            string responseString = await GetWebData(uri);

            if (GoodStatusCode(responseString))
            {
                return HelperMethods.LoadMatchDetailAdvanced(JObject.Parse(responseString));
            }
            else
            {
                errorString = responseString;
                return null;
            }
        }
示例#27
0
 /// <summary>
 /// Retrieve a list of URF game IDs for a 5 minute time range
 /// </summary>
 /// <param name="region">The region of the games</param>
 /// <param name="beginDate">
 /// UTC Date representing the start date for the game list.
 /// Must represent a time with an even 5 minute offset.
 /// </param>
 /// <returns>A list of game IDs</returns>
 public async Task<List<long>> RetrieveUrfIds(CreepScore.Region region, DateTimeOffset beginDate)
 {
     Url url = UrlConstants.UrlBuilder(region, UrlConstants.apiChallengeVersion, "/game/ids");
     if (beginDate.Minute % 5 == 0 && beginDate.Second == 0)
     {
         url.SetQueryParams(new
         {
             beginDate = DateTimeToEpoch(beginDate.UtcDateTime),
             api_key = apiKey
         });
         Uri uri = new Uri(url.ToString());
         await GetPermission(region);
         string responseString = await GetWebData(uri);
         if (GoodStatusCode(responseString))
         {
             return HelperMethods.LoadLongs(JArray.Parse(responseString));
         }
         else
         {
             errorString = responseString;
             return null;
         }
     }
     else
     {
         return null;
     }
 }
示例#28
0
 RankedStats LoadRankedStats(JObject o, CreepScore.Season season)
 {
     return new RankedStats((JArray)o["champions"], (long)o["modifyDate"], (long)o["summonerId"], season);
 }
示例#29
0
        public async Task<PlayerHistoryAdvanced> RetrieveMatchHistory(CreepScore.Region region, List<int> championIds = null, List<GameConstants.Queue> rankedQueues = null, int? beginIndex = null, int? endIndex = null)
        {
            string url = UrlConstants.GetBaseUrl(region) + "/" +
                UrlConstants.GetRegion(region) +
                UrlConstants.matchHistoryAPIVersion +
                UrlConstants.matchHistoryPart + "/" +
                id.ToString() + "?";

            if (championIds != null)
            {
                if (championIds.Count != 0)
                {
                    url += "championIds=";

                    for (int i = 0; i < championIds.Count; i++)
                    {
                        if (i + 1 == championIds.Count)
                        {
                            url += championIds[i].ToString() + "&";
                        }
                        else
                        {
                            url += championIds[i].ToString() + ",";
                        }
                    }
                }
            }

            if (rankedQueues != null)
            {
                if (rankedQueues.Count != 0)
                {
                    string tmpRankedQueues = "";
                    for (int i = 0; i < rankedQueues.Count; i++)
                    {
                        if (rankedQueues[i] == GameConstants.Queue.None)
                        {
                            continue;
                        }
                        else
                        {
                            if (i + 1 == rankedQueues.Count)
                            {
                                tmpRankedQueues += GameConstants.GetQueue(rankedQueues[i]);
                            }
                            else
                            {
                                tmpRankedQueues += GameConstants.GetQueue(rankedQueues[i]) + ",";
                            }
                        }
                    }
                    if (tmpRankedQueues != "")
                    {
                        url += "rankedQueues=" + tmpRankedQueues + "&";
                    }
                }
            }

            if (beginIndex != null)
            {
                url += "beginIndex=" + beginIndex.Value.ToString() + "&";
            }

            if (endIndex != null)
            {
                url += "endIndex=" + endIndex.Value.ToString() + "&";
            }
            url += "api_key=" +
                CreepScore.apiKey;

            Uri uri = new Uri(url);

            await CreepScore.GetPermission(region);
            string responseString = await CreepScore.GetWebData(uri);

            if (CreepScore.GoodStatusCode(responseString))
            {
                return HelperMethods.LoadPlayerHistoryAdvanced(JObject.Parse(responseString));
            }
            else
            {
                errorString = responseString;
                return null;
            }
        }
示例#30
0
        public async Task <MatchListAdvanced> RetrieveMatchList(List <int> championIds = null, List <GameConstants.Queue> rankedQueues = null, List <AdvancedMatchHistoryConstants.SeasonAdvanced> seasons = null, long?beginTime = null, long?endTime = null, int?beginIndex = null, int?endIndex = null)
        {
            string url = UrlConstants.GetBaseUrl(region) +
                         UrlConstants.apiLolPart + "/" +
                         UrlConstants.GetRegion(region) +
                         UrlConstants.matchListAPIVersion +
                         UrlConstants.matchListPart +
                         UrlConstants.bySummonerPart + "/" +
                         id.ToString() + "?";

            if (championIds != null)
            {
                if (championIds.Count != 0)
                {
                    url += "championIds=";

                    for (int i = 0; i < championIds.Count; i++)
                    {
                        if (i + 1 == championIds.Count)
                        {
                            url += championIds[i].ToString() + "&";
                        }
                        else
                        {
                            url += championIds[i].ToString() + ",";
                        }
                    }
                }
            }

            if (rankedQueues != null)
            {
                if (rankedQueues.Count != 0)
                {
                    string tmpRankedQueues = "";
                    for (int i = 0; i < rankedQueues.Count; i++)
                    {
                        if (rankedQueues[i] == GameConstants.Queue.None)
                        {
                            continue;
                        }
                        else
                        {
                            if (i + 1 == rankedQueues.Count)
                            {
                                tmpRankedQueues += GameConstants.GetQueue(rankedQueues[i]);
                            }
                            else
                            {
                                tmpRankedQueues += GameConstants.GetQueue(rankedQueues[i]) + ",";
                            }
                        }
                    }
                    if (tmpRankedQueues != "")
                    {
                        url += "rankedQueues=" + tmpRankedQueues + "&";
                    }
                }
            }

            if (seasons != null)
            {
                if (seasons.Count != 0)
                {
                    string tmpSeasons = "";
                    for (int i = 0; i < seasons.Count; i++)
                    {
                        if (seasons[i] == AdvancedMatchHistoryConstants.SeasonAdvanced.Other)
                        {
                            continue;
                        }
                        else
                        {
                            if (i + 1 == seasons.Count)
                            {
                                tmpSeasons += AdvancedMatchHistoryConstants.GetSeason(seasons[i]);
                            }
                            else
                            {
                                tmpSeasons += AdvancedMatchHistoryConstants.GetSeason(seasons[i]) + ",";
                            }
                        }
                    }
                    if (tmpSeasons != "")
                    {
                        url += "seasons=" + tmpSeasons + "&";
                    }
                }
            }

            if (beginTime != null)
            {
                url += "beginTime=" + beginTime.Value.ToString() + "&";
            }

            if (endTime != null)
            {
                url += "endTime=" + endTime.Value.ToString() + "&";
            }

            if (beginIndex != null)
            {
                url += "beginIndex=" + beginIndex.Value.ToString() + "&";
            }

            if (endIndex != null)
            {
                url += "endIndex=" + endIndex.Value.ToString() + "&";
            }
            url += "api_key=" +
                   CreepScore.apiKey;

            Uri uri = new Uri(url);

            await CreepScore.GetPermission(region);

            string responseString;

            try
            {
                responseString = await CreepScore.GetWebData(uri);
            }
            catch (CreepScoreException)
            {
                throw;
            }
            return(HelperMethods.LoadMatchListAdvanced(JObject.Parse(responseString)));
        }
示例#31
0
        public async Task<PlayerStatsSummaryList> RetrievePlayerStatsSummaries(CreepScore.Season season)
        {
            if (!isLittleSummoner)
            {
                Uri uri = new Uri(UrlConstants.GetBaseUrl(region) + "/" +
                    UrlConstants.GetRegion(region) +
                    UrlConstants.statsAPIVersion +
                    UrlConstants.statsPart +
                    UrlConstants.bySummonerPart + "/" +
                    id.ToString() +
                    UrlConstants.summaryPart +
                    UrlConstants.seasonPart +
                    CreepScore.GetSeason(season) +
                    UrlConstants.andApiKeyPart +
                    CreepScore.apiKey);

                string responseString = await CreepScore.GetWebData(uri);

                if (CreepScore.GoodStatusCode(responseString))
                {
                    return LoadPlayerStatSummariesList(JObject.Parse(responseString), season);
                }
                else
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
示例#32
0
        public async Task<List<string>> RetrieveVersions(CreepScore.Region region)
        {
            Url url = UrlConstants.StaticDataUrlBuilder(region, UrlConstants.versionsPart);
            url.SetQueryParams(new
            {
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());
            string responseString = await GetWebData(uri);

            if (GoodStatusCode(responseString))
            {
                return HelperMethods.LoadStrings(JArray.Parse(responseString));
            }
            else
            {
                errorString = responseString;
                return null;
            }
        }
示例#33
0
        public async Task<ChampionStatic> RetrieveChampionData(CreepScore.Region region, int id, StaticDataConstants.ChampData champData, string locale = "", string version = "", bool dataById = false)
        {
            Url url = UrlConstants.StaticDataUrlBuilder(region, UrlConstants.championPart).AppendPathSegment(id.ToString());
            url.SetQueryParams(new
            {
                locale = locale,
                version = version,
                dataById = dataById.ToString(),
                champData = StaticDataConstants.GetChampData(champData),
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());

            string responseString = await GetWebData(uri);

            if (GoodStatusCode(responseString))
            {
                return HelperMethods.LoadChampionStatic(JObject.Parse(responseString));
            }
            else
            {
                errorString = responseString;
                return null;
            }
        }
示例#34
0
        public async Task<RealmStatic> RetrieveRealmData(CreepScore.Region region)
        {
            Url url = UrlConstants.StaticDataUrlBuilder(region, UrlConstants.realmPart);
            url.SetQueryParams(new
            {
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());
            string responseString = await GetWebData(uri);

            if (GoodStatusCode(responseString))
            {
                return LoadRealmData(JObject.Parse(responseString));
            }
            else
            {
                errorString = responseString;
                return null;
            }
        }
示例#35
0
 public async Task<LanguageStringsStatic> RetrieveLanguageStrings(CreepScore.Region region, string locale = "", string version = "")
 {
     Url url = UrlConstants.StaticDataUrlBuilder(region, UrlConstants.languageStringsPart);
     url.SetQueryParams(new
     {
         locale = locale,
         version = version,
         api_key = apiKey
     });
     Uri uri = new Uri(url.ToString());
     string responseString = await GetWebData(uri);
     if (GoodStatusCode(responseString))
     {
         return HelperMethods.LoadLanguageStringsStatic(JObject.Parse(responseString));
     }
     else
     {
         errorString = responseString;
         return null;
     }
 }
示例#36
0
 public void SetRevisionDate(long date)
 {
     revisionDateLong = date;
     revisionDate     = CreepScore.EpochToDateTime(date);
 }
示例#37
0
 public async Task<Champion> RetrieveChampion(CreepScore.Region region, int id)
 {
     Url url = UrlConstants.UrlBuilder(region, UrlConstants.championAPIVersion, UrlConstants.championPart).AppendPathSegment(id.ToString());
     url.SetQueryParams(new
     {
         api_key = apiKey
     });
     Uri uri = new Uri(url.ToString());
     await GetPermission(region);
     string responseString = await GetWebData(uri);
     if (GoodStatusCode(responseString))
     {
         return LoadChampion(JObject.Parse(responseString));
     }
     else
     {
         errorString = responseString;
         return null;
     }
 }
示例#38
0
        public async Task<PlayerStatsSummaryList> RetrievePlayerStatsSummaries(CreepScore.Season season)
        {
            if (!isLittleSummoner)
            {
                Url url = UrlConstants.UrlBuilder(region, UrlConstants.statsAPIVersion, UrlConstants.statsPart)
                    .AppendPathSegments(UrlConstants.bySummonerPart, id.ToString(), UrlConstants.summaryPart);
                url.SetQueryParams(new
                {
                    season = CreepScore.GetSeason(season),
                    api_key = CreepScore.apiKey
                });
                Uri uri = new Uri(url.ToString());
                await CreepScore.GetPermission(region);
                string responseString = await CreepScore.GetWebData(uri);

                if (CreepScore.GoodStatusCode(responseString))
                {
                    return LoadPlayerStatSummariesList(JObject.Parse(responseString), season);
                }
                else
                {
                    return null;
                }
            }
            else
            {
                return null;
            }
        }
示例#39
0
 public async Task<FeaturedGamesLive> RetrieveFeaturedGames(CreepScore.Region region)
 {
     Url url = new Url(UrlConstants.GetBaseUrl(region)).AppendPathSegments(UrlConstants.observerModeRestpart,
         "/featured");
     url.SetQueryParams(new
     {
         api_key = apiKey
     });
     Uri uri = new Uri(url.ToString());
     await CreepScore.GetPermission(region);
     string responseString = await CreepScore.GetWebData(uri);
     if (CreepScore.GoodStatusCode(responseString))
     {
         return LoadFeaturedGames(JObject.Parse(responseString));
     }
     else
     {
         return null;
     }
 }
示例#40
0
 PlayerStatsSummaryList LoadPlayerStatSummariesList(JObject o, CreepScore.Season season)
 {
     return new PlayerStatsSummaryList((JArray)o["playerStatSummaries"], (long)o["summonerId"], season);
 }
示例#41
0
        public async Task<League> RetrieveChallengerLeague(CreepScore.Region region, GameConstants.Queue queue)
        {
            Url url = UrlConstants.UrlBuilder(region, UrlConstants.leagueAPIVersion, UrlConstants.leaguePart).AppendPathSegment("challenger");
            url.SetQueryParams(new
            {
                type = GameConstants.GetQueue(queue),
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());
            await GetPermission(region);
            string responseString = await GetWebData(uri);

            if (GoodStatusCode(responseString))
            {
                return LoadLeague(JObject.Parse(responseString));
            }
            else
            {
                errorString = responseString;
                return null;
            }
        }
示例#42
0
        public async Task<Summoner> RetrieveSummoner(CreepScore.Region region, string summonerName)
        {
            List<string> temp = new List<string>();
            temp.Add(summonerName);
            List<Summoner> returnedList = await RetrieveSummoners(region, temp);

            if (returnedList != null)
            {
                return returnedList[0];
            }
            else
            {
                return null;
            }
        }
示例#43
0
        public async Task<List<Summoner>> RetrieveSummoners(CreepScore.Region region, List<string> summonerNames)
        {
            string names = "";
            if (summonerNames.Count > 40)
            {
                errorString = "Cannot retrieve more than 40 summoners at once";
                return null;
            }

            for (int i = 0; i < summonerNames.Count; i++)
            {
                if (i != summonerNames.Count - 1)
                {
                    names += summonerNames[i] + ",";
                }
                else
                {
                    names += summonerNames[i];
                }
            }

            Uri uri;
            if (names != "")
            {
                Url url = UrlConstants.UrlBuilder(region, UrlConstants.summonerAPIVersion, UrlConstants.summonerPart)
                    .AppendPathSegments(UrlConstants.byNamePart, names);
                url.SetQueryParams(new
                {
                    api_key = apiKey
                });
                uri = new Uri(url.ToString());
            }
            else
            {
                errorString = "Cannot have an empty list of summoner names";
                return null;
            }

            await GetPermission(region);
            string responseString = await GetWebData(uri);

            if (GoodStatusCode(responseString))
            {
                List<Summoner> summoners = new List<Summoner>();
                Dictionary<string, JObject> values = JsonConvert.DeserializeObject<Dictionary<string, JObject>>(responseString);
                foreach (KeyValuePair<string, JObject> value in values)
                {
                    summoners.Add(new Summoner(value.Value, region));
                }
                return summoners;
            }
            else
            {
                errorString = responseString;
                return null;
            }
        }
示例#44
0
        public async Task<RuneListStatic> RetrieveRunesData(CreepScore.Region region, StaticDataConstants.RuneListData runeListData, string locale = "", string version = "")
        {
            Url url = UrlConstants.StaticDataUrlBuilder(region, UrlConstants.runePart);
            url.SetQueryParams(new
            {
                locale = locale,
                version = version,
                runeListData = StaticDataConstants.GetRuneListData(runeListData),
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());

            string responseString = await GetWebData(uri);

            if (GoodStatusCode(responseString))
            {
                return HelperMethods.LoadRuneListStatic(JObject.Parse(responseString));
            }
            else
            {
                errorString = responseString;
                return null;
            }
        }
示例#45
0
        public async Task<Dictionary<string, Team>> RetrieveTeam(CreepScore.Region region, List<string> teamIds)
        {
            string ids = "";
            if (teamIds.Count > 40)
            {
                errorString = "Cannot retrieve more than 40 teams at once";
                return null;
            }

            for (int i = 0; i < teamIds.Count; i++)
            {
                if (i != teamIds.Count - 1)
                {
                    ids += teamIds[i] + ",";
                }
                else
                {
                    ids += teamIds[i];
                }
            }

            Uri uri;
            if (ids != "")
            {
                uri = new Uri(UrlConstants.GetBaseUrl(region) + "/" +
                    UrlConstants.GetRegion(region) +
                    UrlConstants.teamAPIVersion +
                    UrlConstants.teamPart + "/" +
                    ids +
                    UrlConstants.apiKeyPart +
                    CreepScore.apiKey);
            }
            else
            {
                errorString = "Cannot have an empty list of team ids";
                return null;
            }
            string responseString = await CreepScore.GetWebData(uri);

            if (CreepScore.GoodStatusCode(responseString))
            {
                return HelperMethods.LoadTeam(responseString);
            }
            else
            {
                return null;
            }
        }
示例#46
0
        // Karma = 43

        public StaticDataTests()
        {
            creepScore = new CreepScore(ApiKey.apiKey);
        }
示例#47
0
        public async Task<SummonerSpellStatic> RetrieveSummonerSpellData(CreepScore.Region region, int id, StaticDataConstants.SpellData spellData, string locale = "", string version = "")
        {
            Url url = UrlConstants.StaticDataUrlBuilder(region, UrlConstants.summonerSpellPart).AppendPathSegment(id.ToString());
            url.SetQueryParams(new
            {
                locale = locale,
                version = version,
                spellData = StaticDataConstants.GetSpellData(spellData),
                api_key = apiKey
            });
            Uri uri = new Uri(url.ToString());

            string responseString = await GetWebData(uri);

            if (GoodStatusCode(responseString))
            {
                return HelperMethods.LoadSummonerSpellStatic(JObject.Parse(responseString));
            }
            else
            {
                errorString = responseString;
                return null;
            }
        }