Exemplo n.º 1
0
        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);
        }
Exemplo n.º 2
0
        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);
            }
        }
Exemplo n.º 3
0
 public ReplayManager()
 {
     InitializeComponent();
     //Remove the tab after intializing it
     metroTabControl.TabPages.Remove(tabMatchHistory);
     _leagueClient = new LeagueClient(OnError, OnLeagueClientLoggedIn, OnLeagueClientClosed);
 }
Exemplo n.º 4
0
        public MatchInfo(LeagueClient _leagueClient, int champId, int spell1, int spell2, int item1,
                         int item2, int item3, int item4, int item5, int item6, int item7, int kill, int deaths, int assists, string webUrl,
                         UInt64 matchId, Func <UInt64, String> DownloadReplayCall, DateTime matchDate, Int32 gameLength)
        {
            InitializeComponent();
            this.DownloadReplayCall = DownloadReplayCall;
            this.matchId            = matchId;
            picChampion.Image       = _leagueClient.GetChampionIcon(champId);
            picSummonerSpell1.Image = _leagueClient.GetSummonerSpellIcon(spell1);
            picSummonerSpell2.Image = _leagueClient.GetSummonerSpellIcon(spell2);
            picItem1.Image          = _leagueClient.GetItemIcon(item1);
            picItem2.Image          = _leagueClient.GetItemIcon(item2);
            picItem3.Image          = _leagueClient.GetItemIcon(item3);
            picItem4.Image          = _leagueClient.GetItemIcon(item4);
            picItem5.Image          = _leagueClient.GetItemIcon(item5);
            picItem6.Image          = _leagueClient.GetItemIcon(item6);
            picItem7.Image          = _leagueClient.GetItemIcon(item7);
            lblMatchDate.Text       = matchDate.ToShortDateString();
            TimeSpan t = TimeSpan.FromSeconds(gameLength);

            lblGameLength.Text = string.Format("{0:D2}m:{1:D2}s", t.Minutes, t.Seconds);
            SharableWebUrl     = webUrl;
            if (String.IsNullOrEmpty(SharableWebUrl))
            {
                btnOpenMatchHistoryWebpage.Visible = false;
            }
        }
Exemplo n.º 5
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string sportID = Request.QueryString["SportID"];
            //Delete Teams
            //Delete Team Image First
            //Delete Team Players
            //Delete Record in Sport League BT

            //Delete Team players
            PlayerServiceClient playerClient = new PlayerServiceClient();
            string dl_Player = playerClient.Dl_PlayersBySportID(sportID);

            //Delete Team Image
            FileClient flClient = new FileClient();
            string     dl_Image = flClient.deleteTeamImageBySportID(sportID);

            //Delete from  SportLeague Bridging table
            LeagueClient lgClient         = new LeagueClient();
            string       dl_BridgingTable = lgClient.dl_SprotLeague_BTByID(sportID);

            //Now delete the team
            int LoggedID               = Convert.ToInt32(Session["ID"]);
            TeamServiceClient tsc      = new TeamServiceClient();
            string            dl_Sport = tsc.DeleteTeamByID(sportID);

            if (dl_Sport.Contains("success"))
            {
                Response.Redirect("TeamManagement.aspx?UserID=" + LoggedID);
            }
        }
Exemplo n.º 6
0
 public AppManager(MainWindow window)
 {
     mainWindow    = window;
     ViewModel     = new ViewModel(mainWindow, this);
     requestQueue  = new RequestQueue(this);
     hextechSocket = new HextechSocket(this);
     leagueClient  = new LeagueClient(this);
     ViewModel.EndInit();
 }
Exemplo n.º 7
0
        protected void btnRegTeam_Click(object sender, EventArgs e)
        {
            //CreateLeagueTeams(Team _teams)
            Team team = new Team();

            team.Name       = txtT_Name.Text;
            team.LeagueName = txtL_Name.Text;
            LeagueClient lc  = new LeagueClient();
            string       res = lc.CreateLeagueTeams(team);
        }
Exemplo n.º 8
0
        /// <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;
            }
        }
Exemplo n.º 9
0
        public List <League> GetLeague(string Category)
        {
            LeagueClient  leagueClient = new LeagueClient();
            List <League> leagues      = new List <League>();

            try
            {
                leagues = leagueClient.GetleagueByCat(Category);
                return(leagues);
            }catch (Exception)
            {
                return(null);
            }
        }
Exemplo n.º 10
0
        private void Form1_Load(object sender, EventArgs e)
        {
            LeagueClient lcu = new LeagueClient();

            rift = new Rift(lcu);

            dDragon = new DDragon();
            Console.WriteLine(dDragon.LastPatch());
            List <string> champions = dDragon.GetAllChampions();

            foreach (var champion in champions)
            {
                cmbBox_Champion.Items.Add(champion);
            }
        }
Exemplo n.º 11
0
        /// <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;
            }
        }
Exemplo n.º 12
0
        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());
        }
Exemplo n.º 13
0
        public async Task <bool> CanConnect()
        {
            const string disallowedPlatform = "KR";
            bool         allowed            = false;

            try
            {
                string platform = await LeagueClient.MakeRequestAsync <string>("/lol-platform-config/v1/namespaces/LoginDataPacket/platformId", Method.GET);

                allowed = platform != disallowedPlatform;
            }
            catch (Exception ex)
            {
                LogTo.ErrorException("Cannot get platform. Disallowing connection", ex);
                allowed = false;
            }
            return(allowed);
        }
Exemplo n.º 14
0
        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));
        }
Exemplo n.º 15
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string l_ID     = Request.QueryString["LeagueID"];
            int    LoggedID = Convert.ToInt32(Session["ID"]);
            //dl_League
            LeagueClient lgClient  = new LeagueClient();
            string       dl_league = lgClient.dl_League(l_ID);

            if (dl_league.ToLower().Contains("success"))
            {
                //popup
                Response.Redirect("LeagueList.aspx?UserID=" + LoggedID);
            }
            else
            {
                //popup
                Response.Redirect("LeagueList.aspx?UserID=" + LoggedID);
            }
        }
Exemplo n.º 16
0
        private void Initialize()
        {
            try
            {
                if (Check_Game_Launch())
                {
                    if (!Dispatcher.CheckAccess())
                    {
                        Dispatcher.Invoke(DispatcherPriority.Send, new Initailize_Delegate(Initialize));
                    }
                    else
                    {
                        Btn_Run.IsEnabled     = true;
                        Grid_CB.IsEnabled     = true;
                        lockfile              = TB_Path.Text + "\\lockfile";
                        TB_Path.IsEnabled     = false;
                        Btn_Confirm.IsEnabled = false;

                        threadNames  = new List <string>();
                        leagueClient = new LeagueClient(lockfile);
                        zh_tw        = new Zh_Tw(leagueClient);
                        match        = new LoLHelper_rework_wpf_.Implements.Match(leagueClient);
                        champSelect  = new ChampSelect(leagueClient);
                        rune         = new Rune(leagueClient);
                        summoner     = new Summoner(leagueClient);

                        Create_ThreadPool();
                        Create_Lane_ComboBox_Items();
                        Create_Champion_ComboBox_Items();
                        Use_Remember_Setting();
                        if (this.WindowState == WindowState.Minimized)
                        {
                            PopUp(this, null);
                        }
                    }
                }
            }
            catch { }
        }
Exemplo n.º 17
0
        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);
        }
Exemplo n.º 18
0
        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);
        }
Exemplo n.º 19
0
        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);
            }
        }
Exemplo n.º 20
0
        protected void btnLeague_Click(object sender, EventArgs e)
        {
            League       toCreate = new League();
            LeagueClient lc       = new LeagueClient();

            toCreate.Name  = txtLeagueName.Text;
            toCreate.Price = Convert.ToDecimal(txtPrice.Text);
            toCreate.Desc  = txtLeagueDesc.Text;
            //DateTime.ParseExact(txtStart.Text, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture);
            toCreate.sDate     = DateTime.ParseExact(txtStartDate.Text, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture);
            toCreate.eDate     = DateTime.ParseExact(txtEndDate.Text, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture);
            toCreate.foreignID = 3;
            int leagueID = lc.CreateLeague(toCreate);

            //Upload league image
            makeLeagueDirectory(Convert.ToString(leagueID));
            //Upload Team Image
            ImageFile img = new ImageFile();

            img = UploadFile(flLeague, Convert.ToString(leagueID), "League_Images", "Leagues");
            FileClient fc     = new FileClient();
            string     res1   = fc.saveLeagueImage(img);
            string     number = res1;
        }
Exemplo n.º 21
0
        protected void Page_Load(object sender, EventArgs e)
        {
            string TeamName   = Convert.ToString(Request.QueryString["teamName"]);
            string LeagueName = Convert.ToString(Session["LeagueName"]);
            Team   tm         = new Team();

            tm.Name       = TeamName;
            tm.LeagueName = LeagueName;
            tm.eDate      = DateTime.Now;
            // tm.sDate = DateTime.Now;
            LeagueClient lg  = new LeagueClient();
            string       res = lg.CreateLeagueTeams(tm);

            if (res.ToLower().Contains("success"))
            {
                //Pop up needed
                Response.Redirect("LeagueTeams.aspx");
            }
            else
            {
                //Pop up neeeded
                Response.Redirect("LeagueTeams.aspx");
            }
        }
Exemplo n.º 22
0
        private static IEnumerable<LeagueAccount> InitAccounts()
        {
            var ipService = new LocateServerIP();

            var client = new LeagueClient(ipService, new AuthorizationService(), new LeagueConnection());
            yield return new LeagueAccount(client, LeagueRegion.NorthAmerica, "BunkTester", "leaguetester1");

            var client2 = new LeagueClient(ipService, new AuthorizationService(), new LeagueConnection());
            yield return new LeagueAccount(client2, LeagueRegion.NorthAmerica, "BunkTester2", "leaguetester2");
        }
Exemplo n.º 23
0
 public Task <LolMapsMaps[]> GetMaps()
 => LeagueClient.Cache(() => Client.MakeRequestAsync <LolMapsMaps[]>("/lol-maps/v2/maps", Method.GET));
Exemplo n.º 24
0
 public Task <LolGameQueuesQueue> GetQueueById(int id)
 => LeagueClient.Cache(id.ToString(),
                       () => Client.MakeRequestAsync <LolGameQueuesQueue>($"/lol-game-queues/v1/queues/{id}", Method.GET));
Exemplo n.º 25
0
 public Task <LolGameQueuesQueue[]> GetQueues()
 => LeagueClient.Cache(
     () => Client.MakeRequestAsync <LolGameQueuesQueue[]>("/lol-game-queues/v1/queues", Method.GET));
Exemplo n.º 26
0
 public Task <LolMapsMaps> GetMapById(int id)
 => LeagueClient.Cache(id.ToString(), () => Client.MakeRequestAsync <LolMapsMaps>($"/lol-maps/v1/map/{id}", Method.GET));
Exemplo n.º 27
0
        protected void lnkAddLeague_Click(object sender, EventArgs e)
        {
            int          LoggedID = Convert.ToInt32(Session["ID"]);
            League       toCreate = new League();
            LeagueClient lc       = new LeagueClient();

            toCreate.Name      = txtName.Value;
            toCreate.Price     = Convert.ToDecimal(txtPrice.Value);
            toCreate.Desc      = txtDesc.Value;
            toCreate.sDate     = DateTime.ParseExact(txtsDate.Text, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture); //setting date and time
            toCreate.eDate     = DateTime.ParseExact(txteDate.Text, "yyyy-MM-ddTHH:mm", CultureInfo.InvariantCulture); //date and time
            toCreate.foreignID = LoggedID;
            toCreate.NumTeams  = Convert.ToInt32(txtNumTeams.Value);
            toCreate.Category  = txtType.Value;
            int leagueID = lc.CreateLeague(toCreate);

            if (leagueID == -1)
            {
                //Cant Upload Team
            }
            else
            {
                //Upload league image
                makeLeagueDirectory(Convert.ToString(leagueID));
                //Upload Team Image
                ImageFile img = new ImageFile();
                img = UploadFile(flImage, Convert.ToString(leagueID), "League_Images", "Leagues");
                FileClient fc   = new FileClient();
                string     res1 = fc.saveLeagueImage(img);
                if (!res1.ToLower().Contains("success"))
                {
                    //Cant Upload League Image
                }
                Response.Write("Proceed To Adding Teams");
            }


            //string htmtl = "";
            //htmtl += "<a href='TeamAdding.aspx?teamId ={{Soc.ID}}' class='btn btn-success' name='table_records'>Add Team</a>";
            //tdRedirectSoccer.InnerHtml = htmtl;

            //htmtl = "";
            //htmtl += "<a href='TeamAdding.aspx?teamId ={{Rug.ID}}' class='btn btn-success' name='table_records'>Add Team</a>";
            //tdRedirectRugby.InnerHtml = htmtl;

            //htmtl = "";
            //htmtl += "<a href='TeamAdding.aspx?teamId ={{Crick.ID}}' class='btn btn-success' name='table_records'>Add Team</a>";
            //tdRedirectCricket.InnerHtml = htmtl;
            //Adding Teams
            //toinsert.League_Id = leagues.League_Id;
            //toinsert.Sport_Id = teams.Sport_Id;
            //toinsert.LeagueName = leagues.Name;
            //toinsert.TeamName = teams.Name;
            //for (int i=0; i<toCreate.NumTeams; i++)
            //{
            //    if(toCreate.Category.ToLower().Equals("soccer"))
            //    {
            //        if (soc.Checked == true)
            //        {
            //            Team leagueTeam = new Team();
            //            leagueTeam.Name = rug_TeamName.Text;
            //            leagueTeam.LeagueName = txtName.Value;
            //            string res = lc.CreateLeagueTeams(leagueTeam);
            //        }
            //    }else if(toCreate.Category.ToLower().Equals("cricket"))
            //    {
            //        if (crick.Checked == true)
            //        {
            //            Team leagueTeam = new Team();
            //            leagueTeam.Name = rug_TeamName.Text;
            //            leagueTeam.LeagueName = txtName.Value;
            //            string res = lc.CreateLeagueTeams(leagueTeam);
            //        }
            //    }
            //    else if (toCreate.Category.ToLower().Equals("rugby"))
            //    {
            //        if (rug.Checked == true)
            //        {
            //            Team leagueTeam = new Team();
            //            leagueTeam.Name = rug_TeamName.Text;
            //            leagueTeam.LeagueName = txtName.Value;
            //            string res = lc.CreateLeagueTeams(leagueTeam);
            //        }
            //    }
            //}
        }