private Outcome CalculateOutcome(PlayerHand playerHand, DealerHand dealerHand) { var player = playerHand.FinalValue; var dealer = dealerHand.FinalValue; if (dealerHand.IsBlackjack) { return(playerHand.IsBlackjack ? Outcome.Push : Outcome.Lose); } else if (dealerHand.IsBusted) { return(Outcome.Win); } else if (player > dealer) { return(Outcome.Win); } else if (player < dealer) { return(Outcome.Lose); } else { return(Outcome.Push); } }
private void FinishHand(PlayerHand playerHand, DealerHand dealerHand) { var outcome = CalculateOutcome(playerHand, dealerHand); if (outcome == Outcome.Win) { Console.WriteLine($"{playerHand.Player.Name}, you won!"); playerHand.Win(); dealerHand.Lose(); } else if (outcome == Outcome.Lose) { Console.WriteLine($"{playerHand.Player.Name}, you lost."); playerHand.Lose(); dealerHand.Win(); } else { Console.WriteLine($"{playerHand.Player.Name}, you pushed."); playerHand.Push(); dealerHand.Push(); } Thread.Sleep(2000); dealerHand.Dealer.Sweep(DiscardTray, playerHand); Draw(); }
private void PlayHand(DealerHand hand) { hand.IsTurnPending = false; Draw(); if (HasActivePlayers) { while (hand.KeepPlaying) { Dealer.Deal(Shoe, hand); Draw(); } } Thread.Sleep(2000); }
public void Reset() { Hand = new DealerHand(this); }
public Dealer() { Hand = new DealerHand(this); }