From 36c8a895d10eef92ec98abda093fb20363d77d9b Mon Sep 17 00:00:00 2001 From: Tipragot Date: Wed, 10 Jan 2024 13:58:59 +0000 Subject: [PATCH] Adaptation pour l'utilisation du nouveau serveur (#49) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Le serveur n'est pas encore déployé, il faut attendre l'intervention de @corentin Reviewed-on: https://git.tipragot.fr/raphael/ponguito/pulls/49 Reviewed-by: Corentin Co-authored-by: Tipragot Co-committed-by: Tipragot --- src/scenes/game_over.py | 3 +-- src/scenes/menu.py | 10 +++++----- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/src/scenes/game_over.py b/src/scenes/game_over.py index 7e961ba..2228ea7 100644 --- a/src/scenes/game_over.py +++ b/src/scenes/game_over.py @@ -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) diff --git a/src/scenes/menu.py b/src/scenes/menu.py index 92a4149..e758a9e 100644 --- a/src/scenes/menu.py +++ b/src/scenes/menu.py @@ -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,