Esempio n. 1
0
        public void ReversiGameLoop()
        {
            bool   wantToContinueGame = true;
            string messageForPlayers  = string.Empty;
            int    blackWins          = 0;
            int    whiteWins          = 0;

            while (wantToContinueGame)
            {
                m_GameForm = new ReversiGameForm(m_ReversiGameManager);
                m_GameForm.ShowDialog();

                if (m_BlackPlayer.PlayerScore > m_WhitePlayer.PlayerScore)
                {
                    blackWins++;
                }
                else if (m_WhitePlayer.PlayerScore > m_BlackPlayer.PlayerScore)
                {
                    whiteWins++;
                }
                else
                {
                    blackWins++;
                    whiteWins++;
                }

                messageForPlayers = string.Format(
                    "{0} won!! ({1}/{2}) ({3}/{4}){5} Would you like another round?",
                    m_ReversiGameManager.WhoIsAWinner(),
                    m_BlackPlayer.PlayerScore,
                    m_WhitePlayer.PlayerScore,
                    blackWins,
                    whiteWins,
                    Environment.NewLine);

                if (MessageBox.Show(messageForPlayers, "Reversi", MessageBoxButtons.YesNo, MessageBoxIcon.Information) == DialogResult.No)
                {
                    wantToContinueGame = false;
                }
                else
                {
                    m_ReversiGameManager.RestartGame();
                }
            }
        }