Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Player:
- def __init__(self,startBalance,name,game):
- self.balance = startBalance
- self.name = name
- self.game = game
- self.hand = game.Deck.createHand(5)
- self.score = getScore(self.hand)
- def bet(self,betAmount):
- if betAmount <= self.balance:
- self.balance -= betAmount
- self.game.currentPot += betAmount
- else:
- print("Not enough money")
- class Poker:
- def __init__(self,Deck):
- self.checkCounter = 0
- self.turn = 0
- self.currentPot = 0
- self.previousBet = 0
- self.raised = False
- self.Deck = Deck
- def addPlayers(self,playerList):
- self.playerList = playerList
- def Check(self):
- if self.raised == False:
- if self.checkCounter < 1:
- self.checkCounter += 1
- self.turn += 1
- else:
- Poker.checkWinner(self)
- else:
- print("You have to raise buddy")
- def Fold(self,player):
- Poker.newRound(self,self.playerList[(self.turn + 1) % 2])
- def Raise(self,player,betAmount):
- if betAmount > self.previousBet and betAmount > self.playerList[(self.turn + 1) % 2]:
- self.raised = True
- self.previousBet = betAmount
- player.bet(betAmount)
- self.turn += 1
- else:
- print("You have to raise more than "+self.previousBet+"or you have bet more than the other players balance")
- def Call(self,player):
- if self.raised:
- self.raised = False
- player.bet(self.previousBet)
- self.turn += 1
- else:
- print("There is nothing to call, retard")
- def checkWinner(self):
- if self.playerList[0].score[0] > self.playerList[1].score[0]:
- winner = self.playerList[0]
- elif self.playerList[0].score[0] < self.playerList[1].score[0]:
- winner = self.playerList[1]
- else:
- if self.playerList[0].score[1] > self.playerList[1].score[1]:
- winner = self.playerList[0]
- elif self.playerList[0].score[1] < self.playerList[1].score[1]:
- winner = self.playerList[1]
- else:
- winner = 0
- Poker.newRound(self,winner)
- def newRound(self,winner):
- self.playerList[0].hand = self.Deck.createHand(5)
- self.playerList[1].hand = self.Deck.createHand(5)
- if winner != 0:
- winner.balance += self.currentPot
- print("The winner of the round is "+ winner.name)
- Poker(self.Deck)
- else:
- print("its a tie")
- self.playerList[0].balance += self.currentPot / 2
- self.playerList[1].balance += self.currentPot / 2
- Poker(self.Deck)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement