From eb282aa52e64bb79e2b3d7cea8b5907829fb34a1 Mon Sep 17 00:00:00 2001 From: fheinrich <fheinrich@techfak.uni-bielefeld.de> Date: Thu, 7 Mar 2024 12:45:41 +0100 Subject: [PATCH] Default value in WebsocketMessage Basemodel --- cooperative_cuisine/game_server.py | 3 ++- cooperative_cuisine/pygame_2d_vis/gui.py | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/cooperative_cuisine/game_server.py b/cooperative_cuisine/game_server.py index 1669539c..e45065f9 100644 --- a/cooperative_cuisine/game_server.py +++ b/cooperative_cuisine/game_server.py @@ -625,7 +625,7 @@ class PlayerRequestType(Enum): class WebsocketMessage(BaseModel): type: str - action: None | Action + action: None | Action = None player_hash: str class Config: @@ -644,6 +644,7 @@ def manage_websocket_message(message: str, client_id: str) -> PlayerRequestResul """ message_dict = json.loads(message) request_type = None + try: ws_message = WebsocketMessage(**message_dict) request_type = PlayerRequestType(ws_message.type) diff --git a/cooperative_cuisine/pygame_2d_vis/gui.py b/cooperative_cuisine/pygame_2d_vis/gui.py index 3b9ed6a7..0e756097 100644 --- a/cooperative_cuisine/pygame_2d_vis/gui.py +++ b/cooperative_cuisine/pygame_2d_vis/gui.py @@ -1506,7 +1506,6 @@ class PyGameGUI: websocket = connect(self.websocket_url + player_info["client_id"]) message_dict = { "type": PlayerRequestType.READY.value, - "action": None, "player_hash": player_info["player_hash"], } ws_message = WebsocketMessage(**message_dict) -- GitLab