import random import time import sys from random import randint ##This is how you login## def main(): print ("welcome to the dice game") login() def login(): username="Dave" password="Mmhm" print("Enter username : ") answer1=input() print("Enter password : ") answer2=input() if answer1==username and answer2==password: print("Welcome - Access Granted") menu() def menu(): user1 = input("what is your name player 1 ") user2 = input("what is your name player 2 ") ##This is where i defined all my vairables## def game(): player1 = 0 player2 = 0 player1roll3 = 0 player2roll3 = 0 even = [2, 4, 6, 8, 10, 12, 14, 16, 18] odd = [3, 5, 7, 9, 11, 13, 15, 17] rounds = 0 player1go = 0 player2go = 0 rolling = 0 double = 0 for i in range (5): while True: ##This how player 1 roles## player1 = input("\nPlayer 1 press r to roll") if player1 == "r": print("p1") player1roll1 = random.randint(1, 6) player1roll2 = random.randint(1, 6) player1roll3 = player1roll1 + player1roll2 print("Dice 1 rolled a", player1roll1,) print("Dice 2 rolled a", player1roll2,) print("Player 1 your roll was a", player1roll3,) break ##If player1 roles a double## else: print("\nTo play the game could you please press 'r'") if player1roll1 == player1roll2: print("You got a double. You get one more roll") double = random.randint(1, 6) player1roll3 = player1roll3 + double print("The double dice rolled a", double,) print("You got", player1roll3,) ##If you role a odd number## if player1roll3 in odd: if player1roll3>5: player1go = player1go + player1roll3 - 5 print( "You rolled a odd number 5 points have been removed from your score. You now have", player1go, "points") rolls = 1 droll = 0 rolling = 0 else: print( "You rolled a odd number 5 points have been removed from your score. You now have", player1go, "points") rolls = 1 droll = 0 rolling = 0 ##If you role a even number## elif player1roll3 in even: player1go = player1go + player1roll3 + 10 print( "You rolled a even number 10 points have benn added to your score. You now have", player1go, "points") rolls = 1 droll = 0 rolling = 0 while True: ##This is how player 2 roles## player2 = input("\nPlayer 2 press r to roll") if player2 == 'r': print("P2") player2roll1 = random.randint(1, 6) player2roll2 = random.randint(1, 6) player2roll3 = player2roll1 + player2roll2 print("Dice 1 rolled a", player2roll1,) print("Dice 2 rolled a", player2roll2,) print("Player 2 your roll was a", player2roll3,) rolling = 1 break ##If player 2 roles a double## else: print("\nTo play the game could you please press 'r'") if player2roll1 == player2roll2: print("You got a double. You get one more roll") double = random.randint(1, 6) player2roll3 = player2roll3 + double print("The double dice rolled a", double,) print("You got", player2roll3,) ##If player 2 roles a odd number## if player2roll3 in odd: player2go = player2go + player2roll3 - 5 print( "You rolled a odd number 5 points have been removed from your score. You now have", player2go, "points") rounds = rounds + 1 droll = 1 rolls = 0 rollings = 0 elif player2go in [3, 5]: print( "You rolled a odd number 5 points have been removed from your score. You now have", player2go, "points") rounds = rounds + 1 droll = 1 rolls = 0 rolling = 0 ##If player 2 roles a even number## elif player2roll3 in even: player2go = player2go + player2roll3 + 10 print( "You rolled a even number 10 points have been added to your score. You now have", player2go, "points") rounds = rounds + 1 droll = 1 rolls = 0 rolling = 0 ##If player 1 = player 2 both players role one dice to see who wins## if player1go == player2go: player1 = input("Player 1 press r to roll") if player1 == "r": player1roll1 = random.randint(1, 6) player1roll2 = random.randint(1, 6) player1roll3 = player1roll1 + player1roll2 print("Dice 1 rolled a", player1roll1,) print("Dice 2 rolled a", player1roll2,) print("Player 1 your roll was a", player1roll3,) player2 = input("Player 1 press r to roll") if player2 == "r": player2roll1 = random.randint(1, 6) player2roll2 = random.randint(1, 6) player2roll3 = player2roll1 + player2roll2 print("Dice 1 rolled a", player2roll1,) print("Dice 2 rolled a", player2roll2,) print("Player 1 your roll was a", player2roll3,) ##This shows the final scores## print("\nThe scores have been added up and") time.sleep(2) print('\n') print(player1 , "got", player1go,) print(player2 , "got", player2go,) login() game()