From 2c201b68cbadf0c85bf5d8862747624de36862ee Mon Sep 17 00:00:00 2001 From: Elith Date: Sun, 16 Mar 2025 18:45:08 +0100 Subject: [PATCH] Calcul les points totaux d'un joueur --- totalPoints.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) create mode 100644 totalPoints.py 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"))