Added option to enter a player's name, and changed round_num range to (1, 4)
This commit is contained in:
parent
38d956df2d
commit
7c406f4abc
@ -5,7 +5,6 @@ from collections import Counter
|
||||
from hand_utils import evaluate_hand, Tuple, List, Card, SUITS, RANKS
|
||||
|
||||
starting_chips = 0 # Default starting chips for each player
|
||||
|
||||
rank_counts = Counter()
|
||||
|
||||
@staticmethod
|
||||
@ -20,7 +19,9 @@ def setup_players():
|
||||
|
||||
players = []
|
||||
for i in range(num_players):
|
||||
name = f"Player {i+1}"
|
||||
name = input(f"Enter name for Player {i+1} (or press Enter for default): ").strip()
|
||||
if not name:
|
||||
name = f"Player {i+1}"
|
||||
while True:
|
||||
try:
|
||||
starting_chips = int(input(f"Enter starting chips for {name}: "))
|
||||
@ -43,9 +44,11 @@ def deal_round(deck, players, round_num):
|
||||
print(player.show_hand())
|
||||
|
||||
@staticmethod
|
||||
def determine_winner(players):
|
||||
def determine_winner(players, pot):
|
||||
best_score = (-1, -1)
|
||||
|
||||
winner = None
|
||||
pot = pot
|
||||
|
||||
for player in players:
|
||||
if player.folded:
|
||||
@ -58,7 +61,8 @@ def determine_winner(players):
|
||||
winner = player
|
||||
|
||||
if winner:
|
||||
print(f"\n🏆 {winner.name} wins with: {winner.reveal_full_hand()}")
|
||||
winner.chips += pot
|
||||
print(f"\n🏆 {winner.name} wins the pot with: {winner.reveal_full_hand()} and {winner.chips} chips")
|
||||
|
||||
def deal_initial_cards(deck, players):
|
||||
for player in players:
|
||||
@ -136,12 +140,13 @@ def play():
|
||||
if not player.folded:
|
||||
print(player.reveal_full_hand())
|
||||
|
||||
determine_winner(players)
|
||||
determine_winner(players, pot)
|
||||
print(f"\nTotal pot: {pot}")
|
||||
|
||||
print("\n--- Final Chip Stacks ---")
|
||||
for player in players:
|
||||
print(f"{player.name}: {player.chips} chips")
|
||||
|
||||
|
||||
|
||||
class Deck:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user