}// End UpdateGUI private void DealButton_Click(object sender, EventArgs e) { // Set up a new game TwentyOne_Game.SetUpGame(); // Deal cards and then display them for (int i = 0; i < 2; i++) { TwentyOne_Game.DealOneCardTo(0); // Deal two cards to player TwentyOne_Game.DealOneCardTo(1); // Deal two cards to dealer } DisplayGuiHand(TwentyOne_Game.GetHand(0), playerTable); DisplayGuiHand(TwentyOne_Game.GetHand(1), dealerTable); // Update labels AceCountOne.Text = TwentyOne_Game.GetNumOfUserAcesWithValueOne().ToString(); BustedDealer.Visible = false; BustedPlayer.Visible = false; PointsPlayer.Text = TwentyOne_Game.CalculateHandTotal(0).ToString(); PointsPlayer.Visible = true; PointsDealer.Text = TwentyOne_Game.CalculateHandTotal(1).ToString(); PointsDealer.Visible = true; // Enable and disable buttons StandBtn.Enabled = true; HitBtn.Enabled = true; DealBtn.Enabled = false; }
}// 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