Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2018
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. #Author:Isaac
  2. #Date: Mar 22 2018
  3. #Purpose: to get 2 cards
  4. #inputs:
  5. #outputs:
  6. #----------------------------
  7. import random
  8.  
  9. class TwoCard():
  10. def __init__(self,a=2,b=2):
  11. self.cardOne = a
  12. self.cardTwo = b
  13.  
  14. #Author:Isaac
  15. #Date: Mar 22 2018
  16. #Purpose: to get a random number between
  17. #inputs:
  18. #outputs:
  19. #----------------------------
  20. def getCard():
  21. return random.randint(2,14)
  22.  
  23. #Author:Isaac
  24. #Date: Mar 22 2018
  25. #Purpose: to get an actual hand
  26. #inputs:
  27. #outputs:
  28. #----------------------------
  29. def getHand():
  30. playerHand = TwoCard()
  31. playerHand.cardOne = getCard()
  32. playerHand.cardTwo = getCard()
  33. return playerHand
  34.  
  35. #Author:Isaac
  36. #Date: Mar 22 2018
  37. #Purpose: to check if it is a pair, consecutive, or a non consecutive
  38. #inputs:
  39. #outputs:
  40. #----------------------------
  41. def handType():
  42. firstCard = playerHand.cardOne
  43. secondCard = playerHand.cardTwo
  44. if firstCard < secondCard:
  45. huge = secondCard
  46. little = firstCard
  47. if firstCard == secondCard:
  48. whatType = 7
  49. elif (firstCard - secondCard) == -1:
  50. whatType = 8
  51. elif (firstCard - secondCard) == 1:
  52. whatType = 9
  53. elif firstCard != secondCard:
  54. whatType = 10
  55. return whatType
  56.  
  57. #Author:Isaac
  58. #Date: Mar 22 2018
  59. #Purpose: to check the spread of the hand
  60. #inputs:
  61. #outputs:
  62. #----------------------------
  63. def spread():
  64. firstCard = playerHand.cardOne
  65. secondCard = playerHand.cardTwo
  66. if firstCard <= secondCard:
  67. cardSpread = secondCard - firstCard
  68. cardSpread = cardSpread - 1
  69. else:
  70. cardSpread = firstCard - secondCard
  71. cardSpread = cardSpread - 1
  72.  
  73. return cardSpread
  74.  
  75.  
  76. #Author:Isaac
  77. #Date: Mar 22 2018
  78. #Purpose: to give the player the payout
  79. #inputs:
  80. #outputs:
  81. #----------------------------
  82. def payout():
  83. payoutTimes = spread()
  84. if payoutTimes == 1:
  85. payoutMulti = 5
  86. elif payoutTimes == 2:
  87. payoutMulti = 4
  88. elif payoutTimes == 3:
  89. payoutMulti = 2
  90. else:
  91. payoutMulti = 1
  92. return payoutMulti
  93.  
  94. #Author:Isaac
  95. #Date: Mar 22 2018
  96. #Purpose: to give the player the payout
  97. #inputs:
  98. #outputs:
  99. #----------------------------
  100. def between():
  101. spreadOut = spread()
  102. if spreadOut >= 1:
  103. betweenSpace = 1
  104. else:
  105. betweenSpace = 2
  106. return betweenSpace
  107.  
  108.  
  109. #MAIN=============================================
  110. go = "y"
  111. playerHand = getHand()
  112. whatType = handType()
  113. cardSpread = spread()
  114. payoutTimes = payout()
  115. betweenSpace = between()
  116. while go == "y":
  117. purse = 100
  118. betAmount = int(input("Please input a bet amount between 1 and 100: "))
  119. if betAmount > 0:
  120. print("Your first card is ",playerHand.cardOne)
  121. print("Your second card is ",playerHand.cardTwo)
  122. if whatType == 7:
  123. thirdCard = getCard()
  124. print("Your third card",thirdCard)
  125. if thirdCard == playerHand.cardOne:
  126. purse = (purse + betAmount*11)
  127. else:
  128. print("It is a tie")
  129. elif whatType == 8 or whatType == 9:
  130. print("it is a tie")
  131. elif whatType == 10:
  132. betAdd = int(input("Do you want to make an additional bet? if so please make a bet between 0 and" + str(purse) +": "))
  133. betAmount = betAmount + betAdd
  134. thirdCard = getCard()
  135. print("Your third card",thirdCard)
  136. if thirdCard > playerHand.cardOne and thirdCard < playerHand.cardOne:
  137. print("You win!!")
  138. purse = purse + betAmount * payoutTimes
  139. print("your new balance ",purse)
  140. else:
  141. purse = purse - betAmount
  142. print(purse)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement