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 6b8b9e48 authored by Arnaud Chevalier's avatar Arnaud Chevalier

fixed class player put money on table

parent 54e6f8af
......@@ -3,8 +3,8 @@
<component name="ChangeListManager">
<list default="true" id="a53de62e-41c2-43d1-aadf-ae33d1c54e93" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/card.py" beforeDir="false" afterPath="$PROJECT_DIR$/card.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/player/player.py" beforeDir="false" afterPath="$PROJECT_DIR$/player/player.py" afterDir="false" />
<change beforePath="$PROJECT_DIR$/table.py" beforeDir="false" afterPath="$PROJECT_DIR$/table.py" afterDir="false" />
</list>
<option name="EXCLUDED_CONVERTED_TO_IGNORED" value="true" />
<option name="SHOW_DIALOG" value="false" />
......@@ -18,48 +18,44 @@
<counts>
<entry key="project.closed" value="3" />
<entry key="project.open.time.2" value="1" />
<entry key="project.open.time.7" value="1" />
<entry key="project.open.time.8" value="1" />
<entry key="project.open.time.9" value="1" />
<entry key="project.opened" value="3" />
<entry key="project.opened" value="4" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.open">
<counts>
<entry key="md" value="1" />
<entry key="md" value="2" />
<entry key="py" value="8" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.open">
<counts>
<entry key="Markdown" value="1" />
<entry key="Markdown" value="2" />
<entry key="Python" value="8" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.extensions.edit">
<counts>
<entry key="Python Console" value="250" />
<entry key="py" value="1827" />
<entry key="Python Console" value="259" />
<entry key="py" value="2762" />
</counts>
</usages-collector>
<usages-collector id="statistics.file.types.edit">
<counts>
<entry key="Python" value="2077" />
<entry key="Python" value="3021" />
</counts>
</usages-collector>
</session>
</component>
<component name="FileEditorManager">
<leaf SIDE_TABS_SIZE_LIMIT_KEY="300">
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/player/__init__.py">
<provider selected="true" editor-type-id="text-editor" />
</entry>
</file>
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/card.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="495">
<caret line="33" selection-start-line="33" selection-end-line="33" />
<state relative-caret-position="75">
<caret line="12" column="12" selection-start-line="12" selection-start-column="12" selection-end-line="12" selection-end-column="12" />
</state>
</provider>
</entry>
......@@ -67,12 +63,12 @@
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/player/player.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="480">
<caret line="60" column="8" selection-start-line="60" selection-start-column="8" selection-end-line="60" selection-end-column="13" />
<state relative-caret-position="255">
<caret line="17" column="23" lean-forward="true" selection-start-line="17" selection-start-column="23" selection-end-line="17" selection-end-column="23" />
<folding>
<element signature="e#0#21#0" expanded="true" />
<marker date="1538758454717" expanded="true" signature="59:61" ph="..." />
<marker date="1538758454717" expanded="true" signature="338:344" ph="..." />
<marker date="1539033158102" expanded="true" signature="897:1374" ph="..." />
<marker date="1539033158102" expanded="true" signature="2812:2866" ph="..." />
</folding>
</state>
</provider>
......@@ -81,11 +77,8 @@
<file pinned="false" current-in-tab="false">
<entry file="file://$PROJECT_DIR$/table.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="720">
<caret line="51" selection-start-line="51" selection-end-line="51" />
<folding>
<element signature="e#0#22#0" expanded="true" />
</folding>
<state relative-caret-position="116">
<caret line="87" column="30" selection-start-line="87" selection-start-column="30" selection-end-line="87" selection-end-column="30" />
</state>
</provider>
</entry>
......@@ -106,8 +99,8 @@
<option name="CHANGED_PATHS">
<list>
<option value="$PROJECT_DIR$/card.py" />
<option value="$PROJECT_DIR$/player/player.py" />
<option value="$PROJECT_DIR$/table.py" />
<option value="$PROJECT_DIR$/player/player.py" />
</list>
</option>
</component>
......@@ -213,7 +206,7 @@
<frame x="0" y="0" width="1440" height="900" extended-state="0" />
<editor active="true" />
<layout>
<window_info content_ui="combo" id="Project" order="0" visible="true" weight="0.25679544" />
<window_info active="true" content_ui="combo" id="Project" order="0" visible="true" weight="0.26037195" />
<window_info id="Structure" order="1" side_tool="true" weight="0.25" />
<window_info id="Favorites" order="2" side_tool="true" />
<window_info anchor="bottom" id="Message" order="0" />
......@@ -227,8 +220,8 @@
<window_info anchor="bottom" id="Version Control" order="8" show_stripe_button="false" />
<window_info anchor="bottom" id="Database Changes" order="9" show_stripe_button="false" />
<window_info anchor="bottom" id="Event Log" order="10" side_tool="true" />
<window_info anchor="bottom" id="Terminal" order="11" weight="0.32891566" />
<window_info active="true" anchor="bottom" id="Python Console" order="12" visible="true" weight="0.32891566" />
<window_info anchor="bottom" id="Terminal" order="11" visible="true" weight="0.32891566" />
<window_info anchor="bottom" id="Python Console" order="12" weight="0.32891566" />
<window_info anchor="right" id="Commander" internal_type="SLIDING" order="0" type="SLIDING" weight="0.4" />
<window_info anchor="right" id="Ant Build" order="1" weight="0.25" />
<window_info anchor="right" content_ui="combo" id="Hierarchy" order="2" weight="0.25" />
......@@ -259,29 +252,26 @@
</entry>
<entry file="file://$PROJECT_DIR$/card.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="495">
<caret line="33" selection-start-line="33" selection-end-line="33" />
<state relative-caret-position="75">
<caret line="12" column="12" selection-start-line="12" selection-start-column="12" selection-end-line="12" selection-end-column="12" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/table.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="720">
<caret line="51" selection-start-line="51" selection-end-line="51" />
<folding>
<element signature="e#0#22#0" expanded="true" />
</folding>
<state relative-caret-position="116">
<caret line="87" column="30" selection-start-line="87" selection-start-column="30" selection-end-line="87" selection-end-column="30" />
</state>
</provider>
</entry>
<entry file="file://$PROJECT_DIR$/player/player.py">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="480">
<caret line="60" column="8" selection-start-line="60" selection-start-column="8" selection-end-line="60" selection-end-column="13" />
<state relative-caret-position="255">
<caret line="17" column="23" lean-forward="true" selection-start-line="17" selection-start-column="23" selection-end-line="17" selection-end-column="23" />
<folding>
<element signature="e#0#21#0" expanded="true" />
<marker date="1538758454717" expanded="true" signature="59:61" ph="..." />
<marker date="1538758454717" expanded="true" signature="338:344" ph="..." />
<marker date="1539033158102" expanded="true" signature="897:1374" ph="..." />
<marker date="1539033158102" expanded="true" signature="2812:2866" ph="..." />
</folding>
</state>
</provider>
......
......@@ -10,7 +10,7 @@ class Color(Enum):
HEARTS = 1
SPADES = 2
DIAMONDS = 3
CLUBS =4
CLUBS = 4
class Card:
......
......@@ -32,6 +32,22 @@ class Player:
return self.__chips
# PRIVATE METHODS
def __putMoneyOnTable(self, amount):
if self.__isAllIn:
print("Player {} is already All In".format(self.__position))
return False
else:
if amount >= self.__chips:
print("Player {} is All In".format(self.__position))
self.__isAllIn = True
self.__chipsOnTable += self.__chips
self.__chips = 0
else:
print("Player {} bet {}".format(self.__position, amount))
self.__isAllIn = False
self.__chips -= amount
self.__chipsOnTable += amount
return True
# PUBLIC METHODS
def newHand(self, pos):
......@@ -59,12 +75,12 @@ class Player:
def endTurn(self):
ans = self.__chipsOnTable
self.chipsOnTable(0)
self.__chipsOnTable = 0
return ans
def receiveCards(self, card1, card2):
self.__cards = [card1, card2]
def receiveChip(self, chips):
self.__chips += chips
......@@ -75,49 +91,27 @@ class Player:
return temp
def giveSB(self, 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
return self.__putMoneyOnTable(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
return self.__putMoneyOnTable(bigBlind)
def bet(self, amount):
self.__hasHadAction = True
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
return self.__putMoneyOnTable(amount)
def check(self):
self.__hasHadAction = True
# TODO
return
print("Player {} checked".format(self.__position))
return True
def call(self):
def call(self, amountToCall):
self.__hasHadAction = True
# TODO
return
# TODO check poker rules
print("Player {} called".format(self.__position))
deltaCall = amountToCall - self.__chipsOnTable
return self.__putMoneyOnTable(deltaCall)
def fold(self):
self.__hasHadAction = True
......
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