Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit bdb74d09 authored by Arnaud Chevalier's avatar Arnaud Chevalier

end of turn completed

parent 427955e6
......@@ -95,7 +95,7 @@ class Hand:
self.__sendToBack(0)
self.__sendToBack(0)
elif self.__cards[0].getValue() != threeSame:
__sendToBack(0)
self.__sendToBack(0)
elif secondPair:
self.__handName = HandName.TWO_PAIRS
if self.__cards[0].getValue() != secondPair:
......
......@@ -99,9 +99,11 @@ class Player:
return temp
def giveSB(self, smallBlind):
self.__hasHadAction = True
return self.__putMoneyOnTable(smallBlind)
def giveBB(self, bigBlind):
self.__hasHadAction = True
return self.__putMoneyOnTable(bigBlind)
def bet(self, amount):
......@@ -123,11 +125,13 @@ class Player:
def fold(self):
self.__hasHadAction = True
returnedCards = []
returnedCards.append(self.__cards.pop())
returnedCards.append(self.__cards.pop())
# returnedCards = []
# returnedCards.append(self.__cards.pop())
# returnedCards.append(self.__cards.pop())
print("Player {} fold".format(self.__uniqueId))
self.__isPlaying = False
return returnedCards
# return returnedCards
return True
def yieldAction(self):
self.__hasHadAction = True
......
......@@ -102,7 +102,7 @@ class Table(object):
remainingPlayerIds.append(i)
winner = remainingPlayerIds[0]
for i in remainingPlayerIds:
if self.players[winner].getHand() < self.players[remainingPlayerIds[i]].getHand():
if self.players[winner].getHand() < self.players[i].getHand():
winner = i
#TODO: manage draw
self.players[winner].receiveChip(self.pot)
......@@ -128,10 +128,11 @@ class Table(object):
print("River : {}".format(self.boardCards[4].cardStr()))
def isBettingDone(self):
ans = False
for p in self.players:
if p.isPlaying() and not p.hasHadAction():
return False
return True
if p.isPlaying and (not p.hasHadAction or p.getChipsOnTable() != self.currentBet):
ans = True
return ans
def fold(self, playerId):
if self.activePlayer == playerId:
......
......@@ -6,12 +6,34 @@ player1 = player.player.Player()
print(player1.uniqueId)
player2 = player.player.Player()
print(player2.uniqueId)
player3 = player.player.Player()
print(player3.uniqueId)
player4 = player.player.Player()
print(player4.uniqueId)
player5 = player.player.Player()
print(player5.uniqueId)
t.addPlayer(player1)
t.addPlayer(player2)
t.startHand()
t.call(1)
t.bet(0, 1)
t.addPlayer(player3)
t.addPlayer(player4)
t.addPlayer(player5)
t.startHand()
t.fold(t.activePlayer)
print(t.isBettingDone())
t.call(t.activePlayer)
print(t.isBettingDone())
t.call(t.activePlayer)
print(t.isBettingDone())
t.call(t.activePlayer)
print(t.isBettingDone())
t.call(t.activePlayer)
print(t.isBettingDone())
t.call(t.activePlayer)
print(t.isBettingDone())
t.call(t.activePlayer)
print(t.isBettingDone())
t.call(t.activePlayer)
print(t.isBettingDone())
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment