Exemplo n.º 1
0
 public CurrentGamePlayers(string name, string rank, int id, UriImageSource icon, RiotSharp.Region region)
 {
     this.Name   = name;
     this.Rank   = rank;
     this.ID     = id;
     this.Icon   = icon;
     this.Region = region;
 }
Exemplo n.º 2
0
        private void serverbox_SelectedIndexChanged(object sender, EventArgs e)
        {
            try
            {
                GBAccount gbacc = FindAccount(int.Parse(accidbox.Text));
                if (gbacc != null)
                {
                    RiotSharp.Region reg = RiotSharp.Region.euw;

                    switch (serverbox.Text.ToUpper())
                    {
                    case "EUNE":
                        reg = RiotSharp.Region.eune;
                        break;

                    case "NA":
                        reg = RiotSharp.Region.na;
                        break;

                    case "OCE":
                        reg = RiotSharp.Region.oce;
                        break;

                    case "RU":
                        reg = RiotSharp.Region.ru;
                        break;

                    case "TR":
                        reg = RiotSharp.Region.tr;
                        break;

                    case "KR":
                        reg = RiotSharp.Region.kr;
                        break;

                    case "LAN":
                        reg = RiotSharp.Region.lan;
                        break;

                    case "LAS":
                        reg = RiotSharp.Region.las;
                        break;

                    case "BR":
                        reg = RiotSharp.Region.br;
                        break;
                    }
                    gbacc.Region = reg;

                    SettingsManager.Settings.Accounts[int.Parse(accidbox.Text)] = gbacc;
                }
            }
            catch
            {
            }
        }
Exemplo n.º 3
0
        AccountTier GetTier(Summoner sum, RiotSharp.Region reg)
        {
            try
            {
                List <long> asum = new List <long>(); asum.Add(sum.Id);
                Dictionary <long, List <RiotSharp.LeagueEndpoint.League> > league = API.GetLeagues(reg, asum);

                if (league.Count > 0)
                {
                    foreach (League l in league[sum.Id])
                    {
                        if (l.Queue == RiotSharp.Queue.RankedSolo5x5)
                        {
                            // tier
                            switch (l.Tier.ToString().ToUpper())
                            {
                            case "CHALLENGER":
                                return(AccountTier.Challenger);

                            case "MASTER":
                                return(AccountTier.Master);

                            case "DIAMOND":
                                return(AccountTier.Diamond);

                            case "PLATINUM":
                                return(AccountTier.Plat);

                            case "GOLD":
                                return(AccountTier.Gold);

                            case "SILVER":
                                return(AccountTier.Silver);

                            default:
                                return(AccountTier.UnrankedOrBronze);
                            }

                            break;
                        }
                    }
                }
                return(AccountTier.UnrankedOrBronze);
            }
            catch (Exception ex)
            {
                return(AccountTier.UnrankedOrBronze);
            }
        }
Exemplo n.º 4
0
        private void ginfo_Click(object sender, EventArgs e)
        {
            try
            {
                RiotSharp.Region lolregsharp = RiotTool.PlatformToRegion(CurrentGame.platformId.ToUpper());
                long             sid         = Program.MainFormInstance.API.GetSummoner(lolregsharp, CurrentGame.participants[0].summonerName).Id;

                RootObject rg = Program.MainFormInstance.API.GetCurrentGame(lolregsharp, sid, CurrentGame.platformId.ToUpper());
                UpdateCurrentGameInvoker u = new UpdateCurrentGameInvoker(Program.MainFormInstance.currentGame1.LoadGame);
                u.BeginInvoke(rg, Program.MainFormInstance.API, lolregsharp, 0, null, null);
                Program.MainFormInstance.MainTabControl.SelectedTab = Program.MainFormInstance.GameInfoTab;
            }
            catch
            {
            }
        }
        public void ClaimAccount()
        {
            commands.CreateCommand("ClaimAccount")
            .Parameter("Region", ParameterType.Required)
            .Parameter("Summoner", ParameterType.Unparsed)
            .Do(async(e) =>
            {
                string returnmessage = "An error happened.";
                if (new ServerRepo(new ServerContext()).IsServerVerified(e.Server.Id))
                {
                    RiotSharp.Region region = LeagueAndDatabase.GetRegionFromString(e.GetArg("Region"));
                    string summonername     = e.GetArg("Summoner");
                    SummonerRepo sumRepo    = new SummonerRepo(new SummonerContext());
                    UserRepo userRepo       = new UserRepo(new UserContext());
                    long riotid             = Convert.ToInt32(new SummonerAPI().GetSummonerId(summonername, region));
                    string token            = new StringBuilder().CreateToken();
                    if (
                        sumRepo.IsSummonerInSystem(riotid
                                                   ) == false
                        )
                    {
                        try
                        {
                            userRepo.GetUserIdByDiscord((e.User.Id));
                        }
                        catch
                        {
                            userRepo.AddUser(Convert.ToInt64(e.User.Id));
                        }
                        sumRepo.AddSummoner(userRepo.GetUserIdByDiscord((e.User.Id)), riotid,
                                            new RegionContext().GetRegionId(region), token);
                        returnmessage =
                            Eng_Default.RenameMasteryPage(
                                sumRepo.GetToken(userRepo.GetUserByDiscord((e.User.Id)), riotid).ToString());
                    }
                    else
                    {
                        returnmessage =
                            Eng_Default.RenameMasteryPageLong(
                                sumRepo.GetToken(userRepo.GetUserByDiscord((e.User.Id)), riotid));
                        string token2 = sumRepo.GetToken(userRepo.GetUserByDiscord((e.User.Id)), riotid);
                        foreach (var page in new SummonerAPI().GetSummonerMasteryPages(summonername, region))
                        {
                            if (page.Name.ToLower() == token2.ToLower())
                            {
                                sumRepo.VerifySummoner(userRepo.GetUserByDiscord((e.User.Id)), riotid);
                                returnmessage = Eng_Default.AccountVerified();
                                new RoleManagementCommands(BotUser, commands).GetRoles(e.Server, e.User);
                                new FlairTrigger(BotUser, commands).CreateFlair(new SummonerAPI().GetSummoner(riotid, region));
                            }
                        }
                        foreach (var page in new SummonerAPI().GetRunePages(summonername, region))
                        {
                            if (page.Name.ToLower() == token2.ToLower())
                            {
                                sumRepo.VerifySummoner(userRepo.GetUserByDiscord((e.User.Id)), riotid);
                                returnmessage = Eng_Default.AccountVerified();
                                new RoleManagementCommands(BotUser, commands).GetRoles(e.Server, e.User);
                                new FlairTrigger(BotUser, commands).CreateFlair(new SummonerAPI().GetSummoner(riotid, region));
                            }
                        }
                    }
                }
                else
                {
                    returnmessage = Eng_Default.ServerIsNotVerified();
                }

                await e.Channel.SendMessage(returnmessage);
            });
        }
Exemplo n.º 6
0
        private void metroButton1_Click(object sender, EventArgs e)
        {
            try{
                int gport = 9069;


                SettingsManager.Settings.ApiKey = api.Text;

                SettingsManager.Settings.GameDirectory    = loldir.Text;
                SettingsManager.Settings.RecordIfLate     = ice.Checked;
                SettingsManager.Settings.NetworkInterface = netint.Text;


                SettingsManager.Settings.ProxyUser = proxuser.Text;
                SettingsManager.Settings.ProxyPass = proxpass.Text;
                SettingsManager.Settings.ProxyPort = int.Parse(proxport.Text);
                SettingsManager.Settings.ProxyHost = proxhost.Text;

                SettingsManager.Settings.ApiCacheEnabled     = apicache.Checked;
                SettingsManager.Settings.GhostOverlayEnabled = govcheck.Checked;
                SettingsManager.Settings.HelperEnabled       = helpercheck.Checked;
                SettingsManager.Settings.AutoGameInfo        = autogicheck.Checked;
                SettingsManager.Settings.AutoMoveOld         = automovecheck.Checked;
                SettingsManager.Settings.TopBannerBg         = bannerbgbox.Text;
                SettingsManager.Settings.AnimatorEnabled     = animatorcheck.Checked;
                SettingsManager.Settings.AdvancedGameInfo    = advginfocheck.Checked;
                SettingsManager.Settings.FollowedSummoners   = followedsumtxt.Lines;
                SettingsManager.Settings.AutoRecordGame      = autorecordcheck.Checked;
                SettingsManager.Settings.PortForwarding      = portforwardcheck.Checked;


                if (int.TryParse(gstreamport.Text, out gport))
                {
                    SettingsManager.Settings.GhostStreamPort = gport;
                }
                else
                {
                    SettingsManager.Settings.GhostStreamPort = 9069;
                }


                if (proxyopt.Text == "Network")
                {
                    SettingsManager.Settings.ProxyOption = GhostLib.Network.ProxyType.Network;
                }
                else if (proxyopt.Text == "Proxy")
                {
                    SettingsManager.Settings.ProxyOption = GhostLib.Network.ProxyType.Proxy;
                }
                else
                {
                    SettingsManager.Settings.ProxyOption = GhostLib.Network.ProxyType.None;
                }

                //if (SettingsManager.Settings.Speech != spcheck.Checked && spcheck.Checked && !Speech.Initialized)
                //    Speech.Initialize();
                SettingsManager.Settings.Speech             = spcheck.Checked;
                SettingsManager.Settings.RecordingDirectory = recdir.Text;
                RiotSharp.Region reg = RiotSharp.Region.euw;

                switch (serverbox.Text.ToUpper())
                {
                case "EUNE":
                    reg = RiotSharp.Region.eune;
                    break;

                case "NA":
                    reg = RiotSharp.Region.na;
                    break;

                case "OCE":
                    reg = RiotSharp.Region.oce;
                    break;

                case "RU":
                    reg = RiotSharp.Region.ru;
                    break;

                case "TR":
                    reg = RiotSharp.Region.tr;
                    break;

                case "KR":
                    reg = RiotSharp.Region.kr;
                    break;

                case "LAN":
                    reg = RiotSharp.Region.lan;
                    break;

                case "LAS":
                    reg = RiotSharp.Region.las;
                    break;

                case "BR":
                    reg = RiotSharp.Region.br;
                    break;
                }
                if (API == null && frm != null)
                {
                    frm.API = RiotSharp.RiotApi.GetInstance(api.Text);
                }
                else if (API == null)
                {
                    API = RiotSharp.RiotApi.GetInstance(api.Text);
                }


                // Accounts
                foreach (object item in accidbox.Items)
                {
                    string sitem = item.ToString();
                    if (sitem.Length > 0 && sitem != "Add new summoner")
                    {
                        bool      add   = false;
                        GBAccount gbacc = FindAccount(int.Parse(sitem));
                        if (gbacc == null)
                        {
                            gbacc = new GBAccount();
                            add   = true;
                        }

                        Summoner sum = API.GetSummoner(gbacc.Region, gbacc.SummonerName, false);

                        gbacc.PlayerID = sum.Id;
                        if (add)
                        {
                            gbacc.PbeSummonerName = "";
                            gbacc.PbePlayerID     = 0;
                        }
                        // find player tier
                        gbacc.SummonerTier = GetTier(sum, gbacc.Region);


                        gbacc.SummonerIconId = sum.ProfileIconId;
                        GhostbladeInstance.DataDragonInstance.GetIcon(sum.ProfileIconId);
                        gbacc.SummonerLevel = sum.Level;

                        if (SettingsManager.Settings.Accounts == null)
                        {
                            SettingsManager.Settings.Accounts = new List <GBAccount>();
                        }

                        if (add)
                        {
                            SettingsManager.Settings.Accounts.Insert(0, gbacc);
                        }
                        else
                        {
                            SettingsManager.Settings.Accounts[int.Parse(sitem)] = gbacc;
                        }

                        // make it default
                        if (accidbox.Text == sitem)
                        {
                            SettingsManager.Settings.Accounts.RemoveAt(int.Parse(sitem));
                            SettingsManager.Settings.Accounts.Insert(0, gbacc);
                        }
                    }
                }

                SettingsManager.Save();
                if (frm == null)
                {
                    MessageBox.Show("Settings saved\n You should restart Ghostblade", "Save Settings", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    Process.Start(Application.StartupPath + @"\Ghostblade.exe", "-restart");
                    Process.GetCurrentProcess().Kill();
                }
                else
                {
                    MetroMessageBox.Show(frm, "Settings saved", "Save Settings", MessageBoxButtons.OK, MessageBoxIcon.Information);
                    frm.SelectedAccount = SettingsManager.Settings.Accounts[0];
                    frm.MainTopBanner.Switch(frm.SelectedAccount);
                    frm.RefillTheFollowerQueue();
                }
                //File.WriteAllText(Application.StartupPath + @"\API.dat", api.Text);
                NetworkManager.Init();
            }
            catch (Exception ex)

            {
                //Log.LogEx(ex);
                MessageBox.Show(this, ex.Message + "\n" + ex.StackTrace, "Save Settings", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Exemplo n.º 7
0
        public void LoadGame(RootObject gameinfo, RiotSharp.RiotApi api, RiotSharp.Region reg, long sid)
        {
            try
            {
                BluePanel.BeginInvoke(new MethodInvoker(delegate
                {
                    BluePanel.Controls.Clear();
                    RedPanel.Controls.Clear();
                    ginfo.Text = RiotTool.ToMapString(gameinfo.MapType) + ", " + RiotTool.ToQueueString(gameinfo.gameQueueConfigId) + " - " + RiotTool.PlatformToString(gameinfo.platformId);
                    metroProgressSpinner1.Visible = true;


                    B1.Visible = (gameinfo.bannedChampions.Count != 0);
                    B2.Visible = (gameinfo.bannedChampions.Count != 0);
                    B3.Visible = (gameinfo.bannedChampions.Count != 0);
                    B4.Visible = (gameinfo.bannedChampions.Count != 0);
                    B5.Visible = (gameinfo.bannedChampions.Count != 0);
                    B6.Visible = (gameinfo.bannedChampions.Count != 0);


                    foreach (BannedChampion b in gameinfo.bannedChampions)
                    {
                        Image champ = Image.FromFile(Application.StartupPath + @"\Champions\" + CurrentGame.GetChampion(b.ChampionId) + ".png");
                        switch (b.PickTurn)
                        {
                        case 1:
                            B1.BackgroundImage = champ;
                            break;

                        case 3:
                            B2.BackgroundImage = champ;
                            break;

                        case 5:
                            B3.BackgroundImage = champ;
                            break;

                        case 2:
                            B4.BackgroundImage = champ;
                            break;

                        case 4:
                            B5.BackgroundImage = champ;
                            break;

                        case 6:
                            B6.BackgroundImage = champ;
                            break;
                        }
                    }
                }));
                int c = 0;

                frm.AnimationType = AnimatorNS.AnimationType.Mosaic;
                //foreach (Participant p in gameinfo.participants)
                //{
                ParallelLoopResult pr = Parallel.ForEach(gameinfo.participants, p =>
                {
                    Player pl = new Player(p.TeamId == 200);


                    pl.Dock          = DockStyle.Top;
                    LeaguePlayer pls = new LeaguePlayer();
                    pls.LoadPlayer(reg, api, p, CurrentGame.GetChampion(p.ChampionId));
                    if (pls.SummonerName == "Error occured")
                    {
                        pls.SummonerName = p.Name;
                    }
                    pl.LoadSummonerData(pls);
                    MetroPanel panel = null;
                    if (p.TeamId == 100)
                    {
                        panel = BluePanel;
                    }
                    else
                    {
                        panel = RedPanel;
                    }
                    pls.Dispose();
                    panel.Invoke(new MethodInvoker(delegate
                    {
                        //if (panel == BluePanel && p.TeamId != 100)
                        //    panel = RedPanel;
                        c++;
                        metroProgressSpinner1.Value = (int)((double)((double)c / (double)gameinfo.participants.Count) * 100);

                        panel.Controls.Add(pl);
                        //pl.Visible = false;

                        //frm.Show(pl, Program.MainFormInstance.MainTabControl.SelectedTab == Program.MainFormInstance.GameInfoTab);
                    }));

                    //   }
                });
                while (!pr.IsCompleted)
                {
                    Thread.Sleep(100);
                }

                RedPanel.Invoke(new MethodInvoker(delegate
                {
                    this.RedPanel.Controls.Add(this.RedBan);
                    this.BluePanel.Controls.Add(this.BlueBan);
                    metroProgressSpinner1.Visible = false;
                    metroProgressSpinner1.Value   = 1;
                }));

                Program.MainFormInstance.ShowInfo("Game info", "The current game info are ready to be viewed");
                if (SettingsManager.Settings.Speech)
                {
                    SoundPlayer sp = new SoundPlayer(Application.StartupPath + @"\Data\done.wav");
                    sp.Load();
                    sp.PlaySync();
                    sp.Dispose();
                }
                GC.Collect();
                GC.WaitForPendingFinalizers();
            }
            catch (Exception ex)
            {
                Logger.Instance.Log.Error("Failed to load game", ex);
            }
        }