/// <summary>
        /// Returns the amount won or lost based on the dealer's
        /// hand.  Returns 0.0M for "push" (tie).
        /// </summary>
        public decimal BetResult(PlayerBlackjackHand playerHand, decimal blackjackPayout)
        {
            if (this.IsBlackjack && playerHand.IsBlackjack) {
                return 0.0M;
            }

            if (this.IsBlackjack) {
                return -playerHand.Bet;
            }

            if (playerHand.IsBlackjack) {
                return playerHand.Bet * blackjackPayout;
            }

            if (playerHand.IsBusted) {
                return -playerHand.Bet;
            }

            if (this.IsBusted) {
                return playerHand.Bet;
            }

            if (this.Value == playerHand.Value) {
                return 0.0M;
            }

            if (this.Value < playerHand.Value) {
                return playerHand.Bet;
            }

            return -playerHand.Bet;
        }
Exemplo n.º 2
0
        private void DealButtonClick(object sender, EventArgs e)
        {
            PlayerBlackjackHand.AllowUnnaturalSplits = allowUnnaturalSplitsCheckBox.Checked;
            deck = new Shoe((int)deckNumericUpDown.Value);
            deck.PerfectShuffle();

            dealerHand = new DealerBlackjackHand();
            playerHands = new List<PlayerBlackjackHand>();
            PlayerBlackjackHand hand = new PlayerBlackjackHand(betAmountNumericUpDown.Value);
            playerHands.Add(hand);
            handInPlay = 0;

            hand.Hit(deck.Deal(true));
            dealerHand.Hit(deck.Deal(false));
            hand.Hit(deck.Deal(true));
            dealerHand.Hit(deck.Deal(true));

            // Shut down the dealing area for now,
            //	until end of hand:
            bankGroupBox.Enabled = false;
            configurationGroupBox.Enabled = false;
            resultsLabel.Text = "";

            // Show hands:
            dealerHandPanel.Hand = dealerHand;
            SetPlayerHands();

            // Configure controls for the current hand:
            if (playerHands[handInPlay].IsBlackjack) {
                standButton.Enabled = true;
                standButton.PerformClick();
            } else {
                // Check for dealer blackjack:
                if (dealerHand.IsBlackjack) handInPlay = 1;
                ConfigureControls(handInPlay);
            }
        }