lil_blizzard

Untitled

Jul 30th, 2019
68
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.95 KB | None | 0 0
  1. import random
  2.  
  3. #beginning balance
  4. balance = 5
  5.  
  6. playerScore = 0
  7. playerRoll = [0,0,0]
  8.  
  9. response = input('Are you ready to play ceelo?: ')
  10.  
  11. if response=='yes' or response=='y':
  12.     print('You have $' + str(balance))
  13.  
  14. #runs while this condition is true & until it is broken by 'break'
  15. while True:
  16.  
  17.     bet = input('Enter your bet: ')
  18.  
  19.     #try loop is accounting for ValueError - in case the user inputs something besides a number
  20.     try:
  21.         if int(bet) <= 5:
  22.             print('Your bet is $' + str(bet))
  23.             balance-=int(bet)
  24.             break
  25.         elif int(bet) < 1:
  26.             print('You have to bet something!')
  27.         else:
  28.             print("You can't bet that much.")
  29.     except ValueError:
  30.         print('Enter a number please.')
  31.  
  32. print('You have $' + str(balance) + ' left')
  33.  
  34. #dice roll function
  35. def RollDice():
  36.     roll = [random.randint(1,6) for _ in range(3)]
  37.     roll.sort()
  38.     return roll
  39.  
  40. #analyze the roll list
  41. def AnalyzeRoll(inputRoll):
  42.     while True:
  43.         if (inputRoll[2] == 6 and inputRoll[0] == inputRoll[1]) or inputRoll == [4,5,6]:
  44.             print('Congrats! You take everything.')
  45.             break
  46.             #auto lose
  47.         elif (inputRoll[0] == 1 and inputRoll[1] == inputRoll[2]) or inputRoll == [1,2,3]:
  48.             print('Oops! You lose everything.')
  49.             break
  50.             #set point value
  51.         else:
  52.             if inputRoll[0] == inputRoll[1]:
  53.                 playerScore = inputRoll[2]
  54.             else:
  55.                 playerScore = inputRoll[0]
  56.                 print("Your score is: " + str(playerScore))
  57.                 break
  58.  
  59. #assinging our roll to our global playerRoll variable
  60. #only break out of this loop when we have a valid roll
  61. while True:
  62.     playerRoll = RollDice()
  63.     print(playerRoll)
  64.     if playerRoll[0]==playerRoll[1] or playerRoll[1]==playerRoll[2]:
  65.         break
  66.     else:
  67.         playerRoll = RollDice()
  68.  
  69. AnalyzeRoll(playerRoll)
Add Comment
Please, Sign In to add comment