private void PlayersTurn() { var crd = DealCard(); PlayerHand.Add(crd); DisplayCard(playersCards, crd); playerShown += crd.Value; UpdatePlayerShown(); if (playerShown < 21) { return; } else if (playerShown == 21) { Dispatcher.Invoke(() => btnStand_Click(null, null)); return; } else { if (PlayerHand.Where(pc => pc.Value == 11).Any()) { PlayerHand.Where(pc => pc.Value == 11).First().Value = 1; playerShown -= 10; UpdatePlayerShown(); } else { MessageBox.Show("Dealer Wins", "Bust"); ShowFaceDown(); Dispatcher.Invoke(() => { btnHit.IsEnabled = false; btnStand.IsEnabled = false; }); } } }
private void DealHands() { PlayerHand.Add(DealCard()); DisplayCard(playersCards, PlayerHand.Last()); DealerHand.Add(DealCard()); DisplayCard(dealersCards, DealerHand.Last()); PlayerHand.Add(DealCard()); DisplayCard(playersCards, PlayerHand.Last()); DealerHand.Add(DealCard()); Dispatcher.Invoke(() => dealersCards.Children.Add(new TextEdit() { Name = "FaceDown" })); DealCheck(); if (!gameOver) { Dispatcher.Invoke(() => { btnHit.IsEnabled = true; btnStand.IsEnabled = true; }); } }