Advertisement
Guest User

Untitled

a guest
Feb 24th, 2019
337
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 7.73 KB | None | 0 0
  1. import random, sys, time, csv
  2.  
  3. """
  4. notes to do:
  5. Create authenticater thing in start so ask for username and password in the def Start(): area this is just for security purposes
  6.  
  7. configure it so that on round 1 the even numbers add on points etc from the website at https://www.ocr.org.uk/Images/503195-programming-project-tasks-june-2019-and-june-2020.pdf
  8.  
  9. make it so that the overal points at the endd get put in .txt file
  10.  
  11. create ids
  12.  
  13. if duplicate in txt file then say duplicate
  14.  
  15. 3 retrys
  16. """
  17. #variables
  18. p1_final_score = 0
  19. p2_final_score = 0
  20. p1_round1_score = 0
  21. p2_round1_score = 0
  22. p1_round2_score = 0
  23. p2_round2_score = 0
  24. p1_round3_score = 0
  25. p2_round3_score = 0
  26. p1_round4_score = 0
  27. p2_round4_score = 0
  28. p1_round5_score = 0
  29. p2_round5_score = 0
  30.  
  31.  
  32.  
  33.  
  34. def Start():
  35. global p1_final_score
  36. global p2_final_score
  37. global player1
  38. global player2
  39. global p1p
  40. global p2p
  41.  
  42. #Asks for login
  43. gameuniqueid = random.randint(1000,999999)
  44.  
  45. player1uniqueid = random.randint(1000,9999)
  46. player1 = input("Enter player 1 name: ")
  47. p1p = input("Enter/Create player 1 password: ")
  48. p1_final_score = 0
  49.  
  50. player2uniqueid = random.randint(1000,9999)
  51. player2 = input("Enter player 2 name: ")
  52. p2p = input("Enter/Create player 2 password: ")
  53. p2_final_score = 0
  54.  
  55.  
  56. print("Your game unique ID is:", gameuniqueid )
  57. #Opens Files and enters information
  58. game = []
  59. user1 = []
  60. user2 = []
  61.  
  62.  
  63. file = csv.writer(open("database.csv", "a"))
  64. rows.append(["Game id: ", gameuniqueid])
  65. rows.append([player1uniqueid ,player1, p1p, p1_final_score])
  66. rows.append([player2uniqueid ,player2, p2p, p2_final_score])
  67. file.writerows()
  68. Start_Confirm()
  69. Start()
  70. def Start_Confirm():
  71. global player1
  72. global player2
  73. global p1p
  74. global p2p
  75. start = input("Do you want to start the game ( y / n)")
  76. while start != "y":
  77. start = input("Press (n) to confirm that you would like to leave the game otherwise press (y) to play on? (your data will be erased): ")
  78. if start == "n":
  79. break
  80. else:
  81. #userauth = 0
  82. #passauth = 0
  83. #while userauth != player1:
  84. # userauth = input("auth purposes username: ")
  85. #while passauth != p1p:
  86. # passauth = input("auth purposes password: ")
  87. #else:
  88. Game_Round1()
  89.  
  90. def Game_Round1():
  91. #getting the variables
  92. global p1_final_score
  93. global p2_final_score
  94. global p1_round1_score
  95. global p2_round1_score
  96. #This starts the game.(Player 1 always starts first)
  97. print("player 1 turn")
  98. print("\033[0;37;40m Normal text\n")
  99.  
  100. player1_dice1_round1_dice = input("Round1/Player1: Press 1 to roll dice: ")
  101. time.sleep(0.25) # a little timer inbetween each print / code that outputs just to make everything look neater.
  102. while player1_dice1_round1_dice != "1":
  103. player1_dice1_round1_dice = input("Round1/Player1: Press 1 to roll dice: ")
  104. time.sleep(0.25)
  105. else:
  106. player1_dice1_round1_answer = random.randint(1, 6)
  107. time.sleep(0.25)
  108. print("You rolled the first dice and the answer is: ", player1_dice1_round1_answer)
  109. time.sleep(0.25)
  110. #Rolls dice 2 player 1
  111. player1_dice2_round1_roll_start = input("Round1/Player1: Press 2 to roll dice: ")
  112. time.sleep(0.25)
  113. while player1_dice2_round1_roll_start != "2":
  114. player1_dice2_round1_roll_start = input("Round1/Player1: Press 1 to roll dice: ")
  115. time.sleep(0.25)
  116. else:
  117. player1_dice2_round1_answer = random.randint(1, 6)
  118. time.sleep(0.25)
  119. print("You rolled the second dice and the answer is: ", player1_dice2_round1_answer)
  120. #calculates the scores.
  121. p1_round1_score = (player1_dice1_round1_answer + player1_dice2_round1_answer)
  122. odd_or_even_checker = p1_round1_score % 2
  123.  
  124. #if even or odd then deduct / add points
  125. if odd_or_even_checker > 0:
  126. time.sleep(0.25)
  127. print("as your number is even you will loose 5 points ")
  128. p1_round1_score -= 5
  129. else:
  130. time.sleep(0.25)
  131. print("as your number is even you will gain an extra 10 points ")
  132. p1_round1_score += 10
  133.  
  134. time.sleep(1)
  135. print("your final answer for round 1 is:", (p1_round1_score))
  136. time.sleep(0.25)
  137. print("Player 2 turn")
  138.  
  139. player2_dice1_round1_roll_start = input("Round1/Player2: Press 1 to roll dice: ")
  140. while player2_dice1_round1_roll_start != "1":
  141. player2_dice1_round1_roll_start = input("Round1/Player2: Press 1 to roll dice: ")
  142. else:
  143. p2_dice1_round1_answer = random.randint(1, 6)
  144. print("You rolled the first dice and the answer is: ", p2_dice1_round1_answer)
  145.  
  146. player2_dice2_round1_roll_start = input("Press 2 to roll dice 2: ")
  147. while player2_dice2_round1_roll_start != "2":
  148. player2_dice2_round1_roll_start = input("Press 2 to roll dice2!: ")
  149. else:
  150. p2_dice2_round1_answer = random.randint(1, 6)
  151. print("You rolled the second dice and the answer is: ", p2_dice2_round1_answer)
  152. p2_round1_score = (p2_dice1_round1_answer + p2_dice2_round1_answer)
  153. time.sleep(0.25)
  154. print("your final answer for round 1 is:", (p2_round1_score))
  155. time.sleep(0.25)
  156. print("For round 1, The scores are: Player 1 = ", p1_round1_score, "Player 2 = ",p2_round1_score)
  157. Game_Round2()
  158.  
  159.  
  160.  
  161. """
  162. def Game_Round2():
  163. global p1_final_score
  164. global p2_final_score
  165. global p1_round1_score
  166. global p2_round1_score
  167.  
  168. print("Round 2 will now commence")
  169. #player 1 turn
  170. print("player 1 turn")
  171. player1_dice1_round2_roll_start = input("Press 1 to roll dice 1: ")
  172. while player1_dice1_round2_roll_start != "1":
  173. player1_dice1_round2_roll_start = input("Press 1 to roll dice!: ")
  174. else:
  175. p1_dice1_round2_answer = random.randint(1, 6)
  176. print("You rolled the first dice and the answer is: ", p1_dice1_round2_answer)
  177.  
  178. player1_dice2_round2_roll_start = input("Press 2 to roll dice 2: ")
  179. while player1_dice2_round2_roll_start != "2":
  180. player1_dice2_round2_roll_start = input("Press 2 to roll dice2!: ")
  181. else:
  182. p1_dice2_round2_answer = random.randint(1, 6)
  183. print("You rolled the second dice and the answer is: ", p1_dice2_round2_answer)
  184. p1_round2_score = (p1_dice1_round2_answer + p1_dice2_round2_answer)
  185. print("your final answer for round 1 is:", (p1_round2_score))
  186. #player 2 turn
  187. print("Player 2 turn")
  188. player2_dice1_round2_roll_start = input("Press 1 to roll dice 1: ")
  189. while player2_dice1_round2_roll_start != "1":
  190. player2_dice1_round2_roll_start = input("Press 1 to roll dice!: ")
  191. else:
  192. p2_dice1_round2_answer = random.randint(1, 6)
  193. print("You rolled the first dice and the answer is: ", p2_dice1_round2_answer)
  194. player2_dice2_round2_roll_start = input("Press 2 to roll dice 2: ")
  195. while player2_dice2_round2_roll_start != "2":
  196. player2_dice2_round2_roll_start = input("Press 2 to roll dice2!: ")
  197. else:
  198. p2_dice2_round2_answer = random.randint(1, 6)
  199. print("You rolled the second dice and the answer is: ", p2_dice2_round2_answer)
  200. p2_round2_score = (p2_dice1_round2_answer + p2_dice2_round2_answer)
  201. print("your final answer for round 1 is:", (p2_round2_score))
  202.  
  203. print("For round 1, The scores are: Player 1 = ", p1_round2_score, "Player 2 = ",p2_round2_score)
  204.  
  205.  
  206.  
  207. p1_final_score = (p1_round1_score + p1_round2_score)
  208. p2_final_score = (p2_round1_score + p2_round2_score)
  209.  
  210.  
  211. print("Overall Score for player 1 is: ", p1_final_score)
  212. print("Overall Score for player 1 is: ", p2_final_score)
  213. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement