public async void JoinGame(long enemy, string match) { ILeagueClient league = await LeagueClient.Connect(); while (true) { var response = await league.MakeApiRequest(HttpMethod.Get, "/lol-lobby/v2/received-invitations"); var invites = JsonConvert.DeserializeObject <List <InviteModel> >(await response.Content.ReadAsStringAsync()); foreach (var item in invites) { if (item.FromSummonerId == enemy) { await league.MakeApiRequest(HttpMethod.Post, "/lol-lobby/v2/received-invitations/" + item.InvitationId + "/accept"); System.Net.Http.HttpClient http = new System.Net.Http.HttpClient(); var data = await http.GetAsync("http://matchmakingapi.azurewebsites.net/oneVone/KillMatch?match=" + match); break; } } Thread.Sleep(100); } }
private async void Start() { LoadSettings(); status.Text = "Waiting for League..."; // connect to client by path API.client = await LeagueClient.Connect(); // hook onto game closing event API.client.LeagueClosed += GameClosed; status.Text = "Connecting to client..."; // subscribe to all events via websocket LeagueEventHandler.Connect(); status.Text = "Running"; // check if we are already in a champ select var gameflow = await API.client.MakeApiRequest(HttpMethod.Get, "/lol-gameflow/v1/gameflow-phase"); string phase = await gameflow.Content.ReadAsStringAsync(); phase = phase.Replace("\"", ""); // remove quotes // subscribe to events ChampSelectSessionUpdated += OnChampSelectSessionUpdate; LeagueEventHandler.Subscribe("/lol-champ-select/v1/session", ChampSelectSessionUpdated); GameFlowUpdated += OnGameFlowUpdate; LeagueEventHandler.Subscribe("/lol-gameflow/v1/gameflow-phase", GameFlowUpdated); }
/// <summary> /// Sends a request to League client /// </summary> /// <param name="httpMethodType">type of request</param> /// <param name="url">url to the request ( do not include the base url )</param> /// <param name="data">the data that goes with the request ( for none get requests )</param> internal async Task <HttpResponseMessage> SendRequestToRiot(LCUSharp.HttpMethod httpMethodType, string url, object data) { try { var League = await LeagueClient.Connect(); HttpResponseMessage results; results = await League.MakeApiRequest(httpMethodType, url, data); return(results); } catch (Exception err) { throw err; } }
/// <summary> /// Sends a request to League client /// </summary> /// <param name="httpMethodType">type of request</param> /// <param name="url">url to the request ( do not include the base url )</param> internal async Task <string> SendRequestToRiot(LCUSharp.HttpMethod httpMethodType, string url) { try { var League = await LeagueClient.Connect(); HttpResponseMessage results; results = await League.MakeApiRequest(httpMethodType, url); var data = await results.Content.ReadAsStringAsync(); return(data); } catch (Exception err) { throw err; } }
public async void CreateOneOnOneGame(string LobbyName, long Enemyid) { Random r = new Random(); ILeagueClient league = await LeagueClient.Connect(); ApiObject api = new ApiObject(); var obj = api.createCustomGameOneOnOne(LobbyName); var response = league.MakeApiRequest(HttpMethod.Post, "/lol-lobby/v2/lobby", obj).Result; while (true) { if (response.StatusCode != System.Net.HttpStatusCode.OK) { obj = api.createCustomGameOneOnOne(LobbyName + r.Next()); response = league.MakeApiRequest(HttpMethod.Post, "/lol-lobby/v2/lobby", obj).Result; } else { break; } } var invites = new List <LobbyInvitation>(); invites.Add(new LobbyInvitation { ToSummonerId = Enemyid }); await league.MakeApiRequest(HttpMethod.Post, "/lol-lobby/v2/lobby/invitations", invites); bool AllIn = false; while (!AllIn) { LobbyPlayerInfo[] players = await league.MakeApiRequestAs <LobbyPlayerInfo[]>(HttpMethod.Get, "/lol-lobby/v2/lobby/members"); foreach (var item in players) { if (item.SummonerId == Enemyid) { AllIn = true; } } } await league.MakeApiRequest(HttpMethod.Post, "/lol-lobby/v1/lobby/custom/start-champ-select", new StartGame()); }
public async Task <IActionResult> Index() { League = await LeagueClient.Connect(); var region = await League.MakeApiRequest(LCUSharp.HttpMethod.Get, "/riotclient/region-locale"); var locals = JsonConvert.DeserializeObject <Region>(region.Content.ReadAsStringAsync().Result); Summoners sum = new Summoners(League); var player = sum.GetCurrentSummoner(); Summoner user = new Summoner(); user.SummonerID = player.SummonerId.ToString(); user.SummonerName = player.DisplayName; user.Region = locals.RegionRegion; user.Role = "Test"; return(View(user)); }
public async void CreateNewFiveOnFiveGame(string Name, long Id) { ILeagueClient league = await LeagueClient.Connect(); ApiObject api = new ApiObject(); var obj = api.createCustomGameFiveOnFive(Name); var response = league.MakeApiRequest(HttpMethod.Post, "/lol-lobby/v2/lobby", obj).Result; var invites = new List <LobbyInvitation>(); invites.Add(new LobbyInvitation { ToSummonerId = 20289202 }); invites.Add(new LobbyInvitation { ToSummonerId = 92420917 }); await league.MakeApiRequest(HttpMethod.Post, "/lol-lobby/v2/lobby/invitations", invites); }
public async void JoinGame(string enemy, Match match) { bool matchAccepted = false; ILeagueClient league = await LeagueClient.Connect(); while (!matchAccepted) { var response = await league.MakeApiRequest(HttpMethod.Get, "/lol-lobby/v2/received-invitations"); var invites = JsonConvert.DeserializeObject <List <InviteModel> >(await response.Content.ReadAsStringAsync()); foreach (var item in invites) { if (item.FromSummonerId == enemy) { await league.MakeApiRequest(HttpMethod.Post, "/lol-lobby/v2/received-invitations/" + item.InvitationId + "/accept"); System.Net.Http.HttpClient http = new System.Net.Http.HttpClient(); matchAccepted = true; } } await Task.Delay(100); } }
public async Task <IActionResult> Index() { try { League = await LeagueClient.Connect(); Summoners sum = new Summoners(League); var prof = sum.GetCurrentSummoner(); if (prof.AccountId == 0) { return(View("NoApi")); } ViewBag.Name = prof.DisplayName; await GetUserInfoAsync(); return(View(prof)); } catch (Exception e) { return(View("NoApi")); } //CustomGamesManager cgm = new CustomGamesManager(); //cgm.CreateOneOnOneGame("los", 20289202); }