From ef0451d026c1e42567df53c2dd7cc1cd875a4d1b Mon Sep 17 00:00:00 2001 From: "paulin.pommier" Date: Mon, 13 Mar 2023 10:31:12 +0100 Subject: [PATCH] premier commit --- Paulin basket.py | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 Paulin basket.py diff --git a/Paulin basket.py b/Paulin basket.py new file mode 100644 index 0000000..33910f6 --- /dev/null +++ b/Paulin basket.py @@ -0,0 +1,43 @@ +#Paulin + +def reussite(joueur, action): + nb_tentatives = 0 + nb_reussites = 0 + with open("stats.txt", "r") as f: + for line in f: + champs = line.split() + if champs[0] == joueur and champs[1].startswith(action): + nb_tentatives += 1 + if "reussi" in champs[1]: + nb_reussites += 1 + return nb_tentatives, nb_reussites + + +def points(x, y): + if x**2 + (y-300)**2 <= 22500: # cercle de gauche + return 2 + elif (x-1000)**2 + (y-300)**2 <= 22500: # cercle de droite + return 2 + elif x >= 0 and x <= 1000 and y >= 50 and y <= 550: # zone de tir + if x <= 200 or x >= 800 or y <= 150 or y >= 450: # extérieur + return 3 + else: # intérieur + return 2 + else: # hors terrain + return 0 + + +def totalPoints(joueur): + total = 0 + with open("stats.txt", "r") as f: + for line in f: + champs = line.split() + if champs[0] == joueur: + if champs[1].startswith("tir"): + x, y = int(champs[2]), int(champs[3]) + pts = points(x, y) + total += pts + elif champs[1].startswith("lancer"): + if "reussi" in champs[1]: + total += 1 + return total \ No newline at end of file