コード例 #1
0
ファイル: frmMain.cs プロジェクト: deetr-/idle_master
        public async Task CheckCardDrops(Badge badge)
        {
            if (!await badge.CanCardDrops())
                NextIdle();
            else
            {
                // Resets the clock based on the number of remaining drops
                TimeLeft = badge.RemainingCard == 1 ? 300 : 900;
            }

            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();
        }
コード例 #2
0
ファイル: frmMain.cs プロジェクト: deetr-/idle_master
        public void StartSoloIdle(Badge badge)
        {
            // Set the currentAppID value
            CurrentBadge = badge;

            // Place user "In game" for card drops
            CurrentBadge.Idle();

            // Update game name
            lblGameName.Visible = true;
            lblGameName.Text = CurrentBadge.Name;

            GamesState.Visible = false;
            gameToolStripMenuItem.Enabled = true;

            // Update game image
            try
            {
                picApp.Load("http://cdn.akamai.steamstatic.com/steam/apps/" + CurrentBadge.StringId + "/header_292x136.jpg");
                picApp.Visible = true;
            }
            catch (Exception ex)
            {
                Logger.Exception(ex, "frmMain -> StartIdle -> load pic, for id = " + CurrentBadge.AppId);
            }

            // Update label controls
            lblCurrentRemaining.Text = CurrentBadge.RemainingCard + " " + localization.strings.card_drops_remaining;
            lblCurrentStatus.Text = localization.strings.currently_ingame;
            lblHoursPlayed.Visible = true;
            lblHoursPlayed.Text = CurrentBadge.HoursPlayed + " " + localization.strings.hrs_on_record;

            // Set progress bar values and show the footer
            pbIdle.Maximum = CurrentBadge.RemainingCard;
            pbIdle.Value = 0;
            ssFooter.Visible = true;

            // Start the animated "working" gif
            picIdleStatus.Image = Resources.imgSpin;

            // Start the timer that will check if drops remain
            tmrCardDropCheck.Enabled = true;

            // Reset the timer
            TimeLeft = CurrentBadge.RemainingCard == 1 ? 300 : 900;

            // Set the correct buttons on the form for pause / resume
            btnResume.Visible = false;
            btnPause.Visible = true;
            btnSkip.Visible = true;
            resumeIdlingToolStripMenuItem.Enabled = false;
            pauseIdlingToolStripMenuItem.Enabled = false;
            skipGameToolStripMenuItem.Enabled = false;

            var scale = CreateGraphics().DpiY * 3.9;
            Height = Convert.ToInt32(scale);
        }
コード例 #3
0
        public void StartSoloIdle(Badge badge)
        {
            // Set the currentAppID value
            CurrentBadge = badge;

            // Place user "In game" for card drops
            CurrentBadge.Idle();

            // Update game name
            lblGameName.Visible = true;
            lblGameName.Text    = CurrentBadge.Name;

            GamesState.Visible            = false;
            gameToolStripMenuItem.Enabled = true;

            // Update game image
            try
            {
                picApp.Load("http://cdn.akamai.steamstatic.com/steam/apps/" + CurrentBadge.StringId + "/header_292x136.jpg");
                picApp.Visible = true;
            }
            catch (Exception ex)
            {
                Logger.Exception(ex, "frmMain -> StartIdle -> load pic, for id = " + CurrentBadge.AppId);
            }

            // Update label controls
            lblCurrentRemaining.Text = CurrentBadge.RemainingCard + " " + localization.strings.card_drops_remaining;
            lblCurrentStatus.Text    = localization.strings.currently_ingame;
            lblHoursPlayed.Visible   = true;
            lblHoursPlayed.Text      = CurrentBadge.HoursPlayed + " " + localization.strings.hrs_on_record;

            // Set progress bar values and show the footer
            pbIdle.Maximum   = CurrentBadge.RemainingCard;
            pbIdle.Value     = 0;
            ssFooter.Visible = true;

            // Start the animated "working" gif
            picIdleStatus.Image = Resources.imgSpin;

            // Start the timer that will check if drops remain
            tmrCardDropCheck.Enabled = true;

            // Reset the timer
            //TimeLeft = CurrentBadge.RemainingCard == 1 ? 300 : 900;
            if (Settings.Default.fastModeEnable && CurrentBadge.FastMode)
            {
                if (PreviousBadge != null)
                {
                    TimeLeft = 10;
                }
                else
                {
                    TimeLeft = 20;
                }
            }
            else
            {
                TimeLeft = CurrentBadge.RemainingCard == 1 ? 300 : 900;
            }

            // Set the correct buttons on the form for pause / resume
            btnResume.Visible = false;
            btnPause.Visible  = true;
            btnSkip.Visible   = true;
            resumeIdlingToolStripMenuItem.Enabled = false;
            pauseIdlingToolStripMenuItem.Enabled  = false;
            skipGameToolStripMenuItem.Enabled     = false;

            var scale = CreateGraphics().DpiY * 3.9;

            Height = Convert.ToInt32(scale);
        }
コード例 #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)";
                }
            }
        }
コード例 #5
0
        private void StartIdle()
        {
            // Kill all existing processes before starting any new ones
            // This prevents rogue processes from interfering with idling time and slowing card drops
            try
            {
                String username = WindowsIdentity.GetCurrent().Name;
                foreach (var process in Process.GetProcessesByName("steam-idle"))
                {
                    ManagementObjectSearcher   searcher    = new ManagementObjectSearcher("Select * From Win32_Process Where ProcessID = " + process.Id);
                    ManagementObjectCollection processList = searcher.Get();

                    foreach (ManagementObject obj in processList)
                    {
                        string[] argList   = new string[] { string.Empty, string.Empty };
                        int      returnVal = Convert.ToInt32(obj.InvokeMethod("GetOwner", argList));
                        if (returnVal == 0)
                        {
                            if (argList[1] + "\\" + argList[0] == username)
                            {
                                process.Kill();
                            }
                        }
                    }
                }
            }
            catch (Exception)
            {
            }

            //clear current badge
            CurrentBadge = null;

            // 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.
            if (string.IsNullOrWhiteSpace(Settings.Default.sessionid) || !IsSteamReady)
            {
                ResetClientStatus();
            }
            else
            {
                if (ReloadCount != 0)
                {
                    return;
                }
                if (CanIdleBadges.Any())
                {
                    statistics.setRemainingCards((uint)CardsRemaining);
                    tmrStatistics.Enabled = true;
                    tmrStatistics.Start();
                    if (Settings.Default.OnlyOneGameIdle)
                    {
                        StartSoloIdle(CanIdleBadges.First());
                    }
                    else
                    {
                        if (Settings.Default.OneThenMany)
                        {
                            var multi = CanIdleBadges.Where(b => b.HoursPlayed >= b.MinPlayTime);
                            if (multi.Count() >= 1)
                            {
                                StartSoloIdle(multi.First());
                            }
                            else
                            {
                                StartMultipleIdle();
                            }
                        }
                        else
                        {
                            var multi = CanIdleBadges.Where(b => b.HoursPlayed < b.MinPlayTime);
                            if (multi.Count() >= 2)
                            {
                                StartMultipleIdle();
                            }
                            else
                            {
                                StartSoloIdle(CanIdleBadges.First());
                            }
                        }
                    }
                }
                else
                {
                    IdleComplete();
                }

                UpdateStateInfo();
            }
        }