commit 90da1ba449605f160647aee5c3733adf514ea9c4 Author: Alexi Forestier Date: Thu Mar 9 18:55:48 2023 +0100 projet basket d'Alexi diff --git a/basket_alexi.py b/basket_alexi.py new file mode 100644 index 0000000..b505f90 --- /dev/null +++ b/basket_alexi.py @@ -0,0 +1,64 @@ +from math import sqrt +def reussite(joueur, action): + + success = 0 + attempt = 0 + + with open("stats.txt", "r") as file: + for ligne in file: + lst_elements = ligne.split(' ') + lst_action = lst_elements[1].split('-') + if joueur == lst_elements[0]: + if lst_action[0] == action: + attempt += 1 + if lst_action[1] == "reussi": + success += 1 + print(attempt, success) + return attempt, success + +def totalPoints(joueur): + + total = 0 + + with open("stats.txt", "r") as file: + for ligne in file: + lst_elements = ligne.split(' ') + if joueur == lst_elements[0]: + if lst_elements[1] == 'tir-reussi': + x = int(lst_elements[2]) + y = int(lst_elements[3]) + total = points(x, y) + total + if lst_elements[1] == 'lancer-reu': + total = total + 1 + print(total) + return total + + +def points(x, y): + + norme = 0 + point = 0 + xc = 0 + yc = 300 + xcV = 1000 + ycV = 300 + + if x < 500: + norme = sqrt(((x - xc)**2)+((y - yc)**2)) + if norme < 250: + point = 2 + else: + point = 3 + if x > 500: + norme = sqrt(((x - xcV) ** 2) + ((y - ycV) ** 2)) + if norme < 250: + point = 2 + else: + point = 3 + return point + + + +totalPoints('J1') +reussite('J1', 'tir') +