Exemplo n.º 1
0
    def check_hands_test(self):
        p1 = Player()
        p1.add_card(Card("ace", "spades"))
        p1.add_card(Card("jack", "hearts"))

        self.assertEqual("ace of spades & jack of hearts", p1.print_hand())

        p2 = Dealer()
        p2.add_card(Card("one", "spades"))
        p2.add_card(Card("ten", "diamonds"))

        self.assertEqual("XX & ten of diamonds", p2.print_hand())
Exemplo n.º 2
0
		rank, suit = deal_card().split(',')
		dealer.add_card(Card(rank,suit))

		rank, suit = deal_card().split(',')
		dealer.add_card(Card(rank,suit))

		# Deal player cards
		player = Player()
		rank, suit = deal_card().split(',')
		player.add_card(Card(rank,suit))

		rank, suit = deal_card().split(',')
		player.add_card(Card(rank,suit))

		# Show hands
		print "Dealers Hand : %s", dealer.print_hand()
		print "Players Hand : %s", player.print_hand()

		# Get choice from Player
		player_choice = raw_input("Enter Choice : H(it) or S(tand) - ").lower()
		if player_choice == 'h':
			rank, suit = deal_card().split(',')
			player.add_card(Card(rank,suit))

		print "Dealers Hand : %s", ' & '.join([card[0] + ' of ' + card[1] for card in dealer.cards])
		print "Players Hand : %s", player.print_hand()

		if (get_winning_hand(dealer,player) == player):
			print "Player Wins!!"
		else:
			print "Dealer Wins ...."