├── requirements.txt ├── chips ├── 1.png ├── 10.png ├── 2.png ├── 20.png ├── 25.png ├── 5.png ├── 50.png ├── 100.png ├── 1000.png ├── 2000.png ├── 250.png ├── 500.png └── 5000.png ├── png ├── back.png ├── back@2x.png ├── cardBack.png ├── red_joker.png ├── 10_of_clubs.png ├── 10_of_hearts.png ├── 10_of_spades.png ├── 2_of_clubs.png ├── 2_of_hearts.png ├── 2_of_spades.png ├── 3_of_clubs.png ├── 3_of_hearts.png ├── 3_of_spades.png ├── 4_of_clubs.png ├── 4_of_hearts.png ├── 4_of_spades.png ├── 5_of_clubs.png ├── 5_of_hearts.png ├── 5_of_spades.png ├── 6_of_clubs.png ├── 6_of_hearts.png ├── 6_of_spades.png ├── 7_of_clubs.png ├── 7_of_hearts.png ├── 7_of_spades.png ├── 8_of_clubs.png ├── 8_of_hearts.png ├── 8_of_spades.png ├── 9_of_clubs.png ├── 9_of_hearts.png ├── 9_of_spades.png ├── ace_of_clubs.png ├── black_joker.png ├── 10_of_diamonds.png ├── 2_of_diamonds.png ├── 3_of_diamonds.png ├── 4_of_diamonds.png ├── 5_of_diamonds.png ├── 6_of_diamonds.png ├── 7_of_diamonds.png ├── 8_of_diamonds.png ├── 9_of_diamonds.png ├── ace_of_hearts.png ├── ace_of_spades.png ├── jack_of_clubs.png ├── jack_of_hearts.png ├── jack_of_spades.png ├── king_of_clubs.png ├── king_of_hearts.png ├── king_of_spades.png ├── queen_of_clubs.png ├── ace_of_diamonds.png ├── jack_of_diamonds.png ├── king_of_diamonds.png ├── queen_of_diamonds.png ├── queen_of_hearts.png └── queen_of_spades.png ├── back └── background.jpg ├── .gitpod.yml ├── .gitpod.dockerfile ├── README.md ├── install_requirements.py ├── casino.py └── main.py /requirements.txt: -------------------------------------------------------------------------------- 1 | pygame -------------------------------------------------------------------------------- /chips/1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/chips/1.png -------------------------------------------------------------------------------- /chips/10.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/chips/10.png -------------------------------------------------------------------------------- /chips/2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/chips/2.png -------------------------------------------------------------------------------- /chips/20.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/chips/20.png -------------------------------------------------------------------------------- /chips/25.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/chips/25.png -------------------------------------------------------------------------------- /chips/5.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/chips/5.png -------------------------------------------------------------------------------- /chips/50.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/chips/50.png -------------------------------------------------------------------------------- /png/back.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/back.png -------------------------------------------------------------------------------- /chips/100.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/chips/100.png -------------------------------------------------------------------------------- /chips/1000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/chips/1000.png -------------------------------------------------------------------------------- /chips/2000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/chips/2000.png -------------------------------------------------------------------------------- /chips/250.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/chips/250.png -------------------------------------------------------------------------------- /chips/500.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/chips/500.png -------------------------------------------------------------------------------- /chips/5000.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/chips/5000.png -------------------------------------------------------------------------------- /png/back@2x.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/back@2x.png -------------------------------------------------------------------------------- /png/cardBack.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/cardBack.png -------------------------------------------------------------------------------- /png/red_joker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/red_joker.png -------------------------------------------------------------------------------- /back/background.jpg: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/back/background.jpg -------------------------------------------------------------------------------- /png/10_of_clubs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/10_of_clubs.png -------------------------------------------------------------------------------- /png/10_of_hearts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/10_of_hearts.png -------------------------------------------------------------------------------- /png/10_of_spades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/10_of_spades.png -------------------------------------------------------------------------------- /png/2_of_clubs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/2_of_clubs.png -------------------------------------------------------------------------------- /png/2_of_hearts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/2_of_hearts.png -------------------------------------------------------------------------------- /png/2_of_spades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/2_of_spades.png -------------------------------------------------------------------------------- /png/3_of_clubs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/3_of_clubs.png -------------------------------------------------------------------------------- /png/3_of_hearts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/3_of_hearts.png -------------------------------------------------------------------------------- /png/3_of_spades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/3_of_spades.png -------------------------------------------------------------------------------- /png/4_of_clubs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/4_of_clubs.png -------------------------------------------------------------------------------- /png/4_of_hearts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/4_of_hearts.png -------------------------------------------------------------------------------- /png/4_of_spades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/4_of_spades.png -------------------------------------------------------------------------------- /png/5_of_clubs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/5_of_clubs.png -------------------------------------------------------------------------------- /png/5_of_hearts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/5_of_hearts.png -------------------------------------------------------------------------------- /png/5_of_spades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/5_of_spades.png -------------------------------------------------------------------------------- /png/6_of_clubs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/6_of_clubs.png -------------------------------------------------------------------------------- /png/6_of_hearts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/6_of_hearts.png -------------------------------------------------------------------------------- /png/6_of_spades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/6_of_spades.png -------------------------------------------------------------------------------- /png/7_of_clubs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/7_of_clubs.png -------------------------------------------------------------------------------- /png/7_of_hearts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/7_of_hearts.png -------------------------------------------------------------------------------- /png/7_of_spades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/7_of_spades.png -------------------------------------------------------------------------------- /png/8_of_clubs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/8_of_clubs.png -------------------------------------------------------------------------------- /png/8_of_hearts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/8_of_hearts.png -------------------------------------------------------------------------------- /png/8_of_spades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/8_of_spades.png -------------------------------------------------------------------------------- /png/9_of_clubs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/9_of_clubs.png -------------------------------------------------------------------------------- /png/9_of_hearts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/9_of_hearts.png -------------------------------------------------------------------------------- /png/9_of_spades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/9_of_spades.png -------------------------------------------------------------------------------- /png/ace_of_clubs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/ace_of_clubs.png -------------------------------------------------------------------------------- /png/black_joker.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/black_joker.png -------------------------------------------------------------------------------- /png/10_of_diamonds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/10_of_diamonds.png -------------------------------------------------------------------------------- /png/2_of_diamonds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/2_of_diamonds.png -------------------------------------------------------------------------------- /png/3_of_diamonds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/3_of_diamonds.png -------------------------------------------------------------------------------- /png/4_of_diamonds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/4_of_diamonds.png -------------------------------------------------------------------------------- /png/5_of_diamonds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/5_of_diamonds.png -------------------------------------------------------------------------------- /png/6_of_diamonds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/6_of_diamonds.png -------------------------------------------------------------------------------- /png/7_of_diamonds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/7_of_diamonds.png -------------------------------------------------------------------------------- /png/8_of_diamonds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/8_of_diamonds.png -------------------------------------------------------------------------------- /png/9_of_diamonds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/9_of_diamonds.png -------------------------------------------------------------------------------- /png/ace_of_hearts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/ace_of_hearts.png -------------------------------------------------------------------------------- /png/ace_of_spades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/ace_of_spades.png -------------------------------------------------------------------------------- /png/jack_of_clubs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/jack_of_clubs.png -------------------------------------------------------------------------------- /png/jack_of_hearts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/jack_of_hearts.png -------------------------------------------------------------------------------- /png/jack_of_spades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/jack_of_spades.png -------------------------------------------------------------------------------- /png/king_of_clubs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/king_of_clubs.png -------------------------------------------------------------------------------- /png/king_of_hearts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/king_of_hearts.png -------------------------------------------------------------------------------- /png/king_of_spades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/king_of_spades.png -------------------------------------------------------------------------------- /png/queen_of_clubs.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/queen_of_clubs.png -------------------------------------------------------------------------------- /png/ace_of_diamonds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/ace_of_diamonds.png -------------------------------------------------------------------------------- /png/jack_of_diamonds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/jack_of_diamonds.png -------------------------------------------------------------------------------- /png/king_of_diamonds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/king_of_diamonds.png -------------------------------------------------------------------------------- /png/queen_of_diamonds.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/queen_of_diamonds.png -------------------------------------------------------------------------------- /png/queen_of_hearts.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/queen_of_hearts.png -------------------------------------------------------------------------------- /png/queen_of_spades.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/techwithtim/Black-Jack/HEAD/png/queen_of_spades.png -------------------------------------------------------------------------------- /.gitpod.yml: -------------------------------------------------------------------------------- 1 | image: 2 | file: .gitpod.dockerfile 3 | ports: 4 | - port: 5900 5 | onOpen: ignore 6 | - port: 6080 7 | onOpen: open-preview 8 | tasks: 9 | - init: /usr/bin/python3 main.py 10 | command: /usr/bin/python3 main.py 11 | 12 | -------------------------------------------------------------------------------- /.gitpod.dockerfile: -------------------------------------------------------------------------------- 1 | FROM gitpod/workspace-full-vnc 2 | 3 | USER root 4 | RUN apt-get update && apt-get install -y \ 5 | tk-dev \ 6 | python3-tk \ 7 | python-tk \ 8 | && apt-get clean && rm -rf /var/cache/apt/* && rm -rf /var/lib/apt/lists/* && rm -rf /tmp/* 9 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Black-Jack 2 | A visual game of black jack! Made with pygame. 3 | 4 | Run the *main.py* script to get started. 5 | 6 | # Game Controls 7 | Press space to end beting period or to HIT (get another card). 8 | Press TAB to STAY. 9 | Click on the chips on the left side of thr screen to place a bet. 10 | 11 | # Requirements 12 | - Python 3.x 13 | - pygame 14 | 15 | # 💻 Launch Your Software Development Career Today! 16 | 17 | 🎓 **No degree? No problem!** My program equips you with everything you need to break into tech and land an entry-level software development role. 18 | 19 | 🚀 **Why Join?** 20 | - 💼 **$70k+ starting salary potential** 21 | - 🕐 **Self-paced:** Complete on your own time 22 | - 🤑 **Affordable:** Low risk compared to expensive bootcamps or degrees 23 | - 🎯 **45,000+ job openings** in the market 24 | 25 | 👉 **[Start your journey today!](https://techwithtim.net/dev)** 26 | No experience needed—just your determination. Future-proof your career and unlock six-figure potential like many of our students have! 27 | -------------------------------------------------------------------------------- /install_requirements.py: -------------------------------------------------------------------------------- 1 | import subprocess 2 | import sys 3 | import get_pip 4 | import os 5 | import importlib 6 | import contextlib 7 | 8 | def install(package): 9 | ''' 10 | installs a package using pip 11 | 12 | :param package: string 13 | ''' 14 | subprocess.call([sys.executable, "-m", "pip", "install", package]) 15 | 16 | 17 | required = [] 18 | failed = [] 19 | 20 | # Try to open reqirements.txt file and read all required packages 21 | try: 22 | file = open("requirements.txt", "r") 23 | file_lines = file.readlines() 24 | required = [line.strip().lower() for line in file_lines] 25 | file.close() 26 | except FileNotFoundError: 27 | print("[ERROR] No requiremnts.txt file found") 28 | 29 | 30 | if len(required) > 0: 31 | print("[INPUT] You are about to install", len(required), "packages, would you like to proceed (y/n):", end=" ") 32 | ans = input() 33 | 34 | if ans.lower() == "y": 35 | for package in required: 36 | try: 37 | print("[LOG] Looking for", package) 38 | with contextlib.redirect_stdout(None): 39 | __import__(package) 40 | print("[LOG]", package, "is already installed, skipping...") 41 | except ImportError: 42 | print("[LOG]", package, "not installed") 43 | 44 | try: 45 | print("[LOG] Trying to install", package, "via pip") 46 | try: 47 | import pip 48 | except: 49 | print("[EXCEPTION] Pip is not installed") 50 | print("[LOG] Trying to install pip") 51 | get_pip.main() 52 | print("[LOG] Pip has been installed") 53 | 54 | print("[LOG] Installing", package) 55 | install(package) 56 | with contextlib.redirect_stdout(None): 57 | __import__(package) 58 | print("[LOG]", package, "has been installed") 59 | except Exception as e: 60 | print("[ERROR] Could not install", package, "-", e) 61 | failed.append(package) 62 | 63 | else: 64 | print("[STOP] Operation terminated by user") 65 | else: 66 | print("[LOG] No packages to install") 67 | 68 | if len(failed) > 0: 69 | print("[FAILED]", len(failed), "package(s) were not installed. Failed package install(s):", end=" ") 70 | for x, package in enumerate(failed): 71 | if x != len(failed) -1: 72 | print(package, end=",") 73 | else: 74 | print(package) 75 | -------------------------------------------------------------------------------- /casino.py: -------------------------------------------------------------------------------- 1 | 2 | import random 3 | # Card Value 4 | # 1: Ace 5 | # 2 - 10: 2 - 10 6 | # 11: Jack 7 | # 12: Queen 8 | # 13: King 9 | # Suits 10 | # H: Hearts 11 | # D: Diamonds 12 | # C: Clubs 13 | # S: Spades 14 | 15 | 16 | class cards: 17 | def __init__(self): 18 | self.cardsL = [] 19 | for x in range(1,14): 20 | card = x 21 | for i in range(4): 22 | if i == 0: 23 | suit = 'H' 24 | elif i == 1: 25 | suit = 'D' 26 | elif i == 2: 27 | suit = 'C' 28 | elif i == 3: 29 | suit = 'S' 30 | self.cardsL.append([card, suit]) 31 | 32 | self.cardsL = self.cardsL * 4 33 | 34 | def getCards(self): 35 | return self.cardsL 36 | 37 | 38 | class dealer: 39 | def __init__(self, c): 40 | # 4 decks 41 | self.curValue = 0 42 | self.cardsL = c 43 | self.cards = [] 44 | 45 | def deal(self): 46 | r1 = random.randint(0, len(self.cardsL) - 1) 47 | randCard = self.cardsL[r1] 48 | self.cardsL.pop(r1) 49 | self.cards.append(randCard) 50 | 51 | r2 = random.randint(0, len(self.cardsL) - 1) 52 | randCard2 = self.cardsL[r2] 53 | self.cardsL.pop(r2) 54 | self.cards.append(randCard2) 55 | 56 | self.decision() 57 | return self.cards 58 | 59 | def decision(self): 60 | value = 0 61 | if self.cards[0][0] == 1 and self.cards[1][0] == 1: 62 | value = 2 63 | else: 64 | if self.cards[0][0] == 11 or self.cards[0][0] == 12 or self.cards[0][0] == 13: 65 | value += 10 66 | else: 67 | value += self.cards[0][0] 68 | if self.cards[1][0] == 11 or self.cards[1][0] == 12 or self.cards[1][0] == 13: 69 | value += 10 70 | else: 71 | value += self.cards[1][0] 72 | 73 | self.curValue = value 74 | 75 | if value == 11 and (self.cards[0][0] == 1 or self.cards[1][0] == 1): 76 | self.curValue = 21 77 | return self.curValue 78 | elif value < 17: 79 | self.hit() 80 | else: 81 | return self.curValue 82 | 83 | def hit(self): 84 | value = 0 85 | rand = random.randint(1, len(self.cardsL)) 86 | card = self.cardsL[rand] 87 | self.cards.append(card) 88 | self.cardsL.pop(rand) 89 | 90 | if card[0] == 11 or card[0] == 12 or card[0] == 13: 91 | value = 10 92 | elif card[0] == 1 and self.curValue == 10: 93 | value = 11 94 | elif card[0] == 1 and self.curValue < 11: 95 | value = 11 96 | elif card[0] == 1 and self.curValue == 20: 97 | value = 1 98 | else: 99 | value = card[0] 100 | 101 | self.curValue += value 102 | if self.curValue < 17: 103 | self.hit() 104 | elif self.curValue > 21: 105 | return self.curValue 106 | else: 107 | return self.curValue 108 | 109 | def getScore(self): 110 | return self.curValue 111 | 112 | def reset(self): 113 | self.cards = [] 114 | self.curValue = 0 115 | 116 | 117 | class player(): 118 | def __init__(self, c): 119 | self.cardsL = c 120 | self.cards = [] 121 | self.curValue = 0 122 | 123 | def deal(self): 124 | r1 = random.randint(0, len(self.cardsL) - 1) 125 | randCard = self.cardsL[r1] 126 | self.cardsL.pop(r1) 127 | self.cards.append(randCard) 128 | 129 | r2 = random.randint(0, len(self.cardsL) - 1) 130 | randCard2 = self.cardsL[r2] 131 | self.cardsL.pop(r2) 132 | self.cards.append(randCard2) 133 | 134 | self.cardsL = self.cardsL 135 | 136 | value = 0 137 | if self.cards[0][0] == 11 or self.cards[0][0] == 12 or self.cards[0][0] == 13: 138 | value += 10 139 | else: 140 | value += self.cards[0][0] 141 | if self.cards[1][0] == 11 or self.cards[1][0] == 12 or self.cards[1][0] == 13: 142 | value += 10 143 | else: 144 | value += self.cards[1][0] 145 | 146 | self.curValue = value 147 | 148 | if value == 11 and (self.cards[0][0] == 1 or self.cards[1][0] == 1): 149 | self.curValue = 21 150 | 151 | 152 | return self.cards 153 | 154 | def hit(self): 155 | value = 0 156 | rand = random.randint(1,len(self.cardsL)) 157 | card = self.cardsL[rand] 158 | self.cards.append(card) 159 | self.cardsL.pop(rand) 160 | 161 | if card[0] == 11 or card[0] == 12 or card[0] == 13: 162 | value = 10 163 | elif card[0] == 1 and self.curValue == 10: 164 | value = 11 165 | elif card[0] == 1 and self.curValue < 11: 166 | value = 11 167 | elif card[0] == 1 and self.curValue == 20: 168 | value = 1 169 | else: 170 | value = card[0] 171 | 172 | self.curValue += value 173 | if self.curValue > 21 and self.cards.__contains__(1): 174 | if self.cards.count(1) == 1: 175 | if self.curValue - 10 < 22: 176 | self.curValue = self.curValue - 10 177 | 178 | 179 | return card 180 | 181 | def getScore(self): 182 | return self.curValue 183 | 184 | 185 | c = cards() 186 | deck = c.getCards() 187 | d = dealer(deck) 188 | p = player(deck) 189 | 190 | 191 | 192 | -------------------------------------------------------------------------------- /main.py: -------------------------------------------------------------------------------- 1 | import install_requirements 2 | import casino 3 | import pygame 4 | import sys 5 | import os 6 | import math 7 | import time 8 | import tkinter as tk 9 | from tkinter import messagebox 10 | 11 | 12 | pygame.init() 13 | cardBack = pygame.image.load(os.path.join('png', 'cardBack.png')) 14 | screen = pygame.display.set_mode((1300, 900)) 15 | pygame.display.set_caption('Black Jack') 16 | clock = pygame.time.Clock() 17 | myfont = pygame.font.SysFont('monospace', 70) 18 | smallFont = pygame.font.SysFont('monospace', 30) 19 | bg = pygame.image.load(os.path.join('back', 'background.jpg')) 20 | screen.fill((0,128,0)) 21 | clock = pygame.time.Clock() 22 | deck = casino.cards() 23 | cardList = deck.getCards() 24 | d = casino.dealer(cardList) 25 | p = casino.player(cardList) 26 | 27 | pygame.display.flip() 28 | 29 | onTable = [] 30 | topCards = [] 31 | 32 | cardImg = [None] 33 | # Load 52 Images 34 | two_clubs = pygame.image.load(os.path.join('png', '2_of_clubs.png')) 35 | two_diamonds = pygame.image.load(os.path.join('png', '2_of_diamonds.png')) 36 | two_hearts = pygame.image.load(os.path.join('png', '2_of_hearts.png')) 37 | two_spades = pygame.image.load(os.path.join('png', '2_of_spades.png')) 38 | 39 | three_clubs = pygame.image.load(os.path.join('png', '3_of_clubs.png')) 40 | three_spades = pygame.image.load(os.path.join('png', '3_of_spades.png')) 41 | three_diamonds = pygame.image.load(os.path.join('png', '3_of_diamonds.png')) 42 | three_hearts = pygame.image.load(os.path.join('png', '3_of_hearts.png')) 43 | 44 | four_clubs = pygame.image.load(os.path.join('png', '4_of_clubs.png')) 45 | four_spades = pygame.image.load(os.path.join('png', '4_of_spades.png')) 46 | four_diamonds = pygame.image.load(os.path.join('png', '4_of_diamonds.png')) 47 | four_hearts = pygame.image.load(os.path.join('png', '4_of_hearts.png')) 48 | 49 | five_clubs = pygame.image.load(os.path.join('png', '5_of_clubs.png')) 50 | five_spades = pygame.image.load(os.path.join('png', '5_of_spades.png')) 51 | five_diamonds = pygame.image.load(os.path.join('png', '5_of_diamonds.png')) 52 | five_hearts = pygame.image.load(os.path.join('png', '5_of_hearts.png')) 53 | 54 | six_clubs = pygame.image.load(os.path.join('png', '6_of_clubs.png')) 55 | six_spades = pygame.image.load(os.path.join('png', '6_of_spades.png')) 56 | six_diamonds = pygame.image.load(os.path.join('png', '6_of_diamonds.png')) 57 | six_hearts = pygame.image.load(os.path.join('png', '6_of_hearts.png')) 58 | 59 | seven_clubs = pygame.image.load(os.path.join('png', '7_of_clubs.png')) 60 | seven_spades = pygame.image.load(os.path.join('png', '7_of_spades.png')) 61 | seven_diamonds = pygame.image.load(os.path.join('png', '7_of_diamonds.png')) 62 | seven_hearts = pygame.image.load(os.path.join('png', '7_of_hearts.png')) 63 | 64 | eight_clubs = pygame.image.load(os.path.join('png', '8_of_clubs.png')) 65 | eight_spades = pygame.image.load(os.path.join('png', '8_of_spades.png')) 66 | eight_diamonds = pygame.image.load(os.path.join('png', '8_of_diamonds.png')) 67 | eight_hearts = pygame.image.load(os.path.join('png', '8_of_hearts.png')) 68 | 69 | nine_clubs = pygame.image.load(os.path.join('png', '9_of_clubs.png')) 70 | nine_spades = pygame.image.load(os.path.join('png', '9_of_spades.png')) 71 | nine_diamonds = pygame.image.load(os.path.join('png', '9_of_diamonds.png')) 72 | nine_hearts = pygame.image.load(os.path.join('png', '9_of_hearts.png')) 73 | 74 | ten_clubs = pygame.image.load(os.path.join('png', '10_of_clubs.png')) 75 | ten_spades = pygame.image.load(os.path.join('png', '10_of_diamonds.png')) 76 | ten_diamonds = pygame.image.load(os.path.join('png', '10_of_hearts.png')) 77 | ten_hearts = pygame.image.load(os.path.join('png', '10_of_spades.png')) 78 | 79 | jack_clubs = pygame.image.load(os.path.join('png', 'jack_of_clubs.png')) 80 | jack_spades = pygame.image.load(os.path.join('png', 'jack_of_spades.png')) 81 | jack_diamonds = pygame.image.load(os.path.join('png', 'jack_of_diamonds.png')) 82 | jack_hearts = pygame.image.load(os.path.join('png', 'jack_of_hearts.png')) 83 | 84 | queen_clubs = pygame.image.load(os.path.join('png', 'queen_of_clubs.png')) 85 | queen_spades = pygame.image.load(os.path.join('png', 'queen_of_spades.png')) 86 | queen_diamonds = pygame.image.load(os.path.join('png', 'queen_of_diamonds.png')) 87 | queen_hearts = pygame.image.load(os.path.join('png', 'queen_of_hearts.png')) 88 | 89 | king_clubs = pygame.image.load(os.path.join('png', 'king_of_clubs.png')) 90 | king_spades = pygame.image.load(os.path.join('png', 'king_of_spades.png')) 91 | king_diamonds = pygame.image.load(os.path.join('png', 'king_of_diamonds.png')) 92 | king_hearts = pygame.image.load(os.path.join('png', 'king_of_hearts.png')) 93 | 94 | ace_clubs = pygame.image.load(os.path.join('png', 'ace_of_clubs.png')) 95 | ace_spades = pygame.image.load(os.path.join('png', 'ace_of_spades.png')) 96 | ace_diamonds = pygame.image.load(os.path.join('png', 'ace_of_diamonds.png')) 97 | ace_hearts = pygame.image.load(os.path.join('png', 'ace_of_hearts.png')) 98 | 99 | cardImg.append([ace_clubs, ace_diamonds, ace_hearts, ace_spades]) 100 | cardImg.append([two_clubs, two_diamonds, two_hearts, two_spades]) 101 | cardImg.append([three_clubs, three_diamonds, three_hearts, three_spades]) 102 | cardImg.append([four_clubs, four_diamonds, four_hearts, four_spades]) 103 | cardImg.append([five_clubs, five_diamonds, five_hearts, five_spades]) 104 | cardImg.append([six_clubs, six_diamonds, six_hearts, six_spades]) 105 | cardImg.append([seven_clubs, seven_diamonds, seven_hearts, seven_spades]) 106 | cardImg.append([eight_clubs, eight_diamonds, eight_hearts, eight_spades]) 107 | cardImg.append([nine_clubs, nine_diamonds, nine_hearts, nine_spades]) 108 | cardImg.append([ten_clubs, ten_diamonds, ten_hearts, ten_spades]) 109 | cardImg.append([jack_clubs, jack_diamonds, jack_hearts, jack_spades]) 110 | cardImg.append([queen_clubs, queen_diamonds, queen_hearts, queen_spades]) 111 | cardImg.append([king_clubs, king_diamonds, king_hearts, king_spades]) 112 | 113 | one = pygame.image.load(os.path.join('chips', '1.png')) 114 | two = pygame.image.load(os.path.join('chips', '2.png')) 115 | five = pygame.image.load(os.path.join('chips', '5.png')) 116 | ten = pygame.image.load(os.path.join('chips', '10.png')) 117 | twenty = pygame.image.load(os.path.join('chips', '20.png')) 118 | 119 | didBet = False 120 | betChips = 0 121 | chips = [] 122 | betArray = [] 123 | playerChips = 50 124 | 125 | chips.append([one, 20, 225, 1]) 126 | chips.append([two, 20, 300, 2]) 127 | chips.append([five, 20, 375, 5]) 128 | chips.append([ten, 20, 450, 10]) 129 | chips.append([twenty, 20, 525, 20]) 130 | 131 | 132 | def lost(): 133 | screen.fill((0,128,0)) 134 | label = myfont.render('Press any key to play again', 1, (255,255,255)) 135 | label2 = myfont.render('Out of Chips...', 1, (255,255,255)) 136 | screen.blit(label, (100, 450)) 137 | screen.blit(label2, (350, 350)) 138 | pygame.display.update() 139 | while True: 140 | ev = pygame.event.poll() 141 | if ev.type == pygame.KEYDOWN: 142 | firstStart() 143 | break 144 | if ev.type == pygame.QUIT: 145 | pygame.quit() 146 | 147 | 148 | def bet(): 149 | global betChips 150 | global playerChips 151 | label = myfont.render('Please place your bet: ', 1, (255,255,255)) 152 | screen.blit(label, (230, 430)) 153 | updateChips() 154 | pygame.display.update() 155 | while True: 156 | label = smallFont.render('Press space when finished', 1, (255, 255, 255)) 157 | screen.blit(label, (430, 850)) 158 | updateChips() 159 | pygame.display.update() 160 | ev = pygame.event.poll() 161 | if ev.type == pygame.MOUSEBUTTONDOWN: 162 | pos = pygame.mouse.get_pos() 163 | for i in range(len(chips)): 164 | if pos[0] > chips[i][1] and pos[0] < chips[i][1] + 50: 165 | if pos[1] > chips[i][2] and pos[1] < chips[i][2] + 50: 166 | if playerChips - chips[i][3] >= 0: 167 | betChips += chips[i][3] 168 | dealChips(chips[i][0], 525 + i * 50, 550, chips[i][1], chips[i][2]) 169 | playerChips -= chips[i][3] 170 | else: 171 | root = tk.Tk() 172 | messagebox.showinfo('Not enough chips!', ('You do not have enough \n chips to bet that amount, \n your current amount of chips is ' + str(playerChips))) 173 | try: 174 | root.destroy() 175 | except: 176 | pass 177 | if ev.type == pygame.QUIT: 178 | pygame.quit() 179 | if ev.type == pygame.KEYDOWN: 180 | if betChips >= 1: 181 | pygame.draw.rect(screen, (0, 128, 0), (429, 849, 600, 100)) 182 | break 183 | 184 | 185 | def drawChip(img, x, y): 186 | w = 50 187 | h = 50 188 | newIMG = pygame.transform.scale(img, (w, h)) 189 | screen.blit(newIMG, (x,y)) 190 | 191 | 192 | def firstStart(): 193 | global playerChips 194 | reset() 195 | playerChips = 50 196 | screen.fill((0,128,0)) 197 | label = myfont.render('Welcome to Black Jack!', 1, (255, 255, 255)) 198 | label2 = myfont.render('Press space to start', 1, (255,255,255)) 199 | screen.blit(label2, (225, 550)) 200 | screen.blit(label, (175, 400)) 201 | pygame.display.update() 202 | pygame.init() 203 | 204 | while True: 205 | clock.tick(60) 206 | ev = pygame.event.poll() 207 | if ev.type == pygame.QUIT: 208 | pygame.quit() 209 | if ev.type == pygame.KEYDOWN: 210 | dealplayer(675, 650) 211 | dealplayer(500, 650) 212 | dealplayer(675, 50) 213 | dealplayer(500, 50) 214 | bet() 215 | main() 216 | 217 | def restart(): 218 | global playerChips 219 | screen.fill((0,128,0)) 220 | pygame.display.update() 221 | pygame.init() 222 | 223 | if playerChips == 0: 224 | lost() 225 | 226 | while True: 227 | clock.tick(60) 228 | dealplayer(675, 650) 229 | dealplayer(500, 650) 230 | dealplayer(675, 50) 231 | dealplayer(500, 50) 232 | bet() 233 | main() 234 | 235 | def reset(): 236 | global onTable 237 | global cardImg 238 | global topCards 239 | global didBet 240 | global betChips 241 | global betArray 242 | betArray = [] 243 | onTable = [] 244 | topCards = [] 245 | didBet = False 246 | betChips = 0 247 | time.sleep(1) 248 | 249 | 250 | def dealChips(img, x, y, s, w): 251 | endx = x 252 | endy = y 253 | movex = s 254 | movey = w 255 | x_dist = x - s 256 | y_dist = y - w 257 | constant_x = x_dist / 50 258 | constant_y = y_dist / 30 259 | 260 | for i in range(100): 261 | if movey >= endy and movex >= endx: 262 | break 263 | else: 264 | screen.fill((0, 128, 0)) 265 | drawChip(img, movex, movey) 266 | if movex <= endx: 267 | movex += constant_x 268 | if movey <= endy: 269 | movey += constant_y 270 | 271 | for d in range(len(onTable)): 272 | drawCard(onTable[d][0], onTable[d][1], onTable[d][2]) 273 | 274 | for i in range(len(chips)): 275 | drawChip(chips[i][0], chips[i][1], chips[i][2]) 276 | 277 | for q in range(len(betArray)): 278 | drawChip(betArray[q][0], betArray[q][1], betArray[q][2]) 279 | 280 | clock.tick(50) 281 | drawCard(cardBack, 15, 15) 282 | updateChips() 283 | pygame.display.update() 284 | 285 | betArray.append([img, movex, movey]) 286 | 287 | 288 | def dealplayer(x,y): 289 | endx = x 290 | endy = y 291 | movex = 0 292 | movey = 0 293 | 294 | h = math.sqrt(endx**2 + endy**2) 295 | 296 | for i in range(round(h / 10)): 297 | screen.fill((0, 128, 0)) 298 | movex += endx / (h/10) 299 | movey += endy / (h/10) 300 | drawCard(cardBack, movex, movey) 301 | for d in range(len(onTable)): 302 | drawCard(onTable[d][0], onTable[d][1], onTable[d][2]) 303 | 304 | for i in range(len(chips)): 305 | drawChip(chips[i][0], chips[i][1], chips[i][2]) 306 | 307 | for w in range(len(betArray)): 308 | drawChip(betArray[w][0], betArray[w][1], betArray[w][2]) 309 | 310 | clock.tick(50) 311 | drawCard(cardBack, 15, 15) 312 | updateChips() 313 | pygame.display.update() 314 | 315 | onTable.append([cardBack, x, y]) 316 | 317 | def dealplayerHit(hit,x,y): 318 | endx = x 319 | endy = y 320 | movex = 0 321 | movey = 0 322 | 323 | h = math.sqrt(endx**2 + endy**2) 324 | 325 | for i in range(round(h / 10)): 326 | screen.fill((0, 128, 0)) 327 | updateChips() 328 | movex += endx / (h/10) 329 | movey += endy / (h/10) 330 | drawCard(cardBack, movex, movey) 331 | for d in range(len(onTable)): 332 | drawCard(onTable[d][0], onTable[d][1], onTable[d][2]) 333 | for i in range(len(chips)): 334 | drawChip(chips[i][0], chips[i][1], chips[i][2]) 335 | 336 | for w in range(len(betArray)): 337 | drawChip(betArray[w][0], betArray[w][1], betArray[w][2]) 338 | drawCard(cardBack, 15, 15) 339 | clock.tick(50) 340 | pygame.display.update() 341 | 342 | onTable.append([hit, x, y]) 343 | 344 | 345 | def cardImage(n, suit): 346 | 347 | if suit == 'C': 348 | return cardImg[n][0] 349 | elif suit == 'D': 350 | return cardImg[n][1] 351 | elif suit == 'H': 352 | return cardImg[n][2] 353 | elif suit == 'S': 354 | return cardImg[n][3] 355 | 356 | 357 | def updateChips(): 358 | global playerChips 359 | pygame.draw.rect(screen, (0,128,0), (39, 585, 200, 40), 0) 360 | label = smallFont.render('Chips: ' + str(playerChips), 1, (255,255,255)) 361 | screen.blit(label, (10, 585)) 362 | 363 | 364 | def updateScore(turn=False): 365 | dScore = d.getScore() 366 | pScore = p.getScore() 367 | score1 = smallFont.render(str(dScore), 1, (255,255,255)) 368 | score2 = smallFont.render(str(pScore), 1, (255, 255, 255)) 369 | screen.blit(score2, (1150, 700)) 370 | if turn: 371 | screen.blit(score1, (1150, 50)) 372 | 373 | 374 | def drawCard(img, x, y): 375 | white = (255, 255, 255) 376 | w = 130 377 | h = 181 378 | pygame.draw.rect(screen, white, (x - 5, y - 4, w + 10, h + 8), 0) 379 | newIMG = pygame.transform.scale(img, (w, h)) 380 | screen.blit(newIMG, (x,y)) 381 | 382 | 383 | def main(): 384 | # DRAWING AND INIT 385 | # VARIABLES 386 | global d 387 | global p 388 | global playerChips 389 | deck = casino.cards() 390 | cardList = deck.getCards() 391 | d = casino.dealer(cardList) 392 | p = casino.player(cardList) 393 | playerCards = p.deal() 394 | dealerCards = d.deal() 395 | allowHit = False 396 | playerReveal = False 397 | playerTurn = True 398 | playerStay = False 399 | onTable[2] = [cardImage(dealerCards[0][0], dealerCards[0][1]), 675, 50] 400 | onTable[3] = [cardBack, 500, 50] 401 | while True: 402 | 403 | pygame.display.update() 404 | clock.tick(60) 405 | # PLAYER DECISION 406 | if playerReveal == False: 407 | drawCard(cardBack, 675, 650) 408 | drawCard(cardBack, 500, 650) 409 | label = smallFont.render('Press space to reveal cards', 1, (255,255,255)) 410 | screen.blit(label, (430, 850)) 411 | ev = pygame.event.poll() 412 | if ev.type == pygame.QUIT: 413 | pygame.quit() 414 | if ev.type == pygame.KEYDOWN: 415 | if ev.key == pygame.K_SPACE: 416 | # Show cards 417 | playerReveal = True 418 | allowHit = True 419 | drawCard(cardImage(playerCards[0][0], playerCards[0][1]), 675, 650) 420 | drawCard(cardImage(playerCards[1][0], playerCards[1][1]), 500, 650) 421 | onTable[0] = [cardImage(playerCards[0][0], playerCards[0][1]), 675, 650] 422 | onTable[1] = [cardImage(playerCards[1][0], playerCards[1][1]), 500, 650] 423 | pygame.draw.rect(screen, (0, 128, 0), (429, 849, 550, 100)) 424 | pygame.display.update() 425 | else: 426 | label = smallFont.render('Press space to hit and tab to stay', 1, (255, 255, 255)) 427 | screen.blit(label, (350, 850)) 428 | updateScore() 429 | pygame.display.update() 430 | 431 | ev = pygame.event.poll() 432 | if ev.type == pygame.QUIT: 433 | pygame.quit() 434 | if ev.type == pygame.KEYDOWN: 435 | if ev.key == pygame.K_TAB: 436 | playerStay = True 437 | updateScore(True) 438 | if ev.key == pygame.K_SPACE: 439 | 440 | if allowHit: 441 | hitCard = p.hit() 442 | if len(p.cards) == 3: 443 | dealplayerHit(cardImage(hitCard[0], hitCard[1]), 325, 650) 444 | drawCard(cardImage(hitCard[0], hitCard[1]), 325, 650) 445 | updateScore() 446 | elif len(p.cards) == 4: 447 | dealplayerHit(cardImage(hitCard[0], hitCard[1]), 850, 650) 448 | drawCard(cardImage(hitCard[0], hitCard[1]), 850, 650) 449 | updateScore() 450 | elif len(p.cards) == 5: 451 | dealplayerHit(cardImage(hitCard[0], hitCard[1]), 150, 650) 452 | drawCard(cardImage(hitCard[0], hitCard[1]), 150, 650) 453 | updateScore() 454 | elif len(p.cards) == 6: 455 | dealplayerHit(cardImage(hitCard[0], hitCard[1]), 1025, 650) 456 | drawCard(cardImage(hitCard[0], hitCard[1]), 1025, 650) 457 | updateScore() 458 | allowHit = True 459 | pygame.display.update() 460 | 461 | if p.getScore() > 21: 462 | label = myfont.render('You Went Over 21 :(', 1, (255,255,255)) 463 | screen.blit(label, (300, 430)) 464 | allowHit = False 465 | updateChips() 466 | pygame.display.update() 467 | time.sleep(1) 468 | pygame.draw.rect(screen, (0,128,0), (0, 640, 1300,200)) 469 | pygame.draw.rect(screen, (0, 128, 0), (200, 40, 1300, 200)) 470 | pygame.display.update() 471 | break 472 | 473 | elif p.getScore() == 21 and len(p.cards) == 2: 474 | allowHit = False 475 | playerChips += betChips * 3 476 | label = myfont.render('BLACK JACK!', 1, (255, 255, 255)) 477 | screen.blit(label, (420, 430)) 478 | updateChips() 479 | pygame.display.update() 480 | time.sleep(1) 481 | pygame.draw.rect(screen, (0, 128, 0), (0, 640, 1300, 200)) 482 | pygame.draw.rect(screen, (0, 128, 0), (200, 40, 1300, 200)) 483 | pygame.display.update() 484 | break 485 | 486 | elif playerStay: 487 | playerTurn = False 488 | allowHit = False 489 | updateScore() 490 | pygame.display.update() 491 | 492 | # --------------------------------------------------------------------------------------------------------- 493 | # DEALER 494 | 495 | if playerTurn == False: 496 | drawCard(cardImage(dealerCards[1][0], dealerCards[1][1]), 500, 50) 497 | try: 498 | ind = onTable.index([cardBack, 500, 50]) 499 | onTable[ind] = [cardImage(dealerCards[1][0], dealerCards[1][1]), 500, 50] 500 | except: 501 | pass 502 | updateScore() 503 | if len(d.cards) > 2: 504 | dealplayerHit(cardImage(dealerCards[2][0], dealerCards[2][1]), 325, 50) 505 | drawCard(cardImage(dealerCards[2][0], dealerCards[2][1]), 325, 50) 506 | pygame.display.update() 507 | time.sleep(0.3) 508 | if len(d.cards) > 3: 509 | dealplayerHit(cardImage(dealerCards[3][0], dealerCards[3][1]), 850, 50) 510 | drawCard(cardImage(dealerCards[3][0], dealerCards[3][1]), 850, 50) 511 | pygame.display.update() 512 | time.sleep(0.3) 513 | if len(d.cards) > 4: 514 | dealplayerHit(cardImage(dealerCards[4][0], dealerCards[4][1]), 150, 50) 515 | drawCard(cardImage(dealerCards[4][0], dealerCards[4][1]), 150, 50) 516 | pygame.display.update() 517 | time.sleep(0.3) 518 | if len(d.cards) > 5: 519 | dealplayerHit(cardImage(dealerCards[5][0], dealerCards[5][1]), 1025, 50) 520 | drawCard(cardImage(dealerCards[5][0], dealerCards[5][1]), 1025, 50) 521 | pygame.display.update() 522 | time.sleep(0.3) 523 | updateScore(True) 524 | 525 | if d.getScore() > p.getScore(): 526 | if d.getScore() < 22: 527 | label = myfont.render('You Lost', 1, (255,255,255)) 528 | screen.blit(label, (510, 430)) 529 | updateChips() 530 | pygame.display.update() 531 | break 532 | else: 533 | playerChips += betChips * 2 534 | label = myfont.render('Dealer Bust\'s, You Win', 1, (255,255,255)) 535 | screen.blit(label, (230, 430)) 536 | updateChips() 537 | pygame.display.update() 538 | break 539 | elif d.getScore() < p.getScore(): 540 | playerChips += betChips * 2 541 | label = myfont.render('Winner!', 1, (255,255,255)) 542 | screen.blit(label, (475, 430)) 543 | updateChips() 544 | pygame.display.update() 545 | break 546 | else: 547 | playerChips += betChips 548 | label = myfont.render('Tie', 1, (255,255,255)) 549 | screen.blit(label, (600, 450)) 550 | updateChips() 551 | pygame.display.update() 552 | break 553 | else: 554 | drawCard(cardImage(dealerCards[0][0], dealerCards[0][1]), 675, 50) 555 | drawCard(cardBack, 500, 50) 556 | time.sleep(1) 557 | 558 | reset() 559 | restart() 560 | 561 | firstStart() 562 | 563 | 564 | --------------------------------------------------------------------------------