Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import time
- import random
- #login validation -- working
- loggedin1 = 0
- loggedin2 = 0
- while loggedin1 != 1:
- username1 = input('Enter username:')
- password1 = input('Enter password:')
- if username1 == 'username1' and password1 == 'password':
- loggedin1 = loggedin1 + 1
- time.sleep(1)
- print('Login successful!')
- else:
- time.sleep(1)
- print('Incorrect username or password, please try again.')
- while loggedin2 != 1:
- username2 = input('Enter player2 username:')
- password2 = input('Enter player2 password:')
- if username2 == 'username2' and password1 == 'password':
- loggedin2 = loggedin2 + 1
- time.sleep(1)
- print('Login successful!')
- else:
- time.sleep(1)
- print('Incorrect username or password, please try again.')
- #dice game
- round1 = 0
- score1 = 0
- score2 = 0
- total1 = 0
- total2 = 0
- player1 = 0
- player2 = 0
- for x in range(0,5): #loops game 5 times
- #player 1
- die1 = random.randint(1,6)
- die2 = random.randint(1,6)
- total1 = die1 + die2
- round1 = round1 + 1
- time.sleep(1.2)
- if total1 % 2 == 0: #check if odd or even
- total1 = total1+10
- score1 = score1+total1
- print('Round' +str(round1) + ': ' + username1+'s' + ' total is ' + str(total1))
- else:
- total1 = total1 - 5
- print('Round' +str(round1) + ': ' + username1+'s' + ' total is ' + str(total1))
- score1 = score1+total1
- if die1 == die2:
- total1= total1 + random.randint(1,6) #3rd dice is roll a double
- print(total1)
- score1 = score1+total1
- elif total1 < 0: #makes total 0 instead of negative -- not working
- total1 == 0
- score1 = score1 + total1
- print('Your total score is ' + str(score1))
- round1 = 0
- #player2
- for x in range(0,5):
- die1 = random.randint(1,6)
- die2 = random.randint(1,6)
- total2 = die1 + die2
- round1 = round1 + 1
- time.sleep(1.2)
- if total2 % 2 == 0: #check if odd or even
- total2 = total2+10
- print('Round' +str(round1) + ': Your total is ' + str(total2))
- score2 = score2+total2
- else:
- total2 = total2 - 5
- print('Round' +str(round1) + ': Your total is ' + str(total2))
- score2 = score2+total2
- if die1 == die2:
- total2= total2 + random.randint(1,6) #3rd dice is roll a double
- print(total2)
- score2 = score2+total2
- elif total2 < 0: #makes total 0 instead of negative
- total2 == 0
- score2 = score2 + total2
- print('Your total score is ' + str(score2)) #problem here
- '''
- #works out and declares the winner
- if score1 > score2:
- print(username1 + ' has won!')
- elif score1 < score2:
- print(username2 + ' has won!')
- #tiebreak
- '''
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement