コード例 #1
0
ファイル: Chessboard.cs プロジェクト: ybarr042/PA6-Draft
        private void MainTimer_Tick(object sender, EventArgs e)
        {
            if (!Game.IsGameFinished())
            {
                if (Game.WhiteTurn)
                {
                    if (time_control)
                    {
                        if (Game.WLimit < 10000 && timer1_less10s)
                        {
                            Game_TimeLeft();
                            timer1_less10s = false;
                        }
                        if (Game.WLimit <= MainTimer.Interval)
                        {
                            Game.WhiteTimeLimit = "0.00";
                            Game.WLimit         = 0;
                            MainTimer.Stop();
                            MessageBox.Show(Game.Player1Name + " lost by timeout");
                        }

                        else
                        {
                            Game.WhiteTimeLimit = Game.TimeToString(Game.WLimit -= MainTimer.Interval);
                            Player1Time.Text    = Game.WhiteTimeLimit;
                        }
                    }
                }
                else
                {
                    if (time_control)
                    {
                        if (Game.BLimit < 10000 && timer2_less10s)
                        {
                            Game_TimeLeft();
                            timer2_less10s = false;
                        }
                        if (Game.BLimit <= MainTimer.Interval)
                        {
                            Game.BlackTimeLimit = "0.00";
                            Game.BLimit         = 0;
                            MainTimer.Stop();
                            MessageBox.Show(Game.Player2Name + " lost by timeout");
                        }
                        else
                        {
                            Game.BlackTimeLimit = Game.TimeToString(Game.BLimit -= MainTimer.Interval);
                            Player2Time.Text    = Game.BlackTimeLimit;
                        }
                    }
                }
            }
        }
コード例 #2
0
ファイル: Chessboard.cs プロジェクト: 4UR3L10/COP4226-06
        private void MainTimer_Tick(object sender, EventArgs e)
        {
            if (Game.WhiteTurn)
            {
                if (Game.WLimit <= MainTimer.Interval)
                {
                    Game.WhiteTimeLimit = "0.00";
                    Game.WLimit         = 0;
                    MainTimer.Stop();
                    MessageBox.Show(Game.Player1Name + " lost by timeout");

                    // Data Binding - Updating the Time When Lose - White.
                    this.Player1Time.Text = Game.WhiteTimeLimit;
                }
                else
                {
                    Game.WhiteTimeLimit = Game.TimeToString(Game.WLimit -= MainTimer.Interval);

                    // Data Binding - Updating the Time When Ticking - White.
                    this.Player1Time.Text = Game.WhiteTimeLimit;
                }
            }
            else
            {
                if (Game.BLimit <= MainTimer.Interval)
                {
                    Game.BlackTimeLimit = "0.00";
                    Game.BLimit         = 0;
                    MainTimer.Stop();
                    MessageBox.Show(Game.Player2Name + " lost by timeout");

                    // Data Binding - Updating the Time When Lose - Black.
                    this.Player2Time.Text = Game.BlackTimeLimit;
                }
                else
                {
                    Game.BlackTimeLimit = Game.TimeToString(Game.BLimit -= MainTimer.Interval);

                    // Data Binding - Updating the Time When Ticking - White.
                    this.Player2Time.Text = Game.BlackTimeLimit;
                }
            }
        }