...
 
Commits (2)
......@@ -55,7 +55,7 @@ class Player:
return self.__playerState == PlayerState.ALL_IN
@property
def getChipsOnTable(self):
def chipsOnTable(self):
return self.__chipsOnTable
@property
......@@ -163,11 +163,6 @@ class Player:
self.__hand = newHand
return self.__hand
def endTurn(self):
ans = self.__chipsOnTable
self.__chipsOnTable = 0
return ans
def receiveCards(self, card1, card2):
self.__cards = [card1, card2]
......@@ -221,10 +216,6 @@ class Player:
self.__playerState = PlayerState.FOLDED
return True
def yieldAction(self):
# Timeout, shouldn't be needed (just check/fold called from Table)
self.__hasHadAction = True
def state(self):
# returns player state (all in, playing, folded)
if self.__playerState == PlayerState.FOLDED:
......
......@@ -135,7 +135,7 @@ class Table(object):
self.__timer.start()
for p in self.__players:
if p.isInHand:
print("Player {} : {} ({} chips)".format(p.name, p.getChipsOnTable, p.remainingChips))
print("Player {} : {} ({} chips)".format(p.name, p.chipsOnTable, p.remainingChips))
else:
print("Player {} : out ({} chips)".format(p.name, p.remainingChips))
self.__bCastCB()
......@@ -232,12 +232,12 @@ class Table(object):
pickUpDone = True
for p in self.__players:
if p.isInHand:
if p.isAllIn and p.getChipsOnTable and (not minAllInValue or p.getChipsOnTable < minAllInValue):
minAllInValue = p.getChipsOnTable
if p.isAllIn and p.chipsOnTable and (not minAllInValue or p.chipsOnTable < minAllInValue):
minAllInValue = p.chipsOnTable
pickUpDone = False
if not pickUpDone:
for p in self.__players:
if p.getChipsOnTable <= minAllInValue:
if p.chipsOnTable <= minAllInValue:
if p.isAllIn:
p.potId = len(self.__pots) - 1
self.__pots[-1] += p.yieldBet()
......@@ -331,7 +331,7 @@ class Table(object):
if nbrInHand <= 1:
return True
for p in self.__players:
if p.isPlaying and (not p.hasHadAction or p.getChipsOnTable != self.__currentBet):
if p.isPlaying and (not p.hasHadAction or p.chipsOnTable != self.__currentBet):
return False
return True
......@@ -377,8 +377,8 @@ class Table(object):
return True
def __check(self, p):
if p.getChipsOnTable != self.__currentBet:
print("Player {} cant check, needs to call ({}/{})".format(p.name, p.getChipsOnTable, self.__currentBet))
if p.chipsOnTable != self.__currentBet:
print("Player {} cant check, needs to call ({}/{})".format(p.name, p.chipsOnTable, self.__currentBet))
return False
if not p.check():
print("Player {} cant check, check failed (unexpected).".format(p.name))
......@@ -395,8 +395,8 @@ class Table(object):
return True
def __bet(self, p, amount):
if amount + p.getChipsOnTable < self.__currentBet + self.__minRaise:
print("Player {} cant bet, not adding enough money (would be {}/{})".format(p.name, amount + p.getChipsOnTable, self.__currentBet + self.__minRaise))
if amount + p.chipsOnTable < self.__currentBet + self.__minRaise:
print("Player {} cant bet, not adding enough money (would be {}/{})".format(p.name, amount + p.chipsOnTable, self.__currentBet + self.__minRaise))
return False
if amount > p.remainingChips:
print("Player {} cant bet, not enough money ({}/{})".format(p.name, amount, p.remainingChips))
......@@ -406,8 +406,8 @@ class Table(object):
return False # Betting could not happen for some reason
if not self.__currentBet:
self.__minRaise = amount
if p.getChipsOnTable > self.__currentBet:
self.__currentBet = p.getChipsOnTable
if p.chipsOnTable > self.__currentBet:
self.__currentBet = p.chipsOnTable
print("Player {} added {}, current bet to {}, minraise at {}.".format(p.name, amount, self.__currentBet, self.__minRaise))
return True
......@@ -430,7 +430,7 @@ class Table(object):
"chips": player.remainingChips,
"isActive": player.isPlaying,
"won": player.won,
"chipsOnTable": player.getChipsOnTable,
"chipsOnTable": player.chipsOnTable,
"state": player.state(),
} for player in self.__players],
"holeCards": self.__getHoleCards(userId),
......@@ -475,7 +475,7 @@ class Table(object):
if userIndex == -1:
return []
p = self.__players[userIndex]
return [self.__currentBet + self.__minRaise - p.getChipsOnTable, p.remainingChips]
return [self.__currentBet + self.__minRaise - p.chipsOnTable, p.remainingChips]
def __availableActions(self, userId):
userIndex = self.getPlayerIndex(userId)
......@@ -487,7 +487,7 @@ class Table(object):
if not p.isPlaying:
return []
rslt = ["fold"]
if self.__currentBet == p.getChipsOnTable:
if self.__currentBet == p.chipsOnTable:
rslt.append("check")
else:
rslt.append("call")
......@@ -499,7 +499,7 @@ class Table(object):
if userIndex == -1:
return 0
p = self.__players[userIndex]
return self.__currentBet - p.getChipsOnTable
return self.__currentBet - p.chipsOnTable
def __defaultActionCallback(self):
activePlayerId = self.__players[self.__activePlayer].uniqueId
......