Example #1
0
    print("Welcome to the BlackJack Game")

    while True:
        print("How many chips would you like to bet? (1-100):")

        # Check if the chips count enetered is an integer valules and enough count to play
        chip_count = Error().chip_error(total_chips.total)
        player = Hand()
        dealer = Hand()
        card_in_game = Deck(Card().all_card)

        # Use random function to generate cards for the player and dealers
        # First card for the dealer
        random_choice = random.choices(card_in_game.cards)
        # Pop by index for the card in game
        card_in_game.Deck_pop(card_in_game.find_idx(random_choice[0]))
        dealer.add_card(random_choice, card_in_game.cart[random_choice[0][0]])
        #  second card for the dealer
        random_choice = random.choices(card_in_game.cards)
        card_in_game.Deck_pop(card_in_game.find_idx(random_choice[0]))
        dealer.add_card(random_choice, card_in_game.cart[random_choice[0][0]])
        print(
            "-------------------------------------------------------------------------------------------"
        )
        print("Dealer has cards: <<Card1 Hidden>> ", dealer.Card_in_hand[1][0])
        print(
            "-------------------------------------------------------------------------------------------"
        )

        #  Generate 2 cards for player using random function
        random_choice = random.choices(card_in_game.cards)
Example #2
0
    print("Welcome to BlackJack!")

    while (True):
        print("How many chips would you like to bet? you have now {} ".format(
            player_Chips.total))

        # if y is int  , and you have Enough Chips to Play
        y = Error().Error_bet(player_Chips.total)
        player = Hand()
        dealer = Hand()
        card_in_game = Deck(Card().all_card)

        #  1 card to dealer
        random_choice = random.choices(
            card_in_game.cards)  # random ...[('3', 'Hearts')]....
        card_in_game.Deck_pop(card_in_game.find_idx(
            random_choice[0]))  # pop obj in card_in_game by idx
        dealer.add_card(
            random_choice,
            card_in_game.cart[random_choice[0][0]])  # add card to player
        #  2 card to dealer
        random_choice = random.choices(
            card_in_game.cards)  # random ...[('3', 'Hearts')]....
        card_in_game.Deck_pop(card_in_game.find_idx(
            random_choice[0]))  # pop obj in card_in_game by idx
        dealer.add_card(
            random_choice,
            card_in_game.cart[random_choice[0][0]])  # add card to player
        Beautiful_printing().dealer_printing(
            dealer)  # print 2 card in player hand

        #  1 card to player