Exemplo n.º 1
0
def deal(players, dealer, deck):
    for player in players:
        player.draw(deck)
        player.draw(deck)

    dealer.draw(deck)
    dealer.draw(deck)
Exemplo n.º 2
0
def determine_a_winner(players, dealer, deck, d):

    for player in players:

        while d == True:

            if player.getValue() == 21 and dealer.getValue() < 21:
                dealer.draw(deck)
                print(dealer.name, "has: ")
                dealer.showHand()
                print(dealer.name, "has a total of: ", dealer.getValue())
            elif dealer.getValue() > player.getValue() and dealer.getValue(
            ) > int(16) and dealer.getValue() < int(22):
                print("Dealer wins!!")
                break
            elif dealer.getValue() == player.getValue(
            ) and dealer.getValue() > int(16) and dealer.getValue() < int(22):
                print("Push!")
                break
            elif dealer.getValue() < int(17):
                dealer.draw(deck)
                print(dealer.name, "has: ")
                dealer.showHand()
                print(dealer.name, "has a total of: ", dealer.getValue())
            else:
                print("{} wins!".format(player.name))
                break
Exemplo n.º 3
0
def game_play(player, dealer):
    while player.hand <= 21 and dealer.hand <= 21:
        choice = input("Do you want to hit (y/n) :")
        if choice == 'y':
            player.hand += draw()
            dealer.hand += draw()
        else:
            break
        print(f'player hand has {player.hand}')
    if player.hand > 21:
        player.lost()
    elif player.hand > dealer.hand or dealer.hand > 21:
        player.won()
    else:
        player.draw()
    print(f'Player had {player.hand} and dealer had {dealer.hand}')
    print(player)
Exemplo n.º 4
0
def start_game():
    print("Welcome to the Black Jack")
    dealer = Dealer()
    amount = user_input("Enter your amount :")
    while True:
        player = construct_player(draw(), amount)
        print(f"Dealer starts with {dealer.hand}")
        user_bet(player)
        game_play(player, dealer)
        ans = replay()
        if ans == 'n':
            break
Exemplo n.º 5
0
def draw_sequence():
    #add input for more players to play
    player_1.draw(main_deck)
    dealer.draw(main_deck)
    player_1.draw(main_deck)
    dealer.draw(main_deck)
Exemplo n.º 6
0
    if user_action == "h":
        player_1.draw(main_deck)

        #does player bust?
        if player_1.hand_value() > 21:
            player_turn = False
            player_1.bust = True

    #player ends turn (s)
    else:
        player_turn = False
    #show cards present on table
    cards_on_table(player_1)

#loop runs until dealer turn ends (False)
while dealer_turn == True:

    if dealer.hand_value() < 17:
        dealer.draw(main_deck)

    elif dealer.hand_value() > 21:
        dealer.bust = True
        dealer_turn = False
        cards_on_table(player_1)

    else:
        dealer_turn = False
        cards_on_table(player_1)

round_result(player_1)