oops
This commit is contained in:
parent
4d3a5252ca
commit
0e7f293204
1 changed files with 23 additions and 15 deletions
30
blackjack.py
30
blackjack.py
|
@ -1,4 +1,4 @@
|
||||||
motd = '''\
|
title = '''\
|
||||||
|
|
||||||
.oPYo. 8 8 o 8
|
.oPYo. 8 8 o 8
|
||||||
8 `8 8 8 8 8
|
8 `8 8 8 8 8
|
||||||
|
@ -14,6 +14,7 @@ import random
|
||||||
|
|
||||||
def make_card(vs, style):
|
def make_card(vs, style):
|
||||||
value = vs[0]
|
value = vs[0]
|
||||||
|
|
||||||
if value == '0':
|
if value == '0':
|
||||||
value = '10'
|
value = '10'
|
||||||
else:
|
else:
|
||||||
|
@ -21,8 +22,8 @@ def make_card(vs, style):
|
||||||
|
|
||||||
suit = vs[1] + ' '
|
suit = vs[1] + ' '
|
||||||
|
|
||||||
# fuck discord
|
# request text render of glyph but can break some fonts
|
||||||
# suit = suit + '\uFE0E'
|
# suit += '\uFE0E'
|
||||||
|
|
||||||
deck = '''\
|
deck = '''\
|
||||||
┌────────┐┐┐┐┐┐
|
┌────────┐┐┐┐┐┐
|
||||||
|
@ -76,10 +77,15 @@ def make_card(vs, style):
|
||||||
if style == 'card_part':
|
if style == 'card_part':
|
||||||
return card_part
|
return card_part
|
||||||
|
|
||||||
def generate_deck():
|
def generate_deck(n_decks):
|
||||||
suits = '♠♥♦♣'
|
suits = '♠♥♦♣'
|
||||||
cards = 'A234567890JQK'
|
cards = 'A234567890JQK'
|
||||||
return [card + suit for card in cards for suit in suits]
|
deck = []
|
||||||
|
|
||||||
|
while n_decks > 0:
|
||||||
|
deck += [card + suit for card in cards for suit in suits]
|
||||||
|
n_decks -= 1
|
||||||
|
return deck
|
||||||
|
|
||||||
def draw_card(player):
|
def draw_card(player):
|
||||||
global players
|
global players
|
||||||
|
@ -105,15 +111,13 @@ def deal():
|
||||||
global players
|
global players
|
||||||
for i in range(2):
|
for i in range(2):
|
||||||
for player in players:
|
for player in players:
|
||||||
if player != 'discard':
|
|
||||||
draw_card(player)
|
draw_card(player)
|
||||||
|
|
||||||
def show_board():
|
def show_board():
|
||||||
global players
|
global players
|
||||||
print('\033c', end='')
|
print('\033c', end='')
|
||||||
print(motd)
|
print(title)
|
||||||
for player in players:
|
for player in players:
|
||||||
if player != 'discard':
|
|
||||||
print(' '+player,
|
print(' '+player,
|
||||||
'\t\t\t\t Score:',player_score(player))
|
'\t\t\t\t Score:',player_score(player))
|
||||||
print_hand(player)
|
print_hand(player)
|
||||||
|
@ -134,7 +138,7 @@ def player_score(player):
|
||||||
|
|
||||||
if len(card_scores) == 2 and sum(card_scores) == 11:
|
if len(card_scores) == 2 and sum(card_scores) == 11:
|
||||||
game_active = False
|
game_active = False
|
||||||
gameover = player + 'has blackjack!'
|
gameover = player, 'has blackjack!'
|
||||||
|
|
||||||
if sum(card_scores) < 11:
|
if sum(card_scores) < 11:
|
||||||
if 1 in card_scores:
|
if 1 in card_scores:
|
||||||
|
@ -155,9 +159,12 @@ def main():
|
||||||
global gameover
|
global gameover
|
||||||
|
|
||||||
gameover = 'Error'
|
gameover = 'Error'
|
||||||
|
num_decks = 1
|
||||||
|
|
||||||
# 1-8 decks
|
# 1-8 decks
|
||||||
if len(play_deck) < 4:
|
if len(play_deck) < 4:
|
||||||
play_deck = generate_deck()
|
play_deck = generate_deck(num_decks)
|
||||||
|
|
||||||
# 5-9 seats
|
# 5-9 seats
|
||||||
players = {'Dealer': [],
|
players = {'Dealer': [],
|
||||||
'Player': []}
|
'Player': []}
|
||||||
|
@ -183,6 +190,7 @@ def main():
|
||||||
|
|
||||||
if user_input.lower() == 's':
|
if user_input.lower() == 's':
|
||||||
game_active = False
|
game_active = False
|
||||||
|
|
||||||
while player_score('Dealer') < 17:
|
while player_score('Dealer') < 17:
|
||||||
draw_card('Dealer')
|
draw_card('Dealer')
|
||||||
if player_score('Dealer') > 21:
|
if player_score('Dealer') > 21:
|
||||||
|
@ -204,7 +212,7 @@ def main():
|
||||||
|
|
||||||
|
|
||||||
kill = False
|
kill = False
|
||||||
play_deck = generate_deck()
|
play_deck = []
|
||||||
|
|
||||||
while kill == False:
|
while kill == False:
|
||||||
main()
|
main()
|
||||||
|
|
Loading…
Add table
Reference in a new issue