Привет, я пытаюсь выполнить мой курс по информатике, который предназначен для проверки моих способностей (одна из них, которую я выбрал, была игра в кости. Нам разрешено использовать ресурсы, поэтому я пришел сюда, и мне нужна помощь, когда яЯ должен создать систему подсчета очков, но мне нужно, чтобы она менялась с круглыми числами, чтобы в нее можно было добавлять переменные для получения окончательного результата. Любая помощь будет отличной! Я приложил свой код ниже:
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")