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
- def bet(self,betAmount):
- if betAmount <= self.balance:
- self.balance -= betAmount
- self.game.currentPot += betAmount
- class Poker:
- def __init__(self):
- self.checkCounter = 0
- self.turn = 0
- self.currentPot = 0
- def addPlayers(self,playerList):
- self.playerList = playerList
- def check(self):
- if self.raised == False:
- if checkCounter <= 2:
- checked += 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 checkWinner(self):
- Poker.newRound(self)
- def Raise(self,player,betAmount):
- self.raised = True
- player.bet(betAmount)
- def newRound(self,winner):
- winner.balance += self.currentPot
- print("The winner is "+ winner.name)
- self.currentPot = 0
- self.turn = 0
- self.checkCounter = 0
- Game = Poker()
- Sina = Player(1000,"Sina",Game)
- Varun = Player(1000,"Varun",Game)
- Game.addPlayers([Sina,Varun])
- Sina.bet(1000)
- Varun.bet(1000)
- Game.fold(Sina)
- print(Varun.balance)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement