angryatti

BlackJackGameV5 (required other pastebin file: defs.py)

Oct 1st, 2023 (edited)
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 4.18 KB | None | 0 0
  1. # H.A. 5th-release
  2. from defs import init1 , init2 , selected, selectedPlayer, checkVal, decks, selectedCards , selectedPlayerCards, random
  3. deckNumber=input('One or Six Deck(s)? One)1 Six)6 Default is one: ' )
  4.  
  5. if deckNumber=="6":
  6.    for i in range(int(deckNumber)):
  7.       init1()
  8.       init2()
  9. else:
  10.    init1()
  11.    init2()
  12.  
  13.  
  14. while True:
  15.  
  16.    random.shuffle(decks)
  17.    #print(decks)
  18.    selected()
  19.    selectedPlayer()
  20.    #print(decks)
  21.    valueP =0
  22.    valueD =0
  23.  
  24.    print ('Player Has: '+selectedPlayerCards[0]+' '+selectedPlayerCards[1])
  25.    print ('Dealer has: '+selectedCards[0]+' ??')
  26.  
  27.    checkValueP1 =  selectedPlayerCards[0].split(" ")[0]
  28.    checkValueP2 =  selectedPlayerCards[1].split(" ")[0]
  29.    checkValueD1 =  selectedCards[0].split(" ")[0]
  30.    checkValueD2 =  selectedCards[1].split(" ")[0]
  31.    valueP =0
  32.    valueD =0
  33.    valuePSplit1 =0
  34.    valuePSplit2 =0
  35.  
  36.  
  37.  
  38.    
  39.  
  40.    valueP=int(checkVal(checkValueP1))+int(checkVal(checkValueP2))
  41.    if valueP==22:
  42.       valueP=12
  43.    valueD=int(checkVal(checkValueD1))+int(checkVal(checkValueD2))
  44.    if valueD==22:
  45.       valueD=12
  46.  
  47.  
  48.    print('You have: ',valueP)
  49.    if (valueP ==21):
  50.       print ("Player Win, player has Blackjack")
  51.       #exit()
  52.  
  53.       print ("_____________________________________")
  54.       break
  55.  
  56.    if (valueD ==21):
  57.       print ("Dealer Win, Dealer has Blackjack")
  58.       #exit()
  59.       print ("_____________________________________")
  60.    if valueD == 21 and valueP ==21:
  61.       print("Tie, player and dealer have BlackJack")
  62.       print ("_____________________________________")
  63.       break
  64.    x = 2
  65.  
  66.    if checkVal(checkValueP1) != checkVal(checkValueP2):
  67.       value=input('C(call), S(Stay)')
  68.    else:
  69.       valueX = input("C, Call, S) Stay, X) Split")
  70.       if valueX ==  "X" or valueX == "x":
  71.          #need some workaround
  72.          valuePSplit1 = int(checkVal(checkValueP1))
  73.          valuePSplit2 = int(checkVal(checkValueP2))
  74.          print("First hand C) call, S) Stay X) Split")
  75.  
  76.    if value=="C" or value=="c":
  77.       while True:
  78.          index = random.randint(0,len(decks)-1)
  79.          selectedPlayerCards.append(str(decks[index]))
  80.          decks.pop(index)
  81.          if checkVal(selectedPlayerCards[x].split(" ")[0]) == 11 and valueP+11>21:
  82.             valueP = valueP+1
  83.          valueP = valueP+int(checkVal(selectedPlayerCards[x].split(" ")[0]))
  84.          if valueP == 21:
  85.             print('Player draws: '+ selectedPlayerCards[x] )
  86.             print("Player has 21.")
  87.             if len(selectedPlayerCards)<3:
  88.                print("You have got a BlackJack")
  89.             value="S"
  90.             break
  91.          if valueP >21:
  92.             print('Player draws: '+ selectedPlayerCards[x] )
  93.             print('Player has',valueP)
  94.             print('Too much! The dealer wins')
  95.             print ("_____________________________________")
  96.             break
  97.          print('Player draws: '+ selectedPlayerCards[x] )
  98.          print('Player has',valueP)
  99.          x = x+1
  100.      
  101.          value = input('C(call),S(Stay)')
  102.          if value == "S" or value == "s":
  103.             break
  104.  
  105.    z =2
  106.    if value=="S" or value=="s":
  107.       print ('Dealer has',selectedCards[0],selectedCards[1])
  108.       print ("_____________________________________")
  109.       print ('Dealer has:',valueD)
  110.       while (valueD<17):
  111.          index = random.randint(0,len(decks)-1)
  112.          selectedCards.append(str(decks[index]))
  113.          decks.pop(index)    
  114.          if checkVal(selectedCards[z].split(" ")[0]) == 11 and valueD+11>21:
  115.             valueD = valueD+1
  116.          valueD = valueD+int(checkVal(selectedCards[z].split(" ")[0]))
  117.          print('Dealer draws:', selectedCards[z])
  118.          print ("_____________________________________")
  119.          z = z+1
  120.          print ('Dealer has:',valueD)
  121.       if valueD > valueP and valueD <=21:
  122.          print('Dealer Wins')
  123.       elif valueD == valueP:
  124.          print('Tie')
  125.       else:
  126.          print('Player Wins')
  127.       print ('__________________________________')
  128.  
  129.       print ('Remaining cards: '+str(len(decks)))
  130.  
  131.       selectedCards.clear()
  132.       selectedPlayerCards.clear()
  133.       readExit=input('Press Q to Quit or any key to continue' )
  134.       if readExit =="Q":
  135.          break
Add Comment
Please, Sign In to add comment