Advertisement
Guest User

Untitled

a guest
Dec 5th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.63 KB | None | 0 0
  1. import secrets
  2. import datetime
  3. from functions import login, highesths, finalshowdown
  4.     #setup
  5. date = datetime.date.today()
  6. date = date.strftime("%d/%m/%Y")
  7. n = 0
  8. even = [2, 4, 6, 8, 10, 12]
  9. odd = [1, 3, 5, 7, 9, 11]
  10. dice = [0, 0, 0]
  11. dice2 = [1, 2, 3, 4, 5, 6]
  12. totaldice = 0
  13. totalscore = [0, 0]
  14. roundscore = 0
  15. decidingscore = 0
  16. loginfile = ""
  17. i = 1
  18.  
  19. player1 = input("What is player 1's username? \n")
  20. login(player1)
  21.  
  22.     #Player 2
  23. player2 = input("What is player 2's username? \n")
  24. login(player2)
  25.  
  26.     #Dice Rolling
  27. for i in range(5):
  28.     print("Round " + str(i + 1) + "\n\n\n")
  29.     #Player 1
  30.     print('Player 1 is Rolling the Dice!\n')
  31.     for n in range(2):
  32.         dice[n] = secrets.choice(dice2)
  33.         print('Player 1 Rolled a ' + str(dice[n]) + "\n")
  34.         totaldice = totaldice + dice[n]
  35.         n+1
  36.     n = 0
  37.  
  38.     roundscore = 0 + totaldice
  39.     if totaldice in even:
  40.         roundscore = (roundscore + 10)
  41.         print("Congrats!! You rolled an even total!! You got 10 points added to your score!")
  42.     elif totaldice in odd:
  43.         roundscore = (roundscore - 5)
  44.         print("Oh No!! You rolled an odd total!! You got 5 points removed from your score!")
  45.     if dice[0] == dice[1]:
  46.         print('You Rolled a double!\nYou get to roll another Die!\n')
  47.         input('Press Enter to roll again:\n')
  48.         dice[2] = secrets.choice(dice2)
  49.         roundscore = roundscore + dice[2]
  50.         print('Player 1 Rolled a ' + str(dice[2]) + "\n")
  51.     totaldice = 0
  52.     totalscore[0] = totalscore[0] + roundscore
  53.  
  54.     if roundscore < 0:
  55.         roundscore = 0
  56.  
  57.     print("Player 1's round score is " + str(roundscore) + "\n\n")
  58.     #Player 2
  59.     print('Player 2 is rolling the Dice! \n')
  60.     for n in range(2):
  61.         dice[n] = secrets.choice(dice2)
  62.         print('Player 2 Rolled a ' + str(dice[n]) + "\n")
  63.         totaldice = totaldice + dice[n]
  64.         n+1
  65.     n = 0
  66.  
  67.     roundscore = 0 + totaldice
  68.     if totaldice in even:
  69.         roundscore = (roundscore + 10)
  70.         print("Congrats!! You rolled an even total!! You got 10 points added to your score!")
  71.     elif totaldice in odd:
  72.         roundscore = (roundscore - 5)
  73.         print("Oh No!! You rolled an odd total!! You got 5 points removed from your score!")
  74.     if dice[0] == dice[1]:
  75.         print('You Rolled a double!\nYou get to roll another Die!\n')
  76.         input('Press Enter to roll again:\n')
  77.         dice[2] = secrets.choice(dice2)
  78.         roundscore = roundscore + dice[2]
  79.         print('Player 2 Rolled a ' + str(dice[2]) + "\n")
  80.     totaldice = 0
  81.     totalscore[1] = totalscore[1] + roundscore
  82.  
  83.     if roundscore < 0:
  84.         roundscore = 0
  85.  
  86.     print("Player 2's round score is " + str(roundscore) + "\n\n")
  87.  
  88.     if totalscore[0] < 0:
  89.         totalscore[0] = 1
  90.  
  91.     elif totalscore[1] < 0:
  92.         totalscore[1] = 1
  93.  
  94.     print("Player 1's total score is " + str(totalscore[0]) + "\n")
  95.     print("Player 2's total score is " + str(totalscore[1]) + "\n")
  96.  
  97.     if i == 4:
  98.         if totalscore[0] == totalscore[1]:
  99.             finalshowdown(totalscore, dice, dice2, n)
  100.         elif totalscore[0] > totalscore[1]:
  101.             print("Player 1 Won!!\n\n")
  102.             file = open('Scores.txt', 'a')
  103.             file.write(player1 + ', ' + str(date) + ', ' + str(totalscore[0]) + ',\n')
  104.             file.close()
  105.         elif totalscore[1] > totalscore[0]:
  106.             print("Player 2 Won!!\n\n")
  107.             file = open('Scores.txt', 'a')
  108.             file.write(player2 + ', ' + str(date) + ', ' + str(totalscore[1]) + ',\n')
  109.             file.close()
  110.     else:
  111.         input("Press 'Enter' to begin the next round\n")
  112.  
  113. highesths()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement