2022-12-22 04:58:31 -05:00
|
|
|
from src.deck import Deck
|
|
|
|
from src.screen import Screen
|
|
|
|
from src.gamemaster import GameMaster
|
2022-12-20 23:51:27 -05:00
|
|
|
|
|
|
|
def main():
|
2022-12-22 04:58:31 -05:00
|
|
|
global kill
|
|
|
|
global screen
|
|
|
|
global num_decks
|
2022-12-20 23:51:27 -05:00
|
|
|
deck = Deck()
|
2022-12-22 04:58:31 -05:00
|
|
|
game = GameMaster()
|
|
|
|
|
|
|
|
if num_decks == 'q':
|
|
|
|
game.active = False
|
|
|
|
|
2022-12-20 23:51:27 -05:00
|
|
|
if deck.count_below(4):
|
|
|
|
deck.shuffle(num_decks)
|
|
|
|
|
|
|
|
for player in game.players:
|
|
|
|
for _ in range(2):
|
|
|
|
player.hand.append(deck.draw())
|
|
|
|
|
2022-12-22 04:58:31 -05:00
|
|
|
dealer = game.dealer
|
|
|
|
player = game.player
|
2022-12-20 23:51:27 -05:00
|
|
|
|
|
|
|
while game.active:
|
|
|
|
screen.update(game.players)
|
2022-12-22 04:58:31 -05:00
|
|
|
|
2022-12-20 23:51:27 -05:00
|
|
|
if game.active:
|
|
|
|
user_input = input(str(deck.count()) + ' cards left in deck.\n[H]it or [S]tand? ')
|
2022-12-22 04:58:31 -05:00
|
|
|
|
|
|
|
if not user_input:
|
|
|
|
user_input = 's'
|
2022-12-20 23:51:27 -05:00
|
|
|
|
|
|
|
match user_input.lower():
|
2022-12-22 04:58:31 -05:00
|
|
|
case 'y':
|
|
|
|
game.active = False
|
2022-12-20 23:51:27 -05:00
|
|
|
case 'q':
|
|
|
|
game.active = False
|
2022-12-22 04:58:31 -05:00
|
|
|
kill = True
|
2022-12-20 23:51:27 -05:00
|
|
|
case 'n':
|
|
|
|
game.active = False
|
|
|
|
case 'h':
|
|
|
|
player.hand.append(deck.draw())
|
|
|
|
case 's':
|
|
|
|
while dealer.score() < 17:
|
|
|
|
dealer.hand.append(deck.draw())
|
|
|
|
|
2022-12-22 04:58:31 -05:00
|
|
|
screen.update(game.players)
|
|
|
|
game.score()
|
|
|
|
|
|
|
|
if not game.active:
|
|
|
|
user_input = input('Play again? [Y/n] ')
|
|
|
|
|
|
|
|
kill = False
|
|
|
|
screen = Screen()
|
|
|
|
print(screen.show_intro())
|
|
|
|
num_decks = input('How many decks? (1-8): ')
|
|
|
|
while not kill:
|
|
|
|
main()
|