Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random, sys, time, csv
- """
- notes to do:
- Create authenticater thing in start so ask for username and password in the def Start(): area this is just for security purposes
- 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
- make it so that the overal points at the endd get put in .txt file
- create ids
- if duplicate in txt file then say duplicate
- 3 retrys
- """
- #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():
- global p1_final_score
- global p2_final_score
- global player1
- global player2
- global p1p
- global p2p
- #Asks for login
- gameuniqueid = random.randint(1000,999999)
- player1uniqueid = random.randint(1000,9999)
- player1 = input("Enter player 1 name: ")
- p1p = input("Enter/Create player 1 password: ")
- p1_final_score = 0
- player2uniqueid = random.randint(1000,9999)
- player2 = input("Enter player 2 name: ")
- p2p = input("Enter/Create player 2 password: ")
- p2_final_score = 0
- print("Your game unique ID is:", gameuniqueid )
- #Opens Files and enters information
- game = []
- user1 = []
- user2 = []
- file = csv.writer(open("database.csv", "a"))
- rows.append(["Game id: ", gameuniqueid])
- rows.append([player1uniqueid ,player1, p1p, p1_final_score])
- rows.append([player2uniqueid ,player2, p2p, p2_final_score])
- file.writerows()
- Start_Confirm()
- Start()
- def Start_Confirm():
- global player1
- global player2
- global p1p
- global p2p
- 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:
- #userauth = 0
- #passauth = 0
- #while userauth != player1:
- # userauth = input("auth purposes username: ")
- #while passauth != p1p:
- # passauth = input("auth purposes password: ")
- #else:
- Game_Round1()
- def Game_Round1():
- #getting the variables
- global p1_final_score
- global p2_final_score
- global p1_round1_score
- global p2_round1_score
- #This starts the game.(Player 1 always starts first)
- print("player 1 turn")
- print("\033[0;37;40m Normal text\n")
- player1_dice1_round1_dice = input("Round1/Player1: Press 1 to roll dice: ")
- time.sleep(0.25) # a little timer inbetween each print / code that outputs just to make everything look neater.
- while player1_dice1_round1_dice != "1":
- player1_dice1_round1_dice = input("Round1/Player1: 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 = input("Round1/Player1: Press 2 to roll dice: ")
- time.sleep(0.25)
- while player1_dice2_round1_roll_start != "2":
- player1_dice2_round1_roll_start = input("Round1/Player1: Press 1 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 = p1_round1_score % 2
- #if even or odd then deduct / add points
- if odd_or_even_checker > 0:
- time.sleep(0.25)
- print("as your number is even 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(1)
- print("your final answer for round 1 is:", (p1_round1_score))
- time.sleep(0.25)
- print("Player 2 turn")
- player2_dice1_round1_roll_start = input("Round1/Player2: Press 1 to roll dice: ")
- while player2_dice1_round1_roll_start != "1":
- player2_dice1_round1_roll_start = input("Round1/Player2: Press 1 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)
- time.sleep(0.25)
- print("your final answer for round 1 is:", (p2_round1_score))
- time.sleep(0.25)
- print("For round 1, The scores are: Player 1 = ", p1_round1_score, "Player 2 = ",p2_round1_score)
- Game_Round2()
- """
- def Game_Round2():
- global p1_final_score
- global p2_final_score
- global p1_round1_score
- global p2_round1_score
- print("Round 2 will now commence")
- #player 1 turn
- print("player 1 turn")
- player1_dice1_round2_roll_start = input("Press 1 to roll dice 1: ")
- while player1_dice1_round2_roll_start != "1":
- player1_dice1_round2_roll_start = input("Press 1 to roll dice!: ")
- else:
- p1_dice1_round2_answer = random.randint(1, 6)
- print("You rolled the first dice and the answer is: ", p1_dice1_round2_answer)
- player1_dice2_round2_roll_start = input("Press 2 to roll dice 2: ")
- while player1_dice2_round2_roll_start != "2":
- player1_dice2_round2_roll_start = input("Press 2 to roll dice2!: ")
- else:
- p1_dice2_round2_answer = random.randint(1, 6)
- print("You rolled the second dice and the answer is: ", p1_dice2_round2_answer)
- p1_round2_score = (p1_dice1_round2_answer + p1_dice2_round2_answer)
- print("your final answer for round 1 is:", (p1_round2_score))
- #player 2 turn
- print("Player 2 turn")
- player2_dice1_round2_roll_start = input("Press 1 to roll dice 1: ")
- while player2_dice1_round2_roll_start != "1":
- player2_dice1_round2_roll_start = input("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)
- print("your final answer for round 1 is:", (p2_round2_score))
- print("For round 1, The scores are: Player 1 = ", p1_round2_score, "Player 2 = ",p2_round2_score)
- p1_final_score = (p1_round1_score + p1_round2_score)
- p2_final_score = (p2_round1_score + p2_round2_score)
- print("Overall Score for player 1 is: ", p1_final_score)
- print("Overall Score for player 1 is: ", p2_final_score)
- """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement