Пример #1
0
        /// <summary>
        /// Method used to perform actions when the round starts - called by the start button on click method
        /// </summary>
        private async void StartRound()
        {
            //start the round
            _game.StartRound();

            _firstTimerTick = true;
            _started        = true;

            //disable and close neccessary controls
            _btnOpenPane.IsEnabled  = false;
            _btnStart.IsEnabled     = false;
            _uiPlayerChip.IsEnabled = false;

            //adjust visibilities and text
            _btnOpenPane.Visibility         = Visibility.Collapsed;
            _uiDealerScoreBorder.Visibility = Visibility.Collapsed;
            _txtDealerTotal.Text            = "";

            //use delays and draw the hands of the player and dealer
            await Task.Delay(TimeSpan.FromMilliseconds(1500));

            DrawCardsBE(_canvasPlayerHand, _game.Player.Hand, Alignment.Center);
            await Task.Delay(TimeSpan.FromMilliseconds(1500));

            DrawCardsBE(_canvasDealerHand, _game.Dealer.Hand, Alignment.Center);

            //if the player has a soft-hand value
            if (_game.Player.SoftHandValue != 0)
            {
                //if the player has a soft-hand score of 21
                if (_game.Player.SoftHandValue == 21)
                {
                    //show the score of the player on the screen
                    _txtPlayerTotal.Text = _game.Player.SoftHandValue.ToString();
                }

                //if the player has a soft-hand value that is not 21, show their score and soft-hand score beside each othe
                else
                {
                    _txtPlayerTotal.Text = $"{_game.Player.Score.ToString()}/{_game.Player.SoftHandValue.ToString()}";
                }
            }

            //if the player does not have a soft-hand value
            else
            {
                //show their score
                _txtPlayerTotal.Text = _game.Player.Score.ToString();
            }

            //the cards can now scale and be dynamically drawn
            DrawScreen();

            //check if the player or dealer got blackjack
            GameBlackJack();

            //if nobody got blackjack
            if (_game.DetermineBlackJack() == "none")
            {
                //enable the game buttons
                _btnHold.IsEnabled = true;
                _btnHit.IsEnabled  = true;

                //if the player has enough money to double down
                if (_game.Player.GameMoney >= _game.Player.Bet)
                {
                    //enable the double down button
                    _btnDouble.IsEnabled = true;
                }
            }
        }