Updated setup_player static method to permit each player to provide their starting ships.
This commit is contained in:
parent
e44e9acc27
commit
5e705d5ca8
@ -4,7 +4,7 @@ import random
|
|||||||
from collections import Counter
|
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 = 1000 # Default starting chips for each player
|
starting_chips = 0 # Default starting chips for each player
|
||||||
|
|
||||||
rank_counts = Counter()
|
rank_counts = Counter()
|
||||||
|
|
||||||
@ -13,7 +13,22 @@ def setup_players():
|
|||||||
num_players = int(input("Enter number of players (2–5): "))
|
num_players = int(input("Enter number of players (2–5): "))
|
||||||
if not 2 <= num_players <= 5:
|
if not 2 <= num_players <= 5:
|
||||||
raise ValueError("Must be between 2 and 5 players.")
|
raise ValueError("Must be between 2 and 5 players.")
|
||||||
return [Player(f"Player {i+1}", starting_chips) for i in range(num_players)]
|
|
||||||
|
players = []
|
||||||
|
for i in range(num_players):
|
||||||
|
name = f"Player {i+1}"
|
||||||
|
while True:
|
||||||
|
try:
|
||||||
|
starting_chips = int(input(f"Enter starting chips for {name}: "))
|
||||||
|
if starting_chips <= 0:
|
||||||
|
print("Starting chips must be a positive number.")
|
||||||
|
continue
|
||||||
|
break
|
||||||
|
except ValueError:
|
||||||
|
print("Please enter a valid integer.")
|
||||||
|
players.append(Player(name, starting_chips))
|
||||||
|
|
||||||
|
return players
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def deal_round(deck, players, round_num):
|
def deal_round(deck, players, round_num):
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user