Advertisement
dmesticg

Untitled

Jun 11th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.60 KB | None | 0 0
  1. import random
  2.  
  3. class Deck: #!
  4. def __init__(self,numsuit,numcard):
  5. self.numsuit = numsuit
  6. self.numcard = numcard
  7. self.deck = [[True] * numsuit for i in range (numcard)]
  8.  
  9. def createCard(self): #!
  10. if self.deck.count:
  11. suitval = random.randint(0,self.numsuit-1)
  12. cardval = random.randint(0,self.numcard-1)
  13. while self.deck[cardval][suitval] == False:
  14. suitval = random.randint(0,self.numsuit-1)
  15. cardval = random.randint(0,self.numcard-1)
  16. self.deck[cardval][suitval] = False
  17. return((cardval,suitval))
  18.  
  19. def createHand(self,handSize):
  20. cards = []
  21. for i in range(handSize):
  22. card = Deck.createCard(self)
  23. cards.append(card)
  24. return(cards)
  25.  
  26. def changeHand(self,hand,indexList):
  27. for i in range(len(indexList)):
  28. hand[indexList[i]] = self.deck.createCard(self)
  29. return(hand)
  30.  
  31.  
  32. def setup():
  33. global restart_text,pause_text,throw_text,score_text,menuboxes,gameboxes,pokertable,pokertitle,start_text,whichmenu
  34. global bankamount,betamount,negatory_text,pository_text,amount_text,bet_text,check_text,fold_text,call_text,raise_text,balance_text
  35. global handsize,numberofplayers,backofcard,drawtwocards_text,deckimage,hand1,cardl,cardw,hand2,turn,turn_text,trueholder,trueholder1
  36. turn = 0
  37.  
  38. cardw = 80
  39. cardl = 110
  40. size(1000,650)
  41. #This is the amount of money each user wants to bet
  42. betamount = 0
  43. #Amount of money in bank
  44. bankamount = 100
  45. pokertable = loadImage("poker.jpg")
  46. pokertitle = loadImage("PokerTitle.png")
  47. backofcard = loadImage("backofcard.jpg")
  48. deckimage = loadImage("deck.png")
  49. start_text = [450,310,100,50,"START",color(255,99,71)]
  50.  
  51. bet_text = [780,100,200,50,"Bet",color(0,0,0)]
  52. negatory_text = [780,150,50,50,"-",color(50,50,50)]
  53. pository_text = [930,150,50,50,"+",color(50,50,50)]
  54. amount_text = [820,150,110,50,"$"+str(betamount),color(0,200,0)]
  55. check_text = [780,200,200,50,"check",color(139, 0, 255)]
  56. fold_text = [780,250,200,50,"fold",color(255, 0, 0)]
  57. call_text = [780,300,200,50,"call",color(255, 255, 0)]
  58. raise_text = [780,350,200,50,"raise",color( 255, 127, 0)]
  59. drawtwocards_text = [780,400,200,50,"change cards",color(0,0,0)]
  60. balance_text = [100,70,200,50,"balance:$"+str(bankamount),color(249,123,31)]
  61. turn_text = [780,450,200,50,"turn",color(0,0,0)]
  62.  
  63. whichmenu = 1
  64. menuboxes = [start_text]
  65.  
  66. handsize = 5
  67. numberofplayers =2
  68. trueholder = [False,False,False,False,False]
  69. thedeck = Deck(4,13)
  70. hand1 = thedeck.createHand(5)
  71. hand2 = thedeck.createHand(5)
  72.  
  73. cardw = 80
  74. cardl = 110
  75.  
  76.  
  77.  
  78.  
  79. def draw():
  80. global whichmenu,trueholder
  81. global betamount,bankamount,bet_text,negatory_text,pository_text,amount_text,bet_text,check_text,fold_text,call_text,raise_text,balance_text
  82. global backofcard,handsize,numberofplayers,drawtwocards_text,deckimage,hand1,hand2, thedeck,turn,trueholder,trueholder1
  83. image(pokertable,-100,-50,1100,750)
  84. if whichmenu == 0:
  85. menu()
  86. elif whichmenu == 1:
  87. #this displays back of card
  88. #This displays the hand
  89. drawHand([[0,0],[0,0],[0,0],[0,0],[0,0]],1,backofcard,1152,1600)
  90. drawHand([[0,0],[0,0],[0,0],[0,0],[0,0]],0,backofcard,1152,1600)
  91. if turn == 1:
  92. drawHand(hand1,0,deckimage,80,110)
  93. else:
  94. drawHand(hand2,1,deckimage,80,110)
  95. pokerTable()
  96.  
  97.  
  98.  
  99. def menu():
  100. global whichmenu
  101. background(0)
  102.  
  103. image(pokertable,0,0,1000,650)
  104. image(pokertitle,315,190,400,100)
  105. print(mouseX,mouseY)
  106. drawTextboxes(menuboxes)
  107. if isClicked(textboxes[0]):
  108. whichmenu = 1
  109.  
  110.  
  111.  
  112.  
  113. def pokerTable():
  114. global betamount,bankamount,bet_text,negatory_text,pository_text,amount_text,bet_text,check_text,fold_text,call_text,raise_text,balance_text
  115. global backofcard,handsize,numberofplayers,drawtwocards_text,deckimage,hand1,hand2, thedeck,turn,turn_text,trueholder
  116.  
  117.  
  118. gameboxes = [bet_text,negatory_text,pository_text,amount_text,bet_text, check_text,fold_text,call_text,raise_text,balance_text,drawtwocards_text,turn_text]
  119. drawTextboxes(gameboxes)
  120. betamount = getBet(gameboxes[2],gameboxes[1],betamount,bankamount)
  121. amount_text = [820,150,110,50,"$"+str(betamount),color(0,200,0)]
  122. if isClicked(gameboxes[11]):
  123. trueholder = [False,False,False,False,False]
  124. if turn ==0:
  125. turn = 1
  126. else:
  127. turn = 0
  128.  
  129. if isClicked(gameboxes[5]):
  130. check()
  131. elif isClicked(gameboxes[6]):
  132. fold()
  133. elif isClicked(gameboxes[7]):
  134. call()
  135. elif isClicked(gameboxes[8]):
  136. #Raise() is uppercase cuz raise() is a in-built function
  137. Raise()
  138.  
  139.  
  140.  
  141. def Raise():
  142. pass
  143. def call():
  144. pass
  145.  
  146. def check():
  147. pass
  148.  
  149.  
  150. def fold():
  151. pass
  152.  
  153.  
  154.  
  155. def getBet(plusbox,minusbox,betamount,bankamount):
  156. if isClicked(minusbox) and betamount>1:
  157. betamount -=1
  158. elif isClicked(plusbox) and betamount<bankamount:
  159. betamount+=1
  160. return(betamount)
  161.  
  162.  
  163. def drawTextboxes(textboxes):
  164. textSize(30)
  165. fill(255)
  166. for i in range(len(textboxes)):
  167. fill(textboxes[i][5])
  168. rect(textboxes[i][0],textboxes[i][1],textboxes[i][2],textboxes[i][3])
  169. fill(255)
  170. text(textboxes[i][4],textboxes[i][0],textboxes[i][1]+35)
  171.  
  172. def drawtextboxes(textboxes):
  173. textSize(30)
  174. fill(255)
  175. for i in range(len(textboxes)):
  176. fill(textboxes[i][5])
  177. rect(textboxes[i][0],textboxes[i][1],textboxes[i][2],textboxes[i][3])
  178. fill(255)
  179. text(textboxes[i][4],textboxes[i][0],textboxes[i][1]+35)
  180.  
  181. def isClicked(info):
  182. clicked = False
  183. if mousePressed and mouseButton == LEFT:
  184. if info[0] < mouseX < info[0] + info[2] and info[1] < mouseY < info[1] + info[3]:
  185. clicked = True
  186. return clicked
  187.  
  188. def drawHand(hand,num,theimage,cardw,cardl):
  189. global backofcard,trueholder
  190. for i in range(len(hand)):
  191. cardval = hand[i][0]
  192. suitval = hand[i][1]
  193.  
  194. textSize(30)
  195. print(trueholder)
  196.  
  197. if isClicked([110+130*i,150+(num*250),115,160]) and sum(trueholder)<2 or trueholder[i]:
  198. trueholder[i] = True
  199. copy(backofcard,0,0,1152,1600,110+130*i,150+(num*250),115,160)
  200. else:
  201. copy(theimage, cardw*(cardval), cardl*suitval, cardw, cardl, 110+130*i, 150+(num*250), 115, 160)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement