public HomeController(IRepositoryBase <Entrada> context) { _context = context; _rito = RiotApi.GetInstance(k); _claves = new Claves(); _staticApi = StaticRiotApi.GetInstance(k); }
public async Task Run(string[] args) { System.IO.StreamReader file = new System.IO.StreamReader("token.txt"); string riotToken = file.ReadLine(); string discordToken = file.ReadLine(); api = RiotApi.GetInstance(riotToken); staticApi = StaticRiotApi.GetInstance(riotToken); client = new DiscordClient(new DiscordConfig() { Token = discordToken, TokenType = TokenType.Bot, DiscordBranch = Branch.Canary, LogLevel = LogLevel.Debug, UseInternalLogHandler = true, AutoReconnect = true }); client.UseCommands(new CommandConfig() { Prefix = "$", SelfBot = false }); CreateCommands(client); await client.Connect(); champions = staticApi.GetChampions(Region.na, ChampionData.info).Champions.Values.ToList <ChampionStatic>(); spells = staticApi.GetSummonerSpells(Region.eune, SummonerSpellData.basic).SummonerSpells.Values.ToList <SummonerSpellStatic>(); Console.ReadLine(); }
public void GetSummonerInfo(string summonerName, string api, SummonerViewModel model) { var myApi = RiotApi.GetInstance(api); var staticApi = StaticRiotApi.GetInstance(api); if (summonerName != null) { GrabSummoner(myApi, summonerName, model); var champions = staticApi.GetChampions(Region.na, ChampionData.image).Champions.Values; var summonerSpells = staticApi.GetSummonerSpells(Region.na, SummonerSpellData.image).SummonerSpells.Values; var version = staticApi.GetVersions(Region.na).FirstOrDefault(); var rankedStats = myApi.GetStatsRanked(Region.na, model.SummonerId); var summonerIdList = new List <long> { model.SummonerId }; var leagues = myApi.GetLeagues(Region.na, summonerIdList).FirstOrDefault().Value; GrabEntries(leagues, model); GrabMatchHistory(myApi, model, version, champions, summonerSpells); model.Champions = champions; model.SummonerIcon = "http://ddragon.leagueoflegends.com/cdn/" + version + "/img/profileicon/" + model.SummonerIconId + ".png"; } }
public bool CollectVersionData() { bool success = false; List <string> checkVersions = new List <string>(); // Setup RiotApi var staticApi = StaticRiotApi.GetInstance(Resources.App.ApiKey); try { //Get all Version list and Realm versions = staticApi.GetVersions(RiotSharp.Region.na); realm = staticApi.GetRealm(RiotSharp.Region.na); success = true; } catch (Exception ex) { //TODO: correctly handle errors rather than this XtraMessageBox.Show(@"There was a problem downloading Versions from League of Legends. " + ex.Message + @" " + ex.ToString(), "League Build Stats - Notice"); //System.NullReferenceException means no interenet connection or something } if (success) { success = StoreRiotVersionData(); } return(success); }
public bool DownloadListOfItems(string inputVersion = null) { bool success = false; try { // Setup RiotApi var staticApi = StaticRiotApi.GetInstance(Resources.App.ApiKey); ItemListStatic items; //Get all Items if (inputVersion == null) { items = staticApi.GetItems(RiotSharp.Region.na, ItemData.all); } else { items = staticApi.GetItems(RiotSharp.Region.na, inputVersion, ItemData.all); } StoreRiotItemData(items); SortRiotItemData(items); success = true; } catch (Exception ex) { //TODO: correctly handle errors rather than this MessageBox.Show(ex.ToString()); success = false; } return(success); }
public async void LoadAllChampionsRiotApi() { AllChampions.RemoveAllChampions(); if (MySettings.UserApiKey.Length == 36) { try { StaticRiotApi staticApi = StaticRiotApi.GetInstance(_s.UserApiKey); RiotSharp.StaticDataEndpoint.ChampionListStatic champions = await staticApi.GetChampionsAsync(RiotSharp.Region.euw, RiotSharp.StaticDataEndpoint.ChampionData.info, RiotSharp.Language.en_US); for (int i = 0; i < champions.Champions.Count; i++) { string ChampionName = champions.Champions.Values.ElementAt(i).Name; AllChampions.AddChampion(ChampionName); } } catch (RiotSharpException ex) { StaticErrorLogger.WriteErrorReport(ex, "Handled; AppRuntimeResourcesManager/LoadAllChampionsRiotApi:RiotSharpException"); DisplayPopup("Trouble with loading champions trough the api"); } catch (NullReferenceException ex) { StaticErrorLogger.WriteErrorReport(ex, "Handled; AppRuntimeResourcesManager/LoadAllChampionsRiotApi:NullReferenceException"); DisplayPopup("Internet problem while loading champions"); } } else { DisplayPopup("No correct API key found, get one at https://developer.riotgames.com/"); } }
public RiotApiScrapeJob() { var key = WebConfigurationManager.AppSettings["RiotApiKey"]; var rateLimit1 = int.Parse(WebConfigurationManager.AppSettings["RateLimitPer10Seconds"]); var rateLimit2 = int.Parse(WebConfigurationManager.AppSettings["RateLimitPer10Minutes"]); _api = RiotApi.GetInstance(key, rateLimit1, rateLimit2); _staticApi = StaticRiotApi.GetInstance(key); }
static void Main(string[] args) { var api = RiotApi.GetInstance(ConfigurationManager.AppSettings["ApiKey"]); var staticApi = StaticRiotApi.GetInstance(ConfigurationManager.AppSettings["ApiKey"]); var statusApi = StatusRiotApi.GetInstance(); int id = int.Parse(ConfigurationManager.AppSettings["Summoner1Id"]); string name = ConfigurationManager.AppSettings["Summoner1Name"]; int id2 = int.Parse(ConfigurationManager.AppSettings["Summoner2Id"]); string name2 = ConfigurationManager.AppSettings["Summoner2Name"]; string team = ConfigurationManager.AppSettings["Team1Id"]; string team2 = ConfigurationManager.AppSettings["Team2Id"]; int gameId = int.Parse(ConfigurationManager.AppSettings["GameId"]); Region region = (Region)Enum.Parse(typeof(Region), ConfigurationManager.AppSettings["Region"]); var languages = staticApi.GetLanguages(region); Console.WriteLine(string.Join(", ", languages)); var summ = api.GetSummoner(region, name); var teams = summ.GetTeams(); var match1 = api.GetMatch(region, gameId); Console.WriteLine(match1.MapType); var shards = statusApi.GetShards(); var shardStatus = statusApi.GetShardStatus(region); var statSummaries = api.GetStatsSummaries(region, id); var championIds = new List <int>(); for (int i = 0; i < 30; i += 15) { var matches = api.GetMatchHistory(region, id, i, i + 15, null, new List <Queue>() { Queue.RankedSolo5x5 }); foreach (var match in matches) { championIds.Add(match.Participants[0].ChampionId); } } var mostPlayedChampId = championIds.GroupBy(c => c).OrderByDescending(g => g.Count()).FirstOrDefault().Key; var mostPlayedChamp = staticApi.GetChampion(region, mostPlayedChampId); Console.WriteLine(mostPlayedChamp.Name); var games = api.GetRecentGames(region, id); Console.WriteLine("Done! Press Enter to exit."); Console.ReadLine(); }
private static ChampionStatic getChampion(int championId) { if (Champions == null) { Champions = StaticRiotApi.GetInstance(API_KEY).GetChampions(Region.na, ChampionData.all); } var champion = Champions.Champions.First(x => x.Value.Id == championId); return(champion.Value); }
public async Task HelpCommand() { var champions = StaticRiotApi.GetInstance(Settings.RiotAPIKey).GetChampions(RiotSharp.Misc.Region.euw).Champions; var champ = champions.First(c => c.Key == "Aatrox").Value; MessageHandler messageHandler = new MessageHandler(); EmbedBuilder message = messageHandler.BuildEmbed("Team creation and management command", $"Use `help team` to see how to use it.", Palette.Pink); await ReplyAsync("", false, message.Build()); }
public MainWindow() { InitializeComponent(); Instance = this; Closing += delegate { if (Variables.FirstRun) { Variables.FirstRun = false; } Settings.Default.Save(); }; var cmdArgs = Environment.GetCommandLineArgs(); Settings.Default.Upgrade(); if (Variables.FirstRun || cmdArgs.Contains("firstrun")) { SummonerView.Loaded += (s, e) => { ShowDialog(); }; Transitioner.SelectedIndex = 2; } if (cmdArgs.Contains("update")) { Variables.Items = null; Variables.Champions = null; var versions = StaticRiotApi.GetInstance(Variables.ApiKey).GetVersionsAsync(Variables.Region).GetAwaiter().GetResult(); Variables.Patch = versions[0]; // ReSharper disable once AssignNullToNotNullAttribute System.Diagnostics.Process.Start(Application.ResourceAssembly.Location); Application.Current.Shutdown(); } if (!Directory.Exists("Downloads/Splashes")) { Directory.CreateDirectory("Downloads/Splashes"); } var key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true); const string appName = "SummonersCompanion.exe"; if (key != null && key.GetValue(appName) == null) { key.SetValue(appName, 11001, RegistryValueKind.DWord); } key = Registry.LocalMachine.OpenSubKey(@"SOFTWARE\Wow6432Node\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION", true); if (key?.GetValue(appName) != null) { key.SetValue("YourApplicationName.exe", 11001, RegistryValueKind.DWord); } }
private static ItemStatic getItem(int itemId) { if (Items == null) { Items = StaticRiotApi.GetInstance(API_KEY).GetItems(Region.na, ItemData.all); } if (Items.Items.ContainsKey(itemId)) { var item = Items.Items[itemId]; return(item); } return(Items.Items.Values.First()); }
private RiotSharp.StaticDataEndpoint.Champion.ChampionStatic GetChampionNameById(string id) { try { var champions = StaticRiotApi.GetInstance(Settings.RiotAPIKey).GetChampions(RiotSharp.Misc.Region.euw).Champions; return(champions.First(c => c.Value.Id.ToString() == id).Value); } catch (Exception e) { Debugging.Log("GetChampionNameById", $"Error getting champion name by id: {e.Message}", LogSeverity.Error); return(null); } }
internal static UpsetModel GetUpsetModel() { UpsetModel model = new UpsetModel(); if (Items == null) { Items = StaticRiotApi.GetInstance(API_KEY).GetItems(Region.na, ItemData.all); } if (PotentialUpgrades == null) { InitializePotentialUpgrades(); } model.CompleteItems = Items.Items.Where(x => x.Value.Into == null && x.Value.From != null).Select(x => x.Value).ToList(); model.PotentialUpgrades = PotentialUpgrades; return(model); }
/// <summary> /// Constructor for this class which fetches the API instance.. /// </summary> /// <param name="apiKey">A developer key from https://developer.riotgames.com/ </param> public LeagueStats(string apiKey) { api = RiotApi.GetInstance(apiKey); staticApi = StaticRiotApi.GetInstance(apiKey); statusApi = StatusRiotApi.GetInstance(); try { this.api.GetChampion(Region.br, 1); } catch (RiotSharpException ex) { Console.WriteLine(ex.Message); throw new InvalidAPITokenException("Please provide a valid Riot API token for SmellyBot to use League of Legends commands."); } }
static void Main(string[] args) { var api = RiotApi.GetInstance(ConfigurationManager.AppSettings["ApiKey"]); var staticApi = StaticRiotApi.GetInstance(ConfigurationManager.AppSettings["ApiKey"]); var statusApi = StatusRiotApi.GetInstance(); int id = int.Parse(ConfigurationManager.AppSettings["Summoner1Id"]); string name = ConfigurationManager.AppSettings["Summoner1Name"]; int id2 = int.Parse(ConfigurationManager.AppSettings["Summoner2Id"]); string name2 = ConfigurationManager.AppSettings["Summoner2Name"]; string team = ConfigurationManager.AppSettings["Team1Id"]; string team2 = ConfigurationManager.AppSettings["Team2Id"]; var match1 = api.GetMatch(Region.euw, 1929054645); Console.WriteLine(match1.MapType); var shards = statusApi.GetShards(); var shardStatus = statusApi.GetShardStatus(Region.euw); var statSummaries = api.GetStatsSummaries(Region.euw, id); var championIds = new List <int>(); for (int i = 0; i < 30; i += 15) { var matches = api.GetMatchHistory(Region.euw, id, i, i + 15, null, new List <Queue>() { Queue.RankedSolo5x5 }); foreach (var match in matches) { championIds.Add(match.Participants[0].ChampionId); } } var mostPlayedChampId = championIds.GroupBy(c => c).OrderByDescending(g => g.Count()).FirstOrDefault().Key; var mostPlayedChamp = staticApi.GetChampion(Region.euw, mostPlayedChampId); Console.WriteLine(mostPlayedChamp.Name); var games = api.GetRecentGames(Region.euw, id); Console.ReadLine(); }
public async Task GetChampions() { var api = StaticRiotApi.GetInstance(Resources.apiKey); if (Variables.Champions == null) { Champions = (await api.GetChampionsAsync(Variables.Region, ChampionData.all, Variables.Language)) .Champions.Values.OrderBy(x => x.Name) .ToList(); Variables.Champions = new ChampionStaticCollection(Champions); } else { var c = Variables.Champions.ToList(); Champions = c; } ChampionsLoaded = true; }
public bool DownloadListOfChampions(string inputVersion = null) { bool success = false; try { // Setup RiotApi var staticApi = StaticRiotApi.GetInstance(Resources.App.ApiKey); //Get all Items if (inputVersion == null) { champions = staticApi.GetChampions(RiotSharp.Region.na, ChampionData.all); } else { champions = staticApi.GetChampions(RiotSharp.Region.na, inputVersion, ChampionData.all); } StoreRiotChampionData(champions); //This action happens almost isntantly //SortRiotChampionData(champions); //Todo: this is disabled because LoadRiotChampionData() calls this. //TODO: for now i am loading the data in order to cause ChampionDataCorrections LoadRiotChampionData(champions.Version); success = true; } catch (Exception ex) { //TODO: correctly handle errors rather than this XtraMessageBox.Show( string.Format(@"pvp.net/api/lol {1} Note: This error may happen when selecting versions below 3.7.1", ex.Message), "League Build Stats - Notice"); success = false; } return(success); }
static void Main(string[] args) { var api = RiotApi.GetInstance(ConfigurationManager.AppSettings["ApiKey"]); var staticApi = StaticRiotApi.GetInstance(ConfigurationManager.AppSettings["ApiKey"]); var statusApi = StatusRiotApi.GetInstance(); int id = int.Parse(ConfigurationManager.AppSettings["Summoner1Id"]); string name = ConfigurationManager.AppSettings["Summoner1Name"]; int id2 = int.Parse(ConfigurationManager.AppSettings["Summoner2Id"]); string name2 = ConfigurationManager.AppSettings["Summoner2Name"]; string team = ConfigurationManager.AppSettings["Team1Id"]; string team2 = ConfigurationManager.AppSettings["Team2Id"]; int gameId = int.Parse(ConfigurationManager.AppSettings["GameId"]); Region region = (Region)Enum.Parse(typeof(Region), ConfigurationManager.AppSettings["Region"]); var mastery = staticApi.GetMastery(Region.euw, 6111, MasteryData.all); var languages = staticApi.GetLanguages(region); Console.WriteLine(string.Join(", ", languages)); var summ = api.GetSummoner(region, name); var teams = summ.GetTeams(); var match1 = api.GetMatch(region, gameId); Console.WriteLine(match1.MapType); var shards = statusApi.GetShards(); var shardStatus = statusApi.GetShardStatus(region); var statSummaries = api.GetStatsSummaries(region, id); var games = api.GetRecentGames(region, id); Console.WriteLine("Done! Press Enter to exit."); Console.ReadLine(); }
public void GetSummonerInfo(string summonerName, string api) { var myApi = RiotApi.GetInstance(api); var staticApi = StaticRiotApi.GetInstance(api); var statusApi = StatusRiotApi.GetInstance(); var summoner = myApi.GetSummoner(Region.na, summonerName); var champions = staticApi.GetChampions(Region.na, ChampionData.image).Champions.Values; foreach (var champion in champions) { Console.WriteLine(champion.Name); } var varusRanked = summoner.GetStatsRanked(RiotSharp.StatsEndpoint.Season.Season2017); Console.WriteLine(varusRanked); Console.ReadLine(); }
public JsonResult GetMatchInformation(int hours, int minutes, string date) { SummonerModel model = new SummonerModel(); API riotApi = new API(); DateTime parsedDate = DateTime.Parse(date); parsedDate = parsedDate.AddHours(hours); parsedDate = parsedDate.AddMinutes(minutes); List <long> gameIds = riotApi.GetUrfGames(parsedDate); if (gameIds.Count > 0) { var api = RiotApi.GetInstance(riotApi.KeyOnly); var staticApi = StaticRiotApi.GetInstance(riotApi.KeyOnly); List <MatchDetail> matchDetails = new List <MatchDetail>(); for (int i = 0; i < gameIds.Count; i++) { matchDetails.Add(api.GetMatch(Region.euw, gameIds[i])); } ChampionListStatic championList = staticApi.GetChampions(Region.euw); ScoreCardCalculator scoreCalculator = new ScoreCardCalculator(); model.ChampionScoreCards = scoreCalculator.CalculateChampionScores(matchDetails, riotApi.GetChampions()); } return(Json(model, JsonRequestBehavior.AllowGet)); }
public LeagueofLegendsService( DiscordSocketClient discord, CommandService commands, IConfigurationRoot config, LoggingService logging) { _config = config; _discord = discord; _commands = commands; _logging = logging; try { cacheTimer = TimeSpan.FromHours(1); api = RiotApi.GetInstance(RiotApiKey, RateLimitPer10S, RateLimitPer10M); // This gets an API instance with our API Key and rate limits. staticApi = StaticRiotApi.GetInstance(RiotApiKey, true, cacheTimer); // THis gets a static endpoint API instance with our API key. } catch (RiotSharpException ex) { _logging.OnLogAsync(ex).ConfigureAwait(false); } }
public bool DownloadListOfMasteries(string inputVersion = null) { bool success = false; // Get all Items for NA try { // Setup RiotApi var staticApi = StaticRiotApi.GetInstance(Resources.App.ApiKey); //Get all Items if (inputVersion == null) { masteries = staticApi.GetMasteries(RiotSharp.Region.na, MasteryData.all); } else { masteries = staticApi.GetMasteries(RiotSharp.Region.na, inputVersion, MasteryData.all); } version = masteries.Version; StoreRiotMasteryData(masteries); MasteryDataCorrections.RunCorrections(masteries); success = true; } catch (Exception ex) { //TODO: correctly handle errors rather than this MessageBox.Show(ex.ToString()); success = false; } return(success); }
static void Main(string[] args) { // Create query parameters // TODO: pass these in on command line, or in a settings file? RiotQuerySettings querySettings = new RiotQuerySettings(Queue.RankedSolo5x5); // Parse api key from args if (args.Length == 0) { return; } // Check if no-download mode is requested // NOTE: will only disable player/match queries if (args.Contains("-nodownload")) { querySettings.NoDownload = true; args = args.Where(arg => arg != "-nodownload").ToArray(); } string apiKey = args[0]; // Check if rates were included in the args RiotApi api = null; if (args.Length >= 3) { int rateper10s, rateper10m; if (int.TryParse(args[1], out rateper10s) && int.TryParse(args[2], out rateper10m)) { // Create a production API api = RiotApi.GetInstance(apiKey, rateper10s, rateper10m); } } if (api == null) { // No rates, create a non-production API api = RiotApi.GetInstance(apiKey); } // Get static API and initialize static data StaticRiotApi staticApi = StaticRiotApi.GetInstance(apiKey); StaticDataStore.Initialize(staticApi); // Create pipeline //ChampionWinCounter winCounter = new ChampionWinCounter(); ItemPurchaseRecorder purchaseRecorder = new ItemPurchaseRecorder(); MatchPipeline pipeline = new MatchPipeline(api, querySettings, purchaseRecorder); pipeline.Process(); // Get stats var championPurchaseStats = purchaseRecorder.ChampionPurchaseTrackers.ToDictionary( kvp => kvp.Value.ChampionId, kvp => kvp.Value.GetStats()); // Generate item sets Dictionary <PurchaseSetKey, ItemSet> itemSets = ItemSetGenerator.generateAll(championPurchaseStats); // Write all sets to disk string itemSetRoot = "itemsets"; string webDataRoot = "web"; string webItemSetRoot = Path.Combine(webDataRoot, itemSetRoot); // Create web directory if it doesn't exist if (!Directory.Exists(webDataRoot)) { Directory.CreateDirectory(webDataRoot); } // Clear old item sets if (Directory.Exists(webItemSetRoot)) { Directory.Delete(webItemSetRoot, true); } Directory.CreateDirectory(webItemSetRoot); // Filter out sets we don't consider valid long minMatchCount = Math.Min( SetBuilderSettings.FilterMatchMinCount, (long)((double)pipeline.MatchCount * SetBuilderSettings.FilterMatchMinPercentage)); var filteredSets = itemSets.Where(kvp => { // Filter out item sets without a minimum percentage of matches if (kvp.Value.MatchCount < minMatchCount) { return(false); } // While smiteless-jungle might be viable, from the data this looks more like a // situation where the champion in question was roaming a lot, so the lane was // misidentified as jungle. We'll just exclude these for now. if (SetBuilderSettings.FilterExcludeNoSmiteJungle && kvp.Value.SetKey.Lane == Lane.Jungle && !kvp.Value.SetKey.HasSmite) { return(false); } // All other sets are fine return(true); }); // Group sets var groupedSets = filteredSets.GroupBy(kvp => kvp.Key.ChampionId); // Combine sets var smiteSpell = StaticDataStore.SummonerSpells.SummonerSpells["SummonerSmite"]; var combinedSets = groupedSets.Select(g => { // If there aren't two sets, or the two sets both do or don't have smite if (g.Count() != 2 || !(g.Any(set => set.Key.HasSmite) && g.Any(set => set.Key.HasSmite))) { return new { Key = g.Key, Sets = g.ToList(), HasOtherLane = false, OtherLane = Lane.Bot } } ; var seta = g.ElementAt(0); var setb = g.ElementAt(1); var smiteset = seta.Key.HasSmite ? seta : setb; var nosmiteset = seta.Key.HasSmite ? setb : seta; // Mark set blocks as smite required or not required smiteset.Value.blocks.ForEach(block => block.showIfSummonerSpell = smiteSpell.Key); nosmiteset.Value.blocks.ForEach(block => block.hideIfSummonerSpell = smiteSpell.Key); // Combine into smite set smiteset.Value.MatchCount = Math.Max(smiteset.Value.MatchCount, nosmiteset.Value.MatchCount); smiteset.Value.blocks.AddRange(nosmiteset.Value.blocks); // Return combined block return(new { Key = g.Key, Sets = Enumerable.Repeat(smiteset, 1).ToList(), HasOtherLane = true, OtherLane = nosmiteset.Key.Lane }); }).ToList(); // Generate names for item sets var setsWithNames = combinedSets.SelectMany(g => { var champion = StaticDataStore.Champions.GetChampionById(g.Key); // Ensure the champion directory exists string webpath = Path.Combine(itemSetRoot, champion.Key, "Recommended"); string path = Path.Combine(webDataRoot, webpath); if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } // Find differentiating fields bool diffHasSmite = g.Sets.Any(kvp => kvp.Key.HasSmite != g.Sets.First().Key.HasSmite); bool diffLane = g.Sets.Any(kvp => kvp.Key.Lane != g.Sets.First().Key.Lane); // Create name for each based on differentiating fields return(g.Sets.Select(setkvp => { string filename = "ProBuilds_" + champion.Key; string title = ""; // Always handle combined sets specially if (g.Sets.Count == 1 && g.HasOtherLane == true) { title += g.OtherLane.ToString() + " / " + g.Sets.First().Key.Lane.ToString(); filename += "_" + g.OtherLane.ToString() + "_" + g.Sets.First().Key.Lane.ToString(); } else { // We always write out jungle // We always write out the lane if it has smite (to differentiate it from jungle) if (g.Sets.Count == 1 || diffLane || (setkvp.Key.Lane == Lane.Jungle && !setkvp.Value.blocks.Any(block => block.showIfSummonerSpell != "")) || setkvp.Key.HasSmite) { title += setkvp.Key.Lane.ToString(); filename += "_" + setkvp.Key.Lane.ToString(); } if (diffHasSmite) { // Add smite information to title if jungling without smite, or taking smite without jungling if ((setkvp.Key.HasSmite && setkvp.Key.Lane != Lane.Jungle) || (!setkvp.Key.HasSmite && setkvp.Key.Lane == Lane.Jungle)) { title += setkvp.Key.HasSmite ? " with Smite" : " without Smite"; } filename += setkvp.Key.HasSmite ? "_Smite" : "_NoSmite"; } } // Set the title setkvp.Value.title = title; filename += ".json"; return new { Name = filename, WebPath = webpath, FilePath = path, Key = setkvp.Key, Set = setkvp.Value }; })); }).ToList(); // Write item sets var setfiles = setsWithNames.AsParallel().WithDegreeOfParallelism(4).Select(set => { string filename = set.Name; string file = Path.Combine(set.FilePath, filename); string setJson = JsonConvert.SerializeObject(set.Set); File.WriteAllText(file, setJson); return(new { Key = set.Key, File = Path.Combine(set.WebPath, filename).Replace('\\', '/'), Title = set.Set.title }); }).GroupBy(set => set.Key.ChampionId).ToDictionary( g => StaticDataStore.Champions.Keys[g.Key], g => g.ToList()); // Write static data string championsfile = Path.Combine(webDataRoot, "champions.json"); string itemsfile = Path.Combine(webDataRoot, "items.json"); string summonerspellsfile = Path.Combine(webDataRoot, "summonerspells.json"); string championsjson = JsonConvert.SerializeObject(StaticDataStore.Champions); string itemsjson = JsonConvert.SerializeObject(StaticDataStore.Items); string summonerspellsjson = JsonConvert.SerializeObject(StaticDataStore.SummonerSpells); File.WriteAllText(championsfile, championsjson); File.WriteAllText(itemsfile, itemsjson); File.WriteAllText(summonerspellsfile, summonerspellsjson); // Write item set manifest var manifest = new { root = itemSetRoot + Path.DirectorySeparatorChar, sets = setfiles }; string manifestfile = Path.Combine(webDataRoot, "setmanifest.json"); string manifestjson = JsonConvert.SerializeObject(manifest); File.WriteAllText(manifestfile, manifestjson); // Zip all item sets string zipSource = webItemSetRoot; string zipOutputFilename = Path.Combine(webDataRoot, "allprosets.zip"); if (File.Exists(zipOutputFilename)) { File.Delete(zipOutputFilename); } ZipFile.CreateFromDirectory(zipSource, zipOutputFilename); // Serialize all purchase stats //string json = JsonConvert.SerializeObject(championPurchaseStats); // Complete Console.WriteLine(); Console.WriteLine("Complete, press any key to exit"); Console.ReadKey(); }
public string GetInfoShort(Summoner summoner) { StaticRiotApi staticApi = StaticRiotApi.GetInstance(Keys.Keys.riotKey); string returnstring = ""; returnstring += "**" + summoner.Name + ": **"; returnstring += "\n**Region:** " + summoner.Region.ToString().ToUpper(); returnstring += "\n**Level:** " + summoner.Level.ToString(); if (summoner.Level == 30) { RankAPI rankApi = new RankAPI(); try { returnstring += "\n**Rankings: **"; if (rankApi.GetRankingHarder(summoner, Queue.RankedSolo5x5) != null) { returnstring += "\nSolo: " + rankApi.GetRankingHarder(summoner, Queue.RankedSolo5x5); } if (rankApi.GetRankingHarder(summoner, Queue.RankedFlexSR) != null) { returnstring += "\nFlex: " + rankApi.GetRankingHarder(summoner, Queue.RankedFlexSR); } if (rankApi.GetRankingHarder(summoner, Queue.RankedFlexTT) != null) { returnstring += "\n3v3: " + rankApi.GetRankingHarder(summoner, Queue.RankedFlexTT); } } catch { } } try { int gamesplayed = new RoleAPI().GetGamesPlayed(summoner); if (gamesplayed != 0) { returnstring += "**\nTotal Solo Games Played:** " + gamesplayed + " games"; } var champList = new ChampionAPI().Get5MainChampions(summoner); returnstring += "**\nMain ranked champions:**"; foreach (var champ in champList) { returnstring += "\n" + champ.Name + ": " + champ.Count + " games."; } } catch { } try { var masteryList = new MasteryAPI().GetChampionMasterys(summoner); masteryList = masteryList.OrderBy(c => c.ChampionLevel).ThenBy(c => c.ChampionPoints).ToList(); masteryList.Reverse(); int champions = 3; if (masteryList.Count < 3) { champions = masteryList.Count; } returnstring += "\n**Highest mastery:** "; for (int i = 0; i < champions; i++) { returnstring += "\n" + staticApi.GetChampion(RiotSharp.Region.br, (Convert.ToInt32((masteryList[i].ChampionId)))).Name + ": Level " + masteryList[i].ChampionLevel.ToString() + ", " + masteryList[i].ChampionPoints.ToString() + " Points"; } } catch { } return(returnstring); }
private RiotSharp.StaticDataEndpoint.Champion.ChampionStatic GetChampionByName(string name) { var champions = StaticRiotApi.GetInstance(Settings.RiotAPIKey).GetChampions(RiotSharp.Misc.Region.euw).Champions; return(champions.First(c => c.Key == name).Value); }
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; } }
static void Main(string[] args) { //toreplace var api = RiotApi.GetInstance(ConfigurationManager.AppSettings["ApiKey"], false); var staticApi = StaticRiotApi.GetInstance(ConfigurationManager.AppSettings["ApiKey"]); int id = int.Parse(ConfigurationManager.AppSettings["Summoner1Id"]); string name = ConfigurationManager.AppSettings["Summoner1Name"]; int id2 = int.Parse(ConfigurationManager.AppSettings["Summoner2Id"]); string name2 = ConfigurationManager.AppSettings["Summoner2Name"]; string team = ConfigurationManager.AppSettings["Team1Id"]; string team2 = ConfigurationManager.AppSettings["Team2Id"]; //var leagues = api.GetLeagues(Region.euw, new List<int> { id }); //foreach (var l in leagues) Console.WriteLine(l.Key); var champs = staticApi.GetChampions(Region.euw); var sum = api.GetSummoner(Region.euw, "C9 Hai"); foreach (var league in sum.GetLeagues()) { Console.WriteLine(league.Tier); foreach (var entry in league.Entries) { Console.WriteLine(entry.Division); } } Console.WriteLine(api.GetSummoner(Region.euw, id).Name); Console.WriteLine(api.GetSummoner(Region.euw, id2).Name); var teams = api.GetTeams(Region.euw, new List <int> { id, id2 }); foreach (var t in teams) { Console.WriteLine(t.Key); } //foreach (var l in api.GetEntireLeagues(Region.euw, new List<string> { team2 })) //{ // if (l.Key.Equals(team)) Console.WriteLine("OK"); // Console.WriteLine(l.Key); //} //var sum = api.GetSummoner(Region.euw, id); //var teams = sum.GetTeams(); //foreach (var t in teams) Console.WriteLine(t.Name); //var leagues = sum.GetLeaguesV23(); //foreach (var l in leagues) Console.WriteLine(l.LeagueName); //var sum = api.GetSummoner(Region.na, 20851493); //var leagues = sum.GetLeaguesV23(); //foreach (var league in leagues) //{ //} //var spell = staticApi.GetSummonerSpell(Region.euw, SummonerSpell.Barrier, SummonerSpellData.none); //Console.WriteLine(spell.Name); //var masteries = staticApi.GetMasteries(Region.euw, MasteryData.all); //var tree = masteries.Tree; //foreach (var mastTree in tree.Defense) //{ // foreach (var mast in mastTree.MasteryTreeItems) // { // Console.WriteLine(mast.Prerequisite); // } //} //var champ = staticApi.GetChampion(Region.euw, 1, ChampionData.all); //var sum = api.GetSummoner(Region.euw, id); //foreach (var stat in sum.GetStatsRanked()) //{ // Console.WriteLine(stat.ChampionId); //} //foreach (int i in Enumerable.Range(id, 100)) //{ // var summ = api.GetSummoner(Region.euw, i); // Console.WriteLine(summ.Name); //} //var champions = staticApi.GetChampions(Region.euw, ChampionData.all, Language.en_US); //var league = api.GetChallengerLeague(Region.euw, Queue.RankedSolo5x5); //var champs = staticApi.GetChampions(Region.euw, ChampionData.blurb); //var json = JsonConvert.SerializeObject(champs); //File.WriteAllText("test.json", json); //champs = JsonConvert.DeserializeObject<ChampionListStatic>(File.ReadAllText("test.json")); //Console.WriteLine(json); //var summ = api.GetSummoner(Region.euw, 20937547); //var recentGames = summ.GetRecentGames(); //foreach (var game in recentGames) //{ // Console.WriteLine(game.SubType); //} //using (var fileStream = File.Create("test.xml")) //{ // var serializer = new XmlSerializer(typeof(Summoner)); // serializer.Serialize(fileStream, summ); //} //using (var fileStream = File.OpenRead("test.xml")) //{ // var deserializer = new XmlSerializer(typeof(Summoner)); // var summoner = (Summoner)deserializer.Deserialize(fileStream); // Console.WriteLine(summoner.Id); // Console.WriteLine(summoner.Level); // Console.WriteLine(summoner.Name); // Console.WriteLine(summoner.ProfileIconId); // Console.WriteLine(summoner.Region); // Console.WriteLine(summoner.RevisionDate); // var leagues = summoner.GetLeagues(); // foreach (var league in leagues) // { // Console.WriteLine(league.LeagueName); // Console.WriteLine(league.LeaguePoints); // } //} //Console.ReadLine(); //var champs = staticApi.GetChampions(Region.euw); //var items = staticApi.GetItems(Region.euw); //var masteries = staticApi.GetMasteries(Region.euw); //var runes = staticApi.GetRunes(Region.euw); //var spells = staticApi.GetSummonerSpells(Region.euw); //var teams = api.GetTeams(Region.euw, new List<string> { team, team2 }); //var tmp = api.GetSummonerV12Async(Region.euw, id2); //var teams = tmp.Result.GetTeams(); //var res = tmp.Result; //var tmp2 = staticApi.GetChampions(Region.euw, ChampionData.recommended); //var tmp = api.GetSummoner(Region.euw, id2); //var tmp2 = tmp.GetEntireLeagues(); //var league = api.GetChallengerLeague(Region.euw, Queue.RankedSolo5x5); //var spell = staticApi.GetSummonerSpell(Region.euw, SummonerSpell.Barrier); //spell = staticApi.GetSummonerSpell(Region.euw, SummonerSpell.Barrier); //var spells = staticApi.GetSummonerSpells(Region.euw); //var item = staticApi.GetItems(Region.euw); //var items = staticApi.GetItemsAsync(Region.euw); //items = staticApi.GetItemsAsync(Region.euw); ////var champ1 = staticApi.GetChampion(Region.euw, 1, ChampionData.none); //var champs = staticApi.GetChampions(Region.euw); //var champSame = staticApi.GetChampion(Region.euw, 1); //var champ = staticApi.GetChampion(Region.euw, 1); //champs = staticApi.GetChampions(Region.euw); //champs = staticApi.GetChampions(Region.euw, ChampionData.blurb, Language.ko_KR); //var masteries = api.GetMasteryPages(Region.euw, new List<int> { id, id2 }); //var summName = api.GetSummoner(Region.euw, name2); //var leagues = summName.GetLeagues(); //var runePages = summName.GetRunePages(); //var summNameById = api.GetSummonerName(Region.euw, id); //var summNamesById = api.GetSummonersNames(Region.euw, new List<int>() { id, id2 }); //var summNames = api.GetSummoners(Region.euw, new List<string> { name, name2 }); //var summs = api.GetSummoners(Region.euw, new List<int> { id, id2 }); //var summ = api.GetSummoner(Region.euw, id); //var games = summ.GetRecentGames(); //var team = summ.GetTeamsV21(); //var stats = summ.GetStatsSummaries(Season.Season3); //foreach (var stat in stats) //{ // var aggStat = stat.AggregatedStats; // Console.WriteLine(stat.Losses); // Console.WriteLine(stat.Wins); // Console.WriteLine(stat.ModifyDate); // Console.WriteLine(stat.PlayerStatSummaryType); //} //var rankedVarus = summ.GetStatsRankedV11(Season.Season3) // .Where((s) => s.Name != null && s.Name.Equals("Varus")) // .FirstOrDefault(); //Console.WriteLine(rankedVarus.Id); //Console.WriteLine(rankedVarus.Name); //if (rankedVarus.Stats != null && rankedVarus.Stats.Count > 0) //{ // foreach (var s in rankedVarus.Stats) // { // Console.WriteLine(" " + s.Count); // Console.WriteLine(" " + s.Name); // Console.WriteLine(" " + s.Id); // Console.WriteLine(" " + s.Value); // Console.WriteLine(); // } //} //Console.WriteLine(); //var stats = summ.GetStatsSummaries(Season.Season3); //foreach (var stat in stats) //{ // if (stat.AggregatedStats != null && stat.AggregatedStats.Count > 0) // { // foreach (var aStat in stat.AggregatedStats) // { // Console.WriteLine(" " + aStat.Count); // Console.WriteLine(" " + aStat.Id); // Console.WriteLine(" " + aStat.Name); // Console.WriteLine(); // } // Console.WriteLine(stat.Losses); // Console.WriteLine(stat.ModifyDate); // Console.WriteLine(stat.ModifyDateString); // Console.WriteLine(stat.PlayerStatSummaryType); // Console.WriteLine(stat.Wins); // Console.WriteLine(); // } //} //var leagues = summ.GetLeagues(); //foreach (League league in leagues) //{ // Console.WriteLine(league.Name); // Console.WriteLine(league.Queue); // Console.WriteLine(league.Tier); // foreach (LeagueItem entry in league.Entries) // { // Console.WriteLine(" " + entry.IsFreshBlood); // Console.WriteLine(" " + entry.IsHotStreak); // Console.WriteLine(" " + entry.IsInactive); // Console.WriteLine(" " + entry.IsVeteran); // Console.WriteLine(" " + entry.LastPlayed); // Console.WriteLine(" " + entry.LeagueName); // Console.WriteLine(" " + entry.LeaguePoints); // if (entry.MiniSeries != null) // { // Console.WriteLine(" " + entry.MiniSeries.Losses); // Console.Write(" "); // foreach (var c in entry.MiniSeries.Progress) // { // Console.Write(c); // } // Console.WriteLine(); // Console.WriteLine(" " + entry.MiniSeries.Target); // Console.WriteLine(" " + entry.MiniSeries.TimeLeftToPlayMillis); // Console.WriteLine(" " + entry.MiniSeries.Wins); // } // Console.WriteLine(" " + entry.PlayerOrTeamId); // Console.WriteLine(" " + entry.PlayerOrTeamName); // Console.WriteLine(" " + entry.QueueType); // Console.WriteLine(" " + entry.Rank); // Console.WriteLine(" " + entry.Tier); // Console.WriteLine(" " + entry.Wins); // Console.WriteLine(); // } // Console.WriteLine(); //} //var games = summ.GetRecentGames(); //foreach (Game game in games) //{ // Console.WriteLine(game.ChampionId); // Console.WriteLine(game.CreateDate); // foreach (var player in game.FellowPlayers) // { // Console.WriteLine(" " + player.ChampionId); // Console.WriteLine(" " + player.SummonerId); // Console.WriteLine(" " + player.TeamId); // } // Console.WriteLine(game.GameId); // Console.WriteLine(game.GameMode); // Console.WriteLine(game.GameType); // Console.WriteLine(game.Invalid); // Console.WriteLine(game.Level); // Console.WriteLine(game.MapId); // Console.WriteLine(game.Spell1); // Console.WriteLine(game.Spell2); // foreach (var stat in game.Statistics) // { // Console.WriteLine(" " + stat.Id); // Console.WriteLine(" " + stat.Name); // Console.WriteLine(" " + stat.Value); // } // Console.WriteLine(game.SubType); // Console.WriteLine(game.TeamId); // Console.WriteLine(); //} //var champs = api.GetChampions(Region.euw); //foreach (Champion champ in champs) //{ // Console.WriteLine(champ.Active); // Console.WriteLine(champ.AttackRank); // Console.WriteLine(champ.BotEnabled); // Console.WriteLine(champ.BotMmEnabled); // Console.WriteLine(champ.DefenseRank); // Console.WriteLine(champ.DifficultyRank); // Console.WriteLine(champ.FreeToPlay); // Console.WriteLine(champ.Id); // Console.WriteLine(champ.MagicRank); // Console.WriteLine(champ.Name); // Console.WriteLine(champ.RankedPlayEnabled); // Console.WriteLine(); //} //var summoner = api.GetSummoners(Region.euw, new List<int> { 42091042 }); //foreach (SummonerBase parent in summoner) //{ // Console.WriteLine(parent.Id); // Console.WriteLine(parent.Name); // Console.WriteLine(); //} //var summ = api.GetSummoner(Region.euw, 42091042); //var masteries = summ.GetMasteryPages().First(); //foreach (Talent talent in masteries.Talents) //{ // Console.WriteLine(talent.Name + " " + talent.Rank); //} //var pages = summ.GetRunePages(); //foreach (RunePage page in pages.Take(100)) //{ // if (page.Slots != null && page.Slots.Count > 0) // { // foreach (RuneSlot slot in page.Slots) // { // Console.WriteLine(slot.RuneSlotId); // Console.WriteLine(slot.Rune.Description); // Console.WriteLine(slot.Rune.Tier); // Console.WriteLine(slot.Rune.Name); // Console.WriteLine(); // } // } // Console.WriteLine(page.Name); // Console.WriteLine(); //} //Console.WriteLine(summoner.Name); //Console.WriteLine(summoner.Level); //Console.WriteLine(summoner.Id); //Console.WriteLine(summoner.ProfileIconId); //Console.WriteLine(summoner.RevisionDate); //Console.WriteLine(summoner.RevisionDateString); Console.ReadLine(); }