Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #name: William Herewini
- #date: 28/08/18
- import random
- import time
- import os
- balance = 1000
- print("\n"*20)
- def main():
- money = difficulty()
- char_name()
- choice(money)
- print('The End')
- return
- def difficulty():
- difficulty = ''
- while (difficulty != 'EASY') and (difficulty != 'HARD') and (difficulty != 'EZ'):
- difficulty = input('Easy or Hard?: ').upper()
- time.sleep(1)
- if difficulty == 'EASY':
- money = 500
- print('Money: $500')
- elif difficulty == 'HARD':
- money = 250
- print('Money: $250')
- print('')
- return money
- def intro_scene():
- time.sleep(1)
- print('A bright spotlight shines down upon you, blinding...')
- time.sleep(3)
- print('The rotors of the helicopters, deafening...')
- time.sleep(3)
- print('The wails of the encroaching sirens, piercing...')
- time.sleep(3)
- print('How did you get here you ask?\n')
- time.sleep(3)
- return
- def char_name():
- name = input("What's your name?: ").upper()
- value = random.randint(1, 3)
- time.sleep(1)
- if name == 'TAMARA':
- name = 'Slampa'
- print('Hi Slampa.\n')
- elif value == 1:
- name = name.title()
- print('What kind of name is ' + str(name) + '?')
- time.sleep(1)
- print('Alright then. \n')
- elif value == 2:
- name = name.title()
- print('What a pretty name.\n')
- else:
- name = name.title()
- print('Interesting...\n')
- time.sleep(2)
- print('It began at the casino, where many problematic nights do.')
- time.sleep(2)
- return name
- def choice(money):
- answer = ''
- while answer != 'BLACKJACK' and answer != 'ROULETTE' and answer != 'SLOTS':
- answer = input\
- ('What would you like play? (Blackjack, Roulette, Slots): ').upper()
- time.sleep(1)
- if answer == 'BLACKJACK':
- blackjack(money)
- elif answer == 'ROULETTE':
- roulette(money)
- elif answer == 'SLOTS':
- slots(money, balance)
- return
- '''Intro end'''
- def bet(money):
- bet_1 = 0
- while True:
- try:
- while bet_1 <= 0 or bet_1 > money:
- bet_1 = int(input('How much would you like to bet?: $'))
- break
- except:
- print('That is not an option')
- time.sleep(1)
- if bet_1 <= 0 or bet_1 > money:
- bet(money)
- else:
- return bet_1
- def check_bankrupt(money):
- if money <= 1:
- print('')
- time.sleep(1)
- print('\t-=Money: $0=-')
- time.sleep(1)
- print('You are bankrupt, how unfortunate')
- print('')
- is_bankrupt = True
- return is_bankrupt
- else:
- is_bankrupt = False
- return is_bankrupt
- '''Blackjack start'''
- def blackjack(money):
- print('')
- print('You sit at the nearest table and prepare a bet')
- print('Money: $' + str(money))
- time.sleep(1)
- bet_1 = bet(money)
- print('')
- money = money - bet_1
- time.sleep(1)
- number_1 = choose_card() # Layout: [card, value]
- number_2 = choose_card() # Layout: [card, value]
- your_cards = [number_1[0], number_2[0]]
- total = number_1[1] + number_2[1]
- print('Your cards are ' + str(number_1[0]) + ' and ' + str(number_2[0]) + \
- " for a total of " + str(total))
- number_d1 = choose_card() # Layout: [card, value]
- number_d2 = choose_card() # Layout: [card, value]
- d_total = number_d1[1] + number_d2[1]
- d_cards = [number_d1[0], number_d2[0]]
- time.sleep(2)
- print("The dealer's face-up card is " + str(number_d1[0]))
- print('')
- time.sleep(2)
- if total == 21 and len(your_cards) == 2 and d_total == 21 and len(d_cards) == 2:
- money += bet
- print('The dealer shows a ' + str(number_d2[0]) + ' for a total of ' + str(d_total))
- time.sleep(1)
- print('Push, you now have $' + str(money))
- is_bankrupt = check_bankrupt(money)
- if is_bankrupt:
- return money
- time.sleep(2)
- answer = ''
- while answer != 'YES' and answer != 'Y' and answer != 'NO' and answer != 'N':
- answer = input('Play again? (Yes or No): ').upper()
- time.sleep(1)
- if answer == 'YES' or answer == 'Y':
- blackjack(money)
- elif answer == 'NO' or answer == 'N':
- choice(money)
- if d_total == 21 and len(d_cards) == 2:
- print('The dealer shows a ' + str(number_d2[0]) + ' for a total of ' + str(d_total))
- time.sleep(1)
- print('Too bad, you now have $' + str(money))
- is_bankrupt = check_bankrupt(money)
- if is_bankrupt:
- return money
- time.sleep(1)
- answer = ''
- while answer != 'YES' and answer != 'Y' and answer != 'NO' and answer != 'N':
- answer = input('Play again? (Yes or No): ').upper()
- time.sleep(1)
- if answer == 'YES' or answer == 'Y':
- blackjack(money)
- elif answer == 'NO' or answer == 'N':
- choice(money)
- if total == 21 and len(your_cards) == 2:
- money = stand\
- (money, number_1, number_2, your_cards, number_d1, number_d2, d_cards, total, d_total, bet_1)
- is_bankrupt = check_bankrupt(money)
- if is_bankrupt:
- return money
- answer = ''
- while answer != 'YES' and answer != 'Y' and answer != 'NO' and answer != 'N':
- answer = input('Play again? (Yes or No): ').upper()
- time.sleep(1)
- if answer == 'YES' or answer == 'Y':
- blackjack(money)
- elif answer == 'NO' or answer == 'N':
- choice(money)
- reaction = ''
- while reaction != 'HIT' and reaction != 'STAND':
- reaction = input('What would you like to do? (Hit/Stand): ').upper()
- if reaction == 'STAND':
- money = stand\
- (money, number_1, number_2, your_cards, number_d1, number_d2, d_cards, total, d_total, bet_1)
- elif reaction == 'HIT':
- money = hit\
- (money, number_1, number_2, your_cards, number_d1, number_d2, d_cards, total, d_total, bet_1)
- is_bankrupt = check_bankrupt(money)
- if is_bankrupt:
- return money
- print('')
- time.sleep(2)
- answer = ''
- while answer != 'YES' and answer != 'Y' and answer != 'NO' and answer != 'N':
- answer = input('Play again? (Yes or No): ').upper()
- time.sleep(1)
- if answer == 'YES' or answer == 'Y':
- blackjack(money)
- elif answer == 'NO' or answer == 'N':
- choice(money)
- return money
- def choose_card():
- number_1 = random.randint(1,13)
- num_1_value = 10
- if number_1 == 11:
- number_1 = 'Jack'
- elif number_1 == 12:
- number_1 = 'Queen'
- elif number_1 == 13:
- number_1 = 'King'
- elif number_1 == 1:
- number_1 = 'Ace'
- num_1_value = 11
- else:
- num_1_value = number_1
- return [number_1, num_1_value]
- def stand(money, number_1, number_2, your_cards, number_d1, number_d2, d_cards, total, d_total, bet_1):
- time.sleep(1)
- print('The dealer shows a ' + str(number_d2[0]) + ' for a total of ' + str(d_total))
- time.sleep(2)
- d_cards = [number_d1[0], number_d2[0]]
- while d_total < 17:
- if total == 21 and len(your_cards) == 2:
- break
- num = choose_card() # Layout: [card, value]
- d_total += num[1]
- d_cards.append(num[0])
- if d_total > 21 and ('Ace' in d_cards):
- d_total += -10
- d_cards.remove('Ace')
- print('The dealer deals a ' + str(num[0]) + ' for a total of ' + str(d_total))
- time.sleep(1)
- if d_total > 21:
- print('Dealer is bust')
- d_total = 0
- time.sleep(1)
- print('')
- if total == 21 and len(your_cards) == 2:
- money += 2.5 *bet_1
- print('Natural Blackjack, you now have $' + str(money))
- elif total > d_total:
- money += 2*bet_1
- print('Well done, you now have $' + str(money))
- elif total == d_total:
- money += bet_1
- print('Push, you now have $' + str(money))
- else:
- print('Too bad, you now have $' + str(money))
- time.sleep(1)
- return money
- def hit(money, number_1, number_2, your_cards, number_d1, number_d2, d_cards, total, d_total, bet_1):
- time.sleep(1)
- while total < 21:
- num = choose_card() # Layout: [card, value]
- total += num[1]
- your_cards.append(num[0])
- if total > 21 and ('Ace' in your_cards):
- total += -10
- your_cards.remove('Ace')
- print('You receive a ' + str(num[0]) + ' for a total of ' + str(total))
- print('')
- time.sleep(1)
- if total > 21:
- print('Bust')
- time.sleep(1)
- print('Too bad, you now have $' + str(money))
- break
- elif total == 21:
- money = stand\
- (money, number_1, number_2, your_cards, number_d1, number_d2, d_cards, total, d_total, bet_1)
- break
- reaction = ''
- while reaction != 'HIT' and reaction != 'STAND':
- reaction = input('What would you like to do? (Hit/Stand): ').upper()
- time.sleep(1)
- if reaction == 'STAND':
- money = stand\
- (money, number_1, number_2, your_cards, number_d1, number_d2, d_cards, total, d_total, bet_1)
- print('')
- break
- return money
- '''Blackjack end'''
- '''Roulette start'''
- def roulette(money):
- print('')
- print('You approach the nearest wheel and watch the ball as it \
- is released and prepare your bet')
- print('Money: $' + str(money))
- bet_1 = bet(money)
- money += -1*bet_1
- print('')
- reaction = ''
- time.sleep(1)
- while (reaction not in map(str, range(37))) and reaction != 'RED' and reaction != 'BLACK' \
- and reaction != 'EVEN' and reaction != 'ODD':
- reaction = input('What would you like to bet on? \
- (Red, Black, Even, Odd, #): ').upper()
- spin_result = random.randint(0, 36)
- if spin_result%2 == 0 and spin_result != 0:
- even_odd = 'EVEN'
- colour = 'RED'
- elif spin_result != 0 and spin_result != 0:
- even_odd = 'ODD'
- colour = 'BLACK'
- else:
- even_odd = ''
- colour = 'GREEN'
- time.sleep(2)
- print("The ball comes to a stop on " + str(colour) + ' ' + str(spin_result))
- time.sleep(1)
- if reaction == str(spin_result):
- money += 36*bet_1
- print('Congrats, huge pay out! You now have $' + str(money))
- elif reaction == colour:
- money += 2*bet_1
- print('Well done, you now have $' + str(money))
- elif reaction == even_odd:
- money += 2*bet_1
- print('Well done, you now have $' + str(money))
- else:
- print('Too bad, you now have $' + str(money))
- time.sleep(2)
- is_bankrupt = check_bankrupt(money)
- if is_bankrupt:
- return money
- print('')
- answer = ''
- while answer != 'YES' and answer != 'Y' and answer != 'NO' and answer != 'N':
- answer = input('Play again? (Yes or No): ').upper()
- time.sleep(1)
- if answer == 'YES' or answer == 'Y':
- roulette(money)
- elif answer == 'NO' or answer == 'N':
- choice(money)
- '''Roulette end'''
- '''Slots start'''
- def slots(money, balance):
- print('')
- time.sleep(1)
- print('''Payout table
- 7\t7\t7\t\tpays Jackpot
- Bar\tBar\tBar\t\tpays 250x
- Star\tStar\tStar/Bar\tpays 20x
- Apple\tApple\tApple/Bar\tpays 14x
- Orange\tOrange\tOrange/Bar\tpays 10x
- Cherry\tCherry\tCherry\t\tpays 7x
- Cherry\tCherry\t -\t\tpays 5x
- Cherry\t -\t -\t\tpays 2x
- ''')
- if balance < 0:
- balance = 0
- print('Jackpot: $' + str(balance))
- print('')
- time.sleep(2)
- print('Money: $' + str(money))
- time.sleep(1)
- bet_1 = bet(money)
- while bet_1 <=0 or bet_1 > money:
- bet_1 = input('How much would you like to bet?: ')
- first_spin = slot_spin()
- second_spin = slot_spin()
- third_spin = slot_spin()
- print('')
- print('The slots begin to spin')
- time.sleep(2)
- print(first_spin + '\t' + second_spin + '\t' + third_spin)
- money = slot_payout(money, first_spin, second_spin, third_spin, bet_1, balance)
- def slot_payout(money, first_spin, second_spin, third_spin, bet_1, balance):
- if((first_spin == "CHERRY") and (second_spin != "CHERRY")):
- win = 2*bet_1
- balance = balance - 2*bet_1
- elif((first_spin == "CHERRY") and (second_spin == "CHERRY") and (third_spin != "CHERRY")):
- win = 5*bet_1
- balance = balance - 5*bet_1
- elif((first_spin == "CHERRY") and (second_spin == "CHERRY") and (third_spin == "CHERRY")):
- win = 7*bet_1
- balance = balance - 7*bet_1
- elif((first_spin == "ORANGE") and (second_spin == "ORANGE") and ((third_spin == "ORANGE") or (third_spin == "BAR"))):
- win = 10*bet_1
- balance = balance - 10*bet_1
- elif((first_spin == "APPLE") and (second_spin == "APPLE") and ((third_spin == "APPLE") or (third_spin == "BAR"))):
- win = 14*bet_1
- balance = balance - 14*bet_1
- elif((first_spin == "STAR") and (second_spin == "STAR") and ((third_spin == "STAR") or (third_spin == "BAR"))):
- win = 20*bet_1
- balance = balance - 20*bet_1
- elif((first_spin == "BAR") and (second_spin == "BAR") and (third_spin == "BAR")):
- win = 250*bet_1
- balance = balance - 250*bet_1
- elif((first_spin == "7") and (second_spin == "7") and (third_spin == "7")):
- win = balance
- balance = balance - win
- else:
- win = -1 * bet_1
- balance += bet_1
- print('')
- money += win
- if win == balance:
- print ("JACKPOT!")
- if(win > 0):
- print('You win $' + str(win))
- time.sleep(1)
- print('You now have $' + str(money))
- time.sleep(2)
- else:
- print('You lose, you now have $' + str(money))
- time.sleep(2)
- print('')
- is_bankrupt = check_bankrupt(money)
- if is_bankrupt:
- return money
- answer = ''
- while answer != 'YES' and answer != 'Y' and answer != 'NO' and answer != 'N':
- answer = input('Play again? (Yes or No): ').upper()
- time.sleep(1)
- if answer == 'YES' or answer == 'Y':
- slots(money, balance)
- elif answer == 'NO' or answer == 'N':
- choice(money)
- def slot_spin():
- rand_num = random.randint(0, 6)
- ITEMS = ["CHERRY", "LEMON", "ORANGE", "APPLE", "STAR", "BAR", "7"]
- return ITEMS[rand_num]
- '''Slots end'''
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement