Adaptation pour l'utilisation du nouveau serveur #49

Merged
CoCo_Sol merged 1 commit from new-server into main 2024-01-10 13:59:01 +00:00
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,