Adaptation pour l'utilisation du nouveau serveur (#49)

Le serveur n'est pas encore déployé, il faut attendre l'intervention de @corentin

Reviewed-on: #49
Reviewed-by: Corentin <solois.corentin@gmail.com>
Co-authored-by: Tipragot <contact@tipragot.fr>
Co-committed-by: Tipragot <contact@tipragot.fr>
This commit is contained in:
Tipragot 2024-01-10 13:58:59 +00:00 committed by Corentin
parent 6383d2c922
commit 36c8a895d1
2 changed files with 6 additions and 7 deletions

View file

@ -103,8 +103,7 @@ def new_score(world: World, e: Entity):
f.write(name[Text])
try:
post = {"name": name, "score": world[game.Player1Score]}
rq.post(f"https://{IP}/new_score", post)
rq.get(f"https://{IP}/register/{name}/{world[game.Player1Score]}")
world.set(CurrentScene(thanks.THANKS))
except Exception as error:
print("Error with the serveur:", error)

View file

@ -18,9 +18,9 @@ import requests as rq
IP = "pong.cocosol.fr"
def get_scores() -> list[tuple[int, str, str]]:
def get_scores() -> list[dict[str, object]]:
try:
return rq.get(f"https://{IP}/data").json()
return rq.get(f"https://{IP}/scores").json()
except Exception as error:
print("Error with the serveur : " + str(error))
return []
@ -113,10 +113,10 @@ def __spawn_score(world: World):
"""
Ajoute le score dans le monde.
"""
for i, (score, name, _date) in enumerate(get_scores()):
for i, score in enumerate(get_scores()):
world.new_entity().set(
TextBundle(
f"{name}",
f"{score["name"]}",
position=Vec2(render.WIDTH / 2 - 300, 400 + 50 * i),
origin=Vec2(0),
order=1,
@ -125,7 +125,7 @@ def __spawn_score(world: World):
world.new_entity().set(
TextBundle(
f"{score}",
f"{score["score"]}",
position=Vec2(render.WIDTH / 2 + 300, 400 + 50 * i),
origin=Vec2(1, 0),
order=1,