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 13f8120a authored by Arnaud Chevalier's avatar Arnaud Chevalier

small modifications

parent d40ed201
This diff is collapsed.
from card import Card
from hand import Hand
class Player:
# INIT
def __init__(self):
self.__hand = Hand()
self.__chips = float
self.__cards = [Cards()]
self.__cards = [Card()]
self.__chipsOnTable = float
self.position = int
self.isPlaying = bool
self.isAllIn = bool
self.__position = int
self.__isPlaying = bool
self.__isAllIn = bool
# GETTERS & SETTERS
@property
def chipsOnTable(self):
return self.__chipsOnTable
@chipsOnTable.setter
def chipsOnTable(self, value):
self.__chipsOnTable = value
@property
def chips(self):
return self.__chips
@chips.setter
def chips(self, value):
self.__chips = value
# PRIVATE METHODS
# PUBLIC METHODS
def endTurn(self):
ans = self.chipsOnTable
self.__chipsOnTable = 0
ans = self.__chipsOnTable
self.__chipsOnTable(0)
return ans
def giveSB(self, smallBlind):
self.chips -= smallBlind
self.chipsOnTable += smallBlind
if smallBlind >= self.__chips:
self.__isAllIn = True
self.__chipsOnTable += self.__chips
self.__chips -= self.__chips
else:
self.__isAllIn = False
self.__chips -= smallBlind
self.__chipsOnTable += smallBlind
def giveBB(self, bigBlind):
if bigBlind >= self.__chips:
self.__isAllIn = True
self.__chipsOnTable += self.__chips
self.__chips -= self.__chips
else:
self.__isAllIn = False
self.__chips -= bigBlind
self.__chipsOnTable += bigBlind
def bet(self, amount):
if self.__isAllIn:
return False
else:
if amount <= self.__chips:
if amount == self.__chips:
self.__isAllIn = True
else:
self.__isAllIn = False
self.__chips -= amount
self.__chipsOnTable += amount
else:
return False
def giveBB(self, bigBlend):
self.chips -= bigBlend
self.chipsOnTable += bigBlend
def check(self):
# TODO
return
def call(self):
# TODO
return
def fold(self):
returnedCards = []
returnedCards.append(self.__cards.pop())
returnedCards.append(self.__cards.pop())
self.__isPlaying = False
return returnedCards
......@@ -35,7 +35,7 @@ class Table(object):
def bet(self, playerId, amount):
if self.activePlayer == playerId:
return self.players[playerId].fold(amount)
return self.players[playerId].bet(amount)
else:
return False
......@@ -48,4 +48,4 @@ class Table(object):
"chips": player.chips,
"isActive": player.isActive
} for player in self.players]
}
})
  • Il faudrait une méthode privée pour effectuer le transfert chips -> chips on table, il y a pas mal de code répété là.

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