示例#1
0
        /// <summary>
        /// Resets the game, including putting all the players on the Start square.
        /// This requires updating what is displayed in the GUI,
        /// as well as resetting the attrtibutes of HareAndTortoiseGame .
        /// This method is used by both the Reset button and
        /// when a new value is chosen in the Number of Players ComboBox.
        /// Pre:  none.
        /// Post: the form displays the game in the same state as when the program first starts
        ///       (except that any user names that the player has entered are not reset).
        /// </summary>
        private void ResetGame()
        {
            // removes players from the board
            ResetPlayersInfoInDataGridView();
            UpdatePlayersGuiLocations(TypeOfGuiUpdate.RemovePlayer);
            // places players location at the start of the board
            HareAndTortoiseGame.SetPlayersAtTheStart();
            // resets game controls
            groupBox1.Visible = true;

            // adds all players the board
            UpdatePlayersGuiLocations(TypeOfGuiUpdate.AddPlayer);
        }
        } // end SetupPlayersDataGridView

        /// <summary>
        /// Resets the game, including putting all the players on the Start square.
        /// This requires updating what is displayed in the GUI,
        /// as well as resetting the attrtibutes of HareAndTortoiseGame .
        /// This method is used by both the Reset button and
        /// when a new value is chosen in the Number of Players ComboBox.
        /// Pre:  none.
        /// Post: the form displays the game in the same state as when the program first starts
        ///       (except that any user names that the player has entered are not reset).
        /// </summary>
        private void ResetGame()
        {
            // ########################### Code needs to be written  ##############################################
            UpdatePlayersGuiLocations(TypeOfGuiUpdate.RemovePlayer);
            HareAndTortoiseGame.SetPlayersAtTheStart();
            UpdatePlayersGuiLocations(TypeOfGuiUpdate.AddPlayer);
            SetMaxNumberOfPlayers();
            DisableRollDiceButton();
            ClearRadioButtons();
            EnableSingleStepGroupBox();
            DisableNextPlayerButton();
            MakeNextPlayerButtonInvisible();
            RefreshPlayersInfoInDataGridView();
            playerNumber = HareAndTortoiseGame.FIRST_PLAYER_NUMBER - 1;
        } // end ResetGame
        } // end resetButton_Click

        /// <summary>
        /// Handles the Number of Players combobox being selected
        /// Pre: Number of players is selected
        /// Post: The game runs with specified number of players
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void numberOfPlayersComboBox_SelectedIndexChanged(object sender, EventArgs e)
        {
            int numberOfPlayers = GetNumberOfPlayers();

            UpdatePlayersGuiLocations(TypeOfGuiUpdate.RemovePlayer);
            HareAndTortoiseGame.SetPlayersAtTheStart(numberOfPlayers);
            HareAndTortoiseGame.SetInactivePlayers(numberOfPlayers);
            UpdatePlayersGuiLocations(TypeOfGuiUpdate.AddPlayer);
            playerNumber = HareAndTortoiseGame.FIRST_PLAYER_NUMBER - 1;
            EnableSingleStepGroupBox();
            ClearRadioButtons();
            DisableNextPlayerButton();
            MakeNextPlayerButtonInvisible();
            DisableRollDiceButton();
            RefreshPlayersInfoInDataGridView();
        } // end numberOfPlayersComboBox_SelectedIndexChanged
示例#4
0
        /// <summary>
        /// Resets the game, including putting all the players on the Start square.
        /// This requires updating what is displayed in the GUI,
        /// as well as resetting the attrtibutes of HareAndTortoiseGame .
        /// This method is used by both the Reset button and
        /// when a new value is chosen in the Number of Players ComboBox.
        /// Pre:  none.
        /// Post: the form displays the game in the same state as when the program first starts
        ///       (except that any user names that the player has entered are not reset).
        /// </summary>
        private void ResetGame()
        {
            // ########################### Code needs to be written  ###############################################

            //UpdatePlayersGuiLocations(TypeOfGuiUpdate.RemovePlayer);
            cbPlayers.SelectedItem = HareAndTortoiseGame.NumberOfPlayers;
            HareAndTortoiseGame.SetPlayersAtTheStart();
            cbPlayers.SelectedItem = HareAndTortoiseGame.NumberOfPlayers;
            btnRollDice.Enabled    = true;

            UpdatePlayersGuiLocations(TypeOfGuiUpdate.AddPlayer);

            foreach (Player player in HareAndTortoiseGame.Players)
            {
                player.Money  = 100;
                player.Winner = false;
            }

            RefreshPlayersInfoInDataGridView();
        }