diff --git a/totalPoints.py b/totalPoints.py new file mode 100644 index 0000000..eeb3c8f --- /dev/null +++ b/totalPoints.py @@ -0,0 +1,19 @@ +from points import points + +def totalPoints(joueur): + """Calcule le total de points marqués par un joueur.""" + total = 0 + + with open("stats.txt", "r") as fichier: + for ligne in fichier: + data = ligne.split() + if data[0] == joueur and data[1] == "tir-reussi": + total += points(int(data[2]), int(data[3])) + elif data[0] == joueur and data[1] == "lancer-reu": + total += 1 # Lancer franc vaut toujours 1 point + + return total + +# Test +if __name__ == "__main__": + print(totalPoints("J1"))