def play_hand(self, player): dealer = Dealer() player.value_hand() while player.value_hand < 21: hit_stay = input("Hit or stay? h/s").lower() if hit_stay == 'h': player.deal_hit() elif (player.value_hand > dealer.value_hand) or (dealer.value_hand > 21): print("You win!") dealer.clear_hand()
print("Current chip total: " + str(player.get_chip_total())) print("\n") else: print("Dealer wins!") print("Current chip total: " + str(player.get_chip_total())) print("\n") #play again? #if no chips, can't play again if player.get_chip_total() <= 0: print( "Player is out of money, better hit the bank before playing again." ) break #else, ask if play again play_again = '' while True: play_again = input("Play again? (y or n): ") if play_again.lower() == 'y' or play_again == 'n': break else: print("Invalid input.") if play_again.lower() == 'n': break else: #reset the game-state deck = Deck() player.clear_hand() dealer.clear_hand()