Advertisement
dmesticg

Untitled

Jun 6th, 2018
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 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. class Poker:
  41. def __init__(self,):
  42.  
  43. theDeck = Deck(4,13)
  44. theHand = theDeck.createHand(5)
  45. print(theHand)
  46. theHand = theDeck.changeHand(theHand,[0,1])
  47. print(theHand)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement