コード例 #1
0
        // Comprobar la conexión
        public static bool Comprobar_Conexion(string key, string nombreInvocador, RiotSharp.Misc.Region region)
        {
            RiotSharp.RiotApi api = RiotApi.GetDevelopmentInstance(key);

            try { api.GetSummonerByName(region, nombreInvocador);
                  _NombreInvocador = nombreInvocador;
                  _Key             = key;
                  _Region          = region;
                  return(true); }
            catch (RiotSharpException) { return(false); }
        }
コード例 #2
0
        public async Task <Summoner> GetBasicSummonerDataAsync(string summonerName, RiotSharp.Misc.Region region)
        {
            try
            {
                var summoner = await this.Api.Summoner.GetSummonerByNameAsync(region, summonerName);

                return(summoner);
            }
            catch (RiotSharpException ex)
            {
                return(null);
            }
        }
コード例 #3
0
        public async Task <Match> GetGameAsync(long gameId, RiotSharp.Misc.Region region)
        {
            try
            {
                var game = await this.Api.Match.GetMatchAsync(region, gameId);

                return(game);
            }
            catch (RiotSharpException ex)
            {
                return(null);
            }
        }
コード例 #4
0
        public async Task <ICollection <Match> > GetGamesAsync(GetGamesInputModel input)
        {
            if (input.Count < 0 || input.Count > 10)
            {
                throw new ArgumentException("Count must be between 0 and 10!");
            }

            if (input.RegionId < 0 || input.RegionId > 10)
            {
                throw new ArgumentException("Region Id must be between 0 and 10!");
            }

            if (input.Username.Length <= 0 || input.Username.Length > 16) // Leagues max name length is 16!
            {
                throw new ArgumentException("Username must be between 1 and 16 characters long!");
            }

            RiotSharp.Misc.Region region = (RiotSharp.Misc.Region)input.RegionId;

            var summoner = await this.GetBasicSummonerDataAsync(input.Username, region);

            if (summoner == null)
            {
                throw new ArgumentNullException("summonerName", "Wrong summoner name!");
            }

            var matches = await this.Api.Match.GetMatchListAsync(region, summoner.AccountId);

            var games = new List <Match>();

            for (int i = 0; i < input.Count; i++)
            {
                var game = await this.GetGameAsync(matches.Matches[i].GameId, region);

                games.Add(game);
            }

            return(games);
        }
コード例 #5
0
        public async Task <ICollection <Match> > GetGamesAsync(GetGamesInputModel input)
        {
            RiotSharp.Misc.Region region = (RiotSharp.Misc.Region)input.RegionId;

            var summoner = await this.GetBasicSummonerDataAsync(input.Username, region);

            if (summoner == null)
            {
                throw new ArgumentException("Wrong summoner name!");
            }

            var matches = await this.Api.Match.GetMatchListAsync(region, summoner.AccountId);

            var games = new List <Match>();

            for (int i = 0; i < input.Count; i++)
            {
                var game = await this.GetGameAsync(matches.Matches[i].GameId, region);

                games.Add(game);
            }

            return(games);
        }
コード例 #6
0
        public async Task <Match> GetGameAsync(long gameId, RiotSharp.Misc.Region region)
        {
            var game = await this.Api.Match.GetMatchAsync(region, gameId);

            return(game);
        }