actorcat

python blackjack 10-10

Oct 9th, 2024 (edited)
23
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 41.92 KB | None | 0 0
  1. ### playing cards url... instructions: see below...
  2. ### https://www.dropbox.com/scl/fi/2lm6qoda3u8sosvmtxgrj/cards.zip?rlkey=mhs2xaay1b5n5r7lwv43g05c1&e=1&st=e0pjqijv&dl=0
  3.  
  4. from tkinter import *
  5. import random
  6. from PIL import Image, ImageTk
  7. from tkinter import messagebox
  8. from tkinter.simpledialog import askstring
  9. import os, sys
  10.  
  11. root = Tk()
  12. root.title('Blackjack - Card Deck')
  13. root.configure(background="green")
  14.  
  15. ### Root Geometry width and height...
  16. frame_width = 800
  17. frame_height = 800
  18.  
  19. current_dimensions = [frame_width, frame_height]
  20.  
  21. root.geometry(f'{frame_width}x{frame_height}')
  22.  
  23. def open_geo():
  24.     # Increase the width by 100 pixels
  25.     current_dimensions[0] += 100
  26.     # Update the window geometry
  27.     root.geometry(f'{current_dimensions[0]}x{current_dimensions[1]}')
  28.  
  29. def resource_path(relative_path):
  30.     try:
  31.         base_path = sys._MEIPASS
  32.     except Exception:
  33.         base_path = os.path.abspath(".")
  34.     return os.path.join(base_path, relative_path)
  35.  
  36. def stand_H17():
  37.  
  38.     global player_total, dealer_total, player_score, d_aces, p_aces, enter1
  39.     global split_score, split_total, data
  40.  
  41.     split_hit_button.config(state="disabled")
  42.     split_button.config(state="disabled")
  43.     split_double_button.config(state="disabled")
  44.     card_button.config(state="disabled")
  45.     double_button.config(state="disabled")
  46.     stand_button.config(state="disabled")
  47.     deal_button.config(state="active")
  48.  
  49.     # Keep track of score totals
  50.     player_total = 0
  51.     dealer_total = 0
  52.     split_total = 0
  53.     d_aces = 0
  54.     p_aces = 0
  55.     s_aces = 0
  56.     enter1 = False
  57.     data = []
  58.  
  59.     # Get the dealers score total
  60.     for score in dealer_score:
  61.         if score == 11:
  62.             d_aces += 1
  63.         dealer_total += score
  64.         if d_aces > 0 and dealer_total > 21:
  65.             dealer_total -= 10
  66.             d_aces -= 1
  67.         if d_aces > 0 and dealer_total > 21:
  68.             dealer_total -= 10
  69.             d_aces -= 1
  70.  
  71.     # Loop thru player score list and add up cards
  72.     for score in player_score:
  73.         if score == 11:
  74.             p_aces += 1
  75.         # print("p" + str(score))
  76.         player_total += score
  77.         if p_aces > 0 and player_total > 21:
  78.             player_total -= 10
  79.             p_aces -= 1
  80.         # print(int(player_total))
  81.         if p_aces > 0 and player_total > 21:
  82.             player_total -= 10
  83.             p_aces -= 1
  84.  
  85.         # Loop thru player score list and add up cards
  86.     for score in split_score:
  87.         if score == 11:
  88.             s_aces += 1
  89.         #print("s" + str(score))
  90.         split_total += score
  91.         #print(split_total)
  92.         if s_aces > 0 and split_total > 21:
  93.             split_total -= 10
  94.             s_aces -= 1
  95.         if s_aces > 0 and split_total > 21:
  96.             split_total -= 10
  97.             s_aces -= 1
  98.  
  99.     # Freeze the buttons
  100.     card_button.config(state="disabled")
  101.     stand_button.config(state="disabled")
  102.  
  103.     # Logic
  104.  
  105.     # Ensure values are integers
  106.     player_total = int(player_total)
  107.     dealer_total = int(dealer_total)
  108.  
  109.     # Check if the dealer has reached at least 17
  110.     if dealer_total >= 17 and d_aces == 0:
  111.         enter1 = True
  112.     if dealer_total >= 18:
  113.         enter1 = True
  114.     if enter1 == True:
  115.         # Check if player busts
  116.         if player_total > 21:
  117.             dealer_label_1.config(image=dealer_image1)
  118.             messagebox.showinfo("Player Busts", f"Player Busts! Dealer: {dealer_total}  Player: {player_total}")
  119.  
  120.         # Check if player has a Blackjack
  121.         elif player_total == 21:
  122.             if len(player_score) == 2:  # Assuming player_score is the list of player's cards
  123.                 dealer_label_1.config(image=dealer_image1)
  124.                 cal_ace()
  125.                 messagebox.showinfo("", "Player Blackjack")
  126.             elif player_total == 21 and dealer_total == 21:
  127.                 cal_tie()
  128.                 dealer_label_1.config(image=dealer_image1)
  129.                 messagebox.showinfo("its a tie!!", f"its a tie! Dealer: {dealer_total}  Player: {player_total}")
  130.             else:
  131.                 # Handle 21 but not a Blackjack (e.g., player has more than 2 cards)
  132.                 dealer_label_1.config(image=dealer_image1)
  133.                 cal_add()  # Custom function if needed
  134.                 messagebox.showinfo("Player Wins!!", f"Player Wins! Dealer: {dealer_total}  Player: {player_total}")
  135.  
  136.         # Check if dealer busts
  137.         elif dealer_total > 21:
  138.             dealer_label_1.config(image=dealer_image1)
  139.             cal_add()
  140.             messagebox.showinfo("Player Wins!!", f"Player Wins! Dealer: {dealer_total}  Player: {player_total}")
  141.  
  142.         # Check for a tie
  143.         elif dealer_total == player_total and player_total <= 21:
  144.             dealer_label_1.config(image=dealer_image1)
  145.             cal_tie()  # Custom function if needed
  146.             messagebox.showinfo("Tie!!", f"It's a Tie!! Dealer: {dealer_total}  Player: {player_total}")
  147.  
  148.         # Check if dealer wins
  149.         elif dealer_total > player_total and dealer_total <= 21:
  150.             dealer_label_1.config(image=dealer_image1)
  151.             messagebox.showinfo("Dealer Wins!!", f"Dealer Wins! Dealer: {dealer_total}  Player: {player_total}")
  152.  
  153.         # Check if player wins
  154.         elif player_total > dealer_total and player_total <= 21:
  155.             dealer_label_1.config(image=dealer_image1)
  156.             cal_add()  # Custom function if needed
  157.             messagebox.showinfo("Player Wins!!", f"Player Wins! Dealer: {dealer_total}  Player: {player_total}")
  158.  
  159.         # Ensure values are integers
  160.         split_total = int(split_total)
  161.  
  162.         if split_total > 0:
  163.  
  164.             if split_total > 21:
  165.                 messagebox.showinfo("Split Busts", f"Split Busts! Dealer: {dealer_total}  Split: {split_total}")
  166.  
  167.             # Check if player has a Blackjack
  168.             elif split_total == 21:
  169.                 if len(split_score) == 2:  # Assuming player_score is the list of player's cards
  170.                     cal_ace_split()  # Custom function for Blackjack
  171.                     messagebox.showinfo("", "Split Blackjack")
  172.                 else:
  173.                     # Handle 21 but not a Blackjack (e.g., player has more than 2 cards)
  174.                     cal_add_split()  # Custom function if needed
  175.                     messagebox.showinfo("Split Wins!!", f"Split Wins! Dealer: {dealer_total}  Split: {split_total}")
  176.  
  177.             # Check if dealer busts
  178.             elif dealer_total > 21:
  179.                 cal_add_split()
  180.                 messagebox.showinfo("Split Wins!!", f"Split Wins! Dealer: {dealer_total}  Split: {split_total}")
  181.  
  182.             # Check for a tie
  183.             elif dealer_total == split_total and split_total <= 21:
  184.                 cal_tie_split()  # Custom function if needed
  185.                 messagebox.showinfo("Tie!!", f"It's a Tie!! Dealer: {dealer_total}  Split: {split_total}")
  186.  
  187.             # Check if dealer wins
  188.             elif dealer_total > split_total and dealer_total <= 21:
  189.                 messagebox.showinfo("Dealer Wins!!", f"Dealer Wins! Dealer: {dealer_total}  Split: {split_total}")
  190.  
  191.             # Check if player wins
  192.             elif split_total > dealer_total and split_total <= 21:
  193.                 cal_add()  # Custom function if needed
  194.                 messagebox.showinfo("Split Wins!!", f"Split Wins! Dealer: {dealer_total}  Split: {split_total}")
  195.  
  196.     else:
  197.         # Add Card To Dealer
  198.         if int(dealer_total) == 17 and d_aces > 0:
  199.             dealer_hit()
  200.         if int(dealer_total) < 17:
  201.             dealer_hit()
  202.         stand_H17()
  203.    
  204. def stand_S17():
  205.  
  206.     global player_total, dealer_total, player_score, d_aces, p_aces
  207.     global split_score, split_total
  208.  
  209.     split_hit_button.config(state="disabled")
  210.     split_button.config(state="disabled")
  211.     split_double_button.config(state="disabled")
  212.     card_button.config(state="disabled")
  213.     double_button.config(state="disabled")
  214.     stand_button.config(state="disabled")
  215.     deal_button.config(state="active")
  216.  
  217.     # Keep track of score totals
  218.     player_total = 0
  219.     dealer_total = 0
  220.     split_total = 0
  221.     d_aces = 0
  222.     p_aces = 0
  223.     s_aces = 0
  224.  
  225.     # Get the dealers score total
  226.     for score in dealer_score:
  227.         if score == 11:
  228.             d_aces += 1
  229.         dealer_total += score
  230.         if d_aces > 0 and dealer_total > 21:
  231.             dealer_total -= 10
  232.             d_aces -= 1
  233.         if d_aces > 0 and dealer_total > 21:
  234.             dealer_total -= 10
  235.             d_aces -= 1
  236.  
  237.     # Loop thru player score list and add up cards
  238.     for score in player_score:
  239.         if score == 11:
  240.             p_aces += 1
  241.         # print("p" + str(score))
  242.         player_total += score
  243.         if p_aces > 0 and player_total > 21:
  244.             player_total -= 10
  245.             p_aces -= 1
  246.         # print(int(player_total))
  247.         if p_aces > 0 and player_total > 21:
  248.             player_total -= 10
  249.             p_aces -= 1
  250.  
  251.         # Loop thru player score list and add up cards
  252.     for score in split_score:
  253.         if score == 11:
  254.             s_aces += 1
  255.         #print("s" + str(score))
  256.         split_total += score
  257.         #print(split_total)
  258.         if s_aces > 0 and split_total > 21:
  259.             split_total -= 10
  260.             s_aces -= 1
  261.         if s_aces > 0 and split_total > 21:
  262.             split_total -= 10
  263.             s_aces -= 1
  264.  
  265.     # Freeze the buttons
  266.     card_button.config(state="disabled")
  267.     stand_button.config(state="disabled")
  268.  
  269.     # Logic
  270.  
  271.     # Ensure values are integers
  272.     player_total = int(player_total)
  273.     dealer_total = int(dealer_total)
  274.  
  275.     # Check if the dealer has reached at least 17
  276.     if dealer_total >= 17:
  277.         # Check if player busts
  278.         if player_total > 21:
  279.             dealer_label_1.config(image=dealer_image1)
  280.             messagebox.showinfo("Player Busts", f"Player Busts! Dealer: {dealer_total}  Player: {player_total}")
  281.  
  282.         # Check if player has a Blackjack
  283.         elif player_total == 21:
  284.             if len(player_score) == 2:  # Assuming player_score is the list of player's cards
  285.                 dealer_label_1.config(image=dealer_image1)
  286.                 cal_ace()
  287.                 messagebox.showinfo("", "Player Blackjack")
  288.             elif player_total == 21 and dealer_total == 21:
  289.                 cal_tie()
  290.                 dealer_label_1.config(image=dealer_image1)
  291.                 messagebox.showinfo("its a tie!!", f"its a tie! Dealer: {dealer_total}  Player: {player_total}")
  292.             else:
  293.                 # Handle 21 but not a Blackjack (e.g., player has more than 2 cards)
  294.                 dealer_label_1.config(image=dealer_image1)
  295.                 cal_add()  # Custom function if needed
  296.                 messagebox.showinfo("Player Wins!!", f"Player Wins! Dealer: {dealer_total}  Player: {player_total}")
  297.  
  298.         # Check if dealer busts
  299.         elif dealer_total > 21:
  300.             dealer_label_1.config(image=dealer_image1)
  301.             cal_add()
  302.             messagebox.showinfo("Player Wins!!", f"Player Wins! Dealer: {dealer_total}  Player: {player_total}")
  303.  
  304.         # Check for a tie
  305.         elif dealer_total == player_total and player_total <= 21:
  306.             dealer_label_1.config(image=dealer_image1)
  307.             cal_tie()  # Custom function if needed
  308.             messagebox.showinfo("Tie!!", f"It's a Tie!! Dealer: {dealer_total}  Player: {player_total}")
  309.  
  310.         # Check if dealer wins
  311.         elif dealer_total > player_total and dealer_total <= 21:
  312.             dealer_label_1.config(image=dealer_image1)
  313.             messagebox.showinfo("Dealer Wins!!", f"Dealer Wins! Dealer: {dealer_total}  Player: {player_total}")
  314.  
  315.         # Check if player wins
  316.         elif player_total > dealer_total and player_total <= 21:
  317.             dealer_label_1.config(image=dealer_image1)
  318.             cal_add()  # Custom function if needed
  319.             messagebox.showinfo("Player Wins!!", f"Player Wins! Dealer: {dealer_total}  Player: {player_total}")
  320.  
  321.         # Ensure values are integers
  322.         split_total = int(split_total)
  323.  
  324.         if split_total > 0:
  325.  
  326.             if split_total > 21:
  327.                 messagebox.showinfo("Split Busts", f"Split Busts! Dealer: {dealer_total}  Split: {split_total}")
  328.  
  329.             # Check if player has a Blackjack
  330.             elif split_total == 21:
  331.                 if len(split_score) == 2:  # Assuming player_score is the list of player's cards
  332.                     cal_ace_split()  # Custom function for Blackjack
  333.                     messagebox.showinfo("", "Split Blackjack")
  334.                 else:
  335.                     # Handle 21 but not a Blackjack (e.g., player has more than 2 cards)
  336.                     cal_add_split()  # Custom function if needed
  337.                     messagebox.showinfo("Split Wins!!", f"Split Wins! Dealer: {dealer_total}  Split: {split_total}")
  338.  
  339.             # Check if dealer busts
  340.             elif dealer_total > 21:
  341.                 cal_add_split()
  342.                 messagebox.showinfo("Split Wins!!", f"Split Wins! Dealer: {dealer_total}  Split: {split_total}")
  343.  
  344.             # Check for a tie
  345.             elif dealer_total == split_total and split_total <= 21:
  346.                 cal_tie_split()  # Custom function if needed
  347.                 messagebox.showinfo("Tie!!", f"It's a Tie!! Dealer: {dealer_total}  Split: {split_total}")
  348.  
  349.             # Check if dealer wins
  350.             elif dealer_total > split_total and dealer_total <= 21:
  351.                 messagebox.showinfo("Dealer Wins!!", f"Dealer Wins! Dealer: {dealer_total}  Split: {split_total}")
  352.  
  353.             # Check if player wins
  354.             elif split_total > dealer_total and split_total <= 21:
  355.                 cal_add()  # Custom function if needed
  356.                 messagebox.showinfo("Split Wins!!", f"Split Wins! Dealer: {dealer_total}  Split: {split_total}")
  357.  
  358.     else:
  359.         # Add Card To Dealer
  360.         if int(dealer_total) < 17:
  361.         #   print(int(dealer_total))
  362.             dealer_hit()
  363.         # Recalculate Stuff
  364.         stand_S17()
  365.  
  366. def blackjack_shuffle(player):
  367.     global player_total, dealer_total, player_score, dealer_score, blackjack_status, data
  368.  
  369.     # Keep track of score totals
  370.     player_total = 0
  371.     dealer_total = 0
  372.  
  373.     # Ensure player_score and dealer_score are defined and populated
  374.     if player == "dealer":
  375.         if len(dealer_score) == 2 and sum(dealer_score) == 21:
  376.             # Update status
  377.             blackjack_status["dealer"] = "yes"
  378.  
  379.     if player == "player":
  380.         if len(player_score) == 2 and sum(player_score) == 21:
  381.             # Update status
  382.             blackjack_status["player"] = "yes"
  383.  
  384.     # Check for Push/Tie
  385.     if len(dealer_score) == 2 and len(player_score) == 2:
  386.         if blackjack_status["dealer"] == "yes" and blackjack_status["player"] == "yes":
  387.             dealer_label_1.config(image=dealer_image1)
  388.             cal_tie()
  389.             messagebox.showinfo("Push!", "It's a Tie!")
  390.             card_button.config(state="disabled")
  391.             stand_button.config(state="disabled")
  392.             deal_button.config(state="active")
  393.        
  394.         elif blackjack_status["dealer"] == "yes":
  395.             dealer_label_1.config(image=dealer_image1)
  396.  
  397.             if not card_button.cget('state') == 'disabled':  # Only show message if it hasn't already been disabled
  398.                 messagebox.showinfo("Dealer Wins!", "Blackjack! Dealer Wins!")
  399.  
  400.             card_button.config(state="disabled")
  401.             stand_button.config(state="disabled")
  402.             deal_button.config(state="active")
  403.  
  404.         elif blackjack_status["player"] == "yes":
  405.             dealer_label_1.config(image=dealer_image1)
  406.             cal_ace()
  407.             messagebox.showinfo("Player Wins!", "Blackjack! Player Wins!")
  408.             card_button.config(state="disabled")
  409.             stand_button.config(state="disabled")
  410.             deal_button.config(state="active")
  411.    
  412.     # Ensure data is collected and uploaded
  413.     data = [bankroll1.get(), playerbet1.get(), var1.get(), var2.get()]
  414.     mydata_upload()  # Save the data at the end of the function
  415.  
  416. def player_bust():
  417.  
  418.         global score, player_score, player_total, p_aces
  419.         score = 0
  420.         p_aces = 0
  421.         player_total = 0
  422.  
  423.         for score in player_score:
  424.             if score == 11:
  425.                 p_aces += 1
  426.             # print("score " + str(score))
  427.             # print("ps " + str(player_score))
  428.             player_total += score
  429.             if p_aces > 0 and player_total > 21:
  430.                 player_total -= 10
  431.                 p_aces -= 1
  432.             # print("pt" + str(player_total))
  433.             # print("Aces " + str(p_aces))
  434.             if p_aces > 0 and player_total > 21:
  435.                 player_total -= 10
  436.                 p_aces -= 1
  437.  
  438.         if player_total > 21:
  439.             dealer_label_1.config(image=dealer_image1)
  440.             messagebox.showinfo("Player Busts", f"Player Busts: player: {player_total}")
  441.  
  442.             card_button.config(state="disabled")
  443.             stand_button.config(state="disabled")
  444.             deal_button.config(state="active")
  445.             split_button.config(state="disabled")
  446.  
  447.         # Ensure data is collected and uploaded
  448.         data = [bankroll1.get(), playerbet1.get(), var1.get(), var2.get()]
  449.         mydata_upload()  # Save the data at the end of the function
  450.  
  451. def resize_cards(card):
  452.     # Open the image
  453.     our_card_img = Image.open(card)
  454.  
  455.     # Resize The Image
  456.     our_card_resize_image = our_card_img.resize((100, 145))  # 150, 218
  457.    
  458.     # output the card
  459.     global our_card_image
  460.     our_card_image = ImageTk.PhotoImage(our_card_resize_image)
  461.  
  462.     # Return that card
  463.     return our_card_image
  464.  
  465. def shuffle():
  466.     global Rc, deck, n_decks, shcount
  467.     Rc = 0   # running count
  468.    
  469.     # Define Our Deck
  470.     suits = ["diamonds", "clubs", "hearts", "spades"]
  471.     values = range(2, 15)
  472.     # 11 = Jack, 12=Queen, 13=King, 14 = Ace
  473.  
  474.     deck =[]
  475.     i = 0
  476.     for i in range(int(n_decks)):
  477.         for suit in suits:
  478.             for value in values:
  479.                 deck.append(f'{value}_of_{suit}') # value_of_suit
  480.  
  481.     root.title(f'Blackjack - {len(deck)/52} Decks Left')
  482.  
  483. def deal():
  484.     # Keep track of winning
  485.     global blackjack_status, player_total, dealer_total, input1, input2
  486.     global p_aces, d_aces, Rc, answer, split1
  487.  
  488.     # Keep track of score totals
  489.     player_total = 0
  490.     dealer_total = 0
  491.     d_aces = 0
  492.     p_aces = 0
  493.  
  494.     # bankroll1.delete(0,END)
  495.     # bankroll1.insert(0,1000)
  496.  
  497.     if root.winfo_width() > 800:
  498.         root.geometry(f'{frame_width}x{frame_height}')
  499.  
  500.     if len(deck) <= 40:
  501.         messagebox.showinfo("", "need to shuffle soon")
  502.  
  503.     split_button.config(state="active")
  504.     card_button.config(state="active")
  505.     double_button.config(state="active")
  506.     split_hit_button.config(state="disabled")
  507.     split_double_button.config(state="disabled")
  508.     deal_button.config(state="disabled")
  509.  
  510.     blackjack_status = {"dealer":"no", "player":"no"}
  511.  
  512.     # Enable buttons
  513.     card_button.config(state="normal")
  514.     stand_button.config(state="normal")
  515.     # Clear all the old cards from previous games
  516.     dealer_label_1.config(image='')
  517.     dealer_label_2.config(image='')
  518.     dealer_label_3.config(image='')
  519.     dealer_label_4.config(image='')
  520.     dealer_label_5.config(image='')
  521.     dealer_label_6.config(image='')
  522.     dealer_label_7.config(image='')
  523.     dealer_label_8.config(image='')
  524.     dealer_label_9.config(image='')
  525.     dealer_label_10.config(image='')
  526.  
  527.     player_label_1.config(image='')
  528.     player_label_2.config(image='')
  529.     player_label_3.config(image='')
  530.     player_label_4.config(image='')
  531.     player_label_5.config(image='')
  532.     player_label_6.config(image='')
  533.     player_label_7.config(image='')
  534.     player_label_8.config(image='')
  535.     player_label_9.config(image='')
  536.     player_label_10.config(image='')
  537.  
  538.     split_label_1.config(image='')
  539.     split_label_2.config(image='')
  540.     split_label_3.config(image='')
  541.     split_label_4.config(image='')
  542.     split_label_5.config(image='')
  543.     split_label_6.config(image='')
  544.     split_label_7.config(image='')
  545.     split_label_8.config(image='')
  546.     split_label_9.config(image='')
  547.     split_label_10.config(image='')
  548.  
  549.     # Create our players
  550.     global dealer, player, split1, split_spot, split_score, dealer_spot, player_spot, dealer_score, player_score
  551.     global bank1, bet1
  552.     dealer = []
  553.     player = []
  554.     split1 = []
  555.     dealer_score = []
  556.     player_score = []
  557.     split_score = []
  558.     dealer_spot = 0
  559.     player_spot = 0
  560.     split_spot = 0
  561.  
  562.     if playerbet1.get() == "0":
  563.         messagebox.showinfo("", "you must bet first")
  564.         deal_button.config(state="active")
  565.  
  566.     else:
  567.    
  568.         cal_sub()
  569.  
  570.         # Shuffle Two Cards for player and dealer
  571.         dealer_hit()
  572.         dealer_hit()
  573.  
  574.         player_hit()
  575.         player_hit()
  576.  
  577.         blackjack_shuffle("dealer")
  578.         blackjack_shuffle("player")
  579.  
  580.     # Put number of remaining cards in title bar
  581.     root.title(f'Blackjack - {round(len(deck)/52,2)} Decks Left')
  582.  
  583. def dealer_hit():
  584.     global dealer_spot, d_aces, dealer_score, Rc, x
  585.     global player_total, dealer_total, player_score
  586.     global dealer_image0, dealer_image1, dealer_image2, dealer_image3, dealer_image4, dealer_image5
  587.     global dealer_image6, dealer_image7, dealer_image8, dealer_image9, dealer_image10
  588.  
  589.     if dealer_spot <= 9:
  590.         try:
  591.             # Get the player Card
  592.             dealer_card = random.choice(deck)
  593.             #print(dealer_card)
  594.             # Remove Card From Deck
  595.             deck.remove(dealer_card)
  596.             # Append Card To Dealer List
  597.             dealer.append(dealer_card)
  598.             # Append to dealer score list and convert facecards to 10 or 11
  599.             dcard = int(dealer_card.split("_", 1)[0])
  600.             if dcard == 14:
  601.                 dealer_score.append(11)
  602.             elif dcard == 11 or dcard == 12 or dcard == 13:
  603.                 dealer_score.append(10)
  604.             else:
  605.                 dealer_score.append(dcard)
  606.  
  607.             if dcard in [10,11,12,13,14]:
  608.                 Rc -= 1
  609.             if dcard in [2,3,4,5,6]:
  610.                 Rc += 1
  611.  
  612.             image_path_dealer = resource_path(f'cards/{dealer_card}.png')
  613.             image_path_cover = resource_path(f'cards/{"cover"}.png')
  614.  
  615.             # Output Card To Screen
  616.             if dealer_spot == 0:
  617.                 # Resize Card
  618.                 dealer_image1 = resize_cards(image_path_dealer)
  619.                 dealer_image0 = resize_cards(image_path_cover)
  620.                 # Output Card To Screen
  621.                 dealer_label_1.config(image=dealer_image0)
  622.                 dealer_spot += 1
  623.             elif dealer_spot == 1:
  624.                 # Resize Card
  625.                 dealer_image2 = resize_cards(image_path_dealer)
  626.                 # Output Card To Screen
  627.                 dealer_label_2.config(image=dealer_image2)
  628.                 # Increment our player spot counter
  629.                 dealer_spot += 1
  630.                 if dcard == 14 and var1.get() == "on":
  631.                     insurance()
  632.             elif dealer_spot == 2:
  633.                 # Resize Card
  634.                 dealer_image3 = resize_cards(image_path_dealer)
  635.                 # Output Card To Screen
  636.                 dealer_label_3.config(image=dealer_image3)
  637.                 # Increment our player spot counter
  638.                 dealer_spot += 1
  639.             elif dealer_spot == 3:
  640.                 # Resize Card
  641.                 dealer_image4 = resize_cards(image_path_dealer)
  642.                 # Output Card To Screen
  643.                 dealer_label_4.config(image=dealer_image4)
  644.                 # Increment our player spot counter
  645.                 dealer_spot += 1
  646.             elif dealer_spot == 4:
  647.                 # Resize Card
  648.                 dealer_image5 = resize_cards(image_path_dealer)
  649.                 # Output Card To Screen
  650.                 dealer_label_5.config(image=dealer_image5)
  651.                 # Increment our player spot counter
  652.                 dealer_spot += 1
  653.             elif dealer_spot == 5:
  654.                 open_geo()
  655.                 # Resize Card
  656.                 dealer_image6 = resize_cards(image_path_dealer)
  657.                 # Output Card To Screen
  658.                 dealer_label_6.config(image=dealer_image6)
  659.                 # Increment our player spot counter
  660.                 dealer_spot += 1
  661.             elif dealer_spot == 6:
  662.                 # Resize Card
  663.                 open_geo()
  664.                 dealer_image7 = resize_cards(image_path_dealer)
  665.                 # Output Card To Screen
  666.                 dealer_label_7.config(image=dealer_image7)
  667.                 # Increment our player spot counter
  668.                 dealer_spot += 1
  669.             elif dealer_spot == 7:
  670.                 open_geo()
  671.                 # Resize Card
  672.                 dealer_image8 = resize_cards(image_path_dealer)
  673.                 # Output Card To Screen
  674.                 dealer_label_8.config(image=dealer_image8)
  675.                 # Increment our player spot counter
  676.                 dealer_spot += 1
  677.             elif dealer_spot == 8:
  678.                 open_geo()
  679.                 # Resize Card
  680.                 dealer_image9 = resize_cards(image_path_dealer)
  681.                 # Output Card To Screen
  682.                 dealer_label_9.config(image=dealer_image9)
  683.                 # Increment our player spot counter
  684.                 dealer_spot += 1
  685.             elif dealer_spot == 9:
  686.                 open_geo()
  687.                 # Resize Card
  688.                 dealer_image10 = resize_cards(image_path_dealer)
  689.                 # Output Card To Screen
  690.                 dealer_label_10.config(image=dealer_image10)
  691.                 # Increment our player spot counter
  692.                
  693.             # Put number of remaining cards in title bar
  694.             root.title(f'Blackjack - {round(len(deck)/52,2)} Decks Left')
  695.  
  696.         except:
  697.             root.title(f'Blackjack - No Cards In Deck')
  698.  
  699.         # Check for blackjack
  700.         # blackjack_shuffle("dealer")
  701.  
  702. def player_hit():
  703.     global player_spot, p_aces, Rc
  704.     global player_total, dealer_total, player_score
  705.     if player_spot <= 9:
  706.         try:
  707.             # Get the player Card
  708.             player_card = random.choice(deck)
  709.            
  710.             # Remove Card From Deck
  711.             deck.remove(player_card)
  712.             # Append Card To Dealer List
  713.             player.append(player_card)
  714.  
  715.             # Append to dealer score list and convert facecards to 10 or 11
  716.             pcard = int(player_card.split("_", 1)[0])
  717.             if pcard == 14:
  718.                 player_score.append(11)
  719.  
  720.             elif pcard == 11 or pcard == 12 or pcard == 13:
  721.                 player_score.append(10)
  722.                
  723.             else:
  724.                 player_score.append(pcard)
  725.  
  726.             if pcard in [10,11,12,13,14]:
  727.                 Rc -= 1
  728.             if pcard in [2,3,4,5,6]:
  729.                 Rc += 1
  730.            
  731.             global player_image1, player_image2, player_image3, player_image4, player_image5
  732.             global player_image6, player_image7, player_image8, player_image9, player_image10
  733.             global image_path_player
  734.  
  735.             image_path_player = resource_path(f'cards/{player_card}.png')
  736.  
  737.             if player_spot == 0:
  738.                 # Resize Card
  739.                 player_image1 = resize_cards(image_path_player)
  740.                 # Output Card To Screen
  741.                 player_label_1.config(image=player_image1)
  742.                 # Increment our player spot counter
  743.                 player_spot += 1
  744.             elif player_spot == 1:
  745.                 # Resize Card
  746.                 player_image2 = resize_cards(image_path_player)
  747.                 # Output Card To Screen
  748.                 player_label_2.config(image=player_image2)
  749.                 # Increment our player spot counter
  750.                 player_spot += 1
  751.             elif player_spot == 2:
  752.                 # Resize Card
  753.                 player_image3 = resize_cards(image_path_player)
  754.                 # Output Card To Screen
  755.                 player_label_3.config(image=player_image3)
  756.                 # Increment our player spot counter
  757.                 if split1 == []:
  758.                     player_bust()
  759.                 player_spot += 1
  760.             elif player_spot == 3:
  761.                 # Resize Card
  762.                 player_image4 = resize_cards(image_path_player)
  763.                 # Output Card To Screen
  764.                 player_label_4.config(image=player_image4)
  765.                 # Increment our player spot counter
  766.                 if split1 == []:
  767.                     player_bust()
  768.                 player_spot += 1
  769.             elif player_spot == 4:
  770.                 # Resize Card
  771.                 player_image5 = resize_cards(image_path_player)
  772.                 # Output Card To Screen
  773.                 player_label_5.config(image=player_image5)
  774.                 # Increment our player spot counter
  775.                 if split1 == []:
  776.                     player_bust()
  777.                 player_spot += 1
  778.             elif player_spot == 5:
  779.                 # Resize Card
  780.                 open_geo()
  781.                 player_image6 = resize_cards(image_path_player)
  782.                 # Output Card To Screen
  783.                 player_label_6.config(image=player_image6)
  784.                 # Increment our player spot counter
  785.                 if split1 == []:
  786.                     player_bust()
  787.                 player_spot += 1
  788.             elif player_spot == 6:
  789.                 # Resize Card
  790.                 open_geo()
  791.                 player_image7 = resize_cards(image_path_player)
  792.                 # Output Card To Screen
  793.                 player_label_7.config(image=player_image7)
  794.                 # Increment our player spot counter
  795.                 if split1 == []:
  796.                     player_bust()
  797.                 player_spot += 1
  798.             elif player_spot == 7:
  799.                 # Resize Card
  800.                 open_geo()
  801.                 player_image8 = resize_cards(image_path_player)
  802.                 # Output Card To Screen
  803.                 player_label_8.config(image=player_image8)
  804.                 # Increment our player spot counter
  805.                 if split1 == []:
  806.                     player_bust()
  807.                 player_spot += 1
  808.             elif player_spot == 8:
  809.                 # Resize Card
  810.                 open_geo()
  811.                 player_image9 = resize_cards(image_path_player)
  812.                 # Output Card To Screen
  813.                 player_label_9.config(image=player_image9)
  814.                 # Increment our player spot counter
  815.                 if split1 == []:
  816.                     player_bust()
  817.                 player_spot += 1
  818.             elif player_spot == 9:
  819.                 # Resize Card
  820.                 open_geo()
  821.                 player_image10 = resize_cards(image_path_player)
  822.                 # Output Card To Screen
  823.                 player_label_10.config(image=player_image10)
  824.                 # Increment our player spot counter
  825.                 if split1 == []:
  826.                     player_bust()
  827.                 player_spot += 1
  828.  
  829.             # Put number of remaining cards in title bar
  830.             root.title(f'Blackjack - {round(len(deck)/52,2)} Decks Left')
  831.  
  832.         except:
  833.             root.title(f'Blackjack - No Cards In Deck')
  834.  
  835. def split1():
  836.     global player_card, player_score, split_spot, player_spot, split_score
  837.     global split_image1, scard, scard_score, split_card, split1, image_path_sp
  838.  
  839.     cal_sub()
  840.  
  841.     t1=int(playerbet1.get())
  842.     sum=t1
  843.     splitbet1.delete(0,END)
  844.     splitbet1.insert(0,int(sum))
  845.  
  846.     player1_split1 = player[0].split("_", 1)[0]
  847.     player2_split2 = player[1].split("_", 1)[0]
  848.  
  849.     if  player1_split1 == player2_split2:
  850.    
  851.         split_card = player[1]
  852.         split1.append(split_card)
  853.         player.remove(player[1])
  854.         player_score.remove(player_score[1])
  855.         player_spot -= 1
  856.  
  857.  
  858.  
  859.         scard = int(split_card.split("_", 1)[0])
  860.         if scard == 14:
  861.             split_score.append(11)
  862.  
  863.         elif scard == 11 or scard == 12 or scard == 13:
  864.             split_score.append(10)
  865.            
  866.         else:
  867.             split_score.append(scard)
  868.  
  869.         player_label_2.config(image='')
  870.  
  871.         image_path_sp = resource_path(f'cards/{split_card}.png')
  872.  
  873.         if split_spot == 0:
  874.             # Resize Card
  875.             split_image1 = resize_cards(image_path_sp)
  876.             # Output Card To Screen
  877.             split_label_1.config(image=split_image1)
  878.             # Increment our player spot counter
  879.             split_spot += 1
  880.             player_hit()
  881.             split_hit()
  882.     else:
  883.         messagebox.showinfo("", "sorry, can only split pairs")
  884.  
  885.     split_hit_button.config(state="active")
  886.     split_double_button.config(state="active")
  887.    
  888. def split_hit():
  889.     global split_spot, p_aces, Rc, split_frame
  890.     global split_total, dealer_total, player_score
  891.  
  892.     if split_spot <= 9:
  893.        
  894.         try:
  895.             # Get the player Card
  896.             split_card = random.choice(deck)
  897.             # Remove Card From Deck
  898.             deck.remove(split_card)
  899.             # Append Card To Dealer List
  900.             split1.append(split_card)
  901.  
  902.             # Append to dealer score list and convert facecards to 10 or 11
  903.             scard = int(split_card.split("_", 1)[0])
  904.             if scard == 14:
  905.                 split_score.append(11)
  906.  
  907.             elif scard == 11 or scard == 12 or scard == 13:
  908.                 split_score.append(10)
  909.                
  910.             else:
  911.                 split_score.append(scard)
  912.                 #print(split_card)
  913.  
  914.             if scard in [10,11,12,13,14]:
  915.                 Rc -= 1
  916.             if scard in [2,3,4,5,6]:
  917.                 Rc += 1
  918.            
  919.             global split_image1, split_image2, split_image3, split_image4, split_image5
  920.             global split_image6, split_image7, split_image8, split_image9, split_image10
  921.             global split_label_2, split_label_3, split_label_4, split_label_5, image_path_split
  922.  
  923.             image_path_split = resource_path(f'cards/{split_card}.png')
  924.  
  925.             if split_spot == 1:
  926.                 # Resize Card
  927.                 split_image2 = resize_cards(image_path_split)
  928.                 # Output Card To Screen
  929.                 split_label_2.config(image=split_image2)
  930.                 # Increment our player spot counter
  931.                 split_spot += 1
  932.             elif split_spot == 2:
  933.                 # Resize Card
  934.                 split_image3 = resize_cards(image_path_split)
  935.                 # Output Card To Screen
  936.                 split_label_3.config(image=split_image3)
  937.                 # Increment our player spot counter
  938.                 split_spot += 1
  939.                 #blackjack_shuffle("player")
  940.             elif split_spot == 3:
  941.                 # Resize Card
  942.                 split_image4 = resize_cards(image_path_split)
  943.                 # Output Card To Screen
  944.                 split_label_4.config(image=split_image4)
  945.                 # Increment our player spot counter
  946.                 split_spot += 1
  947.                 #blackjack_shuffle("player")
  948.             elif split_spot == 4:
  949.                 # Resize Card
  950.                 split_image5 = resize_cards(image_path_split)
  951.                 # Output Card To Screen
  952.                 split_label_5.config(image=split_image5)
  953.                 # Increment our player spot counter
  954.                 split_spot += 1
  955.             elif split_spot == 5:
  956.                 open_geo()
  957.                 # Resize Card
  958.                 split_image6 = resize_cards(image_path_split)
  959.                 # Output Card To Screen
  960.                 split_label_6.config(image=split_image6)
  961.                 # Increment our player spot counter
  962.                 split_spot += 1
  963.             elif split_spot == 6:
  964.                 open_geo()
  965.                 # Resize Card
  966.                 split_image7 = resize_cards(image_path_split)
  967.                 # Output Card To Screen
  968.                 split_label_7.config(image=split_image7)
  969.                 # Increment our player spot counter
  970.                 split_spot += 1
  971.                 #blackjack_shuffle("player")
  972.             elif split_spot == 7:
  973.                 open_geo()
  974.                 # Resize Card
  975.                 split_image8 = resize_cards(image_path_split)
  976.                 # Output Card To Screen
  977.                 split_label_8.config(image=split_image8)
  978.                 # Increment our player spot counter
  979.                 split_spot += 1
  980.                 #blackjack_shuffle("player")
  981.             elif split_spot == 8:
  982.                 open_geo()
  983.                 # Resize Card
  984.                 split_image9 = resize_cards(image_path_split)
  985.                 # Output Card To Screen
  986.                 split_label_9.config(image=split_image9)
  987.                 # Increment our player spot counter
  988.                 split_spot += 1
  989.             elif split_spot == 9:
  990.                 open_geo()
  991.                 # Resize Card
  992.                 split_image10 = resize_cards(image_path_split)
  993.                 # Output Card To Screen
  994.                 split_label_10.config(image=split_image10)
  995.            
  996.             # Put number of remaining cards in title bar
  997.             root.title(f'Blackjack - {round(len(deck)/52,2)} Decks Left')
  998.         except:
  999.             root.title(f'Blackjack - No Cards In Deck')
  1000.  
  1001. def run_count():
  1002.     global Rc
  1003.     messagebox.showinfo("Run Ct", Rc)
  1004.  
  1005. def cal_sub():
  1006.    t1=int(bankroll1.get())
  1007.    t2=int(playerbet1.get())
  1008.    sum=t1-t2
  1009.    bankroll1.delete(0,END)
  1010.    bankroll1.insert(0,sum)
  1011.  
  1012. def cal_tie():
  1013.     t1=int(bankroll1.get())
  1014.     t2=int(playerbet1.get())
  1015.     sum=t1+t2
  1016.     bankroll1.delete(0,END)
  1017.     bankroll1.insert(0,sum)
  1018.  
  1019. def cal_add():
  1020.     t1=int(bankroll1.get())
  1021.     t2=int(playerbet1.get())
  1022.     sum=t1+(t2*2)
  1023.     bankroll1.delete(0,END)
  1024.     bankroll1.insert(0,sum)
  1025.  
  1026. def cal_ace():
  1027.     t1=int(bankroll1.get())
  1028.     t2=int(playerbet1.get())
  1029.     sum=t1+(t2*2.5)
  1030.     bankroll1.delete(0,END)
  1031.     bankroll1.insert(0,int(sum))
  1032.  
  1033. def cal_tie_split():
  1034.     t1=int(bankroll1.get())
  1035.     t2=int(splitbet1.get())
  1036.     sum=t1+t2
  1037.     bankroll1.delete(0,END)
  1038.     bankroll1.insert(0,sum)
  1039.  
  1040. def cal_add_split():
  1041.     t1=int(bankroll1.get())
  1042.     t2=int(splitbet1.get())
  1043.     sum=t1+(t2*2)
  1044.     bankroll1.delete(0,END)
  1045.     bankroll1.insert(0,sum)
  1046.  
  1047. def cal_ace_split():
  1048.     t1=int(bankroll1.get())
  1049.     t2=int(splitbet1.get())
  1050.     sum=t1+(t2*2.5)
  1051.     bankroll1.delete(0,END)
  1052.     bankroll1.insert(0,int(sum))
  1053.  
  1054. def cal_sub_split():
  1055.     t1=int(bankroll1.get())
  1056.     t2=int(splitbet1.get())
  1057.     sum=t1-t2
  1058.     bankroll1.delete(0,END)
  1059.     bankroll1.insert(0,sum)
  1060.  
  1061. def player_double():
  1062.     cal_sub()
  1063.     t2=int(playerbet1.get())
  1064.     sum=t2*2
  1065.     playerbet1.delete(0,END)
  1066.     playerbet1.insert(0,int(sum))
  1067.     card_button.config(state="disabled")
  1068.     double_button.config(state="disabled")
  1069.     player_hit()
  1070.     if split1 == [] and player_total <= 21:
  1071.         stand()
  1072.  
  1073. def split_double():
  1074.     cal_sub_split()
  1075.     t3=int(splitbet1.get())
  1076.     sum=t3*2
  1077.     splitbet1.delete(0,END)
  1078.     splitbet1.insert(0,int(sum))
  1079.     split_hit_button.config(state="disabled")
  1080.     split_double_button.config(state="disabled")
  1081.     split_hit()
  1082.  
  1083. def startmoney():
  1084.     global data
  1085.     data = []  # Initialize data to avoid old values
  1086.     mydata_download()  # Populate data from the file
  1087.     # print(data)  # Check the contents of data
  1088.  
  1089.     # Ensure there is enough data to access indexes
  1090.     if len(data) > 2:  # Adjust according to how many items you expect
  1091.         if data[2] == "on":
  1092.             ck_ins.select()  # Assuming ck_ins is defined
  1093.         if data[3] == "on":
  1094.             ck_H17.select()  # Assuming ck_H17 is defined
  1095.  
  1096.     # Use default values if data is empty or not as expected
  1097.     if len(data) > 0:
  1098.         bankroll1.delete(0, END)
  1099.         playerbet1.delete(0, END)
  1100.         bankroll1.insert(0, data[0])
  1101.         playerbet1.insert(0, data[1])
  1102.  
  1103. def player_surrender():
  1104.     t1=int(bankroll1.get())
  1105.     t2=int(playerbet1.get())
  1106.     sum=t1 + (t2*.5)
  1107.     bankroll1.delete(0,END)
  1108.     playerbet1.delete(0,END)
  1109.     bankroll1.insert(0,int(sum))
  1110.     playerbet1.insert(0,int(0))
  1111.     if split1 == []:
  1112.         stand()
  1113.  
  1114. def split_surrender():
  1115.     t1=int(bankroll1.get())
  1116.     t3=int(playerbet1.get())
  1117.     sum=t1 + (t3*.5)
  1118.     bankroll1.delete(0,END)
  1119.     splitbet1.delete(0,END)
  1120.     bankroll1.insert(0,int(sum))
  1121.     splitbet1.insert(0,int(0))
  1122.  
  1123. def insurance():
  1124.  
  1125.     answer = messagebox.askquestion('insurance', 'insurance')
  1126.     if answer == "yes":
  1127.         t1=int(bankroll1.get())
  1128.         t2=int(playerbet1.get())
  1129.         sum=t1-(t2*.5)
  1130.         bankroll1.delete(0,END)
  1131.         bankroll1.insert(0,int(sum))
  1132.     if answer == "yes" and dealer_score == [10, 11]:
  1133.         t1=int(bankroll1.get())
  1134.         t2=int(playerbet1.get())
  1135.         sum=t1+(t2*1.5)
  1136.         bankroll1.delete(0,END)
  1137.         bankroll1.insert(0,int(sum))
  1138.         blackjack_shuffle()
  1139.     if answer == "yes" and dealer_score != [10, 11]:
  1140.         blackjack_shuffle()
  1141.     if answer == "no":
  1142.         blackjack_shuffle()
  1143.  
  1144. def stand():
  1145.     global data
  1146.     data = []
  1147.  
  1148.     if var2.get() == "on":
  1149.         stand_H17()
  1150.     else:
  1151.         stand_S17()
  1152.     data = [bankroll1.get(), playerbet1.get(), var1.get() ,var2.get()]
  1153.     mydata_upload()
  1154.  
  1155. def mydata_upload():
  1156.     global data
  1157.  
  1158.     with open('my_list.txt', 'w') as file:
  1159.         for item in data:
  1160.             file.write(f"{item}\n")
  1161.  
  1162. def mydata_download():
  1163.     global data
  1164.  
  1165.     try:
  1166.         with open('my_list.txt', 'r') as file:
  1167.             data = [line.strip() for line in file.readlines()]
  1168.     except FileNotFoundError:
  1169.         data = ['1000', '20', 'off', 'off']
  1170.  
  1171. my_frame = Frame(root, bg="green")
  1172. my_frame.pack(pady=20)
  1173.  
  1174. # Create Text frame For textboxes
  1175. T_frame = Frame(my_frame, width=1100, height=30, bg="green")
  1176. T_frame.pack_propagate(False)
  1177. T_frame.pack(side=TOP)
  1178.  
  1179. # bankroll1 = bankroll, playerbet1 = bet, splitbet1 = split bet
  1180. label1 = Label(T_frame, text = "Bankroll")
  1181. label1.pack(side=LEFT)
  1182. bankroll1 = Entry(T_frame, width = 15)
  1183. bankroll1.pack(side=LEFT)
  1184.  
  1185. label2 = Label(T_frame, text = "Bet")
  1186. label2.pack(side=LEFT)
  1187. playerbet1 = Entry(T_frame, width = 15)
  1188. playerbet1.pack(side=LEFT)
  1189.  
  1190. label3 = Label(T_frame, text = "Bet")
  1191. splitbet1 = Entry(T_frame, width = 15)
  1192. splitbet1.pack(side=RIGHT)
  1193. label3.pack(side=RIGHT)
  1194.  
  1195. var1 = StringVar()
  1196. var2 = StringVar()
  1197.  
  1198. # Define a Checkbox
  1199. ck_ins = Checkbutton(T_frame, text="Insurance", variable=var1, onvalue="on", offvalue="off")
  1200. ck_ins.pack(side=RIGHT, padx=10)
  1201. ck_H17 = Checkbutton(T_frame, text="hit on soft 17", variable=var2, onvalue="on", offvalue="off")
  1202. ck_H17.pack(side=RIGHT, padx=10)
  1203. ck_ins.deselect()
  1204. ck_H17.deselect()
  1205.  
  1206. # Create Frames For Cards
  1207. dealer_frame = LabelFrame(my_frame, text="", bd=0, bg="green")
  1208. dealer_frame.pack(padx=10, ipadx=0, pady = 10, ipady = 0)
  1209.  
  1210. player_frame = LabelFrame(my_frame, text="", bd=0, bg="green")
  1211. player_frame.pack(padx=10, ipadx=0, pady = 10, ipady = 0)
  1212.  
  1213. split_frame = LabelFrame(my_frame, text="", bd=0, bg="green")
  1214. split_frame.pack(padx=10, ipadx=0, pady = 10, ipady = 0)
  1215.  
  1216. # Put Dealer cards in frames
  1217. dealer_label_1 = Label(dealer_frame, text='', bg="green")
  1218. dealer_label_1.grid(row=0, column=0, pady=5, padx=5)
  1219.  
  1220. dealer_label_2 = Label(dealer_frame, text='', bg="green")
  1221. dealer_label_2.grid(row=0, column=1, pady=5, padx=5)
  1222.  
  1223. dealer_label_3 = Label(dealer_frame, text='', bg="green")
  1224. dealer_label_3.grid(row=0, column=2, pady=5, padx=5)
  1225.  
  1226. dealer_label_4 = Label(dealer_frame, text='', bg="green")
  1227. dealer_label_4.grid(row=0, column=3, pady=5, padx=5)
  1228.  
  1229. dealer_label_5 = Label(dealer_frame, text='', bg="green")
  1230. dealer_label_5.grid(row=0, column=4, pady=5, padx=5)
  1231.  
  1232. dealer_label_6 = Label(dealer_frame, text='', bg="green")
  1233. dealer_label_6.grid(row=0, column=5, pady=5, padx=5)
  1234.  
  1235. dealer_label_7 = Label(dealer_frame, text='', bg="green")
  1236. dealer_label_7.grid(row=0, column=6, pady=5, padx=5)
  1237.  
  1238. dealer_label_8 = Label(dealer_frame, text='', bg="green")
  1239. dealer_label_8.grid(row=0, column=7, pady=5, padx=5)
  1240.  
  1241. dealer_label_9 = Label(dealer_frame, text='', bg="green")
  1242. dealer_label_9.grid(row=0, column=8, pady=5, padx=5)
  1243.  
  1244. dealer_label_10 = Label(dealer_frame, text='', bg="green")
  1245. dealer_label_10.grid(row=0, column=9, pady=5, padx=5)
  1246.  
  1247. # Put Player cards in frames
  1248. player_label_1 = Label(player_frame, text='', bg="green")
  1249. player_label_1.grid(row=1, column=0, pady=5, padx=5)
  1250.  
  1251. player_label_2 = Label(player_frame, text='', bg="green")
  1252. player_label_2.grid(row=1, column=1, pady=5, padx=5)
  1253.  
  1254. player_label_3 = Label(player_frame, text='', bg="green")
  1255. player_label_3.grid(row=1, column=2, pady=5, padx=5)
  1256.  
  1257. player_label_4 = Label(player_frame, text='', bg="green")
  1258. player_label_4.grid(row=1, column=3, pady=5, padx=5)
  1259.  
  1260. player_label_5 = Label(player_frame, text='', bg="green")
  1261. player_label_5.grid(row=1, column=4, pady=5, padx=5)
  1262.  
  1263. player_label_6 = Label(player_frame, text='', bg="green")
  1264. player_label_6.grid(row=1, column=5, pady=5, padx=5)
  1265.  
  1266. player_label_7 = Label(player_frame, text='', bg="green")
  1267. player_label_7.grid(row=1, column=6, pady=5, padx=5)
  1268.  
  1269. player_label_8 = Label(player_frame, text='', bg="green")
  1270. player_label_8.grid(row=1, column=7, pady=5, padx=5)
  1271.  
  1272. player_label_9 = Label(player_frame, text='', bg="green")
  1273. player_label_9.grid(row=1, column=8, pady=5, padx=5)
  1274.  
  1275. player_label_10 = Label(player_frame, text='', bg="green")
  1276. player_label_10.grid(row=1, column=9, pady=5, padx=5)
  1277.  
  1278. # Put Split cards in frames
  1279. split_label_1 = Label(split_frame, text='', bg="green")
  1280. split_label_1.grid(row=2, column=0, pady=5, padx=5)
  1281.  
  1282. split_label_2 = Label(split_frame, text='', bg="green")
  1283. split_label_2.grid(row=2, column=1, pady=5, padx=5)
  1284.  
  1285. split_label_3 = Label(split_frame, text='', bg="green")
  1286. split_label_3.grid(row=2, column=2, pady=5, padx=5)
  1287.  
  1288. split_label_4 = Label(split_frame, text='', bg="green")
  1289. split_label_4.grid(row=2, column=3, pady=5, padx=5)
  1290.  
  1291. split_label_5 = Label(split_frame, text='', bg="green")
  1292. split_label_5.grid(row=2, column=4, pady=5, padx=5)
  1293.  
  1294. split_label_6 = Label(split_frame, text='', bg="green")
  1295. split_label_6.grid(row=2, column=5, pady=5, padx=5)
  1296.  
  1297. split_label_7 = Label(split_frame, text='', bg="green")
  1298. split_label_7.grid(row=2, column=6, pady=5, padx=5)
  1299.  
  1300. split_label_8 = Label(split_frame, text='', bg="green")
  1301. split_label_8.grid(row=2, column=7, pady=5, padx=5)
  1302.  
  1303. split_label_9 = Label(split_frame, text='', bg="green")
  1304. split_label_9.grid(row=2, column=8, pady=5, padx=5)
  1305.  
  1306. split_label_10 = Label(split_frame, text='', bg="green")
  1307. split_label_10.grid(row=2, column=9, pady=5, padx=5)
  1308.  
  1309. # Create Button Frame
  1310. button_frame = Frame(my_frame, width=1100, height=100, bg="green")
  1311. button_frame.pack_propagate(False)
  1312. button_frame.pack()
  1313.  
  1314. # Create a couple buttons
  1315. shuffle_button = Button(button_frame, text="Shuffle Deck", font=("Helvetica", 12), command=shuffle)
  1316. shuffle_button.grid(row=0, column=0)
  1317.  
  1318. card_button = Button(button_frame, text="Player Hit", font=("Helvetica", 12), command=player_hit)
  1319. card_button.grid(row=0, column=1, padx=10)
  1320.  
  1321. double_button = Button(button_frame, text="player double", font=("Helvetica", 12), command=player_double)
  1322. double_button.grid(row=0, column=2, padx=10)
  1323.  
  1324. stand_button = Button(button_frame, text="Stand!", font=("Helvetica", 12), command=stand)
  1325. stand_button.grid(row=0, column=3)
  1326.  
  1327. run_button = Button(button_frame, text="running count", font=("Helvetica", 12), command=run_count)
  1328. run_button.grid(row=2, column=0, padx=10, ipadx=0, pady = 10, ipady = 0)
  1329.  
  1330. split_button = Button(button_frame, text="split", font=("Helvetica", 12), command=split1)
  1331. split_button.grid(row=1, column=0, pady=10)
  1332.  
  1333. split_hit_button = Button(button_frame, text="split hit", font=("Helvetica", 12), command=split_hit)
  1334. split_hit_button.grid(row=1, column=1, pady=10)
  1335.  
  1336. split_double_button = Button(button_frame, text="split double", font=("Helvetica", 12), command=split_double)
  1337. split_double_button.grid(row=1, column=2, pady=10)
  1338.  
  1339. deal_button = Button(button_frame, text="Deal", font=("Helvetica", 12), command=deal)
  1340. deal_button.grid(row=1, column=3, padx=10)
  1341.  
  1342. player_surrender_button = Button(button_frame, text="player surrender", font=("Helvetica", 12), command=player_surrender)
  1343. player_surrender_button.grid(row=2, column=1, padx=10)
  1344.  
  1345. split_surrender_button = Button(button_frame, text="split surrender", font=("Helvetica", 12), command=split_surrender)
  1346. split_surrender_button.grid(row=2, column=2, padx=10)
  1347.  
  1348. # Shuffle Deck On Start
  1349. n_decks = askstring('',"decks")
  1350.  
  1351. startmoney()   
  1352. shuffle()
  1353. deal()
  1354.  
  1355. root.mainloop()
  1356.  
  1357. ### put images folder in same folder as python file...
  1358. ### to get running count add 1 for cards 2-6,,, 7,8,9 add 0,,,, 10-Ace subtract 1...
  1359. ### if you divide your running count with the number of decks you have left, you get your true count...
  1360. ### i guess, any true count above 3 you want to start betting heavy
  1361.  
  1362. ### before you decide to go play blackjack for a living, maybe you should watch this first,,, lol...
  1363. ###   https://rumble.com/v1frh4h-card-counter-hits-casinos-on-american-road-trip-inside-the-edge-wonder.html
  1364. ### check out my etsy shop: https://www.etsy.com/shop/ExcelByActorkitten
  1365.  
  1366.  
Add Comment
Please, Sign In to add comment