Advertisement
asweigart

Refactored Russian Roulette

Apr 17th, 2019
582
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.99 KB | None | 0 0
  1. import time, random
  2.  
  3. dieMessage = ['You DIED! Thank goodness!', 'Good riddance.', 'My Condolences. You failed.', 'I will tell your parents that you died with honor.', 'I will tell your parents that you died for nothing.', 'Will somebody clean this up?']
  4. surviveMessage = ['YEEEHAW! I ain\'t gon die today!', 'Thank heavens! You didn\'t get your brains blown out!', 'You have not died... YET.', 'This is getting intense.', 'Dang.', 'Maybe next time...']
  5.  
  6.  
  7. while True:
  8. # Display the welcome message:
  9. print('Welcome to Russian Roulette!')
  10. time.sleep(2)
  11.  
  12. while True:
  13. peopleCount = int(input('How many people are playing? (2-6): '))
  14. if 2 <= peopleCount <= 6:
  15. break
  16. # This code runs if the player entered a number not in between 2 and 6:
  17. print('You must have at least 2 people and at most 6 people to play!')
  18. time.sleep(2)
  19.  
  20. print('Please state your friends names, one at a time')
  21. choosePerson = []
  22. for i in range(peopleCount):
  23. name = input(f'Person #{i + 1}: ')
  24. choosePerson.append(name)
  25.  
  26. print(f'Welcome, {", ".join(choosePerson[:-1])} , and {choosePerson[-1]}!')
  27. choosePersonNum = random.randint(0, peopleCount - 1)
  28.  
  29. # Play the game:
  30. for i in range(6):
  31. if i == 0:
  32. print('Ok! Let\'s begin!')
  33. time.sleep(2)
  34. print('It\'s ' + choosePerson[choosePersonNum] + 's turn')
  35. time.sleep(2)
  36.  
  37. number = random.randint(0, 5 - i)
  38. if number == 0:
  39. print('BAM!')
  40. time.sleep(2)
  41. print(random.choice(dieMessage))
  42. time.sleep(4)
  43. break
  44. else:
  45. print('click.')
  46. time.sleep(2)
  47. print(random.choice(surviveMessage))
  48. time.sleep(4)
  49. choosePersonNum = (choosePersonNum + 1) % peopleCount
  50.  
  51. print('Would you like to play again?')
  52. playAgain = input().upper()
  53. if not (playAgain in ('YES', 'Y')):
  54. break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement