Finish blackjack
This commit is contained in:
@@ -3,7 +3,9 @@
|
||||
|
||||
import random
|
||||
|
||||
cards = [card for card in range(2, 11) for _ in range(4)]
|
||||
# Generate cards
|
||||
# The first list is for cards 2-10, the second is for cards J-A
|
||||
cards = [card for card in range(2, 11) for _ in range(4)] + [10 for _ in range(0, 16)]
|
||||
|
||||
def card_string(card: int) -> str:
|
||||
match card:
|
||||
@@ -24,8 +26,6 @@ random.shuffle(cards)
|
||||
def deal_card(cards: [int]) -> int:
|
||||
return cards.pop()
|
||||
|
||||
print(cards)
|
||||
|
||||
you = 0
|
||||
dealer = 0
|
||||
|
||||
@@ -38,8 +38,6 @@ print("You got dealt", card_string(card1), "and", card_string(card2), "for a tot
|
||||
|
||||
dealer += deal_card(cards) + deal_card(cards)
|
||||
|
||||
print("Shh dont tell them but the dealer has", dealer)
|
||||
|
||||
dealerWon = False
|
||||
|
||||
while True:
|
||||
@@ -62,3 +60,18 @@ while True:
|
||||
|
||||
if not dealerWon:
|
||||
print("Dealing the dealer")
|
||||
print("Dealer has", dealer)
|
||||
while dealer < 16:
|
||||
card = deal_card(cards)
|
||||
dealer += card
|
||||
print("Dealer got", card_string(card), "they have", dealer)
|
||||
if dealer > 21:
|
||||
print("Dealer is bust!")
|
||||
dealerWon = False
|
||||
break
|
||||
|
||||
if dealerWon:
|
||||
if you > dealer:
|
||||
print("You win!")
|
||||
else:
|
||||
print("Dealer wins...")
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
<title>Max's School Stuff</title>
|
||||
<style>
|
||||
|
||||
body {
|
||||
html {
|
||||
font-family: sans-serif;
|
||||
background-color: black;
|
||||
color: white;
|
||||
|
||||
Reference in New Issue
Block a user