Advertisement
Guest User

Untitled

a guest
Feb 28th, 2019
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 10.52 KB | None | 0 0
  1. import random, sys, time, csv, os
  2. from colorama import Fore, Back, Style, init
  3. init() # Initilizes the colour
  4.  
  5.  
  6. """
  7. References:
  8. Website: https://www.ocr.org.uk/Images/503195-programming-project-tasks-june-2019-and-june-2020.pdf
  9.  
  10. notes to do:
  11. MAIN OBJECTIVE TO START CLEARING NOTES TO DO
  12.  
  13.  
  14. 1. Completely Fix and make Game_Round1 Work before copying and pasting. make sure to change the round number on each one and for some reason when i sound player1/round1 theres 4 search results but when I search player2/round1 theres only 2 search results. I think player two only has 1 dice to roll not 1
  15.  
  16. 2. Add colours to all game_rounds
  17.  
  18. 2. write score to txt file at the end then make sure to print new line
  19.  
  20. 3. Make sure to Reference The "colorama" module in the cs test link fount here https://pypi.org/project/colorama/
  21.  
  22. 4. make it so that the overal points at the endd get put in .txt file
  23.  
  24. 5. Create authenticater thing in start so ask for username and password in the def Start(): area this is just for security purposes
  25.  
  26. 6. 3 retrys in confirm
  27.  
  28. 7. if duplicate in txt file then say duplicate
  29.  
  30. Completed:
  31. create ids - Completed
  32. 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 - completed
  33.  
  34. """
  35.  
  36.  
  37.  
  38. #variables
  39. p1_final_score = 0
  40. p2_final_score = 0
  41. p1_round1_score = 0
  42. p2_round1_score = 0
  43. p1_round2_score = 0
  44. p2_round2_score = 0
  45. p1_round3_score = 0
  46. p2_round3_score = 0
  47. p1_round4_score = 0
  48. p2_round4_score = 0
  49. p1_round5_score = 0
  50. p2_round5_score = 0
  51.  
  52.  
  53.  
  54.  
  55. def Start():
  56. #Variables
  57. global p1_final_score
  58. global p2_final_score
  59. global player1
  60. global player2
  61. global p1p
  62. global p2p
  63.  
  64. #Creates random game ID
  65. gameuniqueid = random.randint(1000,9999)
  66.  
  67. #player 1 credentials
  68.  
  69. player1uniqueid = random.randint(1000,9999)
  70. player1 = input("Enter player 1 name: ")
  71. #p1p = input("Enter/Create player 1 password: ")
  72. p1_final_score = 0
  73.  
  74. #player 2 credentials
  75.  
  76. player2uniqueid = random.randint(1000,9999)
  77. player2 = input("Enter player 2 name: ")
  78. #p2p = input("Enter/Create player 2 password: ")
  79. p2_final_score = 0
  80.  
  81. #Opens Files and enters information
  82. f = open("users.txt" , "a")
  83. #Writes the user inputted information to the text file.
  84. f.write(str(gameuniqueid))
  85. f.write( "Player1 ID/Username/Password" + str(player1uniqueid) + player1 + """p1p""" + "\n")
  86. f.write("Player2 ID/Username/Password" + str(player2uniqueid) + player2 + """p2p""" + "\n")
  87.  
  88. print("Your game unique ID is:", gameuniqueid )
  89. f.close()
  90.  
  91. #Goes too the "Start_Confirm Function
  92. Game_Round1()
  93. #Start_Confirm()-
  94.  
  95. def Start_Confirm():
  96. init()
  97. #Variables
  98. global player1
  99. global player2
  100. global p1p
  101. global p2p
  102.  
  103. ##While Statement
  104. #start = input("Do you want to start the game ( y / n)")
  105. #while start != "y":
  106. # 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): ")
  107. # if start == "n":
  108. # break
  109. #else:
  110.  
  111. def Game_Round1():
  112. init()
  113. #variables
  114. global p1_final_score
  115. global p2_final_score
  116. global p1_round1_score
  117. global p2_round1_score
  118.  
  119. print("player 1 turn")
  120. player1_dice1_round1_dice = print(Fore.GREEN + "Round1/Player1: " + Fore.WHITE + input( "Press 1 to roll dice: "))
  121. #timer delay which pauses before continuing to next line
  122. time.sleep(0.25)
  123. while player1_dice1_round1_dice != "1":
  124. player1_dice1_round1_dice = print(Fore.GREEN + "Round1/Player1: " + Fore.WHITE + input( "Press 1 to roll dice: "))
  125. time.sleep(0.25)
  126. else:
  127. player1_dice1_round1_answer = random.randint(1, 6)
  128. time.sleep(0.25)
  129. print("You rolled the first dice and the answer is: ", player1_dice1_round1_answer)
  130. time.sleep(0.25)
  131.  
  132.  
  133.  
  134.  
  135. #Rolls dice 2 player 1
  136. player1_dice2_round1_roll_start = print(Fore.GREEN + "Round1/Player1: " + Fore.WHITE + input( "Press 2 to roll dice: "))
  137. time.sleep(0.25)
  138. while player1_dice2_round1_roll_start != "2":
  139. player1_dice2_round1_roll_start = print(Fore.GREEN + "Round1/Player1: " + Fore.WHITE + input( "Press 2 to roll dice: "))
  140. time.sleep(0.25)
  141. else:
  142. player1_dice2_round1_answer = random.randint(1, 6)
  143. time.sleep(0.25)
  144. print("You rolled the second dice and the answer is: ", player1_dice2_round1_answer)
  145.  
  146. #calculates the scores
  147. #p1_round1_score = (player1_dice1_round1_answer + player1_dice2_round1_answer)
  148.  
  149. #Odd Or Even Checker
  150. odd_or_even_checker = p1_round1_score % 2
  151. if odd_or_even_checker > 0:
  152. time.sleep(0.25)
  153. print("as your number is odd you will loose 5 points ")
  154. p1_round1_score -= 5
  155. else:
  156. time.sleep(0.25)
  157. print("as your number is even you will gain an extra 10 points ")
  158. p1_round1_score += 10
  159.  
  160. time.sleep(0.25)
  161. print("your final answer for round 1 is:", (p1_round1_score))
  162. time.sleep(0.25)
  163. print("Player 2 turn")
  164. #player 2
  165. player2_dice1_round1_roll_start = print(Fore.GREEN + "Round1/Player2: " + Fore.WHITE + input( "Press 2 to roll dice: "))
  166. while player2_dice1_round1_roll_start != "1":
  167. player2_dice1_round1_roll_start = print(Fore.GREEN + "Round1/Player2: " + Fore.WHITE + input( "Press 2 to roll dice: "))
  168. else:
  169. p2_dice1_round1_answer = random.randint(1, 6)
  170. print("You rolled the first dice and the answer is: ", p2_dice1_round1_answer)
  171.  
  172. player2_dice2_round1_roll_start = input("Press 2 to roll dice 2: ")
  173. while player2_dice2_round1_roll_start != "2":
  174. player2_dice2_round1_roll_start = input("Press 2 to roll dice2!: ")
  175. else:
  176. p2_dice2_round1_answer = random.randint(1, 6)
  177. print("You rolled the second dice and the answer is: ", p2_dice2_round1_answer)
  178. p2_round1_score = (p2_dice1_round1_answer + p2_dice2_round1_answer)
  179.  
  180. #Odd Or Even Checker
  181. odd_or_even_checker = p2_round1_score % 2
  182. if odd_or_even_checker > 0:
  183. time.sleep(0.25)
  184. print("as your number is odd you will loose 5 points ")
  185. p2_round1_score -= 5
  186. else:
  187. time.sleep(0.25)
  188. print("as your number is even you will gain an extra 10 points ")
  189. p2_round1_score += 10
  190.  
  191. #prints round player 2 answer
  192. time.sleep(0.25)
  193. print("your final answer for round 1 is:", (p2_round1_score))
  194. time.sleep(0.25)
  195.  
  196. #prints round player 1 & 2 Answer
  197. print("For round 1, The scores are: Player 1 = ", p1_round1_score, "Player 2 = ",p2_round1_score)
  198. Game_Round2()
  199.  
  200. def Game_Round2():
  201. #variables
  202. global p1_final_score
  203. global p2_final_score
  204. global p1_round1_score
  205. global p2_round1_score
  206.  
  207. print("player 1 turn")
  208. player1_dice1_round2_dice = print(Fore.GREEN + "Round2/Player1: " + Fore.WHITE + input( "Press 2 to roll dice: "))
  209.  
  210. #timer delay which pauses before continuing to next line
  211. time.sleep(0.25)
  212. while player1_dice1_round2_dice != "1":
  213. player1_dice1_round2_dice = print(Fore.GREEN + "Round2/Player1: " + Fore.WHITE + input( "Press 2 to roll dice: "))
  214. time.sleep(0.25)
  215. else:
  216. player1_dice1_round2_answer = random.randint(1, 6)
  217. time.sleep(0.25)
  218. print("You rolled the first dice and the answer is: ", player1_dice1_round2_answer)
  219. time.sleep(0.25)
  220.  
  221. #Rolls dice 2 player 1
  222. player1_dice2_round2_roll_start = print(Fore.GREEN + "Round2/Player1: " + Fore.WHITE + input( "Press 2 to roll dice: "))
  223. time.sleep(0.25)
  224. while player1_dice2_round2_roll_start != "2":
  225. player1_dice2_round2_roll_start = print(Fore.GREEN + "Round2/Player1: " + Fore.WHITE + input( "Press 2 to roll dice: "))
  226. time.sleep(0.25)
  227. else:
  228. player1_dice2_round2_answer = random.randint(1, 6)
  229. time.sleep(0.25)
  230. print("You rolled the second dice and the answer is: ", player1_dice2_round2_answer)
  231.  
  232. #calculates the scores
  233. p1_round2_score = (player1_dice1_round2_answer + player1_dice2_round2_answer)
  234.  
  235. #Odd Or Even Checker
  236. odd_or_even_checker = p1_round2_score % 2
  237. if odd_or_even_checker > 0:
  238. time.sleep(0.25)
  239. print("as your number is odd you will loose 5 points ")
  240. p1_round2_score -= 5
  241. else:
  242. time.sleep(0.25)
  243. print("as your number is even you will gain an extra 10 points ")
  244. p1_round2_score += 10
  245.  
  246. time.sleep(0.25)
  247. print("your final answer for round 1 is:", (p1_round2_score))
  248. time.sleep(0.25)
  249. print("Player 2 turn")
  250.  
  251. player2_dice1_round2_roll_start = input("round2/Player2: Press 1 to roll dice: ")
  252. while player2_dice1_round2_roll_start != "1":
  253. player2_dice1_round2_roll_start = input("round2/Player2: Press 1 to roll dice: ")
  254. else:
  255. p2_dice1_round2_answer = random.randint(1, 6)
  256. print("You rolled the first dice and the answer is: ", p2_dice1_round2_answer)
  257.  
  258. player2_dice2_round2_roll_start = input("Press 2 to roll dice 2: ")
  259. while player2_dice2_round2_roll_start != "2":
  260. player2_dice2_round2_roll_start = input("Press 2 to roll dice2!: ")
  261. else:
  262. p2_dice2_round2_answer = random.randint(1, 6)
  263. print("You rolled the second dice and the answer is: ", p2_dice2_round2_answer)
  264. p2_round2_score = (p2_dice1_round2_answer + p2_dice2_round2_answer)
  265.  
  266. #Odd Or Even Checker
  267. odd_or_even_checker = p2_round2_score % 2
  268. if odd_or_even_checker > 0:
  269. time.sleep(0.25)
  270. print("as your number is odd you will loose 5 points ")
  271. p2_round2_score -= 5
  272. else:
  273. time.sleep(0.25)
  274. print("as your number is even you will gain an extra 10 points ")
  275. p2_round2_score += 10
  276.  
  277. #prints round player 2 answer
  278. time.sleep(0.25)
  279. print("your final answer for round 1 is:", (p2_round2_score))
  280. time.sleep(0.25)
  281.  
  282. #prints round player 1 & 2 Answer
  283. print("For round 1, The scores are: Player 1 = ", p1_round2_score, "Player 2 = ",p2_round2_score)
  284. Game_Round3()
  285.  
  286.  
  287. def finish():
  288. global p1_final_score
  289. global p2_final_score
  290. f = open("users.txt", "a")
  291. f.write("Users Score")
  292. f.write("player 1 Score: " + str(p1_final_score) + "Player 2 Score: " + str(p2_final_score))
  293.  
  294. Game_Round1()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement