示例#1
0
        private void HitButton_Click(object sender, RoutedEventArgs e)
        {
            DoubleDownButton.Visibility = Visibility.Hidden;
            SplitButton.Visibility      = Visibility.Hidden;

            string playerName = GetCurrentPlayerName();

            BlackJackController.HitMe(playerName, false);
            if (BlackJackController.IsBusted(playerName, false))
            {
                HitButton.Visibility = Visibility.Hidden;
                PlayerBustDisplays[playerTurn].Content = "Busted";
            }
            //UpdateHands();
            DisplayCurrentHand();
            PlayerTotalDisplays[playerTurn].Content = $":{BlackJackController.GetTotal(GetCurrentPlayerName(), false)}";
        }
示例#2
0
        public void UpdateHands()
        {
            for (int i = 0; i < NumPlayers; i++)
            {
                PlayerHandDisplays[i].Children.Clear();

                string name  = PlayerNameDisplays[i].Content.ToString();
                int    total = BlackJackController.GetTotal(name, false);
                PlayerTotalDisplays[i].Content = $":{total}";
                if (BlackJackController.IsBusted(name, false))
                {
                    PlayerBustDisplays[i].Content = "Busted";
                }
                var hand = BlackJackController.blackjack.GetPlayer(PlayerNameDisplays[i].Content.ToString()).Hand;
                PlayerHandDisplays[i].Children.Clear();
                PlayerContinuedHandDisplays[i].Children.Clear();

                int count = 0;
                foreach (var card in hand)
                {
                    count++;
                    var pic = ConvertToPicture(card);
                    if (count <= 3)
                    {
                        PlayerHandDisplays[i].Children.Add(pic);
                    }
                    else
                    {
                        PlayerContinuedHandDisplays[i].Children.Add(pic);
                    }
                }
            }
            var dealerHand = BlackJackController.house.Hand;

            DealerHand.Children.Clear();
            foreach (var card in dealerHand)
            {
                var pic = ConvertToPicture(card);
                DealerHand.Children.Add(pic);
            }
        }