Example #1
0
        bool PlayHand(Player player, Card dealerTopCard, Shoe shoe)
        {
            PlayAction play = player.Play(player.Hand, dealerTopCard);

            if (play == PlayAction.Stay)
            {
                return(true);
            }
            if (play == PlayAction.Hit)
            {
                Card card = shoe.GetNextCard();
                bool bust = player.TakeCard(card);
                if (bust)
                {
                    return(false);
                }
                return(PlayHand(player, dealerTopCard, shoe));
            }
            if (play == PlayAction.Double)
            {
                if (player.Hand.Count() != 2)
                {
                    throw new Exception("only double on first");
                }
                var bust = player.TakeCard(shoe.GetNextCard());
                if (bust)
                {
                    return(false);
                }
                return(true);
            }
            throw new InvalidOperationException("shouldn't be here");
        }
Example #2
0
        Card SeedTable(Player[] players, Player dealer, Shoe shoe)
        {
            players.ForEach(x => x.TakeCard(shoe.GetNextCard()));
            dealer.TakeCard(shoe.GetNextCard());
            players.ForEach(x => x.TakeCard(shoe.GetNextCard()));

            Card dealerTopCard = shoe.GetNextCard();

            dealer.TakeCard(dealerTopCard);

            return(dealerTopCard);
        }
Example #3
0
 bool PlayHand(Player player, Card dealerTopCard, Shoe shoe)
 {
     PlayAction play = player.Play(player.Hand, dealerTopCard);
     if (play == PlayAction.Stay)
     {
         return true;
     }
     if (play == PlayAction.Hit)
     {
         Card card = shoe.GetNextCard();
         bool bust = player.TakeCard(card);
         if (bust)
             return false;
         return PlayHand(player, dealerTopCard, shoe);
     }
     if (play == PlayAction.Double)
     {
         if (player.Hand.Count() != 2)
             throw new Exception("only double on first");
         var bust = player.TakeCard(shoe.GetNextCard());
         if (bust)
             return false;
         return true;
     }
     throw new InvalidOperationException("shouldn't be here");
 }
Example #4
0
        Card SeedTable(Player[] players, Player dealer, Shoe shoe)
        {
            players.ForEach(x => x.TakeCard(shoe.GetNextCard()));
            dealer.TakeCard(shoe.GetNextCard());
            players.ForEach(x => x.TakeCard(shoe.GetNextCard()));

            Card dealerTopCard = shoe.GetNextCard();
            dealer.TakeCard(dealerTopCard);

            return dealerTopCard;
        }
Example #5
0
 public Card Deal()
 {
     return(_shoe.GetNextCard());
 }