FORESTIER Alexi
2 years ago
commit
90da1ba449
1 changed files with 64 additions and 0 deletions
@ -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') |
|||
|
Loading…
Reference in new issue