You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
51 lines
1.5 KiB
51 lines
1.5 KiB
"""
|
|
Fonctions non documentées.
|
|
Des mélanges dans la fonction `points`.
|
|
Tirs ratés non pris en charge dans `totalPoints`.
|
|
Problèmes sur les lancers réussis (lancer-reu).
|
|
Note : 14
|
|
"""
|
|
|
|
#Walid et Léo
|
|
|
|
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
|