blackjack/blackjack.py

35 lines
607 B
Python
Raw Normal View History

2022-12-22 04:58:31 -05:00
from src.deck import Deck
2022-12-27 23:47:12 -05:00
from src.io import CLI
2022-12-22 04:58:31 -05:00
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
2022-12-27 23:47:12 -05:00
global ui
2022-12-22 04:58:31 -05:00
global num_decks
2022-12-22 18:30:42 -05:00
global deck
2022-12-31 00:47:08 -05:00
game = GameMaster(deck)
2022-12-22 04:58:31 -05:00
2022-12-31 00:47:08 -05:00
game.deal()
2022-12-20 23:51:27 -05:00
while game.active:
2022-12-31 00:47:08 -05:00
print(ui.update(game))
if not game.blackjack():
game.handle_player_input(ui.player_move(deck.count()), kill)
print(ui.update(game))
2022-12-22 19:15:38 -05:00
2022-12-22 04:58:31 -05:00
kill = False
2022-12-27 23:47:12 -05:00
ui = CLI()
2022-12-28 23:37:53 -05:00
print(ui.intro)
2022-12-22 19:15:38 -05:00
2022-12-27 23:47:12 -05:00
num_decks = ui.get_decks()
2022-12-22 22:32:15 -05:00
if num_decks == 'q':
kill = True
2022-12-22 18:30:42 -05:00
deck = Deck(num_decks)
2022-12-22 19:15:38 -05:00
2022-12-22 04:58:31 -05:00
while not kill:
main()
2022-12-27 23:47:12 -05:00
if not ui.play_again():
kill = True