dépôt creer pour le projet basket
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.

50 lines
1.7 KiB

import re
def reussite(joueur, action):
Tentatives = 0
reussite_sur_laction = 0
with open(r"Basket gagadya.txt", 'r') as f:
f.readline()
for ligne in f:
ligne = ligne.strip()
info = re.split(r' |-', ligne)
#Je sors "re.split(r' |-', ligne) d'un forum car j'ai
if info[0] == joueur and info[1] == action:
Tentatives += 1
if info[2] in ["reussi", "reu", "faite"]:
reussite_sur_laction += 1
print(f"Tentatives : {Tentatives}")
print(f"Réussites : {reussite_sur_laction}")
return Tentatives, reussite_sur_laction
def points(x, y):
niqat = 0
centre1 = (0, 300)
centre2 = (1000, 300)
rayon = 250
dans_cercle1 = (x - centre1[0])**2 + (y - centre1[1])**2 <= rayon**2
dans_cercle2 = (x - centre2[0])**2 + (y - centre2[1])**2 <= rayon**2
if dans_cercle1 or dans_cercle2 :
niqat += 2
else :
niqat += 3
print(f"Les points pour un tir à x={x} et y={y} sont : {niqat}")
return niqat
def totalpoints (joueur):
niqat = 0
with open("Basket gagadya.txt") as f:
f.readline()
for ligne in f:
ligne = ligne.strip()
info = re.split(r' |-', ligne)
if info :
x, y = int(info[3]), int(info[4])
if info[0] == joueur :
if info[2] in ["reussi"] :
niqat += points(x, y)
if info[2] in ["reu"] :
niqat += 1
print(f"Les points pour un lancée franc sont : 1")
print(f"Totals points : {niqat}")
totalpoints ("J2")