Ejemplo n.º 1
0
        /// <summary>
        /// Event Handler that runs when the user clicks on the double button
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private async void OnDoubleClick(object sender, RoutedEventArgs e)
        {
            //if the player has the funs to double
            if (_game.Double() == true)
            {
                //update the bet
                _txtBet.Text = _game.Player.Bet.ToString();

                //if the player has chips remaining
                if (_game.Player.GameMoney != 0)
                {
                    //update the chip count
                    _txtGameMoney.Text = _game.Player.GameMoney.ToString();
                }

                //if the player does not have money left
                else
                {
                    //make the chipstack look empty
                    _txtGameMoney.Text      = "";
                    _uiPlayerChips.Stroke   = new SolidColorBrush(Color.FromArgb(255, 255, 255, 255));
                    _uiPlayerChips.Fill     = new SolidColorBrush();
                    _uiPlayerChip.IsEnabled = false;
                }

                //update the chip total
                _txtChipCount.Text = $"CHIP TOTAL: {_game.Player.GameMoney.ToString()}";

                //disable the game buttons
                _btnHold.IsEnabled   = false;
                _btnHit.IsEnabled    = false;
                _btnDouble.IsEnabled = false;

                //draw the cards again
                DrawCardsBE(_canvasPlayerHand, _game.Player.Hand, Alignment.Center);

                //if the soft-hand value of the player has a value
                if (_game.Player.SoftHandValue != 0)
                {
                    //show the plaer;s score and soft-hand score
                    _txtPlayerTotal.Text = $"{_game.Player.Score.ToString()}/{_game.Player.SoftHandValue.ToString()}";
                    _game.Player.Score   = _game.Player.SoftHandValue;
                }

                //if there is no soft-hand value
                else
                {
                    //show the player's score
                    _txtPlayerTotal.Text = _game.Player.Score.ToString();
                }

                //delay
                await Task.Delay(TimeSpan.FromMilliseconds(1500));

                //if the player's score is above 21
                if (_game.Player.Score > 21)
                {
                    //end the round - the player busted
                    EndRound("PLAYER BUST, DEALER WINS");
                }

                //if the player's score is not above 21
                else
                {
                    //start dealing the dealer cards
                    _tmDealerCardTimer.Start();
                }

                //update the socre label
                _txtPlayerTotal.Text = _game.Player.Score.ToString();
            }
        }