Skip to content

Commit

Permalink
v8.6
Browse files Browse the repository at this point in the history
  • Loading branch information
JordanLeich authored May 11, 2021
1 parent 90e4109 commit 8f567be
Show file tree
Hide file tree
Showing 2 changed files with 102 additions and 25 deletions.
125 changes: 101 additions & 24 deletions Blackjack.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
#!/usr/bin/python3

# Made by Jordan Leich on 6/6/2020, Last updated on 5/6/2021, Version 8.3
# Made by Jordan Leich on 6/6/2020, Last updated on 5/10/2021, Version 8.6

# TODO List
# TODO List add a save feature, add multiple players or a.i. to the game

# Imports
import random
Expand All @@ -16,6 +16,8 @@
user_balance = 1000
dealer_balance = 5000
user_bet = 0
user_dealer_money_choice = 0
user_money_choice = 0
player_cards = []
dealer_cards = []

Expand All @@ -24,28 +26,45 @@ def another_game():
"""
Used when 1 single round of blackjack has ended. Allows the user to play another game of blackjack or quit playing
"""
global user_score, user_balance, dealer_balance
global user_score, user_balance, dealer_balance, user_dealer_money_choice, user_money_choice
print(colors.green + "Your win count is", user_score, "and your total balance is $" + str(user_balance), "\n",
colors.reset)
time.sleep(1)
print(colors.red + "The dealers total balance is $" + str(dealer_balance), "\n", colors.reset)
time.sleep(2)

if user_balance <= 0:
print(colors.red + "You don't have any more money to bet! Game Over!\n", colors.reset)
print(colors.red + "You don't have any more money to bet... Game Over!\n", colors.reset)
time.sleep(2)
quit()
user_game_over_choice = input('Would you like to play all over again (yes / no): ')
print()
time.sleep(.500)

if user_game_over_choice.lower() == 'y' or user_game_over_choice.lower() == 'yes':
print('A new game will begin...\n')
time.sleep(1)
custom_game()
elif user_game_over_choice.lower() == 'n' or user_game_over_choice.lower() == 'no':
print(colors.green + 'Thanks for playing! Exiting game now...\n', colors.reset)
time.sleep(1)
quit()
else:
print(colors.red + 'User game over choice selection error found... Restarting game...\n', colors.reset)
time.sleep(2)
intro()

elif user_balance >= 1:

if dealer_balance <= 0:
print(colors.green + "Congratulations! You have beat BlackJack 21 by defeating the dealers balance!\n",
colors.reset)
print(colors.green + "Congratulations! You have beat the BlackJack 21 game by defeating the dealers "
"balance!\n", colors.reset)
time.sleep(2)
elif dealer_balance <= 2500:
print(colors.green + "The dealers balance is looking small enough for you to win! Your doing well...\n",
colors.reset)
time.sleep(2)
restart_action = input("Do you want to play again or cash out your earning (yes / no): ")
restart_action = input("Do you want to play again or cash out your earning or play a brand new game (yes / no /"
" new): ")
print()
time.sleep(1)
if restart_action.lower() == "yes" or restart_action.lower() == "y":
Expand All @@ -55,6 +74,10 @@ def another_game():
str(user_balance) + str(". Thanks for playing!\n"), colors.reset)
time.sleep(1)
quit()
elif restart_action.lower() == "new":
print('A new game will begin...\n')
time.sleep(1)
intro()
else:
print(colors.red + "Invalid input... Restarting choice...\n", colors.reset)
time.sleep(1)
Expand All @@ -79,7 +102,8 @@ def game():
"""
This is the main code used for the game entirely
"""
global user_score, user_balance, user_bet, dealer_balance, player_cards, dealer_cards
global user_score, user_balance, user_bet, dealer_balance, player_cards, dealer_cards, user_money_choice, \
user_dealer_money_choice

player_cards = []
dealer_cards = []
Expand All @@ -90,13 +114,15 @@ def game():
time.sleep(1)

user_all_in = str(input("Would you like to go all in (yes / no): "))
print()
time.sleep(.500)

if user_all_in.lower() == "y" or user_all_in.lower() == "yes":
user_bet = user_balance
time.sleep(.500)
else:
print()
user_bet = int(input("How much would you like to bet in dollar amount? "))
time.sleep(1)
time.sleep(.500)
if user_bet > user_balance:
print()
print(colors.red + "Your total balance cannot make this bet! Your bet is too high for your balance!\n",
Expand Down Expand Up @@ -217,43 +243,44 @@ def songs():
playsound("songs\\Relax.mp3", False)
print("Now proceeding to BlackJack 21!\n")
time.sleep(1)
game()
custom_game()
elif song_list == 2:
playsound("songs\\Cartoon - On & On.mp3", False)
print("Now proceeding to BlackJack 21!\n")
time.sleep(1)
game()
custom_game()
elif song_list == 3:
playsound("songs\\Alan Walker - Spectre.mp3", False)
print("Now proceeding to BlackJack 21!\n")
time.sleep(1)
game()
custom_game()
elif song_list == 4:
playsound("songs\\DEAF KEV - Invincible.mp3", False)
print("Now proceeding to BlackJack 21!\n")
time.sleep(1)
game()
custom_game()
elif song_list == 5:
playsound("songs\\Different Heaven & EH!DE - My Heart.mp3", False)
print("Now proceeding to BlackJack 21!\n")
time.sleep(1)
game()
custom_game()
elif song_list == 6:
playsound("songs\\Electro-Light - Symbolism.mp3", False)
print("Now proceeding to BlackJack 21!\n")
time.sleep(1)
game()
custom_game()
elif song_list == 7:
print("Exiting song list and proceeding to BlackJack 21!\n")
time.sleep(1)
game()
custom_game()
else:
print(colors.red + "Song input from track list error found!\n", colors.reset)
time.sleep(1)
songs()
elif song_input.lower() == "n" or song_input.lower() == "no":
print("No song has been selected! Proceeding to BlackJack 21!\n")
print("No song has been selected! Now proceeding to game selection...\n")
time.sleep(1)
game()
custom_game()
else:
print(colors.red + "Song input error found...\n", colors.reset)
time.sleep(1)
Expand All @@ -263,12 +290,12 @@ def songs():
def intro():
print(colors.green + 'Hello there! Welcome to Blackjack 21, made by Jordan Leich!\n', colors.reset)
time.sleep(.500)
print(colors.yellow + "The goal of this game is to make the dealer go broke! Achieve this by placing your bets and "
"dealing your cards wisely, but carefully...\n", colors.reset)
print(colors.yellow + '''The goal of this game is to make the dealer go broke and score the most amount of money!
Achieve this by placing your bets and dealing your cards wisely, but carefully...\n''', colors.reset)
time.sleep(2)

user_knowledge = input('Do you know how to play Blackjack 21 or would you like to watch a tutorial via youtube'
' (yes / tutorial): ')
user_knowledge = input('Do you know how to play Blackjack 21 or would you like to watch a tutorial via youtube or '
'skip all setup options to play Blackjack 21 quickly (yes / tutorial / express): ')
print()
time.sleep(1)

Expand All @@ -282,6 +309,10 @@ def intro():
webbrowser.open(url, new=1)
time.sleep(140)
songs()
elif user_knowledge.lower() == 'e' or user_knowledge.lower() == 'express':
print('Express option has been selected, proceeding to Blackjack 21...\n')
time.sleep(.500)
game()
else:
print(colors.red + 'User knowledge input error found...', colors.reset)
time.sleep(1)
Expand Down Expand Up @@ -371,4 +402,50 @@ def game_scoring():
restart()


def custom_game():
global user_balance, dealer_balance, user_score, user_dealer_money_choice, user_money_choice
user_game_picker = input('Would you like to play normal Blackjack 21 or a Custom Game with custom user game '
'settings (blackjack / custom): ')
print()
time.sleep(1)

if user_game_picker.lower() == 'b' or user_game_picker.lower() == 'blackjack' or user_game_picker.lower() == \
'blackjack 21':
print('Normal Blackjack 21 has been selected...\n')
time.sleep(.500)
game()

elif user_game_picker.lower() == 'c' or user_game_picker.lower() == 'custom' or user_game_picker.lower() == \
'custom game':
print('Custom Blackjack 21 has been selected...\n')
time.sleep(.500)
user_money_choice = int(input('How much would you like your starting balance to be? '))
print()
time.sleep(.500)

if user_money_choice <= 0:
print(colors.yellow + 'Invalid starting balance... Please choose a balance greater than 0 dollars!\n',
colors.reset)
time.sleep(2)
custom_game()

user_balance = user_money_choice
user_dealer_money_choice = int(input('How much would you to set the dealers starting balance to? '))
print()
time.sleep(.500)
dealer_balance = user_dealer_money_choice
user_score_choice = int(input('How much would you like to set your scoring counter to? '))
print()
time.sleep(.500)
user_score = user_score_choice
print('Now proceeding to Blackjack 21 game with your custom settings...\n')
time.sleep(1)
game()

else:
print(colors.red + 'User game selection choice error found... Restarting choice selection...\n', colors.reset)
time.sleep(2)
custom_game()


intro()
2 changes: 1 addition & 1 deletion Requirements.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
colored==1.4.2
pip==21.1.1
playsound==1.2.2
setuptools==56.2.0

0 comments on commit 8f567be

Please sign in to comment.