/// <summary> /// Get the instance of StaticRiotApi. /// </summary> /// <param name="apiKey">The api key.</param> /// <returns>The instance of StaticRiotApi.</returns> public static StaticRiotApi GetInstance(string apiKey) { if (instance == null || apiKey != Requester.ApiKey) { instance = new StaticRiotApi(apiKey); } return(instance); }
/// <summary> /// Get the instance of StaticRiotApi. /// </summary> /// <param name="apiKey">The api key.</param> /// <returns>The instance of StaticRiotApi.</returns> public static StaticRiotApi GetInstance(string apiKey) { if (instance == null || apiKey != Requester.ApiKey) { instance = new StaticRiotApi(apiKey); } return instance; }
internal RealmStaticData(StaticRiotApi riotStaticApi, Realm realm, Region region) { Realm = realm; Version = new RiotVersion(Realm.V); Region = region; Champions = riotStaticApi.GetChampions(region, ChampionData.all); Items = riotStaticApi.GetItems(region, ItemData.all); SummonerSpells = riotStaticApi.GetSummonerSpells(region, SummonerSpellData.all); }
private bool IsSummoned() { bool success = true; try { api = RiotApi.GetInstance(VortexConfig.GetRiotApi()); staticApi = StaticRiotApi.GetInstance(VortexConfig.GetRiotApi()); region = (Region)Enum.Parse(typeof(Region), VortexConfig.GetRegion()); oSummoner = api.GetSummoner(region, txtSearchBar.Text); } catch { success = false; } return success; }
public static void Obtener_Enemigos() { RiotSharp.RiotApi Api = RiotApi.GetDevelopmentInstance(_Key); RiotSharp.StaticRiotApi StaticApi = StaticRiotApi.GetInstance(_Key); try { RiotSharp.SummonerEndpoint.Summoner Summoner = Api.GetSummonerByName(_Region, _NombreInvocador); List <RiotSharp.SpectatorEndpoint.Participant> Participants = Api.GetCurrentGame(_Region, Summoner.Id).Participants; // --- ## Diccionarios para cargar los campeones & hechizos ## --- // Dictionary <string, RiotSharp.StaticDataEndpoint.Champion.ChampionStatic> .ValueCollection championlist = StaticApi.GetChampions(_Region, RiotSharp.StaticDataEndpoint.ChampionData.All).Champions.Values; Dictionary <string, RiotSharp.StaticDataEndpoint.SummonerSpell.SummonerSpellStatic> .ValueCollection SummonerSpell = StaticApi.GetSummonerSpells(_Region, RiotSharp.StaticDataEndpoint.SummonerSpellData.All).SummonerSpells.Values; // --- ## Diccionarios para cargar los campeones & hechizos ## --- // int total = Participants.Count; int index = Participants.FindIndex(a => a.SummonerName == _NombreInvocador); if (index > (total / 2) - 1) { for (int i = 0; i <= (total / 2) - 1; i++) { IEnumerable <RiotSharp.StaticDataEndpoint.Champion.ChampionStatic> CampeonWhere = championlist.Where(yourself => yourself.Id == Participants[i].ChampionId); IEnumerable <RiotSharp.StaticDataEndpoint.SummonerSpell.SummonerSpellStatic> Spell1Where = SummonerSpell.Where(yourself => yourself.Id == Participants[i].SummonerSpell1); IEnumerable <RiotSharp.StaticDataEndpoint.SummonerSpell.SummonerSpellStatic> Spell2Where = SummonerSpell.Where(yourself => yourself.Id == Participants[i].SummonerSpell2); Enemigos.Add(CampeonWhere.First()); Hechizos.Add(Spell1Where.First()); Hechizos.Add(Spell2Where.First()); } } else { for (int i = 0; i <= (total / 2) - 1; i++) { IEnumerable <RiotSharp.StaticDataEndpoint.Champion.ChampionStatic> CampeonWhere = championlist.Where(yourself => yourself.Id == Participants[total / 2 + i].ChampionId); IEnumerable <RiotSharp.StaticDataEndpoint.SummonerSpell.SummonerSpellStatic> Spell1Where = SummonerSpell.Where(yourself => yourself.Id == Participants[total / 2 + i].SummonerSpell1); IEnumerable <RiotSharp.StaticDataEndpoint.SummonerSpell.SummonerSpellStatic> Spell2Where = SummonerSpell.Where(yourself => yourself.Id == Participants[total / 2 + i].SummonerSpell2); Enemigos.Add(CampeonWhere.First()); Hechizos.Add(Spell1Where.First()); Hechizos.Add(Spell2Where.First()); } } } catch (RiotSharpException e) { _controlar_excepcion = e.Message; } }
public LeagueService() { this._api = RiotApi.GetInstance(Config.Riot.RiotApiKey, Config.Riot.RiotApiRateLimitPer10Seconds, Config.Riot.RiotApiRateLimitPer10Minutes); this._staticApi = StaticRiotApi.GetInstance(Config.Riot.RiotApiKey); this._regionMapping = new Dictionary<Region, RiotSharp.Region> { [Region.Br] = RiotSharp.Region.br, [Region.Eune] = RiotSharp.Region.eune, [Region.Euw] = RiotSharp.Region.euw, [Region.Na] = RiotSharp.Region.na, [Region.Kr] = RiotSharp.Region.kr, [Region.Lan] = RiotSharp.Region.lan, [Region.Las] = RiotSharp.Region.las, [Region.Oce] = RiotSharp.Region.oce, [Region.Ru] = RiotSharp.Region.ru, [Region.Tr] = RiotSharp.Region.tr, }; this._regionToPlatformMapping = new Dictionary<Region, Platform> { [Region.Br] = Platform.BR1, [Region.Eune] = Platform.EUN1, [Region.Euw] = Platform.EUW1, [Region.Na] = Platform.NA1, [Region.Kr] = Platform.KR, [Region.Lan] = Platform.LA1, [Region.Las] = Platform.LA2, [Region.Oce] = Platform.OC1, [Region.Ru] = Platform.RU, [Region.Tr] = Platform.TR1, }; this._gameQueueTypeMapping = new Dictionary<GameQueueType, RiotSharp.CurrentGameEndpoint.Converters.GameQueueType> { [GameQueueType.Custom] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Custom, [GameQueueType.Normal5x5Blind] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Normal5x5Blind, [GameQueueType.RankedSolo5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.RankedSolo5x5, [GameQueueType.RankedPremade5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.RankedPremade5x5, [GameQueueType.Bot5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Bot5x5, [GameQueueType.Normal3x3] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Normal3x3, [GameQueueType.RankedPremade3x3] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.RankedPremade3x3, [GameQueueType.Normal5x5Draft] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Normal5x5Draft, [GameQueueType.Odin5x5Blind] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Odin5x5Blind, [GameQueueType.Odin5x5Draft] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Odin5x5Draft, [GameQueueType.BotOdin5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.BotOdin5x5, [GameQueueType.Bot5x5Intro] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Bot5x5Intro, [GameQueueType.Bot5x5Beginner] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Bot5x5Beginner, [GameQueueType.Bot5x5Intermediate] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Bot5x5Intermediate, [GameQueueType.RankedTeam3x3] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.RankedTeam3x3, [GameQueueType.RankedTeam5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.RankedTeam5x5, [GameQueueType.BotTt3x3] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.BotTt3x3, [GameQueueType.GroupFinder5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.GroupFinder5x5, [GameQueueType.Aram5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Aram5x5, [GameQueueType.Oneforall5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Oneforall5x5, [GameQueueType.Firstblood1x1] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Firstblood1x1, [GameQueueType.Firstblood2x2] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Firstblood2x2, [GameQueueType.Sr6x6] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Sr6x6, [GameQueueType.Urf5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Urf5x5, [GameQueueType.BotUrf5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.BotUrf5x5, [GameQueueType.NightmareBot5x5Rank1] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.NightmareBot5x5Rank1, [GameQueueType.NightmareBot5x5Rank2] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.NightmareBot5x5Rank2, [GameQueueType.NightmareBot5x5Rank5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.NightmareBot5x5Rank5, [GameQueueType.Ascension5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Ascension5x5, [GameQueueType.Hexakill] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Hexakill, [GameQueueType.BilgewaterAram5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.BilgewaterAram5x5, [GameQueueType.KingPoro5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.KingPoro5x5, [GameQueueType.Bilgewater5x5] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.Bilgewater5x5, [GameQueueType.TeamBuilderDraftRanked] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.TeamBuilderDraftRanked, [GameQueueType.TeamBuilderDraftUnranked] = RiotSharp.CurrentGameEndpoint.Converters.GameQueueType.TeamBuilderDraftUnranked, }; this._gameModeMapping = new Dictionary<GameMode, RiotSharp.GameMode> { [GameMode.Classic] = RiotSharp.GameMode.Classic, [GameMode.Dominion] = RiotSharp.GameMode.Dominion, [GameMode.Aram] = RiotSharp.GameMode.Aram, [GameMode.Tutorial] = RiotSharp.GameMode.Tutorial, [GameMode.OneForAll] = RiotSharp.GameMode.OneForAll, [GameMode.FirstBlood] = RiotSharp.GameMode.FirstBlood, [GameMode.Ascension] = RiotSharp.GameMode.Ascension, [GameMode.Intro] = RiotSharp.GameMode.Intro, [GameMode.KingPoro] = RiotSharp.GameMode.KingPoro, }; this._mapTypeMapping = new Dictionary<MapType, RiotSharp.MapType> { [MapType.SummonersRiftSummerVariant] = RiotSharp.MapType.SummonersRiftSummerVariant, [MapType.SummonersRiftAutumnVariant] = RiotSharp.MapType.SummonersRiftAutumnVariant, [MapType.TheProvingGrounds] = RiotSharp.MapType.TheProvingGrounds, [MapType.TwistedTreelineOriginal] = RiotSharp.MapType.TwistedTreelineOriginal, [MapType.TheCrystalScar] = RiotSharp.MapType.TheCrystalScar, [MapType.TwistedTreelineCurrent] = RiotSharp.MapType.TwistedTreelineCurrent, [MapType.SummonersRift] = RiotSharp.MapType.SummonersRift, [MapType.HowlingAbyss] = RiotSharp.MapType.HowlingAbyss, }; this._gameTypeMapping = new Dictionary<GameType, RiotSharp.GameType> { [GameType.Custom] = RiotSharp.GameType.CustomGame, [GameType.Matched] = RiotSharp.GameType.MatchedGame, [GameType.Tutorial] = RiotSharp.GameType.TutorialGame }; this._laneMapping = new Dictionary<RiotSharp.MatchEndpoint.Lane, Lane> { [RiotSharp.MatchEndpoint.Lane.Bot] = Lane.Bot, [RiotSharp.MatchEndpoint.Lane.Bottom] = Lane.Bot, [RiotSharp.MatchEndpoint.Lane.Jungle] = Lane.Jungle, [RiotSharp.MatchEndpoint.Lane.Mid] = Lane.Mid, [RiotSharp.MatchEndpoint.Lane.Middle] = Lane.Mid, [RiotSharp.MatchEndpoint.Lane.Top] = Lane.Top, }; this._roleMapping = new Dictionary<RiotSharp.MatchEndpoint.Role, Role> { [RiotSharp.MatchEndpoint.Role.Duo] = Role.Duo, [RiotSharp.MatchEndpoint.Role.DuoCarry] = Role.DuoCarry, [RiotSharp.MatchEndpoint.Role.DuoSupport] = Role.DuoSupport, [RiotSharp.MatchEndpoint.Role.None] = Role.None, [RiotSharp.MatchEndpoint.Role.Solo] = Role.Solo, }; }
/// <summary> /// Initialize the static data store by pulling down all data we care about. /// </summary> public static void Initialize(StaticRiotApi riotStaticApi) { var realms = Enum.GetValues(typeof(Region)).OfType<Region>().AsParallel().WithDegreeOfParallelism(4).Select(region => new { Region = region, Realm = riotStaticApi.GetRealm(region) }).ToList(); Version = realms.Max(realm => new RiotVersion(realm.Realm.V)); var filteredRealms = realms.Where(realm => Version.IsSamePatch(new RiotVersion(realm.Realm.V))); // Get data for all valid realms Realms = filteredRealms.ToDictionary(realm => realm.Region, realm => new RealmStaticData(riotStaticApi, realm.Realm, realm.Region)); // Try getting NA data if available RealmStaticData primaryrealm; if (!Realms.TryGetValue(Region.na, out primaryrealm)) { // Try to find an english realm primaryrealm = Realms.FirstOrDefault(kvp => kvp.Value.Realm.L.Contains("en")).Value; // If we can't find english data, give up and just choose the first realm if (primaryrealm == null) primaryrealm = Realms.FirstOrDefault().Value; // If there are no realms, just return if (primaryrealm == null) return; } Champions = primaryrealm.Champions; Items = primaryrealm.Items; SummonerSpells = primaryrealm.SummonerSpells; }