Save unfinished work

This commit is contained in:
Tipragot 2024-01-10 08:45:57 +01:00
parent da8f244026
commit 894d085a8c
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]) f.write(name[Text])
try: try:
post = {"name": name, "score": world[game.Player1Score]} rq.get(f"https://{IP}/register/{name}/{world[game.Player1Score]}")
rq.post(f"https://{IP}/new_score", post)
world.set(CurrentScene(thanks.THANKS)) world.set(CurrentScene(thanks.THANKS))
except Exception as error: except Exception as error:
print("Error with the serveur:", error) print("Error with the serveur:", error)

View file

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