Save unfinished work

This commit is contained in:
Tipragot 2024-01-07 13:55:57 +01:00
parent b73b4a6de4
commit 9f111aec4e
2 changed files with 12 additions and 0 deletions

View file

@ -1,3 +1,4 @@
import os
from plugins import writing
from engine import CurrentScene, Plugin
from engine.ecs import Entity, World
@ -21,6 +22,8 @@ def new_score(world: World, e: Entity):
try:
post = {"name": name[Text], "score": world[game.Player1Score]}
rq.post(f"https://{IP}/new_score", post)
with open("username.txt", "w") as f:
f.write(name[Text])
world.set(CurrentScene(thanks.THANKS))
except Exception as error:
print("Error with the serveur:", error)
@ -38,6 +41,14 @@ def __spawn_elements(world: World):
Ajoute les éléments du menu dans le monde.
"""
if os.path.exists("username.txt"):
with open("username.txt", "r") as f:
name = f.read()
post = {"name": name, "score": world[game.Player1Score]}
rq.post(f"https://{IP}/new_score", post)
world.set(CurrentScene(thanks.THANKS))
return
world.new_entity().set(SpriteBundle("background.png", -5))
world.new_entity().set(
TextBundle(

1
username.txt Normal file
View file

@ -0,0 +1 @@
david