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
def cards_on_table(player): print("===============================================") #dealer hand if player_turn == False: print("\n", dealer.name, "has:", dealer.hand_value()) dealer.showHand() else: print("\n", dealer.name, "has:", dealer.hand[0].value) dealer.show_first() #player hand print("\n", player.name, "has:", player.hand_value()) player.showHand()
def playGame(players, dealer, deck): for player in players: print(player.name, "has: ") player.showHand() print(dealer.name, "shows: ") dealer.showOneCard() print(player.name, "has a total of: ", player.getValue()) t = True #this is where the user decides if they want to hit(add another card) or stay #with what theyve got. This decision is made while only seeing one dealer card while player.getValue() < int(21) and t == True: hit = str(input("Hit (h) or Stay (s) {}? ".format(player.name))) if hit == str("h"): player.draw(deck) #hit print(player.name, "has: ") player.showHand() #cards in hand print(player.name, "has a total of: ", player.getValue()) #value of hand #if the player goes over 21 they lose immediately if player.getValue() > int(21): print("You went over, Dealer wins!!") d = False break #if the player gets 21 the dealer still has a chance to match(push) if player.getValue() == int(21): print("Blackjack!") t = False d = True return d #return d as true to move in to the determine winner function elif hit == str("s"): t = False d = True print("You have decided to stay. ") print(dealer.name, "has: ") dealer.showHand() print(dealer.name, "has a total of: ", dealer.getValue()) return d