예제 #1
0
 private void CancelGameButton_Click(object sender, EventArgs e)
 {
     if (TwentyOne_Game.GetNumOfGamesWon(0) > TwentyOne_Game.GetNumOfGamesWon(1))            // If player wins
     {
         MessageBox.Show("You won! Well done.");                                             // Show message
         TwentyOne_Game.ResetTotals();                                                       // Reset points and games
         this.Hide();                                                                        // Close window
         First_GUI_Form GameForm = new First_GUI_Form();                                     // Open initial window
         GameForm.Closed += (s, args) => this.Close();                                       // Dispose this form together when the other is closed
         GameForm.Show();                                                                    // Show the initial menu
     }
     else if (TwentyOne_Game.GetNumOfGamesWon(0) < TwentyOne_Game.GetNumOfGamesWon(1))       // If dealer wins
     {
         MessageBox.Show("House won! Better luck next time.");                               // " "
         TwentyOne_Game.ResetTotals();
         this.Hide();
         First_GUI_Form GameForm = new First_GUI_Form();
         GameForm.Closed += (s, args) => this.Close();
         GameForm.Show();
     }
     else                                                                                    // If it was a draw
     {
         MessageBox.Show("It was a draw!");
         TwentyOne_Game.ResetTotals();
         this.Hide();
         First_GUI_Form GameForm = new First_GUI_Form();
         GameForm.Closed += (s, args) => this.Close();
         GameForm.Show();
     }
 }
예제 #2
0
        }// End DisplayGuiHand

        /// <summary>
        /// Updates the GUI labels and displays the hands onto the tables
        /// </summary>
        private void UpdateGUI()
        {
            // Update games won count labels
            WonGamePlayer.Text  = TwentyOne_Game.GetNumOfGamesWon(0).ToString();
            WonGamesDealer.Text = TwentyOne_Game.GetNumOfGamesWon(1).ToString();

            // Display hands onto GUI
            DisplayGuiHand(TwentyOne_Game.GetHand(0), playerTable);
            DisplayGuiHand(TwentyOne_Game.GetHand(1), dealerTable);

            // Update dealer and player points label
            PointsPlayer.Text = TwentyOne_Game.GetTotalPoints(0).ToString();
            PointsDealer.Text = TwentyOne_Game.GetTotalPoints(1).ToString();

            // Update ace count label
            AceCountOne.Text = TwentyOne_Game.GetNumOfUserAcesWithValueOne().ToString();
        }// End UpdateGUI