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 20559acd authored by Yildius's avatar Yildius

Added draw mechanic

parent 4f5436c2
......@@ -33,6 +33,9 @@ class Player:
def getHand(self):
return self.__hand
def getHoleCards(self):
return self.__cards
@property
def getRemainingChips(self):
return self.__chips
......
......@@ -13,6 +13,7 @@
from card import Card
from hand import Hand
from deck import Deck
from player.player import Player
......@@ -109,12 +110,30 @@ class Table(object):
for i in remainingPlayerIds:
if self.players[winner].getHand() < self.players[i].getHand():
winner = i
#TODO: manage draw
self.players[winner].receiveChip(self.pot)
winnerList = [winner]
for i in remainingPlayerIds:
if i != winner and not self.players[i].getHand() < self.players[winner].getHand():
winnerList.append(i)
for playerId in winnerList:
self.players[playerId].receiveChip(self.pot / len(winnerList))
self.pot = 0
self.button = self.__playerAtPos(1)
print("Hand ended, player {0} won.".format(winner))
# self.startHand()
if(len(winnerList) > 1):
# There is a draw
print("Hand ended, draw between {0} players :".format(len(winnerList)))
print("Board cards : {}".format(Hand(self.boardCards).cardsStr()))
for playerId in winnerList:
print("Player {} : {}{} -> {}".format(playerId, self.players[playerId].getHoleCards()[0].cardStr(),
self.players[playerId].getHoleCards()[1].cardStr(),
self.players[playerId].getHand().cardsStr()))
else:
# One winner
print("Hand ended, player {0} won.".format(winner))
print("Board cards : {}".format(Hand(self.boardCards).cardsStr()))
print("Player {} : {}{} -> {}".format(winner, self.players[winner].getHoleCards()[0].cardStr(),
self.players[winner].getHoleCards()[1].cardStr(),
self.players[winner].getHand().cardsStr()))
self.startHand()
else:
if self.gameState == GameState.PREFLOP:
for i in range(3):
......
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