SHARE
TWEET

Untitled

a guest Aug 20th, 2019 86 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #name: William Herewini
  2. #date: 28/08/18
  3.  
  4. import random
  5. import time
  6. import os
  7.  
  8. balance = 1000
  9.  
  10. print("\n"*20)
  11.  
  12. def main():
  13.     money = difficulty()
  14.    
  15.     char_name()
  16.     choice(money)
  17.     print('The End')
  18.     return
  19.  
  20. def difficulty():
  21.     difficulty = ''
  22.     while (difficulty != 'EASY') and (difficulty != 'HARD') and (difficulty != 'EZ'):
  23.         difficulty = input('Easy or Hard?: ').upper()
  24.     time.sleep(1)
  25.     if difficulty == 'EASY':
  26.         money = 500
  27.         print('Money: $500')
  28.     elif difficulty == 'HARD':
  29.         money = 250
  30.         print('Money: $250')
  31.     print('')
  32.     return money
  33.  
  34.  
  35. def intro_scene():
  36.     time.sleep(1)
  37.     print('A bright spotlight shines down upon you, blinding...')
  38.     time.sleep(3)
  39.     print('The rotors of the helicopters, deafening...')
  40.     time.sleep(3)
  41.     print('The wails of the encroaching sirens, piercing...')
  42.     time.sleep(3)
  43.     print('How did you get here you ask?\n')
  44.     time.sleep(3)
  45.     return
  46.  
  47.  
  48. def char_name():
  49.     name = input("What's your name?: ").upper()
  50.     value = random.randint(1, 3)
  51.     time.sleep(1)
  52.     if name == 'TAMARA':
  53.         name = 'Slampa'
  54.         print('Hi Slampa.\n')
  55.     elif value == 1:
  56.         name = name.title()
  57.         print('What kind of name is ' + str(name) + '?')
  58.         time.sleep(1)
  59.         print('Alright then. \n')
  60.     elif value == 2:
  61.         name = name.title()
  62.         print('What a pretty name.\n')
  63.     else:
  64.         name = name.title()
  65.         print('Interesting...\n')
  66.     time.sleep(2)
  67.     print('It began at the casino, where many problematic nights do.')
  68.     time.sleep(2)
  69.     return name
  70.  
  71.  
  72. def choice(money):
  73.     answer = ''
  74.     while answer != 'BLACKJACK' and answer != 'ROULETTE' and answer != 'SLOTS':
  75.         answer = input\
  76.             ('What would you like play? (Blackjack, Roulette, Slots): ').upper()
  77.         time.sleep(1)
  78.     if answer == 'BLACKJACK':
  79.         blackjack(money)
  80.     elif answer == 'ROULETTE':
  81.         roulette(money)
  82.     elif answer == 'SLOTS':
  83.         slots(money, balance)
  84.     return
  85.  
  86. '''Intro end'''
  87.  
  88. def bet(money):
  89.     bet_1 = 0
  90.     while True:
  91.         try:
  92.             while bet_1 <= 0 or bet_1 > money:
  93.                 bet_1 = int(input('How much would you like to bet?: $'))
  94.             break
  95.         except:
  96.             print('That is not an option')
  97.             time.sleep(1)
  98.     if bet_1 <= 0 or bet_1 > money:
  99.         bet(money)
  100.     else:
  101.         return bet_1
  102.  
  103. def check_bankrupt(money):
  104.     if money <= 1:
  105.         print('')
  106.         time.sleep(1)
  107.         print('\t-=Money: $0=-')
  108.         time.sleep(1)
  109.         print('You are bankrupt, how unfortunate')
  110.         print('')
  111.         is_bankrupt = True
  112.         return is_bankrupt
  113.     else:
  114.         is_bankrupt = False
  115.         return is_bankrupt
  116.  
  117. '''Blackjack start'''
  118.  
  119. def blackjack(money):
  120.     print('')
  121.     print('You sit at the nearest table and prepare a bet')
  122.     print('Money: $' + str(money))
  123.     time.sleep(1)
  124.     bet_1 = bet(money)
  125.     print('')
  126.     money = money - bet_1
  127.     time.sleep(1)
  128.     number_1 = choose_card() # Layout: [card, value]
  129.     number_2 = choose_card() # Layout: [card, value]
  130.    
  131.     your_cards = [number_1[0], number_2[0]]
  132.    
  133.     total = number_1[1] + number_2[1]
  134.        
  135.     print('Your cards are ' + str(number_1[0]) + ' and ' + str(number_2[0]) + \
  136.           " for a total of " + str(total))
  137.    
  138.     number_d1 = choose_card() # Layout: [card, value]
  139.     number_d2 = choose_card() # Layout: [card, value]
  140.    
  141.     d_total = number_d1[1] + number_d2[1]    
  142.    
  143.     d_cards = [number_d1[0], number_d2[0]]
  144.    
  145.     time.sleep(2)
  146.     print("The dealer's face-up card is " + str(number_d1[0]))
  147.     print('')
  148.     time.sleep(2)
  149.     if total == 21 and len(your_cards) == 2 and d_total == 21 and len(d_cards) == 2:
  150.         money += bet
  151.         print('The dealer shows a ' + str(number_d2[0]) + ' for a total of ' + str(d_total))
  152.         time.sleep(1)
  153.         print('Push, you now have $' + str(money))
  154.         is_bankrupt = check_bankrupt(money)
  155.         if is_bankrupt:
  156.             return money        
  157.         time.sleep(2)
  158.         answer = ''
  159.         while answer != 'YES' and answer != 'Y' and answer != 'NO' and answer != 'N':
  160.             answer = input('Play again? (Yes or No): ').upper()
  161.         time.sleep(1)
  162.         if answer == 'YES' or answer == 'Y':
  163.             blackjack(money)
  164.         elif answer == 'NO' or answer == 'N':
  165.             choice(money)        
  166.        
  167.     if d_total == 21 and len(d_cards) == 2:
  168.         print('The dealer shows a ' + str(number_d2[0]) + ' for a total of ' + str(d_total))
  169.         time.sleep(1)
  170.         print('Too bad, you now have $' + str(money))
  171.         is_bankrupt = check_bankrupt(money)
  172.         if is_bankrupt:
  173.             return money        
  174.         time.sleep(1)
  175.         answer = ''
  176.         while answer != 'YES' and answer != 'Y' and answer != 'NO' and answer != 'N':
  177.             answer = input('Play again? (Yes or No): ').upper()
  178.         time.sleep(1)
  179.         if answer == 'YES' or answer == 'Y':
  180.             blackjack(money)
  181.         elif answer == 'NO' or answer == 'N':
  182.             choice(money)        
  183.    
  184.     if total == 21 and len(your_cards) == 2:
  185.         money = stand\
  186.             (money, number_1, number_2, your_cards, number_d1, number_d2, d_cards, total,  d_total, bet_1)
  187.         is_bankrupt = check_bankrupt(money)
  188.         if is_bankrupt:
  189.             return money        
  190.         answer = ''
  191.         while answer != 'YES' and answer != 'Y' and answer != 'NO' and answer != 'N':
  192.             answer = input('Play again? (Yes or No): ').upper()
  193.         time.sleep(1)
  194.         if answer == 'YES' or answer == 'Y':
  195.             blackjack(money)
  196.         elif answer == 'NO' or answer == 'N':
  197.             choice(money)
  198.            
  199.     reaction = ''
  200.     while reaction != 'HIT' and reaction != 'STAND':
  201.         reaction = input('What would you like to do? (Hit/Stand): ').upper()
  202.        
  203.     if reaction == 'STAND':
  204.         money = stand\
  205.             (money, number_1, number_2, your_cards, number_d1, number_d2, d_cards, total,  d_total, bet_1)
  206.     elif reaction == 'HIT':
  207.         money = hit\
  208.             (money, number_1, number_2, your_cards, number_d1, number_d2, d_cards, total,  d_total, bet_1)
  209.     is_bankrupt = check_bankrupt(money)
  210.     if is_bankrupt:
  211.         return money    
  212.     print('')
  213.     time.sleep(2)
  214.     answer = ''
  215.     while answer != 'YES' and answer != 'Y' and answer != 'NO' and answer != 'N':
  216.         answer = input('Play again? (Yes or No): ').upper()
  217.     time.sleep(1)
  218.     if answer == 'YES' or answer == 'Y':
  219.         blackjack(money)
  220.     elif answer == 'NO' or answer == 'N':
  221.         choice(money)
  222.     return money
  223.  
  224.  
  225. def choose_card():
  226.     number_1 = random.randint(1,13)
  227.     num_1_value = 10
  228.     if number_1 == 11:
  229.         number_1 = 'Jack'
  230.     elif number_1 == 12:
  231.         number_1 = 'Queen'
  232.     elif number_1 == 13:
  233.         number_1 = 'King'
  234.     elif number_1 == 1:
  235.         number_1 = 'Ace'
  236.         num_1_value = 11
  237.     else:
  238.         num_1_value = number_1
  239.     return [number_1, num_1_value]
  240.  
  241.  
  242. def stand(money, number_1, number_2, your_cards, number_d1, number_d2, d_cards, total,  d_total, bet_1):
  243.     time.sleep(1)
  244.     print('The dealer shows a ' + str(number_d2[0]) + ' for a total of ' + str(d_total))
  245.     time.sleep(2)
  246.    
  247.     d_cards = [number_d1[0], number_d2[0]]
  248.    
  249.     while d_total < 17:
  250.         if total == 21 and len(your_cards) == 2:
  251.             break
  252.         num = choose_card() # Layout: [card, value]
  253.         d_total += num[1]
  254.         d_cards.append(num[0])
  255.         if d_total > 21 and ('Ace' in d_cards):
  256.             d_total += -10
  257.             d_cards.remove('Ace')
  258.         print('The dealer deals a ' + str(num[0]) + ' for a total of ' + str(d_total))
  259.         time.sleep(1)
  260.     if d_total > 21:
  261.         print('Dealer is bust')
  262.         d_total = 0
  263.         time.sleep(1)
  264.     print('')      
  265.     if total == 21 and len(your_cards) == 2:
  266.         money += 2.5 *bet_1
  267.         print('Natural Blackjack, you now have $' + str(money))        
  268.     elif total > d_total:
  269.         money += 2*bet_1
  270.         print('Well done, you now have $' + str(money))
  271.     elif total == d_total:
  272.         money += bet_1
  273.         print('Push, you now have $' + str(money))
  274.     else:
  275.         print('Too bad, you now have $' + str(money))
  276.     time.sleep(1)
  277.     return money
  278.  
  279.  
  280. def hit(money, number_1, number_2, your_cards, number_d1, number_d2, d_cards, total,  d_total, bet_1):
  281.     time.sleep(1)
  282.     while total < 21:
  283.         num = choose_card() # Layout: [card, value]
  284.         total += num[1]
  285.         your_cards.append(num[0])
  286.         if total > 21 and ('Ace' in your_cards):
  287.             total += -10
  288.             your_cards.remove('Ace')
  289.         print('You receive a ' + str(num[0]) + ' for a total of ' + str(total))
  290.         print('')
  291.         time.sleep(1)
  292.         if total > 21:
  293.             print('Bust')
  294.             time.sleep(1)
  295.             print('Too bad, you now have $' + str(money))
  296.             break
  297.         elif total == 21:
  298.             money = stand\
  299.                 (money, number_1, number_2, your_cards, number_d1, number_d2, d_cards, total,  d_total, bet_1)
  300.             break
  301.         reaction = ''
  302.         while reaction != 'HIT' and reaction != 'STAND':
  303.             reaction = input('What would you like to do? (Hit/Stand): ').upper()
  304.         time.sleep(1)
  305.         if reaction == 'STAND':
  306.             money = stand\
  307.                 (money, number_1, number_2, your_cards, number_d1, number_d2, d_cards, total,  d_total, bet_1)
  308.             print('')
  309.             break
  310.     return money
  311.  
  312. '''Blackjack end'''
  313.  
  314. '''Roulette start'''
  315.  
  316. def roulette(money):
  317.     print('')
  318.     print('You approach the nearest wheel and watch the ball as it \
  319. is released and prepare your bet')
  320.     print('Money: $' + str(money))
  321.     bet_1 = bet(money)
  322.     money += -1*bet_1
  323.     print('')
  324.     reaction = ''
  325.     time.sleep(1)
  326.     while (reaction not in map(str, range(37))) and reaction != 'RED' and reaction != 'BLACK' \
  327. and reaction != 'EVEN' and reaction != 'ODD':
  328.         reaction = input('What would you like to bet on? \
  329. (Red, Black, Even, Odd, #): ').upper()
  330.     spin_result = random.randint(0, 36)
  331.     if spin_result%2 == 0 and spin_result != 0:
  332.         even_odd = 'EVEN'
  333.         colour = 'RED'
  334.     elif spin_result != 0 and spin_result != 0:
  335.         even_odd = 'ODD'
  336.         colour = 'BLACK'
  337.     else:
  338.         even_odd = ''
  339.         colour = 'GREEN'
  340.        
  341.     time.sleep(2)
  342.     print("The ball comes to a stop on " + str(colour) + ' ' + str(spin_result))
  343.     time.sleep(1)
  344.    
  345.    
  346.     if reaction == str(spin_result):
  347.         money += 36*bet_1
  348.         print('Congrats, huge pay out! You now have $' + str(money))
  349.     elif reaction == colour:
  350.         money += 2*bet_1
  351.         print('Well done, you now have $' + str(money))
  352.     elif reaction == even_odd:
  353.         money += 2*bet_1
  354.         print('Well done, you now have $' + str(money))
  355.     else:
  356.         print('Too bad, you now have $' + str(money))
  357.     time.sleep(2)
  358.     is_bankrupt = check_bankrupt(money)
  359.     if is_bankrupt:
  360.         return money    
  361.     print('')
  362.     answer = ''
  363.     while answer != 'YES' and answer != 'Y' and answer != 'NO' and answer != 'N':
  364.         answer = input('Play again? (Yes or No): ').upper()
  365.     time.sleep(1)
  366.     if answer == 'YES' or answer == 'Y':
  367.         roulette(money)
  368.     elif answer == 'NO' or answer == 'N':
  369.         choice(money)    
  370.  
  371. '''Roulette end'''
  372.  
  373. '''Slots start'''
  374.  
  375. def slots(money, balance):
  376.     print('')
  377.     time.sleep(1)
  378.     print('''Payout table
  379. 7\t7\t7\t\tpays Jackpot
  380. Bar\tBar\tBar\t\tpays 250x
  381. Star\tStar\tStar/Bar\tpays 20x
  382. Apple\tApple\tApple/Bar\tpays 14x
  383. Orange\tOrange\tOrange/Bar\tpays 10x
  384. Cherry\tCherry\tCherry\t\tpays 7x
  385. Cherry\tCherry\t  -\t\tpays 5x
  386. Cherry\t  -\t  -\t\tpays 2x
  387. ''')
  388.     if balance < 0:
  389.         balance = 0
  390.     print('Jackpot: $' + str(balance))
  391.     print('')
  392.     time.sleep(2)
  393.     print('Money: $' + str(money))
  394.     time.sleep(1)
  395.     bet_1 = bet(money)
  396.     while bet_1 <=0 or bet_1 > money:
  397.         bet_1 = input('How much would you like to bet?: ')
  398.     first_spin = slot_spin()
  399.     second_spin = slot_spin()
  400.     third_spin = slot_spin()
  401.     print('')
  402.     print('The slots begin to spin')
  403.     time.sleep(2)
  404.     print(first_spin + '\t' + second_spin + '\t' + third_spin)
  405.     money = slot_payout(money, first_spin, second_spin, third_spin, bet_1, balance)
  406.  
  407. def slot_payout(money, first_spin, second_spin, third_spin, bet_1, balance):
  408.     if((first_spin == "CHERRY") and (second_spin != "CHERRY")):
  409.         win = 2*bet_1
  410.         balance = balance - 2*bet_1
  411.     elif((first_spin == "CHERRY") and (second_spin == "CHERRY") and (third_spin != "CHERRY")):
  412.         win = 5*bet_1
  413.         balance = balance - 5*bet_1
  414.     elif((first_spin == "CHERRY") and (second_spin == "CHERRY") and (third_spin == "CHERRY")):
  415.         win = 7*bet_1
  416.         balance = balance - 7*bet_1
  417.     elif((first_spin == "ORANGE") and (second_spin == "ORANGE") and ((third_spin == "ORANGE") or (third_spin == "BAR"))):
  418.         win = 10*bet_1
  419.         balance = balance - 10*bet_1
  420.     elif((first_spin == "APPLE") and (second_spin == "APPLE") and ((third_spin == "APPLE") or (third_spin == "BAR"))):
  421.         win = 14*bet_1
  422.         balance = balance - 14*bet_1
  423.     elif((first_spin == "STAR") and (second_spin == "STAR") and ((third_spin == "STAR") or (third_spin == "BAR"))):
  424.         win = 20*bet_1
  425.         balance = balance - 20*bet_1
  426.     elif((first_spin == "BAR") and (second_spin == "BAR") and (third_spin == "BAR")):
  427.         win = 250*bet_1
  428.         balance = balance - 250*bet_1
  429.     elif((first_spin == "7") and (second_spin == "7") and (third_spin == "7")):
  430.         win = balance
  431.         balance = balance - win
  432.     else:
  433.         win = -1 * bet_1
  434.         balance += bet_1
  435.     print('')
  436.     money += win
  437.     if win == balance:
  438.         print ("JACKPOT!")
  439.     if(win > 0):
  440.         print('You win $' + str(win))
  441.         time.sleep(1)
  442.         print('You now have $' + str(money))
  443.         time.sleep(2)
  444.     else:
  445.         print('You lose, you now have $' + str(money))
  446.         time.sleep(2)
  447.         print('')
  448.     is_bankrupt = check_bankrupt(money)
  449.     if is_bankrupt:
  450.         return money    
  451.     answer = ''
  452.     while answer != 'YES' and answer != 'Y' and answer != 'NO' and answer != 'N':
  453.         answer = input('Play again? (Yes or No): ').upper()
  454.     time.sleep(1)
  455.     if answer == 'YES' or answer == 'Y':
  456.         slots(money, balance)
  457.     elif answer == 'NO' or answer == 'N':
  458.         choice(money)        
  459.  
  460.  
  461. def slot_spin():
  462.     rand_num = random.randint(0, 6)
  463.     ITEMS = ["CHERRY", "LEMON", "ORANGE", "APPLE", "STAR", "BAR", "7"]
  464.     return ITEMS[rand_num]
  465.  
  466. '''Slots end'''
  467.  
  468. main()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top