Advertisement
dmesticg

Untitled

Jun 11th, 2018
122
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.64 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. if whichmenu == 0:
  84. menu()
  85. elif whichmenu == 1:
  86. pokerTable()
  87. #this displays back of card
  88. drawHand([[0,0],[0,0],[0,0],[0,0],[0,0]],1,backofcard,1152,1600)
  89. drawHand([[0,0],[0,0],[0,0],[0,0],[0,0]],0,backofcard,1152,1600)
  90.  
  91. #This displays the hand
  92. if turn ==0:
  93. trueholder = [False,False,False,False,False]
  94. drawHand(hand1,0,deckimage,80,110)
  95. else:
  96. trueholder = [False,False,False,False,False]
  97. drawHand(hand2,1,deckimage,80,110)
  98.  
  99.  
  100. def menu():
  101. global whichmenu
  102. background(0)
  103.  
  104. image(pokertable,0,0,1000,650)
  105. image(pokertitle,315,190,400,100)
  106. print(mouseX,mouseY)
  107. drawTextboxes(menuboxes)
  108. if isClicked(textboxes[0]):
  109. whichmenu = 1
  110.  
  111.  
  112.  
  113.  
  114. def pokerTable():
  115. global betamount,bankamount,bet_text,negatory_text,pository_text,amount_text,bet_text,check_text,fold_text,call_text,raise_text,balance_text
  116. global backofcard,handsize,numberofplayers,drawtwocards_text,deckimage,hand1,hand2, thedeck,turn,turn_text
  117.  
  118. image(pokertable,-100,-50,1100,750)
  119. 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]
  120. drawTextboxes(gameboxes)
  121. betamount = getBet(gameboxes[2],gameboxes[1],betamount,bankamount)
  122. amount_text = [820,150,110,50,"$"+str(betamount),color(0,200,0)]
  123. if isClicked(gameboxes[11]):
  124. if turn ==0:
  125. turn = 1
  126.  
  127. else:
  128. turn = 0
  129.  
  130. if isClicked(gameboxes[5]):
  131. check()
  132. elif isClicked(gameboxes[6]):
  133. fold()
  134. elif isClicked(gameboxes[7]):
  135. call()
  136. elif isClicked(gameboxes[8]):
  137. #Raise() is uppercase cuz raise() is a in-built function
  138. Raise()
  139.  
  140.  
  141.  
  142. def Raise():
  143. pass
  144. def call():
  145. pass
  146.  
  147. def check():
  148. pass
  149.  
  150.  
  151. def fold():
  152. pass
  153.  
  154.  
  155.  
  156. def getBet(plusbox,minusbox,betamount,bankamount):
  157. if isClicked(minusbox) and betamount>1:
  158. betamount -=1
  159. elif isClicked(plusbox) and betamount<bankamount:
  160. betamount+=1
  161. return(betamount)
  162.  
  163.  
  164. def drawTextboxes(textboxes):
  165. textSize(30)
  166. fill(255)
  167. for i in range(len(textboxes)):
  168. fill(textboxes[i][5])
  169. rect(textboxes[i][0],textboxes[i][1],textboxes[i][2],textboxes[i][3])
  170. fill(255)
  171. text(textboxes[i][4],textboxes[i][0],textboxes[i][1]+35)
  172.  
  173. def drawtextboxes(textboxes):
  174. textSize(30)
  175. fill(255)
  176. for i in range(len(textboxes)):
  177. fill(textboxes[i][5])
  178. rect(textboxes[i][0],textboxes[i][1],textboxes[i][2],textboxes[i][3])
  179. fill(255)
  180. text(textboxes[i][4],textboxes[i][0],textboxes[i][1]+35)
  181.  
  182. def isClicked(info):
  183. clicked = False
  184. if mousePressed and mouseButton == LEFT:
  185. if info[0] < mouseX < info[0] + info[2] and info[1] < mouseY < info[1] + info[3]:
  186. clicked = True
  187. return clicked
  188.  
  189. def drawHand(hand,num,theimage,cardw,cardl):
  190. global backofcard,trueholder
  191. for i in range(len(hand)):
  192. cardval = hand[i][0]
  193. suitval = hand[i][1]
  194.  
  195. textSize(30)
  196. print(trueholder)
  197.  
  198. if isClicked([110+130*i,150+(num*250),115,160]) and sum(trueholder)<2 or trueholder[i]:
  199. trueholder[i] = True
  200. copy(backofcard,0,0,1152,1600,110+130*i,150+(num*250),115,160)
  201. else:
  202. 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