Advertisement
dmesticg

Untitled

Jun 14th, 2018
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. class Player:
  2. def __init__(self,startBalance,name,game):
  3. self.balance = startBalance
  4. self.name = name
  5. self.game = game
  6.  
  7. def bet(self,betAmount):
  8. if betAmount <= self.balance:
  9. self.balance -= betAmount
  10. self.game.currentPot += betAmount
  11.  
  12.  
  13.  
  14. class Poker:
  15. def __init__(self):
  16. self.checkCounter = 0
  17. self.turn = 0
  18. self.currentPot = 0
  19. def addPlayers(self,playerList):
  20. self.playerList = playerList
  21. def check(self):
  22. if self.raised == False:
  23. if checkCounter <= 2:
  24. checked += 1
  25. else:
  26. Poker.checkWinner(self)
  27. else:
  28. print("You have to raise buddy")
  29. def fold(self,player):
  30. Poker.newRound(self,self.playerList[(self.turn + 1) % 2])
  31. def checkWinner(self):
  32. Poker.newRound(self)
  33. def Raise(self,player,betAmount):
  34. self.raised = True
  35. player.bet(betAmount)
  36. def newRound(self,winner):
  37. winner.balance += self.currentPot
  38. print("The winner is "+ winner.name)
  39. self.currentPot = 0
  40. self.turn = 0
  41. self.checkCounter = 0
  42.  
  43.  
  44.  
  45.  
  46. Game = Poker()
  47. Sina = Player(1000,"Sina",Game)
  48. Varun = Player(1000,"Varun",Game)
  49. Game.addPlayers([Sina,Varun])
  50.  
  51.  
  52. Sina.bet(1000)
  53. Varun.bet(1000)
  54. Game.fold(Sina)
  55. print(Varun.balance)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement