示例#1
0
        /// <summary>
        /// Call the PlayGame function and determine the outcome of the round. Allow another turn if player did not roll a 1 or call the next player if player did roll a 1.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void rollButton_Click(object sender, EventArgs e)
        {
            int points = Pig_Single_Die_Game.GetPointsTotal(pigLabelWhosTurnTo.Text);

            if (!Pig_Single_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_Single_Die_Game.GetNextPlayersName();
            }

            if (Pig_Single_Die_Game.HasWon())
            {
                WonGame();
            }
        }
示例#2
0
 /// <summary>
 /// Rolls die through .PlayGame(), updates image, changes player, checks for wins
 /// Updates WhosTurnToLabel, updates textbox, enables groupbox.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void RollButton_Click(object sender, EventArgs e)
 {
     if (Pig_Single_Die_Game.current_player == 1)
     {
         Pig_Single_Die_Game.PlayGame();
         PictureBox.Image           = Images.GetDieImage(Pig_Single_Die_Game.GetFaceValue());
         PlayerOneTotalTextBox.Text = Pig_Single_Die_Game.overall_points.ToString();
         if (Pig_Single_Die_Game.did_roll_one == 1)
         {
             MessageBox.Show("You have thrown a 1.\n Your turn is over!\n Your overall_points reverts to " + Pig_Single_Die_Game.GetPointsTotal() + "!");
             Pig_Single_Die_Game.current_player = 2;
             WhoseTurnToLabel.Text = "Player 2";
         }
         if (Pig_Single_Die_Game.HasWon())
         {
             MessageBox.Show("Player 1 has won!\n Well done!");
             AnotherGameGroupBox.Enabled = true;
         }
     }
     else if (Pig_Single_Die_Game.current_player == 2)
     {
         Pig_Single_Die_Game.PlayGame();
         PictureBox.Image           = Images.GetDieImage(Pig_Single_Die_Game.GetFaceValue());
         PlayerTwoTotalTextBox.Text = Pig_Single_Die_Game.overall_points.ToString();
         if (Pig_Single_Die_Game.did_roll_one == 1)
         {
             MessageBox.Show("You have thrown a 1.\n Your turn is over!\n Your overall_points reverts to " + Pig_Single_Die_Game.GetPointsTotal() + "!");
             Pig_Single_Die_Game.current_player = 1;
             WhoseTurnToLabel.Text            = "Player 1";
             Pig_Single_Die_Game.did_roll_one = 0;
         }
         if (Pig_Single_Die_Game.HasWon())
         {
             MessageBox.Show("Player 2 has won!\n Well done!");
             AnotherGameGroupBox.Enabled = true;
         }
     }
 }//end of RollButton_Click
示例#3
0
        } // end ExitProgram()

        // Event handlers

        private void btnRoll_Click(object sender, EventArgs e)
        {
            bool playGame = Pig_Single_Die_Game.PlayGame();

            SetDieImage();

            if (playGame == false)
            {
                EndTurn();
            }
            else
            {
                EnableHoldButton();

                SetRollOrHoldMessage();

                SetPlayerScores();

                if (Pig_Single_Die_Game.HasWon())
                {
                    VictoryMessage();
                }
            }
        }// end btnRoll_Click