Advertisement
Guest User

Untitled

a guest
Aug 20th, 2017
79
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.63 KB | None | 0 0
  1. from random import randint
  2.  
  3. class cards:
  4. #code by FraserD
  5. def __init__(self):
  6. return None
  7.  
  8.  
  9.  
  10. suitList = ['Clubs', 'Heart', 'Diamond', 'Spade']
  11. numberList = [1,2,3,4,5,6,7,8,9,10, 10, 10, 10]
  12. cardsList = []
  13. cardValue = 0
  14. #cardsShuffled = []
  15. suitCounter = 0 #VV I could combine the two
  16. numberCounter = 0 #for the loop which puts 4 numbers a suit
  17.  
  18. for i in numberList: #generating the cards
  19. while suitCounter != 4:
  20. cardsList.append(numberList[numberCounter])
  21. suitCounter += 1
  22.  
  23. numberCounter += 1
  24. suitCounter = 0
  25. print('Deck of Cards: ', cardsList)
  26. print('Card Number: ', len(cardsList))
  27.  
  28. def play(self):
  29. print("Game Start")
  30. x = randint(0,51)
  31. y = randint(0,51)
  32. print(x, ' x', y, ' y')
  33. self.cardValue = int(self.cardsList[x] + int(self.cardsList[y]))
  34. def check(self):
  35. #print('checkStatement')
  36. print("Card Value: ", self.cardValue)
  37. if self.cardValue > int('21'):
  38. return 'Bust! Try Again!'
  39. card.play()
  40. #return 'Bust! Try Again!'
  41.  
  42. elif self.cardValue == int('21'):
  43. return 'Blackjack! You win!'
  44. card.play()
  45.  
  46.  
  47. elif self.cardValue < int('21'):
  48. pass
  49.  
  50. print("continued")
  51. a = input("Hit(1) or Stay(0)?")
  52. if str(a) == '1':
  53. print(a, ' hit')
  54. self.cardValue += int(self.cardsList[randint(0,51)])
  55. check(self)
  56. elif str(a) == '0':
  57. print(a, ' stay')
  58. return cardValue, 'Close! Game Restarting'
  59. card.play()
  60. return cardValue, 'Close! Game Restarting'
  61. else:
  62. print(a)
  63. return "Error! Not an option! Game Restarting..."
  64. card.play()
  65.  
  66.  
  67.  
  68. print("check")
  69. check(self)
  70.  
  71.  
  72.  
  73. #pyJack3 by FraserD
  74.  
  75.  
  76.  
  77. ''' class shuffle(cards):
  78. **THIS IS A WORK IN PROGRESS SHUFFLE METHOD**
  79.  
  80. def __init__(self):
  81. return None
  82.  
  83. def shuffle(self):
  84. c = 0
  85. while c != 52:
  86. x = randint(0,29)
  87. y = self.cardsList[x]
  88. self.cardsList.pop(x)
  89. self.cardsShuffled.append(y)
  90. c += 1
  91. self.cardsShuffled.append(self.cardsList)
  92. print(self.cardsShuffled)
  93. print('Card Number: ', len(self.cardsShuffled))
  94.  
  95. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement