added comments
This commit is contained in:
@@ -8,9 +8,6 @@ class Game:
|
||||
"""The Game class is the central coordinator, managing the flow of
|
||||
the entire round, from setup to payout."""
|
||||
|
||||
# TODO: - play_round() function
|
||||
# - show_cards function
|
||||
|
||||
def __init__(self) -> None:
|
||||
"""Creates instances of 'Deck', 'Player', and 'Dealer'."""
|
||||
self.deck = Deck()
|
||||
@@ -93,6 +90,7 @@ class Game:
|
||||
print("--Player Cards:--")
|
||||
for card in player_cards:
|
||||
print(str(card))
|
||||
|
||||
print(f"Hand value: {player_hand.value}")
|
||||
|
||||
def play_round(self) -> None:
|
||||
@@ -105,8 +103,8 @@ class Game:
|
||||
player = self.player
|
||||
dealer = self.dealer
|
||||
|
||||
# beginning of a round, shuffle deck and deal cards
|
||||
|
||||
# Beginning of the round, the deck gets shuffled and all the
|
||||
# player cards are shown, while the dealer only shows one card.
|
||||
deck.shuffle()
|
||||
|
||||
player.hand.add_card(deck.deal_card())
|
||||
@@ -115,6 +113,8 @@ class Game:
|
||||
dealer.hand.add_card(deck.deal_card())
|
||||
|
||||
self.show_cards(hide_dealer=True)
|
||||
|
||||
# Player picks a card and adds it to his hand.
|
||||
player_turn = True
|
||||
while player_turn:
|
||||
if input("Do you want another card? [y] ") == "y":
|
||||
@@ -125,13 +125,16 @@ class Game:
|
||||
player.stand()
|
||||
player_turn = False
|
||||
|
||||
# self.show_cards()
|
||||
# Dealers turn and showing the cards of both player and dealer.
|
||||
dealer.play(deck)
|
||||
self.show_cards()
|
||||
|
||||
# Comparing hands and returning the winner of the game.
|
||||
os.system("clear")
|
||||
print(self.compare_hands(0))
|
||||
|
||||
# After each full round, the players and dealers hand get
|
||||
# cleared and a new deck is created.
|
||||
player.hand.__init__()
|
||||
dealer.hand.__init__()
|
||||
deck.__init__()
|
||||
|
||||
Reference in New Issue
Block a user