def test_blackjack_with_dealer_blackjack_return_true(self):
     player, player_hand, dealer_hand = self.setup_dealer_blackjack()
     self.assertTrue(blackjack_test(player, player_hand, dealer_hand))
示例#2
0
            x = deck.deal()
            dealer_hand.add_card(x)
            if i == 1:
                print(
                    "There are {} cards left in the deck.".format(
                        deck.cards_left()))
                print("The dealer's face-up card is a {}".format(x))
                print("")

                print(
                    "Your hand consists of:{}".format(
                        player_hand.show_cards()))
    print("Your score is: {}".format(player_hand.score()))

    # handling being dealt a blackjack
    if blackjack_test(player, player_hand, dealer_hand) == False:
        hit = 'y'

        # the player gets to hit or stay
        while ((hit != 'n') and (player_hand.score() <= 21)):

            hit = (input("Hit? (y/n)").lower())
            if hit != 'n':
                x = deck.deal()
                player_hand.add_card(x)
                print("You were dealt a {}.".format(x))
                print("Your score is: {}".format(player_hand.score()))

        # dealer logic
        print(
            "The dealer shows his hand and has {}".format(
 def test_blackjack_with_dealer_blackjack_money_lost(self):
     player, player_hand, dealer_hand = self.setup_dealer_blackjack()
     blackjack_test(player, player_hand, dealer_hand)
     self.assertEqual(player.money, Decimal(0))
 def test_blackjack_with_blackjack_money_added(self):
     player, player_hand, dealer_hand = self.setup_player_blackjack()
     blackjack_test(player, player_hand, dealer_hand)
     self.assertEqual(player.money, Decimal(2.5))
 def test_blackjack_with_blackjack_wins_increment(self):
     player, player_hand, dealer_hand = self.setup_player_blackjack()
     blackjack_test(player, player_hand, dealer_hand)
     self.assertEqual(player.wins, 1)
 def test_blackjack_with_dual_blackjacks_return_true(self):
     player, player_hand, dealer_hand = self.setup_dual_blackjack_scenario()
     self.assertTrue(blackjack_test(player, player_hand, dealer_hand))
 def test_blackjack_no_blackjack_returns_false(self):
     player, player_hand, dealer_hand = self.setup_player_non_blackjack()
     self.assertFalse(blackjack_test(player, player_hand, dealer_hand))