Done!

This commit is contained in:
Mawoka
2022-10-04 20:04:08 +02:00
parent d52f8cc017
commit 6d0b88b56a
6 changed files with 65 additions and 17 deletions
+6 -1
View File
@@ -43,6 +43,7 @@ class _JoinGameData(BaseModel):
username: str
game_pin: str
captcha: str | None
custom_field: str | None
@sio.event
@@ -104,7 +105,11 @@ async def join_game(sid: str, data: dict):
redis_res = GameSession.parse_raw(redis_res)
await redis.set(f"game_session:{data.game_pin}:players:{data.username}", sid, ex=18000)
await redis.sadd(f"game_session:{data.game_pin}:players", GamePlayer(username=data.username, sid=sid).json())
print(GamePlayer(username=data.username, sid=sid).json())
if data.custom_field == "":
data.custom_field = None
print(data.custom_field)
if data.custom_field is not None:
await redis.hset(f"game:{data.game_pin}:player:custom_fields", data.username, data.custom_field)
# await redis.set(
# f"game_session:{data.game_pin}",
# GameSession(admin=redis_res.admin, game_id=redis_res.game_id, answers=[]).json(),