Advertisement
dmesticg

Untitled

Jun 17th, 2018
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.81 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. self.hand = game.Deck.createHand(5)
  7. self.score = getScore(self.hand)
  8.  
  9. def bet(self,betAmount):
  10. if betAmount <= self.balance:
  11. self.balance -= betAmount
  12. self.game.currentPot += betAmount
  13. else:
  14. print("Not enough money")
  15.  
  16.  
  17.  
  18.  
  19. class Poker:
  20. def __init__(self,Deck):
  21. self.checkCounter = 0
  22. self.turn = 0
  23. self.currentPot = 0
  24. self.previousBet = 0
  25. self.raised = False
  26. self.Deck = Deck
  27. def addPlayers(self,playerList):
  28. self.playerList = playerList
  29. def Check(self):
  30. if self.raised == False:
  31. if self.checkCounter < 1:
  32. self.checkCounter += 1
  33. self.turn += 1
  34. else:
  35. Poker.checkWinner(self)
  36. else:
  37. print("You have to raise buddy")
  38. def Fold(self,player):
  39. Poker.newRound(self,self.playerList[(self.turn + 1) % 2])
  40. def Raise(self,player,betAmount):
  41. if betAmount > self.previousBet and betAmount > self.playerList[(self.turn + 1) % 2]:
  42. self.raised = True
  43. self.previousBet = betAmount
  44. player.bet(betAmount)
  45. self.turn += 1
  46. else:
  47. print("You have to raise more than "+self.previousBet+"or you have bet more than the other players balance")
  48. def Call(self,player):
  49. if self.raised:
  50. self.raised = False
  51. player.bet(self.previousBet)
  52. self.turn += 1
  53. else:
  54. print("There is nothing to call, retard")
  55. def checkWinner(self):
  56. if self.playerList[0].score[0] > self.playerList[1].score[0]:
  57. winner = self.playerList[0]
  58. elif self.playerList[0].score[0] < self.playerList[1].score[0]:
  59. winner = self.playerList[1]
  60. else:
  61. if self.playerList[0].score[1] > self.playerList[1].score[1]:
  62. winner = self.playerList[0]
  63. elif self.playerList[0].score[1] < self.playerList[1].score[1]:
  64. winner = self.playerList[1]
  65. else:
  66. winner = 0
  67. Poker.newRound(self,winner)
  68. def newRound(self,winner):
  69. self.playerList[0].hand = self.Deck.createHand(5)
  70. self.playerList[1].hand = self.Deck.createHand(5)
  71. if winner != 0:
  72. winner.balance += self.currentPot
  73. print("The winner of the round is "+ winner.name)
  74. Poker(self.Deck)
  75. else:
  76. print("its a tie")
  77. self.playerList[0].balance += self.currentPot / 2
  78. self.playerList[1].balance += self.currentPot / 2
  79. Poker(self.Deck)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement