dougbaker45

roulette

Jun 11th, 2019
495
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 6.21 KB | None | 0 0
  1. import random
  2. players = {}
  3. betlocation = None
  4. spinbet = 0
  5. r_black = [2, 4, 6, 8, 10, 11, 13, 15, 17, 20, 22, 24, 26, 28, 29, 31, 33, 35]
  6. r_red = [1, 3, 5, 7, 9, 12, 14, 16, 18, 19, 21, 23, 25, 27, 30, 32, 34, 36]
  7. r_low = list(range(1, 18))
  8. r_high = list(range(19, 36))
  9. r_even = [2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36]
  10. r_odd = [1, 3, 5, 7, 9, 11, 13, 15, 17, 19, 21, 23, 25, 27, 29, 31, 33, 35]
  11. r_firstdozen = list(range(1, 12))
  12. r_seconddozen = list(range(13, 24))
  13. r_thirddozen = list(range(25, 36 ))
  14. r_firstcolumn = [1, 4, 7, 10, 13, 16, 19, 22, 25, 28, 31, 34]
  15. r_secondcolumn = [2, 5, 8, 11, 14, 17, 20, 23, 26, 29, 32, 35]
  16. r_thirdcolumn  = [3, 6, 9, 12, 15, 18, 21, 24, 27, 30, 33, 36]
  17. result = None
  18. r_number = result
  19. numl = []
  20. str_range = list(range(-1,37))
  21. r_range = range(-1, 36)
  22. r_list = ['black', 'red', 'low', 'high', 'even', 'odd', 'first dozen', 'second dozen', 'third dozen', 'first column', 'second column', 'third column', str_range,]
  23. pots = 1
  24. def inputplayers():
  25.     playername = None
  26.     while playername != '':
  27.         playername = str(input('Player Name? : '))
  28.         if playername != '':
  29.             players[playername] = 500
  30. def checkup():
  31.     global pots
  32.     for key in players:
  33.         print('Current Pot for', key, ':',  players[key])
  34.     pots = sum(players.values())
  35. def checkpots():
  36.     global pots
  37.     pots = sum(players.values())
  38. def check():
  39.     global result
  40.     global betlocation
  41.     global spinbet
  42.     if betlocation is black:
  43.         if result in r_black:
  44.             spinbet = spinbet * 2
  45. def spin():
  46.     global result
  47.     result = random.randint(-1, 36)
  48. def bet():
  49.     global r_list
  50.     global pots
  51.     global spinbet
  52.     global players
  53.     global s_bet
  54.     for key in players:
  55.         betlocation = None
  56.         maxbet = players[key]
  57.         while betlocation != '':
  58.             if maxbet <= 0:
  59.                 betlocation = ''
  60.                 continue
  61.             betlocation = str(input('\nType help for list of bets.\n' + 'What bet would you like, ' + key + '? : ')).lower()
  62.             if betlocation == 'help':
  63.                 print('Possible bets are :' , r_list)
  64.                 continue
  65.             if betlocation not in r_list and betlocation not in str(str_range):
  66.                 print('Invalid bet!')
  67.                 continue
  68.             if betlocation != '':
  69.                 print('\nmax bet for ', key, ' is : ', maxbet)
  70.                 spinbet = input('How Much would you like to bet? : ')
  71.                 try:
  72.                     spinbet = int(spinbet)
  73.                 except:
  74.                     print('Invalid Bet')
  75.                     continue
  76.                 if spinbet > maxbet:
  77.                     print('That bet is too large!')
  78.                     continue
  79.                 players[key] -= spinbet
  80.                 maxbet -= spinbet
  81.                 if betlocation == 'black':
  82.                     if result in r_black:
  83.                         spinbet = spinbet * 2
  84.                     else:
  85.                         spinbet = 0
  86.                     players[key] += spinbet
  87.                 if betlocation == 'red':
  88.                     if result in r_red:
  89.                         spinbet = spinbet * 2
  90.                     else:
  91.                         spinbet = 0
  92.                     players[key] += spinbet
  93.                 if betlocation == 'low':
  94.                     if result in r_low:
  95.                         spinbet = spinbet * 2
  96.                     else:
  97.                         spinbet = 0
  98.                     players[key] += spinbet
  99.                 if betlocation == 'high':
  100.                     if result in r_high:
  101.                         spinbet = spinbet * 2
  102.                     else:
  103.                         spinbet = 0
  104.                     players[key] += spinbet
  105.                 if betlocation == 'odd':
  106.                     if result in r_odd:
  107.                         spinbet = spinbet * 2
  108.                     else:
  109.                         spinbet = 0
  110.                     players[key] += spinbet
  111.                 if betlocation == 'even':
  112.                     if result in r_even:
  113.                         spinbet = spinbet * 2
  114.                     else:
  115.                         spinbet = 0
  116.                     players[key] += spinbet
  117.                 if betlocation == 'first dozen':
  118.                     if result in r_firstdozen:
  119.                         spinbet = spinbet * 3
  120.                     else:
  121.                         spinbet = 0
  122.                     players[key] += spinbet
  123.                 if betlocation == 'second dozen':
  124.                     if result in r_seconddozen:
  125.                         spinbet = spinbet * 3
  126.                     else:
  127.                         spinbet = 0
  128.                     players[key] += spinbet
  129.                 if betlocation == 'third dozen':
  130.                     if result in r_thirddozen:
  131.                         spinbet = spinbet * 3
  132.                     else:
  133.                         spinbet = 0
  134.                     players[key] += spinbet
  135.                 if betlocation == 'first column':
  136.                     if result in r_firstcolumn:
  137.                         spinbet = spinbet * 3
  138.                     else:
  139.                         spinbet = 0
  140.                     players[key] += spinbet
  141.                 if betlocation == 'second column':
  142.                     if result in r_secondcolumn:
  143.                         spinbet = spinbet * 3
  144.                     else:
  145.                         spinbet = 0
  146.                     players[key] += spinbet
  147.                 if betlocation == 'third column':
  148.                     if result in r_thirdcolumn:
  149.                         spinbet = spinbet * 3
  150.                     else:
  151.                         spinbet = 0
  152.                     players[key] += spinbet
  153.                 if betlocation in str(r_range):
  154.                     if str(result) == betlocation:
  155.                         spinbet = spinbet * 36
  156.                     else:
  157.                         spinbet = 0
  158.                     players[key] += spinbet
  159.  
  160. print ('Welcome to Roulette!\nPress enter when done!')
  161. inputplayers()
  162. while pots > 0:
  163.     checkup()
  164.     spin()
  165.     bet()
  166.     print('\nThe ball lands on :', result)
  167.     checkpots()
  168. print('Game Over, Thanks for playing!')
Add Comment
Please, Sign In to add comment