Skip to content

Commit 46dd015

Browse files
committed
removed match statement not supported by build pipeline
1 parent d6347f2 commit 46dd015

1 file changed

Lines changed: 36 additions & 39 deletions

File tree

71_Poker/python/game.py

Lines changed: 36 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -137,32 +137,31 @@ def _conduct_betting_round(self, post_draw: bool) -> bool:
137137
while True:
138138
human_action = self._get_human_action()
139139

140-
match human_action:
141-
case Player.Action.FOLD:
142-
# Human fold always ends betting loop (hand ends)
143-
self._settle_bets()
144-
self._award_pot(dealer_wins=True)
145-
return False
146-
147-
case Player.Action.CALL:
148-
# Human call always ends betting loop (proceed to next phase)
149-
self._settle_bets()
150-
return True
140+
if human_action == Player.Action.FOLD:
141+
# Human fold always ends betting loop (hand ends)
142+
self._settle_bets()
143+
self._award_pot(dealer_wins=True)
144+
return False
145+
146+
if human_action == Player.Action.CALL:
147+
# Human call always ends betting loop (proceed to next phase)
148+
self._settle_bets()
149+
return True
151150

152-
case Player.Action.CHECK:
153-
# Pre-draw: human check ends human's turn.
154-
# Post-draw: dealer gets a chance to bet/check back.
155-
if not post_draw or self._handle_human_post_draw_check():
156-
return True
157-
# If dealer bet, we fall through and loop for human response
151+
if human_action == Player.Action.CHECK:
152+
# Pre-draw: human check ends human's turn.
153+
# Post-draw: dealer gets a chance to bet/check back.
154+
if not post_draw or self._handle_human_post_draw_check():
155+
return True
156+
# If dealer bet, we fall through and loop for human response
158157

159-
case Player.Action.RAISE:
160-
if self._handle_human_raise():
161-
return True
162-
# If dealer re-raised, we fall through and loop for human response
158+
elif human_action == Player.Action.RAISE:
159+
if self._handle_human_raise():
160+
return True
161+
# If dealer re-raised, we fall through and loop for human response
163162

164-
case _:
165-
raise ValueError(f"Unknown player action: {human_action}")
163+
else:
164+
raise ValueError(f"Unknown player action: {human_action}")
166165

167166
def _handle_human_post_draw_check(self) -> bool:
168167
"""Process dealer response to human check. Returns True if phase ends."""
@@ -184,25 +183,23 @@ def _handle_human_raise(self) -> bool:
184183
if self.dealer.money < self.dealer.bet:
185184
self._dealer_try_raise_funds()
186185

187-
match dealer_action:
188-
case Player.Action.FOLD:
189-
print("I fold.")
190-
self._settle_bets()
191-
self._award_pot(dealer_wins=False)
192-
return True # Round ends
186+
if dealer_action == Player.Action.FOLD:
187+
print("I fold.")
188+
self._settle_bets()
189+
self._award_pot(dealer_wins=False)
190+
return True # Round ends
193191

194-
case Player.Action.CALL:
195-
print("I'll see you.")
196-
self._settle_bets()
197-
return True
192+
if dealer_action == Player.Action.CALL:
193+
print("I'll see you.")
194+
self._settle_bets()
195+
return True
198196

199-
case Player.Action.RAISE:
200-
raise_amount = self.dealer.bet - self.human.bet
201-
print(f"I'll see you, and raise you {raise_amount}")
202-
return False
197+
if dealer_action == Player.Action.RAISE:
198+
raise_amount = self.dealer.bet - self.human.bet
199+
print(f"I'll see you, and raise you {raise_amount}")
200+
return False
203201

204-
case _:
205-
raise ValueError(f"Unknown dealer action: {dealer_action}")
202+
raise ValueError(f"Unknown dealer action: {dealer_action}")
206203

207204
def _get_human_action(self) -> Player.Action:
208205
"""Prompt user for a bet and return the resulting Action."""

0 commit comments

Comments
 (0)