Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from random import randint
- player1 = input("Enter player 1's name: ")
- player2 = input("Enter player 2's name: ")
- print("")
- print("")
- def menu():
- print("Welcome to this dice game.")
- print("What would you like to do first?")
- print("")
- print("A: Play!")
- print("B: Display rules")
- print("C: Quit :c")
- print("")
- valid = False
- while valid is False:
- choice = input("> ")
- choice = choice.lower()
- if choice == "a":
- valid = True
- game()
- elif choice == "b":
- valid = True
- rules()
- elif choice == "c":
- print("Cya")
- valid = True
- exit
- else:
- print("Enter valid response.")
- valid = False
- def rules():
- print("These are the rules of the game. You must obey them!")
- print("Players take turns to throw two dice . If the throw is a double, i.e. two 2s, two 3s, etc., the player's score reverts to zero and their turn ends. If the throw is not a double, the total shown on the two dice is added to the players score. A player may have as many throws as they like in any turn until they either throw a double or pass the dice. The first player to reach a score of 50, wins the game.")
- print()
- menu()
- def game():
- print("Welcome to the actual game! The fun begins now...")
- print("The first person to role will be " + str(player1) + ".")
- print()
- player1Count = 0
- player2Count = 0
- while player1Count < 50 and player2Count < 50:
- player1Go = True
- player2Go = False
- print("Press enter to role the dice. Or, type skip to turn the dice over to the over player.")
- print()
- while player1Go is True:
- print("Player: " + str(player1) + " Score: " + str(player1Count))
- x = input()
- x = x.lower()
- dice1 = randint(1,6)
- dice2 = randint(1,6)
- if x == "skip":
- player1Go = False
- player2Go = True
- elif dice1 != dice2:
- print("You rolled " + str(dice1) + " and " + str(dice2) + ".")
- player1Count = player1Count + (dice1 + dice2)
- elif dice1 == dice2:
- print("Unlucky! You got doubles, your score is now 0 and it is the other players go.")
- player1Go = False
- player2Go = True
- while player2Go is True:
- print("Player: " + str(player1) + " Score: " + str(player1Count))
- x = input()
- dice1 = randint(1,6)
- dice2 = randint(1,6)
- if x == "skip":
- player2Go = False
- player1Go = True
- elif dice1 != dice2:
- print("You rolled " + str(dice1) + " and " + str(dice2) + ".")
- player2Count = player2Count + (dice1 + dice2)
- elif dice1 == dice2:
- print("Unlucky! You got doubles, your score is now 0 and it is the other players go.")
- player2Go = False
- player1Go = True
- menu()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement