Hi I'm trying to do my computer science course work, which is there to test my abilities (the one I chose was a Dice game. We are allowed to use recourses so I came here, and I need help as I have to create a scoring system but I need it to change with the round numbers so it can add the variables to get a final score. Any help would be great! I have attached my code below:
import time
import random
def totalScore(n,s):
file = open("total.txt", "a")
file.write("name: " + n + ", total: " + str(s) + "\n")
file.close()
return
def login():
while True:
print("")
username = input('What is your username? ')
password = input('What is your password? ')
if username not in ('User1', 'User2'):
print("")
print('Incorrect username, try again')
if password != 'password':
print("")
print('Incorrect password, try again')
continue
print("")
print(f'Welcome, {username} you have been successfully logged in.')
break
user1 = login()
user2 = login()
print("")
print("")
time.sleep(0.5)
print(" Rules")
print(" -----")
time.sleep(1)
print("• The points rolled on each player’s dice are added to their score.")
time.sleep(2)
print("• If the final total is an even number, an additional 10 points are added to their score.")
time.sleep(2)
print("• If the final total is an odd number, 5 points are subtracted from their score.")
time.sleep(2)
print("• If they roll a double, they get to roll one extra die and get the number of points rolled added to their score.")
time.sleep(2)
print("• The score of a player cannot go below 0 at any point.")
time.sleep(2)
print("• The person with the highest score at the end of the 5 rounds wins.")
time.sleep(2)
print("• If both players have the same score at the end of the 5 rounds, they each roll 1 die and whoever gets the highest score wins (this repeats until someone wins).")
time.sleep(2)
print("")
print("")
round_number = 0
msg = "Press Enter to Start The Round:\n\n"
while True:
if input(msg).lower() != '':
continue
round_number += 1
print(f"Round Number {round_number}\n")
print("User1 goes first : ")
roll_number = 0
dice3 = 0
print("")
msg = "Press Enter to Roll The Dice: \n\n"
while True:
if input(msg).lower() != '':
continue
roll_number = 1
dice1 = random.randint(1, 6)
print(f"1> You got a {dice1}\n")
input ("Press Enter to Roll Again!")
roll_number = 2
dice2 = random.randint(1, 6)
print(f"2> You got a {dice2}\n")
if roll_number == 2:
break
print("You have used both of your rolls")
total = dice1 + dice2
print("your total for this round is " + str(total) + ".")
if dice1 == dice2:
input ("Lucky!, you get an additional roll : ")
roll_number = 3
dice3 = random.randint(1, 6)
print(f"Bonus Role> You got a {dice3}\n")
total = total + dice3
print("your final total for this round is " + str(total) + ".")
print("User2 its your turn now : ")
roll_number = 0
dice3 = 0
print("")
msg = "Press Enter to Roll The Dice: \n\n"
while True:
if input(msg).lower() != '':
continue
roll_number = 1
dice1 = random.randint(1, 6)
print(f"1> You got a {dice1}\n")
input ("Press Enter to Roll Again!")
roll_number = 2
dice2 = random.randint(1, 6)
print(f"2> You got a {dice2}\n")
if roll_number == 2:
break
print("You have used both of your rolls")
total = dice1 + dice2
print("your total for this round is " + str(total) + ".")
if dice1 == dice2:
input ("Lucky!, you get an additional roll : ")
roll_number = 3
dice3 = random.randint(1, 6)
print(f"Bonus Role> You got a {dice3}\n")
total = total + dice3
print("your final total for this round is " + str(total) + ".")
msg = "Press Enter to Start a new round! \n"
round_number
if round_number == 5:
break
print("All the rounds are complete")