made it functional
This commit is contained in:
@@ -1,4 +1,3 @@
|
||||
import re
|
||||
from pyjack.dealer import Dealer
|
||||
from pyjack.deck import Deck
|
||||
from pyjack.player import Player
|
||||
@@ -65,18 +64,70 @@ class Game:
|
||||
second card is shown or concealed."""
|
||||
|
||||
player_cards = self.player.hand.cards
|
||||
player_hand = self.player.hand
|
||||
dealer_cards = self.dealer.hand.cards
|
||||
dealer_hand = self.dealer.hand
|
||||
|
||||
print("--Player Cards:--")
|
||||
for card in player_cards:
|
||||
print(str(card))
|
||||
print(f"Hand value: {player_hand.value}")
|
||||
|
||||
if hide_dealer:
|
||||
card = dealer_cards[0]
|
||||
print("--Dealer Cards:--")
|
||||
print(str(card))
|
||||
print("XXXX")
|
||||
print("XXXX\n")
|
||||
else:
|
||||
print("--Dealer Cards:--")
|
||||
for card in dealer_cards:
|
||||
print(str(card))
|
||||
print(f"Hand value: {dealer_hand.value}\n")
|
||||
|
||||
def show_player_cards(self) -> None:
|
||||
"""Displays the players hand"""
|
||||
player_cards = self.player.hand.cards
|
||||
player_hand = self.player.hand
|
||||
|
||||
print("--Player Cards:--")
|
||||
for card in player_cards:
|
||||
print(str(card))
|
||||
print(f"Hand value: {player_hand.value}")
|
||||
|
||||
def play_round(self) -> None:
|
||||
"""Logic of a game round"""
|
||||
|
||||
# Simplify value calls:
|
||||
|
||||
deck = self.deck
|
||||
|
||||
player = self.player
|
||||
dealer = self.dealer
|
||||
|
||||
# beginning of a round, shuffle deck and deal cards
|
||||
|
||||
deck.shuffle()
|
||||
|
||||
player.hand.add_card(deck.deal_card())
|
||||
player.hand.add_card(deck.deal_card())
|
||||
dealer.hand.add_card(deck.deal_card())
|
||||
dealer.hand.add_card(deck.deal_card())
|
||||
|
||||
self.show_cards(hide_dealer=True)
|
||||
player_turn = True
|
||||
while player_turn:
|
||||
if input("Do you want another card? [y] ") == "y":
|
||||
player.hit(deck)
|
||||
self.show_player_cards()
|
||||
else:
|
||||
print("\n")
|
||||
player.stand()
|
||||
player_turn = False
|
||||
|
||||
# self.show_cards()
|
||||
dealer.play(deck)
|
||||
self.show_cards()
|
||||
|
||||
print(self.compare_hands(0))
|
||||
player.hand.clear_hand()
|
||||
dealer.hand.clear_hand()
|
||||
|
||||
Reference in New Issue
Block a user