Advertisement
dmesticg

Untitled

Jun 13th, 2018
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.14 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]] = Deck.createCard(self)
  29. return(hand)
  30.  
  31.  
  32. class Player:
  33. def __init__(self,startBalance,name):
  34. self.balance = startBalance
  35. self.name = name
  36.  
  37. def bet(self,betamount):
  38. pass
  39.  
  40.  
  41. class Game:
  42. def __init__(self,configFile):
  43. self.variableNames = {"test":0,"yeet":0}
  44. try:
  45. with open(configFile,"r") as file:
  46. for line in file:
  47. line = line.replace(" ","")
  48. name,value = line.split("")
  49. self.variableNames[name] = value.strip()
  50. except Exception as E:
  51. print(E)
  52.  
  53. def drawBoxes(self,boxList):
  54. textSize(30)
  55. fill(255)
  56. for i in range(len(boxList)):
  57. fill(boxList[i][5])
  58. rect(boxList[i][0],boxList[i][1],boxList[i][2],boxList[i][3])
  59. fill(255)
  60. text(boxList[i][4],boxList[i][0],boxList[i][1]+35)
  61.  
  62. def board(self):
  63. pass
  64. #background(variableNames["backgroundColor"])
  65. #image(variableNames["pokertable",0,0,1000,650]
  66.  
  67.  
  68.  
  69. theDeck = Deck(4,13)
  70. theHand = theDeck.createHand(5)
  71. print(theHand)
  72. theHand = theDeck.changeHand(theHand,[0,1])
  73. print(theHand)
  74.  
  75. ##
  76. ##game = Board("configFile.txt")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement