Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- class cards:
- #code by FraserD
- def __init__(self):
- return None
- suitList = ['Clubs', 'Heart', 'Diamond', 'Spade']
- numberList = [1,2,3,4,5,6,7,8,9,10, 10, 10, 10]
- cardsList = []
- cardValue = 0
- #cardsShuffled = []
- suitCounter = 0 #VV I could combine the two
- numberCounter = 0 #for the loop which puts 4 numbers a suit
- for i in numberList: #generating the cards
- while suitCounter != 4:
- cardsList.append(numberList[numberCounter])
- suitCounter += 1
- numberCounter += 1
- suitCounter = 0
- print('Deck of Cards: ', cardsList)
- print('Card Number: ', len(cardsList))
- def play(self):
- print("Game Start")
- x = randint(0,51)
- y = randint(0,51)
- print(x, ' x', y, ' y')
- self.cardValue = int(self.cardsList[x] + int(self.cardsList[y]))
- def check(self):
- #print('checkStatement')
- print("Card Value: ", self.cardValue)
- if self.cardValue > int('21'):
- return 'Bust! Try Again!'
- card.play()
- #return 'Bust! Try Again!'
- elif self.cardValue == int('21'):
- return 'Blackjack! You win!'
- card.play()
- elif self.cardValue < int('21'):
- pass
- print("continued")
- a = input("Hit(1) or Stay(0)?")
- if str(a) == '1':
- print(a, ' hit')
- self.cardValue += int(self.cardsList[randint(0,51)])
- check(self)
- elif str(a) == '0':
- print(a, ' stay')
- return cardValue, 'Close! Game Restarting'
- card.play()
- return cardValue, 'Close! Game Restarting'
- else:
- print(a)
- return "Error! Not an option! Game Restarting..."
- card.play()
- print("check")
- check(self)
- #pyJack3 by FraserD
- ''' class shuffle(cards):
- **THIS IS A WORK IN PROGRESS SHUFFLE METHOD**
- def __init__(self):
- return None
- def shuffle(self):
- c = 0
- while c != 52:
- x = randint(0,29)
- y = self.cardsList[x]
- self.cardsList.pop(x)
- self.cardsShuffled.append(y)
- c += 1
- self.cardsShuffled.append(self.cardsList)
- print(self.cardsShuffled)
- print('Card Number: ', len(self.cardsShuffled))
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement