Compare commits
4 Commits
8c3dbc8fcd
...
main
| Author | SHA1 | Date | |
|---|---|---|---|
| e2c99dfea4 | |||
| d57022f742 | |||
| a3aa761739 | |||
| 4222e76262 |
@@ -11,8 +11,8 @@ class Game:
|
|||||||
def __init__(self) -> None:
|
def __init__(self) -> None:
|
||||||
"""Creates instances of 'Deck', 'Player', and 'Dealer'."""
|
"""Creates instances of 'Deck', 'Player', and 'Dealer'."""
|
||||||
self.deck = Deck()
|
self.deck = Deck()
|
||||||
self.player = Player(0)
|
self.player = Player(100)
|
||||||
self.dealer = Dealer(1000)
|
self.dealer = Dealer(10000)
|
||||||
|
|
||||||
def compare_hands(self, bet: float) -> str:
|
def compare_hands(self, bet: float) -> str:
|
||||||
"""*Resolution/Payout*: Compares final hand values, checks for
|
"""*Resolution/Payout*: Compares final hand values, checks for
|
||||||
@@ -103,6 +103,20 @@ class Game:
|
|||||||
player = self.player
|
player = self.player
|
||||||
dealer = self.dealer
|
dealer = self.dealer
|
||||||
|
|
||||||
|
# TODO: implement logic for setting the bet and passing the
|
||||||
|
# value to the hand comparison. Also keep the chip ammount of
|
||||||
|
# the player over multiple rounds.
|
||||||
|
|
||||||
|
# player starts with x amount and bets per round from his
|
||||||
|
# current chips. Internally the chips are handled as a float
|
||||||
|
# the player gets to see the float number as 'IS' and the
|
||||||
|
# rounded down number as 'Payout'
|
||||||
|
|
||||||
|
# HACK: this is just to fuck around and find out...
|
||||||
|
|
||||||
|
player_bet = input("How much do you want to bet?")
|
||||||
|
# player.chips += float(player_bet)
|
||||||
|
|
||||||
# Beginning of the round, the deck gets shuffled and all the
|
# Beginning of the round, the deck gets shuffled and all the
|
||||||
# player cards are shown, while the dealer only shows one card.
|
# player cards are shown, while the dealer only shows one card.
|
||||||
deck.shuffle()
|
deck.shuffle()
|
||||||
@@ -131,7 +145,9 @@ class Game:
|
|||||||
|
|
||||||
# Comparing hands and returning the winner of the game.
|
# Comparing hands and returning the winner of the game.
|
||||||
os.system("clear")
|
os.system("clear")
|
||||||
print(self.compare_hands(0))
|
print(self.compare_hands(float(player_bet)))
|
||||||
|
print(f"Player Chips: {player.chips}")
|
||||||
|
print(f"Dealer Chips: {dealer.chips}")
|
||||||
|
|
||||||
# After each full round, the players and dealers hand get
|
# After each full round, the players and dealers hand get
|
||||||
# cleared and a new deck is created.
|
# cleared and a new deck is created.
|
||||||
|
|||||||
@@ -7,7 +7,13 @@ if __name__ == "__main__":
|
|||||||
print("pyjack by cerberus")
|
print("pyjack by cerberus")
|
||||||
print("do you wanna play a round??")
|
print("do you wanna play a round??")
|
||||||
|
|
||||||
|
# Create game instance with the player and dealer
|
||||||
game = Game()
|
game = Game()
|
||||||
|
|
||||||
|
# Play the game
|
||||||
|
try:
|
||||||
while True:
|
while True:
|
||||||
# os.system("clear")
|
|
||||||
game.play_round()
|
game.play_round()
|
||||||
|
|
||||||
|
except KeyboardInterrupt:
|
||||||
|
print("End Program")
|
||||||
|
|||||||
28
tests/test_player.py
Normal file
28
tests/test_player.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
import pytest
|
||||||
|
|
||||||
|
from pyjack.player import Player
|
||||||
|
from pyjack.deck import Deck
|
||||||
|
|
||||||
|
|
||||||
|
# Start Fixtures
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def player() -> Player:
|
||||||
|
"""Fixture for the player test."""
|
||||||
|
player = Player(0)
|
||||||
|
return player
|
||||||
|
|
||||||
|
|
||||||
|
@pytest.fixture
|
||||||
|
def deck() -> Deck:
|
||||||
|
deck = Deck()
|
||||||
|
return deck
|
||||||
|
|
||||||
|
|
||||||
|
# Start Tests:
|
||||||
|
|
||||||
|
|
||||||
|
def test_player_hit_one_card(player, deck):
|
||||||
|
player.hit(deck)
|
||||||
|
assert len(player.hand.cards) == 1
|
||||||
Reference in New Issue
Block a user