From 764cdf69427b8d9abafe1c5dfb0429ade00406ce Mon Sep 17 00:00:00 2001 From: cerberus Date: Sun, 26 Oct 2025 19:38:23 +0100 Subject: [PATCH] created Player and Dealer class --- src/pyjack/dealer.py | 15 +++++++++++++++ src/pyjack/player.py | 21 +++++++++++++++++++++ 2 files changed, 36 insertions(+) create mode 100644 src/pyjack/dealer.py create mode 100644 src/pyjack/player.py diff --git a/src/pyjack/dealer.py b/src/pyjack/dealer.py new file mode 100644 index 0000000..e075313 --- /dev/null +++ b/src/pyjack/dealer.py @@ -0,0 +1,15 @@ +from pyjack.deck import Deck +from pyjack.player import Player + + +class Dealer(Player): + """The Dealer inherits all player functionality but has a specific, + automated turn behavior.""" + + def __init__(self, chips: int) -> None: + super().__init__(chips) + + def play(self, deck: Deck) -> None: + """Called only after the human player has finished their turn.""" + while self.hand.value < 17: + self.hit(deck) diff --git a/src/pyjack/player.py b/src/pyjack/player.py new file mode 100644 index 0000000..15ab853 --- /dev/null +++ b/src/pyjack/player.py @@ -0,0 +1,21 @@ +from pyjack.hand import Hand +from pyjack.deck import Deck + + +class Player: + """Sets up the player's name, starting chips, and a new Hand object.""" + + def __init__(self, chips: int) -> None: + self.hand = Hand() + self.chips = chips + + def hit(self, deck: Deck): + """Draws Card: Retrieves a card from the Deck and passes it to + the internal hand.""" + + self.hand.add_card(deck.deal_card()) + + def stand(self) -> None: + """Sets an internal state, signaling the end of the players + draw phase.""" + return