Esempio n. 1
0
        /// <summary>
        /// Processes all badges on page
        /// </summary>
        /// <param name="document">HTML document (1 page) from x</param>
        private void ProcessBadgesOnPage(HtmlDocument document)
        {
            foreach (var badge in document.DocumentNode.SelectNodes("//div[@class=\"badge_row is_link\"]"))
            {
                var appIdNode = badge.SelectSingleNode(".//a[@class=\"badge_row_overlay\"]").Attributes["href"].Value;
                var appid     = Regex.Match(appIdNode, @"gamecards/(\d+)/").Groups[1].Value;

                if (string.IsNullOrWhiteSpace(appid) || Settings.Default.blacklist.Contains(appid) || appid == "368020" || appid == "335590" || appIdNode.Contains("border=1"))
                {
                    continue;
                }

                var hoursNode = badge.SelectSingleNode(".//div[@class=\"badge_title_stats_playtime\"]");
                var hours     = hoursNode == null ? string.Empty : Regex.Match(hoursNode.InnerText, @"[0-9\.,]+").Value;

                var nameNode = badge.SelectSingleNode(".//div[@class=\"badge_title\"]");
                var name     = WebUtility.HtmlDecode(nameNode.FirstChild.InnerText).Trim();

                var cardNode = badge.SelectSingleNode(".//span[@class=\"progress_info_bold\"]");
                var cards    = cardNode == null ? string.Empty : Regex.Match(cardNode.InnerText, @"[0-9]+").Value;

                var badgeInMemory = AllBadges.FirstOrDefault(b => b.StringId == appid);
                if (badgeInMemory != null)
                {
                    badgeInMemory.UpdateStats(cards, hours);
                }
                else
                {
                    AllBadges.Add(new Badge(appid, name, cards, hours));
                }
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Processes all badges on page
        /// </summary>
        /// <param name="document">HTML document (1 page) from x</param>
        private void ProcessBadgesOnPage(HtmlDocument document) // AKA6
        {
            foreach (var badge in document.DocumentNode.SelectNodes("//div[@class=\"badge_row is_link\"]"))
            {
                var appIdNode = badge.SelectSingleNode(".//a[@class=\"badge_row_overlay\"]").Attributes["href"].Value;
                var appid     = Regex.Match(appIdNode, @"gamecards/(\d+)/").Groups[1].Value;

                if (string.IsNullOrWhiteSpace(appid) || Settings.Default.blacklist.Contains(appid) || appid == "368020" || appid == "335590" || appIdNode.Contains("border=1"))
                {
                    continue;
                }

                var hoursNode = badge.SelectSingleNode(".//div[@class=\"badge_title_stats_playtime\"]");
                var hours     = hoursNode == null ? string.Empty : Regex.Match(hoursNode.InnerText, @"[0-9\.,]+").Value;

                var nameNode = badge.SelectSingleNode(".//div[@class=\"badge_title\"]");
                var name     = WebUtility.HtmlDecode(nameNode.FirstChild.InnerText).Trim();

                var cardNode = badge.SelectSingleNode(".//span[@class=\"progress_info_bold\"]");
                var cards    = cardNode == null ? string.Empty : Regex.Match(cardNode.InnerText, @"[0-9]+").Value;

                var badgeInMemory = AllBadges.FirstOrDefault(b => b.StringId == appid);
                if (badgeInMemory != null)
                {
                    badgeInMemory.UpdateStats(cards, hours);
                }
                else
                {
                    // un 0 antes = desactivado
                    var ets2   = "227300";
                    var ats    = "270880"; // en blacklist
                    var gtav   = "271590"; // si no tiene cromos no pasa por la lista
                    var rocket = "0252950";
                    // Agregamos if para regular que juegos ingresan a la lista
                    // WhiteList
                    if (String.Equals(appid, gtav) || String.Equals(appid, ets2) || String.Equals(appid, ats) || String.Equals(appid, rocket))
                    {
                        AllBadges.Add(new Badge(appid, name, cards, hours));
                    }
                }
            }
        }
Esempio n. 3
0
 public async Task CheckCardDrops(Badge badge)
 {
     if (!await badge.CanCardDrops())
     {
         NextIdle();
         lblCurrentRemaining.Text = badge.RemainingCard + " " + localization.strings.card_drops_remaining;
         pbIdle.Value             = pbIdle.Maximum - badge.RemainingCard;
         lblHoursPlayed.Text      = badge.HoursPlayed + " " + localization.strings.hrs_on_record;
         UpdateStateInfo();
     }
     else
     {
         // zhenying make it skip to next item
         StopIdle();
         AllBadges.RemoveAll(b => Equals(b, CurrentBadge));
         AllBadges.Add(CurrentBadge);
         StartIdle();
         // Resets the clock based on the number of remaining drops
         //TimeLeft = badge.RemainingCard == 1 ? 300 : 900;
         //TimeLeft = badge.RemainingCard == 1 ? 10 : 30;
     }
 }
Esempio n. 4
0
        private async void tmrCardDropCheck_Tick(object sender, EventArgs e)
        {
            if (TimeLeft <= 0)
            {
                tmrCardDropCheck.Enabled = false;

                // solo mode
                if (CurrentBadge != null)
                {
                    CurrentBadge.Idle();

                    if (PreviousBadge != null)
                    {
                        await PreviousBadge.CanCardDrops();

                        if (PreviousCardsRemaining != PreviousBadge.RemainingCard)
                        {
                            //前のゲームのカードがドロップしたようなので、ファストモード成功。
                            //あと10秒くらいまって次のカードへ。
                            TimeLeft = 10;

                            //前のゲームにカードが残っているようなら、ファストモードにしておく。
                            if (PreviousBadge.RemainingCard > 0)
                            {
                                PreviousBadge.FastMode = true;

                                if (Settings.Default.checkNoDrop)
                                {
                                    //次も同じゲームをIdleする
                                    AllBadges.RemoveAll(b => Equals(b, PreviousBadge));
                                    AllBadges.Insert(0, PreviousBadge);
                                }
                                else
                                {
                                    //追加Idle
                                    if (PreviousBadge.HoursPlayed <= 10)
                                    {
                                        while (PreviousBadge.HoursPlayed > PreviousBadge.MinPlayTime)
                                        {
                                            PreviousBadge.MinPlayTime += 0.5;
                                        }
                                    }
                                    else
                                    {
                                        //Idle時間が10時間を越えていたならFastModeをやめる。
                                        PreviousBadge.FastMode = false;
                                    }
                                }
                            }
                        }
                        else
                        {
                            //ファストモード失敗。

                            //最低プレイ時間を30min間延ばす
                            //ただしプレイ時間が10時間以上のものは通常モードにする。
                            //(無限にIdleするのを防ぐため。)
                            if (PreviousBadge.HoursPlayed <= 10)
                            {
                                while (PreviousBadge.HoursPlayed > PreviousBadge.MinPlayTime)
                                {
                                    PreviousBadge.MinPlayTime += 0.5;
                                }

                                //あと20秒くらいまって次のカードへ。
                                TimeLeft = 10;
                            }
                            else
                            {
                                PreviousBadge.FastMode = false;

                                //次のゲームへ。
                                NextIdle();
                            }
                        }

                        //前のゲームの処理は終わり
                        PreviousBadge = null;
                    }
                    else
                    {
                        if (Settings.Default.fastModeEnable && CurrentBadge.FastMode)
                        {
                            //現在のゲームとカードドロップ数を記録しておく
                            PreviousCardsRemaining = CurrentBadge.RemainingCard;
                            PreviousBadge          = CurrentBadge;

                            //現在のゲームを最後尾へ
                            AllBadges.RemoveAll(b => Equals(b, CurrentBadge));
                            AllBadges.Add(CurrentBadge);

                            //次のゲームへ
                            NextIdle();
                        }
                        else
                        {
                            //通常モード
                            await CheckCardDrops(CurrentBadge);
                        }
                    }
                }

                var isMultipleIdle = CanIdleBadges.Any(b => !Equals(b, CurrentBadge) && b.InIdle);
                if (isMultipleIdle)
                {
                    await LoadBadgesAsync();

                    UpdateIdleProcesses();

                    isMultipleIdle = CanIdleBadges.Any(b => b.HoursPlayed < b.MinPlayTime && b.InIdle);
                    if (isMultipleIdle)
                    {
                        TimeLeft = 360;
                    }
                }

                // Check if user is authenticated and if any badge left to idle
                // There should be check for IsCookieReady, but property is set in timer tick, so it could take some time to be set.
                tmrCardDropCheck.Enabled = !string.IsNullOrWhiteSpace(Settings.Default.sessionid) && IsSteamReady && CanIdleBadges.Any() && TimeLeft != 0;
            }
            else
            {
                TimeLeft      = TimeLeft - 1;
                lblTimer.Text = TimeSpan.FromSeconds(TimeLeft).ToString(@"mm\:ss");
                if (Settings.Default.fastModeEnable && CurrentBadge != null)
                {
                    lblTimer.Text += CurrentBadge.FastMode ? "(F)" : "(N)";
                }
            }
        }
Esempio n. 5
0
        public async Task LoadBadgesAsync()
        {
            var profileLink = Settings.Default.myProfileURL + "/badges";
            var document    = new HtmlDocument();
            var pages       = new List <string>()
            {
                "?p=1"
            };

            try
            {
                for (var i = 0; i < pages.Count; i++)
                {
                    var response = await CookieClient.GetHttpAsync(profileLink + pages[i]);

                    document.LoadHtml(response);

                    var pageNodes = document.DocumentNode.SelectNodes("//a[@class=\"pagelink\"]");
                    if (pageNodes != null)
                    {
                        pages.AddRange(pageNodes.Select(p => p.Attributes["href"].Value).Distinct());
                        pages = pages.Distinct().ToList();
                    }

                    foreach (var badge in document.DocumentNode.SelectNodes("//div[@class=\"badge_row is_link\"]"))
                    {
                        var appIdNode = badge.SelectSingleNode(".//a[@class=\"badge_row_overlay\"]").Attributes["href"].Value;
                        var appid     = Regex.Match(appIdNode, @"gamecards/(\d+)/").Groups[1].Value;

                        if (string.IsNullOrWhiteSpace(appid) || Settings.Default.blacklist.Contains(appid) || appid == "368020" || appid == "335590")
                        {
                            continue;
                        }

                        var hoursNode = badge.SelectSingleNode(".//div[@class=\"badge_title_stats_playtime\"]");
                        var hours     = hoursNode == null ? string.Empty : Regex.Match(hoursNode.InnerText, @"[0-9\.,]+").Value;

                        var nameNode = badge.SelectSingleNode(".//div[@class=\"badge_title\"]");
                        var name     = WebUtility.HtmlDecode(nameNode.FirstChild.InnerText).Trim();

                        var cardNode = badge.SelectSingleNode(".//span[@class=\"progress_info_bold\"]");
                        var cards    = cardNode == null ? string.Empty : Regex.Match(cardNode.InnerText, @"[0-9]+").Value;

                        var badgeInMemory = AllBadges.FirstOrDefault(b => b.StringId == appid);
                        if (badgeInMemory != null)
                        {
                            badgeInMemory.UpdateStats(cards, hours);
                        }
                        else
                        {
                            AllBadges.Add(new Badge(appid, name, cards, hours));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Logger.Exception(ex, "Badge -> LoadBadgesAsync, for profile = " + Settings.Default.myProfileURL);
                // badge page didn't load
                picReadingPage.Image   = null;
                lblDrops.Text          = "Badge page didn't load, will retry in 10 seconds";
                ReloadCount            = 10;
                tmrBadgeReload.Enabled = true;
                return;
            }

            SortBadges(Settings.Default.sort);

            picReadingPage.Visible = false;
            UpdateStateInfo();

            if (CardsRemaining == 0)
            {
                IdleComplete();
            }
        }
Esempio n. 6
0
 public void AddBadge(BadgeModel badge)
 {
     AllBadges.Add(badge);
     badge.PropertyChanged += BadgeIdleStatusChanged;
 }