paulin.pommier
2 years ago
commit
ef0451d026
1 changed files with 43 additions and 0 deletions
@ -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 |
Loading…
Reference in new issue