Comments update

Added quite a bit of comments and some very small QoL changes
This commit is contained in:
Xameren 2024-11-20 22:44:14 +01:00 committed by GitHub
parent 67cf491bec
commit a3e88a6b2f
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -3,8 +3,10 @@ import time
import sys import sys
import json import json
import os import os
os.system("title " + "Xameren's CS2 evaluation script") os.system("title " + "Xameren's CS2 evaluation script")
Kills = 0 Kills = 0
Deaths = 0 Deaths = 0
Assists = 0 Assists = 0
@ -24,9 +26,18 @@ Wins = 0
Draws = 0 Draws = 0
Losses = 0 Losses = 0
SaveFile = "Savefile.json" SaveFile = "Savefile.json"
GameList = [] GameList = []
# Meant for changing the color of print statements
# print(f"This text would be normal {RED} This text would be red {END} This text would go back to being normal")
# Be aware that it does not automatically reset the color for the next line.
# print(f"{RED} This text will be red")
# print("But this would also be red")
GREEN = '\033[92m' GREEN = '\033[92m'
YELLOW = '\033[93m' YELLOW = '\033[93m'
RED = '\033[91m' RED = '\033[91m'
@ -35,39 +46,34 @@ END = '\033[0m'
def rating(Newkills, NewDeaths, NewAssists, NewHS, NewDamage, NewRounds, NewWin, AddMatchTotal, MatchDate = "N/A"): def rating(Newkills, NewDeaths, NewAssists, NewHS, NewDamage, NewRounds, NewWin, AddMatchTotal, MatchDate = "N/A"):
global TotalRating, Rounds, Kills, Deaths, Assists, HS, Damage, Matches, TotalAssistRating, TotalDamageRating, TotalHSrating,TotalKillRating, GameList, TotalTotalRating, Wins, Draws, Losses global TotalRating, Rounds, Kills, Deaths, Assists, HS, Damage, Matches, TotalAssistRating, TotalDamageRating, TotalHSrating,TotalKillRating, GameList, TotalTotalRating, Wins, Draws, Losses
KillRating = round((Newkills/NewDeaths)/2, 3)
AssistRating = round(NewAssists/8, 3)
HSrating = round(NewHS/100, 3)
DamageRating = NewDamage/(135*NewRounds)
KillRating = min(Newkills/(NewRounds*1.25), 1)*0.4+min((Newkills/NewDeaths)/1.25, 1)*0.4-min(NewDeaths/NewRounds, 1)*0.2
AssistRating= min(NewAssists/(NewRounds*0.5), 1)*0.6+min(NewAssists/(NewAssists+Newkills), 1)*0.4
HSrating = NewHS/100*0.6+min(NewHS/100*Newkills/Newkills, 1)*0.4
DamageRating = min(NewDamage/(NewRounds*125), 1)*0.5+min(Newkills/(NewRounds*1.25), 1)*0.3+min(NewDamage/Newkills/125, 1)*0.2
# Calculates your rating
KillRating = min(min(Newkills/(NewRounds*1.25), 1)*0.4+min((Newkills/NewDeaths)/1.25, 1)*0.4-min(NewDeaths/NewRounds, 1)*0.2, 1)
AssistRating= min(min(NewAssists/(NewRounds*0.5), 1)*0.6+min(NewAssists/(NewAssists+Newkills), 1)*0.4, 1)
HSrating = min(NewHS/100*0.6+min(NewHS/100*Newkills/Newkills, 1)*0.4, 1)
DamageRating = min(min(NewDamage/(NewRounds*125), 1)*0.5+min(Newkills/(NewRounds*1.25), 1)*0.3+min(NewDamage/Newkills/125, 1)*0.2, 1)
# In kill rating, your kills per round is worth 40% of the rating, your kills per deaths is worth 40% and your deaths per round is worth 20%
# In assist rating, your Assits per round is worth 60% and your assists per (Kills+assists) is worth 40%
# In HS rating, your headshot percentage is worth 60% and your headshot kills are worth 40%
# In damage rating, your damage per round is worth 50%, your kills per round are worth 30% and your damage per kills are worth 20%
# Sets the current date as the
if AddMatchTotal: if AddMatchTotal:
MatchDate = datetime.now().strftime("%d/%m/%Y") MatchDate = datetime.now().strftime("%d/%m/%Y")
if NewWin == "y":
Wins += 1
elif NewWin == "draw":
Draws += 1
elif NewWin == "n":
Losses += 1
if KillRating > 1:
KillRating = 1
if AssistRating > 1:
AssistRating = 1
if HSrating > 1:
HSrating = 1
if DamageRating > 1:
DamageRating = 1
TotalRating = KillRating*0.3+DamageRating*0.3+HSrating*0.2+AssistRating*0.2 TotalRating = KillRating*0.3+DamageRating*0.3+HSrating*0.2+AssistRating*0.2
#This will add the statistics to the profile
if AddMatchTotal: if AddMatchTotal:
# Adds a win, loss, or a draw to the stats
if NewWin == "y":
Wins += 1
elif NewWin == "draw" or NewWin == "d":
Draws += 1
elif NewWin == "n":
Losses += 1
Kills += Newkills Kills += Newkills
Deaths += NewDeaths Deaths += NewDeaths
Assists += NewAssists Assists += NewAssists
@ -84,55 +90,80 @@ def rating(Newkills, NewDeaths, NewAssists, NewHS, NewDamage, NewRounds, NewWin,
TotalTotalRating = 0.4*TotalKillRating+0.3*TotalDamageRating+0.2*TotalHSrating+0.1*TotalAssistRating TotalTotalRating = 0.4*TotalKillRating+0.3*TotalDamageRating+0.2*TotalHSrating+0.1*TotalAssistRating
#Adds a match to the list of games in the format of K:, D:, A:, HS:, DMG:, Rounds:, Win:, Date:
GameList.insert(0, f"K: {Newkills}, D: {NewDeaths}, A: {NewAssists}, HS: {NewHS}, DMG: {NewDamage}, Rounds: {NewRounds}, Win: {NewWin}, Date: {MatchDate}") GameList.insert(0, f"K: {Newkills}, D: {NewDeaths}, A: {NewAssists}, HS: {NewHS}, DMG: {NewDamage}, Rounds: {NewRounds}, Win: {NewWin}, Date: {MatchDate}")
matchstats(Newkills, NewDeaths, NewAssists, NewHS, NewDamage, NewRounds, NewWin, AssistRating, HSrating, KillRating, DamageRating, TotalRating, MatchDate) matchstats(Newkills, NewDeaths, NewAssists, NewHS, NewDamage, NewRounds, NewWin, AssistRating, HSrating, KillRating, DamageRating, TotalRating, MatchDate)
def register(): def register():
global Username, Kills, Deaths, Assists, HS, Damage, Matches, WR global Username, Kills, Deaths, Assists, HS, Damage, Matches, WR
reset = True reset = True
finished = False
while reset: while reset:
print("Welcome to xameren's CS2 evaluation tool") print("Welcome to xameren's CS2 evaluation tool")
print("What's your Username?") print("What's your Username?")
Username = input("Your Username:") Username = input("Your Username:")
print("Do you want to import your stats?")
print("You will be prompted to fill your KD, kills, assists, deaths, HS% and damage from your last round")
while True: while True:
fillornot = input("(y/n) ") print("\033[H\033[J", end="")
print("Do you want to import your stats?")
print("You will be prompted to fill your KD, kills, assists, deaths, HS% and damage from your last round (y/n)")
fillornot = input("")
print("You can always quit by saying \"q\"")
if fillornot.lower() == "y": if fillornot.lower() == "y":
while True: while True:
try:
Ki = int(input("Kills: ")) try:
De = int(input("Deaths: ")) # Get the input, then make it an intiger. If its impossible, check if the user wrote "q". If yes, rerun it. If not, leave.
As = int(input("Assists: ")) Ki = De = As = Hs = Da = Ro = Wi = 0
Hs = int(input("HS%: ")) Ki = input("Kills: ")
Da = int(input("Damage: ")) Ki = int(Ki)
Ro = int(input("Rounds: ")) De = input("Deaths: ")
De = int(De)
As = input("Assists: ")
As = int(As)
Hs = input("HS%: ")
Hs = int(Hs)
Da = input("Damage: ")
Da = int(Da)
Ro = input("Rounds: ")
Ro = int(Ro)
while True: while True:
Wi = input("Did you win? (y/draw/n)").lower() Wi = input("Did you win? (y/d/n)").lower()
if Wi == "y" or Wi == "n" or Wi == "draw": if Wi == "y" or Wi == "n" or Wi == "d":
finished = True
break
elif Wi == "q":
break break
break break
except ValueError: except ValueError:
# If the user wants to quit, exit the while true statement
print(Ki)
if Ki == "q" or De == "q" or As == "q" or Hs == "q" or Da == "q" or Ro == "q" or Wi == "q":
break
print("Please enter valid numbers") print("Please enter valid numbers")
correctregister = input("Is this all correct? (y/N) ").lower() if Wi == "q":
if correctregister == "y": break
reset = False if finished:
rating(Ki, De, As, Hs, Da, Ro, Wi, AddMatchTotal = True) correctregister = input("Is this all correct? (y/N) ").lower()
break # if all of this is correct, rate it
if correctregister == "y":
reset = False
rating(Ki, De, As, Hs, Da, Ro, Wi, AddMatchTotal = True)
break
# if the user does not want to fill their last round statistics, dont force him
elif fillornot.lower() == "n": elif fillornot.lower() == "n":
print("Alright, no problem") print("Alright, no problem")
reset = False reset = False
time.sleep(1) time.sleep(1)
break break
# Calculates win rate
def WRcalc(): def WRcalc():
if Losses == 0: if Losses == 0:
return 100 return 100
else: else:
return round((Wins/Matches)*100, 2) return round((Wins/Matches)*100, 2)
# Determines what color a statistic should be (must provide a number on a scale of 1 to 100) (Low = bad, High = good)
def Coloring(numbah): def Coloring(numbah):
if numbah < 33: if numbah < 33:
return RED return RED
@ -140,6 +171,8 @@ def Coloring(numbah):
return YELLOW return YELLOW
else: else:
return GREEN return GREEN
# Determines what color a statistic should be (must provide a number on a scale of 1 to 100) (Low = good, High = bad)
def ColoringLow(numbah): def ColoringLow(numbah):
if numbah < 33: if numbah < 33:
return GREEN return GREEN
@ -163,6 +196,9 @@ def matchstats(Newkills, NewDeaths, NewAssists, NewHS, NewDamage, NewRounds, New
print(f" Match {f"{GREEN}Won" if NewWin == "y" else f"{RED}Lost" if NewWin == "n" else "Drawn"}{END}") print(f" Match {f"{GREEN}Won" if NewWin == "y" else f"{RED}Lost" if NewWin == "n" else "Drawn"}{END}")
print(f" Rounds: {NewRounds}") print(f" Rounds: {NewRounds}")
spaces = " " spaces = " "
#print(f"Coloring()" Statistic: Value
# Coloring is for getting the appropriate color to the value of the statistic
# The value must be provided as a number from 1-100, like a percentage
print() print()
print(f"{Coloring(TotalRating*100)}XMRating: {round(TotalRating*100, 3)}{END}") print(f"{Coloring(TotalRating*100)}XMRating: {round(TotalRating*100, 3)}{END}")
print(f"{Coloring(HSrating*100)}{spaces}HS rating: {round(HSrating*100, 3)}{END}") print(f"{Coloring(HSrating*100)}{spaces}HS rating: {round(HSrating*100, 3)}{END}")
@ -204,13 +240,6 @@ def profile():
global Username, Matches, Kills, HS, Rounds, Damage, Deaths, Assists global Username, Matches, Kills, HS, Rounds, Damage, Deaths, Assists
while True: while True:
"""
TotalAssistRating += AssistRating
TotalDamageRating += DamageRating
TotalHSrating += HSrating
TotalKillRating += KillRating
"""
print("\033[H\033[J", end="") print("\033[H\033[J", end="")
print(f"Name: {Username}") print(f"Name: {Username}")
print() print()
@ -269,26 +298,31 @@ def profile():
print(f" {Coloring(round(Assists/Matches, 2)/8*100)}Average/Match: {round(Assists/Matches, 2)}{END}") print(f" {Coloring(round(Assists/Matches, 2)/8*100)}Average/Match: {round(Assists/Matches, 2)}{END}")
print(f" {Coloring(round(Assists/Rounds, 2)/0.4*100)}Average/Round: {round(Assists/Rounds, 2)}{END}") print(f" {Coloring(round(Assists/Rounds, 2)/0.4*100)}Average/Round: {round(Assists/Rounds, 2)}{END}")
print("\n") print("\n")
except Exception as e: # This gets printed if the user has not provided any matches yet
print("error ", e) except Exception:
print("There are no stats to judge you... yet.") print("There are no stats for this script to judge you... yet.\n")
print("c) Change username") print("c) Change username")
print("r) Recent matches") print("r) Recent matches")
print("q) Back to the main menu") print("q) Back to the main menu")
inputprofile = input().lower() inputprofile = input().lower()
# Changes the username
if inputprofile == "c": if inputprofile == "c":
newuser = input("Your new Username will be: ") newuser = input("Your new Username will be: ")
Username = newuser Username = newuser
elif inputprofile == "xamseccod": elif inputprofile == "xamseccod":
print("eGFtZXJlbiBtYWRlIHRoaXM=") print("eGFtZXJlbiBtYWRlIHRoaXM=")
# Shows the list of recently played matches
elif inputprofile == "r": elif inputprofile == "r":
page = 0 page = 0
while True: while True:
print("\033[H\033[J", end="") print("\033[H\033[J", end="")
print("Recent matches\n") print("Recent matches\n")
# Shows a list of 15 matches. This is multiplied by the variable "page" to allow the user to see more than
# 15 matches in this menu
for i, item in enumerate(GameList[0+(page*15):15+(page*15)]): for i, item in enumerate(GameList[0+(page*15):15+(page*15)]):
Colormatches = GameList[i] Colormatches = GameList[i]
values = dict(stritem.split(": ") for stritem in Colormatches.split(", ")) values = dict(stritem.split(": ") for stritem in Colormatches.split(", "))
# If its a win, make it green. If not, make it red. Then print the number of the match and the appropriate game from the GameList
if values["Win"] == "y": if values["Win"] == "y":
print(f" {GREEN}Match {int(i)+(page*15)+1} - {item}{END}") print(f" {GREEN}Match {int(i)+(page*15)+1} - {item}{END}")
elif values["Win"] == "n": elif values["Win"] == "n":
@ -298,7 +332,11 @@ def profile():
print(f"\n1 - {len(GameList)}) to view a match") print(f"\n1 - {len(GameList)}) to view a match")
# If the GameList contains more than 16 matches
if len(GameList) > 15: if len(GameList) > 15:
# Shows you the number of matches youre viewing and the total number of matches
# if = "Showing 16 - 30 out of 45 matches"
# else = "Showing 31 - 45 out of 45 matches"
if page*15+15 < len(GameList): if page*15+15 < len(GameList):
print(f"\nShowing {page*15+1} - {page*15+15} out of {len(GameList)} matches\n") print(f"\nShowing {page*15+1} - {page*15+15} out of {len(GameList)} matches\n")
else: else:
@ -311,14 +349,16 @@ def profile():
leaveinput = input() leaveinput = input()
# Newkills, NewDeaths, NewAssists, NewHS, NewDamage, NewRounds, NewWin, AddMatchTotal
try: try:
# Finds the match youre looking at, translates it to the correct format, and then rates it
Getstats = int(leaveinput) Getstats = int(leaveinput)
if 1 <= Getstats <= len(GameList): if 1 <= Getstats <= len(GameList):
Getstats -= 1 Getstats -= 1
DeletedMatch = GameList[Getstats] DeletedMatch = GameList[Getstats]
values = dict(stritem.split(": ") for stritem in DeletedMatch.split(", ")) values = dict(stritem.split(": ") for stritem in DeletedMatch.split(", "))
# If it doesnt contain a date, pass it without one
try: try:
rating(int(values["K"]), int(values["D"]), int(values["A"]), int(values["HS"]), int(values["DMG"]), int(values["Rounds"]), values["Win"], False, values["Date"]) rating(int(values["K"]), int(values["D"]), int(values["A"]), int(values["HS"]), int(values["DMG"]), int(values["Rounds"]), values["Win"], False, values["Date"])
except Exception: except Exception:
@ -327,16 +367,19 @@ def profile():
except Exception: except Exception:
if leaveinput == "q": if leaveinput == "q":
break break
# Go to the next menu if its possible
elif leaveinput == "n": elif leaveinput == "n":
if len(GameList) > page*15+15: if len(GameList) > page*15+15:
page += 1 page += 1
else: else:
print("This is the last page.") print("This is the last page.")
# Go to the last menu if its possible
elif leaveinput == "b": elif leaveinput == "b":
if 0+(page*15) > 0: if 0+(page*15) > 0:
page -= 1 page -= 1
else: else:
print("This is the first page.") print("This is the first page.")
# Show the help menu
if leaveinput == "h": if leaveinput == "h":
print("\033[H\033[J", end="") print("\033[H\033[J", end="")
print("Help") print("Help")
@ -345,49 +388,68 @@ def profile():
print(" A - Assists") print(" A - Assists")
print(" HS - Headshot percentage") print(" HS - Headshot percentage")
print(" DMG - Damage dealt") print(" DMG - Damage dealt")
print(" Win - If you won (y), lost (n), or tied (draw)") print(" Win - If you won (y), lost (n), or drawn (d)")
print("Enter anything to exit") print("Enter anything to exit")
input() input()
elif inputprofile == "q": elif inputprofile == "q":
break break
def addmatch(): def addmatch():
Quit = False #quitadd means that the user does not want to add a match anymore. Quit Add
while True: quitadd = False
while not quitadd:
# Asks the user for statistics, adds a match to the game list and then shows a rating screen
print("\033[H\033[J", end="") print("\033[H\033[J", end="")
print("Adding a match") print("Adding a match")
print("Please put in your statistics of the match") print("Please put in your statistics of the match")
print("Or say \"q\" to exit")
try: try:
Newkills = int(input("Kills: ")) Newkills = NewDeaths = NewAssists = NewHS = NewDamage = NewRounds = 0
NewDeaths = int(input("Deaths: ")) Newkills = input("Kills: ")
NewAssists = int(input("Assists: ")) Newkills = int(Newkills)
NewHS = int(input("HS%: ")) NewDeaths = input("Deaths: ")
NewDamage = int(input("Damage: ")) NewDeaths = int(NewDeaths)
NewRounds = int(input("Rounds: ")) NewAssists = input("Assists: ")
NewAssists = int(NewAssists)
NewHS = input("HS%: ")
NewHS = int(NewHS)
NewDamage = input("Damage: ")
NewDamage = int(NewDamage)
NewRounds = input("Rounds: ")
NewRounds = int(NewRounds)
while True: while True:
WINyn = input("Did you win? (y/draw/n) ").lower() WINyn = input("Did you win? (y/d/n) ").lower()
if WINyn == "n" or WINyn == "y" or WINyn == "draw": if WINyn == "n" or WINyn == "y" or WINyn == "d":
NewWin = WINyn NewWin = WINyn
break break
if WINyn == "q":
matchsure = input("Is this all correct? (y/n) ").lower() quitadd = True
if matchsure == "y": if not quitadd:
break matchsure = input("Is this all correct? (y/n) ").lower()
elif matchsure == "n": if matchsure == "y":
Quit = True break
break elif matchsure == "n":
quitadd = True
break
except ValueError: except ValueError:
# Stop if the user wants to leave
if Newkills == "q" or NewDeaths == "q" or NewAssists == "q" or NewHS == "q" or NewDamage == "q" or NewRounds == "q":
quitadd = True
print("Please only provide a number") print("Please only provide a number")
if not Quit: if not quitadd:
rating(Newkills, NewDeaths, NewAssists, NewHS, NewDamage, NewRounds, NewWin, True) rating(Newkills, NewDeaths, NewAssists, NewHS, NewDamage, NewRounds, NewWin, True)
def removematch(): def removematch():
global Kills, Deaths, Assists, HS, Damage, Rounds, Wins, Losses, Draws, Matches, TotalKillRating, TotalAssistRating, TotalHSrating, TotalDamageRating global Kills, Deaths, Assists, HS, Damage, Rounds, Wins, Losses, Draws, Matches, TotalKillRating, TotalAssistRating, TotalHSrating, TotalDamageRating
# Asks the user to choose a match to remove, then removes that match
print("\033[H\033[J", end="") print("\033[H\033[J", end="")
page = 0 page = 0
while True: while True:
print("\033[H\033[J", end="") print("\033[H\033[J", end="")
print("Which match would you like to remove?\n") print("Which match would you like to remove?\n")
# Shows a list of 15 matches. This is multiplied by the variable "page" to allow the user to see more than
# 15 matches in this menu
for i, item in enumerate(GameList[0+(page*15):15+(page*15)]): for i, item in enumerate(GameList[0+(page*15):15+(page*15)]):
Colormatches = GameList[i] Colormatches = GameList[i]
@ -398,6 +460,10 @@ def removematch():
print(f" {RED}Match {int(i)+(page*15)+1} - {item}{END}") print(f" {RED}Match {int(i)+(page*15)+1} - {item}{END}")
else: else:
print(f" Match {int(i)+(page*15)+1} - {item}") print(f" Match {int(i)+(page*15)+1} - {item}")
# Shows you the number of matches youre viewing and the total number of matches
# if = "Showing 16 - 30 out of 45 matches"
# else = "Showing 31 - 45 out of 45 matches"
if page*15+15 < len(GameList): if page*15+15 < len(GameList):
print(f"\nShowing {page*15+1} - {page*15+15} out of {len(GameList)} matches\n") print(f"\nShowing {page*15+1} - {page*15+15} out of {len(GameList)} matches\n")
else: else:
@ -426,7 +492,7 @@ def removematch():
Wins -= 1 Wins -= 1
elif values["Win"] == "n": elif values["Win"] == "n":
Losses -= 1 Losses -= 1
elif values["Win"] == "draw": elif values["Win"] == "draw" or values["Win"] == "d":
Draws -= 1 Draws -= 1
""" """
@ -447,7 +513,7 @@ def removematch():
NewDamage = int(values["DMG"]) NewDamage = int(values["DMG"])
# Removes the stats of the match from the totals. Nothing much to see here.
if round(round(min(Newkills/(NewRounds*1.25), 1)*0.4+min((Newkills/NewDeaths)/1.25, 1)*0.4-min(NewDeaths/NewRounds, 1)*0.2, 3)/2, 3) < 1: if round(round(min(Newkills/(NewRounds*1.25), 1)*0.4+min((Newkills/NewDeaths)/1.25, 1)*0.4-min(NewDeaths/NewRounds, 1)*0.2, 3)/2, 3) < 1:
TotalKillRating -= round(min(Newkills/(NewRounds*1.25), 1)*0.4+min((Newkills/NewDeaths)/1.25, 1)*0.4-min(NewDeaths/NewRounds, 1)*0.2, 3) TotalKillRating -= round(min(Newkills/(NewRounds*1.25), 1)*0.4+min((Newkills/NewDeaths)/1.25, 1)*0.4-min(NewDeaths/NewRounds, 1)*0.2, 3)
else: else:
@ -472,6 +538,7 @@ def removematch():
GameList.pop(Chosen) GameList.pop(Chosen)
print("\033[H\033[J", end="") print("\033[H\033[J", end="")
except Exception as e: except Exception as e:
# quits, goes to a new page or goes back a page
if Chosen1 == "q": if Chosen1 == "q":
break break
elif Chosen1 == "n": elif Chosen1 == "n":
@ -482,6 +549,7 @@ def removematch():
page -= 1 page -= 1
def mainmenu(): def mainmenu():
while True: while True:
# Saves and shows the main menu
save() save()
print("\033[H\033[J", end="") print("\033[H\033[J", end="")
print(f"Welcome, {BOLD}{Username}{END}") print(f"Welcome, {BOLD}{Username}{END}")
@ -504,6 +572,7 @@ def load():
global Username, GameList, Kills, Deaths, Assists, HS, WR, Damage, TotalTotalRating, TotalKillRating, TotalAssistRating, TotalHSrating, TotalDamageRating, Rounds, Matches, Wins, Draws, Losses global Username, GameList, Kills, Deaths, Assists, HS, WR, Damage, TotalTotalRating, TotalKillRating, TotalAssistRating, TotalHSrating, TotalDamageRating, Rounds, Matches, Wins, Draws, Losses
if os.path.exists(SaveFile): if os.path.exists(SaveFile):
try: try:
# Loads all the appropriate variables from the save file
print("Saving..") print("Saving..")
with open(SaveFile, 'r') as file: with open(SaveFile, 'r') as file:
GameState = json.load(file) GameState = json.load(file)
@ -532,7 +601,7 @@ def load():
def save(): def save():
global Username, GameList, Kills, Deaths, Assists, HS, WR, Damage, TotalTotalRating, TotalKillRating, TotalAssistRating, TotalHSrating, TotalDamageRating, Rounds, Matches, Wins, Draws, Losses global Username, GameList, Kills, Deaths, Assists, HS, WR, Damage, TotalTotalRating, TotalKillRating, TotalAssistRating, TotalHSrating, TotalDamageRating, Rounds, Matches, Wins, Draws, Losses
# Saves all the appropriate variables to the save file
GameState = { GameState = {
"Username": Username, "Username": Username,
"Kills": Kills, "Kills": Kills,
@ -558,6 +627,7 @@ def save():
json.dump(GameState, file) json.dump(GameState, file)
def start(): def start():
# Starts the script. If the save file exists, it loads and puts you to the main menu, else, it prompts you to register
if os.path.exists(SaveFile): if os.path.exists(SaveFile):
load() load()
mainmenu() mainmenu()
@ -565,4 +635,4 @@ def start():
register() register()
mainmenu() mainmenu()
start() start()