Ejemplo n.º 1
0
 public static Task <bool> BattleNet_RestoreSelected(string[] selectedIds) => Task.FromResult(BattleNetSwitcherFuncs.RestoreSelected(selectedIds));
Ejemplo n.º 2
0
 public static async Task NewLogin_BattleNet()
 {
     Globals.DebugWriteLine(@"[JSInvoke:BattleNet\BattleNetSwitcherBase.NewLogin_BattleNet]");
     await BattleNetSwitcherFuncs.SwapBattleNetAccounts("");
 }
Ejemplo n.º 3
0
            public bool FetchRank()
            {
                if (!BattleNetSwitcherFuncs.ValidateBTag(BTag))
                {
                    return(false);
                }
                var split = BTag.Split("#");
                var req   = WebRequest.Create($"https://playoverwatch.com/en-us/career/pc/{split[0]}-{split[1]}/");

                req.Method = "GET";

                var doc            = new HtmlDocument();
                var responseStream = req.GetResponse().GetResponseStream();

                if (responseStream == null)
                {
                    _ = GeneralInvocableFuncs.ShowToast("error", Lang["Toast_BNet_StatsFail", new { BTag = BTag }],
                                                        renderTo: "toastarea");
                    return(false);
                }

                using (var reader = new StreamReader(responseStream))
                {
                    doc.LoadHtml(reader.ReadToEnd());
                }

                // If the PlayOverwatch site is overloaded
                if (doc.DocumentNode.SelectSingleNode("/html/body/section[1]/section/div/h1") != null)
                {
                    _ = GeneralInvocableFuncs.ShowToast("error", Lang["Toast_BNet_StatsFail", new { BTag = BTag }],
                                                        renderTo: "toastarea");
                    return(false);
                }

                // If the Profile is private
                if (doc.DocumentNode.SelectSingleNode(
                        "/html/body/section[1]/div[1]/section/div/div/div/div/div[1]/p")?.InnerHtml ==
                    "Private Profile")
                {
                    ImgUrl = doc.DocumentNode
                             .SelectSingleNode("/html/body/section[1]/div[1]/section/div/div/div/div/div[2]/img")
                             .Attributes["src"].Value;
                    _ = GeneralInvocableFuncs.ShowToast("warning", Lang["Toast_BNet_Private", new { BTag = BTag }],
                                                        renderTo: "toastarea");
                    _ = BattleNetSwitcherFuncs.DownloadImage(Email, ImgUrl);
                    LastTimeChecked = DateTime.Now - TimeSpan.FromMinutes(1435); // 23 Hours 55 Minutes
                    return(false);
                }

                // If BattleTag is invalid
                if (doc.DocumentNode.SelectSingleNode(
                        "/html/body/section[1]/section/div/h1")?.InnerHtml == "PROFILE NOT FOUND")
                {
                    _ = GeneralInvocableFuncs.ShowToast("error", Lang["Toast_ItemNotFound", new { item = BTag }],
                                                        renderTo: "toastarea");
                    return(false);
                }

                LastTimeChecked = DateTime.Now;
                ImgUrl          = doc.DocumentNode
                                  .SelectSingleNode("/html/body/section[1]/div[1]/section/div/div[2]/div/div/div[2]/img")
                                  .Attributes["src"].Value;
                _ = BattleNetSwitcherFuncs.DownloadImage(Email, ImgUrl);

                var ranks = doc.DocumentNode.SelectNodes(
                    "/html/body/section[1]/div[1]/section/div/div[2]/div/div/div[2]/div/div[3]");

                foreach (var node in ranks.Elements())
                {
                    if (!int.TryParse(node.LastChild.LastChild.InnerHtml, out var sr))
                    {
                        continue;
                    }

                    switch (node.LastChild.FirstChild.Attributes["data-ow-tooltip-text"].Value.Split(" ").First())
                    {
                    case "Tank":
                        OwTankSr = sr;
                        break;

                    case "Damage":
                        OwDpsSr = sr;
                        break;

                    case "Support":
                        OwSupportSr = sr;
                        break;

                    default:
                        continue;
                    }
                }

                return(true);
            }
Ejemplo n.º 4
0
 public static async Task SwapToBattleNet(string accName = "")
 {
     Globals.DebugWriteLine(@"[JSInvoke:BattleNet\BattleNetSwitcherBase.SwapToBattleNet] accName:hidden");
     await BattleNetSwitcherFuncs.SwapBattleNetAccounts(accName);
 }