// Invoked when the deal button is clicked private void Btn_deal_Click(object sender, EventArgs e) { try { // If the current bet is equal to 0, ask the player to place a bet if ((refPlayer.Bet == 0) && (refPlayer.Balance > 0)) { MessageBox.Show(refPlayer.Name + " must place a bet before the dealer deals.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { UpdateButtonsAfterDeal(); game.ReadyToDeal++; if (game.ReadyToDeal < game.ActivePlayers) { return; } game.PlaceBets(); game.DealNewGame(); } } catch (Exception NotEnoughMoneyException) { MessageBox.Show(NotEnoughMoneyException.Message); } }
/// <summary> /// Invoked when the deal button is clicked /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void DealBtn_Click(object sender, EventArgs e) { try { // If the current bet is equal to 0, ask the player to place a bet if ((game.CurrentPlayer.Bet == 0) && (game.CurrentPlayer.Balance > 0)) { MessageBox.Show("You must place a bet before the dealer deals.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { // Place the bet game.CurrentPlayer.PlaceBet(); ShowBankValue(); // Clear the table, set up the UI for playing a game, and deal a new game ClearTable(); SetUpGameInPlay(); game.DealNewGame(); UpdateUIPlayerCards(); // Check see if the current player has blackjack if (game.CurrentPlayer.HasBlackJack()) { EndGame(EndResult.PlayerBlackJack); } } } catch (Exception NotEnoughMoneyException) { MessageBox.Show(NotEnoughMoneyException.Message); } }