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
|
from hand_utils import evaluate_hand, Tuple, List, Card, SUITS, RANKS
|
||||||
|
|
||||||
starting_chips = 0 # Default starting chips for each player
|
starting_chips = 0 # Default starting chips for each player
|
||||||
|
|
||||||
rank_counts = Counter()
|
rank_counts = Counter()
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
@ -20,7 +19,9 @@ def setup_players():
|
|||||||
|
|
||||||
players = []
|
players = []
|
||||||
for i in range(num_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:
|
while True:
|
||||||
try:
|
try:
|
||||||
starting_chips = int(input(f"Enter starting chips for {name}: "))
|
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())
|
print(player.show_hand())
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def determine_winner(players):
|
def determine_winner(players, pot):
|
||||||
best_score = (-1, -1)
|
best_score = (-1, -1)
|
||||||
|
|
||||||
winner = None
|
winner = None
|
||||||
|
pot = pot
|
||||||
|
|
||||||
for player in players:
|
for player in players:
|
||||||
if player.folded:
|
if player.folded:
|
||||||
@ -58,7 +61,8 @@ def determine_winner(players):
|
|||||||
winner = player
|
winner = player
|
||||||
|
|
||||||
if winner:
|
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):
|
def deal_initial_cards(deck, players):
|
||||||
for player in players:
|
for player in players:
|
||||||
@ -136,12 +140,13 @@ def play():
|
|||||||
if not player.folded:
|
if not player.folded:
|
||||||
print(player.reveal_full_hand())
|
print(player.reveal_full_hand())
|
||||||
|
|
||||||
determine_winner(players)
|
determine_winner(players, pot)
|
||||||
print(f"\nTotal pot: {pot}")
|
print(f"\nTotal pot: {pot}")
|
||||||
|
|
||||||
print("\n--- Final Chip Stacks ---")
|
print("\n--- Final Chip Stacks ---")
|
||||||
for player in players:
|
for player in players:
|
||||||
print(f"{player.name}: {player.chips} chips")
|
print(f"{player.name}: {player.chips} chips")
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
class Deck:
|
class Deck:
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user