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.
64 lines
1.5 KiB
64 lines
1.5 KiB
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')
|
|
|
|
|