Advertisement
angryatti

defs.py for BlackJackGameV3

Sep 15th, 2023 (edited)
1,241
0
Never
2
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.63 KB | None | 0 0
  1. import random
  2. from collections import namedtuple
  3.  
  4. Deck = namedtuple('Deck','DeckAndType')
  5.  
  6. highcards = "JQKA"
  7. decks = list()
  8. selectedCards = list()
  9. selectedPlayerCards = list()
  10.  
  11. def init1():
  12.     for j in range(0,4,1):
  13.         for i in range (2,11,1):
  14.            if j ==0:
  15.               temp = Deck(str(i)+" h")
  16.            elif j==1:
  17.               temp = Deck(str(i)+" c")
  18.            elif j==2:
  19.               temp=  Deck(str(i)+" d")
  20.            else:
  21.               temp =  Deck(str(i)+" s")    
  22.            decks.append(temp.DeckAndType)
  23.     pass
  24.  
  25. def init2():
  26.    for z in highcards:
  27.       temp= Deck(z+" h")
  28.       decks.append(temp.DeckAndType)
  29.       temp = Deck(z+" c")
  30.       decks.append(temp.DeckAndType)
  31.       temp = Deck(z+" d")
  32.       decks.append(temp.DeckAndType)
  33.       temp= Deck(z+" s")
  34.       decks.append(temp.DeckAndType)
  35.  
  36. def selected():
  37.    if len(decks)>2:  
  38.       index = random.randint(0,len(decks)-1)
  39.       selectedCards.append(str(decks[index]))
  40.       decks.pop(index)
  41.       index = random.randint(0,len(decks)-1)
  42.       selectedCards.append(str(decks[index]))
  43.       decks.pop(index)
  44.    else:
  45.        exit()
  46.  
  47. def selectedPlayer():
  48.    if len(decks)>2:
  49.       index = random.randint(0,len(decks)-1)
  50.       selectedPlayerCards.append(str(decks[index]))
  51.       decks.pop(index)
  52.       index = random.randint(0,len(decks)-1)
  53.       selectedPlayerCards.append(str(decks[index]))
  54.       decks.pop(index)
  55.    else:
  56.       exit()
  57.  
  58. def checkVal(check):
  59.    if check == 'A':
  60.       valueP=11
  61.    elif check == 'K' or check =='Q' or check == 'J':
  62.       valueP=10
  63.    else:
  64.       valueP = check
  65.    return valueP
Advertisement
Comments
Add Comment
Please, Sign In to add comment
Advertisement