Esempio n. 1
0
        /// <summary>
        /// Set up a new game for the specified number of players.
        /// </summary>
        private void NewGame(int nPlayers, bool chess960)
        {
            // clean up all of the things first
            if (!m_manualBoard)
            {
                Stop();
            }

            // create new game for number of players
            m_aigame = (nPlayers == 0);
            chess    = new ChessRun(this, nPlayers, !m_manualBoard, chess960);

            // show turn status
            SetTurn(Player.WHITE);
            SetStatus(false, "White's turn");

            // reset timers
            m_whiteTime       = new TimeSpan(0);
            m_blackTime       = new TimeSpan(0);
            lblWhiteTime.Text = m_whiteTime.ToString("c");
            lblBlackTime.Text = m_blackTime.ToString("c");

            // show ai difficulty
            if (nPlayers < 2)
            {
                LogMove("AI Difficulty " + (string)temp.Tag + "\n");
            }

            if (m_manualBoard)
            {
                // allow setting up the board
                SetStatus(false, "You may now place pieces via the menu.");
                setPieceToolStripMenuItem.Enabled = true;
            }
            else
            {
                // start the game
                SetStatus(false, "White's Turn");
                if (m_aigame)
                {
                    new Thread(chess.AISelect).Start();
                }
                tmrWhite.Start();
            }

            // allow stopping the game
            endCurrentGameToolStripMenuItem.Enabled = true;
        }
Esempio n. 2
0
        /// <summary>
        /// Stop all current activity / games and reset everything.
        /// </summary>
        private void Stop()
        {
            SetStatus(false, "Choose New Game or Manual Board.");

            // stop the ai and reset chess
            AI.STOP = true;
            chess   = null;

            // reset turn indicator
            SetTurn(Player.WHITE);

            // reset timers
            tmrWhite.Stop();
            tmrBlack.Stop();
            m_whiteTime       = new TimeSpan(0);
            m_blackTime       = new TimeSpan(0);
            lblWhiteTime.Text = m_whiteTime.ToString("c");
            lblBlackTime.Text = m_blackTime.ToString("c");

            // clear the board ui and log
            SetBoard(new ChessBoard());
            txtLog.Text = "";

            // reset board status vars
            m_checkmate      = false;
            m_aigame         = false;
            m_finalizedBoard = false;

            // reset the menu
            manualBoardToolStripMenuItem.Enabled    = true;
            endCurrentGameToolStripMenuItem.Enabled = false;
            if (m_finalizedBoard || m_manualBoard)
            {
                setPieceToolStripMenuItem.Enabled    = false;
                manualBoardToolStripMenuItem.Checked = false;
            }
            endCurrentGameToolStripMenuItem.Enabled = false;
        }