Esempio n. 1
0
def start_game():
    deck = Card.Deck()
    deck.shuffle()
    player = Card.Hand()
    print(player)
    dealer = Card.Hand()
    give_card(dealer, 2)
    show_card(player, 2)
    show_card(dealer, 1)
 # explain if you need total as a function
    player_win = blackjack_check(player)
    dealer_win = blackjack_check(dealer)
    while (player_win):
        if player_c(player):
            #dealer_game()
        else:
            give_card(player, 1)
            player_win = blackjack_check(player)
            if player_loss():
                dealer_win = 1
                break

    if player_win:
        print("Yay! you won")
    elif dealer_win:
        print("Yay! you lost!")
    main()
Esempio n. 2
0
def test_next():
    for i in range(100):
        d = C.Deck()
        lst = []
        for card in d:
            assert type(card) is C.Card
            lst.append(str(card))
        assert len(lst) == 52
        assert len(set(lst)) == 52
Esempio n. 3
0
def test_init_deck():
    for i in range(100):
        d = C.Deck()
        c = d.cards
        assert len(c) == 52
        for card in c:
            assert type(card) is C.Card
        s = set(c)  # the __hash__ method comes in handy here!
        assert len(s) == 52
        m = list(map(str, c))
        s2 = set(m)
        assert len(s2) == 52
Esempio n. 4
0
import Card
import Player

deck = Card.Deck()
deck.populate()
deck.shuffle()
hHand = Card.Hand()
cHand = Card.Hand()
deck.deal([hHand, cHand], 20)

human = Player.Player("Human", hHand)
computer = Player.Player("AI", cHand)
#print(computer.hand)
#print(human.hand)
loop = True
human.find_pairs()
print("before:")
print(human.hand)

print("pairs are: " + human.pairs[0].rank)
print("after:")
print(human.hand)

#while(loop == True):