Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random, sys, time, csv, os
- from colorama import Fore, Back, Style, init
- init() # Initilizes the colour
- """
- References:
- Website: https://www.ocr.org.uk/Images/503195-programming-project-tasks-june-2019-and-june-2020.pdf
- notes to do:
- MAIN OBJECTIVE TO START CLEARING NOTES TO DO
- 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
- 2. Add colours to all game_rounds
- 2. write score to txt file at the end then make sure to print new line
- 3. Make sure to Reference The "colorama" module in the cs test link fount here https://pypi.org/project/colorama/
- 4. make it so that the overal points at the endd get put in .txt file
- 5. Create authenticater thing in start so ask for username and password in the def Start(): area this is just for security purposes
- 6. 3 retrys in confirm
- 7. if duplicate in txt file then say duplicate
- Completed:
- create ids - Completed
- 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
- """
- #variables
- p1_final_score = 0
- p2_final_score = 0
- p1_round1_score = 0
- p2_round1_score = 0
- p1_round2_score = 0
- p2_round2_score = 0
- p1_round3_score = 0
- p2_round3_score = 0
- p1_round4_score = 0
- p2_round4_score = 0
- p1_round5_score = 0
- p2_round5_score = 0
- def Start():
- #Variables
- global p1_final_score
- global p2_final_score
- global player1
- global player2
- global p1p
- global p2p
- #Creates random game ID
- gameuniqueid = random.randint(1000,9999)
- #player 1 credentials
- player1uniqueid = random.randint(1000,9999)
- player1 = input("Enter player 1 name: ")
- #p1p = input("Enter/Create player 1 password: ")
- p1_final_score = 0
- #player 2 credentials
- player2uniqueid = random.randint(1000,9999)
- player2 = input("Enter player 2 name: ")
- #p2p = input("Enter/Create player 2 password: ")
- p2_final_score = 0
- #Opens Files and enters information
- f = open("users.txt" , "a")
- #Writes the user inputted information to the text file.
- f.write(str(gameuniqueid))
- f.write( "Player1 ID/Username/Password" + str(player1uniqueid) + player1 + """p1p""" + "\n")
- f.write("Player2 ID/Username/Password" + str(player2uniqueid) + player2 + """p2p""" + "\n")
- print("Your game unique ID is:", gameuniqueid )
- f.close()
- #Goes too the "Start_Confirm Function
- Game_Round1()
- #Start_Confirm()-
- def Start_Confirm():
- init()
- #Variables
- global player1
- global player2
- global p1p
- global p2p
- ##While Statement
- #start = input("Do you want to start the game ( y / n)")
- #while start != "y":
- # 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): ")
- # if start == "n":
- # break
- #else:
- def Game_Round1():
- init()
- #variables
- global p1_final_score
- global p2_final_score
- global p1_round1_score
- global p2_round1_score
- print("player 1 turn")
- player1_dice1_round1_dice = print(Fore.GREEN + "Round1/Player1: " + Fore.WHITE + input( "Press 1 to roll dice: "))
- #timer delay which pauses before continuing to next line
- time.sleep(0.25)
- while player1_dice1_round1_dice != "1":
- player1_dice1_round1_dice = print(Fore.GREEN + "Round1/Player1: " + Fore.WHITE + input( "Press 1 to roll dice: "))
- time.sleep(0.25)
- else:
- player1_dice1_round1_answer = random.randint(1, 6)
- time.sleep(0.25)
- print("You rolled the first dice and the answer is: ", player1_dice1_round1_answer)
- time.sleep(0.25)
- #Rolls dice 2 player 1
- player1_dice2_round1_roll_start = print(Fore.GREEN + "Round1/Player1: " + Fore.WHITE + input( "Press 2 to roll dice: "))
- time.sleep(0.25)
- while player1_dice2_round1_roll_start != "2":
- player1_dice2_round1_roll_start = print(Fore.GREEN + "Round1/Player1: " + Fore.WHITE + input( "Press 2 to roll dice: "))
- time.sleep(0.25)
- else:
- player1_dice2_round1_answer = random.randint(1, 6)
- time.sleep(0.25)
- print("You rolled the second dice and the answer is: ", player1_dice2_round1_answer)
- #calculates the scores
- #p1_round1_score = (player1_dice1_round1_answer + player1_dice2_round1_answer)
- #Odd Or Even Checker
- odd_or_even_checker = p1_round1_score % 2
- if odd_or_even_checker > 0:
- time.sleep(0.25)
- print("as your number is odd you will loose 5 points ")
- p1_round1_score -= 5
- else:
- time.sleep(0.25)
- print("as your number is even you will gain an extra 10 points ")
- p1_round1_score += 10
- time.sleep(0.25)
- print("your final answer for round 1 is:", (p1_round1_score))
- time.sleep(0.25)
- print("Player 2 turn")
- #player 2
- player2_dice1_round1_roll_start = print(Fore.GREEN + "Round1/Player2: " + Fore.WHITE + input( "Press 2 to roll dice: "))
- while player2_dice1_round1_roll_start != "1":
- player2_dice1_round1_roll_start = print(Fore.GREEN + "Round1/Player2: " + Fore.WHITE + input( "Press 2 to roll dice: "))
- else:
- p2_dice1_round1_answer = random.randint(1, 6)
- print("You rolled the first dice and the answer is: ", p2_dice1_round1_answer)
- player2_dice2_round1_roll_start = input("Press 2 to roll dice 2: ")
- while player2_dice2_round1_roll_start != "2":
- player2_dice2_round1_roll_start = input("Press 2 to roll dice2!: ")
- else:
- p2_dice2_round1_answer = random.randint(1, 6)
- print("You rolled the second dice and the answer is: ", p2_dice2_round1_answer)
- p2_round1_score = (p2_dice1_round1_answer + p2_dice2_round1_answer)
- #Odd Or Even Checker
- odd_or_even_checker = p2_round1_score % 2
- if odd_or_even_checker > 0:
- time.sleep(0.25)
- print("as your number is odd you will loose 5 points ")
- p2_round1_score -= 5
- else:
- time.sleep(0.25)
- print("as your number is even you will gain an extra 10 points ")
- p2_round1_score += 10
- #prints round player 2 answer
- time.sleep(0.25)
- print("your final answer for round 1 is:", (p2_round1_score))
- time.sleep(0.25)
- #prints round player 1 & 2 Answer
- print("For round 1, The scores are: Player 1 = ", p1_round1_score, "Player 2 = ",p2_round1_score)
- Game_Round2()
- def Game_Round2():
- #variables
- global p1_final_score
- global p2_final_score
- global p1_round1_score
- global p2_round1_score
- print("player 1 turn")
- player1_dice1_round2_dice = print(Fore.GREEN + "Round2/Player1: " + Fore.WHITE + input( "Press 2 to roll dice: "))
- #timer delay which pauses before continuing to next line
- time.sleep(0.25)
- while player1_dice1_round2_dice != "1":
- player1_dice1_round2_dice = print(Fore.GREEN + "Round2/Player1: " + Fore.WHITE + input( "Press 2 to roll dice: "))
- time.sleep(0.25)
- else:
- player1_dice1_round2_answer = random.randint(1, 6)
- time.sleep(0.25)
- print("You rolled the first dice and the answer is: ", player1_dice1_round2_answer)
- time.sleep(0.25)
- #Rolls dice 2 player 1
- player1_dice2_round2_roll_start = print(Fore.GREEN + "Round2/Player1: " + Fore.WHITE + input( "Press 2 to roll dice: "))
- time.sleep(0.25)
- while player1_dice2_round2_roll_start != "2":
- player1_dice2_round2_roll_start = print(Fore.GREEN + "Round2/Player1: " + Fore.WHITE + input( "Press 2 to roll dice: "))
- time.sleep(0.25)
- else:
- player1_dice2_round2_answer = random.randint(1, 6)
- time.sleep(0.25)
- print("You rolled the second dice and the answer is: ", player1_dice2_round2_answer)
- #calculates the scores
- p1_round2_score = (player1_dice1_round2_answer + player1_dice2_round2_answer)
- #Odd Or Even Checker
- odd_or_even_checker = p1_round2_score % 2
- if odd_or_even_checker > 0:
- time.sleep(0.25)
- print("as your number is odd you will loose 5 points ")
- p1_round2_score -= 5
- else:
- time.sleep(0.25)
- print("as your number is even you will gain an extra 10 points ")
- p1_round2_score += 10
- time.sleep(0.25)
- print("your final answer for round 1 is:", (p1_round2_score))
- time.sleep(0.25)
- print("Player 2 turn")
- player2_dice1_round2_roll_start = input("round2/Player2: Press 1 to roll dice: ")
- while player2_dice1_round2_roll_start != "1":
- player2_dice1_round2_roll_start = input("round2/Player2: Press 1 to roll dice: ")
- else:
- p2_dice1_round2_answer = random.randint(1, 6)
- print("You rolled the first dice and the answer is: ", p2_dice1_round2_answer)
- player2_dice2_round2_roll_start = input("Press 2 to roll dice 2: ")
- while player2_dice2_round2_roll_start != "2":
- player2_dice2_round2_roll_start = input("Press 2 to roll dice2!: ")
- else:
- p2_dice2_round2_answer = random.randint(1, 6)
- print("You rolled the second dice and the answer is: ", p2_dice2_round2_answer)
- p2_round2_score = (p2_dice1_round2_answer + p2_dice2_round2_answer)
- #Odd Or Even Checker
- odd_or_even_checker = p2_round2_score % 2
- if odd_or_even_checker > 0:
- time.sleep(0.25)
- print("as your number is odd you will loose 5 points ")
- p2_round2_score -= 5
- else:
- time.sleep(0.25)
- print("as your number is even you will gain an extra 10 points ")
- p2_round2_score += 10
- #prints round player 2 answer
- time.sleep(0.25)
- print("your final answer for round 1 is:", (p2_round2_score))
- time.sleep(0.25)
- #prints round player 1 & 2 Answer
- print("For round 1, The scores are: Player 1 = ", p1_round2_score, "Player 2 = ",p2_round2_score)
- Game_Round3()
- def finish():
- global p1_final_score
- global p2_final_score
- f = open("users.txt", "a")
- f.write("Users Score")
- f.write("player 1 Score: " + str(p1_final_score) + "Player 2 Score: " + str(p2_final_score))
- Game_Round1()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement