public async Task EventExampleAsync() { LCUApi = await LeagueClientApi.ConnectAsync(); GameFlowChanged += OnGameFlowChanged; LCUApi.EventHandler.Subscribe("/lol-gameflow/v1/gameflow-phase", GameFlowChanged); }
private async void button5_Click(object sender, EventArgs e) { api = await LCUSharp.LeagueClientApi.ConnectAsync(); await api.RiotClientEndpoint.ShowUxAsync(); // parse all players names from textbox string unparsed = richTextBox1.Text; string[] namesArr = unparsed.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); for (int i = 0; i < namesArr.Length; i++) { // remove white space and everything before including the period namesArr[i] = namesArr[i].Replace(" ", ""); if (namesArr[i].Contains(".")) { // remove everything before and upto dot namesArr[i] = namesArr[i].Substring(namesArr[i].IndexOf('.') + 1); } // ready to go! } foreach (var playerName in namesArr) { await InvitePlayer(playerName); } }
public ChampionSelectService(LeagueClientApi leagueClient) { OnChampSelectSessionChanged += OnChampSelectSessionTriggered; LeagueClient = leagueClient; LeagueClient.EventHandler.Subscribe(Endpoint, (object sender, LeagueEvent ev) => OnChampSelectSessionChanged?.Invoke(sender, ev)); }
public static async Task InitializeClientAsync() { //LCU API Documentation: https://lcu.vivide.re/ Client = await LeagueClientApi.ConnectAsync(); Client.EventHandler.Subscribe("/lol-champ-select/v1/session", OnChampSelect); IsInitialized = true; }
protected override async void OnEnable() { base.OnEnable(); api = await LeagueClientApi.ConnectAsync(); //await CreateLobbyAsync(); }
protected async override void OnEnable() { base.OnEnable(); // Initialize a connection to the league client. api = await LeagueClientApi.ConnectAsync(); api.EventHandler.Subscribe("/lol-matchmaking/v1/ready-check", OnReadyCheck); }
private async void button3_Click(object sender, EventArgs e) { api = await LCUSharp.LeagueClientApi.ConnectAsync(); await api.RiotClientEndpoint.ShowUxAsync(); // join it! await JoinCustomGame(); }
public async void ChangeSummonerIcon(uint profileIconId) { // Initialize a connection to the league client. var api = await LeagueClientApi.ConnectAsync(); // Update the current summoner's profile icon var body = new { profileIconId }; var queryParameters = Enumerable.Empty <string>(); await api.RequestHandler.GetJsonResponseAsync(HttpMethod.Put, "lol-summoner/v1/current-summoner/icon", queryParameters, body); }
async void DisenchantOwnedChampions() { var api = await LeagueClientApi.ConnectAsync(); foreach (var item in OwnedItems.Where(p => p.displayCategories == "CHAMPION")) { Console.WriteLine(item.itemDesc); //string res = await api.RequestHandler.GetJsonResponseAsync(HttpMethod.Post, $"/lol-loot/v1/player-loot/CURRENCY_champion", new string[0], $"[{item.lootId}]"); string res = await api.RequestHandler.GetJsonResponseAsync(HttpMethod.Post, $"/lol-loot/v1/recipes/CURRENCY_champion", new string[0], $"[\"{item.lootId}\"]"); } }
private async Task <LeagueClientApi> ConnectToClient() { Logging.Info("Connecting to League Client"); var stopwatch = Stopwatch.StartNew(); var api = await LeagueClientApi.ConnectAsync(); api.EventHandler.Subscribe("/lol-gameflow/v1/gameflow-phase", ClientStateChanged); api.EventHandler.Subscribe("/lol-champ-select/v1/session", ChampSelectChanged); api.EventHandler.Subscribe("/lol-champ-select/vi/sfx-notifications", ChampSelectSFXChanged); stopwatch.Stop(); State.Client.State.LeagueConntected(); Logging.Info($"Connected to League Client ({stopwatch.ElapsedMilliseconds} ms)."); return(api); }
private async void InitConnection() { ClientAPI = await ConnectToClient(); ClientAPI.Disconnected += async(e, a) => { State.Client.State.LeagueDisconnected(); Logging.Info("Client Disconnected! Attempting to reconnect..."); await ClientAPI.ReconnectAsync(); State.Client.State.LeagueConntected(); Logging.Info("Client Reconnected!"); }; }
private async void button1_Click(object sender, EventArgs e) { // Initialize a connection to the league client. var api = await LeagueClientApi.ConnectAsync(); // Update the current summoner's profile icon to 23. string request = @"{ customGameLobby: { configuration: { gameMode: 'PRACTICETOOL', gameMutator: '', mapId: 11, mutators: { id: 1 }, spectatorPolicy: 'NotAllowed', teamSize: 5 }, lobbyName: 'Practice Tool', lobbyPassword: null }, isCustom: true }"; JObject body = JObject.Parse(request); var queryParameters = Enumerable.Empty <string>(); try { await api.RequestHandler.GetJsonResponseAsync(HttpMethod.Post, "/lol-lobby/v2/lobby", queryParameters, body); string messageBoxText = "A lobby has been created"; string caption = "INFO"; MessageBoxButton button = MessageBoxButton.OK; MessageBoxImage icon = MessageBoxImage.Information; System.Windows.MessageBox.Show(messageBoxText, caption, button, icon); } catch (Exception) { string messageBoxText = "There was an error"; string caption = "ERROR"; MessageBoxButton button = MessageBoxButton.OK; MessageBoxImage icon = MessageBoxImage.Error; System.Windows.MessageBox.Show(messageBoxText, caption, button, icon); System.Windows.Forms.Application.Exit(); } }
async Task <LootItem[]> GetItems() { var api = await LeagueClientApi.ConnectAsync(); try { string res = await api.RequestHandler.GetJsonResponseAsync(HttpMethod.Get, "/lol-loot/v1/player-loot"); return(JsonConvert.DeserializeObject <LootItem[]>(res)); } catch (Exception ex) { Console.WriteLine(ex); return(new LootItem[0]); } }
async void DisenchantDuplicates() { var api = await LeagueClientApi.ConnectAsync(); foreach (var item in OwnedItems) { string body = JsonConvert.SerializeObject(item.lootId, Formatting.Indented); //string res = await api.RequestHandler.GetJsonResponseAsync(HttpMethod.Post, $"/lol-loot/v1/recipes/{item.disenchantLootName}/craft", new string[0], $"[{item.lootId}]"); string res = await api.RequestHandler.GetJsonResponseAsync(HttpMethod.Post, $"/lol-loot/v1/player-loot/CHAMPION_31/context-menu"); //string res = await api.RequestHandler.GetJsonResponseAsync(HttpMethod.Get, $"/lol-loot/v1/recipes/initial-item/{lootId}", new string[0], $"[{item.lootId}]"); //Console.WriteLine(res); } }
private async void button1_Click(object sender, EventArgs e) { api = await LCUSharp.LeagueClientApi.ConnectAsync(); await api.RiotClientEndpoint.ShowUxAsync(); // create game await CreateCustomGame(); // after game creation, obtain lobby id await Task.Delay(1000); var lobby = await GetCustomLobby(); textBox1.Text = lobby.id.ToString(); }
public async Task JoinCustomGame() { // join custom game by id api = await LCUSharp.LeagueClientApi.ConnectAsync(); string url = $"lol-lobby/v1/custom-games/{textBox2.Text}/join"; var body = new { asSpectator = false, password = lobbyPassword }; var queryParameters = Enumerable.Empty <string>(); try { var json = await api.RequestHandler.GetJsonResponseAsync(HttpMethod.Post, url, queryParameters, body); } catch (Exception ex) { MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
public LeagueEnhancer() { Application.ApplicationExit += OnApplicationExit; LeagueClient = LeagueClientApi.ConnectAsync().GetAwaiter().GetResult(); // Register Services Services = new ServiceCollection() .AddSingleton(LeagueClient) .AddSingleton <ChampionSelectService>() .AddSingleton <NotificationService>() .AddSingleton <ChampionService>() .AddSingleton <QueueService>() .BuildServiceProvider(); // Initializing Console.WriteLine("Initializing..."); InitializeModules(); InitializeNotifyIcon(); }
private async void OnReadyCheck(object sender, LeagueEvent e) { ReadyCheckResponse?res; try { res = e?.Data?.ToObject <ReadyCheckResponse>(); } catch { return; } if (autoAccept && res?.playerResponse == PlayerResponse.None) { Console.WriteLine("Game found!"); var api = await LeagueClientApi.ConnectAsync(); await api.RequestHandler.GetJsonResponseAsync(HttpMethod.Post, "/lol-matchmaking/v1/ready-check/accept"); Console.WriteLine("Accepted Readycheck!"); } }