Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
146
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.82 KB | None | 0 0
  1. import time
  2. import random
  3.  
  4.  
  5.  
  6. #login validation -- working
  7.  
  8. loggedin1 = 0
  9. loggedin2 = 0
  10. while loggedin1 != 1:
  11. username1 = input('Enter username:')
  12. password1 = input('Enter password:')
  13.  
  14. if username1 == 'username1' and password1 == 'password':
  15. loggedin1 = loggedin1 + 1
  16. time.sleep(1)
  17. print('Login successful!')
  18. else:
  19. time.sleep(1)
  20. print('Incorrect username or password, please try again.')
  21.  
  22.  
  23. while loggedin2 != 1:
  24. username2 = input('Enter player2 username:')
  25. password2 = input('Enter player2 password:')
  26.  
  27. if username2 == 'username2' and password1 == 'password':
  28. loggedin2 = loggedin2 + 1
  29. time.sleep(1)
  30. print('Login successful!')
  31. else:
  32. time.sleep(1)
  33. print('Incorrect username or password, please try again.')
  34.  
  35.  
  36.  
  37. #dice game
  38. round1 = 0
  39. score1 = 0
  40. score2 = 0
  41. total1 = 0
  42. total2 = 0
  43. player1 = 0
  44. player2 = 0
  45.  
  46.  
  47. for x in range(0,5): #loops game 5 times
  48. #player 1
  49. die1 = random.randint(1,6)
  50. die2 = random.randint(1,6)
  51. total1 = die1 + die2
  52. round1 = round1 + 1
  53.  
  54. time.sleep(1.2)
  55.  
  56. if total1 % 2 == 0: #check if odd or even
  57. total1 = total1+10
  58. score1 = score1+total1
  59. print('Round' +str(round1) + ': ' + username1+'s' + ' total is ' + str(total1))
  60. else:
  61. total1 = total1 - 5
  62. print('Round' +str(round1) + ': ' + username1+'s' + ' total is ' + str(total1))
  63. score1 = score1+total1
  64. if die1 == die2:
  65. total1= total1 + random.randint(1,6) #3rd dice is roll a double
  66. print(total1)
  67. score1 = score1+total1
  68. elif total1 < 0: #makes total 0 instead of negative -- not working
  69. total1 == 0
  70. score1 = score1 + total1
  71. print('Your total score is ' + str(score1))
  72.  
  73.  
  74.  
  75.  
  76.  
  77. round1 = 0
  78.  
  79. #player2
  80. for x in range(0,5):
  81. die1 = random.randint(1,6)
  82. die2 = random.randint(1,6)
  83. total2 = die1 + die2
  84. round1 = round1 + 1
  85.  
  86. time.sleep(1.2)
  87.  
  88. if total2 % 2 == 0: #check if odd or even
  89. total2 = total2+10
  90. print('Round' +str(round1) + ': Your total is ' + str(total2))
  91. score2 = score2+total2
  92. else:
  93. total2 = total2 - 5
  94. print('Round' +str(round1) + ': Your total is ' + str(total2))
  95. score2 = score2+total2
  96. if die1 == die2:
  97. total2= total2 + random.randint(1,6) #3rd dice is roll a double
  98. print(total2)
  99. score2 = score2+total2
  100. elif total2 < 0: #makes total 0 instead of negative
  101. total2 == 0
  102. score2 = score2 + total2
  103. print('Your total score is ' + str(score2)) #problem here
  104.  
  105. '''
  106. #works out and declares the winner
  107. if score1 > score2:
  108. print(username1 + ' has won!')
  109. elif score1 < score2:
  110. print(username2 + ' has won!')
  111.  
  112. #tiebreak
  113.  
  114. '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement