def hit(deck: Deck, name: Hand): ''' Function draws a card from the deck and adds it to the hand. and the ace difference is taken into consideration. ''' hit = deck.deal() name.draw_card(hit)
i += 1 new_round = True while new_round: for player in player_list: player.cards = [] player.cards2 = [] dealer.cards = [] winners_list = [] deck = Deck() deck.shuffle() # Dealing cards dealer.cards = deck.deal(2) print('') print('The dealer has 2 cards') print('You can only see one card of the dealer') print(f"One of the dealer's cards is {dealer.cards[0]}") print('') p_list = [dealer] paste_pics_normal(p_list, 1) starting_deal(player_list, deck) print('') # Placing bets bets = place_bets(player_list)
print("Tie!") # GAMEPLAY while True: print("""Let the game begin ! You start with 100 chips Aces can be count as 1 o 11 Dealer hits until he gets 17 or higher""") deck = Deck() deck.shuffle() player_hand = Hand() player_hand.add_card(deck.deal()) player_hand.add_card(deck.deal()) dealer_hand = Hand() dealer_hand.add_card(deck.deal()) dealer_hand.add_card(deck.deal()) player_chips = Chips() take_bet(player_chips) show_some(player_hand, dealer_hand) while playing: hit_or_stand(deck, player_hand)
Created on Tue Dec 29 18:21:16 2020 @author: Samuel """ from classes import Card from classes import Player from classes import Deck player1 = Player(input("Type your name, player1: ")) player2 = Player(input("Type your name, player2: ")) decker = Deck() decker.shuffle() for cd in range(26): player1.increase(decker.deal()) player2.increase(decker.deal()) game_on = True round = 0 while game_on: round += 1 print("Round", round) if (len(player2.allcards) > len(player1.allcards)) and round >= 10000: print("Rounds up!", player1.name, "loses and", player2.name, "wins") game_on = False break if (len(player1.allcards) > len(player2.allcards)) and round >= 10000: print("Rounds up!", player2.name, "loses and", player1.name, "wins")
d_chips = Chips('delaer', 1000) while game: # Print an opening statement print('Welcome to the Black jack game!') if p_chips.balance <= 0: print('you have no chips to play') break else: pass # Create & shuffle the deck, deal two cards to each player playing = True deck = Deck() deck.shuffle() dealer = Hand() player = Hand() player.add(deck.deal()) player.add(deck.deal()) dealer.add(deck.deal()) dealer.add(deck.deal()) # Prompt the Player for their bet bet = take_bet(p_chips) # Show cards (but keep one dealer card hidden) show_some(player, dealer) while playing: # recall this variable from our hit_or_stand function # Prompt for Player to Hit or Stand playing = hit_or_stand(deck, player) # Show cards (but keep one dealer card hidden) show_some(player, dealer) # If player's hand exceeds 21, run player_busts() and break out of loop if player.points > 21: