/// <summary>
        /// Invoked when the player has finished their turn and clicked the stand button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void StandBtn_Click(object sender, EventArgs e)
        {
            // Dealer should finish playing and the UI should be updated
            game.DealerPlay();
            UpdateUIPlayerCards();

            // Check who won the game
            EndGame(GetGameResult());
        }
        /// <summary>
        /// Invoked when the double down button is clicked
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DblDwnBtn_Click(object sender, EventArgs e)
        {
            try
            {
                // Double the player's bet amount
                game.CurrentPlayer.DoubleDown();
                UpdateUIPlayerCards();
                ShowBankValue();

                //Make sure that the player didn't bust
                if (game.CurrentPlayer.HasBust())
                {
                    EndMoveDetected();
                    endResult = EndResult.PlayerBust;
                }
                else
                {
                    // Otherwise, let the dealer finish playing
                    game.DealerPlay(dealer);
                    UpdateUIPlayerCards();
                    EndMoveDetected();
                    endResult = GetGameResult();
                }
            }
            catch (Exception NotEnoughMoneyException)
            {
                MessageBox.Show(NotEnoughMoneyException.Message);
            }
        }
Exemple #3
0
        private void CurrentPlayerFinishToPlay(object sender, EventArgs e)
        {
            currentForm.UpdateButtonsFinishPlay();

            game.NextPlayer();
            if (UpdateCurrentForm())
            {
                currentForm.UpdateButtonsToPlay();
            }
            else
            {
                // All players are finish to play.
                game.DealerPlay();
                UpdateUIAfterDeal(this, new EventArgs());
                EndGame();
            }
        }