} // end exitButton_Click /// <summary> /// Handles the Roll Dice button being clicked /// Pre: Roll Dice button is clicked /// Post: The game runs according to the specified versions ('Single Step' or 'All Together') /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void rollDiceButton_Click(object sender, EventArgs e) { int numberOfPlayers = GetNumberOfPlayers(); bool finished = false; if (noRadiobutton.Checked == true) { UpdatePlayersGuiLocations(TypeOfGuiUpdate.RemovePlayer); for (int i = 0; i < numberOfPlayers; i++) { HareAndTortoiseGame.PlayOneRound(HareAndTortoiseGame.Players, i); HareAndTortoiseGame.SetInactivePlayers(numberOfPlayers); } // end for UpdatePlayersGuiLocations(TypeOfGuiUpdate.AddPlayer); finished = HareAndTortoiseGame.AllPlayerFinished(numberOfPlayers); if (finished == true) { DisableRollDiceButton(); DisableNextPlayerButton(); HareAndTortoiseGame.IdentifyWinner(numberOfPlayers); } // end if RefreshPlayersInfoInDataGridView(); } // end if } // end rollDiceButton_Click
/// <summary> /// Handle the Next Players Roll button being clicked. /// Pre: the Next Players Roll button is clicked. /// Post: based on single move animation, plays one round of the game. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnNextPlayersRoll_Click(object sender, EventArgs e) { SingleStepAnimation(TypeOfGuiUpdate.RemovePlayer); HareAndTortoiseGame.PlayOneRound(); SingleStepAnimation(TypeOfGuiUpdate.AddPlayer); if (HareAndTortoiseGame.Finished) { btnNextPlayersRoll.Enabled = false; } }
/// <summary> /// Handle the Roll Dice button being clicked. /// Pre: the Roll Dice button is clicked. /// Post: plays one round of the game. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnRollDice_Click(object sender, EventArgs e) { UpdatePlayersGuiLocations(TypeOfGuiUpdate.RemovePlayer); HareAndTortoiseGame.PlayOneRound(); UpdatePlayersGuiLocations(TypeOfGuiUpdate.AddPlayer); if (HareAndTortoiseGame.Finished) { btnRollDice.Enabled = false; } }