Compare commits
5 Commits
8c3dbc8fcd
...
blacktui
| Author | SHA1 | Date | |
|---|---|---|---|
| 084cfd0b9a | |||
| e2c99dfea4 | |||
| d57022f742 | |||
| a3aa761739 | |||
| 4222e76262 |
23
src/asciimatics/ascii.py
Normal file
23
src/asciimatics/ascii.py
Normal file
@@ -0,0 +1,23 @@
|
|||||||
|
from asciimatics.screen import Screen
|
||||||
|
from asciimatics.scene import Scene
|
||||||
|
from asciimatics.effects import Cycle, Stars
|
||||||
|
from asciimatics.renderers import FigletText
|
||||||
|
|
||||||
|
|
||||||
|
def demo(screen):
|
||||||
|
effects = [
|
||||||
|
Cycle(
|
||||||
|
screen,
|
||||||
|
FigletText("Asciimatics", font="big"),
|
||||||
|
screen.height // 2 - 8,
|
||||||
|
),
|
||||||
|
Cycle(
|
||||||
|
screen,
|
||||||
|
FigletText("ROCKS", font="big"),
|
||||||
|
screen.height // 2 + 3,
|
||||||
|
),
|
||||||
|
]
|
||||||
|
screen.play([Scene(effects, 500)])
|
||||||
|
|
||||||
|
|
||||||
|
Screen.wrapper(demo)
|
||||||
12
src/asciimatics/screen.py
Normal file
12
src/asciimatics/screen.py
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
from asciimatics.screen import ManagedScreen
|
||||||
|
from time import sleep
|
||||||
|
|
||||||
|
|
||||||
|
@ManagedScreen
|
||||||
|
def demo(screen):
|
||||||
|
screen.print_at("Hello world", 0, 0)
|
||||||
|
screen.refresh()
|
||||||
|
sleep(10)
|
||||||
|
|
||||||
|
|
||||||
|
demo()
|
||||||
@@ -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