angryatti

BlackJackGameV3 (required other pastebin file: defs.py)

Sep 15th, 2023
244
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.30 KB | None | 0 0
  1. # H.A. Third-release
  2. from defs import *
  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.  
  34.  
  35.  
  36.  
  37.    
  38.  
  39.    valueP=int(checkVal(checkValueP1))+int(checkVal(checkValueP2))
  40.    if valueP==22:
  41.       valueP=12
  42.    valueD=int(checkVal(checkValueD1))+int(checkVal(checkValueD2))
  43.    if valueD==22:
  44.       valueD=12
  45.  
  46.  
  47.    print('You have: ',valueP)
  48.    if (valueP ==21):
  49.       print ("Player Win, player has Blackjack")
  50.       #exit()
  51.  
  52.  
  53.    if (valueD ==21):
  54.       print ("Dealer Win, Dealer has Blackjack")
  55.       #exit()
  56.  
  57.    if valueD == 21 and valueP ==21:
  58.       print("Tie, player and dealer has BlackJack")
  59.  
  60.  
  61.    value=input('C(call), S(Stay)')
  62.  
  63.    x = 2
  64.  
  65.  
  66.    if value=="C" or value=="c":
  67.       while True:
  68.          index = random.randint(0,len(decks)-1)
  69.          selectedPlayerCards.append(str(decks[index]))
  70.          decks.pop(index)
  71.          if checkVal(selectedPlayerCards[x].split(" ")[0]) == 11 and valueP+11>21:
  72.             valueP = valueP+1
  73.          valueP = valueP+int(checkVal(selectedPlayerCards[x].split(" ")[0]))
  74.          if valueP == 21:
  75.             print('Player draws: '+ selectedPlayerCards[x] )
  76.             print("Player has 21.")
  77.             if len(selectedPlayerCards)<3:
  78.                print("You have got a BlackJack")
  79.             value="S"
  80.             break
  81.          if valueP >21:
  82.             print('Player draws: '+ selectedPlayerCards[x] )
  83.             print('Player has',valueP)
  84.             print('Too much! The dealer wins')
  85.             break
  86.          print('Player draws: '+ selectedPlayerCards[x] )
  87.          print('Player has',valueP)
  88.          x = x+1
  89.      
  90.          value = input('C(call),S(Stay)')
  91.          if value == "S" or value == "s":
  92.             break
  93.  
  94.    z =2
  95.    if value=="S" or value=="s":
  96.       print ('Dealer has',selectedCards[0],selectedCards[1])
  97.       print ('Dealer has:',valueD)
  98.       while (valueD<17):
  99.          index = random.randint(0,len(decks)-1)
  100.          selectedCards.append(str(decks[index]))
  101.          decks.pop(index)    
  102.          if checkVal(selectedCards[z].split(" ")[0]) == 11 and valueD+11>21:
  103.             valueD = valueD+1
  104.          valueD = valueD+int(checkVal(selectedCards[z].split(" ")[0]))
  105.          print('Dealer draws:', selectedCards[z])
  106.          z = z+1
  107.          print ('Dealer has:',valueD)
  108.       if valueD > valueP and valueD <=21:
  109.          print('Dealer Wins')
  110.       elif valueD == valueP:
  111.          print('Tie')
  112.       else:
  113.          print('Player Wins')
  114.  
  115.  
  116.       print ('Remaining cards: '+str(len(decks)))
  117.  
  118.       selectedCards.clear()
  119.       selectedPlayerCards.clear()
  120.       readExit=input('Press Q to Quit or any key to continue' )
  121.       if readExit =="Q":
  122.          break
Add Comment
Please, Sign In to add comment