/// <summary> /// Handles everything for the round. /// </summary> static void StartRound() { Console.Clear(); if (!TakeBet()) { EndRound(RoundResult.INVALID_BET); return; } Console.Clear(); InitializeHands(); TakeActions(); Dealer.RevealCard(); Console.Clear(); player.WriteHand(); Dealer.WriteHand(); player.HandsCompleted++; if (player.Hand.Count == 0) { EndRound(RoundResult.SURRENDER); return; } else if (player.GetHandValue() > 21) { EndRound(RoundResult.PLAYER_BUST); return; } while (Dealer.GetHandValue() <= 16) { Thread.Sleep(1000); Dealer.RevealedCards.Add(deck.DrawCard()); Console.Clear(); player.WriteHand(); Dealer.WriteHand(); } if (player.GetHandValue() > Dealer.GetHandValue()) { player.Wins++; if (Casino.IsHandBlackjack(player.Hand)) { EndRound(RoundResult.PLAYER_BLACKJACK); } else { EndRound(RoundResult.PLAYER_WIN); } } else if (Dealer.GetHandValue() > 21) { player.Wins++; EndRound(RoundResult.PLAYER_WIN); } else if (Dealer.GetHandValue() > player.GetHandValue()) { EndRound(RoundResult.DEALER_WIN); } else { EndRound(RoundResult.PUSH); } }
// How we start the game static void StartRound() { Clear(); if (!TakeBet()) { EndRound(RoundResult.INVALID_BET); return; } Clear(); StartHands(); Actions(); Dealer.ShowCard(); Clear(); player.WriteHand(); Dealer.WriteHand(); player.HandsCompleted++; if (player.Hand.Count == 0) { EndRound(RoundResult.FOLD); return; } else if (player.GetHandValue() > 21) { EndRound(RoundResult.PLAYER_BUST); return; } while (Dealer.GetHandValue() <= 16) { Dealer.RevealedCards.Add(deck.DrawCard()); Clear(); player.WriteHand(); Dealer.WriteHand(); } if (player.GetHandValue() > Dealer.GetHandValue()) { player.Wins++; if (Casino.IsHandBlackjack(player.Hand)) { EndRound(RoundResult.PLAYER_BLACKJACK); } else { EndRound(RoundResult.PLAYER_WIN); } } else if (Dealer.GetHandValue() > 21) { player.Wins++; EndRound(RoundResult.PLAYER_WIN); } else if (Dealer.GetHandValue() > player.GetHandValue()) { EndRound(RoundResult.DEALER_WIN); } else { EndRound(RoundResult.PUSH); } }