private void Hold_button2_Click(object sender, EventArgs e) { if (Pig_Double_Die_Game.current_dice_sum == 0) { } else { if (Pig_Double_Die_Game.current_player == "Player 1") { Player_1_textbox.Text = Pig_Double_Die_Game.GetPointsTotal("Player 1").ToString(); Pig_Double_Die_Game.current_player = "Player 2"; Whose_Turn_to_label.Text = "Player 2 Roll Die"; if (Pig_Double_Die_Game.HasWon() == true) { MessageBox.Show("Player 1 has won!"); Yes_Another_pig_radioButton1.Enabled = true; No_another_Pig_radioButton2.Enabled = true; } Pig_Double_Die_Game.current_dice_sum = 0; } else { Player_2_textbox.Text = Pig_Double_Die_Game.GetPointsTotal("Player 2").ToString(); Pig_Double_Die_Game.current_player = "Player 1"; Whose_Turn_to_label.Text = "Player 1 Roll Die"; if (Pig_Double_Die_Game.HasWon() == true) { MessageBox.Show("Player 2 has won!"); Yes_Another_pig_radioButton1.Enabled = true; No_another_Pig_radioButton2.Enabled = true; } Pig_Double_Die_Game.current_dice_sum = 0; } } }
/// <summary> /// Play the game when the dice animation is clicked and determine the outcome of the round. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void playGame() { enableButtons(true); int points = Pig_Double_Die_Game.GetPointsTotal(pigLabelWhosTurnTo.Text); if (!Pig_Double_Die_Game.PlayGame()) { SetupRound(); CountPoints(); } else { SetupRound(); UpdatePoints(points); Program.showOKMessageBox("Sorry, you've thrown a 1.\nYour turn is over.\nYour score reverts to " + points + "."); pigLabelWhosTurnTo.Text = Pig_Double_Die_Game.GetNextPlayersName(); } if (Pig_Double_Die_Game.HasWon()) { WonGame(); } }