예제 #1
0
파일: Table.cs 프로젝트: mahosi1/Blackjack
        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");
        }
예제 #2
0
파일: Table.cs 프로젝트: mahosi1/Blackjack
        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);
        }
예제 #3
0
파일: Table.cs 프로젝트: mahosi1/Blackjack
 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");
 }
예제 #4
0
파일: Table.cs 프로젝트: mahosi1/Blackjack
        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;
        }
예제 #5
0
 public Card Deal()
 {
     return(_shoe.GetNextCard());
 }