Adaptation pour l'utilisation du nouveau serveur #49
|
@ -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)
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue